imio.smartweb.core 1.2.34__py3-none-any.whl → 1.2.37__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- imio/smartweb/core/browser/sitemap.py +52 -46
- imio/smartweb/core/contents/rest/utils.py +99 -0
- imio/smartweb/core/contents/sections/external_content/configure.zcml +29 -0
- imio/smartweb/core/contents/sections/external_content/view.pt +25 -7
- imio/smartweb/core/contents/sections/external_content/view_idelux_waste.pt +50 -0
- imio/smartweb/core/contents/sections/external_content/view_inbw_containers_affluence.pt +91 -0
- imio/smartweb/core/contents/sections/external_content/view_odwb_widget.pt +20 -0
- imio/smartweb/core/contents/sections/external_content/views.py +303 -124
- imio/smartweb/core/contents/sections/text/view.pt +1 -1
- imio/smartweb/core/interfaces.py +7 -0
- imio/smartweb/core/profiles/default/metadata.xml +1 -1
- imio/smartweb/core/profiles/default/registry/plone.xml +21 -4
- imio/smartweb/core/profiles/default/types/Collection.xml +13 -0
- imio/smartweb/core/profiles/default/types/File.xml +13 -0
- imio/smartweb/core/profiles/default/types/Image.xml +13 -0
- imio/smartweb/core/profiles/default/types/imio.smartweb.BlockLink.xml +5 -0
- imio/smartweb/core/profiles/default/types/imio.smartweb.CirkwiView.xml +1 -0
- imio/smartweb/core/profiles/default/types/imio.smartweb.DirectoryView.xml +1 -0
- imio/smartweb/core/profiles/default/types/imio.smartweb.EventsView.xml +1 -0
- imio/smartweb/core/profiles/default/types/imio.smartweb.Folder.xml +1 -0
- imio/smartweb/core/profiles/default/types/imio.smartweb.NewsView.xml +1 -0
- imio/smartweb/core/profiles/default/types/imio.smartweb.Page.xml +1 -0
- imio/smartweb/core/profiles/default/types/imio.smartweb.PortalPage.xml +1 -0
- imio/smartweb/core/profiles/default/types/imio.smartweb.Procedure.xml +1 -0
- imio/smartweb/core/tests/test_section_external_content.py +23 -23
- imio/smartweb/core/tests/test_sections.py +3 -15
- imio/smartweb/core/tests/test_sitemap.py +41 -22
- imio/smartweb/core/upgrades/configure.zcml +36 -0
- imio/smartweb/core/upgrades/profiles/1053_to_1054/registry.xml +39 -0
- imio/smartweb/core/upgrades/profiles/1054_to_1055/types/Collection.xml +13 -0
- imio/smartweb/core/upgrades/profiles/1054_to_1055/types/File.xml +13 -0
- imio/smartweb/core/upgrades/profiles/1054_to_1055/types/Image.xml +13 -0
- imio/smartweb/core/upgrades/profiles/1054_to_1055/types/imio.smartweb.BlockLink.xml +12 -0
- imio/smartweb/core/upgrades/profiles/1054_to_1055/types/imio.smartweb.CirkwiView.xml +12 -0
- imio/smartweb/core/upgrades/profiles/1054_to_1055/types/imio.smartweb.DirectoryView.xml +12 -0
- imio/smartweb/core/upgrades/profiles/1054_to_1055/types/imio.smartweb.EventsView.xml +12 -0
- imio/smartweb/core/upgrades/profiles/1054_to_1055/types/imio.smartweb.Folder.xml +12 -0
- imio/smartweb/core/upgrades/profiles/1054_to_1055/types/imio.smartweb.NewsView.xml +12 -0
- imio/smartweb/core/upgrades/profiles/1054_to_1055/types/imio.smartweb.Page.xml +12 -0
- imio/smartweb/core/upgrades/profiles/1054_to_1055/types/imio.smartweb.PortalPage.xml +12 -0
- imio/smartweb/core/upgrades/profiles/1054_to_1055/types/imio.smartweb.Procedure.xml +12 -0
- imio/smartweb/core/viewlets/configure.zcml +10 -0
- imio/smartweb/core/viewlets/external_content.py +13 -5
- imio/smartweb/core/viewlets/odwb_widget_header.pt +19 -0
- imio/smartweb/core/webcomponents/build/css/373.smartweb-webcomponents-compiled.css +1 -0
- imio/smartweb/core/webcomponents/build/css/486.smartweb-webcomponents-compiled.css +1 -0
- imio/smartweb/core/webcomponents/build/css/686.smartweb-webcomponents-compiled.css +1 -0
- imio/smartweb/core/webcomponents/build/css/919.smartweb-webcomponents-compiled.css +1 -0
- imio/smartweb/core/webcomponents/build/css/smartweb-webcomponents-compiled.css +1 -1
- imio/smartweb/core/webcomponents/build/js/209.smartweb-webcomponents-compiled.js +2 -0
- imio/smartweb/core/webcomponents/build/js/218.smartweb-webcomponents-compiled.js +2 -0
- imio/smartweb/core/webcomponents/build/js/373.smartweb-webcomponents-compiled.js +1 -0
- imio/smartweb/core/webcomponents/build/js/486.smartweb-webcomponents-compiled.js +1 -0
- imio/smartweb/core/webcomponents/build/js/568.smartweb-webcomponents-compiled.js +2 -0
- imio/smartweb/core/webcomponents/build/js/568.smartweb-webcomponents-compiled.js.LICENSE.txt +14 -0
- imio/smartweb/core/webcomponents/build/js/674.smartweb-webcomponents-compiled.js +2 -0
- imio/smartweb/core/webcomponents/build/js/686.smartweb-webcomponents-compiled.js +1 -0
- imio/smartweb/core/webcomponents/build/js/799.smartweb-webcomponents-compiled.js +2 -0
- imio/smartweb/core/webcomponents/build/js/804.smartweb-webcomponents-compiled.js +1 -0
- imio/smartweb/core/webcomponents/build/js/919.smartweb-webcomponents-compiled.js +1 -0
- imio/smartweb/core/webcomponents/build/js/smartweb-webcomponents-compiled.js +1 -1
- imio/smartweb/core/webcomponents/src/utils/translation.js +2 -2
- {imio.smartweb.core-1.2.34.dist-info → imio.smartweb.core-1.2.37.dist-info}/METADATA +28 -1
- {imio.smartweb.core-1.2.34.dist-info → imio.smartweb.core-1.2.37.dist-info}/RECORD +74 -56
- imio/smartweb/core/webcomponents/build/css/323.smartweb-webcomponents-compiled.css +0 -1
- imio/smartweb/core/webcomponents/build/css/392.smartweb-webcomponents-compiled.css +0 -1
- imio/smartweb/core/webcomponents/build/css/528.smartweb-webcomponents-compiled.css +0 -1
- imio/smartweb/core/webcomponents/build/css/647.smartweb-webcomponents-compiled.css +0 -1
- imio/smartweb/core/webcomponents/build/js/143.smartweb-webcomponents-compiled.js +0 -2
- imio/smartweb/core/webcomponents/build/js/144.smartweb-webcomponents-compiled.js +0 -2
- imio/smartweb/core/webcomponents/build/js/323.smartweb-webcomponents-compiled.js +0 -1
- imio/smartweb/core/webcomponents/build/js/392.smartweb-webcomponents-compiled.js +0 -1
- imio/smartweb/core/webcomponents/build/js/493.smartweb-webcomponents-compiled.js +0 -2
- imio/smartweb/core/webcomponents/build/js/528.smartweb-webcomponents-compiled.js +0 -2
- imio/smartweb/core/webcomponents/build/js/528.smartweb-webcomponents-compiled.js.LICENSE.txt +0 -1
- imio/smartweb/core/webcomponents/build/js/647.smartweb-webcomponents-compiled.js +0 -1
- imio/smartweb/core/webcomponents/build/js/729.smartweb-webcomponents-compiled.js +0 -2
- imio/smartweb/core/webcomponents/build/js/729.smartweb-webcomponents-compiled.js.LICENSE.txt +0 -1
- imio/smartweb/core/webcomponents/build/js/9.smartweb-webcomponents-compiled.js +0 -2
- imio/smartweb/core/webcomponents/build/js/969.smartweb-webcomponents-compiled.js +0 -2
- imio/smartweb/core/webcomponents/build/js/969.smartweb-webcomponents-compiled.js.LICENSE.txt +0 -642
- imio/smartweb/core/webcomponents/build/js/979.smartweb-webcomponents-compiled.js +0 -1
- /imio/smartweb/core/webcomponents/build/js/{9.smartweb-webcomponents-compiled.js.LICENSE.txt → 209.smartweb-webcomponents-compiled.js.LICENSE.txt} +0 -0
- /imio/smartweb/core/webcomponents/build/js/{143.smartweb-webcomponents-compiled.js.LICENSE.txt → 218.smartweb-webcomponents-compiled.js.LICENSE.txt} +0 -0
- /imio/smartweb/core/webcomponents/build/js/{493.smartweb-webcomponents-compiled.js.LICENSE.txt → 674.smartweb-webcomponents-compiled.js.LICENSE.txt} +0 -0
- /imio/smartweb/core/webcomponents/build/js/{144.smartweb-webcomponents-compiled.js.LICENSE.txt → 799.smartweb-webcomponents-compiled.js.LICENSE.txt} +0 -0
- /imio.smartweb.core-1.2.34-py3.10-nspkg.pth → /imio.smartweb.core-1.2.37-py3.10-nspkg.pth +0 -0
- {imio.smartweb.core-1.2.34.dist-info → imio.smartweb.core-1.2.37.dist-info}/LICENSE.GPL +0 -0
- {imio.smartweb.core-1.2.34.dist-info → imio.smartweb.core-1.2.37.dist-info}/LICENSE.rst +0 -0
- {imio.smartweb.core-1.2.34.dist-info → imio.smartweb.core-1.2.37.dist-info}/WHEEL +0 -0
- {imio.smartweb.core-1.2.34.dist-info → imio.smartweb.core-1.2.37.dist-info}/namespace_packages.txt +0 -0
- {imio.smartweb.core-1.2.34.dist-info → imio.smartweb.core-1.2.37.dist-info}/top_level.txt +0 -0
@@ -2,6 +2,8 @@ from BTrees.OOBTree import OOBTree
|
|
2
2
|
from imio.smartweb.core.config import DIRECTORY_URL
|
3
3
|
from imio.smartweb.core.config import EVENTS_URL
|
4
4
|
from imio.smartweb.core.config import NEWS_URL
|
5
|
+
from imio.smartweb.core.contents.rest.utils import get_auth_sources_response
|
6
|
+
from imio.smartweb.core.contents.rest.utils import get_entity_id
|
5
7
|
from imio.smartweb.core.utils import get_json
|
6
8
|
from plone import api
|
7
9
|
from plone.base.interfaces import IPloneSiteRoot
|
@@ -86,50 +88,54 @@ class CustomSiteMapView(SiteMapView):
|
|
86
88
|
"lastmod": lastmod,
|
87
89
|
}
|
88
90
|
|
89
|
-
auth_sources =
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
91
|
+
auth_sources = {
|
92
|
+
"directory": {
|
93
|
+
"entity_reg_var": "smartweb.directory_entity_uid",
|
94
|
+
"main_rest_view": "smartweb.default_directory_view",
|
95
|
+
"vocabulary": "imio.smartweb.vocabulary.RemoteDirectoryEntities",
|
96
|
+
"url": DIRECTORY_URL,
|
97
|
+
},
|
98
|
+
"events": {
|
99
|
+
"entity_reg_var": "smartweb.events_entity_uid",
|
100
|
+
"main_rest_view": "smartweb.default_events_view",
|
101
|
+
"vocabulary": "imio.smartweb.vocabulary.RemoteEventsEntities",
|
102
|
+
"url": EVENTS_URL,
|
103
|
+
},
|
104
|
+
"news": {
|
105
|
+
"entity_reg_var": "smartweb.news_entity_uid",
|
106
|
+
"main_rest_view": "smartweb.default_news_view",
|
107
|
+
"vocabulary": "imio.smartweb.vocabulary.RemoteNewsEntities",
|
108
|
+
"url": NEWS_URL,
|
109
|
+
},
|
110
|
+
}
|
111
|
+
for auth_source_key, auth_source_value in auth_sources.items():
|
112
|
+
entity_uid = api.portal.get_registry_record(
|
113
|
+
auth_source_value.get("entity_reg_var")
|
114
|
+
)
|
115
|
+
if entity_uid is None:
|
116
|
+
return self.request.response.setStatus(404, "No entity found")
|
117
|
+
entity_id = get_entity_id(auth_source_value.get("vocabulary"), entity_uid)
|
118
|
+
auth_source_uid = api.portal.get_registry_record(
|
119
|
+
f"smartweb.default_{auth_source_key}_view", default=None
|
120
|
+
)
|
121
|
+
if auth_source_uid is None:
|
122
|
+
return self.request.response.setStatus(
|
123
|
+
404, "No default authentic source found"
|
101
124
|
)
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
f"portal_type={auth_source_value.get('type')}",
|
120
|
-
"fullobjects=0",
|
121
|
-
"sort_on=sortable_title",
|
122
|
-
]
|
123
|
-
url = f"{auth_source_value.get('path')}/{endpoint}?{'&'.join(params)}"
|
124
|
-
results = get_json(url)
|
125
|
-
if results is None:
|
126
|
-
continue
|
127
|
-
for item in results.get("items"):
|
128
|
-
item_id = normalizeString(item.get("title"))
|
129
|
-
item_uid = item.get("id")
|
130
|
-
loc = f"{auth_source_view_url}/{item_id}?u={item_uid}"
|
131
|
-
lastmod = item.get("modified")
|
132
|
-
yield {
|
133
|
-
"loc": loc,
|
134
|
-
"lastmod": lastmod,
|
135
|
-
}
|
125
|
+
brains = api.content.find(UID=auth_source_uid)
|
126
|
+
obj = brains[0].getObject()
|
127
|
+
auth_source_view_url = obj.absolute_url()
|
128
|
+
results = get_auth_sources_response(
|
129
|
+
auth_source_key, normalizeString(entity_id), (60 * 60 * 24)
|
130
|
+
).json()
|
131
|
+
if results is None or results.get("type") == "ValueError":
|
132
|
+
continue
|
133
|
+
for item in results.get("items"):
|
134
|
+
item_id = normalizeString(item.get("title"))
|
135
|
+
item_uid = item.get("id")
|
136
|
+
loc = f"{auth_source_view_url}/{item_id}?u={item_uid}"
|
137
|
+
lastmod = item.get("modified")
|
138
|
+
yield {
|
139
|
+
"loc": loc,
|
140
|
+
"lastmod": lastmod,
|
141
|
+
}
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# # -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
from imio.smartweb.core.config import DIRECTORY_URL
|
4
|
+
from imio.smartweb.core.config import EVENTS_URL
|
5
|
+
from imio.smartweb.core.config import NEWS_URL
|
6
|
+
from imio.smartweb.core.utils import get_wca_token
|
7
|
+
from plone.memoize import ram
|
8
|
+
from plone.memoize.view import memoize
|
9
|
+
from time import time
|
10
|
+
from zope.component import getUtility
|
11
|
+
from zope.schema.interfaces import IVocabularyFactory
|
12
|
+
|
13
|
+
import json
|
14
|
+
import os
|
15
|
+
import requests
|
16
|
+
|
17
|
+
|
18
|
+
def get_entity_id(vocabulary_name, uid):
|
19
|
+
vocabulary = getUtility(IVocabularyFactory, name=vocabulary_name)()
|
20
|
+
for term in vocabulary:
|
21
|
+
if term.token == uid:
|
22
|
+
return term.title or term.id
|
23
|
+
return None
|
24
|
+
|
25
|
+
|
26
|
+
def get_auth_sources_response(
|
27
|
+
sources_name, entity_id, wf_status=["published"], time_to_cache=60
|
28
|
+
):
|
29
|
+
"""_summary_
|
30
|
+
|
31
|
+
Args:
|
32
|
+
sources_name (_type_): 3 values are possible: "directory", "news", "events"
|
33
|
+
entity_id (_type_): _description_
|
34
|
+
|
35
|
+
Returns:
|
36
|
+
_type_: json response
|
37
|
+
"""
|
38
|
+
url = ""
|
39
|
+
if sources_name == "directory":
|
40
|
+
url = DIRECTORY_URL
|
41
|
+
portaltype = "imio.directory.Contact"
|
42
|
+
client_id_varname = "RESTAPI_DIRECTORY_CLIENT_ID"
|
43
|
+
client_secret_varname = "RESTAPI_DIRECTORY_CLIENT_SECRET"
|
44
|
+
elif sources_name == "events":
|
45
|
+
url = EVENTS_URL
|
46
|
+
portaltype = "imio.events.Event"
|
47
|
+
client_id_varname = "RESTAPI_EVENTS_CLIENT_ID"
|
48
|
+
client_secret_varname = "RESTAPI_EVENTS_CLIENT_SECRET"
|
49
|
+
elif sources_name == "news":
|
50
|
+
url = NEWS_URL
|
51
|
+
portaltype = "imio.news.NewsItem"
|
52
|
+
client_id_varname = "RESTAPI_NEWS_CLIENT_ID"
|
53
|
+
client_secret_varname = "RESTAPI_NEWS_CLIENT_SECRET"
|
54
|
+
|
55
|
+
payload = {
|
56
|
+
"query": [
|
57
|
+
{
|
58
|
+
"i": "portal_type",
|
59
|
+
"o": "plone.app.querystring.operation.selection.is",
|
60
|
+
"v": [portaltype],
|
61
|
+
},
|
62
|
+
{
|
63
|
+
"i": "path",
|
64
|
+
"o": "plone.app.querystring.operation.string.absolutePath",
|
65
|
+
"v": f"/{entity_id}",
|
66
|
+
},
|
67
|
+
{
|
68
|
+
"i": "review_state",
|
69
|
+
"o": "plone.app.querystring.operation.selection.any",
|
70
|
+
"v": wf_status,
|
71
|
+
},
|
72
|
+
],
|
73
|
+
"metadata_fields": ["title", "modified"],
|
74
|
+
"sort_on": "effective",
|
75
|
+
"sort_order": "descending",
|
76
|
+
"fullobjects": True,
|
77
|
+
"b_start": 0,
|
78
|
+
"b_size": 4000,
|
79
|
+
}
|
80
|
+
client_id = os.environ.get(client_id_varname)
|
81
|
+
client_secret = os.environ.get(client_secret_varname)
|
82
|
+
auth = get_wca_token(client_id, client_secret)
|
83
|
+
headers = {
|
84
|
+
"Accept": "application/json",
|
85
|
+
"Content-Type": "text/plain",
|
86
|
+
"Authorization": auth,
|
87
|
+
}
|
88
|
+
url = f"{url}/@querystring-search"
|
89
|
+
response = get_cached_data(url, headers, payload, time_to_cache)
|
90
|
+
return response
|
91
|
+
|
92
|
+
|
93
|
+
def _cache_key(func, url, headers, payload, time_to_cache):
|
94
|
+
return (url, time() // time_to_cache)
|
95
|
+
|
96
|
+
|
97
|
+
@ram.cache(_cache_key)
|
98
|
+
def get_cached_data(url, headers, payload, time_to_cache):
|
99
|
+
return requests.request("POST", url, headers=headers, data=json.dumps(payload))
|
@@ -19,4 +19,33 @@
|
|
19
19
|
permission="zope2.View"
|
20
20
|
layer="imio.smartweb.core.interfaces.IImioSmartwebCoreLayer"
|
21
21
|
/>
|
22
|
+
|
23
|
+
<browser:page
|
24
|
+
name="view_idelux_waste"
|
25
|
+
for="*"
|
26
|
+
class="imio.smartweb.core.contents.sections.external_content.views.IdeluxWasteView"
|
27
|
+
template="view_idelux_waste.pt"
|
28
|
+
permission="zope2.View"
|
29
|
+
layer="imio.smartweb.core.interfaces.IImioSmartwebCoreLayer"
|
30
|
+
/>
|
31
|
+
|
32
|
+
<browser:page
|
33
|
+
name="view_inbw_container_affluence"
|
34
|
+
for="*"
|
35
|
+
class="imio.smartweb.core.contents.sections.external_content.views.InbwContainersAffluenceView"
|
36
|
+
template="view_inbw_containers_affluence.pt"
|
37
|
+
permission="zope2.View"
|
38
|
+
layer="imio.smartweb.core.interfaces.IImioSmartwebCoreLayer"
|
39
|
+
/>
|
40
|
+
|
41
|
+
|
42
|
+
<browser:page
|
43
|
+
name="view_odwb_widget"
|
44
|
+
for="*"
|
45
|
+
class="imio.smartweb.core.contents.sections.external_content.views.OdwbWidgetView"
|
46
|
+
template="view_odwb_widget.pt"
|
47
|
+
permission="zope2.View"
|
48
|
+
layer="imio.smartweb.core.interfaces.IImioSmartwebCoreLayer"
|
49
|
+
/>
|
50
|
+
|
22
51
|
</configure>
|
@@ -12,21 +12,39 @@
|
|
12
12
|
<metal:macro use-macro="context/@@sections_macros/section_edition" />
|
13
13
|
<div class="container section-container section-external-content"
|
14
14
|
id=""
|
15
|
+
define="datas view/get_datas"
|
15
16
|
tal:attributes="id string:container-section-${context/id}">
|
16
17
|
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
<tal:check tal:condition="view/has_leadimage">
|
20
|
+
<img tal:attributes="src view/image" />
|
21
|
+
</tal:check>
|
21
22
|
|
22
23
|
<metal:macro use-macro="context/@@sections_macros/section_title" />
|
23
24
|
|
24
25
|
<p tal:replace="structure context/@@description" />
|
26
|
+
<div tal:define="which_plugin view/which_plugin">
|
27
|
+
|
28
|
+
<div tal:condition="not:which_plugin"
|
29
|
+
tal:define="collapse_klass python: 'collapse' if context.collapsible_section else ''"
|
30
|
+
tal:attributes="class string:body-section ratio ${collapse_klass};
|
31
|
+
id string:body-section-${context/id}"
|
32
|
+
tal:content="structure view/contents" />
|
33
|
+
|
34
|
+
<div tal:condition="python:which_plugin == 'ideluxwasteplugin'">
|
35
|
+
<metal:block use-macro="context/@@view_idelux_waste/embeded_datas" tal:define="datas view/contents">
|
36
|
+
</div>
|
37
|
+
|
38
|
+
<div tal:condition="python:which_plugin == 'inbwcontainersaffluenceplugin'">
|
39
|
+
<metal:block use-macro="context/@@view_inbw_container_affluence/embeded_datas" tal:define="datas view/contents">
|
40
|
+
</div>
|
41
|
+
|
42
|
+
<div tal:condition="python:which_plugin == 'odwbwidgetplugin'">
|
43
|
+
<metal:block use-macro="context/@@view_odwb_widget/embeded_datas" tal:define="datas view/contents">
|
44
|
+
</div>
|
45
|
+
|
46
|
+
</div>
|
25
47
|
|
26
|
-
<div tal:define="collapse_klass python: 'collapse' if context.collapsible_section else ''"
|
27
|
-
tal:attributes="class string:body-section ratio ${collapse_klass};
|
28
|
-
id string:body-section-${context/id}"
|
29
|
-
tal:content="structure view/get_embed_external_content" />
|
30
48
|
|
31
49
|
</div>
|
32
50
|
</metal:content-core>
|
@@ -0,0 +1,50 @@
|
|
1
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
|
2
|
+
xmlns:tal="http://xml.zope.org/namespaces/tal"
|
3
|
+
xmlns:metal="http://xml.zope.org/namespaces/metal"
|
4
|
+
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
|
5
|
+
lang="en"
|
6
|
+
i18n:domain="imio.smartweb">
|
7
|
+
|
8
|
+
<metal:macro define-macro="embeded_datas">
|
9
|
+
<script>
|
10
|
+
$(document).ready(function() {
|
11
|
+
$('#searchInput').on('input', function() {
|
12
|
+
var searchTerm = $(this).val().toLowerCase();
|
13
|
+
|
14
|
+
// Loop through each item in the results
|
15
|
+
$('.result-item').each(function() {
|
16
|
+
var searchable = $(this).data('searchable').toLowerCase();
|
17
|
+
|
18
|
+
// If the keyword is found in the consignes_de_tri, show the item, otherwise hide it
|
19
|
+
if (searchable.includes(searchTerm)) {
|
20
|
+
$(this).show(); // Show the matching item
|
21
|
+
} else {
|
22
|
+
$(this).hide(); // Hide the non-matching item
|
23
|
+
}
|
24
|
+
});
|
25
|
+
});
|
26
|
+
});
|
27
|
+
</script>
|
28
|
+
<input type="text" id="searchInput" class="form-control" placeholder="Search Consignes de Tri">
|
29
|
+
<div id="results">
|
30
|
+
<!-- Results will be populated here -->
|
31
|
+
</div>
|
32
|
+
|
33
|
+
<div tal:define="results datas/results">
|
34
|
+
<ul tal:repeat="res results">
|
35
|
+
<tal:def define="filiere res/filiere;
|
36
|
+
dechet res/dechet;
|
37
|
+
infoparc res/infoparc;
|
38
|
+
consignes_de_tri res/consignes_de_tri;
|
39
|
+
searchable string:${filiere} ${dechet} ${infoparc} ${consignes_de_tri}">
|
40
|
+
<li class="result-item" data-searchable="${searchable}" >
|
41
|
+
<h3 tal:content="string:${filiere} - ${dechet}" />
|
42
|
+
<p tal:content="infoparc"></p>
|
43
|
+
<p tal:content="consignes_de_tri"></p>
|
44
|
+
</li>
|
45
|
+
|
46
|
+
</tal:def>
|
47
|
+
</ul>
|
48
|
+
</div>
|
49
|
+
</metal:macro>
|
50
|
+
</html>
|
@@ -0,0 +1,91 @@
|
|
1
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
|
2
|
+
xmlns:tal="http://xml.zope.org/namespaces/tal"
|
3
|
+
xmlns:metal="http://xml.zope.org/namespaces/metal"
|
4
|
+
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
|
5
|
+
lang="en"
|
6
|
+
i18n:domain="imio.smartweb">
|
7
|
+
|
8
|
+
<metal:macro define-macro="embeded_datas">
|
9
|
+
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
10
|
+
<script>
|
11
|
+
$(document).ready(function () {
|
12
|
+
var today = new Date().getDay();
|
13
|
+
var hours = new Date().getHours(); // Get current hour
|
14
|
+
var daysOfWeek = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'];
|
15
|
+
var currentDay = daysOfWeek[today];
|
16
|
+
var jsonDataString = $('#json-data').attr("data");
|
17
|
+
|
18
|
+
var jsonData = JSON.parse(jsonDataString);
|
19
|
+
var todayData = JSON.parse(jsonData.results[0][currentDay]);
|
20
|
+
var current_affluence = jsonData.results[0].current_affluence;
|
21
|
+
|
22
|
+
var keys = [];
|
23
|
+
var dataset1 = [];
|
24
|
+
var dataset2 = [];
|
25
|
+
|
26
|
+
Object.entries(todayData).forEach(function([key, value]) {
|
27
|
+
keys.push(key + "h00");
|
28
|
+
console.log('key' + key + 'hours' + hours);
|
29
|
+
if (key == hours) {
|
30
|
+
dataset2.push(current_affluence);
|
31
|
+
}
|
32
|
+
else {dataset2.push(0);}
|
33
|
+
dataset1.push(value);
|
34
|
+
});
|
35
|
+
|
36
|
+
|
37
|
+
// Define the Chart.js data and options
|
38
|
+
var chartData = {
|
39
|
+
labels: keys, // Hours
|
40
|
+
datasets: [{
|
41
|
+
label: currentDay + ' average affluence',
|
42
|
+
data: dataset1,
|
43
|
+
backgroundColor: 'rgba(54, 162, 235, 0.2)',
|
44
|
+
borderColor: 'rgba(54, 162, 235, 1)',
|
45
|
+
borderWidth: 1
|
46
|
+
},
|
47
|
+
{
|
48
|
+
label: 'Current affluence',
|
49
|
+
data: dataset2,
|
50
|
+
backgroundColor: 'rgba(255, 99, 132, 0.2)', // Specify the desired color
|
51
|
+
borderColor: 'rgba(255, 99, 132, 1)', // Specify the desired color
|
52
|
+
borderWidth: 1
|
53
|
+
}]
|
54
|
+
};
|
55
|
+
|
56
|
+
var chartOptions = {
|
57
|
+
scales: {
|
58
|
+
x: {
|
59
|
+
title: {
|
60
|
+
display: true,
|
61
|
+
text: 'Hours'
|
62
|
+
}
|
63
|
+
},
|
64
|
+
y: {
|
65
|
+
title: {
|
66
|
+
display: true,
|
67
|
+
text: 'Values'
|
68
|
+
},
|
69
|
+
ticks: {
|
70
|
+
stepSize: 1
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
74
|
+
};
|
75
|
+
|
76
|
+
// Get the canvas element
|
77
|
+
var ctx = document.getElementById('myChart').getContext('2d');
|
78
|
+
// Create the Chart.js chart
|
79
|
+
var myChart = new Chart(ctx, {
|
80
|
+
type: 'bar',
|
81
|
+
data: chartData,
|
82
|
+
options: chartOptions
|
83
|
+
});
|
84
|
+
});
|
85
|
+
|
86
|
+
</script>
|
87
|
+
<div id="json-data" tal:attributes="data datas"></div>
|
88
|
+
<canvas id="myChart" width="60%" height="" ></canvas>
|
89
|
+
|
90
|
+
</metal:macro>
|
91
|
+
</html>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
|
2
|
+
xmlns:tal="http://xml.zope.org/namespaces/tal"
|
3
|
+
xmlns:metal="http://xml.zope.org/namespaces/metal"
|
4
|
+
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
|
5
|
+
lang="en"
|
6
|
+
i18n:domain="imio.smartweb">
|
7
|
+
<metal:macro define-macro="embeded_datas">
|
8
|
+
|
9
|
+
<div class="container">
|
10
|
+
<div ng-cloak ng-app="ods-widgets">
|
11
|
+
<div tal:content="structure datas"></div>
|
12
|
+
<!--script type="text/javascript">
|
13
|
+
angular.module('ods-widgets').config(function($locationProvider) {
|
14
|
+
$locationProvider.html5Mode(true);
|
15
|
+
});
|
16
|
+
</script-->
|
17
|
+
</div>
|
18
|
+
</div>
|
19
|
+
</metal:macro>
|
20
|
+
</html>
|