From 37d543d7ab62c110bf949074be2abe451e0e6007 Mon Sep 17 00:00:00 2001 From: Hunter Long Date: Wed, 22 Jan 2020 22:23:41 -0800 Subject: [PATCH] updates --- core/failures.go | 4 +- frontend/package.json | 2 + frontend/src/components/API.js | 20 +- .../components/Dashboard/DashboardIndex.vue | 2 +- .../Dashboard/DashboardServices.vue | 86 ++- .../components/Dashboard/DashboardUsers.vue | 29 +- .../src/components/Dashboard/EditService.vue | 49 ++ .../src/components/Dashboard/ServiceForm.vue | 185 ------- frontend/src/components/Dashboard/TopNav.vue | 16 +- frontend/src/components/Footer.vue | 7 +- .../src/components/Index/ServiceChart.vue | 22 - .../src/components/Service/ServiceBlock.vue | 7 +- .../src/components/Service/ServiceChart.vue | 119 +++- frontend/src/forms/Checkin.vue | 61 ++ frontend/src/forms/CoreSettings.vue | 4 +- frontend/src/forms/Login.vue | 57 ++ frontend/src/forms/Notifier.vue | 56 +- frontend/src/forms/Service.vue | 129 +++-- frontend/src/forms/ToggleSwitch.vue | 29 +- frontend/src/forms/User.vue | 15 +- frontend/src/main.js | 59 +- frontend/src/pages/Dashboard.vue | 91 +-- frontend/src/pages/Login.vue | 40 +- frontend/src/pages/Service.vue | 523 ++++++------------ frontend/src/pages/Settings.vue | 15 +- frontend/src/store.js | 4 + frontend/yarn.lock | 145 +---- 27 files changed, 766 insertions(+), 1010 deletions(-) create mode 100644 frontend/src/components/Dashboard/EditService.vue delete mode 100644 frontend/src/components/Dashboard/ServiceForm.vue delete mode 100644 frontend/src/components/Index/ServiceChart.vue create mode 100644 frontend/src/forms/Checkin.vue create mode 100644 frontend/src/forms/Login.vue diff --git a/core/failures.go b/core/failures.go index 65d7efe2..d589bf42 100644 --- a/core/failures.go +++ b/core/failures.go @@ -50,8 +50,8 @@ func (s *Service) CreateFailure(f *types.Failure) (int64, error) { } // AllFailures will return all failures attached to a service -func (s *Service) AllFailures() []*Failure { - var fails []*Failure +func (s *Service) AllFailures() []*types.Failure { + var fails []*types.Failure col := failuresDB().Where("service = ?", s.Id).Not("method = 'checkin'").Order("id desc") err := col.Find(&fails) if err.Error != nil { diff --git a/frontend/package.json b/frontend/package.json index 1d3dd61e..6dee045f 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -18,9 +18,11 @@ "apexcharts": "^3.15.0", "axios": "^0.19.1", "core-js": "^3.4.4", + "moment": "^2.24.0", "querystring": "^0.2.0", "vue": "^2.6.10", "vue-apexcharts": "^1.5.2", + "vue-moment": "^4.1.0", "vue-router": "~3.0", "vuedraggable": "^2.23.2", "vuex": "^3.1.2" diff --git a/frontend/src/components/API.js b/frontend/src/components/API.js index d7ea415a..7cd77b26 100644 --- a/frontend/src/components/API.js +++ b/frontend/src/components/API.js @@ -28,10 +28,18 @@ class Api { return axios.get('/api/services/'+id+'/data?start=' + start + '&end=' + end + '&group=' + group).then(response => (response.data)) } + async service_failures (id, start, end) { + return axios.get('/api/services/'+id+'/failures?start=' + start + '&end=' + end).then(response => (response.data)) + } + async service_delete (id) { return axios.delete('/api/services/'+id).then(response => (response.data)) } + async services_reorder (data) { + return axios.post('/api/services/reorder', data).then(response => (response.data)) + } + async groups () { return axios.get('/api/groups').then(response => (response.data)) } @@ -48,8 +56,8 @@ class Api { return axios.get('/api/users').then(response => (response.data)) } - async user_create (id) { - return axios.post('/api/users').then(response => (response.data)) + async user_create (data) { + return axios.post('/api/users', data).then(response => (response.data)) } async user_delete (id) { @@ -72,6 +80,14 @@ class Api { return axios.get('/api/notifiers').then(response => (response.data)) } + async notifier_save (data) { + return axios.post('/api/notifier/'+data.method, data).then(response => (response.data)) + } + + async notifier_test (data) { + return axios.post('/api/notifier/'+data.method+'/test', data).then(response => (response.data)) + } + async renewApiKeys () { return axios.get('/api/renew').then(response => (response.data)) } diff --git a/frontend/src/components/Dashboard/DashboardIndex.vue b/frontend/src/components/Dashboard/DashboardIndex.vue index 0e557d64..e5998c26 100644 --- a/frontend/src/components/Dashboard/DashboardIndex.vue +++ b/frontend/src/components/Dashboard/DashboardIndex.vue @@ -16,7 +16,7 @@ -
+
diff --git a/frontend/src/components/Dashboard/DashboardServices.vue b/frontend/src/components/Dashboard/DashboardServices.vue index 3b1a1ab2..c5d486a4 100644 --- a/frontend/src/components/Dashboard/DashboardServices.vue +++ b/frontend/src/components/Dashboard/DashboardServices.vue @@ -19,7 +19,9 @@

Services - Create + + Create +

