diff --git a/src-local/llo/new.js b/src-local/llo/new.js index b33f374..fcbfc00 100644 --- a/src-local/llo/new.js +++ b/src-local/llo/new.js @@ -776,6 +776,142 @@ app.get('/dockerimages', (req, res, next) => { }); +app.get('/dockernetworks', (req, res, next) => { + + var RES = new Object(); + const page = req.query["page"] + const per_page = req.query["per_page"] + var sort = req.query["sort"] + var filter = req.query["filter"] + var type = req.query["type"] + var sort = req.query["sort"] + var sorttmp1 = sort.split('|'); + var sortname = sorttmp1[0]; + var sortorder = sorttmp1[1]; + + var showexec = `docker network ls --format "{{json . }}" | jq . -s ` + exec(showexec, (err, stdout, stderr) => { + if (err) { + console.error(`exec error: ${err}`); + return; + } + + var nn = [] + var string = stdout.toString() + var datajson = JSON.parse(string); + + var results = [] + if(filter !== 'NULL'){ + var grep = new RegExp(filter); + var datalenth = datajson.length + for (var i=0 ; i < datalenth ; i++) + { + if(grep.test(datajson[i]['Name'])){ + results.push(datajson[i]); + } + } + datajson=results + } + + + + // sort by title + if(sortname == 'Repository'){ + datajson.sort(function (a, b) { + if(sortorder == 'asc'){ + return a.Repository.localeCompare(b.Repository); + }else{ + return b.Repository.localeCompare(a.Repository); + } + }); + }else if(sortname == 'Size'){ + datajson.sort(function (a, b) { + if(sortorder == 'asc'){ + return a.Size.localeCompare(b.Size); + }else{ + return b.Size.localeCompare(a.Size); + } + }); + } + + + + + + + var resultid = [] + var datalenth2 = datajson.length + for (var i=0 ; i < datalenth2 ; i++) + { + datajson[i].id=i + datajson[i]._id=i + resultid.push(datajson[i]); + } + datajson=resultid + + //console.log('Number of files ' + stdout); + //console.log('Number string ' + string); + //console.log('stringify ' + JSON.stringify(datajson)); + var total = datajson.length; + var perpage = per_page + //var page = 1 + var lastpage = total/perpage; + + if(lastpage <= 1) { + lastpage=1 + }else{ + lastpage++ + } + lastpage = Math.trunc(lastpage); + + var next=(page+1); + if(next >= lastpage){ + next=lastpage; + } + var prev=(page-1); + if(prev == 0){ + prev=1; + } + var from=((page-1)*perpage)+1; + var to=(perpage*page) + + + var myplaybooks = new Object(); + var links = ` + { + "pagination": { + "total": ${total}, + "per_page": ${perpage}, + "current_page": ${page}, + "last_page": ${lastpage}, + "next_page_url": "?page=${next}", + "prev_page_url": "?page=${prev}", + "from": ${from}, + "to": ${to}, + "frommongo": ${from}, + "tomongo": ${to} + } + } + ` + //"next_page_url": "?page="+${next}, + //"prev_page_url": "?page="+${prev}, +//console.log(JSON.stringify(links)) + //myplaybooks.links = links + myplaybooks.links = JSON.parse(links); + from-- + myplaybooks.data = datajson.slice(from,to); + //myplaybooks.data = datajson; + + var RES = new Object(); + RES.code = req.query["action"] + RES.token = req.query["token"] + RES.error = false + RES.error_msg = "ok" + RES.data = myplaybooks; + res.json(RES.data) + }); + +}); app.get('/buildservices', (req, res, next) => { @@ -967,6 +1103,45 @@ app.get('/hybrid_rmimage', (req, res, next) => { }); +app.get('/hybrid_rmnetworks', (req, res, next) => { + + var RES = new Object(); + RES.instance = req.query["instance"] + var showexec = `docker network rm ${RES.instance}` + //console.log(JSON.stringify(showexec)) + exec(showexec, (err, stdout, stderr) => { + if (err) { + console.error(`exec error: ${err}`); + var string = err.toString() + RES.error = false + RES.error_msg = "ok" + RES.test = string; + //RES.data = found; + res.json(RES) + return; + } + if (stdout) { + var string = stdout.toString() + RES.error = false + RES.error_msg = "ok" + RES.test = 'ok'; + RES.out = string; + //RES.data = found; + res.json(RES) + + }else{ + var found = 'no' + RES.error = false + RES.error_msg = "ok" + RES.test = 'ok'; + RES.out = string; + //RES.data = found; + res.json(RES) + } + }); + +}); + app.get('/hybrid_rmall', (req, res, next) => { // docker rmi $(docker image ls -q) -f; docker container prune -f; docker image prune -f; docker volume prune -f @@ -1034,19 +1209,6 @@ app.get('/getmountinfo', (req, res, next) => { if (stdout) { var string = stdout.toString() var datajson = JSON.parse(string); - //console.log(JSON.stringify(string)) - //console.log(JSON.stringify(datajson)) - //var extenderror = new RegExp(RES.instance); - /* - var found = 'no'; - for(var i = 0; i < datajson.length; i++) { - var servicename = datajson[i].Names - console.log(JSON.stringify(servicename)) - if(extenderror.test(servicename)){ - found = 'yes'; - } - } - */ RES.error = false RES.error_msg = "ok" RES.test = datajson; @@ -1066,6 +1228,96 @@ app.get('/getmountinfo', (req, res, next) => { }); +app.get('/hybrid_inspectnetworks', (req, res, next) => { + + var mypath1 = process.cwd() + var RES = new Object(); + RES.instance = req.query["instance"] + var showexec = `docker network inspect --format='{{json .}}' ${RES.instance} | 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.test = datajson; + res.json(RES) + + }else{ + var found = 'no' + RES.error = false + RES.error_msg = "ok" + RES.test = 'no info'; + res.json(RES) + } + }); + +}); + +app.get('/hybrid_inspectcontainer', (req, res, next) => { + + var mypath1 = process.cwd() + var RES = new Object(); + RES.instance = req.query["instance"] + var showexec = `docker inspect --format='{{json .}}' ${RES.instance} | 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.test = datajson; + res.json(RES) + + }else{ + var found = 'no' + RES.error = false + RES.error_msg = "ok" + RES.test = 'no info'; + res.json(RES) + } + }); + +}); + +app.get('/hybrid_inspectimages', (req, res, next) => { + + var mypath1 = process.cwd() + var RES = new Object(); + RES.instance = req.query["instance"] + var showexec = `docker image inspect --format='{{json .}}' ${RES.instance} | 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.test = datajson; + res.json(RES) + + }else{ + var found = 'no' + RES.error = false + RES.error_msg = "ok" + RES.test = 'no info'; + res.json(RES) + } + }); + +}); + app.get('/getserviceshybridstatus', (req, res, next) => { var RES = new Object(); diff --git a/src/components/mynetwork.vue b/src/components/mynetwork.vue index 4cacabd..8c6f538 100644 --- a/src/components/mynetwork.vue +++ b/src/components/mynetwork.vue @@ -23,6 +23,19 @@ +
+
+
+
+
+
+ View and Manage your local networks +
+
+
+ + +
@@ -42,6 +55,7 @@ import ViewNetwork from "./mynetwork/mytable.vue"; import AdhocView from "./mynetwork/AdhocView.vue"; import DockerServices from "./mynetwork/dockerservices.vue"; import DockerImages from "./mynetwork/images.vue"; +import DockerNetworks from "./mynetwork/networks.vue"; import card from '@/components/Card.vue' //import AvailableServices from "./mynetwork/availableservices.vue"; export default { @@ -50,7 +64,8 @@ export default { AdhocView, card, DockerServices, - DockerImages + DockerImages, + DockerNetworks // AvailableServices }, data () { diff --git a/src/components/mynetwork/availablepoc.vue b/src/components/mynetwork/availablepoc.vue index 153f90a..9aecaf2 100644 --- a/src/components/mynetwork/availablepoc.vue +++ b/src/components/mynetwork/availablepoc.vue @@ -308,12 +308,14 @@ export default { }, mounted() { this.$root.$on('hybrid_refresh_availableservices_poc', () => { - Vue.nextTick( () => this.$refs.vuetable.refresh()) + //Vue.nextTick( () => this.$refs.vuetable.refresh()) + this.refreshVuetable() }) //refresh from socket mytable this.$root.$on('hybrid_refresh_table_poc', (v) => { this.$nextTick(function () { - Vue.nextTick( () => this.$refs.vuetable.refresh()) + // Vue.nextTick( () => this.$refs.vuetable.refresh()) + this.refreshVuetable() this.viewhybridoptions = false this.$wait.end('myRunInstancetutorpoc'); }) @@ -393,7 +395,8 @@ export default { 'filter': this.searchFor, 'type': this.selected } - Vue.nextTick( () => this.$refs.vuetable.refresh()) + //Vue.nextTick( () => this.$refs.vuetable.refresh()) + this.refreshVuetable() }, resetFilter () { this.moreParams = {} @@ -402,7 +405,8 @@ export default { 'filter': '', 'type': 'scripts' } - Vue.nextTick( () => this.$refs.vuetable.refresh()) + //Vue.nextTick( () => this.$refs.vuetable.refresh()) + this.refreshVuetable() }, onPaginationData (paginationData) { this.$refs.pagination.setPaginationData(paginationData) @@ -510,7 +514,8 @@ export default { }) //console.log('RUN 1 '+ JSON.stringify(data.swarmlabname)) - Vue.nextTick( () => this.$refs.vuetable.refresh()) + //Vue.nextTick( () => this.$refs.vuetable.refresh()) + this.refreshVuetable() } }, async rmStorageAndClose(action){ @@ -534,11 +539,11 @@ export default { var value = this.hybridoptions.swarmlabname this.$root.$emit('hybrid_stop_instance_poc', value) Vue.delete(this.testactionrowindex, this.hybridoptions.index) - Vue.nextTick( () => this.$refs.vuetable.refresh()) + //Vue.nextTick( () => this.$refs.vuetable.refresh()) + this.refreshVuetable() }else { console.log('no') } - this.refreshVuetable() }, async checkHybridoptions(){ var storage = this.hybridoptions.swarmlabname @@ -558,7 +563,8 @@ export default { value.port = this.hybridoptions.port this.$root.$emit('hybrid_start_instance_poc', value) Vue.set(this.testactionrowindex, value.swarmlabname, value.index) - Vue.nextTick( () => this.$refs.vuetable.refresh()) + //Vue.nextTick( () => this.$refs.vuetable.refresh()) + this.refreshVuetable() }, refreshVuetable() { diff --git a/src/components/mynetwork/dockerservices.vue b/src/components/mynetwork/dockerservices.vue index 1c41023..0452f78 100644 --- a/src/components/mynetwork/dockerservices.vue +++ b/src/components/mynetwork/dockerservices.vue @@ -85,6 +85,11 @@ class="ti-more btn btn-outline-secondary btn-sm" round @click="onAction('run-more', props.rowData, props.rowIndex)"> + +
@@ -205,7 +210,7 @@ export default { title: 'Actions', titleClass: 'center aligned', dataClass: 'center aligned', - width: '5%' + width: '10%' } ], apiurl:ApiConfig.url_80+"/dockerservices", @@ -329,6 +334,29 @@ export default { console.log('index '+JSON.stringify(data)) //console.log('index '+this.actionrowindex) if(action == 'view-item' ){ + var log = await store.dispatch("pipelineLLO/hybrid_inspectcontainer",{ + token:this.token, + instance:data.ID + }) + //console.log('index '+JSON.stringify(log.data.test[0])) + var info='
Instance Info '+ data.Names +'
id: ' + data.ID+ '
' + info += '
'+ JSON.stringify(log.data.test[0]) +'
' + this.$swal({ + type: 'Info', + title: 'Info!', + icon:'warning', + html: info, + showCloseButton: true, + showLoaderOnConfirm: false, + allowOutsideClick: false, + cancelButtonText: 'No, cancel!', + showCancelButton: false, + showLoaderOnConfirm: false, + reverseButtons: true, + focusCancel: true, + confirmButtonText: 'Ok!' + }) + }else if(action == 'delete-item' ){ this.$swal({ type: 'info', diff --git a/src/components/mynetwork/images.vue b/src/components/mynetwork/images.vue index e37f272..7c903b8 100644 --- a/src/components/mynetwork/images.vue +++ b/src/components/mynetwork/images.vue @@ -110,6 +110,11 @@ class="ti-trash btn btn-outline-secondary btn-sm" round @click="onAction('rm-item', props.rowData, props.rowIndex)"> + + @@ -208,7 +213,7 @@ export default { name: 'CreatedSince', sortField: 'CreatedSince', titleClass: 'center aligned', - dataClass: 'left aligned w-25', + dataClass: 'left aligned w-20', visible:true, width: '10%' }, @@ -230,7 +235,7 @@ export default { title: 'Actions', titleClass: 'center aligned', dataClass: 'center aligned', - width: '5%' + width: '10%' } ], apiurl:ApiConfig.url_80+"/dockerimages", @@ -383,7 +388,7 @@ export default { action:rmimages }) this.$wait.end('myRunInstancedockerimages'); - console.log(JSON.stringify(log)) + //console.log(JSON.stringify(log)) if(log.data.error == 'no'){ if(rmimages != 'images'){ var info='
' + log.data.out + '
' @@ -429,9 +434,31 @@ export default { this.actionrowindex = index this.image2rm = data //this.$root.$emit('hybrid_show_info',data) - console.log('rm '+JSON.stringify(data)) + //console.log('rm '+JSON.stringify(data)) //console.log('index '+this.actionrowindex) if(action == 'info-item' ){ + var log = await store.dispatch("pipelineLLO/hybrid_inspectimages",{ + token:this.token, + instance:this.image2rm.ID + }) + //console.log('index '+JSON.stringify(log.data.test[0])) + var info='
Image Info '+ data.Repository +'
id: ' + data.ID+ '
' + info += ''+ JSON.stringify(log.data.test[0]) +'' + this.$swal({ + type: 'Info', + title: 'Info!', + icon:'warning', + html: info, + showCloseButton: true, + showLoaderOnConfirm: false, + allowOutsideClick: false, + cancelButtonText: 'No, cancel!', + showCancelButton: false, + showLoaderOnConfirm: false, + reverseButtons: true, + focusCancel: true, + confirmButtonText: 'Ok!' + }) }else if(action == 'rm-item' ){ var info = 'test' /* @@ -480,7 +507,7 @@ export default { }) if(log.data.test != 'ok'){ - console.log('-------' + JSON.stringify(log.data.test)) + //console.log('-------' + JSON.stringify(log.data.test)) var info='
' + log.data.test + '
' this.$swal({ type: 'Info', diff --git a/src/components/mynetwork/mytable.vue b/src/components/mynetwork/mytable.vue index 5364dc6..57ae5b7 100755 --- a/src/components/mynetwork/mytable.vue +++ b/src/components/mynetwork/mytable.vue @@ -670,9 +670,6 @@ export default { instance:this.hybridshowdata.Names }) var pocmypathtmp = log.data.mypath - //console.log('log--poc--- ' + pocmypath) - //console.log('log111111111111111---------- ' + JSON.stringify(log)) - var container_bash = '/bin/sh' var container_user = false var swarmlabinstance = new RegExp("^(hybrid-|HYBRID-)"); @@ -684,11 +681,9 @@ export default { // ----- var swarmlabinstance1c = new RegExp("(/poc-|/POC-)"); var pocurl = 'no' - //console.log('log---------- ' + JSON.stringify(this.hybridshowdata)) var myNetwork = this.hybridshowdata.Networks.split('_') var pocmypath = pocmypathtmp + myNetwork[0] - //console.log('log---imypath ok------- ' + JSON.stringify(pocmypath)) if(swarmlabinstance1c.test(this.hybridshowdata.Image)){ var swarmlabinstance1cd = new RegExp("(->)"); if(swarmlabinstance1cd.test(this.hybridshowdata.Ports)){ @@ -698,11 +693,22 @@ export default { if(swarmlabinstance1ce.test(this.hybridshowdata.Names)){ pocurl = 'http://localhost:'+splitcd1[0]+'/?token='+this.token } - //console.log('log1a---------- ' + pocurl) - //console.log('log1---------- ' + JSON.stringify(this.hybridshowdata)) } - //container_user = true } +// ----- + var swarmlabinstance1ca = new RegExp("(microservice-codeserver)"); + var pocurlcodeserver = 'no' + if(swarmlabinstance1ca.test(this.hybridshowdata.Names)){ + //console.log('stringify--1------- ' + JSON.stringify(this.hybridshowdata.Names)); + var swarmlabinstance1cda = new RegExp("(->)"); + if(swarmlabinstance1cda.test(this.hybridshowdata.Ports)){ + var splitcda = this.hybridshowdata.Ports.split(':') + var splitcd1a = splitcda[1].split('-') + pocurlcodeserver = 'http://localhost:'+splitcd1a[0]+'/?token='+this.token + } + } + //console.log('stringify--------- ' + JSON.stringify(pocurlcodeserver)); + // ----- var swarmlabinstance = new RegExp("^(hybrid-|HYBRID-)"); if(swarmlabinstance.test(this.hybridshowdata.Names)){ @@ -734,6 +740,13 @@ if(pocurl != 'no'){ info +='

' } + +if(pocurlcodeserver != 'no'){ + info +='

' + info += 'Click here to open the Web_App' + info +='

' +} + var pocmypathinfo = '' if(pocmypath != ''){ diff --git a/src/components/mynetwork/networks.vue b/src/components/mynetwork/networks.vue new file mode 100644 index 0000000..0cfb9e9 --- /dev/null +++ b/src/components/mynetwork/networks.vue @@ -0,0 +1,603 @@ + + + diff --git a/src/main.js b/src/main.js index 962b15a..03223d1 100644 --- a/src/main.js +++ b/src/main.js @@ -27,7 +27,7 @@ var socketurl = ApiConfig.url_80; const socket = io(socketurl, { autoConnect: false, reconnection: true, - reconnectionDelay: 500, + reconnectionDelay: 3000, maxReconnectionAttempts: Infinity, pingInterval: 25000, pingTimeout: 60000, diff --git a/src/store/modules/create_pipelineLLO.js b/src/store/modules/create_pipelineLLO.js index a994570..b14fe9c 100644 --- a/src/store/modules/create_pipelineLLO.js +++ b/src/store/modules/create_pipelineLLO.js @@ -398,6 +398,130 @@ export default { return R; } } + }, + async hybrid_rmnetworks({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+'/hybrid_rmnetworks' + 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_inspectnetworks({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+'/hybrid_inspectnetworks' + 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_inspectimages({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+'/hybrid_inspectimages' + 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_inspectcontainer({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+'/hybrid_inspectcontainer' + 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_rmall({commit,rootGetters}, value) { //console.log('value '+JSON.stringify(value))