refactored code for naming convention and fixed some style

pull/1097/head
smit95tpatel 2021-12-15 17:20:24 +05:30
parent f60d3431cf
commit dd325cefc3
11 changed files with 221 additions and 142 deletions

View File

@ -2,5 +2,6 @@
"editor.codeActionsOnSave": { "editor.codeActionsOnSave": {
"source.fixAll.eslint": true "source.fixAll.eslint": true
}, },
"editor.defaultFormatter": null "editor.defaultFormatter": null,
"eslint.validate": ["javascript"]
} }

View File

@ -387,11 +387,15 @@ class Api {
await axios.all([ all ]); await axios.all([ all ]);
} }
async getDowntimes ({ serviceId, start, end, skip, count, subStatus }) { async downtimes ({ serviceId, start, end, skip, count, subStatus }) {
return axios.get('api/downtimes', { return axios.get('api/downtimes', {
params: { service_id: serviceId, start, end, skip, count, sub_status: subStatus } params: { service_id: serviceId, start, end, skip, count, sub_status: subStatus }
}).then((response) => response.data); }).then((response) => response.data);
} }
async downtime (id) {
return axios.get(`api/downtimes/${id}`).then((response) => response.data);
}
} }
const api = new Api(); const api = new Api();
export default api; export default api;

View File

@ -1,33 +1,37 @@
<template> <template>
<div class="row"> <div class="col-12">
<DowntimesFilterForm <DowntimesFilterForm
:handle-clear-filters="handleClearFilters" :handle-clear-filters="handleClearFilters"
:params="params" :params="params"
:handle-filter-search="handleFilterSearch" :handle-filter-search="handleFilterSearch"
/> />
<div class="col-12">
<div class="card contain-card mb-4"> <div class="card contain-card mb-4">
<div class="card-header"> <div class="card-header">
{{ $t('downtimes') }} {{ $t('downtimes') }}
<!-- <router-link <router-link
v-if="$store.state.admin" v-if="$store.state.admin"
to="/dashboard/create_service" to="/dashboard/create_downtime"
class="btn btn-sm btn-success float-right" class="btn btn-sm btn-success float-right"
> >
<FontAwesomeIcon icon="plus" /> {{ $t('create') }} <FontAwesomeIcon icon="plus" /> {{ $t('create') }}
</router-link> --> </router-link>
</div> </div>
<div class="card-body pt-0"> <div class="card-body pt-0">
<div <div
v-if="isLoading" v-if="isLoading"
class="loader d-flex align-items-center justify-content-center" class="mt-5"
> >
<div <div class="col-12 text-center">
class="spinner-border" <FontAwesomeIcon
role="status" icon="circle-notch"
> size="3x"
<span class="sr-only"> spin
Loading... />
</div>
<div class="col-12 text-center mt-3 mb-3">
<span class="text-muted">
Loading Downtimes
</span> </span>
</div> </div>
</div> </div>
@ -44,7 +48,6 @@
</div> </div>
</div> </div>
</div> </div>
</div>
</template> </template>
<script> <script>
@ -105,9 +108,3 @@ export default {
} }
}; };
</script> </script>
<style scoped>
.loader {
min-height: 100px;
}
</style>

View File

