Browse Source

add Gui microservice

master
zeus 3 years ago
parent
commit
eab92061e4
  1. 2
      dist/index.html
  2. 2
      dist/js/app.330c2d31.js
  3. 1
      dist/js/app.330c2d31.js.map
  4. 2
      dist/js/app.5466e359.js
  5. 1
      dist/js/app.5466e359.js.map
  6. 73
      src-local/llo/new.js
  7. 37
      src/components/mynetwork/mytable.vue
  8. 9
      src/config/index-gui.js
  9. 31
      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.291cc1d1.css" rel="preload" as="style"><link href="/css/chunk-vendors.e469b508.css" rel="preload" as="style"><link href="/js/app.5466e359.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.291cc1d1.css" rel="stylesheet"></head><body><div id="app"></div><script src="/js/chunk-vendors.d8d18fe6.js"></script><script src="/js/app.5466e359.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.291cc1d1.css" rel="preload" as="style"><link href="/css/chunk-vendors.e469b508.css" rel="preload" as="style"><link href="/js/app.330c2d31.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.291cc1d1.css" rel="stylesheet"></head><body><div id="app"></div><script src="/js/chunk-vendors.d8d18fe6.js"></script><script src="/js/app.330c2d31.js"></script></body></html>

2
dist/js/app.330c2d31.js

File diff suppressed because one or more lines are too long

1
dist/js/app.330c2d31.js.map

File diff suppressed because one or more lines are too long

2
dist/js/app.5466e359.js

File diff suppressed because one or more lines are too long

1
dist/js/app.5466e359.js.map

File diff suppressed because one or more lines are too long

73
src-local/llo/new.js

@ -1169,6 +1169,79 @@ app.get('/rmbuildstatus', (req, res, next) => {
} }
}); });
app.get('/rungui', (req, res, next) => {
var RES = new Object();
RES.instance = req.query["instance"]
RES.error = false
RES.error_msg = "ok"
RES.error_msg0 = ""
RES.data = "All_services_are_running";
var showexec = `./run-gui.sh`
var runpath = `./instance/${RES.instance}/${RES.instance}`
var runpathfile = `./instance/${RES.instance}/${RES.instance}/run-gui.sh`
//console.log(runpath)
//console.log(showexec)
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');
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);
n.data = 'start ...'
io.emit('message_out', n);
n.data = 'i am trying to automatically start the application'
io.emit('message_out', n);
n.data = 'If this fails, try:'
io.emit('message_out', n);
var buildtmpexec = ""
try {
buildtmpexec = fs.readFileSync(runpathfile, {encoding:'utf8', flag:'r'});
} catch (err) {
console.log(err);
}
//var buildtmpexec = `docker run -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix microservice-firefox /bin/sh -c "firefox"`
n.data = buildtmpexec
io.emit('message_out', 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!'
io.emit('message_close', n);
n.name = `${RES.instance}`
n.dir = `${runpath}`
io.emit('message_close_build', n);
});
console.log(run_buildimage.pid);
run_buildimage.unref();
});
app.get('/getbuildstatus', (req, res, next) => { app.get('/getbuildstatus', (req, res, next) => {
var RES = new Object(); var RES = new Object();
RES.instance = req.query["instance"] RES.instance = req.query["instance"]

37
src/components/mynetwork/mytable.vue

@ -42,6 +42,14 @@
@click="onAction('startweb')" @click="onAction('startweb')"
> >
Web</button> Web</button>
<button
v-if="webinterfacegeneric"
class="btn btn-outline-info"
round
type="button"
@click="onAction('startwebgeneric')"
>
openGui</button>
</div> </div>
<div class="input-group-prepend"> <div class="input-group-prepend">
<button <button
@ -233,6 +241,7 @@ import {mapState, mapGetters, mapActions,dispatch} from 'vuex'
import Vue from 'vue' import Vue from 'vue'
import card from '@/components/Card.vue' import card from '@/components/Card.vue'
import {ApiConfig} from "@/config/index"; import {ApiConfig} from "@/config/index";
import {ApiConfigGUI} from "@/config/index-gui";
import { extend } from 'vee-validate'; import { extend } from 'vee-validate';
import { required, alpha_num } from 'vee-validate/dist/rules'; import { required, alpha_num } from 'vee-validate/dist/rules';
@ -259,6 +268,7 @@ export default {
localNetworkoptions:[], localNetworkoptions:[],
localNetworkdefault:'', localNetworkdefault:'',
webinterface: false, webinterface: false,
webinterfacegeneric: false,
webinterface_port: '', webinterface_port: '',
STATUS:{}, STATUS:{},
CONFIG:{ CONFIG:{
@ -313,6 +323,25 @@ export default {
this.webinterface = false this.webinterface = false
this.webinterface_port = '' this.webinterface_port = ''
} }
var urlgeniGUI = this.hybridshowdata.Names.split('_');
// GUI firefox
for(var i = 0; i < ApiConfigGUI.length; i++) {
var obGUI = ApiConfigGUI[i];
if(obGUI.name == urlgeniGUI[0]){
this.webinterfacegeneric = true
//console.log(obGUI.name);
}
}
/*
var filterjugeneric = `microservice-firefox`
var grepju1 = new RegExp(filterjugeneric);
if(grepju1.test(data.Networks) && grepju1.test(data.Names)){
this.webinterfacegeneric = true
}else{
this.webinterfacegeneric = false
}
*/
this.addNetworkMenou = false this.addNetworkMenou = false
this.localNetworks = [] this.localNetworks = []
this.selectedNetworks = [] this.selectedNetworks = []
@ -588,7 +617,13 @@ export default {
var log = await store.dispatch("pipelineLLO/getlogs",{ var log = await store.dispatch("pipelineLLO/getlogs",{
container:this.hybridshowdata.ID container:this.hybridshowdata.ID
}) })
// console.log('logs---------- ' + JSON.stringify(this.hybridshowdata)) }else if(action == 'startwebgeneric'){
var urlgen = this.hybridshowdata.Names.split('_');
//console.log('logs---------- ' + JSON.stringify(this.hybridshowdata))
//console.log('logs---------- ' + JSON.stringify(urlgen[0]))
var log = await store.dispatch("pipelineLLO/rungui",{
instance:urlgen[0]
})
}else if(action == 'startweb'){ }else if(action == 'startweb'){
var log = await store.dispatch("pipelineLLO/getjupyterinfo",{ var log = await store.dispatch("pipelineLLO/getjupyterinfo",{
instance:this.hybridshowdata.Names instance:this.hybridshowdata.Names

9
src/config/index-gui.js

@ -0,0 +1,9 @@
export const ApiConfigGUI = [
{
"name": "microservice-firefox",
"automated": true,
"version": 0,
"port": 0
}
];

31
src/store/modules/create_pipelineLLO.js

@ -336,6 +336,37 @@ export default {
return R; return R;
} }
} }
},
async rungui({commit,rootGetters}, value) {
//console.log('value '+JSON.stringify(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+'/rungui'
var p = await axios.get(sock_server_l,options);
//var p = await axios.get('https://localhost:3000/getservicesinfo',options);
return p
//console.log(JSON.stringify(p))
//console.log(value.token)
//console.log(value.swarmlabname)
} catch (e) {
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{
var R = {
ERROR_str: e,
ERROR: 'yes'
}
return R;
}
}
}, },
async hybrid_rmimage({commit,rootGetters}, value) { async hybrid_rmimage({commit,rootGetters}, value) {
//console.log('value '+JSON.stringify(value)) //console.log('value '+JSON.stringify(value))

Loading…
Cancel
Save