File tree Expand file tree Collapse file tree 6 files changed +68
-1
lines changed Expand file tree Collapse file tree 6 files changed +68
-1
lines changed Original file line number Diff line number Diff line change
1
+ exports . up = function ( knex ) {
2
+ return knex . schema
3
+ . alterTable ( "monitor" , function ( table ) {
4
+ table . string ( "manual_status" ) . defaultTo ( null ) ;
5
+ } ) ;
6
+ } ;
7
+
8
+ exports . down = function ( knex ) {
9
+ return knex . schema . alterTable ( "monitor" , function ( table ) {
10
+ table . dropColumn ( "manual_status" ) ;
11
+ } ) ;
12
+ } ;
Original file line number Diff line number Diff line change
1
+ const { MonitorType } = require ( "./monitor-type" ) ;
2
+ const { UP , DOWN , PENDING } = require ( "../../src/util" ) ;
3
+
4
+ class ManualMonitorType extends MonitorType {
5
+ name = "Manual" ;
6
+ type = "manual" ;
7
+ description = "A monitor that allows manual control of the status" ;
8
+ supportsConditions = false ;
9
+ conditionVariables = [ ] ;
10
+
11
+ /**
12
+ * @inheritdoc
13
+ */
14
+ async check ( monitor , heartbeat ) {
15
+ if ( monitor . manual_status !== null ) {
16
+ heartbeat . status = monitor . manual_status ;
17
+ switch ( monitor . manual_status ) {
18
+ case UP :
19
+ heartbeat . msg = "Up" ;
20
+ break ;
21
+ case DOWN :
22
+ heartbeat . msg = "Down" ;
23
+ break ;
24
+ default :
25
+ heartbeat . msg = "Pending" ;
26
+ }
27
+ } else {
28
+ heartbeat . status = PENDING ;
29
+ heartbeat . msg = "Manual monitoring - No status set" ;
30
+ }
31
+ }
32
+ }
33
+
34
+ module . exports = {
35
+ ManualMonitorType
36
+ } ;
Original file line number Diff line number Diff line change @@ -876,6 +876,7 @@ let needSetup = false;
876
876
bean . rabbitmqUsername = monitor . rabbitmqUsername ;
877
877
bean . rabbitmqPassword = monitor . rabbitmqPassword ;
878
878
bean . conditions = JSON . stringify ( monitor . conditions ) ;
879
+ bean . manual_status = monitor . manual_status ;
879
880
880
881
// ping advanced options
881
882
bean . ping_numeric = monitor . ping_numeric ;
Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ class UptimeKumaServer {
118
118
UptimeKumaServer . monitorTypeList [ "snmp" ] = new SNMPMonitorType ( ) ;
119
119
UptimeKumaServer . monitorTypeList [ "mongodb" ] = new MongodbMonitorType ( ) ;
120
120
UptimeKumaServer . monitorTypeList [ "rabbitmq" ] = new RabbitMqMonitorType ( ) ;
121
+ UptimeKumaServer . monitorTypeList [ "manual" ] = new ManualMonitorType ( ) ;
121
122
122
123
// Allow all CORS origins (polling) in development
123
124
let cors = undefined ;
@@ -558,4 +559,5 @@ const { GroupMonitorType } = require("./monitor-types/group");
558
559
const { SNMPMonitorType } = require ( "./monitor-types/snmp" ) ;
559
560
const { MongodbMonitorType } = require ( "./monitor-types/mongodb" ) ;
560
561
const { RabbitMqMonitorType } = require ( "./monitor-types/rabbitmq" ) ;
562
+ const { ManualMonitorType } = require ( "./monitor-types/manual" ) ;
561
563
const Monitor = require ( "./model/monitor" ) ;
Original file line number Diff line number Diff line change 1122
1122
"Add Another Tag" : " Add Another Tag" ,
1123
1123
"Staged Tags for Batch Add" : " Staged Tags for Batch Add" ,
1124
1124
"Clear Form" : " Clear Form" ,
1125
- "pause" : " Pause"
1125
+ "pause" : " Pause" ,
1126
+ "Manual" : " Manual"
1126
1127
}
Original file line number Diff line number Diff line change 55
55
<option value =" push" >
56
56
Push
57
57
</option >
58
+ <option value =" manual" >
59
+ {{ $t("Manual") }}
60
+ </option >
58
61
</optgroup >
59
62
60
63
<optgroup :label =" $t('Specific Monitor Type')" >
115
118
<input id =" name" v-model =" monitor.name" type =" text" class =" form-control" data-testid =" friendly-name-input" :placeholder =" defaultFriendlyName" >
116
119
</div >
117
120
121
+ <!-- Manual Status switcher -->
122
+ <div v-if =" monitor.type === 'manual'" class =" mb-3" >
123
+ <div class =" btn-group w-100 mb-3" >
124
+ <button class =" btn btn-success" @click =" monitor.manual_status = 1" >
125
+ <i class =" fas fa-check" ></i > {{ $t("Up") }}
126
+ </button >
127
+ <button class =" btn btn-danger" @click =" monitor.manual_status = 0" >
128
+ <i class =" fas fa-times" ></i > {{ $t("Down") }}
129
+ </button >
130
+ </div >
131
+ </div >
132
+
118
133
<!-- URL -->
119
134
<div v-if =" monitor.type === 'http' || monitor.type === 'keyword' || monitor.type === 'json-query' || monitor.type === 'real-browser' " class =" my-3" >
120
135
<label for =" url" class =" form-label" >{{ $t("URL") }}</label >
You can’t perform that action at this time.
0 commit comments