From 3b7df28c470a67e745508c3565be58dec2f1d9af Mon Sep 17 00:00:00 2001 From: hunterlong Date: Tue, 14 Apr 2020 09:08:50 -0700 Subject: [PATCH] UI, and more issue fixes --- .github/FUNDING.yml | 1 + CHANGELOG.md | 6 + Makefile | 4 +- database/grouping.go | 42 +++ frontend/public/base.gohtml | 16 +- frontend/src/API.js | 4 +- .../Dashboard}/Checkins.vue | 2 +- .../Dashboard/DashboardServices.vue | 8 +- .../Dashboard}/Failures.vue | 24 +- .../Dashboard}/Incidents.vue | 2 +- .../src/components/Index/IncidentsBlock.vue | 4 +- .../src/components/Index/UpdatesBlock.vue | 8 +- .../src/components/Service/AdvancedChart.vue | 276 +++++++++++++++ .../src/components/Service/ServiceBlock.vue | 14 +- .../src/components/Service/ServiceInfo.vue | 17 +- frontend/src/mixin.js | 10 + frontend/src/pages/Service.vue | 329 +++++++++--------- frontend/src/routes.js | 6 +- frontend/src/store.js | 5 + handlers/api.go | 3 - handlers/cache.go | 2 - handlers/services.go | 138 ++------ types/core/struct.go | 1 - types/services/methods.go | 143 ++++++++ version.txt | 2 +- 25 files changed, 739 insertions(+), 328 deletions(-) rename frontend/src/{pages => components/Dashboard}/Checkins.vue (99%) rename frontend/src/{pages => components/Dashboard}/Failures.vue (80%) rename frontend/src/{pages => components/Dashboard}/Incidents.vue (99%) create mode 100644 frontend/src/components/Service/AdvancedChart.vue diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 062927ab..11a07e52 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,2 +1,3 @@ github: hunterlong +patreon: statping custom: ['https://www.buymeacoffee.com/hunterlong'] diff --git a/CHANGELOG.md b/CHANGELOG.md index 0147aadb..dbb47bb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 0.90.26 (04-13-2020) +- Fixed Delete Failures button/function +- Removed timezone field from Settings (core) +- Modified CDN asset URL +- Fixed single Service view, more complex charts + # 0.90.25 - Added string response on OnTest for Notifiers - Modified UI to show user the response for a Notifier. diff --git a/Makefile b/Makefile index d83fad6b..cc09f128 100644 --- a/Makefile +++ b/Makefile @@ -27,8 +27,8 @@ lite: clean reup: down clean compose-build-full up -test: clean - go test -v -p=4 -ldflags="-X main.VERSION=testing" -coverprofile=coverage.out ./... +test: clean compile + go test -v -p=1 -ldflags="-X main.VERSION=testing" -coverprofile=coverage.out ./... # build all arch's and release Statping release: test-deps diff --git a/database/grouping.go b/database/grouping.go index f81b6d5b..6c76b821 100644 --- a/database/grouping.go +++ b/database/grouping.go @@ -146,6 +146,45 @@ type isObject interface { Db() Database } +func ParseRequest(r *http.Request) (*GroupQuery, error) { + fields := parseGet(r) + grouping := fields.Get("group") + startField := utils.ToInt(fields.Get("start")) + endField := utils.ToInt(fields.Get("end")) + limit := utils.ToInt(fields.Get("limit")) + offset := utils.ToInt(fields.Get("offset")) + fill, _ := strconv.ParseBool(fields.Get("fill")) + orderBy := fields.Get("order") + if limit == 0 { + limit = 10000 + } + + if grouping == "" { + grouping = "1h" + } + groupDur, err := time.ParseDuration(grouping) + if err != nil { + log.Errorln(err) + groupDur = 1 * time.Hour + } + + query := &GroupQuery{ + Start: time.Unix(startField, 0).UTC(), + End: time.Unix(endField, 0).UTC(), + Group: groupDur, + Order: orderBy, + Limit: int(limit), + Offset: int(offset), + FillEmpty: fill, + } + + if query.Start.After(query.End) { + return nil, errors.New("start time is after ending time") + } + + return query, nil +} + func ParseQueries(r *http.Request, o isObject) (*GroupQuery, error) { fields := parseGet(r) grouping := fields.Get("group") @@ -169,6 +208,9 @@ func ParseQueries(r *http.Request, o isObject) (*GroupQuery, error) { log.Errorln(err) groupDur = 1 * time.Hour } + if endField == 0 { + endField = utils.Now().Unix() + } query := &GroupQuery{ Start: time.Unix(startField, 0).UTC(), diff --git a/frontend/public/base.gohtml b/frontend/public/base.gohtml index 525d21e2..95564ce7 100644 --- a/frontend/public/base.gohtml +++ b/frontend/public/base.gohtml @@ -10,9 +10,9 @@ {{if USE_CDN}} - - - + + + {{else}} {{if USING_ASSETS}} @@ -33,11 +33,11 @@
{{if USE_CDN}} - - - - - + + + + + {{else}} <% _.each(htmlWebpackPlugin.tags.bodyTags, function(bodyTag) { %> <%= bodyTag %> <% }) %> diff --git a/frontend/src/API.js b/frontend/src/API.js index 8d31d009..5b431e0a 100644 --- a/frontend/src/API.js +++ b/frontend/src/API.js @@ -56,8 +56,8 @@ class Api { return axios.get('api/services/' + id + '/failure_data?start=' + start + '&end=' + end + '&group=' + group + '&fill=' + fill).then(response => (response.data)) } - async service_uptime(id) { - return axios.get('api/services/' + id + '/uptime_data').then(response => (response.data)) + async service_uptime(id, start, end) { + return axios.get('api/services/' + id + '/uptime_data?start=' + start + '&end=' + end).then(response => (response.data)) } async service_heatmap(id, start, end, group) { diff --git a/frontend/src/pages/Checkins.vue b/frontend/src/components/Dashboard/Checkins.vue similarity index 99% rename from frontend/src/pages/Checkins.vue rename to frontend/src/components/Dashboard/Checkins.vue index f39c043d..310b322d 100644 --- a/frontend/src/pages/Checkins.vue +++ b/frontend/src/components/Dashboard/Checkins.vue @@ -41,7 +41,7 @@ + + + diff --git a/frontend/src/components/Service/ServiceBlock.vue b/frontend/src/components/Service/ServiceBlock.vue index 9a91c820..18a60557 100644 --- a/frontend/src/components/Service/ServiceBlock.vue +++ b/frontend/src/components/Service/ServiceBlock.vue @@ -49,12 +49,9 @@
- - -
- -
- +
@@ -133,6 +130,10 @@ export default { this.track_service = this.in_service }, methods: { + async setService() { + await this.$store.commit('setService', this.service) + this.$router.push('/service/'+this.service.id, {props: {in_service: this.service}}) + }, async showMoreStats() { this.expanded = !this.expanded; @@ -174,7 +175,6 @@ export default { if (!this.timer_func) { this.timer_func = setInterval(async () => { this.track_service = await Api.service(this.service.id) - window.console.log(this.track_service.name) }, this.track_service.check_interval * 1000) } } diff --git a/frontend/src/components/Service/ServiceInfo.vue b/frontend/src/components/Service/ServiceInfo.vue index 1c03f7fc..88e5a81f 100644 --- a/frontend/src/components/Service/ServiceInfo.vue +++ b/frontend/src/components/Service/ServiceInfo.vue @@ -67,23 +67,23 @@