diff --git a/src/panels/config/core/ha-config-section-core.js b/src/panels/config/core/ha-config-section-core.js index 74cb573073..8112846cdb 100644 --- a/src/panels/config/core/ha-config-section-core.js +++ b/src/panels/config/core/ha-config-section-core.js @@ -62,104 +62,6 @@ class HaConfigSectionCore extends LocalizeMixin(PolymerElement) { - - - -
- [[localize('ui.panel.config.core.section.core.server_management.introduction')]] -
-
- [[localize('ui.panel.config.core.section.core.server_management.restart')]] - - [[localize('ui.panel.config.core.section.core.server_management.stop')]] - -
-
`; } diff --git a/src/panels/config/dashboard/ha-config-navigation.ts b/src/panels/config/dashboard/ha-config-navigation.ts index fe10e7c473..09fd1770dc 100644 --- a/src/panels/config/dashboard/ha-config-navigation.ts +++ b/src/panels/config/dashboard/ha-config-navigation.ts @@ -23,6 +23,7 @@ const PAGES: Array<{ advanced?: boolean; }> = [ { page: "core", core: true }, + { page: "server_control", core: true }, { page: "person" }, { page: "entity_registry", core: true }, { page: "area_registry", core: true }, diff --git a/src/panels/config/ha-panel-config.ts b/src/panels/config/ha-panel-config.ts index 9cd3d10155..1c249c39ea 100644 --- a/src/panels/config/ha-panel-config.ts +++ b/src/panels/config/ha-panel-config.ts @@ -48,6 +48,11 @@ class HaPanelConfig extends HassRouterPage { load: () => import(/* webpackChunkName: "panel-config-core" */ "./core/ha-config-core"), }, + server_control: { + tag: "ha-config-server-control", + load: () => + import(/* webpackChunkName: "panel-config-server-control" */ "./server_control/ha-config-server-control"), + }, customize: { tag: "ha-config-customize", load: () => diff --git a/src/panels/config/server_control/ha-config-section-server-control.js b/src/panels/config/server_control/ha-config-section-server-control.js new file mode 100644 index 0000000000..20d130498f --- /dev/null +++ b/src/panels/config/server_control/ha-config-section-server-control.js @@ -0,0 +1,222 @@ +import "@material/mwc-button"; +import "@polymer/paper-input/paper-input"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../../../components/ha-card"; +import "../../../components/buttons/ha-call-service-button"; +import "../../../resources/ha-style"; + +import "../ha-config-section"; + +import isComponentLoaded from "../../../common/config/is_component_loaded"; +import LocalizeMixin from "../../../mixins/localize-mixin"; + +/* + * @appliesMixin LocalizeMixin + */ +class HaConfigSectionServerControl extends LocalizeMixin(PolymerElement) { + static get template() { + return html` + + + [[localize('ui.panel.config.server_control.caption')]] + [[localize('ui.panel.config.server_control.description')]] + + + +
+ [[localize('ui.panel.config.server_control.section.server_management.introduction')]] +
+
+ [[localize('ui.panel.config.server_control.section.server_management.restart')]] + + [[localize('ui.panel.config.server_control.section.server_management.stop')]] + +
+
+
+ `; + } + + static get properties() { + return { + hass: { + type: Object, + }, + + isWide: { + type: Boolean, + value: false, + }, + + validating: { + type: Boolean, + value: false, + }, + + isValid: { + type: Boolean, + value: null, + }, + + validateLog: { + type: String, + value: "", + }, + + showAdvanced: Boolean, + }; + } + + groupLoaded(hass) { + return isComponentLoaded(hass, "group"); + } + + automationLoaded(hass) { + return isComponentLoaded(hass, "automation"); + } + + scriptLoaded(hass) { + return isComponentLoaded(hass, "script"); + } + + validateConfig() { + this.validating = true; + this.validateLog = ""; + this.isValid = null; + + this.hass.callApi("POST", "config/core/check_config").then((result) => { + this.validating = false; + this.isValid = result.result === "valid"; + + if (!this.isValid) { + this.validateLog = result.errors; + } + }); + } +} + +customElements.define( + "ha-config-section-server-control", + HaConfigSectionServerControl +); diff --git a/src/panels/config/server_control/ha-config-server-control.js b/src/panels/config/server_control/ha-config-server-control.js new file mode 100644 index 0000000000..cebf5243bd --- /dev/null +++ b/src/panels/config/server_control/ha-config-server-control.js @@ -0,0 +1,63 @@ +import "@polymer/app-layout/app-header/app-header"; +import "@polymer/app-layout/app-toolbar/app-toolbar"; +import "@polymer/paper-icon-button/paper-icon-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../../../layouts/hass-subpage"; +import "../../../resources/ha-style"; + +import "./ha-config-section-server-control"; + +import LocalizeMixin from "../../../mixins/localize-mixin"; + +/* + * @appliesMixin LocalizeMixin + */ +class HaConfigServerControl extends LocalizeMixin(PolymerElement) { + static get template() { + return html` + + + +
+ +
+
+ `; + } + + static get properties() { + return { + hass: Object, + isWide: Boolean, + showAdvanced: Boolean, + }; + } + + computeClasses(isWide) { + return isWide ? "content" : "content narrow"; + } +} + +customElements.define("ha-config-server-control", HaConfigServerControl); diff --git a/src/translations/en.json b/src/translations/en.json index a82d4a580b..de90e209c3 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -580,10 +580,10 @@ }, "core": { "caption": "General", - "description": "Validate your configuration file and control the server", + "description": "Change your general Home Assistant configuration", "section": { "core": { - "header": "Configuration and Server Control", + "header": "General Configuration", "introduction": "Changing your configuration can be a tiresome process. We know. This section will try to make your life a little bit easier.", "core_config": { "edit_requires_storage": "Editor disabled because config stored in configuration.yaml.", @@ -599,31 +599,37 @@ "imperial_example": "Fahrenheit, pounds", "metric_example": "Celsius, kilograms", "save_button": "Save" - }, - "validation": { - "heading": "Configuration validation", - "introduction": "Validate your configuration if you recently made some changes to your configuration and want to make sure that it is all valid", - "check_config": "Check config", - "valid": "Configuration valid!", - "invalid": "Configuration invalid" - }, - "reloading": { - "heading": "Configuration reloading", - "introduction": "Some parts of Home Assistant can reload without requiring a restart. Hitting reload will unload their current configuration and load the new one.", - "core": "Reload core", - "group": "Reload groups", - "automation": "Reload automations", - "script": "Reload scripts" - }, - "server_management": { - "heading": "Server management", - "introduction": "Control your Home Assistant server… from Home Assistant.", - "restart": "Restart", - "stop": "Stop" } } } }, + "server_control": { + "caption": "Server Control", + "description": "Restart and stop the Home Assistant server", + "section": { + "validation": { + "heading": "Configuration validation", + "introduction": "Validate your configuration if you recently made some changes to your configuration and want to make sure that it is all valid", + "check_config": "Check config", + "valid": "Configuration valid!", + "invalid": "Configuration invalid" + }, + "reloading": { + "heading": "Configuration reloading", + "introduction": "Some parts of Home Assistant can reload without requiring a restart. Hitting reload will unload their current configuration and load the new one.", + "core": "Reload core", + "group": "Reload groups", + "automation": "Reload automations", + "script": "Reload scripts" + }, + "server_management": { + "heading": "Server management", + "introduction": "Control your Home Assistant server… from Home Assistant.", + "restart": "Restart", + "stop": "Stop" + } + } + }, "customize": { "caption": "Customization", "description": "Customize your entities",