antosdk-apps/Dockman/build/debug/main.js

1 line
5.4 KiB
JavaScript
Raw Normal View History

2021-04-01 13:01:33 +02:00
(function(){var t;t=class extends this.OS.application.BaseApplication{constructor(t){super("Dockman",t)}main(){var t,e,i,s;for(this.setting.hosts||(this.setting.hosts=[]),this.treeview=this.find("obj-view"),this.currenthost=void 0,this.tabbar=this.find("host-tab-bar"),this.tabbar.ontabselect=t=>(this.currenthost=t.data.item.data,this.loadHost()),this.tabbar.ontabclose=t=>{var e,i;return(e=this.setting.hosts.indexOf(t.data.item.data))>=0&&(this.tabbar.selected===e&&(i=e+1,e>=this.setting.hosts.length-1&&(i=e-1),this.tabbar.selected=i),this.setting.hosts.splice(e,1),!0)},this.find("add").onbtclick=t=>this.openDialog("MultiInputDialog",{title:"__(Add new Docker host)",model:{text:"__(Name)",url:"__(Host url)"},allow_empty:!1}).then(t=>this.addTab(t,!0)),this.imglist=this.find("img-list"),this.imglist.onlistselect=t=>{var e;return this.loadContainer(t.data.item.data.text,!1),e={text:t.data.item.data.text,nodes:this.getTreeData(t.data.item.data)},this.treeview.data=e,this.treeview.expandAll()},this.ctnlist=this.find("container-list"),this.ctnlist.onlistselect=t=>{var e;return e={text:t.data.item.data.text,nodes:this.getTreeData(t.data.item.data)},this.treeview.data=e,this.treeview.expandAll(),this.imglist.selected=-1},this.imglist.buttons=[{text:"",iconclass:"fa fa-arrow-down",onbtclick:()=>{var t,e;return t="",(e=this.imglist.selectedItem)&&(t=e.data.text),this.openDialog("PromptDialog",{title:__("Pull image"),label:__("Pull image:"),value:t}).then(t=>{if(""!==t)return this.exec("pull_image",{host:this.currenthost.url,image:t}).then(t=>t.error?this.error(t.error):this.openDialog("TextDialog",{title:__("Command output"),disable:!0,value:atob(t.result)}).then(t=>this.loadHost()))})}},{text:"",iconclass:"fa fa-refresh",onbtclick:()=>this.loadHost()},{text:"",iconclass:"fa fa-minus",onbtclick:()=>{var t;if(t=this.imglist.selectedItem)return this.ask({title:__("Comfirm delete"),text:__("Are you sure?")}).then(e=>{if(e)return this.exec("rm_image",{host:this.currenthost.url,id:t.data.ID}).then(t=>t.error?this.error(t.error):this.openDialog("TextDialog",{title:__("Command output"),disable:!0,value:t.result}).then(t=>this.loadHost()))})}}],this.ctnlist.buttons=[{text:"",iconclass:"fa fa-play",onbtclick:()=>{var t,e;if((e=this.ctnlist.selectedItem)&&e.data&&!(t=e.data).Detail.State.Running)return this.exec("run_container",{host:this.currenthost.url,id:t.ID}).then(e=>e.error?this.error(e.error):(this.notify(__("Container {0} started",t.ID)),this.loadContainer(t.Image,!0)))}},{text:"",iconclass:"fa fa-stop",onbtclick:()=>{var t,e;if((e=this.ctnlist.selectedItem)&&e.data&&(t=e.data).Detail.State.Running)return this.exec("stop_container",{host:this.currenthost.url,id:t.ID}).then(e=>e.error?this.error(e.error):(this.notify(__("Container {0} stopped",t.ID)),this.loadContainer(t.Image,!0)))}},{text:"",iconclass:"fa fa-refresh",onbtclick:()=>{var t,e,i;if(t=this.ctnlist.data[0])e=t.Image;else{if(!(i=this.imglist.selectedItem))return;e=i.data.text}return this.loadContainer(e,!0)}},{text:"",iconclass:"fa fa-plus",onbtclick:()=>{var t;if(this.ctnlist.data[0])t=this.ctnlist.data[0].Image;else{if(!this.imglist.selectedItem)return;t=this.imglist.selectedItem.data.text}return console.log(t),this.openDialog("KeyValueDialog",{title:__("Container parameters"),data:{p:"8080:80",restart:"always",name:"Container_Name",memory:"200m",cpus:"1",hostname:"Container_HostNamed"}}).then(e=>this.exec("create_container",{host:this.currenthost.url,image:t,parameters:e}).then(e=>e.error?this.error(e.error):this.openDialog("TextDialog",{title:__("Command output"),disable:!0,value:e.result}).then(e=>this.loadContainer(t,!0))))}},{text:"",iconclass:"fa fa-minus",onbtclick:()=>{var t,e;if((e=this.ctnlist.selectedItem)&&e.data)return t=e.data,this.ask({title:__("Comfirm delete"),text:__("Are you sure?")}).then(e=>{if(e)return this.exec("rm_container",{host:this.currenthost.url,id:t.ID}).then(e=>e.error?this.error(e.error):(this.notify(__("Container {0} removed",t.ID)),this.loadContainer(t.Image,!0)))})}},{text:"",iconclass:"bi bi-bootstrap-reboot",onbtclick:()=>{