You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
128 lines
3.5 KiB
128 lines
3.5 KiB
import { mapState, mapActions, commit } from 'vuex'
|
|
import store from '@/store/index'
|
|
import axios from 'axios'
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
token: '',
|
|
llo: {},
|
|
log: [],
|
|
socketid:''
|
|
},
|
|
getters: {
|
|
getlog (state, container) {
|
|
//console.log("js1 get "+JSON.stringify(state.llo))
|
|
return state.log
|
|
},
|
|
gettoken (state, container) {
|
|
//console.log("js1 get "+JSON.stringify(state.llo))
|
|
return state.token
|
|
},
|
|
getllosrc (state, container) {
|
|
//console.log("js1 get "+JSON.stringify(state.llo))
|
|
return state.llo
|
|
},
|
|
getsocketid (state, container) {
|
|
//console.log("js1 get "+JSON.stringify(state.llo))
|
|
return state.socketid
|
|
}
|
|
},
|
|
mutations: {
|
|
add_log (state, data) {
|
|
//console.log("js1 set "+JSON.stringify(data))
|
|
state.log.push(data);
|
|
},
|
|
set_token (state, data) {
|
|
//console.log("js1 set "+JSON.stringify(data))
|
|
state.token=data;
|
|
},
|
|
rm_log (state, path) {
|
|
//console.log("js1 set "+JSON.stringify(data))
|
|
state.log = state.log.filter((item) => item.tailed_path !== path);
|
|
//const filteredArray = myarr.filter(obj => obj.name !== 'foo');
|
|
//console.log("js1 set "+JSON.stringify(filterlog))
|
|
console.log("js1 setrm "+JSON.stringify(state.log))
|
|
|
|
//state.log = filterlog;
|
|
},
|
|
tail_log (state, path) {
|
|
//console.log("js1 set "+JSON.stringify(data))
|
|
state.log = state.log.filter((item) => item.tailed_path !== path).splice(0, 4);
|
|
//const filteredArray = myarr.filter(obj => obj.name !== 'foo');
|
|
//console.log("js1 set "+JSON.stringify(filterlog))
|
|
console.log("js1 setrmrmrmrmrmrmrmrm "+JSON.stringify(state.log))
|
|
|
|
//state.log = filterlog;
|
|
},
|
|
setllo (state, data) {
|
|
//console.log("js1 set "+JSON.stringify(data))
|
|
state.llo=data;
|
|
},
|
|
setsocketid (state, data) {
|
|
//console.log("js1 set "+JSON.stringify(data))
|
|
state.socketid = data;
|
|
}
|
|
},
|
|
actions: {
|
|
addlog({commit}, value) {
|
|
//console.log("container "+value)
|
|
var tt = {}
|
|
tt.message = value.log.log.message
|
|
tt.tailed_path = value.log.log.tailed_path
|
|
tt.date = value.log.date
|
|
commit('add_log', tt)
|
|
},
|
|
settoken({commit}, value) {
|
|
//console.log("container "+value)
|
|
commit('set_token', value.token)
|
|
},
|
|
rmlog({commit}, value) {
|
|
//console.log("containerirm "+value)
|
|
commit('rm_log', value.path)
|
|
},
|
|
taillog({commit}, value) {
|
|
console.log("containerirm "+value)
|
|
commit('tail_log', value.path)
|
|
},
|
|
async get_data({commit,rootGetters}, value) {
|
|
try {
|
|
|
|
let p = await axios.get("https://factory.swarmlab.io:55527/run", {
|
|
timeout: 45000,
|
|
params: {
|
|
code: value.code
|
|
}
|
|
});
|
|
|
|
//var p = value.code
|
|
console.log("paramp "+JSON.stringify(p))
|
|
store.dispatch('pipelineLLO/setScriptllo', p)
|
|
return p;
|
|
|
|
} catch (e) {
|
|
if(e.error == "invalid_token"){
|
|
window.location.href = 'https://api-login.swarmlab.io:8089';
|
|
}else{
|
|
var R = {
|
|
ERROR_str: e,
|
|
ERROR: 'yes'
|
|
}
|
|
return R;
|
|
}
|
|
}
|
|
},
|
|
setScriptllo({commit}, value) {
|
|
//console.log("container "+value)
|
|
commit('setllo', value)
|
|
},
|
|
setsocketllo({commit}, value) {
|
|
//console.log("container "+value)
|
|
commit('setsocketid', value)
|
|
},
|
|
setScriptCodlogAction({commit}, value) {
|
|
//console.log("container "+value)
|
|
commit('setScriptCodelog', value)
|
|
}
|
|
}
|
|
}
|
|
|