/// <summary> /// Return the string required to create a web page check box. /// </summary> protected string FormCheckBox(string Name, bool Checked = false, bool AutoPostBack = true, bool SubmitForm = true) { clsJQuery.jqCheckBox cb = new clsJQuery.jqCheckBox(Name, "", PageName, AutoPostBack, SubmitForm); cb.id = "o" + Name; cb.@checked = Checked; return(cb.Build()); }
public string BuildCheckbox(string name, bool rebuilding = false, string label = "") { var checkbox = new clsJQuery.jqCheckBox(name, label, this.PageName, true, false); checkbox.id = "o" + name; switch (name) { case "CheckboxLogTimer": checkbox.@checked = _settings.LogTimerElapsed; break; case "CheckboxDebugLogging": checkbox.@checked = _settings.DebugLog; break; } var ret = string.Empty; if (rebuilding) { ret = checkbox.Build(); this.divToUpdate.Add(name + "_div", ret); } else { ret = "<div style='float: left;' id='" + name + "_div'>" + checkbox.Build() + "</div>"; } return(ret); }
private string CreateUiForFutureComputation(clsJQuery.jqCheckBox checkDoFutureComputation, DataCurveTriggerSettings triggerSettings) { var sb = new StringBuilder(); sb.AppendLine( "<tr><th class='not_mapped_style' style='text-align:left' colspan='6'>Future computation:</th></tr>"); sb.AppendLine($"<tr><td colspan='7'>{checkDoFutureComputation.Build()} Use future computation</td></tr>"); sb.AppendLine(CreateFutureComputationUi(triggerSettings)); return(sb.ToString()); }
protected string FormCheckBox(string name, string label, bool @checked) { var checkbox = new clsJQuery.jqCheckBox(name, label, PageName, true, true) { id = NameToIdWithPrefix(name), @checked = @checked, }; return(checkbox.Build()); }
protected string FormCheckBox(string name, string label, bool @checked, bool autoPostBack = false) { var cb = new clsJQuery.jqCheckBox(name, label, PageName, true, true) { id = NameToIdWithPrefix(name), @checked = @checked, autoPostBack = autoPostBack, }; return(cb.Build()); }
/// <summary> /// Return the string required to create a web page check box. /// </summary> protected string FormCheckBox(string name, bool Checked = false, bool autoPostBack = true, bool submitForm = true) { var cb = new clsJQuery.jqCheckBox(name, "", PageName, autoPostBack, submitForm) { id = "o" + name, @checked = Checked }; return(cb.Build()); }
/// <summary> /// Return the string required to create a web page check box. /// </summary> protected string FormCheckBox(string name, bool @checked = false, bool autoPostBack = true, bool submitForm = true) { var cb = new clsJQuery.jqCheckBox(name, string.Empty, PageName, autoPostBack, submitForm) { id = $"o{name}", @checked = @checked }; return(cb.Build()); }
public override string ConfigDevice(int @ref, string user, int userRights, bool newDevice) { if ((userRights & 2) != 2) { // User is not an admin return("<p><strong>Access Denied:</strong> You are not an administrative user.</p>"); } bool deviceIsExempt = hs.GetINISetting("IgnoreDeviceRefs", @ref.ToString(), "", IniFilename) == "1"; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(PageBuilderAndMenu.clsPageBuilder.FormStart("whn_device_config_form", "whn_device_config_form", "post")); clsJQuery.jqCheckBox checkBox = new clsJQuery.jqCheckBox("ignore_device", "Don't send webhook notifications for this feature", "deviceutility", true, true); checkBox.@checked = deviceIsExempt; stringBuilder.Append(checkBox.Build()); stringBuilder.Append(PageBuilderAndMenu.clsPageBuilder.FormEnd()); return(stringBuilder.ToString()); }
private string BuildTabCB() { var stb = new StringBuilder(); var cb1 = new clsJQuery.jqCheckBox("CB1", "check 1", this.PageName, true, false); var cb2 = new clsJQuery.jqCheckBox("CB2", "check 2", this.PageName, true, true); var cb3 = new clsJQuery.jqCheckBox("CB3", "check 3", this.PageName, false, true); var cb4 = new clsJQuery.jqCheckBox("CB4", "check 4", this.PageName, false, false); cb1.id = "oCB1"; cb2.id = "oCB2"; cb3.id = "oCB3"; cb4.id = "oCB4"; stb.Append(PageBuilderAndMenu.clsPageBuilder.FormStart("frmTab2", "checkbox", "Post")); stb.Append(cb1.Build()); stb.Append(cb2.Build()); stb.Append(cb3.Build()); stb.Append(cb4.Build()); stb.Append(BuildButton("ButtonCB1") + " "); stb.Append(PageBuilderAndMenu.clsPageBuilder.FormEnd()); return(stb.ToString()); }
private string CreateChoicesForFutureComputation(DataCurveTriggerSettings triggerSettings) { var sb = new StringBuilder(); var checkDoFutureComputation = new clsJQuery.jqCheckBox(Constants.CheckIfUseFutureComputationKey + triggerSettings.UID + triggerSettings.UniqueControllerId, "", Constants.EventsPage, true, true); checkDoFutureComputation.@checked = triggerSettings.UseFutureComputation; checkDoFutureComputation.toolTip = "Try to estimate the future value"; if (!triggerSettings.UseFutureComputation) { var fontType = "class='not_mapped_style' style='font-style: italic'"; sb.AppendLine("<tr><th class='not_mapped_style' style='text-align:left'>Future computation:</th></tr>"); sb.AppendLine($"<tr><td {fontType} colspan='7'>{checkDoFutureComputation.Build()} No future computation </td></tr>"); } else { sb.AppendLine(CreateUiForFutureComputation(checkDoFutureComputation, triggerSettings)); } return(sb.ToString()); }
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()); }
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()); }