Browse Source

latest

master
lefteris 4 years ago
parent
commit
080d7496a3
  1. 39
      package-lock.json
  2. 1
      package.json
  3. 43
      src/App.vue
  4. 371
      src/components/docgrep/rungrep.vue
  5. 786
      src/components/doclive/AdhocView.vue
  6. 70
      src/components/doclive/runLlo.vue

39
package-lock.json

@ -10872,6 +10872,45 @@
"date-format-parse": "^0.2.6" "date-format-parse": "^0.2.6"
} }
}, },
"vuetable-2": {
"version": "2.0.0-beta.4",
"resolved": "https://registry.npmjs.org/vuetable-2/-/vuetable-2-2.0.0-beta.4.tgz",
"integrity": "sha512-sWSdKIPYiATI9hOuPlQ09iSWEFAfhe6sPovl4hK2SemvqvgxLIF8UjG3LwJJC7idWS9UPpK9fRrSXoFJhRcluQ==",
"requires": {
"axios": "^0.15.3"
},
"dependencies": {
"axios": {
"version": "0.15.3",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.15.3.tgz",
"integrity": "sha1-LJ1jiy4ZGgjqHWzJiOrda6W9wFM=",
"requires": {
"follow-redirects": "1.0.0"
}
},
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"requires": {
"ms": "2.0.0"
}
},
"follow-redirects": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.0.0.tgz",
"integrity": "sha1-jjQpjL0uF28lTv/sdaHHjMhJ/Tc=",
"requires": {
"debug": "^2.2.0"
}
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
}
}
},
"vuex": { "vuex": {
"version": "3.6.0", "version": "3.6.0",
"resolved": "https://registry.npmjs.org/vuex/-/vuex-3.6.0.tgz", "resolved": "https://registry.npmjs.org/vuex/-/vuex-3.6.0.tgz",

1
package.json

@ -32,6 +32,7 @@
"vue-sweetalert2": "^4.1.1", "vue-sweetalert2": "^4.1.1",
"vue-template-compiler": "^2.6.12", "vue-template-compiler": "^2.6.12",
"vue2-datepicker": "^3.8.2", "vue2-datepicker": "^3.8.2",
"vuetable-2": "^2.0.0-beta.4",
"vuex": "^3.6.0" "vuex": "^3.6.0"
}, },
"devDependencies": { "devDependencies": {

43
src/App.vue

@ -77,6 +77,7 @@
<script> <script>
import DocLive from "./components/DocLive.vue"; import DocLive from "./components/DocLive.vue";
import DocGrep from "./components/DocGrep.vue"; import DocGrep from "./components/DocGrep.vue";
import axios from "axios";
import "@/assets/css/themify-icons.css"; import "@/assets/css/themify-icons.css";
export default { export default {
@ -94,12 +95,52 @@ export default {
}, },
mounted() {}, mounted() {},
created() { created() {
var url_string = window.location.href; //var url_string = window.location.href;
//hardcoded token
var url_string =
"https://api-client.swarmlab.io:8088/?token=8ee68923f567ad2fb5835f579c4d74f0cad6b1d1";
var url = new URL(url_string); var url = new URL(url_string);
this.token = url.searchParams.get("token"); this.token = url.searchParams.get("token");
console.log("token " + this.token); console.log("token " + this.token);
//LEFOS === CHECK TOKEN IF VALID ELSE REDIRECT TO GET A NEW ONE
this.checktoken(this.token);
}, },
methods: { methods: {
//LEFOS === CHECK TOKEN IF VALID ELSE REDIRECT TO GET A NEW ONE
async checktoken(value) {
try {
var token = value;
var pipelines = {
source: "ssologin",
};
var params = {
pipeline: pipelines,
};
var options = {
headers: {
"content-type": "application/x-www-form-urlencoded",
Authorization: `Bearer ${token}`,
},
};
var pipelineApi = await axios.post(
"https://api.swarmlab.io/istokenvalidsso",
params,
options
);
return pipelineApi;
} 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";
}
console.error(e);
}
},
saveDocLive() { saveDocLive() {
this.$root.$emit("asciilive_save", "save"); this.$root.$emit("asciilive_save", "save");
}, },

371
src/components/docgrep/rungrep.vue

@ -1,216 +1,205 @@
<template> <template>
<div <div class="runGrep">
class="runGrep" <div class="row">
> <div class="col-12">
<div class="input-group mb-2">
<div class="row"> <div class="input-group-prepend">
<div class="col-12"> <div class="input-group-text">/</div>
<div class="input-group mb-2"> </div>
<div class="input-group-prepend"> <input
<div class="input-group-text">/</div> type="text"
</div> class="form-control"
placeholder="regex"
<input type="text" class="form-control" placeholder="regex" v-model="search.regex"
v-model="search.regex" />
<div class="input-group-append">
<div class="input-group-text">/</div>
<div class="form-control custom-switch">
<input
id="customSwitch1"
type="checkbox"
class="custom-control-input"
v-model="search.case"
/>
<label class="custom-control-label" for="customSwitch1"
>Ignore case</label
> >
<div class="input-group-append">
<div class="input-group-text">/</div>
<div class="form-control custom-switch">
<input
id="customSwitch1"
type="checkbox"
class="custom-control-input"
v-model="search.case"
>
<label class="custom-control-label" for="customSwitch1">Ignore case</label>
</div>
</div>
</div> </div>
</div>
</div> </div>
</div> <!-- row --> </div>
</div>
<div class="row"> <!-- row -->
<div class="col-9">
<div class="input-group mb-2"> <div class="row">
<div class="col-9">
<div class="input-group-prepend"> <div class="input-group mb-2">
<div class="input-group-text">Log</div> <div class="input-group-prepend">
</div> <div class="input-group-text">Log</div>
<input type="text" class="form-control" placeholder="file" </div>
v-model="search.log" <input
> type="text"
<input type="text" class="form-control" placeholder="desc" class="form-control"
v-model="search.desc" placeholder="file"
> v-model="search.log"
</div> />
</div> <!-- col --> <input
type="text"
<div class="col-3"> class="form-control"
<button placeholder="desc"
class="btn btn-outline-secondary" v-model="search.desc"
round />
type="button" </div>
@click="setregex" </div>
> <!-- col -->
Search
</button> <div class="col-3">
</div> <!-- col --> <button
</div> <!-- row --> class="btn btn-outline-secondary"
round
type="button"
<div class="row"> @click="setregex"
<div class="col-12 viewGrep"> >
Search
<table class="table table-hover"> </button>
<thead> </div>
<tr> <!-- col -->
<th scope="col">Action</th> </div>
<th scope="col">Log</th> <!-- row -->
<th scope="col">Regex</th>
<th scope="col">IC</th> <div class="row">
<th scope="col">Desc</th> <div class="col-12 viewGrep">
</tr> <table class="table table-hover">
</thead> <thead>
<tbody <tr>
v-for="item in log" <th scope="col">Action</th>
> <th scope="col">Log</th>
<tr> <th scope="col">Regex</th>
<td <th scope="col">IC</th>
> <th scope="col">Desc</th>
<span class="badge badge-danger badge-pill" </tr>
style="cursor: pointer" </thead>
@click="removeregex(item.id)" <tbody v-for="item in log">
>Remove</span> <tr>
<td>
</td> <span
<td class="badge badge-danger badge-pill"
style="cursor: pointer" style="cursor: pointer"
>{{item.log}}</td> @click="removeregex(item.id)"
<td >Remove</span
style="cursor: pointer" >
>{{item.regex}}</td> </td>
<td <td style="cursor: pointer">{{ item.log }}</td>
style="cursor: pointer" <td style="cursor: pointer">{{ item.regex }}</td>
>{{item.case}}</td> <td style="cursor: pointer">{{ item.case }}</td>
<td <td style="cursor: pointer">{{ item.desc }}</td>
style="cursor: pointer" </tr>
>{{item.desc}}</td> </tbody>
</tr> </table>
</tbody> </div>
</table> <!-- col -->
</div>
</div> <!-- col --> <!-- row -->
</div> <!-- row -->
</div> </div>
</template> </template>
<script> <script>
import {mapState, mapGetters, mapActions,dispatch} from 'vuex' import { mapState, mapGetters, mapActions, dispatch } from "vuex";
import Vue from 'vue' import Vue from "vue";
import store from '@/store/index' import store from "@/store/index";
export default { export default {
components: { components: {},
}, data() {
data () {
return { return {
search:{ search: {
log: '', log: "",
regex: '', regex: "",
desc: '', desc: "",
case: true case: true,
}, },
obj:1, obj: 1,
log:[] log: [],
} };
}, },
methods: { methods: {
removeregex (index){ removeregex(index) {
let ind = this.log.map(item => item.id).indexOf(index) // find index let ind = this.log.map((item) => item.id).indexOf(index); // find index
this.log.splice(ind, 1); this.log.splice(ind, 1);
//console.log(JSON.stringify(index)) //console.log(JSON.stringify(index))
//console.log(JSON.stringify(this.log)) //console.log(JSON.stringify(this.log))
},
setregex() {
var o = {};
o.id = this.obj++;
o.log = this.search.log;
o.regex = this.search.regex;
o.case = this.search.case;
o.desc = this.search.desc;
this.log.push(o);
//console.log(JSON.stringify(this.log))
}, },
setregex (){
var o = {}
o.id = this.obj++
o.log = this.search.log
o.regex = this.search.regex
o.case = this.search.case
o.desc = this.search.desc
this.log.push(o)
//console.log(JSON.stringify(this.log))
}
}, },
mounted() { mounted() {
this.$root.$on('GREP_on_data', (message) => { this.$root.$on("GREP_on_data", (message) => {
this.$nextTick(function () { this.$nextTick(function() {
var regexpath = this.log.filter((item) => item.log === message.log.tailed_path); var regexpath = this.log.filter(
(item) => item.log === message.log.tailed_path
//console.log('regexpath2 '+ JSON.stringify(regexpath)) );
var code = ''
var regexoutput = false; //console.log('regexpath2 '+ JSON.stringify(regexpath))
if (Array.isArray(regexpath) && regexpath.length){ var code = "";
regexoutput = true; var regexoutput = false;
}else{ if (Array.isArray(regexpath) && regexpath.length) {
regexoutput = false; regexoutput = true;
} } else {
if(regexoutput){ regexoutput = false;
}
//var logtmp = store.getters['pipelineLLO/getlog']; if (regexoutput) {
var logtmp = message.log.message //var logtmp = store.getters['pipelineLLO/getlog'];
//var itemlog = '' var logtmp = message.log.message;
code += '' //var itemlog = ''
//itemlog = logtmp.filter(item1 => item1.tailed_path === path); code += "";
//console.log('logtmp22 '+ JSON.stringify(itemlog)) //itemlog = logtmp.filter(item1 => item1.tailed_path === path);
for (let regex of regexpath) { //console.log('logtmp22 '+ JSON.stringify(itemlog))
//console.log(regex.regex) for (let regex of regexpath) {
if( regex.case){ //console.log(regex.regex)
var re = new RegExp(regex.regex, 'i'); if (regex.case) {
//console.log("true"); var re = new RegExp(regex.regex, "i");
}else{ //console.log("true");
var re = new RegExp(regex.regex); } else {
//console.log("false"); var re = new RegExp(regex.regex);
} //console.log("false");
if (re.test(logtmp)) {
code += logtmp + ' ' + message.log.tailed_path
code += "\n"
// -------------------------------------
// send to grep rungrep to view
// -------------------------------------
this.$root.$emit('GREP_view_data',code)
} else {
console.log("Not found");
}
}
} }
if (re.test(logtmp)) {
}) code += logtmp + " " + message.log.tailed_path;
}) code += "\n";
// -------------------------------------
// send to grep rungrep to view
// -------------------------------------
this.$root.$emit("GREP_view_data", code);
} else {
console.log("Not found");
}
}
}
});
});
},
beforeDestroy() {
this.$root.$off("GREP_on_data");
}, },
beforeDestroy () {
this.$root.$off('GREP_on_data')
}
}; };
</script> </script>
<style> <style>
.runGrep { .runGrep {
font-family: monospace; font-family: monospace;
height: 350px; height: 350px;
} }
.viewGrep { .viewGrep {
height:300px; height: 300px;
overflow-y:auto; overflow-y: auto;
} }
</style> </style>

786
src/components/doclive/AdhocView.vue

@ -1,15 +1,11 @@
<template> <template>
<div> <div>
<b-row no-gutters w-100 h-100 v-if="showlloedit">
<b-row no-gutters w-100 h-100 <b-col cols="12" sm="12" md="12">
v-if="showlloedit" <b-row>
> <b-col cols="4">
<b-col cols="12" sm="12" md="12" > <div class="input-group input-group-sm sm-3">
<!--
<b-row >
<b-col cols="4">
<div class="input-group input-group-sm sm-3">
<!--
<select <select
class="custom-select custom-select-sm " class="custom-select custom-select-sm "
@change="setKeymap" @change="setKeymap"
@ -29,64 +25,81 @@
i</button> i</button>
</div> </div>
--> -->
</div> </div>
</b-col> </b-col>
<b-col cols="3"> <b-col cols="3">
<div class="input-group input-group-sm sm-3"> <div class="input-group input-group-sm sm-3">
<button type="button" <button
round type="button"
disable round
class="btn btn-outline-info btn-sm" disable
v-if="socketonline" class="btn btn-outline-info btn-sm"
@click="socketconnect" v-if="socketonline"
> @click="socketconnect"
online </button> >
<button type="button" online
round </button>
class="btn btn-outline-info btn-sm" <button
v-else type="button"
@click="socketconnect" round
> class="btn btn-outline-info btn-sm"
socket disconnected</button> v-else
<button type="button" @click="socketconnect"
round >
class="btn btn-outline-info btn-sm" socket disconnected
v-if="socketonline" </button>
@click="hotreload()"> <button
Hot_Reload</button> type="button"
</div> round
</b-col> class="btn btn-outline-info btn-sm"
v-if="socketonline"
<b-col cols="5" > @click="hotreload()"
<div class="input-group input-group-sm d-flex justify-content-end"> >
</div> Hot_Reload
<div class="input-group input-group-sm d-flex justify-content-end"> </button>
<div class="input-group-append"> </div>
<button type="button" </b-col>
round
class="btn btn-outline-warning btn-sm" <b-col cols="5">
v-if="socketonline" <div
@click="infoHotreload()"> class="input-group input-group-sm d-flex justify-content-end"
Hot_Reload_HowTo</button> ></div>
</div> <div class="input-group input-group-sm d-flex justify-content-end">
<div class="input-group-append"> <div class="input-group-append">
<button type="button" <button
round type="button"
class="btn btn-outline-warning btn-sm" round
v-if="tryConsole" class="btn btn-outline-warning btn-sm"
@click="clear()"> v-if="socketonline"
Clear</button> @click="infoHotreload()"
</div> >
<div class="input-group-append"> Hot_Reload_HowTo
<button type="button" </button>
round </div>
class="btn btn-outline-info btn-sm" <div class="input-group-append">
v-if="cmOptions.keyMap == 'sublime'" <button
@click="infoFilter"> type="button"
i</button> round
</div> class="btn btn-outline-warning btn-sm"
<!-- v-if="tryConsole"
@click="clear()"
>
Clear
</button>
</div>
<div class="input-group-append">
<button
type="button"
round
class="btn btn-outline-info btn-sm"
v-if="cmOptions.keyMap == 'sublime'"
@click="infoFilter"
>
i
</button>
</div>
<!--
<div class="input-group-append"> <div class="input-group-append">
<button <button
type="button" type="button"
@ -96,278 +109,273 @@
>Create task!</button> >Create task!</button>
</div> </div>
--> -->
</div> </div>
</b-col> </b-col>
</b-row>
<div class="codemirror" >
<codemirror
ref="myCm"
:value="code"
:options="cmOptions"
@cursorActivity="onCmCursorActivity"
@ready="onCmReady"
@focus="onCmFocus"
@input="onCmCodeChange"
></codemirror>
</div>
</b-col>
</b-row> </b-row>
<div class="codemirror">
<codemirror
</div> ref="myCm"
:value="code"
:options="cmOptions"
@cursorActivity="onCmCursorActivity"
@ready="onCmReady"
@focus="onCmFocus"
@input="onCmCodeChange"
></codemirror>
</div>
</b-col>
</b-row>
</div>
</template> </template>
<script> <script>
import {mapState, mapGetters, mapActions,dispatch} from 'vuex' import { mapState, mapGetters, mapActions, dispatch } from "vuex";
import Vue from 'vue' import Vue from "vue";
import store from '@/store/index' import store from "@/store/index";
import { codemirror } from "vue-codemirror";
import { codemirror } from 'vue-codemirror' import JSZip from "jszip";
import JSZip from 'jszip'; import FileSaver from "file-saver";
import FileSaver from 'file-saver'; import "codemirror/lib/codemirror.css";
import 'codemirror/lib/codemirror.css' import "codemirror/theme/neat.css";
import 'codemirror/theme/neat.css' import "codemirror/theme/paraiso-light.css";
import 'codemirror/theme/paraiso-light.css' import "codemirror/addon/selection/active-line.js";
import'codemirror/addon/selection/active-line.js'
import "codemirror/addon/hint/show-hint.js";
import'codemirror/addon/hint/show-hint.js' import "codemirror/addon/hint/show-hint.css";
import'codemirror/addon/hint/show-hint.css' import "codemirror/addon/hint/javascript-hint.js";
import'codemirror/addon/hint/javascript-hint.js' import "codemirror/addon/selection/active-line.js";
import'codemirror/addon/selection/active-line.js' import "codemirror/addon/scroll/annotatescrollbar.js";
import'codemirror/addon/scroll/annotatescrollbar.js' import "codemirror/addon/search/matchesonscrollbar.js";
import'codemirror/addon/search/matchesonscrollbar.js' import "codemirror/addon/search/searchcursor.js";
import'codemirror/addon/search/searchcursor.js' import "codemirror/addon/search/match-highlighter.js";
import'codemirror/addon/search/match-highlighter.js'
import "codemirror/mode/shell/shell.js";
import'codemirror/mode/shell/shell.js' import "codemirror/addon/edit/matchbrackets.js";
import'codemirror/addon/edit/matchbrackets.js' import "codemirror/addon/comment/comment.js";
import'codemirror/addon/comment/comment.js' import "codemirror/addon/dialog/dialog.js";
import'codemirror/addon/dialog/dialog.js' import "codemirror/addon/dialog/dialog.css";
import'codemirror/addon/dialog/dialog.css' import "codemirror/addon/search/searchcursor.js";
import'codemirror/addon/search/searchcursor.js' import "codemirror/addon/search/search.js";
import'codemirror/addon/search/search.js' import "codemirror/keymap/sublime.js";
import'codemirror/keymap/sublime.js' import "codemirror/keymap/vim.js";
import'codemirror/keymap/vim.js'
import "codemirror/addon/fold/foldgutter.css";
import'codemirror/addon/fold/foldgutter.css' import "codemirror/addon/fold/brace-fold.js";
import'codemirror/addon/fold/brace-fold.js' import "codemirror/addon/fold/comment-fold.js";
import'codemirror/addon/fold/comment-fold.js' import "codemirror/addon/fold/foldcode.js";
import'codemirror/addon/fold/foldcode.js' import "codemirror/addon/fold/foldgutter.js";
import'codemirror/addon/fold/foldgutter.js' import "codemirror/addon/fold/indent-fold.js";
import'codemirror/addon/fold/indent-fold.js' import "codemirror/addon/fold/markdown-fold.js";
import'codemirror/addon/fold/markdown-fold.js' import "codemirror/addon/fold/xml-fold.js";
import'codemirror/addon/fold/xml-fold.js' import "codemirror/lib/codemirror";
import 'codemirror/lib/codemirror'; import "codemirror/addon/display/placeholder";
import 'codemirror/addon/display/placeholder';
export default { export default {
components: { components: {
codemirror codemirror,
}, },
data () { data() {
return { return {
socketonline:false, socketonline: false,
tryConsole:false, tryConsole: false,
ssl:{}, ssl: {},
getinfo:'', getinfo: "",
token:'', token: "",
swarmlabname:'', swarmlabname: "",
code: '', code: "",
editchoice: '', editchoice: "",
optionsedit: [ optionsedit: [
{ text: 'code', value: 'code' }, { text: "code", value: "code" },
{ text: 'text', value: 'text' } { text: "text", value: "text" },
], ],
llodesc:[{ llodesc: [
llo_url : '', {
llo_name : '', llo_url: "",
llo_author : '', llo_name: "",
llo_intro : '' llo_author: "",
}], llo_intro: "",
llo:[{ },
id : 0, ],
rm : false, llo: [
data_info : 'Asciidoc \n', {
data_code : '#Your source code', id: 0,
data_service : '', rm: false,
code_datafile : 'url', data_info: "Asciidoc \n",
code_name : '', data_code: "#Your source code",
code_exec : '', data_service: "",
code_options : '', code_datafile: "url",
code_mime : '', code_name: "",
code_info : '', code_exec: "",
code_code : '', code_options: "",
code_codeout : '', code_mime: "",
code_codeoutput : 'console', code_info: "",
points : '', code_code: "",
challenge_question : '', code_codeout: "",
code_challenge_question : '', code_codeoutput: "console",
challenge_answer : '', points: "",
challenge_answer_hint : '', challenge_question: "",
code_challenge_answer_hint : '', code_challenge_question: "",
challenge_answer_source : '', challenge_answer: "",
challenge_answer_code_out : '', challenge_answer_hint: "",
challenge_answer_code : '', code_challenge_answer_hint: "",
code_challenge_answer_code : '' challenge_answer_source: "",
}], challenge_answer_code_out: "",
searchLLO: [], challenge_answer_code: "",
searchLLOactive : false, code_challenge_answer_code: "",
ADOC_html_code:'', },
challenge:[], ],
action:'', searchLLO: [],
tryLLO:[], searchLLOactive: false,
service:'os2', ADOC_html_code: "",
active:0, challenge: [],
activecount:0, action: "",
remove:'', tryLLO: [],
activeField:'', service: "os2",
bootstrap:false, active: 0,
firstbootstrap:0, activecount: 0,
htmlasciitmp:'', remove: "",
datafile: 'https://git.swarmlab.io:3000/labs/examples-mpi2/raw/branch/master/0_netstat/data', activeField: "",
datadir: '0_netstat/data', bootstrap: false,
LearningObject:'', firstbootstrap: 0,
showllo:true, htmlasciitmp: "",
showlloedit:true, datafile:
selected: 'sublime', "https://git.swarmlab.io:3000/labs/examples-mpi2/raw/branch/master/0_netstat/data",
options: [ datadir: "0_netstat/data",
{ text: 'vim', value: 'vim' }, LearningObject: "",
{ text: 'sublime', value: 'sublime' } showllo: true,
], showlloedit: true,
optionsmime: [ selected: "sublime",
{ text: 'sh', value: 'bash' }, options: [
{ text: 'javascript', value: 'javascript' }, { text: "vim", value: "vim" },
{ text: 'python', value: 'python' }, { text: "sublime", value: "sublime" },
{ text: 'php', value: 'php' }, ],
{ text: 'sql', value: 'sq;' }, optionsmime: [
{ text: 'xml', value: 'xml' }, { text: "sh", value: "bash" },
{ text: 'c', value: 'c' } { text: "javascript", value: "javascript" },
], { text: "python", value: "python" },
pValidate: false, { text: "php", value: "php" },
cmOptions: { { text: "sql", value: "sq;" },
tabSize: 2, { text: "xml", value: "xml" },
styleActiveLine: true, { text: "c", value: "c" },
lineNumbers: true, ],
lineSeparator:'\n', pValidate: false,
line: true, cmOptions: {
foldGutter: true, tabSize: 2,
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"], styleActiveLine: true,
highlightSelectionMatches: { showToken: /\w/, annotateScrollbar: true }, lineNumbers: true,
styleSelectedText: true, lineSeparator: "\n",
mode: 'shell', line: true,
hintOptions:{ foldGutter: true,
completeSingle: false gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
}, highlightSelectionMatches: { showToken: /\w/, annotateScrollbar: true },
keyMap: "sublime", styleSelectedText: true,
//keyMap: "vim", mode: "shell",
matchBrackets: true, hintOptions: {
showCursorWhenSelecting: true, completeSingle: false,
indentUnit:this.ADOC_html_code, },
lineWrapping: true, keyMap: "sublime",
//theme: 'neat', //keyMap: "vim",
theme: 'paraiso-light', matchBrackets: true,
refresh:true, showCursorWhenSelecting: true,
readOnly: true, indentUnit: this.ADOC_html_code,
autofocus: false, lineWrapping: true,
extraKeys: { "Ctrl": "autocomplete" } //theme: 'neat',
}, theme: "paraiso-light",
ADOC_html:[] refresh: true,
} readOnly: true,
autofocus: false,
extraKeys: { Ctrl: "autocomplete" },
},
ADOC_html: [],
};
}, },
methods: { methods: {
socketconnect() {
socketconnect () { // send to runLLO
// send to runLLO this.$root.$emit("SERVER_socket_connect");
this.$root.$emit('SERVER_socket_connect') },
}, clear() {
clear () { this.tryConsole = false;
this.tryConsole = false this.code = "";
this.code = ''
},
async getdata () {
var field = this.getinfo
var log = await store.dispatch("pipelineLLO/get_data",{
code:field
})
},
async showactive(index) {
this.topwindow(index)
},
onCmReady(cm) {
cm.on('change', (cm, chg) => {
}),
cm.on('keypress', () => {
cm.showHint({completeSingle:false})
})
}, },
onCmCursorActivity(a, b, c) { async getdata() {
var field = this.getinfo;
var log = await store.dispatch("pipelineLLO/get_data", {
code: field,
});
}, },
onCmFocus(cm) {
async showactive(index) {
this.topwindow(index);
}, },
onCmReady(cm) {
cm.on("change", (cm, chg) => {}),
cm.on("keypress", () => {
cm.showHint({ completeSingle: false });
});
},
onCmCursorActivity(a, b, c) {},
onCmFocus(cm) {},
onCmCodeChange(newCode) { onCmCodeChange(newCode) {
this.code = newCode this.code = newCode;
//this.$root.$emit('socket_add',this.code) //this.$root.$emit('socket_add',this.code)
}, },
handleChange() { handleChange() {},
setKeymap() {
this.cmOptions.keyMap = this.selected;
}, },
setKeymap () { infoFilter() {
this.cmOptions.keyMap = this.selected var title1 = "<h3>Playbook Images</h3>";
var winfop =
'<table class="table table-striped table-sm ">' +
'<tr><td class="text-left">Shift-Tab</td> <td class="text-left">indentLess</td></tr>' +
'<tr><td class="text-left">Alt-Q</td> <td class="text-left">wrapLines</td></tr>' +
'<tr><td class="text-left">Ctrl-Up</td> <td class="text-left">scrollLineUp</td></tr>' +
'<tr><td class="text-left">Ctrl-Down</td> <td class="text-left">scrollLineDown</td></tr>' +
'<tr><td class="text-left">Ctrl-L</td> <td class="text-left">selectLine</td></tr>' +
'<tr><td class="text-left">Esc</td> <td class="text-left">singleSelectionTop</td></tr>' +
'<tr><td class="text-left">Ctrl-Enter</td> <td class="text-left">insertLineAfter</td></tr>' +
'<tr><td class="text-left">Ctrl-D</td> <td class="text-left">selectNextOccurrence</td></tr>' +
'<tr><td class="text-left">Shift-Ctrl-Space</td> <td class="text-left">selectScope</td></tr>' +
'<tr><td class="text-left">Shift-Ctrl-M</td> <td class="text-left">selectBetweenBrackets</td></tr>' +
'<tr><td class="text-left">Ctrl-M</td> <td class="text-left">goToBracket</td></tr>' +
'<tr><td class="text-left">Ctrl-K Ctrl-Y</td> <td class="text-left">sublimeYank</td></tr>' +
'<tr><td class="text-left">Ctrl-K Ctrl-C</td> <td class="text-left">showInCenter</td></tr>' +
'<tr><td class="text-left">Ctrl-K Ctrl-G</td> <td class="text-left">clearBookmarks</td></tr>' +
'<tr><td class="text-left">Ctrl-K Ctrl-Backspace</td> <td class="text-left">delLineLeft</td></tr>' +
'<tr><td class="text-left">Ctrl-K Ctrl-0</td> <td class="text-left">unfoldAll</td></tr>' +
'<tr><td class="text-left">Ctrl-K Ctrl-J</td> <td class="text-left">unfoldAll</td></tr>' +
'<tr><td class="text-left">Ctrl-Alt-Up</td> <td class="text-left">addCursorToPrevLine</td></tr>' +
'<tr><td class="text-left">Ctrl-Alt-Down</td> <td class="text-left">addCursorToNextLine</td></tr>' +
'<tr><td class="text-left">Ctrl-F3</td> <td class="text-left">findUnder</td></tr>' +
'<tr><td class="text-left">Shift-Ctrl-F3</td> <td class="text-left">findUnderPrevious</td></tr>' +
'<tr><td class="text-left">Shift-Ctrl-[</td> <td class="text-left">fold</td></tr>' +
'<tr><td class="text-left">Shift-Ctrl-]</td> <td class="text-left">unfold</td></tr>' +
'<tr><td class="text-left">Ctrl-F</td> <td class="text-left">find</td></tr>' +
"</table>";
var title1 = "";
var winfo = "";
this.$swal({
title: "<strong>Key bindings</strong>",
type: "info",
html: winfop + title1 + winfo,
showCloseButton: true,
showLoaderOnConfirm: false,
allowOutsideClick: false,
});
}, },
infoFilter() {
var title1='<h3>Playbook Images</h3>'
var winfop='<table class="table table-striped table-sm ">'+
'<tr><td class="text-left">Shift-Tab</td> <td class="text-left">indentLess</td></tr>'+
'<tr><td class="text-left">Alt-Q</td> <td class="text-left">wrapLines</td></tr>'+
'<tr><td class="text-left">Ctrl-Up</td> <td class="text-left">scrollLineUp</td></tr>'+
'<tr><td class="text-left">Ctrl-Down</td> <td class="text-left">scrollLineDown</td></tr>'+
'<tr><td class="text-left">Ctrl-L</td> <td class="text-left">selectLine</td></tr>'+
'<tr><td class="text-left">Esc</td> <td class="text-left">singleSelectionTop</td></tr>'+
'<tr><td class="text-left">Ctrl-Enter</td> <td class="text-left">insertLineAfter</td></tr>'+
'<tr><td class="text-left">Ctrl-D</td> <td class="text-left">selectNextOccurrence</td></tr>'+
'<tr><td class="text-left">Shift-Ctrl-Space</td> <td class="text-left">selectScope</td></tr>'+
'<tr><td class="text-left">Shift-Ctrl-M</td> <td class="text-left">selectBetweenBrackets</td></tr>'+
'<tr><td class="text-left">Ctrl-M</td> <td class="text-left">goToBracket</td></tr>'+
'<tr><td class="text-left">Ctrl-K Ctrl-Y</td> <td class="text-left">sublimeYank</td></tr>'+
'<tr><td class="text-left">Ctrl-K Ctrl-C</td> <td class="text-left">showInCenter</td></tr>'+
'<tr><td class="text-left">Ctrl-K Ctrl-G</td> <td class="text-left">clearBookmarks</td></tr>'+
'<tr><td class="text-left">Ctrl-K Ctrl-Backspace</td> <td class="text-left">delLineLeft</td></tr>'+
'<tr><td class="text-left">Ctrl-K Ctrl-0</td> <td class="text-left">unfoldAll</td></tr>'+
'<tr><td class="text-left">Ctrl-K Ctrl-J</td> <td class="text-left">unfoldAll</td></tr>'+
'<tr><td class="text-left">Ctrl-Alt-Up</td> <td class="text-left">addCursorToPrevLine</td></tr>'+
'<tr><td class="text-left">Ctrl-Alt-Down</td> <td class="text-left">addCursorToNextLine</td></tr>'+
'<tr><td class="text-left">Ctrl-F3</td> <td class="text-left">findUnder</td></tr>'+
'<tr><td class="text-left">Shift-Ctrl-F3</td> <td class="text-left">findUnderPrevious</td></tr>'+
'<tr><td class="text-left">Shift-Ctrl-[</td> <td class="text-left">fold</td></tr>'+
'<tr><td class="text-left">Shift-Ctrl-]</td> <td class="text-left">unfold</td></tr>'+
'<tr><td class="text-left">Ctrl-F</td> <td class="text-left">find</td></tr>'+
'</table>'
var title1=''
var winfo=''
this.$swal({
title: '<strong>Key bindings</strong>',
type: 'info',
html: winfop+title1+winfo,
showCloseButton: true,
showLoaderOnConfirm: false,
allowOutsideClick: false
})
},
async hotreload() { async hotreload() {
var field = this.getinfo var field = this.getinfo;
var log = await store.dispatch("pipelineLLO/hotreload",{ var log = await store.dispatch("pipelineLLO/hotreload", {
token:this.token, token: this.token,
swarmlabname:this.swarmlabname swarmlabname: this.swarmlabname,
}) });
}, },
infoHotreload() { infoHotreload() {
var html1 = ` <div style="overflow-x: auto;"> <table class="table table-striped table-sm "> var html1 = ` <div style="overflow-x: auto;"> <table class="table table-striped table-sm ">
<thead> <thead>
<tr> <tr>
<th></th> <th></th>
@ -406,63 +414,57 @@ export default {
<td class="text-left" colspan="2"><i>Execute script every time you run git push</i></td> <td class="text-left" colspan="2"><i>Execute script every time you run git push</i></td>
</tr> </tr>
</tbody> </tbody>
</table></div>` </table></div>`;
this.$swal({
title: "<strong>HowTo</strong>",
this.$swal({ type: "info",
title: '<strong>HowTo</strong>', html: html1,
type: 'info', showCloseButton: true,
html: html1, showLoaderOnConfirm: false,
showCloseButton: true, allowOutsideClick: false,
showLoaderOnConfirm: false, });
allowOutsideClick: false },
})
}
}, },
computed: { computed: {
codemirror() { codemirror() {
return this.$refs.myCm.codemirror return this.$refs.myCm.codemirror;
} },
},
}, mounted() {
mounted() {
// from runLLO // from runLLO
this.$root.$on('SERVER_socket_status', (v) => { this.$root.$on("SERVER_socket_status", (v) => {
this.$nextTick(function () { this.$nextTick(function() {
if(v == 'off'){ if (v == "off") {
this.socketonline = false this.socketonline = false;
}else if(v == 'on'){ } else if (v == "on") {
this.socketonline = true this.socketonline = true;
} }
}) });
}) });
// from runLLO // from runLLO
this.$root.$on('playground_log_in', (path) => { this.$root.$on("playground_log_in", (path) => {
//this.$nextTick(function () { //this.$nextTick(function () {
var restapi = store.getters['pipelineLLO/getrestapi']; var restapi = store.getters["pipelineLLO/getrestapi"];
if(restapi == "off"){ // rest off ara socket if (restapi == "off") {
var logtmp = store.getters['pipelineLLO/getlog']; // rest off ara socket
}else if(restapi == "on"){ // rest on ara read from rest not from socket var logtmp = store.getters["pipelineLLO/getlog"];
var logtmp = store.getters['pipelineLLO/getmongolog']; } else if (restapi == "on") {
} // rest on ara read from rest not from socket
console.log('logtmp-roi '+ JSON.stringify(logtmp)) var logtmp = store.getters["pipelineLLO/getmongolog"];
var itemlog = '' }
this.code = '' console.log("logtmp-roi " + JSON.stringify(logtmp));
itemlog = logtmp.filter(item1 => item1.tailed_path === path); var itemlog = "";
//Vue.set(this.log_path_lenght, item, loglenght); this.code = "";
console.log('logtmp22 '+ JSON.stringify(itemlog)) itemlog = logtmp.filter((item1) => item1.tailed_path === path);
for (let iteml of itemlog) { //Vue.set(this.log_path_lenght, item, loglenght);
this.code += iteml.message console.log("logtmp22 " + JSON.stringify(itemlog));
+ ' ' for (let iteml of itemlog) {
+ iteml.tailed_path this.code += iteml.message + " " + iteml.tailed_path + " " + iteml.date;
+ ' '
+ iteml.date this.code += "\n";
}
this.code += "\n" /*
}
/*
for (let itemlog of logtmp) { for (let itemlog of logtmp) {
//console.log('logtmp '+ JSON.stringify(itemlog)) //console.log('logtmp '+ JSON.stringify(itemlog))
this.code += itemlog.message this.code += itemlog.message
@ -487,32 +489,36 @@ export default {
} }
*/ */
//this.code += v //this.code += v
//this.code += "\n" //this.code += "\n"
this.$refs.myCm.codemirror.setCursor(this.$refs.myCm.codemirror.lineCount(), 0); this.$refs.myCm.codemirror.setCursor(
this.tryConsole=true this.$refs.myCm.codemirror.lineCount(),
//}) 0
}) );
this.tryConsole = true;
//})
});
},
beforeDestroy() {
this.$root.$off("SERVER_socket_status");
this.$root.$off("playground_log_in");
},
}, created() {
beforeDestroy () { //LEFOS TOKEN ====
this.$root.$off('SERVER_socket_status') //this.token = new URL(location.href).searchParams.get("token");
this.$root.$off('playground_log_in') this.token = new URL(
}, "https://api-client.swarmlab.io:8088/?token=8ee68923f567ad2fb5835f579c4d74f0cad6b1d1"
).searchParams.get("token");
created () { this.swarmlabname = new URL(location.href).searchParams.get("pipelinename");
this.token = new URL(location.href).searchParams.get('token'); },
this.swarmlabname = new URL(location.href).searchParams.get('pipelinename');
}
}; };
</script> </script>
<style> <style>
.CodeMirror { .CodeMirror {
font-family: monospace;
height: 550px;
font-family: monospace;
height: 550px;
} }
</style> </style>

70
src/components/doclive/runLlo.vue

@ -149,8 +149,26 @@
<div class="col-1"></div> <div class="col-1"></div>
<!-- col --> <!-- col -->
<vuetable
ref="vuetable"
:api-mode="false"
:data="localData"
:fields="['message', 'timestamp', 'type', 'process_id', 'app_name']"
>
</vuetable>
</div> </div>
<!-- row --> <!-- row -->
<!-- <vuetable
ref="vuetable"
api-url="https://localhost:3000/test"
:api-mode="true"
:http-options="httpOptions"
:fields="['message', 'timestamp', 'type', 'process_id', 'app_name']"
data-path=""
pagination-path=""
>
</vuetable> -->
<div class="row rowlog overflow-auto"> <div class="row rowlog overflow-auto">
<div class="col-12" v-for="item in log_path"> <div class="col-12" v-for="item in log_path">
@ -195,9 +213,12 @@ import DatePicker from "vue2-datepicker";
import "vue2-datepicker/index.css"; import "vue2-datepicker/index.css";
import { DateTime } from "luxon"; import { DateTime } from "luxon";
import FileSaver from "file-saver"; import FileSaver from "file-saver";
import Vuetable from "vuetable-2";
import axios from "axios";
export default { export default {
components: { components: {
Vuetable,
DatePicker, DatePicker,
}, },
data() { data() {
@ -225,6 +246,7 @@ export default {
logintoken: "", logintoken: "",
code: [], code: [],
logdata: [], logdata: [],
localData: [],
}; };
}, },
methods: { methods: {
@ -332,8 +354,7 @@ export default {
async socketauthenticate() { async socketauthenticate() {
var tokentmp = store.getters["pipelineLLO/gettoken"]; var tokentmp = store.getters["pipelineLLO/gettoken"];
// pernaw hardcoded to token // pernaw hardcoded to token
var test = "cd2189ebbef3f0b43c5e73fac1cfb7e8cbe0d47c"; this.$socket.client.emit("authenticate", tokentmp);
this.$socket.client.emit("authenticate", test);
}, },
async socketreconnect() { async socketreconnect() {
var log = await this.socketopen(); var log = await this.socketopen();
@ -354,11 +375,18 @@ export default {
this.$socket.client.close(); this.$socket.client.close();
}, },
}, },
computed: {}, computed: {
httpOptions() {
var token = store.getters["pipelineLLO/gettoken"];
var p = "headers: {Authorization: token}}"; //table props -> :http-options="httpOptions"
return { headers: { Authorization: "Bearer " + token } }; //table props -> :http-options="httpOptions"
},
},
beforeMount() { beforeMount() {
this.socketauthenticate(); this.socketauthenticate();
console.log("send1"); console.log("send1");
}, },
/** /**
* *
* == Socket subscribe * == Socket subscribe
@ -420,14 +448,16 @@ export default {
*/ */
created() { created() {
this.socketopen(); //var logintoken = new URL(location.href).searchParams.get("token");
var logintoken = new URL(location.href).searchParams.get("token"); var logintoken = new URL(
// hardcoded token "https://api-client.swarmlab.io:8088/?token=8ee68923f567ad2fb5835f579c4d74f0cad6b1d1"
var hardtoken = "cd2189ebbef3f0b43c5e73fac1cfb7e8cbe0d47c"; ).searchParams.get("token");
this.logintoken = logintoken;
var log = store.dispatch("pipelineLLO/settoken", { var log = store.dispatch("pipelineLLO/settoken", {
token: hardtoken, token: logintoken,
}); });
this.socketopen();
//var tokentmp =store.getters['pipelineLLO/gettoken']; //var tokentmp =store.getters['pipelineLLO/gettoken'];
//console.log("tokennnn "+tokentmp); //console.log("tokennnn "+tokentmp);
}, },
@ -443,10 +473,8 @@ export default {
*/ */
sockets: { sockets: {
connect() { connect() {
//hardtoken var logintoken = store.getters["pipelineLLO/gettoken"];
var hardtoken = "cd2189ebbef3f0b43c5e73fac1cfb7e8cbe0d47c"; this.$socket.client.emit("authenticate", logintoken);
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 username = 'username'
@ -665,15 +693,27 @@ export default {
console.log(" socket message " + JSON.stringify(val)); console.log(" socket message " + JSON.stringify(val));
}, },
async logsend(val) { async logsend(val) {
// ==== LEFOS
console.log(" socket message " + JSON.stringify(val)); console.log(" socket message " + JSON.stringify(val));
var log = val.log;
console.log(" LOG: " + JSON.parse(JSON.stringify(log))); // var log = val.log;
// console.log(" LOG: " + JSON.parse(JSON.stringify(log)));
var log = store.dispatch("pipelineLLO/addlog", {
log: val,
});
this.localData.push(val);
}, },
}, },
}; };
</script> </script>
<style> <style>
.table {
overflow: scroll;
max-height: 400px;
}
.CodeMirror { .CodeMirror {
font-family: monospace; font-family: monospace;
height: 750px; height: 750px;

Loading…
Cancel
Save