webapp: Added loading animations to several views

This commit is contained in:
Thomas Basler 2022-07-12 20:56:30 +02:00
parent f917f5dc0d
commit c0ed5f3e14
7 changed files with 434 additions and 340 deletions

View File

@ -6,44 +6,53 @@
<BootstrapAlert v-model="showAlert" dismissible :variant="alertType"> <BootstrapAlert v-model="showAlert" dismissible :variant="alertType">
{{ alertMessage }} {{ alertMessage }}
</BootstrapAlert> </BootstrapAlert>
<form @submit="saveDtuConfig">
<div class="card">
<div class="card-header text-white bg-primary">DTU Configuration</div>
<div class="card-body">
<div class="row mb-3">
<label for="inputDtuSerial" class="col-sm-2 col-form-label">Serial:</label>
<div class="col-sm-10">
<input type="number" class="form-control" id="inputDtuSerial" min="1" max="99999999999"
placeholder="DTU Serial" v-model="dtuConfigList.dtu_serial" />
</div>
</div>
<div class="row mb-3"> <div class="text-center" v-if="dataLoading">
<label for="inputPollInterval" class="col-sm-2 col-form-label">Poll Interval:</label> <div class="spinner-border" role="status">
<div class="col-sm-10"> <span class="visually-hidden">Loading...</span>
<div class="input-group"> </div>
<input type="number" class="form-control" id="inputPollInterval" min="1" max="86400" </div>
placeholder="Poll Interval in Seconds" v-model="dtuConfigList.dtu_pollinterval"
aria-describedby="pollIntervalDescription" /> <template v-if="!dataLoading">
<span class="input-group-text" id="pollIntervalDescription">seconds</span> <form @submit="saveDtuConfig">
<div class="card">
<div class="card-header text-white bg-primary">DTU Configuration</div>
<div class="card-body">
<div class="row mb-3">
<label for="inputDtuSerial" class="col-sm-2 col-form-label">Serial:</label>
<div class="col-sm-10">
<input type="number" class="form-control" id="inputDtuSerial" min="1" max="99999999999"
placeholder="DTU Serial" v-model="dtuConfigList.dtu_serial" />
</div>
</div>
<div class="row mb-3">
<label for="inputPollInterval" class="col-sm-2 col-form-label">Poll Interval:</label>
<div class="col-sm-10">
<div class="input-group">
<input type="number" class="form-control" id="inputPollInterval" min="1" max="86400"
placeholder="Poll Interval in Seconds" v-model="dtuConfigList.dtu_pollinterval"
aria-describedby="pollIntervalDescription" />
<span class="input-group-text" id="pollIntervalDescription">seconds</span>
</div>
</div>
</div>
<div class="row mb-3">
<label for="inputTimezone" class="col-sm-2 col-form-label">PA Level:</label>
<div class="col-sm-10">
<select class="form-select" v-model="dtuConfigList.dtu_palevel">
<option v-for="palevel in palevelList" :key="palevel.key" :value="palevel.key">
{{ palevel.value }}
</option>
</select>
</div> </div>
</div> </div>
</div> </div>
<div class="row mb-3">
<label for="inputTimezone" class="col-sm-2 col-form-label">PA Level:</label>
<div class="col-sm-10">
<select class="form-select" v-model="dtuConfigList.dtu_palevel">
<option v-for="palevel in palevelList" :key="palevel.key" :value="palevel.key">
{{ palevel.value }}
</option>
</select>
</div>
</div>
</div> </div>
</div> <button type="submit" class="btn btn-primary mb-3">Save</button>
<button type="submit" class="btn btn-primary mb-3">Save</button> </form>
</form> </template>
</div> </div>
</template> </template>
@ -57,6 +66,7 @@ export default defineComponent({
}, },
data() { data() {
return { return {
dataLoading: true,
dtuConfigList: { dtuConfigList: {
dtu_serial: 0, dtu_serial: 0,
dtu_pollinterval: 0, dtu_pollinterval: 0,
@ -78,11 +88,13 @@ export default defineComponent({
}, },
methods: { methods: {
getDtuConfig() { getDtuConfig() {
this.dataLoading = true;
fetch("/api/dtu/config") fetch("/api/dtu/config")
.then((response) => response.json()) .then((response) => response.json())
.then( .then(
(data) => { (data) => {
this.dtuConfigList = data; this.dtuConfigList = data;
this.dataLoading = false;
} }
); );
}, },

View File

@ -6,129 +6,138 @@
<BootstrapAlert v-model="showAlert" dismissible :variant="alertType"> <BootstrapAlert v-model="showAlert" dismissible :variant="alertType">
{{ alertMessage }} {{ alertMessage }}
</BootstrapAlert> </BootstrapAlert>
<form @submit="saveMqttConfig">
<div class="card"> <div class="text-center" v-if="dataLoading">
<div class="card-header text-white bg-primary">MqTT Configuration</div> <div class="spinner-border" role="status">
<div class="card-body"> <span class="visually-hidden">Loading...</span>
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="inputMqtt"
v-model="mqttConfigList.mqtt_enabled" />
<label class="form-check-label" for="inputMqtt">Enable MqTT</label>
</div>
</div>
</div> </div>
</div>
<div class="card mt-5" v-show="mqttConfigList.mqtt_enabled"> <template v-if="!dataLoading">
<div class="card-header text-white bg-primary"> <form @submit="saveMqttConfig">
MqTT Broker Parameter <div class="card">
<div class="card-header text-white bg-primary">MqTT Configuration</div>
<div class="card-body">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="inputMqtt"
v-model="mqttConfigList.mqtt_enabled" />
<label class="form-check-label" for="inputMqtt">Enable MqTT</label>
</div>
</div>
</div> </div>
<div class="card-body">
<div class="row mb-3">
<label for="inputHostname" class="col-sm-2 col-form-label">Hostname:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputHostname" maxlength="32"
placeholder="Hostname or IP address" v-model="mqttConfigList.mqtt_hostname" />
</div>
</div>
<div class="row mb-3"> <div class="card mt-5" v-show="mqttConfigList.mqtt_enabled">
<label for="inputPort" class="col-sm-2 col-form-label">Port:</label> <div class="card-header text-white bg-primary">
<div class="col-sm-10"> MqTT Broker Parameter
<input type="number" class="form-control" id="inputPort" min="1" max="65535"
placeholder="Port number" v-model="mqttConfigList.mqtt_port" />
</div>
</div> </div>
<div class="card-body">
<div class="row mb-3"> <div class="row mb-3">
<label for="inputUsername" class="col-sm-2 col-form-label">Username:</label> <label for="inputHostname" class="col-sm-2 col-form-label">Hostname:</label>
<div class="col-sm-10"> <div class="col-sm-10">
<input type="text" class="form-control" id="inputUsername" maxlength="32" <input type="text" class="form-control" id="inputHostname" maxlength="32"
placeholder="Username, leave empty for anonymous connection" placeholder="Hostname or IP address" v-model="mqttConfigList.mqtt_hostname" />
v-model="mqttConfigList.mqtt_username" />
</div>
</div>
<div class="row mb-3">
<label for="inputPassword" class="col-sm-2 col-form-label">Password:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputPassword" maxlength="32"
placeholder="Password, leave empty for anonymous connection"
v-model="mqttConfigList.mqtt_password" />
</div>
</div>
<div class="row mb-3">
<label for="inputTopic" class="col-sm-2 col-form-label">Base Topic:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputTopic" maxlength="32"
placeholder="Base topic, will be prepend to all published topics (e.g. inverter/)"
v-model="mqttConfigList.mqtt_topic" />
</div>
</div>
<div class="row mb-3">
<label for="inputPublishInterval" class="col-sm-2 col-form-label">Publish Interval:</label>
<div class="col-sm-10">
<div class="input-group">
<input type="number" class="form-control" id="inputPublishInterval" min="5" max="86400"
placeholder="Publish Interval in Seconds"
v-model="mqttConfigList.mqtt_publish_interval"
aria-describedby="publishIntervalDescription" />
<span class="input-group-text" id="publishIntervalDescription">seconds</span>
</div> </div>
</div> </div>
</div>
<div class="row mb-3"> <div class="row mb-3">
<label class="col-sm-2 form-check-label" for="inputRetain">Enable Retain Flag</label> <label for="inputPort" class="col-sm-2 col-form-label">Port:</label>
<div class="col-sm-10"> <div class="col-sm-10">
<div class="form-check form-switch"> <input type="number" class="form-control" id="inputPort" min="1" max="65535"
<input class="form-check-input" type="checkbox" id="inputRetain" placeholder="Port number" v-model="mqttConfigList.mqtt_port" />
v-model="mqttConfigList.mqtt_retain" /> </div>
</div>
<div class="row mb-3">
<label for="inputUsername" class="col-sm-2 col-form-label">Username:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputUsername" maxlength="32"
placeholder="Username, leave empty for anonymous connection"
v-model="mqttConfigList.mqtt_username" />
</div>
</div>
<div class="row mb-3">
<label for="inputPassword" class="col-sm-2 col-form-label">Password:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputPassword" maxlength="32"
placeholder="Password, leave empty for anonymous connection"
v-model="mqttConfigList.mqtt_password" />
</div>
</div>
<div class="row mb-3">
<label for="inputTopic" class="col-sm-2 col-form-label">Base Topic:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputTopic" maxlength="32"
placeholder="Base topic, will be prepend to all published topics (e.g. inverter/)"
v-model="mqttConfigList.mqtt_topic" />
</div>
</div>
<div class="row mb-3">
<label for="inputPublishInterval" class="col-sm-2 col-form-label">Publish Interval:</label>
<div class="col-sm-10">
<div class="input-group">
<input type="number" class="form-control" id="inputPublishInterval" min="5"
max="86400" placeholder="Publish Interval in Seconds"
v-model="mqttConfigList.mqtt_publish_interval"
aria-describedby="publishIntervalDescription" />
<span class="input-group-text" id="publishIntervalDescription">seconds</span>
</div>
</div>
</div>
<div class="row mb-3">
<label class="col-sm-2 form-check-label" for="inputRetain">Enable Retain Flag</label>
<div class="col-sm-10">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="inputRetain"
v-model="mqttConfigList.mqtt_retain" />
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div>
<div class="card mt-5" v-show="mqttConfigList.mqtt_enabled"> <div class="card mt-5" v-show="mqttConfigList.mqtt_enabled">
<div class="card-header text-white bg-primary">LWT Parameters</div> <div class="card-header text-white bg-primary">LWT Parameters</div>
<div class="card-body"> <div class="card-body">
<div class="row mb-3"> <div class="row mb-3">
<label for="inputLwtTopic" class="col-sm-2 col-form-label">LWT Topic:</label> <label for="inputLwtTopic" class="col-sm-2 col-form-label">LWT Topic:</label>
<div class="col-sm-10"> <div class="col-sm-10">
<div class="input-group"> <div class="input-group">
<span class="input-group-text" id="basic-addon3">{{ <span class="input-group-text" id="basic-addon3">{{
mqttConfigList.mqtt_topic mqttConfigList.mqtt_topic
}}</span> }}</span>
<input type="text" class="form-control" id="inputLwtTopic" maxlength="32" <input type="text" class="form-control" id="inputLwtTopic" maxlength="32"
placeholder="LWT topic, will be append base topic" placeholder="LWT topic, will be append base topic"
v-model="mqttConfigList.mqtt_lwt_topic" aria-describedby="basic-addon3" /> v-model="mqttConfigList.mqtt_lwt_topic" aria-describedby="basic-addon3" />
</div>
</div>
</div>
<div class="row mb-3">
<label for="inputLwtOnline" class="col-sm-2 col-form-label">LWT Online message:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputLwtOnline" maxlength="20"
placeholder="Message that will be published to LWT topic when online"
v-model="mqttConfigList.mqtt_lwt_online" />
</div>
</div>
<div class="row mb-3">
<label for="inputLwtOffline" class="col-sm-2 col-form-label">LWT Offline message:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputLwtOffline" maxlength="20"
placeholder="Message that will be published to LWT topic when offline"
v-model="mqttConfigList.mqtt_lwt_offline" />
</div> </div>
</div> </div>
</div> </div>
<div class="row mb-3">
<label for="inputLwtOnline" class="col-sm-2 col-form-label">LWT Online message:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputLwtOnline" maxlength="20"
placeholder="Message that will be published to LWT topic when online"
v-model="mqttConfigList.mqtt_lwt_online" />
</div>
</div>
<div class="row mb-3">
<label for="inputLwtOffline" class="col-sm-2 col-form-label">LWT Offline message:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputLwtOffline" maxlength="20"
placeholder="Message that will be published to LWT topic when offline"
v-model="mqttConfigList.mqtt_lwt_offline" />
</div>
</div>
</div> </div>
</div> <button type="submit" class="btn btn-primary mb-3">Save</button>
<button type="submit" class="btn btn-primary mb-3">Save</button> </form>
</form> </template>
</div> </div>
</template> </template>
@ -142,6 +151,7 @@ export default defineComponent({
}, },
data() { data() {
return { return {
dataLoading: true,
mqttConfigList: { mqttConfigList: {
mqtt_enabled: false, mqtt_enabled: false,
mqtt_hostname: "", mqtt_hostname: "",
@ -165,9 +175,13 @@ export default defineComponent({
}, },
methods: { methods: {
getMqttConfig() { getMqttConfig() {
this.dataLoading = true;
fetch("/api/mqtt/config") fetch("/api/mqtt/config")
.then((response) => response.json()) .then((response) => response.json())
.then((data) => (this.mqttConfigList = data)); .then((data) => {
this.mqttConfigList = data;
this.dataLoading = false;
});
}, },
saveMqttConfig(e: Event) { saveMqttConfig(e: Event) {
e.preventDefault(); e.preventDefault();

View File

@ -4,79 +4,87 @@
<h1>MqTT Info</h1> <h1>MqTT Info</h1>
</div> </div>
<div class="card"> <div class="text-center" v-if="dataLoading">
<div class="card-header text-white bg-primary">Configuration Summary</div> <div class="spinner-border" role="status">
<div class="card-body"> <span class="visually-hidden">Loading...</span>
<div class="table-responsive">
<table class="table table-hover table-condensed">
<tbody>
<tr>
<th>Status</th>
<td class="badge" :class="{
'bg-danger': !mqttDataList.mqtt_enabled,
'bg-success': mqttDataList.mqtt_enabled,
}">
<span v-if="mqttDataList.mqtt_enabled">enabled</span>
<span v-else>disabled</span>
</td>
</tr>
<tr>
<th>Server</th>
<td>{{ mqttDataList.mqtt_hostname }}</td>
</tr>
<tr>
<th>Port</th>
<td>{{ mqttDataList.mqtt_port }}</td>
</tr>
<tr>
<th>Username</th>
<td>{{ mqttDataList.mqtt_username }}</td>
</tr>
<tr>
<th>Base Topic</th>
<td>{{ mqttDataList.mqtt_topic }}</td>
</tr>
<tr>
<th>Publish Interval</th>
<td>{{ mqttDataList.mqtt_publish_interval }} seconds</td>
</tr>
<tr>
<th>Retain</th>
<td class="badge" :class="{
'bg-danger': !mqttDataList.mqtt_retain,
'bg-success': mqttDataList.mqtt_retain,
}">
<span v-if="mqttDataList.mqtt_retain">enabled</span>
<span v-else>disabled</span>
</td>
</tr>
</tbody>
</table>
</div>
</div> </div>
</div> </div>
<div class="card mt-5"> <template v-if="!dataLoading">
<div class="card-header text-white bg-primary">Runtime Summary</div> <div class="card">
<div class="card-body"> <div class="card-header text-white bg-primary">Configuration Summary</div>
<div class="table-responsive"> <div class="card-body">
<table class="table table-hover table-condensed"> <div class="table-responsive">
<tbody> <table class="table table-hover table-condensed">
<tr> <tbody>
<th>Connection Status</th> <tr>
<td class="badge" :class="{ <th>Status</th>
'bg-danger': !mqttDataList.mqtt_connected, <td class="badge" :class="{
'bg-success': mqttDataList.mqtt_connected, 'bg-danger': !mqttDataList.mqtt_enabled,
}"> 'bg-success': mqttDataList.mqtt_enabled,
<span v-if="mqttDataList.mqtt_connected">connected</span> }">
<span v-else>disconnected</span> <span v-if="mqttDataList.mqtt_enabled">enabled</span>
</td> <span v-else>disabled</span>
</tr> </td>
</tbody> </tr>
</table> <tr>
<th>Server</th>
<td>{{ mqttDataList.mqtt_hostname }}</td>
</tr>
<tr>
<th>Port</th>
<td>{{ mqttDataList.mqtt_port }}</td>
</tr>
<tr>
<th>Username</th>
<td>{{ mqttDataList.mqtt_username }}</td>
</tr>
<tr>
<th>Base Topic</th>
<td>{{ mqttDataList.mqtt_topic }}</td>
</tr>
<tr>
<th>Publish Interval</th>
<td>{{ mqttDataList.mqtt_publish_interval }} seconds</td>
</tr>
<tr>
<th>Retain</th>
<td class="badge" :class="{
'bg-danger': !mqttDataList.mqtt_retain,
'bg-success': mqttDataList.mqtt_retain,
}">
<span v-if="mqttDataList.mqtt_retain">enabled</span>
<span v-else>disabled</span>
</td>
</tr>
</tbody>
</table>
</div>
</div> </div>
</div> </div>
</div>
<div class="card mt-5">
<div class="card-header text-white bg-primary">Runtime Summary</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-hover table-condensed">
<tbody>
<tr>
<th>Connection Status</th>
<td class="badge" :class="{
'bg-danger': !mqttDataList.mqtt_connected,
'bg-success': mqttDataList.mqtt_connected,
}">
<span v-if="mqttDataList.mqtt_connected">connected</span>
<span v-else>disconnected</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</template>
</div> </div>
</template> </template>
@ -86,6 +94,7 @@ import { defineComponent } from 'vue';
export default defineComponent({ export default defineComponent({
data() { data() {
return { return {
dataLoading: true,
mqttDataList: { mqttDataList: {
mqtt_enabled: false, mqtt_enabled: false,
mqtt_hostname: "", mqtt_hostname: "",
@ -103,9 +112,13 @@ export default defineComponent({
}, },
methods: { methods: {
getNtpInfo() { getNtpInfo() {
this.dataLoading = true;
fetch("/api/mqtt/status") fetch("/api/mqtt/status")
.then((response) => response.json()) .then((response) => response.json())
.then((data) => (this.mqttDataList = data)); .then((data) => {
this.mqttDataList = data;
this.dataLoading = false;
});
}, },
}, },
}); });

View File

@ -6,94 +6,103 @@
<BootstrapAlert v-model="showAlert" dismissible :variant="alertType"> <BootstrapAlert v-model="showAlert" dismissible :variant="alertType">
{{ alertMessage }} {{ alertMessage }}
</BootstrapAlert> </BootstrapAlert>
<form @submit="saveNetworkConfig">
<div class="card">
<div class="card-header text-white bg-primary">WiFi Configuration</div>
<div class="card-body">
<div class="row mb-3">
<label for="inputSSID" class="col-sm-2 col-form-label">WiFi SSID:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputSSID" maxlength="32" placeholder="SSID"
v-model="networkConfigList.ssid" />
</div>
</div>
<div class="row mb-3"> <div class="text-center" v-if="dataLoading">
<label for="inputPassword" class="col-sm-2 col-form-label">WiFi Password:</label> <div class="spinner-border" role="status">
<div class="col-sm-10"> <span class="visually-hidden">Loading...</span>
<input type="password" class="form-control" id="inputPassword" maxlength="64" </div>
placeholder="PSK" v-model="networkConfigList.password" /> </div>
</div>
</div>
<div class="row mb-3"> <template v-if="!dataLoading">
<label for="inputHostname" class="col-sm-2 col-form-label">Hostname:</label> <form @submit="saveNetworkConfig">
<div class="col-sm-10"> <div class="card">
<input type="text" class="form-control" id="inputHostname" maxlength="32" <div class="card-header text-white bg-primary">WiFi Configuration</div>
placeholder="Hostname" v-model="networkConfigList.hostname" /> <div class="card-body">
<div class="row mb-3">
<label for="inputSSID" class="col-sm-2 col-form-label">WiFi SSID:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputSSID" maxlength="32" placeholder="SSID"
v-model="networkConfigList.ssid" />
</div>
</div> </div>
</div>
<div class="row mb-3"> <div class="row mb-3">
<label class="col-sm-2 form-check-label" for="inputDHCP">Enable DHCP</label> <label for="inputPassword" class="col-sm-2 col-form-label">WiFi Password:</label>
<div class="col-sm-10"> <div class="col-sm-10">
<div class="form-check form-switch"> <input type="password" class="form-control" id="inputPassword" maxlength="64"
<input class="form-check-input" type="checkbox" id="inputDHCP" placeholder="PSK" v-model="networkConfigList.password" />
v-model="networkConfigList.dhcp" /> </div>
</div>
<div class="row mb-3">
<label for="inputHostname" class="col-sm-2 col-form-label">Hostname:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputHostname" maxlength="32"
placeholder="Hostname" v-model="networkConfigList.hostname" />
</div>
</div>
<div class="row mb-3">
<label class="col-sm-2 form-check-label" for="inputDHCP">Enable DHCP</label>
<div class="col-sm-10">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="inputDHCP"
v-model="networkConfigList.dhcp" />
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div>
<div class="card" v-show="!networkConfigList.dhcp"> <div class="card" v-show="!networkConfigList.dhcp">
<div class="card-header text-white bg-primary"> <div class="card-header text-white bg-primary">
Static IP Configuration Static IP Configuration
</div>
<div class="card-body">
<div class="row mb-3">
<label for="inputIP" class="col-sm-2 col-form-label">IP Address:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputIP" maxlength="32" placeholder="IP address"
v-model="networkConfigList.ipaddress" />
</div>
</div> </div>
<div class="card-body">
<div class="row mb-3"> <div class="row mb-3">
<label for="inputNetmask" class="col-sm-2 col-form-label">Netmask:</label> <label for="inputIP" class="col-sm-2 col-form-label">IP Address:</label>
<div class="col-sm-10"> <div class="col-sm-10">
<input type="text" class="form-control" id="inputNetmask" maxlength="32" <input type="text" class="form-control" id="inputIP" maxlength="32"
placeholder="Netmask" v-model="networkConfigList.netmask" /> placeholder="IP address" v-model="networkConfigList.ipaddress" />
</div>
</div> </div>
</div>
<div class="row mb-3"> <div class="row mb-3">
<label for="inputGateway" class="col-sm-2 col-form-label">Default Gateway:</label> <label for="inputNetmask" class="col-sm-2 col-form-label">Netmask:</label>
<div class="col-sm-10"> <div class="col-sm-10">
<input type="text" class="form-control" id="inputGateway" maxlength="32" <input type="text" class="form-control" id="inputNetmask" maxlength="32"
placeholder="Default Gateway" v-model="networkConfigList.gateway" /> placeholder="Netmask" v-model="networkConfigList.netmask" />
</div>
</div> </div>
</div>
<div class="row mb-3"> <div class="row mb-3">
<label for="inputDNS1" class="col-sm-2 col-form-label">DNS Server 1:</label> <label for="inputGateway" class="col-sm-2 col-form-label">Default Gateway:</label>
<div class="col-sm-10"> <div class="col-sm-10">
<input type="text" class="form-control" id="inputDNS1" maxlength="32" <input type="text" class="form-control" id="inputGateway" maxlength="32"
placeholder="DNS Server 1" v-model="networkConfigList.dns1" /> placeholder="Default Gateway" v-model="networkConfigList.gateway" />
</div>
</div> </div>
</div>
<div class="row mb-3"> <div class="row mb-3">
<label for="inputDNS2" class="col-sm-2 col-form-label">DNS Server 2:</label> <label for="inputDNS1" class="col-sm-2 col-form-label">DNS Server 1:</label>
<div class="col-sm-10"> <div class="col-sm-10">
<input type="text" class="form-control" id="inputDNS2" maxlength="32" <input type="text" class="form-control" id="inputDNS1" maxlength="32"
placeholder="DNS Server 2" v-model="networkConfigList.dns2" /> placeholder="DNS Server 1" v-model="networkConfigList.dns1" />
</div>
</div>
<div class="row mb-3">
<label for="inputDNS2" class="col-sm-2 col-form-label">DNS Server 2:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputDNS2" maxlength="32"
placeholder="DNS Server 2" v-model="networkConfigList.dns2" />
</div>
</div> </div>
</div> </div>
</div> </div>
</div> <button type="submit" class="btn btn-primary mb-3">Save</button>
<button type="submit" class="btn btn-primary mb-3">Save</button> </form>
</form> </template>
</div> </div>
</template> </template>
@ -107,6 +116,7 @@ export default defineComponent({
}, },
data() { data() {
return { return {
dataLoading: true,
networkConfigList: { networkConfigList: {
ssid: "", ssid: "",
password: "", password: "",
@ -128,9 +138,13 @@ export default defineComponent({
}, },
methods: { methods: {
getNetworkConfig() { getNetworkConfig() {
this.dataLoading = true;
fetch("/api/network/config") fetch("/api/network/config")
.then((response) => response.json()) .then((response) => response.json())
.then((data) => (this.networkConfigList = data)); .then((data) => {
this.networkConfigList = data;
this.dataLoading = false;
});
}, },
saveNetworkConfig(e: Event) { saveNetworkConfig(e: Event) {
e.preventDefault(); e.preventDefault();

View File

@ -3,14 +3,22 @@
<div class="page-header"> <div class="page-header">
<h1>Network Info</h1> <h1>Network Info</h1>
</div> </div>
<WifiStationInfo v-bind="networkDataList"/> <div class="text-center" v-if="dataLoading">
<div class="mt-5"></div> <div class="spinner-border" role="status">
<WifiApInfo v-bind="networkDataList"/> <span class="visually-hidden">Loading...</span>
<div class="mt-5"></div> </div>
<InterfaceStationInfo v-bind="networkDataList"/> </div>
<div class="mt-5"></div>
<InterfaceApInfo v-bind="networkDataList"/> <template v-if="!dataLoading">
<div class="mt-5"></div> <WifiStationInfo v-bind="networkDataList" />
<div class="mt-5"></div>
<WifiApInfo v-bind="networkDataList" />
<div class="mt-5"></div>
<InterfaceStationInfo v-bind="networkDataList" />
<div class="mt-5"></div>
<InterfaceApInfo v-bind="networkDataList" />
<div class="mt-5"></div>
</template>
</div> </div>
</template> </template>
@ -30,6 +38,7 @@ export default defineComponent({
}, },
data() { data() {
return { return {
dataLoading: true,
networkDataList: { networkDataList: {
// WifiStationInfo // WifiStationInfo
sta_status: false, sta_status: false,
@ -57,9 +66,13 @@ export default defineComponent({
}, },
methods: { methods: {
getNetworkInfo() { getNetworkInfo() {
this.dataLoading = true;
fetch("/api/network/status") fetch("/api/network/status")
.then((response) => response.json()) .then((response) => response.json())
.then((data) => (this.networkDataList = data)); .then((data) => {
this.networkDataList = data;
this.dataLoading = false;
});
}, },
}, },
}); });

View File

@ -4,55 +4,64 @@
<h1>NTP Info</h1> <h1>NTP Info</h1>
</div> </div>
<div class="card"> <div class="text-center" v-if="dataLoading">
<div class="card-header text-white bg-primary">Configuration Summary</div> <div class="spinner-border" role="status">
<div class="card-body"> <span class="visually-hidden">Loading...</span>
<div class="table-responsive">
<table class="table table-hover table-condensed">
<tbody>
<tr>
<th>Server</th>
<td>{{ ntpDataList.ntp_server }}</td>
</tr>
<tr>
<th>Timezone</th>
<td>{{ ntpDataList.ntp_timezone }}</td>
</tr>
<tr>
<th>Timezone Description</th>
<td>{{ ntpDataList.ntp_timezone_descr }}</td>
</tr>
</tbody>
</table>
</div>
</div> </div>
</div> </div>
<div class="card mt-5"> <template v-if="!dataLoading">
<div class="card-header text-white bg-primary">Current Time</div> <div class="card">
<div class="card-body"> <div class="card-header text-white bg-primary">Configuration Summary</div>
<div class="table-responsive"> <div class="card-body">
<table class="table table-hover table-condensed"> <div class="table-responsive">
<tbody> <table class="table table-hover table-condensed">
<tr> <tbody>
<th>Status</th> <tr>
<td class="badge" :class="{ <th>Server</th>
'bg-danger': !ntpDataList.ntp_status, <td>{{ ntpDataList.ntp_server }}</td>
'bg-success': ntpDataList.ntp_status, </tr>
}"> <tr>
<span v-if="ntpDataList.ntp_status">synced</span> <th>Timezone</th>
<span v-else>not synced</span> <td>{{ ntpDataList.ntp_timezone }}</td>
</td> </tr>
</tr> <tr>
<tr> <th>Timezone Description</th>
<th>Local Time</th> <td>{{ ntpDataList.ntp_timezone_descr }}</td>
<td>{{ ntpDataList.ntp_localtime }}</td> </tr>
</tr> </tbody>
</tbody> </table>
</table> </div>
</div> </div>
</div> </div>
</div>
<div class="card mt-5">
<div class="card-header text-white bg-primary">Current Time</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-hover table-condensed">
<tbody>
<tr>
<th>Status</th>
<td class="badge" :class="{
'bg-danger': !ntpDataList.ntp_status,
'bg-success': ntpDataList.ntp_status,
}">
<span v-if="ntpDataList.ntp_status">synced</span>
<span v-else>not synced</span>
</td>
</tr>
<tr>
<th>Local Time</th>
<td>{{ ntpDataList.ntp_localtime }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</template>
</div> </div>
</template> </template>
@ -62,6 +71,7 @@ import { defineComponent } from 'vue';
export default defineComponent({ export default defineComponent({
data() { data() {
return { return {
dataLoading: true,
ntpDataList: { ntpDataList: {
ntp_server: "", ntp_server: "",
ntp_timezone: "", ntp_timezone: "",
@ -76,9 +86,13 @@ export default defineComponent({
}, },
methods: { methods: {
getNtpInfo() { getNtpInfo() {
this.dataLoading = true;
fetch("/api/ntp/status") fetch("/api/ntp/status")
.then((response) => response.json()) .then((response) => response.json())
.then((data) => (this.ntpDataList = data)); .then((data) => {
this.ntpDataList = data;
this.dataLoading = false;
});
}, },
}, },
}); });

View File

@ -3,12 +3,21 @@
<div class="page-header"> <div class="page-header">
<h1>System Info</h1> <h1>System Info</h1>
</div> </div>
<FirmwareInfo v-bind="systemDataList"/>
<div class="mt-5"></div> <div class="text-center" v-if="dataLoading">
<HardwareInfo v-bind="systemDataList"/> <div class="spinner-border" role="status">
<div class="mt-5"></div> <span class="visually-hidden">Loading...</span>
<MemoryInfo v-bind="systemDataList"/> </div>
<div class="mt-5"></div> </div>
<template v-if="!dataLoading">
<FirmwareInfo v-bind="systemDataList" />
<div class="mt-5"></div>
<HardwareInfo v-bind="systemDataList" />
<div class="mt-5"></div>
<MemoryInfo v-bind="systemDataList" />
<div class="mt-5"></div>
</template>
</div> </div>
</template> </template>
@ -26,6 +35,7 @@ export default defineComponent({
}, },
data() { data() {
return { return {
dataLoading: true,
systemDataList: { systemDataList: {
// HardwareInfo // HardwareInfo
chipmodel: "", chipmodel: "",
@ -56,9 +66,13 @@ export default defineComponent({
}, },
methods: { methods: {
getSystemInfo() { getSystemInfo() {
this.dataLoading = true;
fetch("/api/system/status") fetch("/api/system/status")
.then((response) => response.json()) .then((response) => response.json())
.then((data) => (this.systemDataList = data)); .then((data) => {
this.systemDataList = data;
this.dataLoading = false;
})
}, },
}, },
}); });