This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Scheduler more customisation needed
#1
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 Sad

BR,

Alex
Reply
#2
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
Reply
#3
Hi buuuudzik,

great work, will try today. Thank you!

Alex
Reply
#4
Enjoy and feel free to share here new ideasWink
Done is better than perfect
Reply
#5
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
Reply
#6
See this: https://forum.logicmachine.net/showthread.php?tid=686
Reply
#7
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
Reply
#8
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)
Reply
#9
Super,

thank you, I will use it to take details about existing settings.

Alex
Reply
#10
(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
Reply
#11
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?
Reply
#12
(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
Reply


Forum Jump: