Skip to content

Commit cc24b4a

Browse files
djs0109sbanoeon
andauthored
feat(subscription): adapte subscription module, including the models and the synchronization behavior
* feat(subscription): sync subscriptions with orion BREAKING CHANGE: subscriptions model has been modified. Subscriptions are now synchronized with orion * chore(subscription): adapt the shown information on box * chore(subscription): add tooltip for notification endpoint in panel * chore(subscription): show pattern in panel * chore(subscription): change header to description in panel * chore(subscription): change name and env variable of subscriptions module * chore(subscription): remove unused model fields * chore(subscription): remove unused dependency in models * fix(subscription): activation function * fix(entity): wrong authentication in Update * fix(subscriptions): fixed notification module not loading attributes * chore(subscriptions): adapted notification model for Filip 5.0 * refactor(subscriptions): refactored to include custom options too * refactor(subscriptions): included todos * fix(subscriptions): fixed form type from Text to JSON for ngsi * chore(subscription): adjust class structure and tooltip --------- Co-authored-by: Saira Bano <[email protected]>
1 parent 1df6863 commit cc24b4a

File tree

18 files changed

+855
-239
lines changed

18 files changed

+855
-239
lines changed

app/Entirety/.env.EXAMPLE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Application Load
22
ENTITIES_LOAD=True
33
DEVICES_LOAD=True
4-
NOTIFICATIONS_LOAD=True
4+
SUBSCRIPTIONS_LOAD=True
55
SEMANTICS_LOAD=True
66

77
# Database

app/Entirety/projects/mixins.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def get_context_data(self, **kwargs):
1313

