Skip to content

Commit f6e53d3

Browse files
author
Diane LAKESTANI
committed
fix(outages): set default outage to type "none"
1 parent 2b57a89 commit f6e53d3

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

dev/postman.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1823,7 +1823,7 @@
18231823
],
18241824
"body": {
18251825
"mode": "raw",
1826-
"raw": "{\n \"name\": \"Updated New Service\",\n \"domain\": \"https://google.com\",\n \"expected\": \"\",\n \"expected_status\": 200,\n \"check_interval\": 60,\n \"type\": \"http\",\n \"method\": \"GET\",\n \"post_data\": \"\",\n \"port\": 0,\n \"timeout\": 10,\n \"order_id\": 0,\n \"is_outage_enabled\": false,\n \"outage_type\": \"\"\n}"
1826+
"raw": "{\n \"name\": \"Updated New Service\",\n \"domain\": \"https://google.com\",\n \"expected\": \"\",\n \"expected_status\": 200,\n \"check_interval\": 60,\n \"type\": \"http\",\n \"method\": \"GET\",\n \"post_data\": \"\",\n \"port\": 0,\n \"timeout\": 10,\n \"order_id\": 0,\n \"is_outage_enabled\": false,\n \"outage_type\": \"none\"\n}"
18271827
},
18281828
"url": {
18291829
"raw": "{{endpoint}}/api/services/{{service_id}}",

frontend/src/mixin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ export default Vue.mixin({
258258
return addSeconds(date, amount)
259259
},
260260
serviceBadgeClass(service) {
261-
if (service.is_outage_enabled) {
261+
if (service.outage_type != "none") {
262262
if (service.outage_type === 'critical') {
263263
return 'bg-danger';
264264
} else if (service.outage_type === 'minor' || service.outage_type === 'major') {
@@ -269,7 +269,7 @@ export default Vue.mixin({
269269
return service.online ? 'bg-success' : 'bg-danger';
270270
},
271271
textClass(service) {
272-
if (service.is_outage_enabled) {
272+
if (service.outage_type != "none") {
273273
if (service.outage_type === 'critical') {
274274
return 'text-danger';
275275
} else if (service.outage_type === 'minor' || service.outage_type === 'major') {

handlers/services.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,15 @@ func apiServiceOutagePatchHandler(w http.ResponseWriter, r *http.Request) {
131131
return
132132
}
133133

134-
service.IsOutageEnabled = req.IsOutageEnabled
135-
service.OutageType = req.OutageType
136-
137134
issueDefault := "Service was triggered to be outaged"
138135

139136
if req.IsOutageEnabled {
140-
services.RecordFailure(service, issueDefault, "trigger", service.OutageType)
141-
} else {
142-
services.RecordSuccess(service)
137+
services.RecordFailure(service, issueDefault, "trigger", req.OutageType)
143138
}
144139

140+
service.IsOutageEnabled = req.IsOutageEnabled
141+
service.OutageType = req.OutageType
142+
145143
if err := service.Update(); err != nil {
146144
sendErrorJson(err, w, r)
147145
return

types/services/struct.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ type Service struct {
6262
Incidents []*incidents.Incident `gorm:"foreignkey:service;association_foreignkey:id" json:"incidents,omitempty" yaml:"incidents"`
6363
Checkins []*checkins.Checkin `gorm:"foreignkey:service;association_foreignkey:id" json:"checkins,omitempty" yaml:"-" scope:"user,admin"`
6464
Failures []*failures.Failure `gorm:"-" json:"failures,omitempty" yaml:"-" scope:"user,admin"`
65-
OutageType string `gorm:"column:outage_type;default:''" json:"outage_type,omitempty" yaml:"-"`
65+
OutageType string `gorm:"column:outage_type;default:'none'" json:"outage_type" yaml:"-"`
6666
IsOutageEnabled bool `gorm:"column:is_outage_enabled;default:false" json:"is_outage_enabled" yaml:"-"`
6767

6868
notifyAfterCount int64 `gorm:"-" json:"-" yaml:"-"`

0 commit comments

Comments
 (0)