Browse Source

last changes

master
lefteris 4 years ago
parent
commit
e8c0869881
  1. 128
      src/App.vue
  2. 6
      src/components/doclive/config.js
  3. 468
      src/components/doclive/runLlo.vue
  4. 41
      src/main.js
  5. 231
      src/store/modules/create_pipelineLLO.js

128
src/App.vue

@ -1,24 +1,27 @@
<template>
<div id="app">
<!-- ***************** nav items ****************** -->
<b-navbar toggleable="md" class="navbar-secondary" >
<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>
<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-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"/>
@ -53,115 +56,93 @@
@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>
<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>
<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: "",
};
},
mounted() {},
created() {
var url_string = window.location.href
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' ){
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}
]
}
}
}
}
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 {
.nav-background {
background: #353535;
}
}
.ti-swarmlab:before {
.ti-swarmlab:before {
position: relative;
top:-5px;
right:-8px;
top: -5px;
right: -8px;
font-size: 1.5em;
font-weight: 300;
content: "\e606";
color: #222;
color: #74B3C8;
color: #74b3c8;
border-color: #c60000;
}
@ -169,8 +150,7 @@ export default {
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;

468
src/components/doclive/runLlo.vue

@ -2,12 +2,11 @@
<div>
<div class="row">
<div class="col-12 d-flex justify-content-center text-center">
<h4 class="text-info"> Search </h4>
<h4 class="text-info">Search</h4>
</div>
</div>
<div class="row">
<div class="col-6">
<div class="input-group input-group-sm sm-6">
<!-- --------------------------------------------------------- -->
@ -15,9 +14,9 @@
<!-- --------------------------------------------------------- -->
<div class="input-group input-group-sm mb-3">
<div class="input-group-prepend">
<button class="btn btn-outline-secondary"
type="button"
>Start date </button>
<button class="btn btn-outline-secondary" type="button">
Start date
</button>
</div>
<date-picker
type="date"
@ -29,7 +28,8 @@
</date-picker>
</div>
</div>
</div> <!-- col -->
</div>
<!-- col -->
<div class="col-6">
<div class="input-group input-group-sm sm-6">
@ -38,9 +38,9 @@
<!-- --------------------------------------------------------- -->
<div class="input-group input-group-sm mb-3">
<div class="input-group-prepend">
<button class="btn btn-outline-secondary"
type="button"
>End date </button>
<button class="btn btn-outline-secondary" type="button">
End date
</button>
</div>
<date-picker
type="date"
@ -56,48 +56,67 @@
class="btn btn-outline-primary"
round
type="button"
@click="setFilter">
Go</button>
@click="setFilter"
>
Go
</button>
</div>
</div>
</div>
</div> <!-- col -->
</div> <!-- row -->
</div>
<!-- col -->
</div>
<!-- row -->
<div class="row">
<div class="col-6">
<div class="input-group input-group-sm sm-6">
<div class="input-group-prepend">
<div class="form-control custom-control custom-switch custom-control-inline">
<input type="checkbox" class="custom-control-input" id="log_logerror"
<div
class="form-control custom-control custom-switch custom-control-inline"
>
<input
type="checkbox"
class="custom-control-input"
id="log_logerror"
v-model="logcheck.error"
/>
<label class="custom-control-label" for="log_logerror"
>Error</label
>
<label class="custom-control-label" for="log_logerror">Error</label>
</div>
<div class="form-control custom-control custom-switch custom-control-inline">
<input type="checkbox" class="custom-control-input" id="log_output"
<div
class="form-control custom-control custom-switch custom-control-inline"
>
<input
type="checkbox"
class="custom-control-input"
id="log_output"
v-model="logcheck.output"
data-size="large"
data-toggle="toggle"
/>
<label class="custom-control-label" for="log_output"
>Output</label
>
<label class="custom-control-label" for="log_output">Output</label>
</div>
<div class="form-control custom-control custom-switch custom-control-inline">
<input type="checkbox" class="custom-control-input" id="log_log"
v-model="logcheck.log"
<div
class="form-control custom-control custom-switch custom-control-inline"
>
<input
type="checkbox"
class="custom-control-input"
id="log_log"
v-model="logcheck.log"
/>
<label class="custom-control-label" for="log_log">Log</label>
</div>
</div>
</div>
</div> <!-- col -->
</div>
<!-- col -->
<div class="col-5">
<div class="input-group input-group-sm sm-5 justify-content-end ">
@ -107,8 +126,10 @@
class="btn btn-outline-warning"
round
type="button"
@click="Clearlog">
Clear</button>
@click="Clearlog"
>
Clear
</button>
</div>
<div class="input-group-append">
@ -116,211 +137,209 @@
class="btn btn-outline-primary"
round
type="button"
@click="Hotlog">
Hot_log</button>
@click="Hotlog"
>
Hot_log
</button>
</div>
</div>
</div>
</div> <!-- col -->
<div class="col-1">
</div> <!-- col -->
</div> <!-- row -->
</div>
<!-- col -->
<div class="col-1"></div>
<!-- col -->
</div>
<!-- row -->
<div class="row rowlog overflow-auto">
<div class="col-12"
v-for="item in log_path"
>
<b-row
class="border-bottom"
v-if="logview(item) === true"
>
<div class="col-12" v-for="item in log_path">
<b-row class="border-bottom" v-if="logview(item) === true">
<b-col cols="2">
<span class="badge badge-danger badge-pill"
<span
class="badge badge-danger badge-pill"
style="cursor: pointer"
@click="clearLog()"
>Clear</span>
>Clear</span
>
</b-col>
<b-col cols="8"
style="cursor: pointer"
@click="selectPath(item)"
>
<b-col cols="8" style="cursor: pointer" @click="selectPath(item)">
{{ item }}
</b-col>
<b-col cols="2">
<span class="badge badge-secondary badge-pill"
<span
class="badge badge-secondary badge-pill"
v-if="log_path_lenght[item] == log_path_lenghtstatus[item]"
>{{log_path_lenght[item]}}</span>
>{{ log_path_lenght[item] }}</span
>
<span class="badge badge-primary badge-pill"
v-else
>{{log_path_lenght[item]}}</span>
<span class="badge badge-primary badge-pill" v-else>{{
log_path_lenght[item]
}}</span>
</b-col>
</b-row>
</div> <!-- col -->
</div> <!-- row -->
</div>
<!-- col -->
</div>
<!-- row -->
</div>
</template>
<script>
import {mapState, mapGetters, mapActions,dispatch} from 'vuex'
import Vue from 'vue'
import store from '@/store/index'
import JSZip from 'jszip';
import DatePicker from 'vue2-datepicker'
import 'vue2-datepicker/index.css';
import { mapState, mapGetters, mapActions, dispatch } from "vuex";
import Vue from "vue";
import store from "@/store/index";
import JSZip from "jszip";
import DatePicker from "vue2-datepicker";
import "vue2-datepicker/index.css";
import { DateTime } from "luxon";
import FileSaver from 'file-saver';
import FileSaver from "file-saver";
export default {
components: {
DatePicker
DatePicker,
},
data () {
data() {
return {
log_path:[],
log_path_lenght:[],
log_path_lenghtstatus:[],
loglenghttotal:32,
log_path: [],
log_path_lenght: [],
log_path_lenghtstatus: [],
loglenghttotal: 32,
search: {
datestart: "",
dateend: "",
log: "",
output: "",
error: ""
error: "",
},
logcheck: {
log: true,
error: true,
output: true
output: true,
},
selected: [],
showlloedit:true,
issocket:'close',
socketdata:'',
logintoken:'',
code:[],
logdata: []
}
showlloedit: true,
issocket: "close",
socketdata: "",
logintoken: "",
code: [],
logdata: [],
};
},
methods: {
Hotlog() {
this.Clearlog()
var restapi = "off"
var logrestapi = store.dispatch("pipelineLLO/setRestapi",{
restapi:restapi
})
this.Clearlog();
var restapi = "off";
var logrestapi = store.dispatch("pipelineLLO/setRestapi", {
restapi: restapi,
});
},
Clearlog() {
var log = store.dispatch("pipelineLLO/RMmongolog")
this.log_path = []
var log = store.dispatch("pipelineLLO/RMmongolog");
this.log_path = [];
//var mongolog = store.getters['pipelineLLO/getmongolog'];
//console.log("rmmongolog "+JSON.stringify(mongolog))
},
logview(item) {
//console.log('path ' + JSON.stringify(item))
if(this.logcheck.log){
if(item.endsWith('-log')){
if (this.logcheck.log) {
if (item.endsWith("-log")) {
return true;
}
}
if(this.logcheck.error){
if(item.endsWith('-error')){
if (this.logcheck.error) {
if (item.endsWith("-error")) {
return true;
}
}
if(this.logcheck.output){
if(item.endsWith('-output')){
if (this.logcheck.output) {
if (item.endsWith("-output")) {
return true;
}
}
},
async selectPath(path) {
console.log('path ' + JSON.stringify(path))
var statuslenght = this.log_path_lenght[path]
console.log("path " + JSON.stringify(path));
var statuslenght = this.log_path_lenght[path];
Vue.set(this.log_path_lenghtstatus, path, statuslenght);
// -------------------------------------
// send to AdhocView to view in code
// -------------------------------------
this.$root.$emit('playground_log_in',path)
this.$root.$emit("playground_log_in", path);
},
async clearLog(path) {
console.log('path ' + JSON.stringify(path))
console.log("path " + JSON.stringify(path));
Vue.set(this.log_path_lenght, path, 0);
Vue.set(this.log_path_lenghtstatus, path, 0);
var log = store.dispatch("pipelineLLO/rmlog",{
path:path
})
var log = store.dispatch("pipelineLLO/rmlog", {
path: path,
});
},
async setFilter() {
console.log(JSON.stringify(this.search))
console.log(JSON.stringify(this.search));
var ddd8 = JSON.stringify(this.search.datestart)
ddd8 = ddd8.replace(/"/g,''); //"
var ddd8 = JSON.stringify(this.search.datestart);
ddd8 = ddd8.replace(/"/g, ""); //"
var datestart = DateTime.fromISO(ddd8, { zone: "Europe/Athens" });
//console.log(datestart.zoneName); //=> 'Europe/Paris'
//console.log(datestart.toString()); //=> 'Europe/Paris'
var ddd18 = JSON.stringify(this.search.dateend)
ddd18 = ddd18.replace(/"/g,''); //"
var ddd18 = JSON.stringify(this.search.dateend);
ddd18 = ddd18.replace(/"/g, ""); //"
var dateend = DateTime.fromISO(ddd18, { zone: "Europe/Athens" });
var restapi = "on"
var logrestapi = await store.dispatch("pipelineLLO/setRestapi",{
restapi:restapi
})
var swarmlabname = new URL(location.href).searchParams.get('pipelinename');
var log = await store.dispatch("pipelineLLO/get_log",{
datestart:datestart.toISODate(),
dateend:dateend.toISODate(),
swarmlabname:swarmlabname
})
var mongolog = store.getters['pipelineLLO/getmongolog'];
console.log("paramp "+JSON.stringify(mongolog))
var restapi = "on";
var logrestapi = await store.dispatch("pipelineLLO/setRestapi", {
restapi: restapi,
});
var swarmlabname = new URL(location.href).searchParams.get(
"pipelinename"
);
var log = await store.dispatch("pipelineLLO/get_log", {
datestart: datestart.toISODate(),
dateend: dateend.toISODate(),
swarmlabname: swarmlabname,
});
var mongolog = store.getters["pipelineLLO/getmongolog"];
console.log("paramp " + JSON.stringify(mongolog));
//this.$root.$emit('GREP_on_data',mongolog.data.data)
// list files from data
this.log_path = [...new Set(mongolog.map(item => item.tailed_path))];
var loglenght = ''
this.log_path = [...new Set(mongolog.map((item) => item.tailed_path))];
var loglenght = "";
for (let item of this.log_path) {
loglenght = mongolog.filter(item1 => item1.tailed_path === item).length;
loglenght = mongolog.filter((item1) => item1.tailed_path === item)
.length;
Vue.set(this.log_path_lenght, item, loglenght);
if(loglenght > this.loglenghttotal){
if (loglenght > this.loglenghttotal) {
// -------------------------------------
// Save store
// -------------------------------------
var ltotal1 = store.dispatch("pipelineLLO/taillog",{
path:item
})
var ltotal1 = store.dispatch("pipelineLLO/taillog", {
path: item,
});
}
}
},
async resetFilter() {
console.log(JSON.stringify(this.logdata))
console.log(JSON.stringify(this.logdata));
},
async socketopen () {
async socketopen() {
this.$socket.client.open();
},
async socketauthenticate () {
var tokentmp = store.getters['pipelineLLO/gettoken'];
this.$socket.client.emit('authenticate', tokentmp);
async socketauthenticate() {
var tokentmp = store.getters["pipelineLLO/gettoken"];
// pernaw hardcoded to token
var test = "c96e7fe836f9ffaf83e1fb7bc2b49819251057b0";
this.$socket.client.emit("authenticate", test);
},
async socketreconnect () {
var log = await this.socketopen()
this.socketauthenticate()
async socketreconnect() {
var log = await this.socketopen();
this.socketauthenticate();
},
/**
/**
*
* == socketclose()
*
@ -330,18 +349,17 @@ export default {
* ----
*
*/
async socketclose () {
this.$socket.client.close();
}
async socketclose() {
this.$socket.client.close();
},
computed: {
},
beforeMount () {
this.socketauthenticate()
console.log('send')
computed: {},
beforeMount() {
this.socketauthenticate();
console.log("send1");
},
/**
/**
*
* == Socket subscribe
*
@ -357,13 +375,13 @@ export default {
*/
mounted() {
// from AdhocView
this.$root.$on('SERVER_socket_connect', (v) => {
this.$nextTick(function () {
this.socketreconnect()
})
})
this.$root.$on("SERVER_socket_connect", (v) => {
this.$nextTick(function() {
this.socketreconnect();
});
});
},
/**
/**
*
* == Destroy EventBus
*
@ -380,8 +398,8 @@ export default {
* <1> EventBus is used for parent/child component communication.
*
*/
beforeDestroy () {
this.$root.$off('SERVER_socket_socket')
beforeDestroy() {
this.$root.$off("SERVER_socket_socket");
},
/**
*
@ -401,12 +419,14 @@ export default {
*
*/
created () {
this.socketopen()
var logintoken = new URL(location.href).searchParams.get('token');
var log = store.dispatch("pipelineLLO/settoken",{
token:logintoken
})
created() {
this.socketopen();
var logintoken = new URL(location.href).searchParams.get("token");
// hardcoded token
var hardtoken = "c96e7fe836f9ffaf83e1fb7bc2b49819251057b0";
var log = store.dispatch("pipelineLLO/settoken", {
token: hardtoken,
});
//var tokentmp =store.getters['pipelineLLO/gettoken'];
//console.log("tokennnn "+tokentmp);
@ -423,9 +443,12 @@ export default {
*/
sockets: {
connect() {
this.$socket.client.emit('authenticate', 'logintoken');
//hardtoken
var hardtoken = "c96e7fe836f9ffaf83e1fb7bc2b49819251057b0";
this.$socket.client.emit("authenticate", hardtoken);
//this.$socket.client.emit("authenticate", "logintoken");
this.$socket.client.emit('socket_id_get', 'socketdatasend');
this.$socket.client.emit("socket_id_get", "socketdatasend");
//var username = 'username'
//var roomname = 'roomname'
//this.$socket.client.emit('setUsername',{user:username});
@ -433,10 +456,10 @@ export default {
//this.$socket.client.emit('joinRooom',{room:roomname});
//var msg = {user:username,room:roomname,msg:'hiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii'}
//this.$socket.client.emit('sendMessage',msg);
console.log('socket connected '+ 'socketdatasend' )
this.issocket = 'open'
console.log("socket connected " + "socketdatasend");
this.issocket = "open";
// send to AdhocView
this.$root.$emit('SERVER_socket_status','on')
this.$root.$emit("SERVER_socket_status", "on");
},
/**
*
@ -444,10 +467,10 @@ export default {
*
*/
error(error) {
console.log("socket error "+JSON.stringify(error))
this.issocket = 'close'
console.log("socket error " + JSON.stringify(error));
this.issocket = "close";
// send to AdhocView
this.$root.$emit('SERVER_socket_status','off')
this.$root.$emit("SERVER_socket_status", "off");
},
/**
*
@ -455,11 +478,11 @@ export default {
*
*/
connect_error(error) {
console.log("socket connect_error "+JSON.stringify(error))
this.issocket = 'close'
console.log("socket connect_error " + JSON.stringify(error));
this.issocket = "close";
// send to AdhocView
this.$root.$emit('SERVER_socket_status','off')
this.socketreconnect()
this.$root.$emit("SERVER_socket_status", "off");
this.socketreconnect();
},
/**
*
@ -467,11 +490,11 @@ export default {
*
*/
disconnect(reason) {
console.log("socket disconnect "+JSON.stringify(reason))
this.issocket = 'close'
console.log("socket disconnect " + JSON.stringify(reason));
this.issocket = "close";
// send to AdhocView
this.$root.$emit('SERVER_socket_status','off')
this.socketreconnect()
this.$root.$emit("SERVER_socket_status", "off");
this.socketreconnect();
},
/**
*
@ -479,11 +502,11 @@ export default {
*
*/
connect_timeout(reason) {
console.log("socket timeout "+JSON.stringify(reason))
this.issocket = 'close'
console.log("socket timeout " + JSON.stringify(reason));
this.issocket = "close";
// send to AdhocView
this.$root.$emit('SERVER_socket_status','off')
this.socketreconnect()
this.$root.$emit("SERVER_socket_status", "off");
this.socketreconnect();
},
/**
*
@ -491,10 +514,12 @@ export default {
*
*/
reconnect(attemptNumber) {
console.log("socket reconnect attemptNumber "+JSON.stringify(attemptNumber))
console.log(
"socket reconnect attemptNumber " + JSON.stringify(attemptNumber)
);
// send to AdhocView
this.$root.$emit('SERVER_socket_status','off')
this.socketreconnect()
this.$root.$emit("SERVER_socket_status", "off");
this.socketreconnect();
},
/**
*
@ -502,10 +527,10 @@ export default {
*
*/
reconnect_attempt(attemptNumber) {
console.log("socket reconnect_attempt "+JSON.stringify(attemptNumber))
console.log("socket reconnect_attempt " + JSON.stringify(attemptNumber));
// send to AdhocView
this.$root.$emit('SERVER_socket_status','off')
this.socketreconnect()
this.$root.$emit("SERVER_socket_status", "off");
this.socketreconnect();
},
/**
*
@ -513,9 +538,9 @@ export default {
*
*/
reconnecting(attemptNumber) {
console.log("socket reconnecting "+JSON.stringify(attemptNumber))
this.$root.$emit('SERVER_socket_status','off')
this.socketreconnect()
console.log("socket reconnecting " + JSON.stringify(attemptNumber));
this.$root.$emit("SERVER_socket_status", "off");
this.socketreconnect();
},
/**
*
@ -523,11 +548,11 @@ export default {
*
*/
reconnect_error(error) {
console.log("socket reconnect_error "+JSON.stringify(error))
this.issocket = 'close'
console.log("socket reconnect_error " + JSON.stringify(error));
this.issocket = "close";
// send to AdhocView
this.$root.$emit('SERVER_socket_status','off')
this.socketreconnect()
this.$root.$emit("SERVER_socket_status", "off");
this.socketreconnect();
},
/**
*
@ -535,10 +560,10 @@ export default {
*
*/
unauthorized(val) {
console.log("socket unauthorized "+JSON.stringify(val))
this.issocket = 'close'
console.log("socket unauthorized " + JSON.stringify(val));
this.issocket = "close";
// send to AdhocView
this.$root.$emit('SERVER_socket_status','off')
this.$root.$emit("SERVER_socket_status", "off");
},
/**
*
@ -546,9 +571,9 @@ export default {
*
*/
socket_id_emit(val) {
console.log("socket id from server "+JSON.stringify(val))
console.log("socket id from serveri saved "+JSON.stringify(socketsave))
this.issocket = 'open'
console.log("socket id from server " + JSON.stringify(val));
console.log("socket id from serveri saved " + JSON.stringify(socketsave));
this.issocket = "open";
},
/**
*
@ -587,17 +612,17 @@ export default {
},
*/
async logdata(val) {
console.log(" socket from logdata "+JSON.stringify(val))
console.log(" socket from logdata " + JSON.stringify(val));
// -------------------------------------
// Save store
// -------------------------------------
var log = store.dispatch("pipelineLLO/addlog",{
log:val
})
var log = store.dispatch("pipelineLLO/addlog", {
log: val,
});
// -------------------------------------
// send to grep rungrep to view
// -------------------------------------
this.$root.$emit('GREP_on_data',val)
this.$root.$emit("GREP_on_data", val);
// -------------------------------------
// send to AdhocView to view in code
// -------------------------------------
@ -605,23 +630,23 @@ export default {
// -------------------------------------
// send to AdhocView for socket status
// -------------------------------------
this.$root.$emit('SERVER_socket_status','on')
this.$root.$emit("SERVER_socket_status", "on");
var ltmp = store.getters['pipelineLLO/getlog'];
var ltmp = store.getters["pipelineLLO/getlog"];
//console.log('logtmpltmp '+ JSON.stringify(ltmp))
this.log_path = [...new Set(ltmp.map(item => item.tailed_path))];
var loglenght = ''
this.log_path = [...new Set(ltmp.map((item) => item.tailed_path))];
var loglenght = "";
for (let item of this.log_path) {
//console.log('l1find '+ JSON.stringify(item))
loglenght = ltmp.filter(item1 => item1.tailed_path === item).length;
loglenght = ltmp.filter((item1) => item1.tailed_path === item).length;
Vue.set(this.log_path_lenght, item, loglenght);
if(loglenght > this.loglenghttotal){
if (loglenght > this.loglenghttotal) {
// -------------------------------------
// Save store
// -------------------------------------
var ltotal1 = store.dispatch("pipelineLLO/taillog",{
path:item
})
var ltotal1 = store.dispatch("pipelineLLO/taillog", {
path: item,
});
}
/*
this.log_path_lenght[item] = ltmp.filter(function(item1){
@ -635,20 +660,16 @@ export default {
//console.log('l2 '+ this.log_path_lenght[item] )
}
//console.log('l1 '+ JSON.stringify(this.log_path))
},
async message(val) {
console.log(" socket message "+JSON.stringify(val))
}
}
console.log(" socket message " + JSON.stringify(val));
},
},
};
</script>
<style>
.CodeMirror {
font-family: monospace;
height: 750px;
}
@ -656,5 +677,4 @@ export default {
display: flex; /* equal height of the children */
height: 470px;
}
</style>

41
src/main.js

@ -1,21 +1,17 @@
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,
@ -24,22 +20,19 @@ const socket = io('https://factory.swarmlab.io:55527', {
pingInterval: 25000,
pingTimeout: 60000,
//transports: ["websocket"],
transports: [ 'websocket', 'polling' ],
transports: ["websocket", "polling"],
//transports: ["polling"],
secure: true,
rejectUnauthorized: false
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),
});

231
src/store/modules/create_pipelineLLO.js

@ -1,153 +1,156 @@
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) {
getrestapi(state, container) {
//console.log("js1 get "+JSON.stringify(state.llo))
return state.restapi
return state.restapi;
//return state.log
},
getmongolog (state, container) {
getmongolog(state, container) {
//console.log("js1 get "+JSON.stringify(state.llo))
return state.mongolog
return state.mongolog;
//return state.log
},
getlog (state, container) {
getlog(state, container) {
//console.log("js1 get "+JSON.stringify(state.llo))
return state.log
return state.log;
},
gettoken (state, container) {
gettoken(state, container) {
//console.log("js1 get "+JSON.stringify(state.llo))
return state.token
return state.token;
},
getllosrc (state, container) {
getllosrc(state, container) {
//console.log("js1 get "+JSON.stringify(state.llo))
return state.llo
return state.llo;
},
getsocketid (state, container) {
getsocketid(state, container) {
//console.log("js1 get "+JSON.stringify(state.llo))
return state.socketid
}
return state.socketid;
},
},
mutations: {
add_log (state, data) {
add_log(state, data) {
//console.log("js1 set "+JSON.stringify(data))
state.log.push(data);
},
setrestapi (state, data) {
setrestapi(state, data) {
//console.log("js1 set "+JSON.stringify(data))
state.restapi=data
state.restapi = data;
},
set_token (state, data) {
set_token(state, data) {
//console.log("js1 set "+JSON.stringify(data))
state.token=data;
state.token = data;
},
rm_log (state, path) {
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))
console.log("js1 setrm " + JSON.stringify(state.log));
//state.log = filterlog;
},
tail_log (state, path) {
tail_log(state, path) {
//console.log("js1 set "+JSON.stringify(data))
state.log = state.log.filter((item) => item.tailed_path !== path).splice(0, 4);
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))
console.log("js1 setrmrmrmrmrmrmrmrm " + JSON.stringify(state.log));
//state.log = filterlog;
},
setmongolog (state, data) {
setmongolog(state, data) {
//console.log("js1 set "+JSON.stringify(data))
state.mongolog.push(data);
//state.log.push(data);
},
rmmongolog (state, data) {
rmmongolog(state, data) {
//console.log("js1 set "+JSON.stringify(data))
state.mongolog = [];
//state.log.push(data);
},
setllo (state, data) {
setllo(state, data) {
//console.log("js1 set "+JSON.stringify(data))
state.llo=data;
state.llo = data;
},
setsocketid (state, data) {
setsocketid(state, data) {
//console.log("js1 set "+JSON.stringify(data))
state.socketid = data;
}
},
},
actions: {
RMmongolog({commit}, value) {
commit('rmmongolog')
RMmongolog({ commit }, value) {
commit("rmmongolog");
},
addlog({commit}, value) {
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)
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) {
setRestapi({ commit }, value) {
//console.log("container "+value)
commit('setrestapi', value.restapi)
commit("setrestapi", value.restapi);
},
settoken({commit}, value) {
settoken({ commit }, value) {
//console.log("container "+value)
commit('set_token', value.token)
commit("set_token", value.token);
},
rmlog({commit}, value) {
rmlog({ commit }, value) {
//console.log("containerirm "+value)
commit('rm_log', value.path)
commit("rm_log", value.path);
},
taillog({commit}, value) {
console.log("containerirm "+value)
commit('tail_log', value.path)
taillog({ commit }, value) {
console.log("containerirm " + value);
commit("tail_log", value.path);
},
async get_data({commit,rootGetters}, value) {
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)
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{
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'
}
ERROR: "yes",
};
return R;
}
}
},
async get_log({commit,rootGetters}, value) {
async get_log({ commit, rootGetters }, value) {
try {
var token = store.getters['pipelineLLO/gettoken'];
var token = store.getters["pipelineLLO/gettoken"];
let p = await axios.get("https://factory.swarmlab.io:55527/get_log", {
timeout: 45000,
@ -155,83 +158,97 @@ export default {
token: token,
start: value.datestart,
end: value.dateend,
swarmlabname: value.swarmlabname
}
swarmlabname: value.swarmlabname,
},
});
//var p = value.code
console.log("paramp-------------------------- "+JSON.stringify(value))
store.dispatch('pipelineLLO/set_mongolog', p)
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{
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'
}
ERROR: "yes",
};
return R;
}
}
},
async hotreload({commit,rootGetters}, value) {
async hotreload({ commit, rootGetters }, value) {
try {
var token = value.token
var token = value.token;
var params = {
swarmlabname: value.swarmlabname
}
swarmlabname: value.swarmlabname,
};
var options = {
headers: { 'content-type': 'application/x-www-form-urlencoded',Authorization: `Bearer ${token}` },
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{
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))
console.log(JSON.stringify(p));
} catch (e) {
if(e.message == "Request failed with status code 401" || /401/i.test(e.message)){
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{
window.location.href = "https://api-login.swarmlab.io:8089";
} else {
var R = {
ERROR_str: e,
ERROR: 'yes'
}
ERROR: "yes",
};
return R;
}
}
},
set_mongolog({commit}, value) {
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
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)
commit("setmongolog", itemobj);
}
},
setScriptllo({commit}, value) {
setScriptllo({ commit }, value) {
//console.log("container "+value)
commit('setllo', value)
commit("setllo", value);
},
setsocketllo({commit}, value) {
setsocketllo({ commit }, value) {
//console.log("container "+value)
commit('setsocketid', value)
commit("setsocketid", value);
},
setScriptCodlogAction({commit}, value) {
setScriptCodlogAction({ commit }, value) {
//console.log("container "+value)
commit('setScriptCodelog', value)
}
}
}
commit("setScriptCodelog", value);
},
},
};

Loading…
Cancel
Save