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
#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


Messages In This Thread
RE: Scheduler more customisation needed - by josemabera - 17.10.2020, 19:26

Forum Jump: