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. 117
      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

117
src-local/llo/new.js

@ -1516,32 +1516,101 @@ app.get('/runeditor', (req, res, next) => {
RES.instance = req.query["instance"]
RES.error = false
RES.error_msg = "ok"
RES.error_msg0 = ""
RES.data = "All_services_are_running";
var showexec = `./swarmlab_editor_service.sh ${RES.instance}`
var runpath = `.`
var runpathfile = `./swarmlab_editor_service.sh`
const apptest = require('express')();
var newport1 = ''
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(showexec)
var buildoutdir = `${runpath}/logs/build-out.log`
var builderrdir = `${runpath}/logs/build-out.log`
// console.log(showexec)
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 builderr = fs.openSync(builderrdir, 'a');
/*
try {
const buildout = fs.openSync(buildoutdir, 'a');
const builderr = fs.openSync(builderrdir, 'a');
//const buildout = fs.openSync(buildoutdir, 'a');
//const builderr = fs.openSync(builderrdir, 'a');
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, {
detached: true,
shell: true,
stdio: [ 'ignore', buildout, builderr ],
cwd: runpath
});
var n = {}
n.pid = run_buildimage.pid
io.emit('build_set_buildpid', n);
@ -1555,33 +1624,35 @@ try {
n.data = 'If this fails, try:'
io.emit('message_out', n);
var buildtmpexec = `${mypath1}/swarmlab_editor_service.sh ${RES.instance}`
//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"`
var buildtmpexec = `${mypath1}/swarmlab_editor_service.sh ${RES.instance} ${newport1}`
n.data = buildtmpexec
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) => {
//console.log('exit '+data);
var n = {}
n.data = 'exit!'
io.emit('message_close', n);
});
run_buildimage.on('close', (data) => {
//console.log('close '+data);
var n = {}
n.data = 'close!'
n.data = `close!`
io.emit('message_close', n);
n.name = `${RES.instance}`
n.dir = `${runpath}`
io.emit('message_close_build', n);
RES.error = false
RES.error_msg = 'no'
RES.data = 'no'
res.json(RES)
});
console.log(run_buildimage.pid);
run_buildimage.unref();
@ -1592,6 +1663,7 @@ try {
RES.data = 'no'
res.json(RES)
}
*/
});
@ -1788,12 +1860,14 @@ app.get('/getlogs', (req, res, next) => {
var n = {}
n.data = data.toString()
io.emit('message_out', n);
//console.log('logdata')
});
log.stderr.on('data', function (data) {
var n = {}
n.data = data.toString()
io.emit('message_err', n);
//console.log('logdataerr')
});
log.on('close', function (code) {
@ -1804,6 +1878,7 @@ app.get('/getlogs', (req, res, next) => {
RES.error_msg = "ok"
RES.data = code;
res.json(RES)
//console.log('logdataclose')
});
/*
exec(showexec, (err, stdout, stderr) => {

4
src-local/swarmlab_editor_service

@ -1,4 +1,4 @@
#!/bin/bash
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
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

17
src-local/swarmlab_editor_service.sh

@ -33,16 +33,19 @@ if [[ -z "$1" ]] ; then
exit 1
fi
service=$1
servicebase=$(echo $service | cut -d'_' -f1)
if [[ -z "$2" ]] ; then
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 &
#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"
service=$1
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,
webinterface_port: '',
STATUS:{},
editor_instance:{
'start':'',
'port':''
},
CONFIG:{
'status':'',
'workerkey':'',
@ -624,19 +628,14 @@ export default {
//console.log('startobj ' + JSON.stringify(obj))
////console.log(this.$socket.client.connect())
}else if(action == 'basedireditor'){
console.log('start editor-------- ' + JSON.stringify(this.hybridshowdata.Names))
var log = await store.dispatch("pipelineLLO/runeditor",{
token:this.token,
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'){
@ -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('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) {
// console.log(" socket pid "+JSON.stringify(val))
this.$root.$emit('SERVER_build_set_sshpid',val)

21
src/config/index-editor.js

@ -7,5 +7,26 @@ export const ApiConfigEDIT = [
"url": 'http',
"version": 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