Пример #1
0
        private string BuildButton(string name)
        {
            var ButtonText = "Submit";
            var b          = new clsJQuery.jqButton(name, "", this.PageName, true);

            switch (name)
            {
            case "ButtonLB":
                ButtonText = "Add to Listbox";
                break;

            case "ButtonDD1":
                ButtonText = "Add to Dropdown 1";
                break;

            case "ButtonDD2":
                ButtonText = "Add to Dropdown 2";
                break;
            }

            b.functionToCallOnClick = "userConfirm()";
            b.includeClickFunction  = true;
            b.id    = "o" + name;
            b.label = ButtonText;

            return(b.Build());
        }
Пример #2
0
        private string BuildButton(string name, bool rebuilding = false)
        {
            var button     = new clsJQuery.jqButton(name, "", this.PageName, false);
            var buttonText = "Submit";

            var ret = string.Empty;

            //'Handles the text for different buttons, based on the button name
            switch (name)
            {
            case "Button1":
                buttonText        = "Go To Status Page";
                button.submitForm = false;
                break;
            }

            button.id    = "o" + name;
            button.label = buttonText;
            ret          = button.Build();

            if (rebuilding)
            {
                this.divToUpdate.Add(name + "_div", ret);
            }
            else
            {
                ret = "<div style='float: left;' id='" + name + "_div'>" + ret + "</div>";
            }

            return(ret);
        }
        /// <summary>
        ///     Return the string required to create a web page button.
        /// </summary>
        protected string FormButton(string name,
                                    string label            = "Submit",
                                    bool submitForm         = true,
                                    string imagePathNormal  = "",
                                    string imagePathPressed = "",
                                    string toolTip          = "",
                                    bool enabled            = true,
                                    string style            = "")
        {
            var b = new clsJQuery.jqButton(name, label, PageName, submitForm)
            {
                id = $"o{name}",
                imagePathNormal = imagePathNormal
            };

            b.imagePathPressed = string.IsNullOrWhiteSpace(imagePathPressed) ? b.imagePathNormal : imagePathPressed;
            b.toolTip          = toolTip;
            b.enabled          = enabled;
            b.style            = style;

            var button = b.Build();

            button = button.Replace("</button>\r\n", "</button>").Trim();
            return(button);
        }
Пример #4
0
        private StringBuilder BuildLinkButton(StringBuilder optionsString, string bName, string bLabel, string bUrl)
        {
            clsJQuery.jqButton button = new clsJQuery.jqButton(bName, bLabel, this.PageName, true);
            button.url = bUrl;
            optionsString.Append(button.Build());

            return(optionsString);
        }
Пример #5
0
        private StringBuilder BuildLinkButton(StringBuilder pluginSB, string bName, string bLabel, string bUrl)
        {
            clsJQuery.jqButton button = new clsJQuery.jqButton(bName, bLabel, this.PageName, true);
            //button.url = bUrl;
            pluginSB.Append(button.Build());

            return(pluginSB);
        }
Пример #6
0
        protected string FormPageButton(string name, string label)
        {
            var b = new clsJQuery.jqButton(name, label, PageName, true)
            {
                id = NameToIdWithPrefix(name),
            };

            return(b.Build());
        }
Пример #7
0
        private string BuildSettingsPage(string user, int userRights, string queryString, string messageBox = null, string messageBoxClass = null)
        {
            string pageName = "IdleLightColorsSettings";

            PageBuilderAndMenu.clsPageBuilder builder = new PageBuilderAndMenu.clsPageBuilder(pageName);
            if ((userRights & 2) != 2)
            {
                // User is not an admin
                builder.reset();
                builder.AddHeader(hs.GetPageHeader(pageName, "HS-WD200+ Idle Light Colors Settings", "", "", false, true));
                builder.AddBody("<p><strong>Access Denied:</strong> You are not an administrative user.</p>");
                builder.AddFooter(hs.GetPageFooter());
                builder.suppressDefaultFooter = true;

                return(builder.BuildPage());
            }

            StringBuilder sb = new StringBuilder();

            sb.Append(
                "<p>The active color will be used when an HS-WD200+ dimmer is in normal mode and is on (at any level).<br />The idle color will be used when an HS-WD200+ dimmer is in normal mode and is off.</p>");
            sb.Append("<p>Status mode will override these colors, as usual.</p>");

            sb.Append(PageBuilderAndMenu.clsPageBuilder.FormStart("ils_config_form", "ils_config_form", "post"));
            sb.Append("<table width=\"1000px\" cellspacing=\"0\"><tr><td class=\"tableheader\" colspan=\"3\">Settings</td></tr>");

            sb.Append("<tr><td class=\"tablecell\" style=\"width:200px\" align=\"left\">Normal Mode Active Color:</td>");
            sb.Append("<td class=\"tablecell\">");
            clsJQuery.jqDropList dropdown = new clsJQuery.jqDropList("ActiveColor", pageName, true);
            BuildColorDropdown(pageName, dropdown, onColor);
            sb.Append(dropdown.Build());
            sb.Append("</td></tr>");

            sb.Append("<tr><td class=\"tablecell\" style=\"width:200px\" align=\"left\">Normal Mode Idle Color:</td>");
            sb.Append("<td class=\"tablecell\">");
            dropdown = new clsJQuery.jqDropList("IdleColor", pageName, true);
            BuildColorDropdown(pageName, dropdown, offColor);
            sb.Append(dropdown.Build());
            sb.Append("</td></tr>");

            sb.Append("</table>");

            clsJQuery.jqButton doneBtn = new clsJQuery.jqButton("DoneBtn", "Done", pageName, false);
            doneBtn.url = "/";
            sb.Append("<br />");
            sb.Append(doneBtn.Build());
            sb.Append("<br /><br />");

            builder.reset();
            builder.AddHeader(hs.GetPageHeader(pageName, "HS-WD200+ Idle Light Colors Settings", "", "", false, true));
            builder.AddBody(sb.ToString());
            builder.AddFooter(hs.GetPageFooter());
            builder.suppressDefaultFooter = true;

            return(builder.BuildPage());
        }
Пример #8
0
        protected string PageTypeButton(string name, string label, string type, string id = null)
        {
            var b = new clsJQuery.jqButton(name, label, PageName, false)
            {
                id  = NameToIdWithPrefix(name),
                url = Invariant($"/{pageUrl}?{PageTypeId}={HttpUtility.UrlEncode(type.ToString(CultureInfo.InvariantCulture))}&{RecordId}={HttpUtility.UrlEncode(id ?? string.Empty)}"),
            };

            return(b.Build());
        }
Пример #9
0
        private string IFrameChangeUrlButton(string name, string iframe, string pageType, string url)
        {
            var button = new clsJQuery.jqButton(name, name, PageName, false)
            {
                id = NameToIdWithPrefix(name),
            };

            button.functionToCallOnClick = Invariant($"$('#{iframe}').prop('src', '{url}')");
            return(button.Build());
        }
Пример #10
0
        protected string PageTypeButton(string name, string label, string pageType, string deviceId = null)
        {
            var b = new clsJQuery.jqButton(name, label, PageName, false)
            {
                id  = NameToIdWithPrefix(name),
                url = Invariant($@"/{HttpUtility.UrlEncode(ConfigPage.Name)}?{PageTypeId}={HttpUtility.UrlEncode(pageType)}&{DeviceIdId}={HttpUtility.UrlEncode(deviceId ?? string.Empty)}"),
            };

            return(b.Build());
        }
        private string HistoryBackButton()
        {
            var b = new clsJQuery.jqButton("Back", "Back", PageName, false)
            {
                id  = NameToIdWithPrefix("Back"),
                url = Invariant($"/{pageUrl}?{TabId}=1"),
            };

            return(b.Build());
        }
Пример #12
0
        public override string GetPagePlugin(string page, string user, int userRights, string queryString)
        {
            HS.WriteLog("Debug", "Requested page name " + page + " by user " + user + " with rights " + userRights);
            if (page != "WebSocketNotificationConfig")
            {
                return("Unknown page " + page);
            }

            PageBuilderAndMenu.clsPageBuilder pageBuilder = new PageBuilderAndMenu.clsPageBuilder(page);

            if ((userRights & 2) != 2)
            {
                // User is not an admin
                pageBuilder.reset();
                pageBuilder.AddHeader(HS.GetPageHeader(page, "WebHook Notifications Settings", "", "", false, true));
                pageBuilder.AddBody("<p><strong>Access Denied:</strong> You are not an administrative user.</p>");
                pageBuilder.AddFooter(HS.GetPageFooter());
                pageBuilder.suppressDefaultFooter = true;

                return(pageBuilder.BuildPage());
            }

            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(
                PageBuilderAndMenu.clsPageBuilder.FormStart("wsn_config_form", "wsn_config_form", "post"));

            stringBuilder.Append(
                "<table width=\"1000px\" cellspacing=\"0\"><tr><td class=\"tableheader\" colspan=\"3\">Settings</td></tr>");

            stringBuilder.Append(
                "<tr><td class=\"tablecell\" style=\"width:200px\" align=\"left\">WebSocket Port:</td>");
            stringBuilder.Append("<td class=\"tablecell\">");

            clsJQuery.jqTextBox textBox =
                new clsJQuery.jqTextBox("WebSocketPort", "text", _port, page, 100, true);
            stringBuilder.Append(textBox.Build());
            stringBuilder.Append("</td></tr>");

            stringBuilder.Append("</table>");

            clsJQuery.jqButton doneBtn = new clsJQuery.jqButton("DoneBtn", "Done", page, false);
            doneBtn.url = "/";
            stringBuilder.Append("<br />");
            stringBuilder.Append(doneBtn.Build());
            stringBuilder.Append("<br /><br />");

            pageBuilder.reset();
            pageBuilder.AddHeader(HS.GetPageHeader(page, "WebSocket Notifications Settings", "", "", false, true));
            pageBuilder.AddBody(stringBuilder.ToString());
            pageBuilder.AddFooter(HS.GetPageFooter());
            pageBuilder.suppressDefaultFooter = true;

            return(pageBuilder.BuildPage());
        }
Пример #13
0
        protected string FormButton(string name, string label, string toolTip, bool submit = true)
        {
            var button = new clsJQuery.jqButton(name, label, PageName, submit)
            {
                id      = NameToIdWithPrefix(name),
                toolTip = toolTip,
            };

            button.toolTip = toolTip;
            button.enabled = true;

            return(button.Build());
        }
Пример #14
0
        private StringBuilder BuildHelpButton(StringBuilder optionsString, string oName, string oTooltip, string oLabel, string oText, string bName, string bLabel, string bUrl)
        {
            clsJQuery.jqOverlay ol = new clsJQuery.jqOverlay(oName, this.PageName, false, "events_overlay");
            ol.toolTip = oTooltip;
            ol.label   = oLabel;
            clsJQuery.jqButton button = new clsJQuery.jqButton(bName, bLabel, this.PageName, true);
            button.url = bUrl;

            ol.overlayHTML  = PageBuilderAndMenu.clsPageBuilder.FormStart("overlayformm", "testpage", "post");
            ol.overlayHTML += "<div>" + oText + "<br><br>" + button.Build() + "</div>";
            ol.overlayHTML += PageBuilderAndMenu.clsPageBuilder.FormEnd();
            optionsString.Append(ol.Build());

            return(optionsString);
        }
Пример #15
0
        /// <summary>
        /// Return the string required to create a web page button.
        /// </summary>
        protected string FormButton(string Name, string label = "Submit", bool SubmitForm   = true,
                                    string ImagePathNormal    = "", string ImagePathPressed = "", string ToolTip = "",
                                    bool Enabled = true, string Style = "")
        {
            clsJQuery.jqButton b = new clsJQuery.jqButton(Name, label, PageName, SubmitForm);
            b.id = "o" + Name;
            b.imagePathNormal  = ImagePathNormal;
            b.imagePathPressed = (ImagePathPressed == "") ? b.imagePathNormal : ImagePathPressed;
            b.toolTip          = ToolTip;
            b.enabled          = Enabled;
            b.style            = Style;

            string Button = b.Build();

            Button.Replace("</button>\r\n", "</button>");
            Button.Trim();
            return(Button);
        }
Пример #16
0
        public PageReturn Page_HS3_EnOcean_Interfaces(String pPageName, String pCleanName, NameValueCollection pArgs)
        {
            var stb = new StringBuilder();

            string conf_node_id = pArgs.Get("configure_node");

            stb.Append(DivStart("pluginpage", ""));

            // Add message area for (ajax) errors
            stb.Append(DivStart("errormessage", "class='errormessage'"));
            stb.Append(DivEnd());

            stb.Append(DivEnd());

            var ifList = mCore.GetInterfaces();

            stb.AppendLine("<h3>Existing controllers</h3>");
            stb.AppendLine("<table border=\"1\" style=\"width: 400px\" cellspacing=\"0\">");
            stb.AppendLine("<tr><th>Interface port</th><th>Status</th></tr>");
            int ifCount = 0;

            foreach (var iface in ifList)
            {
                stb.AppendLine("<tr><td>" + iface.getPortName() + "</td><td>" + iface.getControllerStatus() + "</td></tr>");
                ifCount++;
            }
            if (ifCount == 0)
            {
                stb.AppendLine("<tr><td colspan=\"2\">No interfaces added.</td></tr>");
            }
            stb.AppendLine("</table>");
            // TODO: Show table with existing interfaces and status!

            clsJQuery.jqButton ctrlBtnAddInterface = new clsJQuery.jqButton("add_interface", "Add interface", pPageName, true);
//            var ctrlComPortList = new clsJQuery.jqListBox("com_selector", "");
            stb.AppendLine(FormStart("addForm", pPageName, "POST"));
            stb.AppendLine("<h3>Add new controller instance</h3>");
            stb.AppendLine("<table cellspacing=\"0\">");
            stb.AppendLine("<tr><td>");
            stb.AppendLine("<input type=\"text\" name=\"name\" value=\"Primary Controller\">");
            stb.AppendLine("</td><td>");
            stb.AppendLine("<select name=\"com_selector\">\n");
            foreach (var p in SerialPort.GetPortNames())
            {
                var validPort = true;
                foreach (var i in ifList)
                {
                    if (i.getPortName() == p)
                    {
                        validPort = false;
                    }
                }
                if (validPort)
                {
                    stb.AppendLine("\t<option value=\"" + p + "\">" + p + "</option>\n");
                }
            }
            stb.AppendLine("</select>\n");
            stb.AppendLine("</td></tr>");
            //          stb.Append(ctrlComPortList.Build());
            stb.AppendLine("<tr><td>&nbsp;</td><td>");
            stb.Append("<input type=\"submit\" name=\"add_interface\" value=\"Add\">");
            stb.AppendLine("</td></tr>");
            stb.AppendLine("</table>");
            stb.AppendLine(FormEnd());
            stb.AppendLine("<br/>");
            return(new PageReturn(stb.ToString(), false));
        }
Пример #17
0
        public string GetPagePlugin(string pageName, string user, int userRights, string queryString)
        {
            StringBuilder pluginSB = new StringBuilder();
            OptionsPage   page     = this;

            try
            {
                page.reset();

                // handle queries with special data

                /*System.Collections.Specialized.NameValueCollection parts = null;
                 * if ((!string.IsNullOrEmpty(queryString)))
                 * {
                 *  parts = HttpUtility.ParseQueryString(queryString);
                 * }
                 * if (parts != null)
                 * {
                 *  if (parts["myslide1"] == "myslide_name_open")
                 *  {
                 *      // handle a get for tab content
                 *      string name = parts["name"];
                 *      return ("<table><tr><td>cell1</td><td>cell2</td></tr><tr><td>cell row 2</td><td>cell 2 row 2</td></tr></table>");
                 *      //Return ("<div><b>content data for tab</b><br><b>content data for tab</b><br><b>content data for tab</b><br><b>content data for tab</b><br><b>content data for tab</b><br><b>content data for tab</b><br></div>")
                 *  }
                 *  if (parts["myslide1"] == "myslide_name_close")
                 *  {
                 *      return "";
                 *  }
                 * }*/

                this.AddHeader(Util.hs.GetPageHeader(pageName, Util.IFACE_NAME, "", "", false, true));
                //pluginSB.Append("<link rel = 'stylesheet' href = 'hspi_rachiosiid/css/style.css' type = 'text/css' /><br>");
                //page.AddHeader(pluginSB.ToString());



                //page.RefreshIntervalMilliSeconds = 5000
                // handler for our status div
                //stb.Append(page.AddAjaxHandler("/devicestatus?ref=3576", "stat"))
                pluginSB.Append(this.AddAjaxHandlerPost("action=updatetime", this.PageName));



                // page body starts here



                pluginSB.Append(clsPageBuilder.DivStart("pluginpage", ""));
                //Dim dv As DeviceClass = GetDeviceByRef(3576)
                //Dim CS As CAPIStatus
                //CS = dv.GetStatus

                pluginSB.AppendLine("<table class='full_width_table' cellspacing='0' width='100%' >");
                pluginSB.AppendLine("<tr><td  colspan='1' >");
                // Status/Options Tabs

                clsJQuery.jqTabs jqtabs = new clsJQuery.jqTabs("optionsTab", this.PageName);

                // Options Tab
                clsJQuery.Tab tab = new clsJQuery.Tab();
                tab          = new clsJQuery.Tab();
                tab.tabTitle = "Options";
                tab.tabDIVID = "rachiosiid-options";

                var optionsString = new StringBuilder();

                optionsString.Append("<table cellspacing='0' cellpadding='5'  width='100%'>");

                // Rachio API Access Token
                optionsString.Append("<tr><td class='tableheader' colspan='2'>Rachio API Access Token</td></tr>");
                optionsString.Append("<tr><td class='tablecell'>API Access Token</td>");
                optionsString.Append("<td class='tablecell'>");
                optionsString.Append(PageBuilderAndMenu.clsPageBuilder.FormStart("myform1", "testpage", "post"));


                clsJQuery.jqTextBox tokenTextBox = new clsJQuery.jqTextBox("APIToken", "text", apiKey, this.PageName, 30, true);
                tokenTextBox.promptText  = "Enter your Rachio API access token.";
                tokenTextBox.toolTip     = "Access Token";
                tokenTextBox.dialogWidth = 600;
                optionsString.Append(tokenTextBox.Build());



                clsJQuery.jqOverlay ol = new clsJQuery.jqOverlay("ov1", this.PageName, false, "events_overlay");
                ol.toolTip = "Help with API Access Token";
                ol.label   = "Help?";

                clsJQuery.jqButton apiBut = new clsJQuery.jqButton("apilink", "Rachio-API", this.PageName, true);
                apiBut.url = "https://app.rach.io/";

                ol.overlayHTML  = PageBuilderAndMenu.clsPageBuilder.FormStart("overlayformm", "testpage", "post");
                ol.overlayHTML += "<div>If you don't have an<br>access token saved, follow<br>the button link below to<br>navigate to the Rachio API.<br>Sign in and copy the <br>API Access Token within<br> the settings menu on the<br>top-right of the page.<br><br>" + apiBut.Build() + "</div>";
                ol.overlayHTML += PageBuilderAndMenu.clsPageBuilder.FormEnd();
                optionsString.Append(ol.Build());
                optionsString.Append(PageBuilderAndMenu.clsPageBuilder.FormEnd());
                optionsString.Append("</td></tr>");

                // Rachio Options
                optionsString.Append("<tr><td class='tableheader' colspan='2'>Rachio Options</td></tr>");

                optionsString.Append("<tr><td class='tablecell'>Unit Type</td>");
                optionsString.Append("<td class='tablecell'>");
                clsJQuery.jqDropList dl = new clsJQuery.jqDropList("unitType", this.PageName, false);
                dl.toolTip = "Select your preferred units.";
                if (unitType == null || unitType.Equals("US"))
                {
                    dl.AddItem("U.S. customary  units (miles, °F, etc...)", "1", true);
                    dl.AddItem("Metric system units (kms, °C, etc...)", "2", false);
                }
                else
                {
                    dl.AddItem("U.S. customary  units (miles, °F, etc...)", "1", false);
                    dl.AddItem("Metric system units (kms, °C, etc...)", "2", true);
                }
                dl.autoPostBack = true;
                optionsString.Append(dl.Build());

                clsJQuery.jqDropList dl2 = new clsJQuery.jqDropList("updateInterval", this.PageName, false);
                optionsString.Append("</td></tr>");

                optionsString.Append("<tr><td class='tablecell'>Update Frequency</td>");
                optionsString.Append("<td class='tablecell'>");
                dl2.toolTip = "Specify how often RachioSIID receives updates from the Rachio API servers.";

                for (int i = 1; i < 61; i++)
                {
                    dl2.AddItem(i.ToString() + " Minute(s)", i.ToString(), updateInterval == i);
                }

                dl2.autoPostBack = true;
                optionsString.Append(dl2.Build());

                optionsString.Append("</td></tr>");

                optionsString.Append("<tr><td class='tablecell'>Zones View</td>");
                optionsString.Append("<td class='tablecell'>");
                optionsString.Append(PageBuilderAndMenu.clsPageBuilder.FormStart("myform2", "testpage", "post"));

                clsJQuery.jqOverlay ol2 = new clsJQuery.jqOverlay("ov2", this.PageName, false, "events_overlay");
                ol2.toolTip      = "Specify which Zone devices are in view";
                ol2.label        = "Zones";
                ol2.overlayHTML  = PageBuilderAndMenu.clsPageBuilder.FormStart("overlayformm", "testpage", "post");
                ol2.overlayHTML += "<div>Select which Zones are visible:<br><br>";

                for (int i = 1; i < 17; i++)
                {
                    clsJQuery.jqCheckBox zoneCheck = new clsJQuery.jqCheckBox("ZoneCheck" + i, "Zone " + i, this.PageName, true, false);
                    if (ZoneChecks != null)
                    {
                        zoneCheck.@checked = ZoneChecks[i - 1];
                    }
                    else
                    {
                        zoneCheck.@checked = true;
                    }
                    zoneCheck.enabled = true;
                    ol2.overlayHTML  += zoneCheck.Build() + "<br>";
                }

                ol2.overlayHTML += "</div>";
                ol2.overlayHTML += PageBuilderAndMenu.clsPageBuilder.FormEnd();
                optionsString.Append(ol2.Build());
                optionsString.Append(PageBuilderAndMenu.clsPageBuilder.FormEnd());
                optionsString.Append("</td></tr>");

                // Homeseer Device Options

                /*optionsString.Append("<tr><td class='header' colspan='2'>Homeseer Device Options</td></tr>");
                 *
                 * optionsString.Append("<tr><td>Forecast Days</td>");
                 * optionsString.Append("<td>");
                 * dl.toolTip = "Specify the number of days to create weather forecast devices.";
                 *
                 *
                 * dl.AddItem("Disabled", "1", false);
                 * dl.AddItem("Today's Forecast", "2", true);
                 * dl.AddItem("Today's and Tomorrow's Forecast", "3", false);
                 * for (int i = 4; i < 9; i++)
                 * {
                 *      dl.AddItem((i-2).ToString() + " Day Forecast", i.ToString(), false);
                 * }
                 *
                 * dl.autoPostBack = true;
                 * optionsString.Append(dl.Build());
                 * dl.ClearItems();
                 * optionsString.Append("</td></tr>");
                 *
                 * optionsString.Append("<tr><td>Device Image</td>");
                 * optionsString.Append("<td>");
                 * dl.toolTip = "Select your preferred units.";
                 * dl.AddItem("Yes", "1", true);
                 * dl.AddItem("No", "2", false);
                 * dl.autoPostBack = true;
                 * optionsString.Append(dl.Build());
                 * dl.ClearItems();
                 * optionsString.Append("</td></tr>");*/

                // Web Page Access

                /*optionsString.Append("<tr><td class='header' colspan='2'>Web Page Access</td></tr>");
                 *
                 * optionsString.Append("<tr><td>Forecast Days</td>");
                 * optionsString.Append("<td>");
                 * optionsString.Append(PageBuilderAndMenu.clsPageBuilder.FormStart("FormCheckbox", "userroles", "post"));
                 *
                 * clsJQuery.jqCheckBox guestCheck = new clsJQuery.jqCheckBox("guestCheck", "Guest", this.PageName, true, false);
                 * guestCheck.@checked = false;
                 * optionsString.Append(guestCheck.Build());
                 *
                 * clsJQuery.jqCheckBox adminCheck = new clsJQuery.jqCheckBox("adminCheck", "Admin", this.PageName, true, false);
                 * adminCheck.@checked = true;
                 * adminCheck.enabled = false;
                 * optionsString.Append(adminCheck.Build());
                 *
                 * clsJQuery.jqCheckBox normalCheck = new clsJQuery.jqCheckBox("normalCheck", "Normal", this.PageName, true, false);
                 * normalCheck.@checked = false;
                 * optionsString.Append(normalCheck.Build());
                 *
                 * clsJQuery.jqCheckBox localCheck = new clsJQuery.jqCheckBox("localCheck", "Local", this.PageName, true, false);
                 * localCheck.@checked = false;
                 * optionsString.Append(localCheck.Build());
                 *
                 * optionsString.Append("</td></tr>");*/

                // Applications Options
                optionsString.Append("<tr><td class='tableheader' colspan='2'>Applications Options</td></tr>");
                optionsString.Append("<tr><td class='tablecell'>Logging Level</td>");
                optionsString.Append("<td class='tablecell'>");

                clsJQuery.jqDropList dl3 = new clsJQuery.jqDropList("loggingType", this.PageName, false);
                dl3.toolTip = "Specifiy the plugin logging level";
                if (loggingType == "Off")
                {
                    dl3.AddItem("Off", "1", true);
                    dl3.AddItem("Debug", "2", false);
                }
                else
                {
                    dl3.AddItem("Off", "1", false);
                    dl3.AddItem("Debug", "2", true);
                }

                /*var logLevel = new string[10] {"", "Emergency", "Alert", "Critical", "Error", "Warning", "Notice", "", "Trace", "Debug"};
                 * for (int i = 1; i < 10; i++)
                 * {
                 *  if(i==7)
                 *      dl.AddItem("Informational", i.ToString(), true);
                 *  else
                 *      dl.AddItem(logLevel[i], i.ToString(), false);
                 * }*/

                dl3.autoPostBack = true;
                optionsString.Append(dl3.Build());

                optionsString.Append("</td></tr>");

                optionsString.Append("</table>");



                tab.tabContent = optionsString.ToString();
                jqtabs.tabs.Add(tab);

                pluginSB.Append(jqtabs.Build());
                pluginSB.AppendLine("</td></tr></table>");


                // container test
                //Dim statCont As New clsJQuery.jqContainer("contid", "Office Lamp", "/homeseer/on.gif", 100, 100, "this is the content")
                //stb.Append(statCont.build)
            }
            catch (Exception ex)
            {
                pluginSB.Append("Status/Options error: " + ex.Message);
            }
            pluginSB.Append("<br>");

            pluginSB.Append(DivEnd());
            page.AddBody(pluginSB.ToString());

            return(page.BuildPage());
        }