@ -125,6 +125,7 @@
import { mapGetters, mapState } from 'vuex'; import { mapGetters, mapState } from 'vuex';
export default { export default {
name: 'DashboardDowntimeList',
data: function () { data: function () {
return { return {
isLoading: false, isLoading: false,

View File

@ -0,0 +1,57 @@
<template>
<div class="col-12">
<div
v-if="isLoading"
class="row mt-5"
>
<div class="col-12 text-center">
<FontAwesomeIcon
icon="circle-notch"
size="3x"
spin
/>
</div>
<div class="col-12 text-center mt-3 mb-3">
<span class="text-muted">
Loading Downtime
</span>
</div>
</div>
<FormDowntime />
</div>
</template>
<script>
import Api from '../../API';
const FormDowntime = () =>
import(/* webpackChunkName: "dashboard" */ '../../forms/Downtime.vue');
export default {
name: 'EditDowntime',
components: {
FormDowntime
},
data: function () {
return { isLoading: false, downtime: null };
},
created () {
this.getDowntime();
},
methods: {
getDowntime: async function () {
const id = this.$route.params.id;
if (!id) {
return;
}
this.isLoading = true;
const { output } = await Api.getDowntime(id);
this.isLoading = false;
this.downtime = output;
}
}
};
</script>

View File

@ -32,6 +32,7 @@
import { mapState } from 'vuex'; import { mapState } from 'vuex';
export default { export default {
name: 'DasboardDowntimePagination',
props: { props: {
count:{ count:{
type: Number, type: Number,

View File

@ -0,0 +1,10 @@
<template>
<form @submit.prevent="() => {}">
<div class="card contain-card mb-4">
<div class="card-header">
{{ $t("downtime_info") }}
</div>
<div class="card-body" />
</div>
</form>
</template>

View File

@ -1,5 +1,4 @@
<template> <template>
<div class="col-12">
<div class="card contain-card mb-4"> <div class="card contain-card mb-4">
<div class="card-header"> <div class="card-header">
{{ $t('filters') }} {{ $t('filters') }}
@ -7,7 +6,7 @@
<div class="card-body"> <div class="card-body">
<form> <form>
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-2"> <div class="form-group col-md-3">
<label class="col-form-label"> <label class="col-form-label">
{{ $t('service') }} {{ $t('service') }}
</label> </label>
@ -28,7 +27,7 @@
</option> </option>
</select> </select>
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-4">
<label class="col-form-label"> <label class="col-form-label">
Downtime Date Range Downtime Date Range
</label> </label>
@ -80,7 +79,7 @@
</select> </select>
</div> </div>
<div class="form-group col-md-2 d-flex align-items-end"> <div class="form-group col-md-3 d-flex align-items-end">
<div <div
class="ml-auto" class="ml-auto"
role="group" role="group"
@ -105,7 +104,6 @@
</form> </form>
</div> </div>
</div> </div>
</div>
</template> </template>
<script> <script>
@ -115,6 +113,7 @@ import 'flatpickr/dist/flatpickr.css';
import { initialParams } from '../components/Dashboard/DashboardDowntimes.vue'; import { initialParams } from '../components/Dashboard/DashboardDowntimes.vue';
export default { export default {
name: 'DashboardDowntimeFilters',
components: { components: {
FlatPickr FlatPickr
}, },

View File

@ -6,6 +6,7 @@ const english = {
actions: 'Actions', actions: 'Actions',
services: 'Services', services: 'Services',
downtimes: 'Downtimes', downtimes: 'Downtimes',
downtime_info: 'Downtime Info',
filters: 'Filters', filters: 'Filters',
service: 'Service', service: 'Service',
clear: 'Clear', clear: 'Clear',

View File

@ -16,7 +16,8 @@ const Checkins = () => import(/* webpackChunkName: "dashboard" */ '@/components/
const Failures = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/Failures'); const Failures = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/Failures');
const NotFound = () => import(/* webpackChunkName: "index" */ '@/pages/NotFound'); const NotFound = () => import(/* webpackChunkName: "index" */ '@/pages/NotFound');
const Importer = () => import(/* webpackChunkName: "index" */ '@/components/Dashboard/Importer'); const Importer = () => import(/* webpackChunkName: "index" */ '@/components/Dashboard/Importer');
const DashboardDowntimes = () => import(/* webpackChunkName: "downtimes" */ '@/components/Dashboard/DashboardDowntimes'); const DashboardDowntimes = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/DashboardDowntimes');
const EditDowntime = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/EditDowntime');
import VueRouter from 'vue-router'; import VueRouter from 'vue-router';
import Api from './API'; import Api from './API';
@ -145,6 +146,13 @@ const routes = [
requiresAuth: true, requiresAuth: true,
title: 'Statping - Downtimes', title: 'Statping - Downtimes',
} }
},{
path: 'create_downtime',
component: EditDowntime,
meta: {
requiresAuth: true,
title: 'Statping - Create Downtime',
}
},{ },{
path: 'messages', path: 'messages',
component: DashboardMessages, component: DashboardMessages,

View File

@ -163,7 +163,7 @@ export default new Vuex.Store({
context.commit('setServices', services); context.commit('setServices', services);
}, },
async getDowntimes (context, { payload }) { async getDowntimes (context, { payload }) {
const { output } = await Api.getDowntimes(payload); const { output } = await Api.downtimes(payload);
context.commit('setDowntimes', output); context.commit('setDowntimes', output);
}, },
async loadCore (context) { async loadCore (context) {