Browse Source

last changes

master
lefteris 4 years ago
parent
commit
e8c0869881
  1. 200
      src/App.vue
  2. 6
      src/components/doclive/config.js
  3. 1074
      src/components/doclive/runLlo.vue
  4. 45
      src/main.js
  5. 419
      src/store/modules/create_pipelineLLO.js

200
src/App.vue

@ -1,36 +1,39 @@
<template>
<div id="app">
<!-- ***************** nav items ****************** -->
<b-navbar toggleable="md" class="navbar-secondary" >
<b-navbar-toggle target="nav_collapse"> </b-navbar-toggle>
<b-navbar-brand class="logo simple-text ti-swarmlab text-secondary">
Swarmlab.io Playground
</b-navbar-brand>
<b-collapse is-nav id="nav_collapse">
<b-navbar-nav>
</b-navbar-nav>
<!-- Right aligned nav items -->
<b-navbar-nav class="ml-auto">
<b-nav-item href="https://git.swarmlab.io:3000" target="_swarmlabgit"> Swarmlab_git </b-nav-item>
<b-nav-item > | </b-nav-item>
<b-nav-item :href="'https://api-client.swarmlab.io:8088/?token='+ token" target="_swarmlab"> Lab_onDemand </b-nav-item>
<b-nav-item > | </b-nav-item>
<!--
<!-- ***************** nav items ****************** -->
<b-navbar toggleable="md" class="navbar-secondary">
<b-navbar-toggle target="nav_collapse"> </b-navbar-toggle>
<b-navbar-brand class="logo simple-text ti-swarmlab text-secondary">
Swarmlab.io Playground
</b-navbar-brand>
<b-collapse is-nav id="nav_collapse">
<b-navbar-nav> </b-navbar-nav>
<!-- Right aligned nav items -->
<b-navbar-nav class="ml-auto">
<b-nav-item href="https://git.swarmlab.io:3000" target="_swarmlabgit">
Swarmlab_git
</b-nav-item>
<b-nav-item> | </b-nav-item>
<b-nav-item
:href="'https://api-client.swarmlab.io:8088/?token=' + token"
target="_swarmlab"
>
Lab_onDemand
</b-nav-item>
<b-nav-item> | </b-nav-item>
<!--
<b-nav-form>
<b-form-input size="sm" class="mr-sm-2" type="text" placeholder="Search"/>
<b-button size="sm" class="my-2 my-sm-0" type="submit">Search</b-button>
</b-nav-form>
-->
<!-- template
<!-- template
<b-nav-item-dropdown right>
-->
<!-- Using template slot -->
<!-- template
<!-- Using template slot -->
<!-- template
<template slot="button-content">
<em>Template</em>
</template>
@ -53,124 +56,101 @@
@click="saveDocLive">
Save As Zip</button>
-->
</b-navbar-nav>
</b-collapse>
</b-navbar>
<!-- ***************** container items ****************** -->
<b-row>
<b-col cols="12">
<doc-live
style="background-color: #f8f9fa"
>
</doc-live>
</b-col>
</b-row>
<b-row>
<b-col cols="12">
<doc-grep
style="background-color: #f8f9fa"
>
</doc-grep>
</b-col>
</b-row>
</b-navbar-nav>
</b-collapse>
</b-navbar>
<!-- ***************** container items ****************** -->
<b-row>
<b-col cols="12">
<doc-live style="background-color: #f8f9fa"> </doc-live>
</b-col>
</b-row>
<b-row>
<b-col cols="12">
<doc-grep style="background-color: #f8f9fa"> </doc-grep>
</b-col>
</b-row>
</div>
</template>
<script>
import DocLive from './components/DocLive.vue'
import DocGrep from './components/DocGrep.vue'
import DocLive from "./components/DocLive.vue";
import DocGrep from "./components/DocGrep.vue";
import "@/assets/css/themify-icons.css";
export default {
name: 'app',
name: "app",
components: {
DocLive,
DocGrep
DocGrep,
},
data() {
return {
show: true,
token: '',
SwarmabAsciiLabTemplate:''
}
},
mounted() {
token: "",
SwarmabAsciiLabTemplate: "",
};
},
created() {
var url_string = window.location.href
mounted() {},
created() {
var url_string = window.location.href;
var url = new URL(url_string);
this.token = url.searchParams.get("token");
console.log("token "+ this.token);
console.log("token " + this.token);
},
methods: {
saveDocLive() {
this.$root.$emit('asciilive_save','save')
this.$root.$emit("asciilive_save", "save");
},
async connect_to_iot(iot) {
if( iot == 'mesh' ){
this.SwarmabAsciiLabTemplate = {
"iot5": {
"id": 5,
"name": "auto5",
"img": "rinse.png",
"Servicios": [
{"model":"Sentra", "doors":4},
{"model":"Maxima", "doors":4},
{"model":"Skyline", "doors":2}
]
}
}
if (iot == "mesh") {
this.SwarmabAsciiLabTemplate = {
iot5: {
id: 5,
name: "auto5",
img: "rinse.png",
Servicios: [
{ model: "Sentra", doors: 4 },
{ model: "Maxima", doors: 4 },
{ model: "Skyline", doors: 2 },
],
},
};
}
}
}
}
},
},
};
</script>
<style>
@import url('https://fonts.googleapis.com/css?family=Lato:400,700');
@import url("https://fonts.googleapis.com/css?family=Lato:400,700");
body {
background: #EEF1F4 !important;
}
body {
background: #eef1f4 !important;
}
.nav-background {
background: #353535;
}
.nav-background {
background: #353535;
}
.ti-swarmlab:before {
position: relative;
top:-5px;
right:-8px;
font-size: 1.5em;
font-weight: 300;
content: "\e606";
color: #222;
color: #74B3C8;
border-color: #c60000;
.ti-swarmlab:before {
position: relative;
top: -5px;
right: -8px;
font-size: 1.5em;
font-weight: 300;
content: "\e606";
color: #222;
color: #74b3c8;
border-color: #c60000;
}
.ti-themify-logo:before {
content: "\e6d1";
content: "\e6d1";
}
.menoutext {
font-family: 'Lato', sans-serif !important;
}
.menoutext {
font-family: "Lato", sans-serif !important;
}
</style>

6
src/components/doclive/config.js

@ -0,0 +1,6 @@
var config = {};
//hardcoded token for testing
config.token = "c96e7fe836f9ffaf83e1fb7bc2b49819251057b0";
module.exports = config;

1074
src/components/doclive/runLlo.vue

File diff suppressed because it is too large

45
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),
});

419
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);
},
},
};

Loading…
Cancel
Save