Пример #18
0
        public override string GetPagePlugin(string pageName, string user, int userRights, string queryString)
        {
            Program.WriteLog(LogType.Debug, "Requested page name " + pageName + " by user " + user + " with rights " + userRights);
            if (pageName != "WebHookNotificationConfig")
            {
                return("Unknown page " + pageName);
            }

            PageBuilderAndMenu.clsPageBuilder pageBuilder = new PageBuilderAndMenu.clsPageBuilder(pageName);

            if ((userRights & 2) != 2)
            {
                // User is not an admin
                pageBuilder.reset();
                pageBuilder.AddHeader(hs.GetPageHeader(pageName, "WebHook Notifications Settings", "", "", false, true));
                pageBuilder.AddBody("<p><strong>Access Denied:</strong> You are not an administrative user.</p>");
                pageBuilder.AddFooter(hs.GetPageFooter());
                pageBuilder.suppressDefaultFooter = true;

                return(pageBuilder.BuildPage());
            }

            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(
                PageBuilderAndMenu.clsPageBuilder.FormStart("whn_config_form", "whn_config_form", "post"));

            stringBuilder.Append(
                "<table width=\"1000px\" cellspacing=\"0\"><tr><td class=\"tableheader\" colspan=\"3\">Settings</td></tr>");

            clsJQuery.jqCheckBox checkBox;
            for (byte i = 1; i <= TOTAL_WEBHOOK_SLOTS; i++)
            {
                stringBuilder.Append(
                    "<tr><td class=\"tablecell\" style=\"width:200px\" align=\"left\">WebHook URL " + i + ":</td>");
                stringBuilder.Append("<td class=\"tablecell\">");

                clsJQuery.jqTextBox textBox =
                    new clsJQuery.jqTextBox("WebHookUrl" + i, "text", webHooks[i - 1]?.ToString(), pageName, 100, true);
                stringBuilder.Append(textBox.Build());
                stringBuilder.Append("</td><td class=\"tablecell\" style=\"width:300px\">");

                checkBox          = new clsJQuery.jqCheckBox("IgnoreInvalidCertificate" + i, "Ignore invalid HTTPS certificate", pageName, true, true);
                checkBox.@checked = hs.GetINISetting("IgnoreCertificate", "webhook" + i, "0", IniFilename) == "1";
                stringBuilder.Append(checkBox.Build());

                stringBuilder.Append("</td></tr>");
            }

            stringBuilder.Append("<tr><td class=\"tablecell\" style=\"width:200px\" align=\"left\"></td>");
            stringBuilder.Append("<td class=\"tablecell\" colspan=\"2\">");
            checkBox = new clsJQuery.jqCheckBox(
                "IgnoreTimerEvents",
                "Suppress WebHooks for HS3 timers",
                pageName,
                true,
                true
                );
            checkBox.@checked = ignoreTimerEvents;
            stringBuilder.Append(checkBox.Build());
            stringBuilder.Append("</td></tr>");

            stringBuilder.Append("<tr><td class=\"tablecell\" style=\"width:250px\" align=\"left\"></td>");
            stringBuilder.Append("<td class=\"tablecell\" colspan=\"2\">");
            checkBox = new clsJQuery.jqCheckBox(
                "IgnoreUnchangedEvents",
                "Suppress WebHooks for events in which a device's value did not change (not effective on STRING_CHANGE events)",
                pageName,
                true,
                true
                );
            checkBox.@checked = ignoreUnchangedEvents;
            stringBuilder.Append(checkBox.Build());
            stringBuilder.Append("</td></tr>");

            stringBuilder.Append("</table>");

            clsJQuery.jqButton doneBtn = new clsJQuery.jqButton("DoneBtn", "Done", pageName, false);
            doneBtn.url = "/";
            stringBuilder.Append("<br />");
            stringBuilder.Append(doneBtn.Build());
            stringBuilder.Append("<br /><br />");

            pageBuilder.reset();
            pageBuilder.AddHeader(hs.GetPageHeader(pageName, "WebHook Notifications Settings", "", "", false, true));
            pageBuilder.AddBody(stringBuilder.ToString());
            pageBuilder.AddFooter(hs.GetPageFooter());
            pageBuilder.suppressDefaultFooter = true;

            return(pageBuilder.BuildPage());
        }
