Browse Source

add custom

master
zeus 3 years ago
parent
commit
4b481360bb
  1. 2
      dist/index.html
  2. 2
      dist/js/app.36e297d4.js
  3. 1
      dist/js/app.36e297d4.js.map
  4. 2
      dist/js/app.e1fd99bf.js
  5. 1
      dist/js/app.e1fd99bf.js.map
  6. 70
      src-local/llo/new.js
  7. 190
      src/components/mynetwork/availablemicroservices.vue
  8. 10
      src/config/index-web.js
  9. 64
      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.e1fd99bf.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.e1fd99bf.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.36e297d4.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.36e297d4.js"></script></body></html>

2
dist/js/app.36e297d4.js

File diff suppressed because one or more lines are too long

1
dist/js/app.36e297d4.js.map

File diff suppressed because one or more lines are too long

2
dist/js/app.e1fd99bf.js

File diff suppressed because one or more lines are too long

1
dist/js/app.e1fd99bf.js.map

File diff suppressed because one or more lines are too long

70
src-local/llo/new.js

@ -1879,6 +1879,76 @@ app.get('/checkowner', (req, res, next) => {
} }
}); });
app.get('/getcustom', (req, res, next) => {
var RES = new Object();
var mypath1 = process.cwd()
var runuser = process.env.USER || ""
RES.instance = req.query["instance"]
RES.error = false
RES.error_msg = "ok"
var instancedir = `./instance/${RES.instance}/${RES.instance}/custom`
//console.log(instancedir)
if (fs.existsSync(instancedir)) {
var extrapackages = `${instancedir}/extrapackages`
var extrash = `${instancedir}/custom.sh`
try {
const extrapackagestext = fs.readFileSync(extrapackages, {encoding:'utf8', flag:'r'});
const extrashtext = fs.readFileSync(extrash, {encoding:'utf8', flag:'r'});
RES.error = false
RES.error_msg = 'ok'
RES.extrapackagestext = extrapackagestext
RES.extrashtext = extrashtext
res.json(RES)
} catch (error) {
//console.log('Error:', error);
RES.error = true
RES.error_msg = error
RES.data = 'no'
res.json(RES)
}
}else{
RES.error = false
RES.error_msg = 'nodir'
RES.data = 'no'
res.json(RES)
}
});
app.get('/savecustom', (req, res, next) => {
var RES = new Object();
var mypath1 = process.cwd()
var runuser = process.env.USER || ""
RES.instance = req.query["instance"]
RES.package = req.query["package"]
RES.sh = req.query["sh"]
RES.error = false
RES.error_msg = "ok"
var instancedir = `./instance/${RES.instance}/${RES.instance}/custom`
if (fs.existsSync(instancedir)) {
var extrapackages = `${instancedir}/extrapackages`
var extrash = `${instancedir}/custom.sh`
try {
const extrapackagestext = fs.writeFileSync(extrapackages, RES.package, {encoding:'utf8'});
const extrashtext = fs.writeFileSync(extrash, RES.sh, {encoding:'utf8'});
RES.error = false
RES.error_msg = 'ok'
RES.extrapackagestext = extrapackagestext
RES.extrashtext = extrapackagestext
res.json(RES)
} catch (error) {
//console.log('Error:', error);
RES.error = true
RES.error_msg = error
RES.data = 'no'
res.json(RES)
}
}else{
RES.error = false
RES.error_msg = 'nodir'
RES.data = 'no'
res.json(RES)
}
});
app.get('/runbackup', (req, res, next) => { app.get('/runbackup', (req, res, next) => {
var RES = new Object(); var RES = new Object();

190
src/components/mynetwork/availablemicroservices.vue

@ -92,6 +92,29 @@
> >
<div class="text-info">{{ up_name }}</div> <div class="text-info">{{ up_name }}</div>
--> -->
<button class="btn btn-outline-info"
v-if="viewhybridoptions && customedit "
round
type="button"
@click="setcustom"
>
Custom</button>
<button class="btn btn-outline-warning"
v-if="viewhybridoptions && customedit && custommenouopen"
round
type="button"
@click="setcustomcancel"
>
Cancel</button>
<button class="btn btn-outline-primary"
v-if="viewhybridoptions && customedit && custommenouopen"
round
type="button"
@click="setcustomsave"
>
Save</button>
<button class="btn btn-outline-success" <button class="btn btn-outline-success"
round round
type="button" type="button"
@ -100,6 +123,43 @@
Up</button> Up</button>
</div> </div>
<div class="input-group-append"
v-if="viewhybridoptions && custommenou"
>
<div class="row"
<b-col class="text-center" cols="5" sm="5" md="5">
<div class="form-group">
<label for="custompackages" class="text-dark">Add Extrapackages <br>
<span class="text-success">
{{ customostext }}
</span >
</label>
<textarea class="form-control" id="custompackages" rows="8"
v-model="custom.os"
>
{{ custom.os }}
</textarea>
</div>
</b-col>
<b-col class="text-center" cols="7" sm="7" md="7">
<div class="form-group">
<label for="customshell" class="text-dark">Custom sh script <br>
<span class="text-success">
{{ customshtext }}
</span >
</label>
<textarea class="form-control" id="customshell" rows="8"
v-model="custom.sh"
>
{{ custom.sh }}
</textarea>
</div>
</b-col>
</div>
</div>
<div class="input-group-append" <div class="input-group-append"
v-if="viewhybridoptions && heavy" v-if="viewhybridoptions && heavy"
> >
@ -247,6 +307,15 @@ export default {
viewhybridoptions: false, viewhybridoptions: false,
heavy: false, heavy: false,
heavytext: '', heavytext: '',
customedit: false,
custommenouopen: false,
custommenou: false,
custom: {
'os':'',
'sh':''
},
customostext: '',
customshtext: '',
up_name:'', up_name:'',
swarmlab:{}, swarmlab:{},
playbookInfo: {}, playbookInfo: {},
@ -440,6 +509,7 @@ export default {
//console.log(this.testtestdir) //console.log(this.testtestdir)
}, },
async checkactionrowindex(data,index){ async checkactionrowindex(data,index){
this.resetcustom()
if(data._id == index) { if(data._id == index) {
this.dataselect=data this.dataselect=data
this.indexselect=index this.indexselect=index
@ -522,6 +592,7 @@ export default {
this.currentpagepaginationData = paginationData this.currentpagepaginationData = paginationData
}, },
onChangePage (page) { onChangePage (page) {
this.resetcustom()
this.currentpage = page this.currentpage = page
this.$refs.vuetable.changePage(page) this.$refs.vuetable.changePage(page)
}, },
@ -572,6 +643,7 @@ export default {
Vue.nextTick( () => this.refreshVuetable()) Vue.nextTick( () => this.refreshVuetable())
//this.refreshVuetable() //this.refreshVuetable()
}else if(action == 'rm-install' ){ }else if(action == 'rm-install' ){
this.resetcustom()
this.hybridoptions.swarmlabname = data.swarmlabname this.hybridoptions.swarmlabname = data.swarmlabname
this.$wait.start('myRunInstancetutor'); this.$wait.start('myRunInstancetutor');
//console.log(this.hybridoptions.swarmlabname) //console.log(this.hybridoptions.swarmlabname)
@ -632,6 +704,13 @@ export default {
this.refreshVuetable() this.refreshVuetable()
}else if(action == 'run-item' ){ }else if(action == 'run-item' ){
this.resetcustom()
//this.customedit = false
//this.custommenouopen = false
//this.custommenou = false
//this.custom.os = ''
//this.custom.sh = ''
this.heavy = false this.heavy = false
this.heavytext = '' this.heavytext = ''
@ -666,15 +745,32 @@ export default {
this.hybridoptions.index = index this.hybridoptions.index = index
for(var i = 0; i < ApiConfigWEB.length; i++) { for(var i = 0; i < ApiConfigWEB.length; i++) {
var obWEB = ApiConfigWEB[i]; var obWEB = ApiConfigWEB[i];
//--------------
if(obWEB.name == this.hybridoptions.swarmlabname){ if(obWEB.name == this.hybridoptions.swarmlabname){
if(obWEB.hasOwnProperty('large')){ if(obWEB.hasOwnProperty('large')){
if(obWEB.large != 'no'){ if(obWEB.large != 'no'){
console.log(obWEB.large) // console.log(obWEB.large)
this.heavy = true this.heavy = true
this.heavytext = obWEB.large this.heavytext = obWEB.large
} }
} }
} }
// -------------------------
if(obWEB.name == this.hybridoptions.swarmlabname){
if(obWEB.hasOwnProperty('custom')){
if(obWEB.custom != 'no'){
console.log(obWEB.custom)
this.customedit = true
this.custom.os = obWEB.customos
this.custom.sh = obWEB.customsh
this.customostext = obWEB.customostext
this.customshtext = obWEB.customshtext
}
}
}
// -------------------------
} }
/* /*
console.log('RUN 1 '+ JSON.stringify(data.swarmlabname)) console.log('RUN 1 '+ JSON.stringify(data.swarmlabname))
@ -732,8 +828,93 @@ export default {
}else { }else {
console.log('no') console.log('no')
} }
},
async setcustomcancel(){
this.custommenouopen = false
this.custommenou = false
},
async setcustomsave(){
let value = {}
value.swarmlabname = this.hybridoptions.swarmlabname
var log = await store.dispatch("pipelineLLO/savecustom",{
token:this.token,
instance:this.hybridoptions.swarmlabname,
package:this.custom.os,
sh:this.custom.sh
})
this.custommenouopen = false
this.custommenou = false
console.log('chown ok '+ JSON.stringify(log.data))
},
async setcustom(){
let value = {}
value.swarmlabname = this.hybridoptions.swarmlabname
this.custommenouopen = true
this.custommenou = true
var log = await store.dispatch("pipelineLLO/getcustom",{
token:this.token,
instance:this.hybridoptions.swarmlabname
})
if(log.data.error === false){
if(log.data.error_msg == 'nodir'){
//console.log('chown reload')
var info=`<h5><b> Please redownload Microservice and try launching the module again </b><br>
</h5>
`
this.$swal({
type: 'Info',
icon:'info',
html: info,
showCloseButton: true,
showLoaderOnConfirm: false,
allowOutsideClick: false,
cancelButtonText: 'No, cancel!',
showCancelButton: false,
showLoaderOnConfirm: false,
reverseButtons: true,
focusCancel: true,
confirmButtonText: 'Ok!'
})
}
if(log.data.error_msg == 'ok'){
if(log.data.extrapackagestext != ''){
//this.custom.os = log.data.extrapackagestext
Vue.set(this.custom, 'os', log.data.extrapackagestext)
}
if(log.data.extrashtext != ''){
//this.custom.sh = log.data.extrashtext
Vue.set(this.custom, 'sh', log.data.extrashtext)
}
console.log('chown extrapackages1 '+ JSON.stringify(this.custom.os))
console.log('chown sh1 '+ JSON.stringify(this.custom.sh))
}
}else{
var info=`<h5><b> Please remove and download Microservice and try launching the module again </b><br>
</h5>
`
this.$swal({
type: 'Info',
icon:'info',
html: info,
showCloseButton: true,
showLoaderOnConfirm: false,
allowOutsideClick: false,
cancelButtonText: 'No, cancel!',
showCancelButton: false,
showLoaderOnConfirm: false,
reverseButtons: true,
focusCancel: true,
confirmButtonText: 'Ok!'
})
}
//console.log('chownlog '+ JSON.stringify(log))
//console.log('chown extrapackages '+ JSON.stringify(this.custom.os))
//console.log('chown sh '+ JSON.stringify(this.custom.sh))
}, },
async setHybridoptions(){ async setHybridoptions(){
this.resetcustom()
//console.log(JSON.stringify(this.hybridoptions)) //console.log(JSON.stringify(this.hybridoptions))
// run on mytable.vue // run on mytable.vue
@ -763,6 +944,13 @@ export default {
this.vuetablekeyg += 1 this.vuetablekeyg += 1
}) })
}, },
async resetcustom() {
this.customedit = false
this.custommenouopen = false
this.custommenou = false
this.custom.os = ''
this.custom.sh = ''
},
async refreshVuetable() { async refreshVuetable() {
//this.vuetablekeyg += 1 //this.vuetablekeyg += 1
// EDO // EDO

10
src/config/index-web.js

@ -4,6 +4,11 @@ export const ApiConfigWEB = [
{ {
"name": "just-test-info-no-service", "name": "just-test-info-no-service",
"large": 'no or text', "large": 'no or text',
"custom": 'true',
"customostext": 'Base OS: python:3.11-rc-alpine3.15',
"customos": 'apk add --no-cache net-tools ',
"customshtext": 'It is executed after all the normal builds',
"customsh": ' #!/bin/sh',
"app": false, "app": false,
"url": 'http', "url": 'http',
"port": "6901/tcp", "port": "6901/tcp",
@ -530,6 +535,11 @@ export const ApiConfigWEB = [
{ {
"name": "microservice-jsshell", "name": "microservice-jsshell",
"large": 'no', "large": 'no',
"custom": 'true',
"customostext": 'Base OS: python:3.11-rc-alpine3.15',
"customos": 'apk add --no-cache net-tools ',
"customshtext": 'It is executed after all the normal builds',
"customsh": ' #!/bin/sh',
"app": false, "app": false,
"url": 'http', "url": 'http',
"port": "80/tcp", "port": "80/tcp",

64
src/store/modules/create_pipelineLLO.js

@ -367,6 +367,70 @@ export default {
return R; return R;
} }
} }
},
async getcustom({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+'/getcustom'
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 savecustom({commit,rootGetters}, value) {
//console.log('value '+JSON.stringify(value))
try {
var token = value.token
var params = {
instance: value.instance,
package: value.package,
sh: value.sh
}
var options = {
params: params,
headers: { 'content-type': 'application/x-www-form-urlencoded',Authorization: `Bearer ${token}` },
};
var sock_server_l = ApiConfig.url_80+'/savecustom'
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 runeditor({commit,rootGetters}, value) { async runeditor({commit,rootGetters}, value) {
//console.log('value '+JSON.stringify(value)) //console.log('value '+JSON.stringify(value))

Loading…
Cancel
Save