mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-29 20:26:39 +00:00
Split General Config and Server Control (#3418)
* Initial split of core and server control config * Changed Typescript to Javascript * Show Server controls without Advanced Mode * Update en.json
This commit is contained in:
parent
c523bae2c8
commit
aab967798a
@ -62,104 +62,6 @@ class HaConfigSectionCore extends LocalizeMixin(PolymerElement) {
|
||||
|
||||
<ha-config-name-form hass="[[hass]]"></ha-config-name-form>
|
||||
<ha-config-core-form hass="[[hass]]"></ha-config-core-form>
|
||||
|
||||
<template is="dom-if" if="[[showAdvanced]]">
|
||||
<ha-card
|
||||
header="[[localize('ui.panel.config.core.section.core.validation.heading')]]"
|
||||
>
|
||||
<div class="card-content">
|
||||
[[localize('ui.panel.config.core.section.core.validation.introduction')]]
|
||||
<template is="dom-if" if="[[!validateLog]]">
|
||||
<div class="validate-container">
|
||||
<template is="dom-if" if="[[!validating]]">
|
||||
<template is="dom-if" if="[[isValid]]">
|
||||
<div class="validate-result" id="result">
|
||||
[[localize('ui.panel.config.core.section.core.validation.valid')]]
|
||||
</div>
|
||||
</template>
|
||||
<mwc-button raised="" on-click="validateConfig">
|
||||
[[localize('ui.panel.config.core.section.core.validation.check_config')]]
|
||||
</mwc-button>
|
||||
</template>
|
||||
<template is="dom-if" if="[[validating]]">
|
||||
<paper-spinner active=""></paper-spinner>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
<template is="dom-if" if="[[validateLog]]">
|
||||
<div class="config-invalid">
|
||||
<span class="text">
|
||||
[[localize('ui.panel.config.core.section.core.validation.invalid')]]
|
||||
</span>
|
||||
<mwc-button raised="" on-click="validateConfig">
|
||||
[[localize('ui.panel.config.core.section.core.validation.check_config')]]
|
||||
</mwc-button>
|
||||
</div>
|
||||
<div id="configLog" class="validate-log">[[validateLog]]</div>
|
||||
</template>
|
||||
</div>
|
||||
</ha-card>
|
||||
|
||||
<ha-card
|
||||
header="[[localize('ui.panel.config.core.section.core.reloading.heading')]]"
|
||||
>
|
||||
<div class="card-content">
|
||||
[[localize('ui.panel.config.core.section.core.reloading.introduction')]]
|
||||
</div>
|
||||
<div class="card-actions">
|
||||
<ha-call-service-button
|
||||
hass="[[hass]]"
|
||||
domain="homeassistant"
|
||||
service="reload_core_config"
|
||||
>[[localize('ui.panel.config.core.section.core.reloading.core')]]
|
||||
</ha-call-service-button>
|
||||
<ha-call-service-button
|
||||
hass="[[hass]]"
|
||||
domain="group"
|
||||
service="reload"
|
||||
hidden$="[[!groupLoaded(hass)]]"
|
||||
>[[localize('ui.panel.config.core.section.core.reloading.group')]]
|
||||
</ha-call-service-button>
|
||||
<ha-call-service-button
|
||||
hass="[[hass]]"
|
||||
domain="automation"
|
||||
service="reload"
|
||||
hidden$="[[!automationLoaded(hass)]]"
|
||||
>[[localize('ui.panel.config.core.section.core.reloading.automation')]]
|
||||
</ha-call-service-button>
|
||||
<ha-call-service-button
|
||||
hass="[[hass]]"
|
||||
domain="script"
|
||||
service="reload"
|
||||
hidden$="[[!scriptLoaded(hass)]]"
|
||||
>[[localize('ui.panel.config.core.section.core.reloading.script')]]
|
||||
</ha-call-service-button>
|
||||
</div>
|
||||
</ha-card>
|
||||
</template>
|
||||
<ha-card
|
||||
header="[[localize('ui.panel.config.core.section.core.server_management.heading')]]"
|
||||
>
|
||||
<div class="card-content">
|
||||
[[localize('ui.panel.config.core.section.core.server_management.introduction')]]
|
||||
</div>
|
||||
<div class="card-actions warning">
|
||||
<ha-call-service-button
|
||||
class="warning"
|
||||
hass="[[hass]]"
|
||||
domain="homeassistant"
|
||||
service="restart"
|
||||
>[[localize('ui.panel.config.core.section.core.server_management.restart')]]
|
||||
</ha-call-service-button>
|
||||
<ha-call-service-button
|
||||
class="warning"
|
||||
hass="[[hass]]"
|
||||
domain="homeassistant"
|
||||
service="stop"
|
||||
>[[localize('ui.panel.config.core.section.core.server_management.stop')]]
|
||||
</ha-call-service-button>
|
||||
</div>
|
||||
</ha-card>
|
||||
</ha-config-section>
|
||||
`;
|
||||
}
|
||||
|
@ -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 },
|
||||
|
@ -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: () =>
|
||||
|
@ -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`
|
||||
<style include="iron-flex ha-style">
|
||||
.validate-container {
|
||||
@apply --layout-vertical;
|
||||
@apply --layout-center-center;
|
||||
height: 140px;
|
||||
}
|
||||
|
||||
.validate-result {
|
||||
color: var(--google-green-500);
|
||||
font-weight: 500;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.config-invalid {
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
.config-invalid .text {
|
||||
color: var(--google-red-500);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.config-invalid mwc-button {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.validate-log {
|
||||
white-space: pre-wrap;
|
||||
direction: ltr;
|
||||
}
|
||||
</style>
|
||||
<ha-config-section is-wide="[[isWide]]">
|
||||
<span slot="header"
|
||||
>[[localize('ui.panel.config.server_control.caption')]]</span
|
||||
>
|
||||
<span slot="introduction"
|
||||
>[[localize('ui.panel.config.server_control.description')]]</span
|
||||
>
|
||||
|
||||
<template is="dom-if" if="[[showAdvanced]]">
|
||||
<ha-card
|
||||
header="[[localize('ui.panel.config.server_control.section.validation.heading')]]"
|
||||
>
|
||||
<div class="card-content">
|
||||
[[localize('ui.panel.config.server_control.section.validation.introduction')]]
|
||||
<template is="dom-if" if="[[!validateLog]]">
|
||||
<div class="validate-container">
|
||||
<template is="dom-if" if="[[!validating]]">
|
||||
<template is="dom-if" if="[[isValid]]">
|
||||
<div class="validate-result" id="result">
|
||||
[[localize('ui.panel.config.server_control.section.validation.valid')]]
|
||||
</div>
|
||||
</template>
|
||||
<mwc-button raised="" on-click="validateConfig">
|
||||
[[localize('ui.panel.config.server_control.section.validation.check_config')]]
|
||||
</mwc-button>
|
||||
</template>
|
||||
<template is="dom-if" if="[[validating]]">
|
||||
<paper-spinner active=""></paper-spinner>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
<template is="dom-if" if="[[validateLog]]">
|
||||
<div class="config-invalid">
|
||||
<span class="text">
|
||||
[[localize('ui.panel.config.server_control.section.validation.invalid')]]
|
||||
</span>
|
||||
<mwc-button raised="" on-click="validateConfig">
|
||||
[[localize('ui.panel.config.server_control.section.validation.check_config')]]
|
||||
</mwc-button>
|
||||
</div>
|
||||
<div id="configLog" class="validate-log">[[validateLog]]</div>
|
||||
</template>
|
||||
</div>
|
||||
</ha-card>
|
||||
|
||||
<ha-card
|
||||
header="[[localize('ui.panel.config.server_control.section.reloading.heading')]]"
|
||||
>
|
||||
<div class="card-content">
|
||||
[[localize('ui.panel.config.server_control.section.reloading.introduction')]]
|
||||
</div>
|
||||
<div class="card-actions">
|
||||
<ha-call-service-button
|
||||
hass="[[hass]]"
|
||||
domain="homeassistant"
|
||||
service="reload_core_config"
|
||||
>[[localize('ui.panel.config.server_control.section.reloading.core')]]
|
||||
</ha-call-service-button>
|
||||
<ha-call-service-button
|
||||
hass="[[hass]]"
|
||||
domain="group"
|
||||
service="reload"
|
||||
hidden$="[[!groupLoaded(hass)]]"
|
||||
>[[localize('ui.panel.config.server_control.section.reloading.group')]]
|
||||
</ha-call-service-button>
|
||||
<ha-call-service-button
|
||||
hass="[[hass]]"
|
||||
domain="automation"
|
||||
service="reload"
|
||||
hidden$="[[!automationLoaded(hass)]]"
|
||||
>[[localize('ui.panel.config.server_control.section.reloading.automation')]]
|
||||
</ha-call-service-button>
|
||||
<ha-call-service-button
|
||||
hass="[[hass]]"
|
||||
domain="script"
|
||||
service="reload"
|
||||
hidden$="[[!scriptLoaded(hass)]]"
|
||||
>[[localize('ui.panel.config.server_control.section.reloading.script')]]
|
||||
</ha-call-service-button>
|
||||
</div>
|
||||
</ha-card>
|
||||
</template>
|
||||
<ha-card
|
||||
header="[[localize('ui.panel.config.server_control.section.server_management.heading')]]"
|
||||
>
|
||||
<div class="card-content">
|
||||
[[localize('ui.panel.config.server_control.section.server_management.introduction')]]
|
||||
</div>
|
||||
<div class="card-actions warning">
|
||||
<ha-call-service-button
|
||||
class="warning"
|
||||
hass="[[hass]]"
|
||||
domain="homeassistant"
|
||||
service="restart"
|
||||
>[[localize('ui.panel.config.server_control.section.server_management.restart')]]
|
||||
</ha-call-service-button>
|
||||
<ha-call-service-button
|
||||
class="warning"
|
||||
hass="[[hass]]"
|
||||
domain="homeassistant"
|
||||
service="stop"
|
||||
>[[localize('ui.panel.config.server_control.section.server_management.stop')]]
|
||||
</ha-call-service-button>
|
||||
</div>
|
||||
</ha-card>
|
||||
</ha-config-section>
|
||||
`;
|
||||
}
|
||||
|
||||
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
|
||||
);
|
63
src/panels/config/server_control/ha-config-server-control.js
Normal file
63
src/panels/config/server_control/ha-config-server-control.js
Normal file
@ -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`
|
||||
<style include="iron-flex ha-style">
|
||||
.content {
|
||||
padding-bottom: 32px;
|
||||
}
|
||||
|
||||
.border {
|
||||
margin: 32px auto 0;
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.12);
|
||||
max-width: 1040px;
|
||||
}
|
||||
|
||||
.narrow .border {
|
||||
max-width: 640px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<hass-subpage
|
||||
header="[[localize('ui.panel.config.server_control.caption')]]"
|
||||
>
|
||||
<div class$="[[computeClasses(isWide)]]">
|
||||
<ha-config-section-server-control
|
||||
is-wide="[[isWide]]"
|
||||
show-advanced="[[showAdvanced]]"
|
||||
hass="[[hass]]"
|
||||
></ha-config-section-server-control>
|
||||
</div>
|
||||
</hass-subpage>
|
||||
`;
|
||||
}
|
||||
|
||||
static get properties() {
|
||||
return {
|
||||
hass: Object,
|
||||
isWide: Boolean,
|
||||
showAdvanced: Boolean,
|
||||
};
|
||||
}
|
||||
|
||||
computeClasses(isWide) {
|
||||
return isWide ? "content" : "content narrow";
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define("ha-config-server-control", HaConfigServerControl);
|
@ -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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user