Browse Source

editor 1

master
zeus 3 years ago
parent
commit
53b352ccea
  1. 2
      dist/index.html
  2. 2
      dist/js/app.2008b35a.js
  3. 1
      dist/js/app.2008b35a.js.map
  4. 2
      dist/js/app.47b8cfe9.js
  5. 1
      dist/js/app.47b8cfe9.js.map
  6. 113
      src-local/llo/new.js
  7. 4
      src-local/swarmlab_editor_service
  8. 17
      src-local/swarmlab_editor_service.sh
  9. 52
      src/components/mynetwork/mytable.vue
  10. 21
      src/config/index-editor.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.2008b35a.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.2008b35a.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.47b8cfe9.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.47b8cfe9.js"></script></body></html>

2
dist/js/app.2008b35a.js

File diff suppressed because one or more lines are too long

1
dist/js/app.2008b35a.js.map

File diff suppressed because one or more lines are too long

2
dist/js/app.47b8cfe9.js

File diff suppressed because one or more lines are too long

1
dist/js/app.47b8cfe9.js.map

File diff suppressed because one or more lines are too long

113
src-local/llo/new.js

@ -1516,25 +1516,94 @@ app.get('/runeditor', (req, res, next) => {
RES.instance = req.query["instance"] RES.instance = req.query["instance"]
RES.error = false RES.error = false
RES.error_msg = "ok" RES.error_msg = "ok"
RES.error_msg0 = ""
RES.data = "All_services_are_running"; RES.data = "All_services_are_running";
var showexec = `./swarmlab_editor_service.sh ${RES.instance}` const apptest = require('express')();
var runpath = `.` var newport1 = ''
var runpathfile = `./swarmlab_editor_service.sh` const servertest1 = apptest.listen(0, () => {
servertest1.close();
})
newport1 = servertest1.address().port
var showexec = `./swarmlab_editor_service.sh ${RES.instance} ${newport1}`
//var runpath = `.`
//var runpathfile = `./swarmlab_editor_service.sh`
// console.log(runpath) // console.log(runpath)
console.log(showexec) // console.log(showexec)
var buildoutdir = `${runpath}/logs/build-out.log`
var builderrdir = `${runpath}/logs/build-out.log` log = spawn(showexec, {
shell: true,
//cwd: services_path,
detached: false,
stdio: 'pipe'
});
log.stdout.on('data', function (data) {
var n = {}
n.data = data.toString()
io.emit('message_out', n);
io.emit('message_close', n);
//console.log('data')
var filter = `start:${RES.instance}`
var grep = new RegExp(filter);
if(grep.test(n.data)){
n.start = `${RES.instance}`
n.port = `${newport1}`
io.emit('message_exec_editor', n);
io.emit('message_close', n);
//console.log('close')
io.emit('message_err', n);
RES.error = false
RES.error_msg = 'ok'
RES.data = n.data
RES.port = newport1
res.json(RES)
}
});
log.stderr.on('data', function (data) {
var n = {}
n.data = data.toString()
io.emit('message_err', n);
});
log.on('close', function (code) {
var n = {}
n.data = code
io.emit('message_close', n);
//RES.error = false
//RES.error_msg = "ok"
//RES.data = code;
//res.json(RES)
/*
RES.error = false
RES.error_msg = 'no'
RES.port = newport1
res.json(RES)
*/
});
//var buildoutdir = `${runpath}/logs/build-out.log`
//var builderrdir = `${runpath}/logs/build-out.log`
//const buildout = fs.openSync(buildoutdir, 'a'); //const buildout = fs.openSync(buildoutdir, 'a');
//const builderr = fs.openSync(builderrdir, 'a'); //const builderr = fs.openSync(builderrdir, 'a');
/*
try { try {
const buildout = fs.openSync(buildoutdir, 'a'); //const buildout = fs.openSync(buildoutdir, 'a');
const builderr = fs.openSync(builderrdir, 'a'); //const builderr = fs.openSync(builderrdir, 'a');
var buildimage = `echo "EXEC PID: $$"; ${showexec}` var buildimage = `echo "EXEC PID: $$"; ${showexec}`
//var buildimage = `echo "EXEC PID: $$"; docker run -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix microservice-firefox /bin/sh -c "firefox"`
const run_buildimage = spawn(buildimage, { const run_buildimage = spawn(buildimage, {
detached: true, detached: true,
shell: true, shell: true,
@ -1555,33 +1624,35 @@ try {
n.data = 'If this fails, try:' n.data = 'If this fails, try:'
io.emit('message_out', n); io.emit('message_out', n);
var buildtmpexec = `${mypath1}/swarmlab_editor_service.sh ${RES.instance}` var buildtmpexec = `${mypath1}/swarmlab_editor_service.sh ${RES.instance} ${newport1}`
//buildtmpexec = fs.readFileSync(runpathfile, {encoding:'utf8', flag:'r'});
//var buildtmpexec = `docker run -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix microservice-firefox /bin/sh -c "firefox"`
n.data = buildtmpexec n.data = buildtmpexec
io.emit('message_out', n); io.emit('message_out', n);
n.data = 'close!'
io.emit('message_close', n);
n.start = `${RES.instance}`
n.port = `${newport1}`
io.emit('message_exec_editor', n);
run_buildimage.on('exit', (data) => { run_buildimage.on('exit', (data) => {
//console.log('exit '+data); //console.log('exit '+data);
var n = {} var n = {}
n.data = 'exit!' n.data = 'exit!'
io.emit('message_close', n); io.emit('message_close', n);
}); });
run_buildimage.on('close', (data) => { run_buildimage.on('close', (data) => {
//console.log('close '+data); //console.log('close '+data);
var n = {} var n = {}
n.data = 'close!' n.data = `close!`
io.emit('message_close', n); io.emit('message_close', n);
n.name = `${RES.instance}` n.name = `${RES.instance}`
n.dir = `${runpath}` n.dir = `${runpath}`
io.emit('message_close_build', n); io.emit('message_close_build', n);
RES.error = false
RES.error_msg = 'no'
RES.data = 'no'
res.json(RES)
}); });
console.log(run_buildimage.pid); console.log(run_buildimage.pid);
run_buildimage.unref(); run_buildimage.unref();
@ -1592,6 +1663,7 @@ try {
RES.data = 'no' RES.data = 'no'
res.json(RES) res.json(RES)
} }
*/
}); });
@ -1788,12 +1860,14 @@ app.get('/getlogs', (req, res, next) => {
var n = {} var n = {}
n.data = data.toString() n.data = data.toString()
io.emit('message_out', n); io.emit('message_out', n);
//console.log('logdata')
}); });
log.stderr.on('data', function (data) { log.stderr.on('data', function (data) {
var n = {} var n = {}
n.data = data.toString() n.data = data.toString()
io.emit('message_err', n); io.emit('message_err', n);
//console.log('logdataerr')
}); });
log.on('close', function (code) { log.on('close', function (code) {
@ -1804,6 +1878,7 @@ app.get('/getlogs', (req, res, next) => {
RES.error_msg = "ok" RES.error_msg = "ok"
RES.data = code; RES.data = code;
res.json(RES) res.json(RES)
//console.log('logdataclose')
}); });
/* /*
exec(showexec, (err, stdout, stderr) => { exec(showexec, (err, stdout, stderr) => {

4
src-local/swarmlab_editor_service

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
code-server --disable-update-check --bind-addr 0.0.0.0:8080 --user-data-dir /home --auth none & code-server --disable-update-check --bind-addr 0.0.0.0:8080 --user-data-dir /home --auth none
firefox http://127.0.0.1:8080 #firefox http://127.0.0.1:8080

17
src-local/swarmlab_editor_service.sh

@ -33,16 +33,19 @@ if [[ -z "$1" ]] ; then
exit 1 exit 1
fi fi
service=$1 if [[ -z "$2" ]] ; then
servicebase=$(echo $service | cut -d'_' -f1) echo 'no port'
exit 1
fi
R_PORT1=$2
#code-server --disable-update-check --bind-addr 0.0.0.0:8080 --user-data-dir /home --auth none & service=$1
#firefox http://127.0.0.1:8080
xhost +local:docker
docker run --rm --volumes-from $service -e TZ=Europe/Athens -e DISPLAY=$DISPLAY -v $(pwd)/swarmlab_editor_service:/tmp/start -v /tmp/.X11-unix:/tmp/.X11-unix hub.swarmlab.io:5480/swarmlab-codeserver /bin/bash -c "/tmp/start"
#docker run --rm --volumes-from $service -e TZ=Europe/Athens -e DISPLAY=$DISPLAY --mount type=bind,source=$(pwd)/swarmlab_editor_service,target=/tmp/start -v /tmp/.X11-unix:/tmp/.X11-unix hub.swarmlab.io:5480/swarmlab-codeserver /bin/bash -c "/tmp/start"
xhost +local:docker
docker stop edit_$service
docker container rm edit_$service
docker run --rm --volumes-from $service -p $R_PORT1:8080 -e TZ=Europe/Athens -e DISPLAY=$DISPLAY -v $(pwd)/swarmlab_editor_service:/tmp/start -v /tmp/.X11-unix:/tmp/.X11-unix --name edit_$service hub.swarmlab.io:5480/swarmlab-codeserver /bin/bash -c "echo \"start:${service}\"; /tmp/start"

52
src/components/mynetwork/mytable.vue

@ -332,6 +332,10 @@ export default {
webinterfacegenericedit: false, webinterfacegenericedit: false,
webinterface_port: '', webinterface_port: '',
STATUS:{}, STATUS:{},
editor_instance:{
'start':'',
'port':''
},
CONFIG:{ CONFIG:{
'status':'', 'status':'',
'workerkey':'', 'workerkey':'',
@ -624,19 +628,14 @@ export default {
//console.log('startobj ' + JSON.stringify(obj)) //console.log('startobj ' + JSON.stringify(obj))
////console.log(this.$socket.client.connect()) ////console.log(this.$socket.client.connect())
}else if(action == 'basedireditor'){ }else if(action == 'basedireditor'){
console.log('start editor-------- ' + JSON.stringify(this.hybridshowdata.Names))
var log = await store.dispatch("pipelineLLO/runeditor",{ var log = await store.dispatch("pipelineLLO/runeditor",{
token:this.token,
instance:this.hybridshowdata.Names instance:this.hybridshowdata.Names
}) })
//console.log('start editor-------- ' + JSON.stringify(this.hybridshowdata.Names))
/* //console.log('start token-------- ' + JSON.stringify(log.data.port))
* console.log('start editor-------- ' + JSON.stringify(log))
* this.$root.$emit('SERVER_hybrid_table_stop')
*
*
*
*
*/
}else if(action == 'basebackupview'){ }else if(action == 'basebackupview'){
@ -1373,6 +1372,39 @@ info +='This permits the docker user on the local machine to connect to X window
this.$root.$emit('SERVER_build_closebuild',val) this.$root.$emit('SERVER_build_closebuild',val)
//this.$root.$emit('hybrid_refresh_table_storage') //this.$root.$emit('hybrid_refresh_table_storage')
}, },
async message_exec_editor(val) {
// refresh table hybrid storage
console.log(" socket out editor "+JSON.stringify(val))
if(val.start){
this.$root.$emit('SERVER_hybrid_table_stop')
this.editor_instance.start=val.start
this.editor_instance.start=val.port
var info=`<h5><b>Editor</b><br>
<br>
`
info +='<p class="text-secondary">'
info +=' <b>Click on hyperlink opens Editor in new tab</b></p>'
info +='<b> <a class="text-info" href="http://127.0.0.1:'+val.port+'" target="_blank">Open Editor</a></b>'
info +='<br>'
this.$swal({
type: 'Info',
title: 'Info!',
icon:'info',
html: info,
showCloseButton: true,
showLoaderOnConfirm: false,
allowOutsideClick: false,
cancelButtonText: 'No, cancel!',
showCancelButton: false,
showLoaderOnConfirm: false,
reverseButtons: true,
focusCancel: true,
confirmButtonText: 'Ok!'
})
}
//this.$root.$emit('hybrid_refresh_table_storage')
},
async build_set_sshpid(val) { async build_set_sshpid(val) {
// console.log(" socket pid "+JSON.stringify(val)) // console.log(" socket pid "+JSON.stringify(val))
this.$root.$emit('SERVER_build_set_sshpid',val) this.$root.$emit('SERVER_build_set_sshpid',val)

21
src/config/index-editor.js

@ -7,5 +7,26 @@ export const ApiConfigEDIT = [
"url": 'http', "url": 'http',
"version": 0, "version": 0,
"port": 0 "port": 0
},
{
"name": "microservice-ansible",
"automated": true,
"url": 'http',
"version": 0,
"port": 0
},
{
"name": "microservice-nodejs",
"automated": true,
"url": 'http',
"version": 0,
"port": 0
},
{
"name": "microservice-numpylite",
"automated": true,
"url": 'http',
"version": 0,
"port": 0
} }
]; ];

Loading…
Cancel
Save