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)) {
bean.msg = "Monitor under 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"
let startTime = dayjs().valueOf();
@ -482,8 +481,7 @@ class Monitor extends BeanModel {
if (Monitor.isImportantForNotification(isFirstBeat, previousBeat?.status, bean.status)) {
log.debug("monitor", `[${this.name}] sendNotification`);
await Monitor.sendNotification(isFirstBeat, this, bean);
}
else {
} else {
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) {
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;
}
}

View file

@ -3,8 +3,8 @@
<div class="list-header">
<div class="search-wrapper float-start">
<select v-model="selectedList" class="form-control">
<option value="monitor" selected>{{$t('Monitor List')}}</option>
<option value="maintenance">{{$t('Maintenance List')}}</option>
<option value="monitor" selected>{{ $t('Monitor List') }}</option>
<option value="maintenance">{{ $t('Maintenance List') }}</option>
</select>
</div>
<div class="search-wrapper">
@ -27,7 +27,11 @@
{{ $t("No Maintenance, please") }} <router-link to="/addMaintenance">{{ $t("add one") }}</router-link>
</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'">
<router-link
v-for="(item, index) in sortedMaintenanceList" :key="index" :to="maintenanceURL(item.id)"
class="item" :class="{ 'disabled': !$root.isActiveMaintenance(item.end_date) }"
>
<div class="row">
<div class="col-9 col-md-8 small-padding">
<div class="info">
@ -37,10 +41,18 @@
</div>
</div>
</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'">
<router-link
v-for="(item, index) in sortedMonitorList" :key="index" :to="monitorURL(item.id)"
class="item" :class="{ 'disabled': ! item.active }"
>
<div class="row">
<div class="col-9 col-md-8 small-padding" :class="{ 'monitor-item': $root.userHeartbeatBar == 'bottom' || $root.userHeartbeatBar == 'none' }">
<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 }}
@ -49,7 +61,10 @@
<Tag v-for="tag in item.tags" :key="tag" :item="tag" :size="'sm'" />
</div>
</div>
<div v-show="$root.userHeartbeatBar == 'normal'" :key="$root.userHeartbeatBar" class="col-3 col-md-4">
<div
v-show="$root.userHeartbeatBar == 'normal'" :key="$root.userHeartbeatBar"
class="col-3 col-md-4"
>
<HeartbeatBar size="small" :monitor-id="item.id" />
</div>
</div>
@ -60,6 +75,7 @@
</div>
</div>
</router-link>
</template>
</div>
</div>
</template>
@ -282,7 +298,6 @@ export default {
margin-top: 5px;
}
.bg-maintenance {
background-color: $maintenance;
}

View file

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

View file

@ -34,10 +34,11 @@ export default {
const inputDate = new Date(value);
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");
else
} else {
return this.datetimeFormat(value, "YYYY-MM-DD HH:mm");
}
},
date(value) {

View file

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

View file

@ -8,12 +8,12 @@
</button>
<ul class="dropdown-menu dropdown-menu-end">
<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") }}
</button>
</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") }}
</button>
</li>

View file

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

View file

@ -3,9 +3,9 @@
<div v-if="maintenance">
<h1> {{ maintenance.title }}</h1>
<p class="url">
<span>{{$t("Start")}}: {{ $root.datetimeMaintenance(maintenance.start_date) }}</span>
<span>{{ $t("Start") }}: {{ $root.datetimeMaintenance(maintenance.start_date) }}</span>
<br>
<span>{{$t("End")}}: {{ $root.datetimeMaintenance(maintenance.end_date) }}</span>
<span>{{ $t("End") }}: {{ $root.datetimeMaintenance(maintenance.end_date) }}</span>
</p>
<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>
<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 }}
</button>

View file

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