diff --git a/frontend/src/layouts/modals/Stats.vue b/frontend/src/layouts/modals/Stats.vue index de171cd..6a4a7e4 100644 --- a/frontend/src/layouts/modals/Stats.vue +++ b/frontend/src/layouts/modals/Stats.vue @@ -3,8 +3,8 @@ - - {{ $t('stats.graphTitle') + " - " + $t('objects.' + resource) + " : " + tag }} + + {{ $t('stats.graphTitle') }} @@ -12,7 +12,13 @@ - +
+ {{ $t('objects.' + resource) + " : " + tag }} +
+ + + + @@ -60,13 +66,29 @@ export default { loaded: false, alert: false, intervalId: 0, + limit: 1, + periods: [ + { value: 1, title: i18n.global.n(1) + i18n.global.t('date.h')}, + { value: 6, title: i18n.global.n(6) + i18n.global.t('date.h')}, + { value: 12, title: i18n.global.n(12) + i18n.global.t('date.h')}, + { value: 24, title: i18n.global.n(1) + i18n.global.t('date.d')}, + { value: 48, title: i18n.global.n(2) + i18n.global.t('date.d')}, + { value: 240, title: i18n.global.n(10) + i18n.global.t('date.d')}, + { value: 480, title: i18n.global.n(20) + i18n.global.t('date.d')}, + { value: 720, title: i18n.global.n(30) + i18n.global.t('date.d')}, + { value: 1440, title: i18n.global.n(60) + i18n.global.t('date.d')}, + { value: 2160, title: i18n.global.n(90) + i18n.global.t('date.d')}, + ], options: { responsive: true, - maintainAspectRatio: true, + maintainAspectRatio: false, interaction: { intersect: false, mode: 'index', }, + elements: { + point: { pointStyle: 'crossRot' } + }, plugins: { tooltip: { callbacks: { @@ -99,13 +121,13 @@ export default { } }, methods: { - async loadData(limit: number) { + async loadData() { this.loading = true - const data = await HttpUtils.get('api/stats', { resource: this.resource, tag: this.tag, limit: limit }) + const data = await HttpUtils.get('api/stats', { resource: this.resource, tag: this.tag, limit: this.limit }) if (data.success && data.obj) { const obj = data.obj const l = String(i18n.global.locale) == 'fa' ? "fa-IR" : "en-US" - const oneStep = limit * 3600 * 1000 / 360 // Each 10 sec + const oneStep = this.limit * 3600 * 1000 / 360 // Each 10 sec const now = new Date().getTime() const steps = [] for (let i = 360; i >= 0; i--) { @@ -145,8 +167,10 @@ export default { ], } this.loaded = true + this.alert = false } else { this.alert = true + this.loaded = false } this.loading = false }, @@ -163,10 +187,10 @@ export default { watch: { visible(v) { if (v) { - const limit = 1 - this.loadData(limit) + this.limit = 1 + this.loadData() this.intervalId = setInterval(() => { - this.loadData(limit) + this.loadData() }, 10000) } else { this.loaded = false