You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
563 lines
16 KiB
563 lines
16 KiB
3 years ago
|
<template>
|
||
|
<card class="card-user" style="max-height:100%">
|
||
|
|
||
|
|
||
|
<v-wait for="myRunInstancetutor">
|
||
|
<template slot="waiting">
|
||
|
<div>
|
||
|
<img src="@/assets/loading.gif" />
|
||
|
Enter Lab_room...
|
||
|
</div>
|
||
|
</template>
|
||
|
</v-wait>
|
||
|
|
||
|
<b-container fluid class="bv-example-row">
|
||
|
|
||
|
<div class="input-group input-group-sm sm-3">
|
||
|
<div class="input-group-append">
|
||
|
<button
|
||
|
class="btn btn-outline-info"
|
||
|
round
|
||
|
type="button"
|
||
|
@click="setRefresh">
|
||
|
Refresh table</button>
|
||
|
</div>
|
||
|
|
||
|
<input type="text"
|
||
|
class="form-control"
|
||
|
aria-label="Small" aria-describedby="inputGroup-sizing-sm"
|
||
|
placeholder="Search by Name"
|
||
|
v-model="searchFor"
|
||
|
@keyup.enter="setFilter"
|
||
|
>
|
||
|
|
||
|
<div class="input-group-append">
|
||
|
<button
|
||
|
class="btn btn-outline-primary"
|
||
|
round
|
||
|
type="button"
|
||
|
@click="setFilter">
|
||
|
Go</button>
|
||
|
</div>
|
||
|
|
||
|
<div class="input-group-append">
|
||
|
<button class="btn btn-outline-secondary"
|
||
|
round
|
||
|
type="button"
|
||
|
@click="resetFilter">
|
||
|
Reset</button>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="white h-100 flex-fixed-width-item"
|
||
|
<vuetable
|
||
|
ref="vuetable"
|
||
|
:key="vuetablekeyl"
|
||
|
:api-url='apiurl'
|
||
|
:api-mode="true"
|
||
|
:http-options="httpOptions"
|
||
|
:fields="fields"
|
||
|
:item-actions="itemActions"
|
||
|
:sort-order="sortOrder"
|
||
|
:show-sort-icons="true"
|
||
|
:multi-sort="multiSort"
|
||
|
:per-page="perpage"
|
||
|
pagination-path="links.pagination"
|
||
|
:pagination-component="paginationComponent"
|
||
|
:append-params="moreParams"
|
||
|
wrapper-class="vuetable-wrapper"
|
||
|
loading-class="loading"
|
||
|
detail-row-id="id"
|
||
|
@vuetable:pagination-data="onPaginationData"
|
||
|
@vuetable:load-success="loadsuccess"
|
||
|
@vuetable:load-error="onLoadError"
|
||
|
:css="css.table"
|
||
|
>
|
||
|
|
||
|
<div slot="actions" slot-scope="props">
|
||
|
<button
|
||
|
v-if="actionrowindex == props.rowIndex"
|
||
|
class="ti-more-alt btn btn-secondary btn-sm"
|
||
|
round
|
||
|
@click="onAction('run-more', props.rowData, props.rowIndex)">
|
||
|
</button>
|
||
|
<button
|
||
|
v-else
|
||
|
class="ti-more btn btn-outline-secondary btn-sm"
|
||
|
round
|
||
|
@click="onAction('run-more', props.rowData, props.rowIndex)">
|
||
|
</button>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
<div slot="actionslocal" slot-scope="props">
|
||
|
<div class="d-flex justify-content-center"
|
||
|
v-if="checkbuildrowindex(props.rowData,props.rowIndex)"
|
||
|
>
|
||
|
<button
|
||
|
v-if="testactionrowindex[props.rowData.name] == props.rowIndex"
|
||
|
class="ti-trash btn btn-info btn-sm"
|
||
|
title="Remove Box_Instance"
|
||
|
round
|
||
|
@click="onAction('delete-item', props.rowData, props.rowIndex)"
|
||
|
>
|
||
|
</button>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
</vuetable>
|
||
|
<div class="vuetable-pagination ui basic segment grid">
|
||
|
<vuetable-pagination-info
|
||
|
ref="paginationInfo"
|
||
|
:css="css.paginationInfo"
|
||
|
>
|
||
|
</vuetable-pagination-info>
|
||
|
<vuetable-pagination
|
||
|
:css="css.pagination"
|
||
|
ref="pagination"
|
||
|
@vuetable-pagination:change-page="onChangePage"
|
||
|
>
|
||
|
</vuetable-pagination>
|
||
|
</div>
|
||
|
</div>
|
||
|
</b-container>
|
||
|
</card>
|
||
|
</template>
|
||
|
<script>
|
||
|
import store from '@/store/index'
|
||
|
import {mapState, mapGetters, mapActions,dispatch} from 'vuex'
|
||
|
import Vue from 'vue'
|
||
|
import {Vuetable, VuetablePaginationDropdown} from 'vuetable-2'
|
||
|
import VuetablePaginationInfo from 'vuetable-2/src/components/VuetablePaginationInfo'
|
||
|
import VuetablePagination from 'vuetable-2/src/components/VuetablePagination'
|
||
|
import CssConfig from 'vuetable-2/src/components/VuetableCssConfig.js'
|
||
|
import card from '@/components/Card.vue'
|
||
|
import {ApiConfig} from "@/config/index";
|
||
|
export default {
|
||
|
components: {
|
||
|
card,
|
||
|
Vuetable,
|
||
|
VuetablePagination,
|
||
|
VuetablePaginationInfo,
|
||
|
VuetablePaginationDropdown
|
||
|
},
|
||
|
props: {
|
||
|
},
|
||
|
data() {
|
||
|
return{
|
||
|
actionrowindex:'',
|
||
|
playbookInfo: {},
|
||
|
token: '',
|
||
|
build_file :{},
|
||
|
testactionrowindex:[], // downloaded used in installed
|
||
|
playbook: {
|
||
|
'title':'',
|
||
|
'name':'',
|
||
|
'description':''
|
||
|
},
|
||
|
container:{
|
||
|
name:'',
|
||
|
view:0
|
||
|
},
|
||
|
pipeline:{},
|
||
|
selected: 'hybrid',
|
||
|
options: [
|
||
|
{ text: 'Packages', value: 'packages' },
|
||
|
{ text: 'Images', value: 'images' },
|
||
|
{ text: 'Scripts', value: 'scripts' }
|
||
|
],
|
||
|
showModal: false,
|
||
|
visibility: [],
|
||
|
active:false,
|
||
|
rmbox:{},
|
||
|
vuetablekeyl:0,
|
||
|
fielddata:{},
|
||
|
fields: [
|
||
|
{
|
||
|
name: 'name',
|
||
|
title: '<span class="orange"></span>Name',
|
||
|
sortField: 'name',
|
||
|
visible:true,
|
||
|
dataClass: 'text-left text-wrap text-break break-word',
|
||
|
width: '65%'
|
||
|
},
|
||
|
{
|
||
|
name: 'Image',
|
||
|
title: '<span class="orange"></span>Image',
|
||
|
//sortField: 'Image',
|
||
|
visible:false,
|
||
|
dataClass: 'left aligned w-25',
|
||
|
width: '15%',
|
||
|
formatter (value) {
|
||
|
const result = /^ondemand_playground/.test(value);
|
||
|
if (result) {
|
||
|
var v = '<p class="text-warning">Playground</p>'
|
||
|
return v
|
||
|
}else{
|
||
|
var v = '<p class="text-info">Lab</p>'
|
||
|
return v
|
||
|
}
|
||
|
}
|
||
|
|
||
|
},
|
||
|
{
|
||
|
name: '_id',
|
||
|
title: '<span class="orange"></span>mongo',
|
||
|
visible:false
|
||
|
},
|
||
|
{
|
||
|
name: 'Status',
|
||
|
title: '<span class="orange"></span>Status',
|
||
|
sortField: 'Status',
|
||
|
titleClass: 'center aligned',
|
||
|
visible:true,
|
||
|
width: '10%'
|
||
|
},
|
||
|
{
|
||
|
name: 'ID',
|
||
|
sortField: 'ID',
|
||
|
titleClass: 'center aligned',
|
||
|
dataClass: 'left aligned w-25',
|
||
|
visible:false,
|
||
|
width: '15%'
|
||
|
},
|
||
|
{
|
||
|
name: '__slot:actionslocal', // <----
|
||
|
title: 'Box',
|
||
|
titleClass: 'center',
|
||
|
dataClass: 'center aligned',
|
||
|
width: '5%'
|
||
|
},
|
||
|
{
|
||
|
name: '__slot:actions', // <----
|
||
|
title: 'Actions',
|
||
|
titleClass: 'center aligned',
|
||
|
dataClass: 'center aligned',
|
||
|
width: '5%'
|
||
|
},
|
||
|
],
|
||
|
apiurl:ApiConfig.url_80+"/buildservices",
|
||
|
//apiurl:ApiConfig.swarmlab_url_80+"/swarmlabhybridservices",
|
||
|
css: CssConfig,
|
||
|
perpage: 5,
|
||
|
searchFor: '',
|
||
|
sortOrder: [{
|
||
|
field: 'name',
|
||
|
direction: 'asc'
|
||
|
}],
|
||
|
multiSort: true,
|
||
|
paginationComponent: 'vuetable-pagination',
|
||
|
itemActions: [
|
||
|
{ name: 'view-item', label: '', icon: 'glyphicon glyphicon-zoom-in', class: 'btn btn-info', extra: {'title': 'View', 'data-toggle':"tooltip", 'data-placement': "left"} },
|
||
|
{ name: 'edit-item', label: '', icon: 'glyphicon glyphicon-pencil', class: 'btn btn-warning', extra: {title: 'Edit', 'data-toggle':"tooltip", 'data-placement': "top"} },
|
||
|
{ name: 'delete-item', label: '', icon: 'glyphicon glyphicon-remove', class: 'btn btn-danger', extra: {title: 'Delete', 'data-toggle':"tooltip", 'data-placement': "right" } }
|
||
|
],
|
||
|
moreParams: {
|
||
|
'filter': '',
|
||
|
'type': 'scripts',
|
||
|
'tutor': 'yes'
|
||
|
},
|
||
|
|
||
|
}
|
||
|
},
|
||
|
mounted() {
|
||
|
this.$root.$on('SERVER_build_closebuild', (v) => {
|
||
|
console.log('build from server '+JSON.stringify(v))
|
||
|
if(v.build == "ok" && v.file !== 'false'){
|
||
|
Vue.set(this.build_file, v.name, v.name)
|
||
|
// this.$set(this.user, 'last_name', 'Doe')
|
||
|
console.log('build ok '+JSON.stringify(this.build_file))
|
||
|
}else{
|
||
|
Vue.delete(this.build_file, v.name)
|
||
|
console.log('build no '+JSON.stringify(this.build_file))
|
||
|
}
|
||
|
if( v.homefile_exist == 'yes'){
|
||
|
console.log('build no '+JSON.stringify(v.homefile))
|
||
|
var info = `
|
||
|
<b-container fluid>
|
||
|
<div class="row text-center">
|
||
|
<div class="col-12">
|
||
|
|
||
|
<h5> <b>File exists</b> </h5>
|
||
|
<h5> Error: You cannot Create a VM that already exists.</h5>
|
||
|
<h5> Please rename or remove the file and Retry </h5>
|
||
|
<p class="mb-1 list-group-item list-group-item-success">
|
||
|
${v.homefile}
|
||
|
</p>
|
||
|
</div> <!-- col -->
|
||
|
</div> <!-- row -->
|
||
|
</b-container fluid>
|
||
|
`
|
||
|
this.$swal({
|
||
|
type: 'info',
|
||
|
html: info,
|
||
|
icon: 'info',
|
||
|
showCloseButton: true,
|
||
|
showLoaderOnConfirm: false,
|
||
|
allowOutsideClick: false,
|
||
|
cancelButtonText: 'No, cancel!',
|
||
|
showCancelButton: false,
|
||
|
showLoaderOnConfirm: false,
|
||
|
reverseButtons: true,
|
||
|
focusCancel: false,
|
||
|
confirmButtonText: 'ok! '
|
||
|
})
|
||
|
}
|
||
|
this.refreshVuetable()
|
||
|
})
|
||
|
},
|
||
|
created() {
|
||
|
var url_string = window.location.href
|
||
|
var url = new URL(url_string);
|
||
|
this.token = url.searchParams.get("token");
|
||
|
//console.log("token "+ this.token);
|
||
|
|
||
|
},
|
||
|
beforeDestroy () {
|
||
|
this.$root.$off('SERVER_build_closebuild')
|
||
|
},
|
||
|
computed: {
|
||
|
httpOptions() {
|
||
|
var token = this.token
|
||
|
var p="headers: {Authorization: token}}"; //table props -> :http-options="httpOptions"
|
||
|
return {headers: {Authorization: 'Bearer ' + token}} //table props -> :http-options="httpOptions"
|
||
|
},
|
||
|
|
||
|
},
|
||
|
|
||
|
methods: {
|
||
|
onError (type,description) {
|
||
|
var winfo=description
|
||
|
var info='<h5>Bootstrap '+type+'</h5>'
|
||
|
this.$swal({
|
||
|
type: type,
|
||
|
html: info+winfo,
|
||
|
showCloseButton: true,
|
||
|
showLoaderOnConfirm: false,
|
||
|
allowOutsideClick: false,
|
||
|
cancelButtonText: 'No, cancel!',
|
||
|
showCancelButton: false,
|
||
|
showLoaderOnConfirm: false,
|
||
|
reverseButtons: true,
|
||
|
focusCancel: true,
|
||
|
confirmButtonText: 'Ok!'
|
||
|
})
|
||
|
},
|
||
|
|
||
|
|
||
|
setRefresh () {
|
||
|
this.moreParams = {
|
||
|
'filter': '',
|
||
|
'type': this.selected
|
||
|
}
|
||
|
Vue.nextTick( () => this.$refs.vuetable.refresh())
|
||
|
},
|
||
|
setFilter () {
|
||
|
this.moreParams = {
|
||
|
'filter': this.searchFor,
|
||
|
'type': this.selected
|
||
|
}
|
||
|
Vue.nextTick( () => this.$refs.vuetable.refresh())
|
||
|
},
|
||
|
resetFilter () {
|
||
|
this.moreParams = {}
|
||
|
this.searchFor = ''
|
||
|
Vue.nextTick( () => this.$refs.vuetable.refresh())
|
||
|
},
|
||
|
onPaginationData (paginationData) {
|
||
|
this.$refs.pagination.setPaginationData(paginationData)
|
||
|
this.$refs.paginationInfo.setPaginationData(paginationData)
|
||
|
},
|
||
|
onChangePage (page) {
|
||
|
this.$refs.vuetable.changePage(page)
|
||
|
},
|
||
|
editRow(rowData) {
|
||
|
alert("You clicked edit on"+ JSON.stringify(rowData));
|
||
|
},
|
||
|
async onAction (action, data, index) {
|
||
|
this.actionrowindex = index
|
||
|
this.rmbox = data
|
||
|
var obj = {}
|
||
|
obj.name = data.name
|
||
|
obj.dir = data.dir
|
||
|
obj.config = data.config
|
||
|
this.$root.$emit('BUILD_hybrid_show_info',data)
|
||
|
console.log('index '+this.actionrowindex)
|
||
|
console.log('data '+JSON.stringify(obj))
|
||
|
if(action == 'view-item' ){
|
||
|
console.log('data' + JSON.stringify(data))
|
||
|
console.log('index '+JSON.stringify(index))
|
||
|
console.log('build info '+JSON.stringify(this.build_file))
|
||
|
}else if(action == 'delete-item' ){
|
||
|
var info = `
|
||
|
<b-container fluid>
|
||
|
<div class="row text-center">
|
||
|
<div class="col-12">
|
||
|
<p class="mb-1 list-group-item list-group-item-success">
|
||
|
Remove
|
||
|
</p>
|
||
|
</div> <!-- col -->
|
||
|
</div> <!-- row -->
|
||
|
</b-container fluid>
|
||
|
`
|
||
|
this.$swal({
|
||
|
type: 'info',
|
||
|
html: info,
|
||
|
showCloseButton: true,
|
||
|
showLoaderOnConfirm: false,
|
||
|
allowOutsideClick: false,
|
||
|
cancelButtonText: 'No, cancel!',
|
||
|
showCancelButton: true,
|
||
|
showLoaderOnConfirm: false,
|
||
|
reverseButtons: true,
|
||
|
focusCancel: false,
|
||
|
confirmButtonText: 'Remove the box! '
|
||
|
}).then((result)=> {
|
||
|
this.removeAndClose(result);
|
||
|
})
|
||
|
console.log('data da1 '+JSON.stringify(data))
|
||
|
}else if(action == 'run-item' ){
|
||
|
}
|
||
|
},
|
||
|
async removeAndClose(result){
|
||
|
var obj = {}
|
||
|
obj.instance = this.rmbox.name
|
||
|
obj.dir = this.rmbox.dir
|
||
|
obj.config = this.rmbox.config
|
||
|
if (result.isConfirmed) {
|
||
|
//console.log('value obj11111111111111111111111 '+ JSON.stringify(result))
|
||
|
var res1 = await store.dispatch('pipelineLLO/rmbuildstatus', obj)
|
||
|
console.log('value objdata111111111111111111 '+ JSON.stringify(res1))
|
||
|
if(res1.data.data == 'yes'){
|
||
|
Vue.delete(this.testactionrowindex, data.name)
|
||
|
Vue.nextTick( () => this.$refs.vuetable.refresh())
|
||
|
}
|
||
|
}else {
|
||
|
console.log('no')
|
||
|
}
|
||
|
},
|
||
|
async checkbuildrowindex(data,index){
|
||
|
if(this.testactionrowindex[index] == index){
|
||
|
var obj = {}
|
||
|
obj.token = this.token
|
||
|
obj.instance = data.name
|
||
|
var res1 = await store.dispatch('pipelineLLO/getbuildstatus', obj)
|
||
|
if(res1.data.data == 'yes'){
|
||
|
Vue.set(this.testactionrowindex, data.name, index)
|
||
|
}else{
|
||
|
Vue.delete(this.testactionrowindex, data.name)
|
||
|
}
|
||
|
console.log('resi NO3 '+JSON.stringify(this.testactionrowindex))
|
||
|
}else{
|
||
|
var obj = {}
|
||
|
obj.token = this.token
|
||
|
obj.instance = data.name
|
||
|
var res = await store.dispatch('pipelineLLO/getbuildstatus', obj)
|
||
|
if(res.data.data == 'yes'){
|
||
|
Vue.set(this.testactionrowindex, index, index)
|
||
|
}else{
|
||
|
Vue.delete(this.testactionrowindex, data.name)
|
||
|
}
|
||
|
console.log('resi NO2 '+JSON.stringify(this.testactionrowindex))
|
||
|
}
|
||
|
},
|
||
|
refreshVuetable() {
|
||
|
this.$nextTick(()=>{
|
||
|
this.vuetablekeyl += 1
|
||
|
})
|
||
|
},
|
||
|
playbookinfoShow(value) {
|
||
|
return this.visibility[value]=true
|
||
|
},
|
||
|
playbookinfo(value) {
|
||
|
return this.playbookInfo=value
|
||
|
},
|
||
|
rowClicked(row, event) {
|
||
|
return {
|
||
|
html: true,
|
||
|
title: () => { return 'Hello <b>Popover:</b> ' + (++this.counter) },
|
||
|
content: () => { return 'The date is:<br><em>' + new Date() + '</em>' }
|
||
|
}
|
||
|
},
|
||
|
loadsuccess(response) {
|
||
|
var data = response.data.data
|
||
|
this.fielddata=data
|
||
|
var n = data.length
|
||
|
n=n-1
|
||
|
},
|
||
|
onLoadError(payload) {
|
||
|
/*
|
||
|
//error2 "invalid_token" join-service.vue:684
|
||
|
//error2 "The access token provided has expired" join-service.vue:685
|
||
|
//error2 "Unauthorized" join-service.vue:686
|
||
|
//error2 401
|
||
|
console.log('error2 '+JSON.stringify(payload.response.data.error))
|
||
|
console.log('error2 '+JSON.stringify(payload.response.data.error_description))
|
||
|
console.log('error2 '+JSON.stringify(payload.response.statusText))
|
||
|
console.log('error2 '+JSON.stringify(payload.response.status))
|
||
|
*/
|
||
|
if(payload.response.status == '401'){
|
||
|
window.location.href = 'https://api-login.swarmlab.io:8089';
|
||
|
Vue.nextTick( () => window.location.href = 'https://api-login.swarmlab.io:8089')
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
},
|
||
|
|
||
|
|
||
|
actions: {
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
};
|
||
|
</script>
|
||
|
<style>
|
||
|
.flex-fixed-width-item {
|
||
|
flex: 0 0 100px;
|
||
|
}
|
||
|
.modalinfo {
|
||
|
z-index: 10000000 !important;
|
||
|
position:fixed;
|
||
|
}
|
||
|
/* a container with flex-direction column */
|
||
|
|
||
|
.vue-notifyjs.notifications{
|
||
|
.alert{
|
||
|
z-index: 100;
|
||
|
}
|
||
|
.list-move {
|
||
|
transition: transform 0.3s, opacity 0.4s;
|
||
|
}
|
||
|
.list-item {
|
||
|
display: inline-block;
|
||
|
margin-right: 10px;
|
||
|
|
||
|
}
|
||
|
.list-enter-active {
|
||
|
transition: transform 0.2s ease-in, opacity 0.4s ease-in;
|
||
|
}
|
||
|
.list-leave-active {
|
||
|
transition: transform 1s ease-out, opacity 0.4s ease-out;
|
||
|
}
|
||
|
|
||
|
.list-enter {
|
||
|
opacity: 0;
|
||
|
transform: scale(1.1);
|
||
|
|
||
|
}
|
||
|
.list-leave-to {
|
||
|
opacity: 0;
|
||
|
transform: scale(1.2, 0.7);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
pre {
|
||
|
//background-color: rgb(255, 247, 229);
|
||
|
background-color: #eff0f1;
|
||
|
border: 1px solid blue;
|
||
|
//white-space: pre-line;
|
||
|
}
|
||
|
|
||
|
</style>
|