2021-06-25 13:55:49 +00:00
< template >
2021-08-19 18:37:59 +00:00
< transition name = "slide-fade" appear >
2021-08-23 08:59:27 +00:00
< div v-if = "monitor" >
2023-01-28 13:53:40 +00:00
< router-link v-if = "group !== ''" :to="monitorURL(monitor.parent)" > {{ group }} < / router -link >
2024-01-28 10:15:29 +00:00
< h1 >
{ { monitor . name } }
< div class = "monitor-id" >
< div class = "hash" > # < / div >
< div > { { monitor . id } } < / div >
< / div >
< / h1 >
2021-11-25 21:11:13 +00:00
< p v-if = "monitor.description" > {{ monitor.description }} < / p >
2024-01-28 10:15:29 +00:00
< div class = "d-flex" >
< div class = "tags" >
< Tag v-for = "tag in monitor.tags" :key="tag.id" :item="tag" :size="'sm'" / >
< / div >
2021-08-26 10:55:19 +00:00
< / div >
2021-08-19 18:37:59 +00:00
< p class = "url" >
2023-07-13 15:37:26 +00:00
< a v-if = "monitor.type === 'http' || monitor.type === 'keyword' || monitor.type === 'json-query' || monitor.type === 'mp-health' " :href="monitor.url" target="_blank" rel="noopener noreferrer" > {{ filterPassword ( monitor.url ) }} < / a >
2023-04-27 07:34:01 +00:00
< span v-if = "monitor.type === 'port'" > TCP Port {{ monitor.hostname }} : {{ monitor.port }} < / span >
2021-08-19 18:37:59 +00:00
< span v-if = "monitor.type === 'ping'" > Ping : {{ monitor.hostname }} < / span >
< span v-if = "monitor.type === 'keyword'" >
< br >
2023-04-06 00:10:21 +00:00
< span > { { $t ( "Keyword" ) } } : < / span >
< span class = "keyword" > { { monitor . keyword } } < / span >
< span v-if = "monitor.invertKeyword" alt="Inverted keyword" class="keyword-inverted" > ↧ < / span >
2021-08-19 18:37:59 +00:00
< / span >
2023-07-13 15:37:26 +00:00
< span v-if = "monitor.type === 'json-query'" >
< br >
< span > { { $t ( "Json Query" ) } } : < / span > < span class = "keyword" > { { monitor . jsonPath } } < / span >
< br >
< span > { { $t ( "Expected Value" ) } } : < / span > < span class = "keyword" > { { monitor . expectedValue } } < / span >
< / span >
2021-08-29 01:57:26 +00:00
< span v-if = "monitor.type === 'dns'" > [ {{ monitor.dns_resolve_type }} ] {{ monitor.hostname }}
< br >
< span > { { $t ( "Last Result" ) } } : < / span > < span class = "keyword" > { { monitor . dns _last _result } } < / span >
< / span >
2023-04-01 15:54:27 +00:00
< span v-if = "monitor.type === 'docker'" > Docker container : {{ monitor.docker_container }} < / span >
< span v-if = "monitor.type === 'gamedig'" > Gamedig - {{ monitor.game }} : {{ monitor.hostname }} : {{ monitor.port }} < / span >
2023-04-18 19:20:35 +00:00
< span v-if = "monitor.type === 'grpc-keyword'" > gRPC - {{ filterPassword ( monitor.grpcUrl ) }}
2023-04-01 15:54:27 +00:00
< br >
< span > { { $t ( "Keyword" ) } } : < / span > < span class = "keyword" > { { monitor . keyword } } < / span >
< / span >
2023-04-18 19:20:35 +00:00
< span v-if = "monitor.type === 'mongodb'" > {{ filterPassword ( monitor.databaseConnectionString ) }} < / span >
2023-04-01 15:54:27 +00:00
< span v-if = "monitor.type === 'mqtt'" > MQTT : {{ monitor.hostname }} : {{ monitor.port }} / {{ monitor.mqttTopic }} < / span >
2023-04-18 19:20:35 +00:00
< span v-if = "monitor.type === 'mysql'" > {{ filterPassword ( monitor.databaseConnectionString ) }} < / span >
< span v-if = "monitor.type === 'postgres'" > {{ filterPassword ( monitor.databaseConnectionString ) }} < / span >
2023-04-01 15:54:27 +00:00
< span v-if = "monitor.type === 'push'">Push: <a :href="pushURL" target="_blank" rel="noopener noreferrer" > {{ pushURL }} < / a > < / span >
2023-04-18 19:20:35 +00:00
< span v-if = "monitor.type === 'radius'" > Radius : {{ filterPassword ( monitor.hostname ) }} < / span >
< span v-if = "monitor.type === 'redis'" > {{ filterPassword ( monitor.databaseConnectionString ) }} < / span >
< span v-if = "monitor.type === 'sqlserver'" > SQL Server : {{ filterPassword ( monitor.databaseConnectionString ) }} < / span >
2023-04-01 15:54:27 +00:00
< span v-if = "monitor.type === 'steam'" > Steam Game Server : {{ monitor.hostname }} : {{ monitor.port }} < / span >
2021-08-19 18:37:59 +00:00
< / p >
2021-06-25 13:55:49 +00:00
2021-08-19 18:37:59 +00:00
< div class = "functions" >
2022-10-15 13:01:48 +00:00
< div class = "btn-group" role = "group" >
< button v-if = "monitor.active" class="btn btn-normal" @click="pauseDialog" >
< font-awesome-icon icon = "pause" / > { { $t ( "Pause" ) } }
< / button >
2023-01-28 12:39:17 +00:00
< button v-if = "! monitor.active" class="btn btn-primary" :disabled="monitor.forceInactive" @click="resumeMonitor" >
2022-10-15 13:01:48 +00:00
< font-awesome-icon icon = "play" / > { { $t ( "Resume" ) } }
< / button >
< router-link : to = " '/edit/' + monitor.id " class = "btn btn-normal" >
< font-awesome-icon icon = "edit" / > { { $t ( "Edit" ) } }
< / router-link >
2022-12-27 22:26:05 +00:00
< router-link : to = " '/clone/' + monitor.id " class = "btn btn-normal" >
2023-01-02 12:17:38 +00:00
< font-awesome-icon icon = "clone" / > { { $t ( "Clone" ) } }
2022-12-27 22:26:05 +00:00
< / router-link >
2024-01-03 16:29:38 +00:00
< button class = "btn btn-normal text-danger" @click ="deleteDialog" >
2022-10-15 13:01:48 +00:00
< font-awesome-icon icon = "trash" / > { { $t ( "Delete" ) } }
< / button >
< / div >
2021-06-25 13:55:49 +00:00
< / div >
2021-08-19 18:37:59 +00:00
< div class = "shadow-box" >
< div class = "row" >
< div class = "col-md-8" >
< HeartbeatBar :monitor-id = "monitor.id" / >
2021-08-24 10:26:44 +00:00
< span class = "word" > { { $t ( "checkEverySecond" , [ monitor . interval ] ) } } < / span >
2021-08-19 18:37:59 +00:00
< / div >
< div class = "col-md-4 text-center" >
2021-10-18 16:19:26 +00:00
< span class = "badge rounded-pill" : class = " 'bg-' + status.color " style = "font-size: 30px;" > { { status . text } } < / span >
2021-08-19 18:37:59 +00:00
< / div >
< / div >
2021-06-30 13:04:58 +00:00
< / div >
2021-07-26 14:53:07 +00:00
2023-09-25 09:49:00 +00:00
<!-- Push Examples -- >
< div v-if = "monitor.type === 'push'" class="shadow-box big-padding" >
< a href = "#" @ click = "pushMonitor.showPushExamples = !pushMonitor.showPushExamples" > { { $t ( "pushViewCode" ) } } < / a >
< transition name = "slide-fade" appear >
< div v-if = "pushMonitor.showPushExamples" class="mt-3" >
< select id = "push-current-example" v-model = "pushMonitor.currentExample" class="form-select" >
< optgroup :label = "$t('programmingLanguages')" >
< option value = "csharp" > C # < / option >
< option value = "go" > Go < / option >
< option value = "java" > Java < / option >
< option value = "javascript-fetch" > JavaScript ( fetch ) < / option >
< option value = "php" > PHP < / option >
< option value = "python" > Python < / option >
< option value = "typescript-fetch" > TypeScript ( fetch ) < / option >
< / optgroup >
< optgroup :label = "$t('pushOthers')" >
< option value = "bash-curl" > Bash ( curl ) < / option >
< option value = "powershell" > PowerShell < / option >
< option value = "docker" > Docker < / option >
< / optgroup >
< / select >
< prism-editor v-model = "pushMonitor.code" class="css-editor mt-3" :highlight="pushExampleHighlighter" line -numbers readonly > < / prism-editor >
< / div >
< / transition >
< / div >
2023-06-27 07:54:33 +00:00
<!-- Stats -- >
2021-08-19 18:37:59 +00:00
< div class = "shadow-box big-padding text-center stats" >
< div class = "row" >
2023-06-03 18:55:24 +00:00
< div v-if = "monitor.type !== 'group'" class="col-12 col-sm col row d-flex align-items-center d-sm-block" >
2023-04-11 13:16:45 +00:00
< h4 class = "col-4 col-sm-12" > { { pingTitle ( ) } } < / h4 >
< p class = "col-4 col-sm-12 mb-0 mb-sm-2" > ( { { $t ( "Current" ) } } ) < / p >
< span class = "col-4 col-sm-12 num" >
2021-08-19 18:37:59 +00:00
< a href = "#" @ click.prevent = " showPingChartBox = ! showPingChartBox " >
< CountUp :value = "ping" / >
< / a >
< / span >
< / div >
2023-06-03 18:55:24 +00:00
< div v-if = "monitor.type !== 'group'" class="col-12 col-sm col row d-flex align-items-center d-sm-block" >
2023-04-11 13:16:45 +00:00
< h4 class = "col-4 col-sm-12" > { { pingTitle ( true ) } } < / h4 >
< p class = "col-4 col-sm-12 mb-0 mb-sm-2" > ( 24 { { $t ( "-hour" ) } } ) < / p >
< span class = "col-4 col-sm-12 num" >
< CountUp :value = "avgPing" / >
< / span >
2021-08-19 18:37:59 +00:00
< / div >
2023-08-31 21:19:21 +00:00
<!-- Uptime ( 24 - hour ) -- >
2023-04-11 13:16:45 +00:00
< div class = "col-12 col-sm col row d-flex align-items-center d-sm-block" >
< h4 class = "col-4 col-sm-12" > { { $t ( "Uptime" ) } } < / h4 >
< p class = "col-4 col-sm-12 mb-0 mb-sm-2" > ( 24 { { $t ( "-hour" ) } } ) < / p >
< span class = "col-4 col-sm-12 num" >
< Uptime :monitor = "monitor" type = "24" / >
< / span >
2021-08-19 18:37:59 +00:00
< / div >
2023-08-31 21:19:21 +00:00
<!-- Uptime ( 30 - day ) -- >
2023-04-11 13:16:45 +00:00
< div class = "col-12 col-sm col row d-flex align-items-center d-sm-block" >
< h4 class = "col-4 col-sm-12" > { { $t ( "Uptime" ) } } < / h4 >
< p class = "col-4 col-sm-12 mb-0 mb-sm-2" > ( 30 { { $t ( "-day" ) } } ) < / p >
< span class = "col-4 col-sm-12 num" >
< Uptime :monitor = "monitor" type = "720" / >
< / span >
2021-08-19 18:37:59 +00:00
< / div >
2023-08-31 21:19:21 +00:00
<!-- Uptime ( 1 - year ) -- >
< div class = "col-12 col-sm col row d-flex align-items-center d-sm-block" >
< h4 class = "col-4 col-sm-12" > { { $t ( "Uptime" ) } } < / h4 >
< p class = "col-4 col-sm-12 mb-0 mb-sm-2" > ( 1 { { $t ( "-year" ) } } ) < / p >
< span class = "col-4 col-sm-12 num" >
< Uptime :monitor = "monitor" type = "1y" / >
< / span >
< / div >
2023-04-11 13:16:45 +00:00
< div v-if = "tlsInfo" class="col-12 col-sm col row d-flex align-items-center d-sm-block" >
< h4 class = "col-4 col-sm-12" > { { $t ( "Cert Exp." ) } } < / h4 >
< p class = "col-4 col-sm-12 mb-0 mb-sm-2" > ( < Datetime :value = "tlsInfo.certInfo.validTo" date -only / > ) < / p >
< span class = "col-4 col-sm-12 num" >
2022-05-30 09:53:32 +00:00
< a href = "#" @ click.prevent = " toggleCertInfoBox = ! toggleCertInfoBox " > { { tlsInfo . certInfo . daysRemaining } } { { $tc ( "day" , tlsInfo . certInfo . daysRemaining ) } } < / a >
2021-08-19 18:37:59 +00:00
< / span >
< / div >
< / div >
2021-07-26 14:53:07 +00:00
< / div >
2021-06-30 13:04:58 +00:00
2021-10-09 11:08:38 +00:00
<!-- Cert Info Box -- >
2021-08-19 18:37:59 +00:00
< transition name = "slide-fade" appear >
< div v-if = "showCertInfoBox" class="shadow-box big-padding text-center" >
< div class = "row" >
< div class = "col" >
2021-10-01 10:44:32 +00:00
< certificate-info :certInfo = "tlsInfo.certInfo" :valid = "tlsInfo.valid" / >
2021-08-19 18:37:59 +00:00
< / div >
< / div >
< / div >
< / transition >
2021-10-09 11:08:38 +00:00
<!-- Ping Chart -- >
2021-08-19 18:37:59 +00:00
< div v-if = "showPingChartBox" class="shadow-box big-padding text-center ping-chart-wrapper" >
< div class = "row" >
< div class = "col" >
< PingChart :monitor-id = "monitor.id" / >
< / div >
< / div >
2021-08-10 11:34:47 +00:00
< / div >
2023-06-27 07:54:33 +00:00
<!-- Screenshot -- >
< div v-if = "monitor.type === 'real-browser'" class="shadow-box" >
< div class = "row" >
2023-11-23 18:58:33 +00:00
< div class = "col-md-6 zoom-cursor" >
< img :src = "screenshotURL" style = "width: 100%;" alt = "screenshot of the website" @click ="showScreenshotDialog" >
2023-06-27 07:54:33 +00:00
< / div >
2023-11-23 18:58:33 +00:00
< ScreenshotDialog ref = "screenshotDialog" :imageURL = "screenshotURL" / >
2023-06-27 07:54:33 +00:00
< / div >
< / div >
2021-08-23 18:02:38 +00:00
< div class = "shadow-box table-shadow-box" >
2021-08-29 16:47:01 +00:00
< div class = "dropdown dropdown-clear-data" >
< button class = "btn btn-sm btn-outline-danger dropdown-toggle" type = "button" data -bs -toggle = " dropdown " >
< font-awesome-icon icon = "trash" / > { { $t ( "Clear Data" ) } }
< / button >
< ul class = "dropdown-menu dropdown-menu-end" >
< li >
< button type = "button" class = "dropdown-item" @click ="clearEventsDialog" >
{ { $t ( "Events" ) } }
< / button >
< / li >
< li >
< button type = "button" class = "dropdown-item" @click ="clearHeartbeatsDialog" >
{ { $t ( "Heartbeats" ) } }
< / button >
< / li >
< / ul >
< / div >
2021-08-19 18:37:59 +00:00
< table class = "table table-borderless table-hover" >
< thead >
< tr >
2021-08-24 10:26:44 +00:00
< th > { { $t ( "Status" ) } } < / th >
< th > { { $t ( "DateTime" ) } } < / th >
< th > { { $t ( "Message" ) } } < / th >
2021-07-21 04:09:09 +00:00
< / tr >
2021-08-19 18:37:59 +00:00
< / thead >
< tbody >
2023-04-11 13:16:45 +00:00
< tr v-for = "(beat, index) in displayedRecords" :key="index" style="padding: 10px;" >
2021-08-19 18:37:59 +00:00
< td > < Status :status = "beat.status" / > < / td >
2021-08-22 23:22:55 +00:00
< td : class = "{ 'border-0':! beat.msg}" > < Datetime :value = "beat.time" / > < / td >
< td class = "border-0" > { { beat . msg } } < / td >
2021-07-21 04:09:09 +00:00
< / tr >
2021-08-19 18:37:59 +00:00
2023-09-23 11:03:45 +00:00
< tr v-if = "importantHeartBeatListLength === 0" >
2021-08-19 18:37:59 +00:00
< td colspan = "3" >
2021-08-24 10:26:44 +00:00
{ { $t ( "No important events" ) } }
2021-07-27 17:47:13 +00:00
< / td >
2021-07-21 04:09:09 +00:00
< / tr >
< / tbody >
< / table >
2021-08-19 18:37:59 +00:00
< div class = "d-flex justify-content-center kuma_pagination" >
< pagination
v - model = "page"
2023-09-23 11:03:45 +00:00
: records = "importantHeartBeatListLength"
2021-08-19 18:37:59 +00:00
: per - page = "perPage"
2021-09-26 15:20:12 +00:00
: options = "paginationConfig"
2021-08-19 18:37:59 +00:00
/ >
< / div >
< / div >
2021-06-30 13:04:58 +00:00
2021-08-29 02:03:55 +00:00
< Confirm ref = "confirmPause" :yes-text = "$t('Yes')" :no-text = "$t('No')" @yes ="pauseMonitor" >
{ { $t ( "pauseMonitorMsg" ) } }
2021-08-19 18:37:59 +00:00
< / Confirm >
2021-07-18 01:04:40 +00:00
2021-08-26 00:43:26 +00:00
< Confirm ref = "confirmDelete" btn -style = " btn -danger " :yes-text = "$t('Yes')" :no-text = "$t('No')" @yes ="deleteMonitor" >
{ { $t ( "deleteMonitorMsg" ) } }
2021-08-19 18:37:59 +00:00
< / Confirm >
2021-08-29 16:47:01 +00:00
< Confirm ref = "confirmClearEvents" btn -style = " btn -danger " :yes-text = "$t('Yes')" :no-text = "$t('No')" @yes ="clearEvents" >
{ { $t ( "clearEventsMsg" ) } }
< / Confirm >
< Confirm ref = "confirmClearHeartbeats" btn -style = " btn -danger " :yes-text = "$t('Yes')" :no-text = "$t('No')" @yes ="clearHeartbeats" >
{ { $t ( "clearHeartbeatsMsg" ) } }
< / Confirm >
2021-07-18 01:04:40 +00:00
< / div >
2021-08-19 18:37:59 +00:00
< / transition >
2021-06-25 13:55:49 +00:00
< / template >
< script >
2021-08-11 16:47:58 +00:00
import { defineAsyncComponent } from "vue" ;
2021-10-01 10:44:32 +00:00
import { useToast } from "vue-toastification" ;
const toast = useToast ( ) ;
2021-06-25 13:55:49 +00:00
import Confirm from "../components/Confirm.vue" ;
2021-06-25 19:03:06 +00:00
import HeartbeatBar from "../components/HeartbeatBar.vue" ;
2021-06-30 13:04:58 +00:00
import Status from "../components/Status.vue" ;
import Datetime from "../components/Datetime.vue" ;
import CountUp from "../components/CountUp.vue" ;
2021-07-01 05:11:16 +00:00
import Uptime from "../components/Uptime.vue" ;
2021-07-18 01:04:40 +00:00
import Pagination from "v-pagination-3" ;
2021-08-11 16:47:58 +00:00
const PingChart = defineAsyncComponent ( ( ) => import ( "../components/PingChart.vue" ) ) ;
2021-08-26 10:55:19 +00:00
import Tag from "../components/Tag.vue" ;
2021-10-01 10:44:32 +00:00
import CertificateInfo from "../components/CertificateInfo.vue" ;
2023-01-28 13:53:40 +00:00
import { getMonitorRelativeURL } from "../util.ts" ;
2023-04-18 19:20:35 +00:00
import { URL } from "whatwg-url" ;
2023-06-27 07:54:33 +00:00
import { getResBaseURL } from "../util-frontend" ;
2023-09-25 09:49:00 +00:00
import { highlight , languages } from "prismjs/components/prism-core" ;
import "prismjs/components/prism-clike" ;
import "prismjs/components/prism-javascript" ;
import "prismjs/components/prism-css" ;
import { PrismEditor } from "vue-prism-editor" ;
import "vue-prism-editor/dist/prismeditor.min.css" ;
2023-11-23 18:58:33 +00:00
import ScreenshotDialog from "../components/ScreenshotDialog.vue" ;
2021-06-25 13:55:49 +00:00
export default {
components : {
2021-07-01 05:11:16 +00:00
Uptime ,
2021-06-30 13:04:58 +00:00
CountUp ,
Datetime ,
2021-06-25 19:03:06 +00:00
HeartbeatBar ,
2021-06-30 13:04:58 +00:00
Confirm ,
Status ,
2021-07-18 01:04:40 +00:00
Pagination ,
2021-08-10 11:34:47 +00:00
PingChart ,
2021-08-26 10:55:19 +00:00
Tag ,
2021-10-01 10:44:32 +00:00
CertificateInfo ,
2023-09-25 09:49:00 +00:00
PrismEditor ,
2023-11-23 18:58:33 +00:00
ScreenshotDialog
2021-06-25 13:55:49 +00:00
} ,
data ( ) {
return {
2021-07-18 01:04:40 +00:00
page : 1 ,
perPage : 25 ,
heartBeatList : [ ] ,
2021-07-26 14:53:07 +00:00
toggleCertInfoBox : false ,
2021-08-11 12:59:33 +00:00
showPingChartBox : true ,
2021-09-26 15:20:12 +00:00
paginationConfig : {
2021-10-29 11:37:38 +00:00
hideCount : true ,
2021-10-26 16:03:49 +00:00
chunksNavigation : "scroll" ,
} ,
2023-06-27 07:54:33 +00:00
cacheTime : Date . now ( ) ,
2023-09-23 11:03:45 +00:00
importantHeartBeatListLength : 0 ,
displayedRecords : [ ] ,
2023-09-25 09:49:00 +00:00
pushMonitor : {
showPushExamples : false ,
currentExample : "javascript-fetch" ,
code : "" ,
} ,
2021-10-01 10:44:32 +00:00
} ;
2021-06-25 13:55:49 +00:00
} ,
computed : {
monitor ( ) {
2021-10-01 10:44:32 +00:00
let id = this . $route . params . id ;
2021-06-27 08:10:55 +00:00
return this . $root . monitorList [ id ] ;
} ,
2021-06-25 13:55:49 +00:00
2021-06-27 08:10:55 +00:00
lastHeartBeat ( ) {
2023-06-27 07:54:33 +00:00
// Also trigger screenshot refresh here
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
this . cacheTime = Date . now ( ) ;
2021-06-27 08:10:55 +00:00
if ( this . monitor . id in this . $root . lastHeartbeatList && this . $root . lastHeartbeatList [ this . monitor . id ] ) {
2021-10-01 10:44:32 +00:00
return this . $root . lastHeartbeatList [ this . monitor . id ] ;
2021-07-27 17:47:13 +00:00
}
return {
status : - 1 ,
2021-10-01 10:44:32 +00:00
} ;
2021-06-25 13:55:49 +00:00
} ,
2021-06-27 08:10:55 +00:00
2021-06-30 13:04:58 +00:00
ping ( ) {
2021-07-12 03:20:18 +00:00
if ( this . lastHeartBeat . ping || this . lastHeartBeat . ping === 0 ) {
2021-06-30 13:04:58 +00:00
return this . lastHeartBeat . ping ;
}
2021-07-27 17:47:13 +00:00
2021-10-01 10:44:32 +00:00
return this . $t ( "notAvailableShort" ) ;
2021-06-30 13:04:58 +00:00
} ,
avgPing ( ) {
2021-07-12 03:20:18 +00:00
if ( this . $root . avgPingList [ this . monitor . id ] || this . $root . avgPingList [ this . monitor . id ] === 0 ) {
2021-06-30 13:04:58 +00:00
return this . $root . avgPingList [ this . monitor . id ] ;
}
2021-07-27 17:47:13 +00:00
2021-10-01 10:44:32 +00:00
return this . $t ( "notAvailableShort" ) ;
2021-06-30 13:04:58 +00:00
} ,
2021-06-27 08:10:55 +00:00
status ( ) {
if ( this . $root . statusList [ this . monitor . id ] ) {
2021-10-01 10:44:32 +00:00
return this . $root . statusList [ this . monitor . id ] ;
2021-06-27 08:10:55 +00:00
}
2021-07-27 17:47:13 +00:00
2021-10-01 10:44:32 +00:00
return { } ;
2021-07-18 01:04:40 +00:00
} ,
2021-06-27 08:10:55 +00:00
2021-10-01 10:44:32 +00:00
tlsInfo ( ) {
2021-10-09 11:08:38 +00:00
// Add: this.$root.tlsInfoList[this.monitor.id].certInfo
// Fix: TypeError: Cannot read properties of undefined (reading 'validTo')
// Reason: TLS Info object format is changed in 1.8.0, if for some reason, it cannot connect to the site after update to 1.8.0, the object is still in the old format.
if ( this . $root . tlsInfoList [ this . monitor . id ] && this . $root . tlsInfoList [ this . monitor . id ] . certInfo ) {
2021-10-01 10:44:32 +00:00
return this . $root . tlsInfoList [ this . monitor . id ] ;
2021-07-21 04:09:09 +00:00
}
2021-07-27 17:47:13 +00:00
2021-10-01 10:44:32 +00:00
return null ;
2021-07-21 04:09:09 +00:00
} ,
2021-07-26 14:53:07 +00:00
showCertInfoBox ( ) {
2021-10-01 10:44:32 +00:00
return this . tlsInfo != null && this . toggleCertInfoBox ;
2021-07-26 14:53:07 +00:00
} ,
2023-01-28 01:58:03 +00:00
group ( ) {
if ( ! this . monitor . pathName . includes ( "/" ) ) {
return "" ;
}
return this . monitor . pathName . substr ( 0 , this . monitor . pathName . lastIndexOf ( "/" ) ) ;
2023-05-31 19:19:46 +00:00
} ,
2023-04-01 15:54:27 +00:00
pushURL ( ) {
return this . $root . baseURL + "/api/push/" + this . monitor . pushToken + "?status=up&msg=OK&ping=" ;
} ,
2023-06-27 07:54:33 +00:00
screenshotURL ( ) {
return getResBaseURL ( ) + this . monitor . screenshot + "?time=" + this . cacheTime ;
}
2021-07-27 17:47:13 +00:00
} ,
2023-09-23 11:03:45 +00:00
watch : {
page ( to ) {
this . getImportantHeartbeatListPaged ( ) ;
} ,
monitor ( to ) {
this . getImportantHeartbeatListLength ( ) ;
2023-09-25 09:49:00 +00:00
} ,
"monitor.type" ( ) {
if ( this . monitor && this . monitor . type === "push" ) {
this . loadPushExample ( ) ;
}
} ,
"pushMonitor.currentExample" ( ) {
this . loadPushExample ( ) ;
} ,
2023-09-23 11:03:45 +00:00
} ,
2021-07-27 17:47:13 +00:00
mounted ( ) {
2023-09-23 11:03:45 +00:00
this . getImportantHeartbeatListLength ( ) ;
2021-07-27 17:47:13 +00:00
2023-09-23 11:03:45 +00:00
this . $root . emitter . on ( "newImportantHeartbeat" , this . onNewImportantHeartbeat ) ;
2023-09-25 09:49:00 +00:00
if ( this . monitor && this . monitor . type === "push" ) {
if ( this . lastHeartBeat . status === - 1 ) {
this . pushMonitor . showPushExamples = true ;
}
this . loadPushExample ( ) ;
}
2021-06-25 13:55:49 +00:00
} ,
2023-09-23 11:03:45 +00:00
beforeUnmount ( ) {
this . $root . emitter . off ( "newImportantHeartbeat" , this . onNewImportantHeartbeat ) ;
} ,
2021-06-25 13:55:49 +00:00
methods : {
2023-06-27 07:54:33 +00:00
getResBaseURL ,
2023-08-11 07:46:41 +00:00
/ * *
* Request a test notification be sent for this monitor
* @ returns { void }
* /
2021-06-30 13:04:58 +00:00
testNotification ( ) {
2021-10-01 10:44:32 +00:00
this . $root . getSocket ( ) . emit ( "testNotification" , this . monitor . id ) ;
2023-10-14 11:00:27 +00:00
this . $root . toastSuccess ( "Test notification is requested." ) ;
2021-06-30 13:04:58 +00:00
} ,
2023-08-11 07:46:41 +00:00
/ * *
* Show dialog to confirm pause
* @ returns { void }
* /
2021-06-25 13:55:49 +00:00
pauseDialog ( ) {
this . $refs . confirmPause . show ( ) ;
} ,
2021-06-30 13:04:58 +00:00
2023-08-11 07:46:41 +00:00
/ * *
* Resume this monitor
* @ returns { void }
* /
2021-06-25 13:55:49 +00:00
resumeMonitor ( ) {
this . $root . getSocket ( ) . emit ( "resumeMonitor" , this . monitor . id , ( res ) => {
2021-10-01 10:44:32 +00:00
this . $root . toastRes ( res ) ;
} ) ;
2021-06-25 13:55:49 +00:00
} ,
2021-06-30 13:04:58 +00:00
2023-08-11 07:46:41 +00:00
/ * *
* Request that this monitor is paused
* @ returns { void }
* /
2021-06-25 13:55:49 +00:00
pauseMonitor ( ) {
this . $root . getSocket ( ) . emit ( "pauseMonitor" , this . monitor . id , ( res ) => {
2021-10-01 10:44:32 +00:00
this . $root . toastRes ( res ) ;
} ) ;
2021-06-25 13:55:49 +00:00
} ,
2021-06-30 13:04:58 +00:00
2023-08-11 07:46:41 +00:00
/ * *
* Show dialog to confirm deletion
* @ returns { void }
* /
2021-06-25 13:55:49 +00:00
deleteDialog ( ) {
this . $refs . confirmDelete . show ( ) ;
} ,
2021-06-30 13:04:58 +00:00
2023-11-23 18:58:33 +00:00
/ * *
* Show Screenshot Dialog
* @ returns { void }
* /
showScreenshotDialog ( ) {
this . $refs . screenshotDialog . show ( ) ;
} ,
2023-08-11 07:46:41 +00:00
/ * *
* Show dialog to confirm clearing events
* @ returns { void }
* /
2021-08-29 16:47:01 +00:00
clearEventsDialog ( ) {
this . $refs . confirmClearEvents . show ( ) ;
} ,
2023-08-11 07:46:41 +00:00
/ * *
* Show dialog to confirm clearing heartbeats
* @ returns { void }
* /
2021-08-29 16:47:01 +00:00
clearHeartbeatsDialog ( ) {
this . $refs . confirmClearHeartbeats . show ( ) ;
} ,
2023-08-11 07:46:41 +00:00
/ * *
* Request that this monitor is deleted
* @ returns { void }
* /
2021-06-25 13:55:49 +00:00
deleteMonitor ( ) {
this . $root . deleteMonitor ( this . monitor . id , ( res ) => {
2023-10-14 11:00:27 +00:00
this . $root . toastRes ( res ) ;
2021-06-25 13:55:49 +00:00
if ( res . ok ) {
2021-10-01 10:44:32 +00:00
this . $router . push ( "/dashboard" ) ;
2021-06-25 13:55:49 +00:00
}
2021-10-01 10:44:32 +00:00
} ) ;
2021-07-27 17:47:13 +00:00
} ,
2021-06-30 13:04:58 +00:00
2023-08-11 07:46:41 +00:00
/ * *
* Request that this monitors events are cleared
* @ returns { void }
* /
2021-08-29 16:47:01 +00:00
clearEvents ( ) {
this . $root . clearEvents ( this . monitor . id , ( res ) => {
2023-09-23 11:03:45 +00:00
if ( res . ok ) {
this . getImportantHeartbeatListLength ( ) ;
} else {
2021-08-29 16:47:01 +00:00
toast . error ( res . msg ) ;
}
2021-10-01 10:44:32 +00:00
} ) ;
2021-08-29 16:47:01 +00:00
} ,
2023-08-11 07:46:41 +00:00
/ * *
* Request that this monitors heartbeats are cleared
* @ returns { void }
* /
2021-08-29 16:47:01 +00:00
clearHeartbeats ( ) {
this . $root . clearHeartbeats ( this . monitor . id , ( res ) => {
2021-09-04 18:03:40 +00:00
if ( ! res . ok ) {
2021-08-29 16:47:01 +00:00
toast . error ( res . msg ) ;
}
2021-10-01 10:44:32 +00:00
} ) ;
2021-08-29 16:47:01 +00:00
} ,
2021-09-19 13:15:12 +00:00
2022-06-02 12:46:44 +00:00
/ * *
* Return the correct title for the ping stat
2023-08-11 07:46:41 +00:00
* @ param { boolean } average Is the statistic an average ?
* @ returns { string } Title formatted dependant on monitor type
2022-06-02 12:46:44 +00:00
* /
2021-09-19 13:15:12 +00:00
pingTitle ( average = false ) {
2021-10-01 10:44:32 +00:00
let translationPrefix = "" ;
2021-09-19 13:15:12 +00:00
if ( average ) {
2021-10-01 10:44:32 +00:00
translationPrefix = "Avg. " ;
2021-09-19 13:15:12 +00:00
}
2023-07-13 15:37:26 +00:00
if ( this . monitor . type === "http" || this . monitor . type === "keyword" || this . monitor . type === "json-query" ) {
2021-09-19 13:15:12 +00:00
return this . $t ( translationPrefix + "Response" ) ;
}
return this . $t ( translationPrefix + "Ping" ) ;
} ,
2023-01-28 13:53:40 +00:00
/ * *
* Get URL of monitor
* @ param { number } id ID of monitor
* @ returns { string } Relative URL of monitor
* /
monitorURL ( id ) {
return getMonitorRelativeURL ( id ) ;
} ,
2023-05-31 19:19:46 +00:00
2023-08-11 07:46:41 +00:00
/ * *
* Filter and hide password in URL for display
* @ param { string } urlString URL to censor
* @ returns { string } Censored URL
* /
2023-04-18 19:20:35 +00:00
filterPassword ( urlString ) {
try {
let parsedUrl = new URL ( urlString ) ;
if ( parsedUrl . password !== "" ) {
parsedUrl . password = "******" ;
}
return parsedUrl . toString ( ) ;
} catch ( e ) {
// Handle SQL Server
return urlString . replaceAll ( /Password=(.+);/ig , "Password=******;" ) ;
}
2023-09-23 11:03:45 +00:00
} ,
/ * *
* Retrieves the length of the important heartbeat list for this monitor .
* @ returns { void }
* /
getImportantHeartbeatListLength ( ) {
if ( this . monitor ) {
this . $root . getSocket ( ) . emit ( "monitorImportantHeartbeatListCount" , this . monitor . id , ( res ) => {
if ( res . ok ) {
this . importantHeartBeatListLength = res . count ;
this . getImportantHeartbeatListPaged ( ) ;
}
} ) ;
}
} ,
/ * *
* Retrieves the important heartbeat list for the current page .
* @ returns { void }
* /
getImportantHeartbeatListPaged ( ) {
if ( this . monitor ) {
const offset = ( this . page - 1 ) * this . perPage ;
this . $root . getSocket ( ) . emit ( "monitorImportantHeartbeatListPaged" , this . monitor . id , offset , this . perPage , ( res ) => {
if ( res . ok ) {
this . displayedRecords = res . data ;
}
} ) ;
}
} ,
/ * *
* Updates the displayed records when a new important heartbeat arrives .
* @ param { object } heartbeat - The heartbeat object received .
* @ returns { void }
* /
onNewImportantHeartbeat ( heartbeat ) {
if ( heartbeat . monitorID === this . monitor ? . id ) {
if ( this . page === 1 ) {
this . displayedRecords . unshift ( heartbeat ) ;
if ( this . displayedRecords . length > this . perPage ) {
this . displayedRecords . pop ( ) ;
}
this . importantHeartBeatListLength += 1 ;
}
}
} ,
2023-09-25 09:49:00 +00:00
/ * *
* Highlight the example code
* @ param { string } code Code
* @ returns { string } Highlighted code
* /
pushExampleHighlighter ( code ) {
return highlight ( code , languages . js ) ;
} ,
loadPushExample ( ) {
this . pushMonitor . code = "" ;
this . $root . getSocket ( ) . emit ( "getPushExample" , this . pushMonitor . currentExample , ( res ) => {
let code = res . code
. replace ( "60" , this . monitor . interval )
. replace ( "https://example.com/api/push/key?status=up&msg=OK&ping=" , this . pushURL ) ;
this . pushMonitor . code = code ;
} ) ;
}
2021-07-27 17:47:13 +00:00
} ,
2021-10-01 10:44:32 +00:00
} ;
2021-06-25 13:55:49 +00:00
< / script >
< style lang = "scss" scoped >
@ import "../assets/vars.scss" ;
2021-08-18 04:22:45 +00:00
@ media ( max - width : 767 px ) {
2021-08-11 09:16:53 +00:00
. badge {
margin - top : 14 px ;
}
}
2021-08-18 04:22:45 +00:00
@ media ( max - width : 550 px ) {
2021-08-10 16:29:47 +00:00
. functions {
text - align : center ;
}
2021-08-18 04:22:45 +00:00
. ping - chart - wrapper {
padding : 10 px ! important ;
}
2021-08-29 16:47:01 +00:00
. dropdown - clear - data {
margin - bottom : 10 px ;
}
2021-08-10 16:29:47 +00:00
}
2021-08-18 04:22:45 +00:00
@ media ( max - width : 400 px ) {
2021-08-10 16:29:47 +00:00
. btn {
display : inline - flex ;
flex - direction : column ;
align - items : center ;
padding - top : 10 px ;
2023-04-11 13:16:45 +00:00
font - size : 0.9 em ;
2021-08-10 16:29:47 +00:00
}
a . btn {
padding - left : 25 px ;
padding - right : 25 px ;
}
2021-08-29 16:47:01 +00:00
. dropdown - clear - data {
button {
display : block ;
padding - top : 4 px ;
}
}
2021-08-10 16:29:47 +00:00
}
2021-06-27 08:10:55 +00:00
. url {
2021-06-25 13:55:49 +00:00
color : $primary ;
margin - bottom : 20 px ;
2021-06-27 08:10:55 +00:00
font - weight : bold ;
a {
color : $primary ;
}
2021-06-25 13:55:49 +00:00
}
. shadow - box {
padding : 20 px ;
margin - top : 25 px ;
}
2021-06-27 08:10:55 +00:00
. word {
2024-01-28 10:15:29 +00:00
color : $secondary - text ;
2021-06-27 08:10:55 +00:00
font - size : 14 px ;
}
2021-06-30 13:04:58 +00:00
table {
font - size : 14 px ;
tr {
transition : all ease - in - out 0.2 ms ;
}
}
. stats p {
font - size : 13 px ;
2024-01-28 10:15:29 +00:00
color : $secondary - text ;
2021-06-30 13:04:58 +00:00
}
2021-07-26 14:53:07 +00:00
. stats {
padding : 10 px ;
. col {
margin : 20 px 0 ;
}
}
2021-08-08 05:47:29 +00:00
2023-04-11 13:16:45 +00:00
@ media ( max - width : 550 px ) {
. stats {
. col {
margin : 10 px 0 ! important ;
}
2023-04-11 13:27:03 +00:00
2023-04-11 13:16:45 +00:00
h4 {
font - size : 1.1 rem ;
}
}
}
2021-08-08 05:47:29 +00:00
. keyword {
color : black ;
}
2021-08-29 16:47:01 +00:00
. dropdown - clear - data {
float : right ;
2023-01-05 19:24:29 +00:00
ul {
width : 100 % ;
min - width : unset ;
padding - left : 0 ;
}
2021-08-29 16:47:01 +00:00
}
2021-08-24 15:38:25 +00:00
. dark {
2021-08-08 05:47:29 +00:00
. keyword {
color : $dark - font - color ;
}
2021-08-29 16:47:01 +00:00
2023-04-06 00:10:21 +00:00
. keyword - inverted {
color : $dark - font - color ;
}
2021-08-29 16:47:01 +00:00
. dropdown - clear - data {
ul {
background - color : $dark - bg ;
border - color : $dark - bg2 ;
border - width : 2 px ;
2021-09-04 18:03:40 +00:00
li button {
2021-08-29 16:47:01 +00:00
color : $dark - font - color ;
}
li button : hover {
background - color : $dark - bg2 ;
}
}
}
2021-08-08 05:47:29 +00:00
}
2021-08-29 18:22:49 +00:00
2021-08-26 10:55:19 +00:00
. tags {
margin - bottom : 0.5 rem ;
}
. tags > div : first - child {
margin - left : 0 ! important ;
}
2024-01-28 10:15:29 +00:00
. monitor - id {
display : inline - flex ;
font - size : 0.7 em ;
margin - left : 0.3 em ;
color : $secondary - text ;
flex - direction : row ;
flex - wrap : nowrap ;
. hash {
user - select : none ;
}
. dark & {
opacity : 0.7 ;
}
}
2021-06-25 13:55:49 +00:00
< / style >