@@ -31,34 +33,37 @@ - - - + + - - +
- {{service.name}} + + + {{service.name}} -
ONLINE
-
OFFLINE
+ {{service.online ? "ONLINE" : "OFFLINE"}} +
-
PUBLIC
-
PRIVATE
+ + {{service.public ? "PUBLIC" : "PRIVATE"}} +
{{serviceGroup(service)}}
- View + + View +
@@ -75,8 +80,8 @@ - + {{group.name}} {{$store.getters.servicesInGroup(group.id).length}} @@ -94,7 +99,7 @@ - +

Create Group

@@ -110,27 +115,64 @@ + + + diff --git a/frontend/src/components/Dashboard/ServiceForm.vue b/frontend/src/components/Dashboard/ServiceForm.vue deleted file mode 100644 index 88488220..00000000 --- a/frontend/src/components/Dashboard/ServiceForm.vue +++ /dev/null @@ -1,185 +0,0 @@ - - - - - - diff --git a/frontend/src/components/Dashboard/TopNav.vue b/frontend/src/components/Dashboard/TopNav.vue index 0db70d60..7cfc01f9 100644 --- a/frontend/src/components/Dashboard/TopNav.vue +++ b/frontend/src/components/Dashboard/TopNav.vue @@ -8,27 +8,27 @@
- +
@@ -50,7 +50,10 @@ name: 'ServiceBlock', components: {ServiceChart}, props: { - service: Object + service: { + type: Object, + required: true + }, } } diff --git a/frontend/src/components/Service/ServiceChart.vue b/frontend/src/components/Service/ServiceChart.vue index 104372a1..ccf78469 100644 --- a/frontend/src/components/Service/ServiceChart.vue +++ b/frontend/src/components/Service/ServiceChart.vue @@ -1,10 +1,34 @@ diff --git a/frontend/src/forms/Checkin.vue b/frontend/src/forms/Checkin.vue new file mode 100644 index 00000000..c776a176 --- /dev/null +++ b/frontend/src/forms/Checkin.vue @@ -0,0 +1,61 @@ + + + + + + diff --git a/frontend/src/forms/CoreSettings.vue b/frontend/src/forms/CoreSettings.vue index b0c2006a..56a2fa62 100644 --- a/frontend/src/forms/CoreSettings.vue +++ b/frontend/src/forms/CoreSettings.vue @@ -69,7 +69,7 @@
- +
@@ -84,7 +84,7 @@
API Secret is used for read, create, update and delete routes - You can Regenerate API Keys if you need to. + You can Regenerate API Keys if you need to.
diff --git a/frontend/src/forms/Login.vue b/frontend/src/forms/Login.vue new file mode 100644 index 00000000..bcb9988e --- /dev/null +++ b/frontend/src/forms/Login.vue @@ -0,0 +1,57 @@ + + + + + + diff --git a/frontend/src/forms/Notifier.vue b/frontend/src/forms/Notifier.vue index 21aa57ef..8c6bc268 100644 --- a/frontend/src/forms/Notifier.vue +++ b/frontend/src/forms/Notifier.vue @@ -1,15 +1,13 @@ @@ -73,21 +71,41 @@ }, data () { return { - notifier: { - - } + error: null } }, mounted() { }, methods: { - async saveGroup(e) { + async saveNotifier(e) { e.preventDefault(); - const data = {name: this.group.name, public: this.group.public} - await Api.group_create(data) - const groups = await Api.groups() - this.$store.commit('setGroups', groups) + let form = {} + this.notifier.form.forEach((f) => { + form[f.field] = this.notifier[f.field] + }); + form.enabled = this.notifier.enabled + form.limits = parseInt(this.notifier.limits) + form.method = this.notifier.method + await Api.notifier_save(form) + const notifiers = await Api.notifiers() + this.$store.commit('setNotifiers', notifiers) + }, + async testNotifier(e) { + e.preventDefault(); + let form = {} + this.notifier.form.forEach((f) => { + form[f.field] = this.notifier[f.field] + }); + form.enabled = this.notifier.enabled + form.limits = parseInt(this.notifier.limits) + form.method = this.notifier.method + const tested = await Api.notifier_test(form) + if (tested === "ok") { + alert('This notifier seems to be working!') + } else { + this.error = tested + } }, } } diff --git a/frontend/src/forms/Service.vue b/frontend/src/forms/Service.vue index 36c66ff9..34b760f5 100644 --- a/frontend/src/forms/Service.vue +++ b/frontend/src/forms/Service.vue @@ -1,17 +1,17 @@ diff --git a/frontend/src/forms/ToggleSwitch.vue b/frontend/src/forms/ToggleSwitch.vue index c95dc0ab..8d6fdabd 100644 --- a/frontend/src/forms/ToggleSwitch.vue +++ b/frontend/src/forms/ToggleSwitch.vue @@ -1,17 +1,12 @@ diff --git a/frontend/src/pages/Login.vue b/frontend/src/pages/Login.vue index 9da5f726..1334dbd4 100644 --- a/frontend/src/pages/Login.vue +++ b/frontend/src/pages/Login.vue @@ -4,54 +4,24 @@
-
-
- -
- -
-
-
- -
- -
-
-
-
- -
-
-
+
diff --git a/frontend/src/pages/Service.vue b/frontend/src/pages/Service.vue index 42385fee..a9bcc43a 100644 --- a/frontend/src/pages/Service.vue +++ b/frontend/src/pages/Service.vue @@ -1,21 +1,21 @@