Пример #19
0
        public PageReturn Page_HS3_EnOcean_Interfaces(String pPageName, String pCleanName, NameValueCollection pArgs)
        {
            var stb = new StringBuilder();

            string conf_node_id = pArgs.Get("configure_node");
            stb.Append(DivStart("pluginpage", ""));

            // Add message area for (ajax) errors
            stb.Append(DivStart("errormessage", "class='errormessage'"));
            stb.Append(DivEnd());

            stb.Append(DivEnd());

            var ifList = mCore.GetInterfaces();
            stb.AppendLine("<h3>Existing controllers</h3>");
            stb.AppendLine("<table border=\"1\" style=\"width: 400px\" cellspacing=\"0\">");
            stb.AppendLine("<tr><th>Interface port</th><th>Status</th></tr>");
            int ifCount = 0;
            foreach (var iface in ifList)
            {
                stb.AppendLine("<tr><td>" + iface.getPortName() + "</td><td>" + iface.getControllerStatus() + "</td></tr>");
                ifCount++;
            }
            if (ifCount == 0)
                stb.AppendLine("<tr><td colspan=\"2\">No interfaces added.</td></tr>");
            stb.AppendLine("</table>");
            // TODO: Show table with existing interfaces and status!

            clsJQuery.jqButton ctrlBtnAddInterface = new clsJQuery.jqButton("add_interface", "Add interface", pPageName, true);
            //            var ctrlComPortList = new clsJQuery.jqListBox("com_selector", "");
            stb.AppendLine(FormStart("addForm", pPageName, "POST"));
            stb.AppendLine("<h3>Add new controller instance</h3>");
            stb.AppendLine("<table cellspacing=\"0\">");
            stb.AppendLine("<tr><td>");
            stb.AppendLine("<input type=\"text\" name=\"name\" value=\"Primary Controller\">");
            stb.AppendLine("</td><td>");
            stb.AppendLine("<select name=\"com_selector\">\n");
            foreach (var p in SerialPort.GetPortNames())
            {
                var validPort = true;
                foreach (var i in ifList)
                {
                    if (i.getPortName() == p)
                        validPort = false;
                }
                if (validPort)
                    stb.AppendLine("\t<option value=\"" + p + "\">" + p + "</option>\n");
            }
            stb.AppendLine("</select>\n");
            stb.AppendLine("</td></tr>");
              //          stb.Append(ctrlComPortList.Build());
            stb.AppendLine("<tr><td>&nbsp;</td><td>");
            stb.Append("<input type=\"submit\" name=\"add_interface\" value=\"Add\">");
            stb.AppendLine("</td></tr>");
            stb.AppendLine("</table>");
            stb.AppendLine(FormEnd());
            stb.AppendLine("<br/>");
            return new PageReturn(stb.ToString(), false);
        }