Very rough go at connecting to socket and rendering console data for server
This commit is contained in:
parent
784c73becd
commit
8db9d9bbee
9 changed files with 311 additions and 114 deletions
|
@ -1,10 +1,11 @@
|
|||
import route from '../../../../../vendor/tightenco/ziggy/src/js/route';
|
||||
import Server from '../../models/server';
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
server: {},
|
||||
credentials: {node: '', key: ''},
|
||||
console: [],
|
||||
},
|
||||
getters: {
|
||||
},
|
||||
|
@ -34,10 +35,44 @@ export default {
|
|||
.catch(reject);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Get authentication credentials that the client should use when connecting to the daemon to
|
||||
* retrieve server information.
|
||||
*
|
||||
* @param commit
|
||||
* @param {String} server
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
getCredentials: ({commit}, {server}) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios.get(route('server.credentials', {server}))
|
||||
.then(response => {
|
||||
// If there is a 302 redirect or some other odd behavior (basically, response that isnt
|
||||
// in JSON format) throw an error and don't try to continue with the login.
|
||||
if (!(response.data instanceof Object)) {
|
||||
return reject(new Error('An error was encountered while processing this request.'));
|
||||
}
|
||||
|
||||
if (response.data.key) {
|
||||
commit('SERVER_CREDENTIALS', response.data)
|
||||
}
|
||||
|
||||
return resolve();
|
||||
})
|
||||
.catch(reject);
|
||||
});
|
||||
},
|
||||
},
|
||||
mutations: {
|
||||
SERVER_DATA: function (state, data) {
|
||||
state.server = data;
|
||||
}
|
||||
},
|
||||
SERVER_CREDENTIALS: function (state, credentials) {
|
||||
state.credentials = credentials;
|
||||
},
|
||||
CONSOLE_DATA: function (state, data) {
|
||||
state.console.push(data);
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue