Posts: 335
Threads: 75
Joined: Jun 2017
Reputation:
6
Hi,
how show data from scheduler in other visualization object? As example I need show time from scheduler 1 in visualization?
I created widget with scheduler, but can I hide selection of "Holidays" and bulls to other schedulers? May be I can hide also other elements?
I need not to allow customers change to many parameters, only time.
Is it possible? Not so strength in CSS still
BR,
Alex
Posts: 940
Threads: 161
Joined: Jul 2015
Reputation:
33
14.10.2020, 22:31
(This post was last modified: 15.10.2020, 05:49 by buuuudzik.)
Currently it is possible to show only specified schedulers and hide holidays:
http://4n.lv:7999/scada-vis/schedulers?id=1&nohol
http://4n.lv:7999/scada-vis/schedulers?id=1,2&nohol
To allow further customization I've added yesteday another param support:
http://4n.lv:7999/scada-vis/schedulers?simple
http://4n.lv:7999/scada-vis/schedulers?i...hol&simple
But to use it you must add below code section to your Custom Javascript:
Code: $(function () {
// Simplify and limit scheduler form
if (location.href.match(/\/schedulers(.+)simple/g)) {
function setCustomSchedulerView() {
const inSchedulers = document.body.classList.contains("schedulers");
if (inSchedulers) {
const eventForm = document.getElementById("event-form");
if (!eventForm) return;
const findOnForm = (selector) => eventForm.querySelector(selector);
const hideEl = (el) => (el.style.display = "none");
const disableEl = (el) => (el.disabled = true);
const doOnSelector = (selector, handler) => {
const el = findOnForm(selector);
if (el) handler(el);
};
const doOnGlobalSelector = (selector, handler) => {
const el = document.querySelector(selector);
if (el) handler(el);
};
const doOnSelectorBeforeLabel = (selector, handler) => {
const el = findOnForm(selector);
if (
el &&
el.previousElementSibling &&
el.previousElementSibling.tagName === "LABEL"
)
handler(el.previousElementSibling);
};
const doOnSelectorAndParent = (selector, parentSelector, handler) => {
let el = findOnForm(selector);
if (el) {
handler(el);
let parent = null;
let limit = 10;
while (!parent && limit > 0) {
el = el.parentElement;
if (el && el.matches(parentSelector)) parent = el;
if (!el || parent) break;
limit--;
}
if (parent) handler(parent);
}
};
const hideSelector = (selector) => doOnSelector(selector, hideEl);
const hideGlobalSelector = (selector) => doOnGlobalSelector(selector, hideEl);
const hideSelectorAndParent = (selector, parentSelector) =>
doOnSelectorAndParent(selector, parentSelector, hideEl);
const hideSelectorBeforeLabel = (selector) =>
doOnSelectorBeforeLabel(selector, hideEl);
const disableSelector = (selector) => doOnSelector(selector, disableEl);
const disableGlobalSelector = (selector) => doOnGlobalSelector(selector, disableEl);
const disableSelectorAndParent = (selector, parentSelector) =>
doOnSelectorAndParent(selector, parentSelector, disableEl);
const schedulerFormElementsConfig = [
// style can be one from: "visible", "hidden", "disabled"
{
name: "active",
style: "hidden",
selector: "#event-active",
parent: ".checkbox",
},
{
name: "name",
style: "disabled",
selector: "#event-name",
},
{
name: "type",
style: "visible",
selector: "#event-type",
},
{
name: "type-sunrise-sunset",
style: "visible",
selector: "#event-type-sunrise-sunset",
},
{
name: "daysofweek",
style: "hidden",
selector: "#event-daysofweek",
},
{
name: "dayweeknrs",
style: "hidden",
selector: "#event-dayweeknrs",
},
{
name: "daysofmonth",
style: "hidden",
selector: "#event-daysofmonth",
},
{
name: "months",
style: "hidden",
selector: "#event-months",
},
{
name: "holidays",
style: "hidden",
selector: "#event-holidays",
},
{
name: "year",
style: "hidden",
selector: "#event-year",
parent: ".checkbox",
},
{
name: "value-bool",
style: "disabled",
selector: "#event-value-bool",
},
{
name: "value-color",
style: "disabled",
selector: "#event-value-color",
},
{
name: "value-spinner",
style: "disabled",
selector: "#event-value-spinner",
},
{
name: "value-slider",
style: "disabled",
selector: "#event-value-slider",
},
{
name: "value-enums",
style: "disabled",
selector: "#event-value-enums",
},
{
name: "value-text",
style: "disabled",
selector: "#event-value-text",
},
{
name: "value-lighting",
style: "disabled",
selector: "#event-value-lighting",
},
];
schedulerFormElementsConfig.forEach((config) => {
switch (config.style) {
case "hidden":
if (!config.parent) {
hideSelector(config.selector);
hideSelectorBeforeLabel(config.selector);
} else {
hideSelectorAndParent(config.selector, config.parent);
hideSelectorBeforeLabel(config.parent);
}
break;
case "disabled":
if (!config.parent) {
disableSelector(config.selector);
} else {
disableSelectorAndParent(config.selector, config.parent);
}
break;
case "visible":
default:
}
});
const schedulerGlobalButtonsConfig = [
{
name: "logout",
style: "hidden",
selector: ".btn-logout",
},
{
name: "home",
style: "hidden",
selector: ".btn-home",
},
{
name: "scheduler-edit",
style: "hidden",
selector: ".scheduler-edit",
},
{
name: "add",
style: "hidden",
selector: "#event-add",
},
{
name: "delete",
style: "hidden",
selector: ".actions .delete",
},
];
schedulerGlobalButtonsConfig.forEach((config) => {
switch (config.style) {
case "hidden":
hideGlobalSelector(config.selector);
break;
case "disabled":
disableGlobalSelector(config.selector);
break;
case "visible":
default:
}
});
}
}
setCustomSchedulerView();
}
});
Every element you can customize by setting "visible", "hidden" or "disabled".
Done is better than perfect
Posts: 335
Threads: 75
Joined: Jun 2017
Reputation:
6
Hi buuuudzik,
great work, will try today. Thank you!
Alex
Posts: 940
Threads: 161
Joined: Jul 2015
Reputation:
33
Enjoy and feel free to share here new ideas
Done is better than perfect
Posts: 335
Threads: 75
Joined: Jun 2017
Reputation:
6
16.10.2020, 06:49
(This post was last modified: 16.10.2020, 06:56 by AlexLV.)
Hi,
but is possible somehow show at visu times from scheduler or copy them to groups? I want show times at visualization, but if needed - than open scheduler for corrections..
Alex
Posts: 7764
Threads: 42
Joined: Jun 2015
Reputation:
447
Posts: 335
Threads: 75
Joined: Jun 2017
Reputation:
6
Thank you admin,
As I see from example from link you given:
hour = 12 -- event time / start hour
min = 30 -- event time / minute
id = 42 -- event DB id
db:update('scheduler_events', {
start_hour = hour,
start_min = min
}, { id = id })
possible update local db. I think it also means that the same way I can just read db with existing setting and than copy them to group. After that I can show data at visu..
So how I can just read existing scheduler parameters (need Time hour and minute at least) and copy it to groups..
BR,
Alex
Posts: 7764
Threads: 42
Joined: Jun 2015
Reputation:
447
You can get all events for a certain scheduler via a DB query:
Code: scheduler_id = 123
events = db:getall('SELECT * FROM scheduler_events WHERE scheduler=?', scheduler_id)
log(events)
Posts: 335
Threads: 75
Joined: Jun 2017
Reputation:
6
Super,
thank you, I will use it to take details about existing settings.
Alex
Posts: 24
Threads: 7
Joined: May 2018
Reputation:
0
(14.10.2020, 22:31)buuuudzik Wrote: Currently it is possible to show only specified schedulers and hide holidays:
http://4n.lv:7999/scada-vis/schedulers?id=1&nohol
http://4n.lv:7999/scada-vis/schedulers?id=1,2&nohol
To allow further customization I've added yesteday another param support:
http://4n.lv:7999/scada-vis/schedulers?simple
http://4n.lv:7999/scada-vis/schedulers?i...hol&simple
But to use it you must add below code section to your Custom Javascript:
Code: $(function () {
// Simplify and limit scheduler form
if (location.href.match(/\/schedulers(.+)simple/g)) {
function setCustomSchedulerView() {
const inSchedulers = document.body.classList.contains("schedulers");
if (inSchedulers) {
const eventForm = document.getElementById("event-form");
if (!eventForm) return;
const findOnForm = (selector) => eventForm.querySelector(selector);
const hideEl = (el) => (el.style.display = "none");
const disableEl = (el) => (el.disabled = true);
const doOnSelector = (selector, handler) => {
const el = findOnForm(selector);
if (el) handler(el);
};
const doOnGlobalSelector = (selector, handler) => {
const el = document.querySelector(selector);
if (el) handler(el);
};
const doOnSelectorBeforeLabel = (selector, handler) => {
const el = findOnForm(selector);
if (
el &&
el.previousElementSibling &&
el.previousElementSibling.tagName === "LABEL"
)
handler(el.previousElementSibling);
};
const doOnSelectorAndParent = (selector, parentSelector, handler) => {
let el = findOnForm(selector);
if (el) {
handler(el);
let parent = null;
let limit = 10;
while (!parent && limit > 0) {
el = el.parentElement;
if (el && el.matches(parentSelector)) parent = el;
if (!el || parent) break;
limit--;
}
if (parent) handler(parent);
}
};
const hideSelector = (selector) => doOnSelector(selector, hideEl);
const hideGlobalSelector = (selector) => doOnGlobalSelector(selector, hideEl);
const hideSelectorAndParent = (selector, parentSelector) =>
doOnSelectorAndParent(selector, parentSelector, hideEl);
const hideSelectorBeforeLabel = (selector) =>
doOnSelectorBeforeLabel(selector, hideEl);
const disableSelector = (selector) => doOnSelector(selector, disableEl);
const disableGlobalSelector = (selector) => doOnGlobalSelector(selector, disableEl);
const disableSelectorAndParent = (selector, parentSelector) =>
doOnSelectorAndParent(selector, parentSelector, disableEl);
const schedulerFormElementsConfig = [
// style can be one from: "visible", "hidden", "disabled"
{
name: "active",
style: "hidden",
selector: "#event-active",
parent: ".checkbox",
},
{
name: "name",
style: "disabled",
selector: "#event-name",
},
{
name: "type",
style: "visible",
selector: "#event-type",
},
{
name: "type-sunrise-sunset",
style: "visible",
selector: "#event-type-sunrise-sunset",
},
{
name: "daysofweek",
style: "hidden",
selector: "#event-daysofweek",
},
{
name: "dayweeknrs",
style: "hidden",
selector: "#event-dayweeknrs",
},
{
name: "daysofmonth",
style: "hidden",
selector: "#event-daysofmonth",
},
{
name: "months",
style: "hidden",
selector: "#event-months",
},
{
name: "holidays",
style: "hidden",
selector: "#event-holidays",
},
{
name: "year",
style: "hidden",
selector: "#event-year",
parent: ".checkbox",
},
{
name: "value-bool",
style: "disabled",
selector: "#event-value-bool",
},
{
name: "value-color",
style: "disabled",
selector: "#event-value-color",
},
{
name: "value-spinner",
style: "disabled",
selector: "#event-value-spinner",
},
{
name: "value-slider",
style: "disabled",
selector: "#event-value-slider",
},
{
name: "value-enums",
style: "disabled",
selector: "#event-value-enums",
},
{
name: "value-text",
style: "disabled",
selector: "#event-value-text",
},
{
name: "value-lighting",
style: "disabled",
selector: "#event-value-lighting",
},
];
schedulerFormElementsConfig.forEach((config) => {
switch (config.style) {
case "hidden":
if (!config.parent) {
hideSelector(config.selector);
hideSelectorBeforeLabel(config.selector);
} else {
hideSelectorAndParent(config.selector, config.parent);
hideSelectorBeforeLabel(config.parent);
}
break;
case "disabled":
if (!config.parent) {
disableSelector(config.selector);
} else {
disableSelectorAndParent(config.selector, config.parent);
}
break;
case "visible":
default:
}
});
const schedulerGlobalButtonsConfig = [
{
name: "logout",
style: "hidden",
selector: ".btn-logout",
},
{
name: "home",
style: "hidden",
selector: ".btn-home",
},
{
name: "scheduler-edit",
style: "hidden",
selector: ".scheduler-edit",
},
{
name: "add",
style: "hidden",
selector: "#event-add",
},
{
name: "delete",
style: "hidden",
selector: ".actions .delete",
},
];
schedulerGlobalButtonsConfig.forEach((config) => {
switch (config.style) {
case "hidden":
hideGlobalSelector(config.selector);
break;
case "disabled":
disableGlobalSelector(config.selector);
break;
case "visible":
default:
}
});
}
}
setCustomSchedulerView();
}
});
Every element you can customize by setting "visible", "hidden" or "disabled".
I can't access the virtual LM , what's the username and password? , with admin user and admin password no access
Posts: 1764
Threads: 6
Joined: Jul 2015
Reputation:
117
Yeah I noticed that last week, this happens sometimes when someone in the demo LM changes the password, some people do not understand that they should not do that (:
@Edgars: Can you reset the PW?
Posts: 21
Threads: 6
Joined: Aug 2018
Reputation:
1
(18.10.2020, 07:04)Erwin van der Zwart Wrote: Yeah I noticed that last week, this happens sometimes when someone in the demo LM changes the password, some people do not understand that they should not do that (:
@Edgars: Can you reset the PW?
Done!
Thank you very much
|