mirror of https://github.com/statping/statping
removed eslint from store.js
parent
c2c3ab9a18
commit
8f6b4d9631
|
@ -1,19 +1,19 @@
|
||||||
import Vuex from 'vuex';
|
import Vuex from 'vuex'
|
||||||
import Vue from 'vue';
|
import Vue from 'vue'
|
||||||
import Api from './API';
|
import Api from "./API"
|
||||||
|
|
||||||
Vue.use(Vuex);
|
Vue.use(Vuex)
|
||||||
|
|
||||||
export const HAS_ALL_DATA = 'HAS_ALL_DATA';
|
export const HAS_ALL_DATA = 'HAS_ALL_DATA'
|
||||||
export const HAS_PUBLIC_DATA = 'HAS_PUBLIC_DATA';
|
export const HAS_PUBLIC_DATA = 'HAS_PUBLIC_DATA'
|
||||||
|
|
||||||
export const GET_CORE = 'GET_CORE';
|
export const GET_CORE = 'GET_CORE'
|
||||||
export const GET_SERVICES = 'GET_SERVICES';
|
export const GET_SERVICES = 'GET_SERVICES'
|
||||||
export const GET_TOKEN = 'GET_TOKEN';
|
export const GET_TOKEN = 'GET_TOKEN'
|
||||||
export const GET_GROUPS = 'GET_GROUPS';
|
export const GET_GROUPS = 'GET_GROUPS'
|
||||||
export const GET_MESSAGES = 'GET_MESSAGES';
|
export const GET_MESSAGES = 'GET_MESSAGES'
|
||||||
export const GET_NOTIFIERS = 'GET_NOTIFIERS';
|
export const GET_NOTIFIERS = 'GET_NOTIFIERS'
|
||||||
export const GET_USERS = 'GET_USERS';
|
export const GET_USERS = 'GET_USERS'
|
||||||
|
|
||||||
export default new Vuex.Store({
|
export default new Vuex.Store({
|
||||||
state: {
|
state: {
|
||||||
|
@ -32,13 +32,12 @@ export default new Vuex.Store({
|
||||||
admin: false,
|
admin: false,
|
||||||
user: false,
|
user: false,
|
||||||
loggedIn: false,
|
loggedIn: false,
|
||||||
downtimes: [],
|
|
||||||
modal: {
|
modal: {
|
||||||
visible: false,
|
visible: false,
|
||||||
title: 'Modal Header',
|
title: "Modal Header",
|
||||||
body: 'This is the content for the modal body',
|
body: "This is the content for the modal body",
|
||||||
btnText: 'Save Changes',
|
btnText: "Save Changes",
|
||||||
btnColor: 'btn-primary',
|
btnColor: "btn-primary",
|
||||||
func: null,
|
func: null,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -70,88 +69,88 @@ export default new Vuex.Store({
|
||||||
groupsClean: state => state.groups.filter(g => g.name !== '').sort((a, b) => a.order_id - b.order_id),
|
groupsClean: state => state.groups.filter(g => g.name !== '').sort((a, b) => a.order_id - b.order_id),
|
||||||
groupsCleanInOrder: state => state.groups.filter(g => g.name !== '').sort((a, b) => a.order_id - b.order_id).sort((a, b) => a.order_id - b.order_id),
|
groupsCleanInOrder: state => state.groups.filter(g => g.name !== '').sort((a, b) => a.order_id - b.order_id).sort((a, b) => a.order_id - b.order_id),
|
||||||
serviceCheckins: (state) => (id) => {
|
serviceCheckins: (state) => (id) => {
|
||||||
return state.checkins.filter(c => c.service_id === id);
|
return state.checkins.filter(c => c.service_id === id)
|
||||||
},
|
},
|
||||||
serviceByAll: (state) => (element) => {
|
serviceByAll: (state) => (element) => {
|
||||||
if (!isNaN(parseFloat(element)) && isFinite(element)) {
|
if (!isNaN(parseFloat(element)) && isFinite(element)) {
|
||||||
return state.services.find(s => s.id === parseInt(element));
|
return state.services.find(s => s.id === parseInt(element))
|
||||||
} else {
|
} else {
|
||||||
return state.services.find(s => s.permalink === element);
|
return state.services.find(s => s.permalink === element)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
serviceById: (state) => (id) => {
|
serviceById: (state) => (id) => {
|
||||||
return state.services.find(s => s.permalink === id || s.id === id);
|
return state.services.find(s => s.permalink === id || s.id === id)
|
||||||
},
|
},
|
||||||
servicesInGroup: (state) => (id) => {
|
servicesInGroup: (state) => (id) => {
|
||||||
return state.services.filter(s => s.group_id === id).sort((a, b) => a.order_id - b.order_id);
|
return state.services.filter(s => s.group_id === id).sort((a, b) => a.order_id - b.order_id)
|
||||||
},
|
},
|
||||||
serviceMessages: (state) => (id) => {
|
serviceMessages: (state) => (id) => {
|
||||||
return state.messages.filter(s => s.service === id);
|
return state.messages.filter(s => s.service === id)
|
||||||
},
|
},
|
||||||
onlineServices: (state) => (online) => {
|
onlineServices: (state) => (online) => {
|
||||||
return state.services.filter(s => s.online === online);
|
return state.services.filter(s => s.online === online)
|
||||||
},
|
},
|
||||||
groupById: (state) => (id) => {
|
groupById: (state) => (id) => {
|
||||||
return state.groups.find(g => g.id === id);
|
return state.groups.find(g => g.id === id)
|
||||||
},
|
},
|
||||||
cleanGroups: (state) => () => {
|
cleanGroups: (state) => () => {
|
||||||
return state.groups.filter(g => g.name !== '').sort((a, b) => a.order_id - b.order_id);
|
return state.groups.filter(g => g.name !== '').sort((a, b) => a.order_id - b.order_id)
|
||||||
},
|
},
|
||||||
userById: (state) => (id) => {
|
userById: (state) => (id) => {
|
||||||
return state.users.find(u => u.id === id);
|
return state.users.find(u => u.id === id)
|
||||||
},
|
},
|
||||||
messageById: (state) => (id) => {
|
messageById: (state) => (id) => {
|
||||||
return state.messages.find(m => m.id === id);
|
return state.messages.find(m => m.id === id)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
setHasAllData(state, bool) {
|
setHasAllData(state, bool) {
|
||||||
state.hasAllData = bool;
|
state.hasAllData = bool
|
||||||
},
|
},
|
||||||
setHasPublicData(state, bool) {
|
setHasPublicData(state, bool) {
|
||||||
state.hasPublicData = bool;
|
state.hasPublicData = bool
|
||||||
},
|
},
|
||||||
setCore(state, core) {
|
setCore(state, core) {
|
||||||
state.core = core;
|
state.core = core
|
||||||
},
|
},
|
||||||
setToken(state, token) {
|
setToken(state, token) {
|
||||||
state.token = token;
|
state.token = token
|
||||||
},
|
},
|
||||||
setService(state, service) {
|
setService(state, service) {
|
||||||
state.service = service;
|
state.service = service
|
||||||
},
|
},
|
||||||
setServices(state, services) {
|
setServices(state, services) {
|
||||||
state.services = services;
|
state.services = services
|
||||||
},
|
},
|
||||||
setCheckins(state, checkins) {
|
setCheckins(state, checkins) {
|
||||||
state.checkins = checkins;
|
state.checkins = checkins
|
||||||
},
|
},
|
||||||
setGroups(state, groups) {
|
setGroups(state, groups) {
|
||||||
state.groups = groups;
|
state.groups = groups
|
||||||
},
|
},
|
||||||
setMessages(state, messages) {
|
setMessages(state, messages) {
|
||||||
state.messages = messages;
|
state.messages = messages
|
||||||
},
|
},
|
||||||
setUsers(state, users) {
|
setUsers(state, users) {
|
||||||
state.users = users;
|
state.users = users
|
||||||
},
|
},
|
||||||
setNotifiers(state, notifiers) {
|
setNotifiers(state, notifiers) {
|
||||||
state.notifiers = notifiers;
|
state.notifiers = notifiers
|
||||||
},
|
},
|
||||||
setAdmin(state, admin) {
|
setAdmin(state, admin) {
|
||||||
state.admin = admin;
|
state.admin = admin
|
||||||
},
|
},
|
||||||
setLoggedIn(state, loggedIn) {
|
setLoggedIn(state, loggedIn) {
|
||||||
state.loggedIn = loggedIn;
|
state.loggedIn = loggedIn
|
||||||
},
|
},
|
||||||
setUser(state, user) {
|
setUser(state, user) {
|
||||||
state.user = user;
|
state.user = user
|
||||||
},
|
},
|
||||||
setOAuth(state, oauth) {
|
setOAuth(state, oauth) {
|
||||||
state.oauth = oauth;
|
state.oauth = oauth
|
||||||
},
|
},
|
||||||
setModal(state, modal) {
|
setModal(state, modal) {
|
||||||
state.modal = modal;
|
state.modal = modal
|
||||||
},
|
},
|
||||||
setDowntimes (state, downtimes) {
|
setDowntimes (state, downtimes) {
|
||||||
state.downtimes = downtimes;
|
state.downtimes = downtimes;
|
||||||
|
@ -159,52 +158,48 @@ export default new Vuex.Store({
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
async getAllServices(context) {
|
async getAllServices(context) {
|
||||||
const services = await Api.services();
|
const services = await Api.services()
|
||||||
context.commit('setServices', services);
|
context.commit("setServices", services);
|
||||||
},
|
},
|
||||||
async getDowntimes (context, { payload }) {
|
async getDowntimes (context, { payload }) {
|
||||||
const { output } = await Api.downtimes(payload);
|
const { output } = await Api.downtimes(payload);
|
||||||
context.commit('setDowntimes', output ?? []);
|
context.commit('setDowntimes', output ?? []);
|
||||||
},
|
},
|
||||||
async loadCore(context) {
|
async loadCore(context) {
|
||||||
const [ core, token ] = await Promise.all([ Api.core(), Api.token() ]);
|
const core = await Api.core()
|
||||||
context.commit('setCore', core);
|
const token = await Api.token()
|
||||||
context.commit('setAdmin', token);
|
context.commit("setCore", core);
|
||||||
context.commit('setCore', core);
|
context.commit('setAdmin', token)
|
||||||
context.commit('setUser', token !== undefined);
|
context.commit('setCore', core)
|
||||||
|
context.commit('setUser', token !== undefined)
|
||||||
},
|
},
|
||||||
async loadRequired(context) {
|
async loadRequired(context) {
|
||||||
const [ groups, services, messages, oauth ] = await Promise.all([
|
const groups = await Api.groups()
|
||||||
Api.groups(),
|
context.commit("setGroups", groups);
|
||||||
Api.services(),
|
const services = await Api.services()
|
||||||
Api.messages(),
|
context.commit("setServices", services);
|
||||||
Api.oauth()
|
const messages = await Api.messages()
|
||||||
]);
|
context.commit("setMessages", messages)
|
||||||
context.commit('setGroups', groups);
|
const oauth = await Api.oauth()
|
||||||
context.commit('setServices', services);
|
context.commit("setOAuth", oauth);
|
||||||
context.commit('setMessages', messages);
|
context.commit("setHasPublicData", true)
|
||||||
context.commit('setOAuth', oauth);
|
|
||||||
context.commit('setHasPublicData', true);
|
|
||||||
},
|
},
|
||||||
async loadAdmin(context) {
|
async loadAdmin(context) {
|
||||||
const [ groups, services, messages, checkins, notifiers, users, oauth ] = await Promise.all([
|
const groups = await Api.groups()
|
||||||
Api.groups(),
|
context.commit("setGroups", groups);
|
||||||
Api.services(),
|
const services = await Api.services()
|
||||||
Api.messages(),
|
context.commit("setServices", services);
|
||||||
Api.checkins(),
|
const messages = await Api.messages()
|
||||||
Api.notifiers(),
|
context.commit("setMessages", messages)
|
||||||
Api.users(),
|
context.commit("setHasPublicData", true)
|
||||||
Api.oauth(),
|
const checkins = await Api.checkins()
|
||||||
]);
|
context.commit("setCheckins", checkins);
|
||||||
|
const notifiers = await Api.notifiers()
|
||||||
context.commit('setGroups', groups);
|
context.commit("setNotifiers", notifiers);
|
||||||
context.commit('setServices', services);
|
const users = await Api.users()
|
||||||
context.commit('setMessages', messages);
|
context.commit("setUsers", users);
|
||||||
context.commit('setHasPublicData', true);
|
const oauth = await Api.oauth()
|
||||||
context.commit('setCheckins', checkins);
|
context.commit("setOAuth", oauth);
|
||||||
context.commit('setNotifiers', notifiers);
|
|
||||||
context.commit('setUsers', users);
|
|
||||||
context.commit('setOAuth', oauth);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
Loading…
Reference in New Issue