public void FillJobDropDown() { _jobSelectDropdown.Clear(); foreach (JobEntry jobEntry in PageStorage <ManualData> .Instance.StorageData.JobEntries) { bool active = jobEntry.BatchEntries.Any(batchEntry => batchEntry.Name == _batch.Name); StylableAnchor entry = _jobSelectDropdown.AddEntry(jobEntry.Name, active); entry.Click += (sender, args) => { if (active) { _appendToJobButton.IsHidden = true; _removeFromJobButton.IsHidden = false; } else { _appendToJobButton.IsHidden = false; _removeFromJobButton.IsHidden = true; } _jobSelectDropdown.Button.Text = jobEntry.Name; _jobNameMultiInputGroup.IsHidden = true; }; } _jobSelectDropdown.AddDivider(); _jobSelectDropdown.AddEntry(NewJobString).Click += (sender, args) => { _jobSelectDropdown.Button.Text = NewJobString; _jobNameMultiInputGroup.IsHidden = false; _appendToJobButton.IsHidden = false; _removeFromJobButton.IsHidden = true; }; }
private void AddHumiditySensor(ChannelData channel, Grid grid) { List <StylableAnchor> humiditySensorEntries = new List <StylableAnchor>(); MultiInputGroup humiditySensorMultiInputGroup = new MultiInputGroup(); humiditySensorMultiInputGroup.AddStyling(StylingOption.MarginTop, 4); humiditySensorMultiInputGroup.AppendLabel("Feuchtigkeitssensor"); _humiditySensorEnabledTwoStateButtonGroup = new TwoStateButtonGroup("Aktiv", "Inaktiv", channel.HumiditySensorEnabled, !channel.HumiditySensorEnabled); humiditySensorMultiInputGroup.AppendCustomElement(_humiditySensorEnabledTwoStateButtonGroup, false); _humiditySensorDropdown = new Dropdown(new Button(StylingColor.Secondary, true, text: "N/A")); _humiditySensorDropdown.Button.SetAttribute("data-realName", channel.HumiditySensor); Anchor humiditySensorNone = _humiditySensorDropdown.AddEntry("Ohne", _humiditySensorDropdown.Button.GetAttribute("data-realName").ToString() == ""); humiditySensorNone.Click += (sender, args) => { _humiditySensorDropdown.Button.SetAttribute("data-realName", ""); UpdateHumiditySensorDropDown(humiditySensorEntries, humiditySensorNone); }; _humiditySensorDropdown.AddDivider(); foreach ((string realSensorName, string customSensorName) in PageStorage <SettingsData> .Instance.StorageData.HumiditySensors) { StylableAnchor humiditySensorEntry = _humiditySensorDropdown.AddEntry(customSensorName, _humiditySensorDropdown.Button.GetAttribute("data-realName").ToString() == realSensorName); humiditySensorEntry.SetToolTip(ToolTipLocation.Right, realSensorName); humiditySensorEntry.Click += (sender, args) => { _humiditySensorDropdown.Button.SetAttribute("data-realName", realSensorName); UpdateHumiditySensorDropDown(humiditySensorEntries, humiditySensorNone); }; humiditySensorEntry.SetAttribute("data-realName", realSensorName); humiditySensorEntries.Add(humiditySensorEntry); } UpdateHumiditySensorDropDown(humiditySensorEntries, humiditySensorNone); humiditySensorMultiInputGroup.AppendCustomElement(_humiditySensorDropdown, false); grid.AddRow().AppendCollum(humiditySensorMultiInputGroup, autoSize: true); }
public SettingsPage(PageStorage <SettingsData> settingsData) : base("div") { bool useSafeLoading = false; if (settingsData.TryLoad() == false) { settingsData.UseSafeLoading(); useSafeLoading = true; } if (PageStorage <HumiditySensorData> .Instance.TryLoad() == false) { PageStorage <HumiditySensorData> .Instance.UseSafeLoading(); useSafeLoading = true; } this.AddScriptDependency("/lib/bootstrap3-typeahead.min.js"); const int labelSize = 180; _settingsData = settingsData; #region Initialize Grid Container wrappingContainer = new Container(this); Grid grid = new Grid(wrappingContainer); grid.AddStyling(StylingOption.MarginRight, 2); grid.AddStyling(StylingOption.MarginLeft, 2); grid.AddStyling(StylingOption.MarginTop, 4); grid.AddStyling(StylingOption.MarginBottom, 2); #endregion Initialize Grid if (useSafeLoading) { grid.AddRow().AppendCollum(new Heading(3, "Wegen Verbindungsproblemem wurden keine Daten geladen!") { Style = { Color = Color.Red } }); } #region AutoEnabled MultiInputGroup autoEnabledMultiInputGroup = new MultiInputGroup(); autoEnabledMultiInputGroup.AppendLabel("Automatik", labelSize); autoEnabledMultiInputGroup .AppendCustomElement( new TwoStateButtonGroup("Aktiv", "Inaktiv", settingsData.StorageData.Enabled, !settingsData.StorageData.Enabled), false).FirstButtonStateChange += (sender, args) => settingsData.StorageData.Enabled = args.NewButtonState; autoEnabledMultiInputGroup.AddStyling(StylingOption.MarginBottom, 2); autoEnabledMultiInputGroup.AppendCustomElement(new Button(StylingColor.Danger, true, Button.ButtonSize.Normal, false, "Alle Kanäle ausschalten", fontAwesomeIcon: "stop"), false).Click += (sender, args) => { ServerConnection.DeleteAsync("settings", "stopall"); }; grid.AddRow().AppendCollum(autoEnabledMultiInputGroup, autoSize: true); #endregion AutoEnabled #region WeatherEnabled MultiInputGroup weatherEnabledMultiInputGroup = new MultiInputGroup(); weatherEnabledMultiInputGroup.AppendLabel("Wetterdaten verwenden", labelSize); weatherEnabledMultiInputGroup .AppendCustomElement( new TwoStateButtonGroup("Aktiv", "Inaktiv", settingsData.StorageData.WeatherEnabled, !settingsData.StorageData.WeatherEnabled), false).FirstButtonStateChange += (sender, args) => settingsData.StorageData.WeatherEnabled = args.NewButtonState; weatherEnabledMultiInputGroup.AddStyling(StylingOption.MarginBottom, 2); grid.AddRow().AppendCollum(weatherEnabledMultiInputGroup, autoSize: true); #endregion WeatherEnabled #region Location Row locationRow = grid.AddRow(); locationRow.AddStyling(StylingOption.MarginBottom, 2); MultiInputGroup weatherLocationMultiInputGroup = new MultiInputGroup(); weatherLocationMultiInputGroup.AppendLabel("Standort", labelSize); StylableTextInput weatherLocationTextInput = weatherLocationMultiInputGroup.AppendTextInput("Bitte Eintragen...", false); weatherLocationTextInput.Value = settingsData.StorageData.LocationFriendlyName; #region Hidden TextInputs TextInput weatherLocationChangeTextInput = new TextInput { IsHidden = true, Value = settingsData.StorageData.Location }; locationRow.AppendChild(weatherLocationChangeTextInput); TextInput weatherLocationNameChangeTextInput = new TextInput { IsHidden = true, Value = settingsData.StorageData.LocationFriendlyName }; locationRow.AppendChild(weatherLocationNameChangeTextInput); #endregion Hidden TextInputs #region Autocomplete weatherLocationTextInput.ActivateAutocomplete("/settings/WeatherLocations.json", new Dictionary <string, TextInput>() { { "location", weatherLocationChangeTextInput }, { "name", weatherLocationNameChangeTextInput } }); #endregion Autocomplete locationRow.AppendCollum(weatherLocationMultiInputGroup, autoSize: true); #region Save Button Button saveLocationButton = new Button(StylingColor.Success, true, text: "Übernehmen"); saveLocationButton.Click += (sender, args) => { if (weatherLocationChangeTextInput.Value == "") { weatherLocationTextInput.SetValidation(false, true); } else { weatherLocationTextInput.SetValidation(false, false); settingsData.StorageData.Location = weatherLocationChangeTextInput.Value; settingsData.StorageData.LocationFriendlyName = weatherLocationNameChangeTextInput.Value; weatherLocationTextInput.Value = settingsData.StorageData.LocationFriendlyName; } }; locationRow.AppendCollum(saveLocationButton, autoSize: true); #endregion Save Button #endregion Location #region Override _overrideInputGroup = new OverrideInputGroup(_settingsData.StorageData.OverrideValue, labelSizeInPx: labelSize); grid.AddRow().AppendCollum(_overrideInputGroup, autoSize: true); #endregion Override #region Rename HumiditySensors Row humidityRow = grid.AddRow(); humidityRow.AppendChild(new Heading(3, "Feuchigkeitssensoren Umbenennen")); humidityRow.AddNewLine(); #region Sync Server HumidityList with Storage foreach (string humiditySensor in PageStorage <HumiditySensorData> .Instance.StorageData.HumiditySensors) { if (settingsData.StorageData.HumiditySensors.ContainsKey(humiditySensor) == false) { settingsData.StorageData.HumiditySensors.Add(humiditySensor, humiditySensor); } } List <string> removeList = new List <string>(); foreach ((string realSensorName, string _) in settingsData.StorageData.HumiditySensors) { if (PageStorage <HumiditySensorData> .Instance.StorageData.HumiditySensors.Contains(realSensorName) == false) { removeList.Add(realSensorName); } } foreach (string s in removeList) { settingsData.StorageData.HumiditySensors.Remove(s); } #endregion Sync Server HumidityList with Storage _humidityDropdown = new Dropdown(new Button(StylingColor.Secondary, true, widthInPx: 150)); humidityRow.AppendCollum(_humidityDropdown, autoSize: true); foreach (string humiditySensor in PageStorage <HumiditySensorData> .Instance.StorageData.HumiditySensors) { StylableAnchor stylableAnchor = _humidityDropdown.AddEntry(humiditySensor); stylableAnchor.Click += (sender, args) => SelectHumiditySensor(humiditySensor); } _humiditySensorTextInputGroup = new TextInputGroup("Freundlicher Name", "Bitte Eingeben!"); humidityRow.AppendCollum(_humiditySensorTextInputGroup, autoSize: true); Button button = new Button(StylingColor.Success, true, text: "Übernehmen"); button.Click += (sender, args) => { if (_humidityDropdown.Button.Text != "") { _settingsData.StorageData.HumiditySensors[_humidityDropdown.Button.Text] = _humiditySensorTextInputGroup.TextInput.Value; } }; humidityRow.AppendCollum(button, autoSize: true); if (PageStorage <HumiditySensorData> .Instance.StorageData.HumiditySensors.Count > 0) { SelectHumiditySensor(PageStorage <HumiditySensorData> .Instance.StorageData.HumiditySensors.First()); } else { humidityRow.IsHidden = true; } humidityRow.AddStyling(StylingOption.MarginBottom, 2); #endregion Rename HumiditySensors #region Backend Server Path grid.AddRow().AppendCollum(new Heading(3, "Backend Server Schnittstelle einstellen") { ClassName = "text-center mb-4" }); Row backendServerRow = grid.AddRow(); Row backendServerConfigurationSingeApiRow = grid.AddRow(); Row backendServerConfigurationMultiApiRow = grid.AddRow(); backendServerRow.AddNewLine(); BackendData backendInstanceStorageData = PageStorage <BackendData> .Instance.StorageData; MultiInputGroup backendConfigurationSourceSwitchingMultiInputGroup = backendServerRow.AppendCollum(new MultiInputGroup()); backendConfigurationSourceSwitchingMultiInputGroup.AppendLabel("Quelle Auswählen", labelSize); TwoStateButtonGroup backendConfigurationSourceSwitchingTwoStateButton = backendConfigurationSourceSwitchingMultiInputGroup.AppendCustomElement(new TwoStateButtonGroup("Sammelkonfiguration", "einzele Konfiguration", !backendInstanceStorageData.SingleApiConfiguration, backendInstanceStorageData.SingleApiConfiguration), false); void OnBackendConfigurationSourceSwitchingTwoStateButtonOnFirstButtonStateChange(object sender, ButtonChangeEventHandlerArgs args) { if (args.NewButtonState == true) { backendServerConfigurationSingeApiRow.Style.Display = "none"; backendServerConfigurationMultiApiRow.Style.Display = null; } else { backendServerConfigurationSingeApiRow.Style.Display = null; backendServerConfigurationMultiApiRow.Style.Display = "none"; } backendInstanceStorageData.SingleApiConfiguration = !args.NewButtonState; } backendConfigurationSourceSwitchingTwoStateButton.FirstButtonStateChange += OnBackendConfigurationSourceSwitchingTwoStateButtonOnFirstButtonStateChange; OnBackendConfigurationSourceSwitchingTwoStateButtonOnFirstButtonStateChange(null, new ButtonChangeEventHandlerArgs(false, !backendInstanceStorageData.SingleApiConfiguration)); backendConfigurationSourceSwitchingMultiInputGroup.AddStyling(StylingOption.MarginBottom, 5); #region backendServerConfigurationSingeApiRow foreach ((string name, BackendProperty backedProperties) in backendInstanceStorageData.BackendProperties) { backendServerConfigurationSingeApiRow.AddNewLine(); backendServerConfigurationSingeApiRow.AppendCollum(CreateSingleBackendCollum(name, backedProperties), autoSize: true); } backendServerConfigurationSingeApiRow.AddNewLine(); backendServerConfigurationSingeApiRow.AddNewLine(); backendServerConfigurationSingeApiRow.AppendCollum(new Button(StylingColor.Light, false, Button.ButtonSize.Normal, false, "Standardkonfiguration eintragen")).Click += (sender, args) => { foreach ((string name, BackendProperty _) in backendInstanceStorageData.BackendProperties) { if (_backendPathTextInputDictionary[name].Value == "") { _backendPathTextInputDictionary[name].Value = $"http://{Dns.GetHostAddresses("WebPiServer.PiWeb")[0].ToString()}:5000/api/{name}"; } } }; #endregion backendServerConfigurationSingeApiRow #region backendServerConfigurationMultiApiRow backendServerConfigurationMultiApiRow.AppendCollum(CreateMultiBackendCollum(backendInstanceStorageData, out StylableTextInput backendServerConfigurationMultiApiTextInput), autoSize: true); backendServerConfigurationMultiApiRow.AddNewLine(); backendServerConfigurationMultiApiRow.AppendCollum(new Button(StylingColor.Light, false, Button.ButtonSize.Normal, false, "Standardkonfiguration eintragen")).Click += (sender, args) => { if (backendServerConfigurationMultiApiTextInput.Value == "") { backendServerConfigurationMultiApiTextInput.Value = $"http://{Dns.GetHostAddresses("WebPiServer.PiWeb")[0].ToString()}:5000/api"; } }; #endregion backendServerConfigurationMultiApiRow #endregion Backend Server Path }
public HistoryPage() : base("div") { AddStyling(StylingOption.MarginRight, 5); AddStyling(StylingOption.MarginLeft, 5); AddStyling(StylingOption.PaddingRight, 5); AddStyling(StylingOption.PaddingLeft, 5); //Container wrappingContainer = new Container(this); Grid grid = new Grid(this); Dropdown messageKindDropdown = new Dropdown(new Button(StylingColor.Light, false, text: "Quelle auswählen!")); Row headerRow = new Grid(grid.AddRow()).AddRow(); headerRow.AppendCollum(messageKindDropdown, 6); messageKindDropdown.AddStyling(StylingOption.MarginBottom, 4); // Table historyTable = new Table(new List<string>() { "Zeitpunkt", "Status", "Quelle", "Meldung" }, CreateHistoryTableContent(), true); Table <DateTime> historyTable = new Table <DateTime>(new List <string>() { "Zeitpunkt", "Status", "Quelle", "Meldung" }, FetchEntries, FetchSearchEntries, FetchAmount, PrimaryCellConverter, true, 14); grid.AddRow().AppendCollum(historyTable); messageKindDropdown.AddEntry("Alles").Click += (sender, args) => { historyTable.SetFilter("", "", true); messageKindDropdown.Button.Text = "Alles anzeigen"; }; messageKindDropdown.AddDivider(); messageKindDropdown.AddEntry("System").Click += (sender, args) => { historyTable.SetFilter("Quelle", "System", true); messageKindDropdown.Button.Text = "System-Meldungen anzeigen"; }; messageKindDropdown.AddEntry("Automatikbetrieb").Click += (sender, args) => { historyTable.SetFilter("Quelle", "Automatic", true); messageKindDropdown.Button.Text = "Automatikbetrieb-Meldungen anzeigen"; }; messageKindDropdown.AddEntry("Handbetrieb").Click += (sender, args) => { historyTable.SetFilter("Quelle", "Manual", true); messageKindDropdown.Button.Text = "Handbetrieb-Meldungen anzeigen"; }; historyTable.SetCellValueColor("Status", "OK", StylingColor.Success); historyTable.SetCellValueColor("Status", "Warn", StylingColor.Warning); historyTable.SetCellValueColor("Status", "Warnung", StylingColor.Warning); historyTable.SetCellValueColor("Status", "Error", StylingColor.Danger); historyTable.SetCellValueColor("Status", "Fehler", StylingColor.Danger); Button refreshButton = headerRow.AppendCollum(new Button(StylingColor.Primary, true, Button.ButtonSize.Normal, false, "Inhalt Aktualisieren! "), 2, false); refreshButton.Click += (sender, args) => { refreshButton.IsDisabled = true; historyTable.RefreshBeginningTableContent(); refreshButton.IsDisabled = false; if (refreshButton.Text.Contains(" !")) { refreshButton.Text = refreshButton.Text.Replace(" !", "! "); } else { refreshButton.Text = refreshButton.Text.TrimEnd(' ', '!') + " !"; } }; historyTable.EndUpdate(); }