Resolve lint errors

This commit is contained in:
Karel Krýda 2022-04-30 14:57:08 +02:00
parent 7532acc95d
commit f78d01d770
11 changed files with 105 additions and 80 deletions

View File

@ -212,8 +212,7 @@ class Monitor extends BeanModel {
if (await Monitor.isUnderMaintenance(this.id)) { if (await Monitor.isUnderMaintenance(this.id)) {
bean.msg = "Monitor under maintenance"; bean.msg = "Monitor under maintenance";
bean.status = MAINTENANCE; bean.status = MAINTENANCE;
} } else if (this.type === "http" || this.type === "keyword") {
else if (this.type === "http" || this.type === "keyword") {
// Do not do any queries/high loading things before the "bean.ping" // Do not do any queries/high loading things before the "bean.ping"
let startTime = dayjs().valueOf(); let startTime = dayjs().valueOf();
@ -482,8 +481,7 @@ class Monitor extends BeanModel {
if (Monitor.isImportantForNotification(isFirstBeat, previousBeat?.status, bean.status)) { if (Monitor.isImportantForNotification(isFirstBeat, previousBeat?.status, bean.status)) {
log.debug("monitor", `[${this.name}] sendNotification`); log.debug("monitor", `[${this.name}] sendNotification`);
await Monitor.sendNotification(isFirstBeat, this, bean); await Monitor.sendNotification(isFirstBeat, this, bean);
} } else {
else {
log.debug("monitor", `[${this.name}] will not sendNotification because it is (or was) under maintenance`); log.debug("monitor", `[${this.name}] will not sendNotification because it is (or was) under maintenance`);
} }
@ -950,7 +948,7 @@ class Monitor extends BeanModel {
} }
static async isUnderMaintenance(monitorID) { static async isUnderMaintenance(monitorID) {
const maintenance = await R.getRow("SELECT COUNT(*) AS count FROM monitor_maintenance mm JOIN maintenance ON mm.maintenance_id = maintenance.id WHERE mm.monitor_id = ? AND datetime(maintenance.start_date) <= datetime('now') AND datetime(maintenance.end_date) >= datetime('now') LIMIT 1", [monitorID]); const maintenance = await R.getRow("SELECT COUNT(*) AS count FROM monitor_maintenance mm JOIN maintenance ON mm.maintenance_id = maintenance.id WHERE mm.monitor_id = ? AND datetime(maintenance.start_date) <= datetime('now') AND datetime(maintenance.end_date) >= datetime('now') LIMIT 1", [ monitorID ]);
return maintenance.count !== 0; return maintenance.count !== 0;
} }
} }

View File

@ -3,8 +3,8 @@
<div class="list-header"> <div class="list-header">
<div class="search-wrapper float-start"> <div class="search-wrapper float-start">
<select v-model="selectedList" class="form-control"> <select v-model="selectedList" class="form-control">
<option value="monitor" selected>{{$t('Monitor List')}}</option> <option value="monitor" selected>{{ $t('Monitor List') }}</option>
<option value="maintenance">{{$t('Maintenance List')}}</option> <option value="maintenance">{{ $t('Maintenance List') }}</option>
</select> </select>
</div> </div>
<div class="search-wrapper"> <div class="search-wrapper">
@ -27,39 +27,55 @@
{{ $t("No Maintenance, please") }} <router-link to="/addMaintenance">{{ $t("add one") }}</router-link> {{ $t("No Maintenance, please") }} <router-link to="/addMaintenance">{{ $t("add one") }}</router-link>
</div> </div>
<router-link v-if="selectedList === 'maintenance'" v-for="(item, index) in sortedMaintenanceList" :key="index" :to="maintenanceURL(item.id)" class="item" :class="{ 'disabled': !this.$root.isActiveMaintenance(item.end_date) }"> <template v-if="selectedList === 'maintenance'">
<div class="row"> <router-link
<div class="col-9 col-md-8 small-padding"> v-for="(item, index) in sortedMaintenanceList" :key="index" :to="maintenanceURL(item.id)"
<div class="info"> class="item" :class="{ 'disabled': !$root.isActiveMaintenance(item.end_date) }"
<Uptime :monitor="null" type="maintenance" :pill="true" /> >
{{ item.title }} <div class="row">
<div class="col-9 col-md-8 small-padding">
<div class="info">
<Uptime :monitor="null" type="maintenance" :pill="true" />
{{ item.title }}
</div>
</div> </div>
</div> </div>
</div> </router-link>
</router-link> </template>
<router-link v-if="selectedList === 'monitor'" v-for="(item, index) in sortedMonitorList" :key="index" :to="monitorURL(item.id)" class="item" :class="{ 'disabled': ! item.active }"> <template v-if="selectedList === 'monitor'">
<div class="row"> <router-link
<div class="col-9 col-md-8 small-padding" :class="{ 'monitor-item': $root.userHeartbeatBar == 'bottom' || $root.userHeartbeatBar == 'none' }"> v-for="(item, index) in sortedMonitorList" :key="index" :to="monitorURL(item.id)"
<div class="info"> class="item" :class="{ 'disabled': ! item.active }"
<Uptime :monitor="item" type="24" :pill="true" /> >
{{ item.name }} <div class="row">
<div
class="col-9 col-md-8 small-padding"
:class="{ 'monitor-item': $root.userHeartbeatBar == 'bottom' || $root.userHeartbeatBar == 'none' }"
>
<div class="info">
<Uptime :monitor="item" type="24" :pill="true" />
{{ item.name }}
</div>
<div class="tags">
<Tag v-for="tag in item.tags" :key="tag" :item="tag" :size="'sm'" />
</div>
</div> </div>
<div class="tags"> <div
<Tag v-for="tag in item.tags" :key="tag" :item="tag" :size="'sm'" /> v-show="$root.userHeartbeatBar == 'normal'" :key="$root.userHeartbeatBar"
class="col-3 col-md-4"
>
<HeartbeatBar size="small" :monitor-id="item.id" />
</div> </div>
</div> </div>
<div v-show="$root.userHeartbeatBar == 'normal'" :key="$root.userHeartbeatBar" class="col-3 col-md-4">
<HeartbeatBar size="small" :monitor-id="item.id" />
</div>
</div>
<div v-if="$root.userHeartbeatBar == 'bottom'" class="row"> <div v-if="$root.userHeartbeatBar == 'bottom'" class="row">
<div class="col-12 bottom-style"> <div class="col-12 bottom-style">
<HeartbeatBar size="small" :monitor-id="item.id" /> <HeartbeatBar size="small" :monitor-id="item.id" />
</div>
</div> </div>
</div> </router-link>
</router-link> </template>
</div> </div>
</div> </div>
</template> </template>
@ -282,7 +298,6 @@ export default {
margin-top: 5px; margin-top: 5px;
} }
.bg-maintenance { .bg-maintenance {
background-color: $maintenance; background-color: $maintenance;
} }

View File

@ -31,7 +31,7 @@ export default {
color() { color() {
if (this.type === "maintenance" || this.monitor.maintenance) { if (this.type === "maintenance" || this.monitor.maintenance) {
return "maintenance" return "maintenance";
} }
if (this.lastHeartBeat.status === 0) { if (this.lastHeartBeat.status === 0) {

View File

@ -34,10 +34,11 @@ export default {
const inputDate = new Date(value); const inputDate = new Date(value);
const now = new Date(Date.now()); const now = new Date(Date.now());
if (inputDate.getFullYear() === now.getUTCFullYear() && inputDate.getMonth() === now.getUTCMonth() && inputDate.getDay() === now.getUTCDay()) if (inputDate.getFullYear() === now.getUTCFullYear() && inputDate.getMonth() === now.getUTCMonth() && inputDate.getDay() === now.getUTCDay()) {
return this.datetimeFormat(value, "HH:mm"); return this.datetimeFormat(value, "HH:mm");
else } else {
return this.datetimeFormat(value, "YYYY-MM-DD HH:mm"); return this.datetimeFormat(value, "YYYY-MM-DD HH:mm");
}
}, },
date(value) { date(value) {

View File

@ -464,8 +464,7 @@ export default {
text: this.$t("Maintenance"), text: this.$t("Maintenance"),
color: "maintenance", color: "maintenance",
}; };
} } else if (! lastHeartBeat) {
else if (! lastHeartBeat) {
result[monitorID] = unknown; result[monitorID] = unknown;
} else if (lastHeartBeat.status === 1) { } else if (lastHeartBeat.status === 1) {
result[monitorID] = { result[monitorID] = {
@ -505,8 +504,7 @@ export default {
if (monitor && monitor.maintenance) { if (monitor && monitor.maintenance) {
result.maintenance++; result.maintenance++;
} } else if (monitor && ! monitor.active) {
else if (monitor && ! monitor.active) {
result.pause++; result.pause++;
} else if (beat) { } else if (beat) {
if (beat.status === 1) { if (beat.status === 1) {

View File

@ -8,12 +8,12 @@
</button> </button>
<ul class="dropdown-menu dropdown-menu-end"> <ul class="dropdown-menu dropdown-menu-end">
<li> <li>
<button type="button" class="dropdown-item" @click="this.$router.push('/add')"> <button type="button" class="dropdown-item" @click="$router.push('/add')">
<font-awesome-icon icon="heartbeat" /> {{ $t("Monitor") }} <font-awesome-icon icon="heartbeat" /> {{ $t("Monitor") }}
</button> </button>
</li> </li>
<li> <li>
<button type="button" class="dropdown-item" @click="this.$router.push('/addMaintenance')"> <button type="button" class="dropdown-item" @click="$router.push('/addMaintenance')">
<font-awesome-icon icon="exclamation-circle" /> {{ $t("Maintenance") }} <font-awesome-icon icon="exclamation-circle" /> {{ $t("Maintenance") }}
</button> </button>
</li> </li>

View File

@ -11,15 +11,19 @@
<!-- Title --> <!-- Title -->
<div class="my-3"> <div class="my-3">
<label for="name" class="form-label">{{ $t("Title") }}</label> <label for="name" class="form-label">{{ $t("Title") }}</label>
<input id="name" v-model="maintenance.title" type="text" class="form-control" <input
:placeholder="titlePlaceholder" required> id="name" v-model="maintenance.title" type="text" class="form-control"
:placeholder="titlePlaceholder" required
>
</div> </div>
<!-- Description --> <!-- Description -->
<div class="my-3"> <div class="my-3">
<label for="description" class="form-label">{{ $t("Description") }}</label> <label for="description" class="form-label">{{ $t("Description") }}</label>
<textarea id="description" v-model="maintenance.description" class="form-control" <textarea
:placeholder="descriptionPlaceholder"></textarea> id="description" v-model="maintenance.description" class="form-control"
:placeholder="descriptionPlaceholder"
></textarea>
</div> </div>
<!-- Affected Monitors --> <!-- Affected Monitors -->
@ -50,21 +54,28 @@
<!-- Start Date Time --> <!-- Start Date Time -->
<div class="my-3"> <div class="my-3">
<label for="start_date" class="form-label">{{ $t("Start of maintenance") }} ({{this.$root.timezone}})</label> <label for="start_date" class="form-label">{{ $t("Start of maintenance") }} ({{ $root.timezone }})</label>
<input :type="'datetime-local'" id="start_date" v-model="maintenance.start_date" <input
class="form-control" :class="{'darkCalendar': dark }" required> id="start_date" v-model="maintenance.start_date" :type="'datetime-local'"
class="form-control" :class="{'darkCalendar': dark }" required
>
</div> </div>
<!-- End Date Time --> <!-- End Date Time -->
<div class="my-3"> <div class="my-3">
<label for="end_date" class="form-label">{{ $t("Expected end of maintenance") }} ({{this.$root.timezone}})</label> <label for="end_date" class="form-label">{{ $t("Expected end of maintenance") }} ({{ $root.timezone }})</label>
<input :type="'datetime-local'" id="end_date" v-model="maintenance.end_date" <input
class="form-control" :class="{'darkCalendar': dark }" required> id="end_date" v-model="maintenance.end_date" :type="'datetime-local'"
class="form-control" :class="{'darkCalendar': dark }" required
>
</div> </div>
<div class="mt-5 mb-1"> <div class="mt-5 mb-1">
<button id="monitor-submit-btn" class="btn btn-primary" type="submit" <button
:disabled="processing">{{ $t("Save") }} id="monitor-submit-btn" class="btn btn-primary" type="submit"
:disabled="processing"
>
{{ $t("Save") }}
</button> </button>
</div> </div>
</div> </div>
@ -78,7 +89,7 @@
<script> <script>
import CopyableInput from "../components/CopyableInput.vue"; import CopyableInput from "../components/CopyableInput.vue";
import {useToast} from "vue-toastification"; import { useToast } from "vue-toastification";
import VueMultiselect from "vue-multiselect"; import VueMultiselect from "vue-multiselect";
const toast = useToast(); const toast = useToast();

View File

@ -3,9 +3,9 @@
<div v-if="maintenance"> <div v-if="maintenance">
<h1> {{ maintenance.title }}</h1> <h1> {{ maintenance.title }}</h1>
<p class="url"> <p class="url">
<span>{{$t("Start")}}: {{ $root.datetimeMaintenance(maintenance.start_date) }}</span> <span>{{ $t("Start") }}: {{ $root.datetimeMaintenance(maintenance.start_date) }}</span>
<br> <br>
<span>{{$t("End")}}: {{ $root.datetimeMaintenance(maintenance.end_date) }}</span> <span>{{ $t("End") }}: {{ $root.datetimeMaintenance(maintenance.end_date) }}</span>
</p> </p>
<div class="functions" style="margin-top: 10px"> <div class="functions" style="margin-top: 10px">
@ -22,7 +22,7 @@
<label for="affected_monitors" class="form-label" style="margin-top: 20px">{{ $t("Affected Monitors") }}</label> <label for="affected_monitors" class="form-label" style="margin-top: 20px">{{ $t("Affected Monitors") }}</label>
<br> <br>
<button v-for="monitor in this.affectedMonitors" class="btn btn-monitor" style="margin: 5px; cursor: auto; color: white; font-weight: bold"> <button v-for="monitor in affectedMonitors" class="btn btn-monitor" style="margin: 5px; cursor: auto; color: white; font-weight: bold">
{{ monitor }} {{ monitor }}
</button> </button>

View File

@ -104,15 +104,16 @@
<!-- Uploader --> <!-- Uploader -->
<!-- url="/api/status-page/upload-logo" --> <!-- url="/api/status-page/upload-logo" -->
<ImageCropUpload v-model="showImageCropUpload" <ImageCropUpload
field="img" v-model="showImageCropUpload"
:width="128" field="img"
:height="128" :width="128"
:langType="$i18n.locale" :height="128"
img-format="png" :langType="$i18n.locale"
:noCircle="true" img-format="png"
:noSquare="false" :noCircle="true"
@crop-success="cropSuccess" :noSquare="false"
@crop-success="cropSuccess"
/> />
<!-- Title --> <!-- Title -->
@ -196,16 +197,18 @@
<!-- Maintenance --> <!-- Maintenance -->
<template v-if="maintenance.length !== 0"> <template v-if="maintenance.length !== 0">
<div v-for="maintenanceItem in maintenance" class="shadow-box alert mb-4 p-4 maintenance" role="alert" <div
:class="maintenanceClass"> v-for="maintenanceItem in maintenance" class="shadow-box alert mb-4 p-4 maintenance" role="alert"
<h4 v-text="maintenanceItem.title" class="alert-heading"/> :class="maintenanceClass"
>
<h4 class="alert-heading" v-text="maintenanceItem.title" />
<div v-text="maintenanceItem.description" class="content"/> <div class="content" v-text="maintenanceItem.description" />
<!-- Incident Date --> <!-- Incident Date -->
<div class="date mt-3"> <div class="date mt-3">
{{ $t("End") }}: {{ $root.datetimeMaintenance(maintenanceItem.end_date) }} {{ $t("End") }}: {{ $root.datetimeMaintenance(maintenanceItem.end_date) }}
({{ dateFromNow(maintenanceItem.start_date) }})<br/> ({{ dateFromNow(maintenanceItem.start_date) }})<br />
</div> </div>
</div> </div>
</template> </template>
@ -448,8 +451,7 @@ export default {
if (beat.status === MAINTENANCE) { if (beat.status === MAINTENANCE) {
return STATUS_PAGE_MAINTENANCE; return STATUS_PAGE_MAINTENANCE;
} } else if (beat.status === UP) {
else if (beat.status === UP) {
hasUp = true; hasUp = true;
} else { } else {
status = STATUS_PAGE_PARTIAL_DOWN; status = STATUS_PAGE_PARTIAL_DOWN;