Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: healthcheck #1

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Changelog
1.0a4 (unreleased)
------------------

- Nothing changed yet.
- Add plausible server healthcheck into plausible control panel
[remdub]


1.0a3 (2024-02-20)
Expand Down
4 changes: 3 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ Plausible integration into Plone 5 and Plone 6 classic UI
Features
--------

- Plausible browserview
- Statistics browserview @@plausible-view
- Optional link to statistics browserview in user menu
- Plausible server healthcheck in control panel



Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
lang="en"
metal:use-macro="here/prefs_main_template/macros/master"
i18n:domain="plone">

<body>
<style>
.card {
position: relative;
display: flex;
flex-direction: column;
min-width: 0;
word-wrap: break-word;
background-color: #fff;
background-clip: border-box;
border: 1px solid rgba(0, 0, 0, .125);
border-radius: .25rem;
margin-bottom: 1em;
}
.card-header {
padding: .5rem 1rem;
margin-bottom: 0;
background-color: rgba(0, 0, 0, .03);
border-bottom: 1px solid rgba(0, 0, 0, .125);
}
.card-body {
flex: 1 1 auto;
padding: 1rem 1rem;
}
</style>
<div metal:fill-slot="prefs_configlet_main">

<h1 class="documentFirstHeading" tal:content="view/label">View Title</h1>

<div metal:use-macro="context/global_statusmessage/macros/portal_message">
Portal status message
</div>

<div id="content-core">
<div class="card" tal:condition="here/@@plausible-utils/is_plausible_set">
<div class="card-header">
<span i18n:domain="collective.plausible" i18n:translate="">Configuration state</span>
</div>
<div class="card-body portalMessage warning" role="status" >
<span i18n:domain="collective.plausible" i18n:translate="">Plausible parameters are set (here or environment variables)</span>
</div>
<div class="card-header">
<span i18n:domain="collective.plausible" i18n:translate="">Plausible server healthcheck</span>
</div>
<div class="card-body portalMessage warning" role="status">
<ul tal:condition="here/@@plausible-utils/get_plausible_instance_healthcheck">
<li><span i18n:domain="collective.plausible" i18n:translate="">Clickhouse :&nbsp;</span><span tal:content="here/@@plausible-utils/get_plausible_instance_healthcheck/clickhouse" /></li>
<li><span i18n:domain="collective.plausible" i18n:translate="">Postgresql :&nbsp;</span><span tal:content="here/@@plausible-utils/get_plausible_instance_healthcheck/clickhouse" /></li>
<li><span i18n:domain="collective.plausible" i18n:translate="">Sites cache :&nbsp;</span><span tal:content="here/@@plausible-utils/get_plausible_instance_healthcheck/clickhouse" /></li>
</ul>
<span i18n:domain="collective.plausible" i18n:translate="" tal:condition="not: here/@@plausible-utils/get_plausible_instance_healthcheck">Error while trying to connect to Plausible API</span>
</div>
</div>
<div class="card" tal:condition="not: here/@@plausible-utils/is_plausible_set">
<div class="card-header">
<span i18n:domain="collective.plausible" i18n:translate="">Configuration state</span>
</div>
<div class="card-body portalMessage warning" role="status" >
<span i18n:domain="collective.plausible" i18n:translate="">Plausible parameters are not set yet. You can define it here or via environment variables.</span>
</div>
</div>
<div class="card">
<div class="card-header">
<span>Paramètres de Plausible</span>
</div>
<div id="layout-contents">
<span tal:replace="structure view/contents" />
</div>
</div>
</div>

</div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
from collective.plausible import _
from collective.plausible.interfaces import ICollectivePlausibleLayer
from plone.app.registry.browser.controlpanel import ControlPanelFormWrapper
from plone.app.registry.browser.controlpanel import RegistryEditForm
from plone.restapi.controlpanels import RegistryConfigletPanel
from plone.z3cform import layout
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from zope import schema
from zope.component import adapter
from zope.interface import Interface
Expand Down Expand Up @@ -50,8 +50,12 @@ class PlausibleControlPanel(RegistryEditForm):
label = _("Plausible Control Panel")


class ControlPanelFormView(layout.FormWrapper):
index = ViewPageTemplateFile("controlpanel.pt")


PlausibleControlPanelView = layout.wrap_form(
PlausibleControlPanel, ControlPanelFormWrapper
PlausibleControlPanel, ControlPanelFormView
)


Expand Down
34 changes: 33 additions & 1 deletion src/collective/plausible/locales/collective.plausible.pot
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-02-17 11:10+0000\n"
"POT-Creation-Date: 2024-02-22 11:23+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand All @@ -27,6 +27,18 @@ msgstr ""
msgid "Add a link to the statistics browser view in the user menu"
msgstr ""

#: ../controlpanels/plausible_control_panel/controlpanel.pt:55
msgid "Clickhouse :&nbsp;"
msgstr ""

#: ../controlpanels/plausible_control_panel/controlpanel.pt:45
msgid "Configuration state"
msgstr ""

#: ../controlpanels/plausible_control_panel/controlpanel.pt:59
msgid "Error while trying to connect to Plausible API"
msgstr ""

#: ../controlpanels/plausible_control_panel/controlpanel.py:24
msgid "Example : imio.be"
msgstr ""
Expand Down Expand Up @@ -60,10 +72,30 @@ msgstr ""
msgid "Plausible authentification token"
msgstr ""

