fetching current time
This commit is contained in:
@@ -39,12 +39,18 @@ module.exports = {
|
||||
z_slider: false,
|
||||
z_slider_variant: " ",
|
||||
config: "",
|
||||
current_time: "",
|
||||
is_loading_time: false,
|
||||
selected_date: null,
|
||||
selected_hours: `${new Date().getHours()}`,
|
||||
selected_minutes: `${new Date().getMinutes()}`,
|
||||
};
|
||||
},
|
||||
|
||||
created: function () {
|
||||
this.fetch_current_time();
|
||||
},
|
||||
|
||||
ready: function () {
|
||||
this.autoCheckUpgrade = this.config.admin["auto-check-upgrade"];
|
||||
},
|
||||
@@ -66,6 +72,24 @@ module.exports = {
|
||||
},
|
||||
|
||||
methods: {
|
||||
fetch_current_time: async function () {
|
||||
try {
|
||||
this.is_loading_time = true;
|
||||
const response = await api.get("time");
|
||||
if (response.timeinfo) {
|
||||
const { timeinfo } = response;
|
||||
this.current_time = timeinfo.split(": ")[1].split(" U")[0];
|
||||
} else {
|
||||
this.current_time = " ";
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error fetching time:", error);
|
||||
this.current_time = "Error fetching time";
|
||||
} finally {
|
||||
this.is_loading_time = false;
|
||||
}
|
||||
},
|
||||
|
||||
backup: function () {
|
||||
document.getElementById("download-target").src =
|
||||
"/api/config/download/" +
|
||||
|
||||
@@ -67,7 +67,8 @@ script#admin-general-view-template(type="text/x-template")
|
||||
h2 Date/Time
|
||||
p
|
||||
strong Current Date/Time:
|
||||
| {{get_current_time}}
|
||||
span(v-if="isLoadingTime") Loading...
|
||||
span(v-else) {{ current_time }}
|
||||
.pure-form
|
||||
input(id="date" type="date" v-model="selected_date")
|
||||
input(id="hours" type="number" v-model="selected_hours" placeholder="HH" maxlength="2" min="0" max="23" style="width:45px")
|
||||
|
||||
Reference in New Issue
Block a user