diff --git a/src/App.vue b/src/App.vue index bab8306..0c2a997 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,36 +1,39 @@ diff --git a/src/components/doclive/config.js b/src/components/doclive/config.js new file mode 100644 index 0000000..ce1b0e1 --- /dev/null +++ b/src/components/doclive/config.js @@ -0,0 +1,6 @@ +var config = {}; + +//hardcoded token for testing +config.token = "c96e7fe836f9ffaf83e1fb7bc2b49819251057b0"; + +module.exports = config; diff --git a/src/components/doclive/runLlo.vue b/src/components/doclive/runLlo.vue index 8eafc77..6109f0d 100644 --- a/src/components/doclive/runLlo.vue +++ b/src/components/doclive/runLlo.vue @@ -1,347 +1,365 @@ diff --git a/src/main.js b/src/main.js index 9519483..c7697f4 100644 --- a/src/main.js +++ b/src/main.js @@ -1,45 +1,38 @@ -import Vue from 'vue' -import App from './App.vue' -import store from '@/store/index' -import BootstrapVue from 'bootstrap-vue' -import 'bootstrap/dist/css/bootstrap.css' -import 'bootstrap-vue/dist/bootstrap-vue.css' -import VueSweetalert2 from 'vue-sweetalert2'; +import Vue from "vue"; +import App from "./App.vue"; +import store from "@/store/index"; +import BootstrapVue from "bootstrap-vue"; +import "bootstrap/dist/css/bootstrap.css"; +import "bootstrap-vue/dist/bootstrap-vue.css"; +import VueSweetalert2 from "vue-sweetalert2"; Vue.use(VueSweetalert2); +import VueSocketIOExt from "vue-socket.io-extended"; +import io from "socket.io-client"; - - -import VueSocketIOExt from 'vue-socket.io-extended'; -import io from 'socket.io-client'; - - -const socket = io('https://factory.swarmlab.io:55527', { -//const socket = io('http://factory.swarmlab.io:55528', { +const socket = io("localhost:3000", { + //const socket = io('http://factory.swarmlab.io:55528', { //autoConnect: false autoConnect: false, reconnection: true, reconnectionDelay: 500, maxReconnectionAttempts: Infinity, - pingInterval: 25000, + pingInterval: 25000, pingTimeout: 60000, //transports: ["websocket"], - transports: [ 'websocket', 'polling' ], + transports: ["websocket", "polling"], //transports: ["polling"], - secure: true, - rejectUnauthorized: false + secure: true, + rejectUnauthorized: false, }); Vue.use(VueSocketIOExt, socket); - - Vue.use(BootstrapVue); -Vue.config.productionTip = false +Vue.config.productionTip = false; new Vue({ - el: '#app', + el: "#app", store, - render: h => h(App) -}) - + render: (h) => h(App), +}); diff --git a/src/store/modules/create_pipelineLLO.js b/src/store/modules/create_pipelineLLO.js index 8f5a963..5474c60 100644 --- a/src/store/modules/create_pipelineLLO.js +++ b/src/store/modules/create_pipelineLLO.js @@ -1,237 +1,254 @@ -import { mapState, mapActions, commit } from 'vuex' -import store from '@/store/index' -import axios from 'axios' +import { mapState, mapActions, commit } from "vuex"; +import store from "@/store/index"; +import axios from "axios"; export default { namespaced: true, state: { - token: '', + token: "", llo: {}, log: [], mongolog: [], - socketid:'', - restapi:'off' + socketid: "", + restapi: "off", }, getters: { - getrestapi (state, container) { - //console.log("js1 get "+JSON.stringify(state.llo)) - return state.restapi - //return state.log - }, - getmongolog (state, container) { - //console.log("js1 get "+JSON.stringify(state.llo)) - return state.mongolog - //return state.log - }, - 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 - } + getrestapi(state, container) { + //console.log("js1 get "+JSON.stringify(state.llo)) + return state.restapi; + //return state.log + }, + getmongolog(state, container) { + //console.log("js1 get "+JSON.stringify(state.llo)) + return state.mongolog; + //return state.log + }, + 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); - }, - setrestapi (state, data) { - //console.log("js1 set "+JSON.stringify(data)) - state.restapi=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)) + add_log(state, data) { + //console.log("js1 set "+JSON.stringify(data)) + state.log.push(data); + }, + setrestapi(state, data) { + //console.log("js1 set "+JSON.stringify(data)) + state.restapi = 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; + }, + 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; - }, - setmongolog (state, data) { - //console.log("js1 set "+JSON.stringify(data)) - state.mongolog.push(data); - //state.log.push(data); - }, - rmmongolog (state, data) { - //console.log("js1 set "+JSON.stringify(data)) - state.mongolog = []; - //state.log.push(data); - }, - 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; - } + //state.log = filterlog; + }, + setmongolog(state, data) { + //console.log("js1 set "+JSON.stringify(data)) + state.mongolog.push(data); + //state.log.push(data); + }, + rmmongolog(state, data) { + //console.log("js1 set "+JSON.stringify(data)) + state.mongolog = []; + //state.log.push(data); + }, + 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: { - RMmongolog({commit}, value) { - commit('rmmongolog') - }, - 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) - }, - setRestapi({commit}, value) { - //console.log("container "+value) - commit('setrestapi', value.restapi) - }, - 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 { - + RMmongolog({ commit }, value) { + commit("rmmongolog"); + }, + 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); + }, + setRestapi({ commit }, value) { + //console.log("container "+value) + commit("setrestapi", value.restapi); + }, + 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 - } + code: value.code, + }, }); - - //var p = value.code - console.log("paramp "+JSON.stringify(p)) - store.dispatch('pipelineLLO/setScriptllo', p) - return p; - } catch (e) { - if(e.message == "Request failed with status code 401" || /401/i.test(e.message)){ - window.location.href = 'https://api-login.swarmlab.io:8089'; - }else{ - var R = { + //var p = value.code + console.log("paramp " + JSON.stringify(p)); + store.dispatch("pipelineLLO/setScriptllo", p); + return p; + } catch (e) { + if ( + e.message == "Request failed with status code 401" || + /401/i.test(e.message) + ) { + window.location.href = "https://api-login.swarmlab.io:8089"; + } else { + var R = { ERROR_str: e, - ERROR: 'yes' - } - return R; + ERROR: "yes", + }; + return R; } - } - }, - async get_log({commit,rootGetters}, value) { - try { - var token = store.getters['pipelineLLO/gettoken']; - + } + }, + async get_log({ commit, rootGetters }, value) { + try { + var token = store.getters["pipelineLLO/gettoken"]; + let p = await axios.get("https://factory.swarmlab.io:55527/get_log", { timeout: 45000, params: { - token: token, - start: value.datestart, - end: value.dateend, - swarmlabname: value.swarmlabname - } + token: token, + start: value.datestart, + end: value.dateend, + swarmlabname: value.swarmlabname, + }, }); - - //var p = value.code - console.log("paramp-------------------------- "+JSON.stringify(value)) - store.dispatch('pipelineLLO/set_mongolog', p) - return p; - } catch (e) { - if(e.message == "Request failed with status code 401" || /401/i.test(e.message)){ - window.location.href = 'https://api-login.swarmlab.io:8089'; - }else{ - var R = { + //var p = value.code + console.log( + "paramp-------------------------- " + JSON.stringify(value) + ); + store.dispatch("pipelineLLO/set_mongolog", p); + return p; + } catch (e) { + if ( + e.message == "Request failed with status code 401" || + /401/i.test(e.message) + ) { + window.location.href = "https://api-login.swarmlab.io:8089"; + } else { + var R = { ERROR_str: e, - ERROR: 'yes' - } - return R; - } - } - }, - async hotreload({commit,rootGetters}, value) { - try { - var token = value.token - var params = { - swarmlabname: value.swarmlabname - } - var options = { - headers: { 'content-type': 'application/x-www-form-urlencoded',Authorization: `Bearer ${token}` }, + ERROR: "yes", }; - var p = await axios.post('https://api.swarmlab.io/swarmlabrunhotreload',params,options); - if(p.error == "invalid_token"){ - console.log(p) - console.log(JSON.stringify(p)) - }else{ + return R; + } + } + }, + async hotreload({ commit, rootGetters }, value) { + try { + var token = value.token; + var params = { + swarmlabname: value.swarmlabname, + }; + var options = { + headers: { + "content-type": "application/x-www-form-urlencoded", + Authorization: `Bearer ${token}`, + }, + }; + var p = await axios.post( + "https://api.swarmlab.io/swarmlabrunhotreload", + params, + options + ); + if (p.error == "invalid_token") { + console.log(p); + console.log(JSON.stringify(p)); + } else { } //console.log(value.token) //console.log(value.swarmlabname) - console.log(JSON.stringify(p)) - } catch (e) { - if(e.message == "Request failed with status code 401" || /401/i.test(e.message)){ + console.log(JSON.stringify(p)); + } catch (e) { + if ( + e.message == "Request failed with status code 401" || + /401/i.test(e.message) + ) { //console.log('error '+JSON.stringify(e)) - window.location.href = 'https://api-login.swarmlab.io:8089'; - }else{ - var R = { + window.location.href = "https://api-login.swarmlab.io:8089"; + } else { + var R = { ERROR_str: e, - ERROR: 'yes' - } - return R; + ERROR: "yes", + }; + return R; } - } - }, - set_mongolog({commit}, value) { - //console.log("container "+value) - //commit('setmongolog', value) - for (let item of value.data.data) { - //console.log(JSON.stringify(item)) - var itemobj = {} - itemobj.message = item.message - itemobj.tailed_path = item.tailed_path - itemobj.date = item.time - //console.log('vvvvvvvvvvvvvvvvvvvvvvvv '+JSON.stringify(itemobj)) + } + }, + set_mongolog({ commit }, value) { + //console.log("container "+value) + //commit('setmongolog', value) + for (let item of value.data.data) { + //console.log(JSON.stringify(item)) + var itemobj = {}; + itemobj.message = item.message; + itemobj.tailed_path = item.tailed_path; + itemobj.date = item.time; + //console.log('vvvvvvvvvvvvvvvvvvvvvvvv '+JSON.stringify(itemobj)) - commit('setmongolog', itemobj) - } - }, - 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) - } - } -} + commit("setmongolog", itemobj); + } + }, + 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); + }, + }, +};