#: ../controlpanels/plausible_control_panel/controlpanel.pt:67
msgid "Plausible parameters are not set yet. You can define it here or via environment variables."
msgstr ""

#: ../controlpanels/plausible_control_panel/controlpanel.pt:48
msgid "Plausible parameters are set (here or environment variables)"
msgstr ""

#: ../controlpanels/plausible_control_panel/controlpanel.pt:51
msgid "Plausible server healthcheck"
msgstr ""

#: ../controlpanels/plausible_control_panel/controlpanel.py:31
msgid "Plausible token"
msgstr ""

#: ../controlpanels/plausible_control_panel/controlpanel.pt:56
msgid "Postgresql :&nbsp;"
msgstr ""

#: ../controlpanels/plausible_control_panel/controlpanel.pt:57
msgid "Sites cache :&nbsp;"
msgstr ""

#: ../profiles/default/actions.xml
#: ../upgrades/1001/actions.xml
msgid "Statistics"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-02-17 11:10+0000\n"
"POT-Creation-Date: 2024-02-22 11:23+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand All @@ -24,6 +24,18 @@ msgstr ""
msgid "Add a link to the statistics browser view in the user menu"
msgstr ""

#: ../controlpanels/plausible_control_panel/controlpanel.pt:55
msgid "Clickhouse :&nbsp;"
msgstr ""

#: ../controlpanels/plausible_control_panel/controlpanel.pt:45
msgid "Configuration state"
msgstr ""

#: ../controlpanels/plausible_control_panel/controlpanel.pt:59
msgid "Error while trying to connect to Plausible API"
msgstr ""

#: ../controlpanels/plausible_control_panel/controlpanel.py:24
msgid "Example : imio.be"
msgstr ""
Expand Down Expand Up @@ -57,10 +69,30 @@ msgstr ""
msgid "Plausible authentification token"
msgstr ""

#: ../controlpanels/plausible_control_panel/controlpanel.pt:67
msgid "Plausible parameters are not set yet. You can define it here or via environment variables."
msgstr ""

#: ../controlpanels/plausible_control_panel/controlpanel.pt:48
msgid "Plausible parameters are set (here or environment variables)"
msgstr ""

#: ../controlpanels/plausible_control_panel/controlpanel.pt:51
msgid "Plausible server healthcheck"
msgstr ""

#: ../controlpanels/plausible_control_panel/controlpanel.py:31
msgid "Plausible token"
msgstr ""

#: ../controlpanels/plausible_control_panel/controlpanel.pt:56
msgid "Postgresql :&nbsp;"
msgstr ""

#: ../controlpanels/plausible_control_panel/controlpanel.pt:57
msgid "Sites cache :&nbsp;"
msgstr ""

#: ../profiles/default/actions.xml
#: ../upgrades/1001/actions.xml
msgid "Statistics"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-02-17 11:10+0000\n"
"POT-Creation-Date: 2024-02-22 11:23+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand All @@ -24,6 +24,18 @@ msgstr "Ajouter un lien dans le menu utilisateur"
msgid "Add a link to the statistics browser view in the user menu"
msgstr "Ajouter un lien vers la vue des statistiques dans le menu utilisateur"

#: ../controlpanels/plausible_control_panel/controlpanel.pt:55
msgid "Clickhouse :&nbsp;"
msgstr "Clickouse :&nbsp;"

#: ../controlpanels/plausible_control_panel/controlpanel.pt:45
msgid "Configuration state"
msgstr "Etat de la configuration"

#: ../controlpanels/plausible_control_panel/controlpanel.pt:59
msgid "Error while trying to connect to Plausible API"
msgstr "Erreur lors de la tentative de connexion à l'API Plausible"

#: ../controlpanels/plausible_control_panel/controlpanel.py:24
msgid "Example : imio.be"
msgstr "Exemple : imio.be"
Expand Down Expand Up @@ -57,10 +69,30 @@ msgstr "Plausible analytics n'est pas configuré"
msgid "Plausible authentification token"
msgstr "Token d'authentification Plausible"

#: ../controlpanels/plausible_control_panel/controlpanel.pt:67
msgid "Plausible parameters are not set yet. You can define it here or via environment variables."
msgstr "Les paramètres de Plausible n'ont pas encore été définis. Vous pouvez les définir ici ou via des variables d'environnement."

#: ../controlpanels/plausible_control_panel/controlpanel.pt:48
msgid "Plausible parameters are set (here or environment variables)"
msgstr "Les paramètres de Plausible ont été définis (ici ou via des variables d'environnement)"

#: ../controlpanels/plausible_control_panel/controlpanel.pt:51
msgid "Plausible server healthcheck"
msgstr "Etat du serveur Plausible"

#: ../controlpanels/plausible_control_panel/controlpanel.py:31
msgid "Plausible token"
msgstr "Token Plausible"

#: ../controlpanels/plausible_control_panel/controlpanel.pt:56
msgid "Postgresql :&nbsp;"
msgstr "Postgresql :&nbsp;"

#: ../controlpanels/plausible_control_panel/controlpanel.pt:57
msgid "Sites cache :&nbsp;"
msgstr "Cache des sites :&nbsp;"

#: ../profiles/default/actions.xml
#: ../upgrades/1001/actions.xml
msgid "Statistics"
Expand Down
Loading
Loading