1414
context["entities_load"] = apps.is_installed("entities")
1515
context["devices_load"] = apps.is_installed("devices")
16-
context["notifications_load"] = apps.is_installed("subscriptions")
16+
context["subscriptions_load"] = apps.is_installed("subscriptions")
1717
context["semantics_load"] = apps.is_installed("semantics")
1818
# TODO change the tag if data model module
1919
context["smart_datamodels_load"] = apps.is_installed(

app/Entirety/static/js/subscription.js

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,165 @@ function removeEntity(event) {
125125
});
126126
}
127127
}
128+
129+
function showMqttSection() {
130+
var mqtt = document.getElementById('mqtt');
131+
var mqttCustom = document.getElementById('mqttCustom');
132+
var http = document.getElementById('http');
133+
var httpCustom = document.getElementById('httpCustom');
134+
135+
// Show only MQTT section
136+
mqtt.classList.remove('d-none');
137+
mqtt.classList.add('d-block');
138+
139+
// Hide HTTP and other sections
140+
http.classList.add('d-none');
141+
http.classList.remove('d-block');
142+
httpCustom.classList.add('d-none');
143+
httpCustom.classList.remove('d-block');
144+
mqttCustom.classList.add('d-none');
145+
mqttCustom.classList.remove('d-block');
146+
147+
// Enable only MQTT inputs
148+
mqtt.querySelectorAll('input, select, textarea').forEach(function (input) {
149+
input.disabled = false;
150+
});
151+
mqttCustom.querySelectorAll('input, select, textarea').forEach(function (input) {
152+
input.disabled = true;
153+
});
154+
http.querySelectorAll('input, select, textarea').forEach(function (input) {
155+
input.disabled = true;
156+
});
157+
httpCustom.querySelectorAll('input, select, textarea').forEach(function (input) {
158+
input.disabled = true;
159+
});
160+
}
161+
162+
function showMqttCustomSection() {
163+
var mqtt = document.getElementById('mqtt');
164+
var mqttCustom = document.getElementById('mqttCustom');
165+
var http = document.getElementById('http');
166+
var httpCustom = document.getElementById('httpCustom');
167+
168+
// Show only MQTT Custom section
169+
mqttCustom.classList.remove('d-none');
170+
mqttCustom.classList.add('d-block');
171+
172+
// Hide other sections
173+
mqtt.classList.add('d-none');
174+
mqtt.classList.remove('d-block');
175+
http.classList.add('d-none');
176+
http.classList.remove('d-block');
177+
httpCustom.classList.add('d-none');
178+
httpCustom.classList.remove('d-block');
179+
180+
// Enable only MQTT Custom inputs
181+
mqtt.querySelectorAll('input, select, textarea').forEach(function (input) {
182+
input.disabled = true;
183+
});
184+
mqttCustom.querySelectorAll('input, select, textarea').forEach(function (input) {
185+
input.disabled = false;
186+
});
187+
http.querySelectorAll('input, select, textarea').forEach(function (input) {
188+
input.disabled = true;
189+
});
190+
httpCustom.querySelectorAll('input, select, textarea').forEach(function (input) {
191+
input.disabled = true;
192+
});
193+
}
194+
195+
function showHttpSection() {
196+
var mqtt = document.getElementById('mqtt');
197+
var mqttCustom = document.getElementById('mqttCustom');
198+
var http = document.getElementById('http');
199+
var httpCustom = document.getElementById('httpCustom');
200+
201+
// Show only HTTP section
202+
http.classList.remove('d-none');
203+
http.classList.add('d-block');
204+
205+
// Hide other sections
206+
mqtt.classList.add('d-none');
207+
mqtt.classList.remove('d-block');
208+
mqttCustom.classList.add('d-none');
209+
mqttCustom.classList.remove('d-block');
210+
httpCustom.classList.add('d-none');
211+
httpCustom.classList.remove('d-block');
212+
213+
// Enable only HTTP inputs
214+
http.querySelectorAll('input, select, textarea').forEach(function (input) {
215+
input.disabled = false;
216+
});
217+
mqtt.querySelectorAll('input, select, textarea').forEach(function (input) {
218+
input.disabled = true;
219+
});
220+
mqttCustom.querySelectorAll('input, select, textarea').forEach(function (input) {
221+
input.disabled = true;
222+
});
223+
httpCustom.querySelectorAll('input, select, textarea').forEach(function (input) {
224+
input.disabled = true;
225+
});
226+
}
227+
228+
function showHttpCustomSection() {
229+
var mqtt = document.getElementById('mqtt');
230+
var mqttCustom = document.getElementById('mqttCustom');
231+
var http = document.getElementById('http');
232+
var httpCustom = document.getElementById('httpCustom');
233+
234+
// Show only HTTP Custom section
235+
httpCustom.classList.remove('d-none');
236+
httpCustom.classList.add('d-block');
237+
238+
// Hide other sections
239+
mqtt.classList.add('d-none');
240+
mqtt.classList.remove('d-block');
241+
mqttCustom.classList.add('d-none');
242+
mqttCustom.classList.remove('d-block');
243+
http.classList.add('d-none');
244+
http.classList.remove('d-block');
245+
246+
// Enable only HTTP Custom inputs
247+
httpCustom.querySelectorAll('input, select, textarea').forEach(function (input) {
248+
input.disabled = false;
249+
});
250+
mqtt.querySelectorAll('input, select, textarea').forEach(function (input) {
251+
input.disabled = true;
252+
});
253+
mqttCustom.querySelectorAll('input, select, textarea').forEach(function (input) {
254+
input.disabled = true;
255+
});
256+
http.querySelectorAll('input, select, textarea').forEach(function (input) {
257+
input.disabled = true;
258+
});
259+
}
260+
261+
function handleEndpointTypeChange(endpointType) {
262+
if (endpointType.value === 'mqtt') {
263+
showMqttSection();
264+
} else if (endpointType.value === 'mqttCustom') {
265+
showMqttCustomSection();
266+
} else if (endpointType.value === 'http') {
267+
showHttpSection();
268+
} else if (endpointType.value === 'httpCustom') {
269+
showHttpCustomSection();
270+
}
271+
}
272+
273+
document.addEventListener('DOMContentLoaded', function () {
274+
var endpointType = document.getElementById('id_endpoint_type');
275+
276+
// Run appropriate function on page load
277+
handleEndpointTypeChange(endpointType);
278+
279+
// Attach change event listener to dropdown
280+
endpointType.addEventListener('change', function () {
281+
handleEndpointTypeChange(this);
282+
});
283+
});
284+
285+
// Handle back/forward navigation using the pageshow event
286+
window.addEventListener('pageshow', function () {
287+
var endpointType = document.getElementById('id_endpoint_type');
288+
handleEndpointTypeChange(endpointType);
289+
});

0 commit comments

Comments
 (0)