forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
64 lines (63 loc) · 2.11 KB
/
server.js
File metadata and controls
64 lines (63 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import LoadingState from '../../models/loadingStates';
import route from '../../../../../vendor/tightenco/ziggy/src/js/route';
export default {
state: {
servers: {},
serverIDs: [],
currentServerID: '',
serverLoadingState: '',
},
mutations: {
setCurrentServer (state, serverID) {
state.currentServerID = serverID;
},
setServers (state, servers) {
servers.forEach(s => {
state.servers[s.identifier] = s;
if (!!state.serverIDs.indexOf(s.identifier)) {
state.serverIDs.push(s.identifier)
}
});
},
removeServer (state, serverID) {
delete state.servers[serverID];
state.serverIDs.remove(serverID);
},
setServerLoadingState (state, s) {
state.serverLoadingState = s;
}
},
actions: {
loadServers({ commit }) {
commit('setServerLoadingState', LoadingState.LOADING);
window.axios.get(route('api.client.index'))
.then(response => {
commit('setServers', response.data.data.map(o => o.attributes));
commit('setServerLoadingState', LoadingState.DONE);
})
.catch(err => {
console.error(err);
const response = err.response;
if (response.data && _.isObject(response.data.errors)) {
response.data.errors.forEach(function (error) {
this.error(error.detail);
});
}
})
.finally(() => {
this.loading = false;
});
},
},
getters: {
currentServer (state) {
return state.servers[state.route.params.serverID];
},
isServersLoading (state) {
return state.serverLoadingState === LoadingState.LOADING;
},
serverList (state) {
return state.serverIDs.map(k => state.servers[k]);
}
}
};