Skip to content
Snippets Groups Projects
Commit ff73d396 authored by Alexander Kaschta's avatar Alexander Kaschta :owl: Committed by Janis Streib
Browse files

UPD: Add maintenance info (WIP)

parent a8e7df8a
No related branches found
No related tags found
No related merge requests found
......@@ -129,6 +129,7 @@ import SystemInfoService from './api-services/system_info.service'
import colorutil from '@/util/colorutil'
import SystemAlertDisplay from '@/components/SystemAlertDisplay.vue'
import SpecReady from '@/views/SpecReady.vue'
import dateutil from '@/util/dateutil'
export default {
components: { SpecReady, SystemAlertDisplay, GlobalSearch, SideNavbar, Sidebar, NetvsFooter, Navbar, CopyField },
......@@ -167,6 +168,25 @@ export default {
this.$store.commit('updateAlerts', alerts.data)
}).catch(() => {
}) // Fail silently
SystemInfoService.getMaintenance(this.$store.state.netdb_axios_config).then((items) => {
const alerts = this.$store.state.alerts
// Iterate over all maintenance announcements and add them to the alerts
for (const item of items.data.maint_state_list) {
// NOTE: The text generation is only a temporary solution until the api supports multiple languages
alerts.push({
title: { de: item.subject, en: item.subject },
content:
{
de: 'Von ' + dateutil.format_date(new Date(Date.parse(item.ts_begin))) + ' bis ' + item.ts_end + ' wird es für ' + item.duration + 'h Wartungsarbeiten geben.',
en: 'Test'
}
})
}
console.log(alerts)
// Update the alerts
this.$store.commit('updateAlerts', alerts)
}).catch(() => {
}) // Fail silently
SystemInfoService.getFrontendVersion().then((sysinfo) => {
if (config.COMMIT_SHORT_SHA !== sysinfo.data.commit_short) {
EventBus.$emit('update_available', sysinfo.data.version)
......
......@@ -20,4 +20,10 @@ export default {
getAlerts() {
return Axios.get('/api/alerts.json?' + Math.random().toString())
},
getMaintenance(config) {
const ta = [
{ name: 'wapi.maint_state.list', old: { sorting_params_list: ['is_active', 'ts_begin'] } }
]
return TransactionService.execute(config, ta)
}
}
......@@ -8,5 +8,10 @@ export default {
fmt[part] = i++
})
return new Date(parts[fmt.YYYY], parts[fmt.MM] - 1, parts[fmt.DD], parts[fmt.hh], parts[fmt.mm], parts[fmt.ss], parts[fmt.ms])
},
format_date(date) {
return date.getUTCFullYear() + '-' + String(date.getUTCMonth() + 1).padStart(2, '0') + '-' +
String(date.getUTCDate()).padStart(2, '0') + ' ' + String(date.getUTCHours()).padStart(2, '0') +
':' + String(date.getUTCMinutes()).padStart(2, '0') + ':' + String(date.getUTCSeconds()).padStart(2, '0') + ' (UTC)'
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment