Browse Source

sort error

master
zeus 3 years ago
parent
commit
f2577977a5
  1. 2
      dist/index.html
  2. 2
      dist/js/app.8f8d6e80.js
  3. 1
      dist/js/app.8f8d6e80.js.map
  4. 2
      dist/js/app.e836f85c.js
  5. 1
      dist/js/app.e836f85c.js.map
  6. 93
      src-local/llo/new.js
  7. 144
      src/components/mynetwork/availablemicroservices.vue
  8. 63
      src/config/index-web.js
  9. 75
      src/store/modules/create_pipelineLLO.js

2
dist/index.html

@ -1 +1 @@
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Vue App</title><link href="/css/app.25658f84.css" rel="preload" as="style"><link href="/css/chunk-vendors.e469b508.css" rel="preload" as="style"><link href="/js/app.8f8d6e80.js" rel="preload" as="script"><link href="/js/chunk-vendors.d8d18fe6.js" rel="preload" as="script"><link href="/css/chunk-vendors.e469b508.css" rel="stylesheet"><link href="/css/app.25658f84.css" rel="stylesheet"></head><body><div id="app"></div><script src="/js/chunk-vendors.d8d18fe6.js"></script><script src="/js/app.8f8d6e80.js"></script></body></html>
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Vue App</title><link href="/css/app.25658f84.css" rel="preload" as="style"><link href="/css/chunk-vendors.e469b508.css" rel="preload" as="style"><link href="/js/app.e836f85c.js" rel="preload" as="script"><link href="/js/chunk-vendors.d8d18fe6.js" rel="preload" as="script"><link href="/css/chunk-vendors.e469b508.css" rel="stylesheet"><link href="/css/app.25658f84.css" rel="stylesheet"></head><body><div id="app"></div><script src="/js/chunk-vendors.d8d18fe6.js"></script><script src="/js/app.e836f85c.js"></script></body></html>

2
dist/js/app.8f8d6e80.js

File diff suppressed because one or more lines are too long

1
dist/js/app.8f8d6e80.js.map

File diff suppressed because one or more lines are too long

2
dist/js/app.e836f85c.js

File diff suppressed because one or more lines are too long

1
dist/js/app.e836f85c.js.map

File diff suppressed because one or more lines are too long

93
src-local/llo/new.js

@ -1027,6 +1027,25 @@ app.get('/buildservices', (req, res, next) => {
});
app.get('/getservicesinfoall', (req, res, next) => {
var RES = new Object();
RES.instance = req.query["instance"]
var servicepath = './instance/'
fs.readdir(servicepath, { withFileTypes: true }, (error, files) => {
const directoriesInDIrectory = files
.filter((item) => item.isDirectory())
.map((item) => item.name);
//console.log(directoriesInDIrectory);
RES.error = false
RES.error_msg = "ok"
RES.data = directoriesInDIrectory;
res.json(RES)
});
});
app.get('/getservicesinfo', (req, res, next) => {
@ -1416,6 +1435,80 @@ app.get('/getservicesstatus', (req, res, next) => {
});
app.get('/getservicesstatusall', (req, res, next) => {
var RES = new Object();
var showexec = `docker ps --format '{"Names":"{{ .Names }}", "Status":"{{.Status}}"}' | jq . -s `
exec(showexec, (err, stdout, stderr) => {
if (err) {
console.error(`exec error: ${err}`);
return;
}
if (stdout) {
var string = stdout.toString()
var datajson = JSON.parse(string);
RES.error = false
RES.error_msg = "ok"
RES.data = datajson;
res.json(RES)
}else{
RES.error = true
RES.error_msg = "no"
RES.data = 'no';
res.json(RES)
}
});
});
app.get('/stopservice', (req, res, next) => {
var RES = new Object();
var service = req.query["instance"]
var services_path = './instance/'+service+'/'+service
var services_pathexec = process.cwd()
var stopeditexec = `/bin/bash ./stop-sidecar-edit-service.sh ${service}`
const stopedit = spawn(stopeditexec, {
stdio: 'pipe',
shell: true,
cwd: services_pathexec
});
stopedit.on('close', function (code) {
const stop = spawn('/bin/sh ./stop.sh', {
stdio: 'pipe',
shell: true,
cwd: services_path
});
stop.stdout.on('data', function (data) {
var n = {}
n.data = data.toString()
io.emit('message_out', n);
});
stop.stderr.on('data', function (data) {
var n = {}
n.data = data.toString()
io.emit('message_err', n);
});
stop.on('close', function (code) {
var n = {}
n.data = code
io.emit('message_close', n);
RES.error = false
RES.error_msg = "ok"
RES.data = 'ok';
res.json(RES)
});
});
});
app.get('/rmbuildstatus', (req, res, next) => {
var RES = new Object();
RES.instance = req.query["instance"]

144
src/components/mynetwork/availablemicroservices.vue

@ -100,6 +100,12 @@
Up</button>
</div>
<div class="input-group-append"
v-if="viewhybridoptions && heavy"
>
<p class="text-danger">{{ heavytext }}</p>
</div>
<div class="white h-100 flex-fixed-width-item"
<vuetable
ref="vuetable"
@ -130,23 +136,29 @@ EDO
props.rowData._id gia to pagination problem
pass props.rowData._id as index
allagi tou vuetablerefresh
<button
class="ti-cloud-down btn btn-outline-secondary btn-sm"
title="Download Lab_Instance"
round
@click="checkactionrowindex(props.rowData,props.rowData._id)">
update</button>
-->
<div slot="actionsenabled" slot-scope="props">
<div class="d-flex justify-content-center">
<button
v-if="testactionrowindex[props.rowData.swarmlabname] == props.rowData._id"
class="ti-thumb-up btn btn-info btn-sm"
title="Stop Lab_Instance"
v-if="testtest[props.rowData.swarmlabname] != props.rowData.swarmlabname && testtestdir[props.rowData.swarmlabname] == props.rowData.swarmlabname"
class="ti-thumb-down btn btn-secondary btn-sm"
title="Start Lab_Instance"
round
@click="onAction('down-item', props.rowData, props.rowData._id)"
@click="onAction('run-item', props.rowData, props.rowData._id)"
>
</button>
<button
v-if="testactionrowindex[props.rowData.swarmlabname] != props.rowData._id && testactionrowindex[props.rowData._id] == props.rowData._id"
class="ti-thumb-down btn btn-secondary btn-sm"
title="Start Lab_Instance"
v-if="testtest[props.rowData.swarmlabname] == props.rowData.swarmlabname && testtestdir[props.rowData.swarmlabname] == props.rowData.swarmlabname"
class="ti-thumb-up btn btn-info btn-sm"
title="Stop Lab_Instance"
round
@click="onAction('run-item', props.rowData, props.rowData._id)"
@click="onAction('down-item', props.rowData, props.rowData._id)"
>
</button>
</div>
@ -155,7 +167,7 @@ allagi tou vuetablerefresh
:key="vuetablekeygslot">
<div class="d-flex justify-content-center">
<button
v-if="testactionrowindex[props.rowData._id] == props.rowData._id && testactionrowindex[props.rowData.swarmlabname] != props.rowData._id"
v-if="testtest[props.rowData.swarmlabname] != props.rowData.swarmlabname && testtestdir[props.rowData.swarmlabname] == props.rowData.swarmlabname"
class="ti-trash btn btn-info btn-sm"
title="Remove Lab_Instance"
@click="onAction('rm-install', props.rowData, props.rowData._id)"
@ -167,7 +179,6 @@ allagi tou vuetablerefresh
<div slot="actions" slot-scope="props">
<div class="d-flex justify-content-center">
<button
v-if="checkactionrowindex(props.rowData,props.rowData._id)"
class="ti-cloud-down btn btn-outline-secondary btn-sm"
title="Download Lab_Instance"
round
@ -224,6 +235,8 @@ export default {
return{
testactionrowindex:[], // downloaded used in installed
teststatusindex:[], // status stop run used in status
testtest:[], // up or down services
testtestdir:[], // install download or not service
hybridoptions: {
'index':'',
'swarmlabname':'',
@ -231,6 +244,8 @@ export default {
'port':''
},
viewhybridoptions: false,
heavy: false,
heavytext: '',
up_name:'',
swarmlab:{},
playbookInfo: {},
@ -349,12 +364,12 @@ export default {
})
})
},
created() {
async created() {
var url_string = window.location.href
var url = new URL(url_string);
this.token = url.searchParams.get("token");
await this.checkactionrowindexall()
//console.log("token "+ this.token);
},
beforeDestroy () {
this.$root.$off('hybrid_refresh_availableservices')
@ -386,6 +401,42 @@ export default {
focusCancel: true,
confirmButtonText: 'Ok!'
})
},
async checkactionrowindexall(){
var obj = {}
obj.token = this.token
obj.instance = 'info'
var res1 = await store.dispatch('pipelineLLO/getservicesstatusall', obj)
if(res1.data.data){
//console.log('resall '+JSON.stringify(res1))
//console.log('resall--- '+JSON.stringify(res1.data.data))
var al = res1.data.data.length;
for (var arrayIndex in this.testtest) {
Vue.delete(this.testtest, this.testtest[arrayIndex])
}
//console.log(this.testtest)
for (let index = 0; index < al; ++index) {
var el = res1.data.data[index];
//console.log(el.Names)
var el1 = el.Names.split('_');
Vue.set(this.testtest, el1[0], el1[0])
}
}
var res2 = await store.dispatch('pipelineLLO/getservicesinfoall', obj)
if(res2.data.data){
//console.log(res2.data.data)
for (var arrayIndex in this.testtestdir) {
Vue.delete(this.testtestdir, this.testtestdir[arrayIndex])
}
//console.log(this.testtestdir)
var all = res2.data.data.length;
for (let index = 0; index < all; ++index) {
var el1a = res2.data.data[index];
//console.log(el1a)
Vue.set(this.testtestdir, el1a, el1a)
}
}
//console.log(this.testtestdir)
},
async checkactionrowindex(data,index){
if(data._id == index) {
@ -402,11 +453,16 @@ export default {
//console.log('res8 all '+JSON.stringify(res1))
if(res1.data.data == 'yes'){
//EDO
Vue.set(this.testactionrowindex, data.swarmlabname, index)
//Vue.set(this.testactionrowindex, data.swarmlabname, data.swarmlabname)
//Vue.set(this.testactionrowindex, data.swarmlabname, index)
Vue.set(this.testactionrowindex, index, data.swarmlabname)
//console.log('running---- '+data.swarmlabname)
//console.log(this.testactionrowindex)
}else{
//console.log('res8 NO '+JSON.stringify(res1.data))
Vue.delete(this.testactionrowindex, data.swarmlabname)
//Vue.delete(this.testactionrowindex, data.swarmlabname)
Vue.delete(this.testactionrowindex, index)
//console.log('NOTrunning---- '+data.swarmlabname)
//console.log(this.testactionrowindex)
}
}else{
var obj = {}
@ -416,25 +472,28 @@ export default {
//console.log('resi YES '+JSON.stringify(res))
if(res.data.data == 'yes'){
//EDO
Vue.set(this.testactionrowindex, index, index)
Vue.set(this.testactionrowindex, index, data.swarmlabname)
var res1 = await store.dispatch('pipelineLLO/getservicesstatus', obj)
//console.log('res8 all '+JSON.stringify(res1))
if(res1.data.data == 'yes'){
//EDO
Vue.set(this.testactionrowindex, data.swarmlabname, index)
//Vue.set(this.testactionrowindex, data.swarmlabname, data.swarmlabname)
Vue.set(this.testactionrowindex, index, data.swarmlabname)
//console.log('running1111111111---- '+data.swarmlabname)
//console.log(this.testactionrowindex)
//console.log('res8 YES '+JSON.stringify(res1.data))
}else{
//console.log('res8 NO '+JSON.stringify(res1.data))
Vue.delete(this.testactionrowindex, data.swarmlabname)
Vue.delete(this.testactionrowindex, index)
//console.log('notrunning1111111111---- '+data.swarmlabname)
//console.log(this.testactionrowindex)
}
//console.log('resiiiiiiii yes '+JSON.stringify(this.testactionrowindex[index]))
}else{
//Vue.delete(this.testactionrowindex, index)
Vue.delete(this.testactionrowindex, index)
//console.log('resi NO2 '+JSON.stringify(res))
}
}
//console.log('string YES '+JSON.stringify(this.testactionrowindex))
//console.log(this.testactionrowindex)
},
setFilter () {
this.moreParams = {
@ -514,10 +573,9 @@ export default {
}else if(action == 'rm-install' ){
this.hybridoptions.swarmlabname = data.swarmlabname
this.$wait.start('myRunInstancetutor');
//console.log(this.hybridoptions.swarmlabname)
var res = await store.dispatch('pipelineLLO/rmswarmlablocal', this.hybridoptions.swarmlabname)
this.$wait.end('myRunInstancetutor');
var obj = {}
obj.token = this.token
obj.instance = data.swarmlabname
@ -544,13 +602,8 @@ export default {
focusCancel: true,
confirmButtonText: 'Ok!'
})
//console.log('inf res11111111111 '+ JSON.stringify(res.data.path))
}
}
//Vue.nextTick( () => this.$refs.vuetable.refresh())
Vue.delete(this.testactionrowindex, data.swarmlabname)
this.refreshVuetable()
this.$root.$emit('hybrid_refresh_info_deploy_local')
}else if(action == 'run-install' ){
@ -577,8 +630,16 @@ export default {
this.refreshVuetable()
}else if(action == 'run-item' ){
this.heavy = false
this.heavytext = ''
this.up_name = data.swarmlabname
//console.log('RUN------------ '+ JSON.stringify(data))
var filtermicrosfot = `microservice-volatilitywindows`
var grepmicrosoft = new RegExp(filtermicrosfot);
var filterju = `microservice-jupyter`
var grepju = new RegExp(filterju);
if(grepju.test(data.swarmlabname)){
@ -589,7 +650,14 @@ export default {
value.size = this.hybridoptions.size
value.port = this.hybridoptions.port
this.$root.$emit('hybrid_start_instance', value)
Vue.set(this.testactionrowindex, value.swarmlabname, value.index)
//Vue.set(this.testactionrowindex, value.swarmlabname, value.index)
//Vue.set(this.testactionrowindex, value.index, value.swarmlabname)
}else if(grepmicrosoft.test(data.swarmlabname)){
this.viewhybridoptions = true
this.heavy = true
this.heavytext = 'Note that this image are somewhat heavy (~2GB) since they embed some of the kernel debug symbols for Microsoft Windows. It can take some time to build the Instance'
this.hybridoptions.swarmlabname = data.swarmlabname
this.hybridoptions.index = index
}else{
this.viewhybridoptions = true
this.hybridoptions.swarmlabname = data.swarmlabname
@ -599,7 +667,6 @@ export default {
console.log('RUN 1 '+ JSON.stringify(data.swarmlabname))
// run on mytable.vue
this.$root.$emit('hybrid_start_instance', data.swarmlabname)
Vue.set(this.testactionrowindex, data.swarmlabname, index)
Vue.nextTick( () => this.$refs.vuetable.refresh())
*/
}
@ -639,10 +706,15 @@ export default {
//console.log('yes')
// run on mytable.vue
var value = this.hybridoptions.swarmlabname
await this.$root.$emit('hybrid_stop_instance', value)
Vue.delete(this.testactionrowindex, this.hybridoptions.index)
//await this.$root.$emit('hybrid_stop_instance', value)
var log = await store.dispatch("pipelineLLO/stopservice",{
token:this.token,
instance:this.hybridoptions.swarmlabname
})
//Vue.delete(this.testactionrowindex, this.hybridoptions.index)
//console.log('down service '+ JSON.stringify(this.hybridoptions.index))
//Vue.nextTick( () => this.$refs.vuetable.refresh())
//console.log(log)
this.refreshVuetable()
}else {
console.log('no')
@ -664,7 +736,8 @@ export default {
//console.log('chown '+ JSON.stringify(this.hybridoptions.swarmlabname))
//console.log('chownlog '+ JSON.stringify(log))
this.$root.$emit('hybrid_start_instance', value)
Vue.set(this.testactionrowindex, value.swarmlabname, value.index)
//Vue.set(this.testactionrowindex, value.swarmlabname, value.index)
//Vue.set(this.testactionrowindex, value.index, value.swarmlabname)
//Vue.nextTick( () => this.$refs.vuetable.refresh())
//Vue.nextTick( () => this.$refs.vuetable.refresh())
this.refreshVuetable()
@ -690,7 +763,10 @@ export default {
//this.indexselect=index
//console.log('error2a '+JSON.stringify(this.dataselect))
//console.log('error2b '+JSON.stringify(this.indexselect))
await this.checkactionrowindex(this.dataselect, this.indexselect)
// this version with this.checkactionrowindex dont work
// render hangs
//await this.checkactionrowindex(this.dataselect, this.indexselect)
await this.checkactionrowindexall()
this.vuetablekeygslot += 1
//})
},

63
src/config/index-web.js

@ -189,5 +189,68 @@ export const ApiConfigWEB = [
"ttyd": true,
"ttydport": "3787/tcp",
"ttydurl": 'http'
},
{
"name": "microservice-powershell",
"app": false,
"url": 'http',
"port": "80/tcp",
"ttyd": true,
"ttydport": "3787/tcp",
"ttydurl": 'http'
},
{
"name": "microservice-dvwa",
"app": true,
"url": 'http',
"port": "80/tcp",
"ttyd": true,
"ttydport": "3787/tcp",
"ttydurl": 'http'
},
{
"name": "microservice-hping3",
"app": false,
"url": 'http',
"port": "80/tcp",
"ttyd": true,
"ttydport": "3787/tcp",
"ttydurl": 'http'
},
{
"name": "microservice-volatilitylinux",
"app": false,
"url": 'http',
"port": "80/tcp",
"ttyd": true,
"ttydport": "3787/tcp",
"ttydurl": 'http'
},
{
"name": "microservice-volatilitywindows",
"app": false,
"url": 'http',
"port": "80/tcp",
"ttyd": true,
"ttydport": "3787/tcp",
"ttydurl": 'http'
},
{
"name": "microservice-twint",
"app": false,
"url": 'http',
"port": "80/tcp",
"ttyd": true,
"ttydport": "3787/tcp",
"ttydurl": 'http'
},
{
"name": "microservice-twintexplorer",
"app": false,
"url": 'http',
"port": "80/tcp",
"ttyd": true,
"ttydport": "3787/tcp",
"ttydurl": 'http'
}
];

75
src/store/modules/create_pipelineLLO.js

@ -915,6 +915,81 @@ export default {
return R;
}
}
},
async getservicesstatusall({commit,rootGetters}, value) {
try {
var token = value.token
var params = {
instance: value.instance
}
var options = {
params: params,
headers: { 'content-type': 'application/x-www-form-urlencoded',Authorization: `Bearer ${token}` },
};
var sock_server_l = ApiConfig.url_80+'/getservicesstatusall'
var p = await axios.get(sock_server_l,options);
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 stopservice({commit,rootGetters}, value) {
try {
var token = value.token
var params = {
instance: value.instance
}
var options = {
params: params,
headers: { 'content-type': 'application/x-www-form-urlencoded',Authorization: `Bearer ${token}` },
};
var sock_server_l = ApiConfig.url_80+'/stopservice'
var p = await axios.get(sock_server_l,options);
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 getservicesinfoall({commit,rootGetters}, value) {
try {
var token = value.token
var params = {
instance: value.instance
}
var options = {
params: params,
headers: { 'content-type': 'application/x-www-form-urlencoded',Authorization: `Bearer ${token}` },
};
var sock_server_l = ApiConfig.url_80+'/getservicesinfoall'
var p = await axios.get(sock_server_l,options);
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 rmbuildstatus({commit,rootGetters}, value) {
//console.log('valuei22222222222222222222222222222222 '+JSON.stringify(value))

Loading…
Cancel
Save