From ddd4892990d3c1019dbbaeec2951440fcae62735 Mon Sep 17 00:00:00 2001 From: yutent Date: Thu, 25 Jan 2024 12:06:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=901.0=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- debian/control | 2 +- usr/lib/dooke/_docker.py | 6 ++---- usr/lib/dooke/dooke.py | 8 +++----- usr/lib/dooke/webapp/lib/ui/modal/popconfirm.js | 4 ++-- usr/lib/dooke/webapp/views/home.js | 8 ++++++-- usr/lib/dooke/webapp/views/images.js | 2 -- usr/lib/dooke/webapp/views/networks.js | 2 -- usr/lib/dooke/webapp/views/services.js | 2 -- usr/lib/dooke/webapp/views/volumes.js | 2 -- 9 files changed, 14 insertions(+), 22 deletions(-) diff --git a/debian/control b/debian/control index a73c727..88a3aa6 100644 --- a/debian/control +++ b/debian/control @@ -5,7 +5,7 @@ Architecture: all Priority: optional Maintainer: Yutent Installed-Size: {{size}} -Depends: python3-webengine-gtk3 (>=0.6.1) +Depends: python3-webengine-gtk3 (>=0.7.0) Homepage: https://git.wkit.fun/appcat/dooke Author: yutent Description: docker管理面板。 diff --git a/usr/lib/dooke/_docker.py b/usr/lib/dooke/_docker.py index b81804f..7c94c0c 100644 --- a/usr/lib/dooke/_docker.py +++ b/usr/lib/dooke/_docker.py @@ -146,8 +146,7 @@ class Docker: def start(self, id = ''): cmd = 'docker start ' + id out = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE,stderr=subprocess.PIPE) - print('stdout', out.stdout.decode()) - print('stderr', out.stderr.decode()) + return out.stderr.decode().strip() @@ -155,8 +154,7 @@ class Docker: def stop(self, id = ''): cmd = 'docker stop ' + id out = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE,stderr=subprocess.PIPE) - print('stdout', out.stdout.decode()) - print('stderr', out.stderr.decode()) + return out.stderr.decode().strip() diff --git a/usr/lib/dooke/dooke.py b/usr/lib/dooke/dooke.py index dedaded..bfe0b7f 100755 --- a/usr/lib/dooke/dooke.py +++ b/usr/lib/dooke/dooke.py @@ -11,7 +11,6 @@ from webengine.gtk3 import WebEngine, create_setting, create_hmr_server, create_ from _window import Window from _docker import Docker -# from utils import run_async APP_ID = 'fun.wkit.dooke' @@ -50,7 +49,7 @@ class Application(Gtk.Application): def bridge_handler(self, ev, params): _error = None output = None - # print(ev, params) + match ev: case 'docker': action = params['action'] @@ -96,7 +95,6 @@ class Application(Gtk.Application): _error = client.rmi(params.get('id')) - return (_error, output) @@ -119,6 +117,6 @@ if __name__ == "__main__": try: app = Application() app.run(sys.argv) - except Exception as err: - print(err) + except KeyboardInterrupt: + pass diff --git a/usr/lib/dooke/webapp/lib/ui/modal/popconfirm.js b/usr/lib/dooke/webapp/lib/ui/modal/popconfirm.js index 27c5e79..0f8c24d 100644 --- a/usr/lib/dooke/webapp/lib/ui/modal/popconfirm.js +++ b/usr/lib/dooke/webapp/lib/ui/modal/popconfirm.js @@ -1,4 +1,4 @@ -import{css as p,html as c,Component as l,bind as a,unbind as f,styleMap as d,offset as h,outsideClick as m,clearOutsideClick as x}from"wkit";import"../base/button.js";const w="\u8BF7\u786E\u8BA4\u4F60\u7684\u64CD\u4F5C!";class u extends l{static props={title:"str!",confirmButtonType:"str!primary"};static styles=[p`:host{display:inline-flex}.container{position:relative}.tooltip{display:none;position:fixed;z-index:9;justify-content:center;align-items:center;max-width:260px;min-width:32px;padding:8px 12px 12px;border-radius:3px;font-size:var(--wc-popconfirm-font, 14px);background:var(--wc-popconfirm-background, #fff);color:var(--wc-popconfirm-color, var(--color-dark-1));box-shadow:0 0 3px var(--wc-popconfirm-shadow, rgba(0, 0, 0, 0.3));word-break:break-all;-webkit-user-select:none;user-select:none}.tooltip::after{position:absolute;display:block;width:8px;height:8px;border-radius:2px;background:var(--wc-popconfirm-background, #fff);content:"";transform:rotate(45deg);box-shadow:-1px -1px 0 var(--wc-popconfirm-shadow, rgba(0, 0, 0, 0.1))}.tooltip[placement=left-top]::after{right:16px;bottom:-4px;box-shadow:1px 1px 0 var(--wc-popconfirm-shadow, rgba(0, 0, 0, 0.1))}.tooltip[placement=left-bottom]::after{right:16px;top:-4px}.tooltip[placement=right-top]::after{left:16px;bottom:-4px;box-shadow:1px 1px 0 var(--wc-popconfirm-shadow, rgba(0, 0, 0, 0.1))}.tooltip[placement=right-bottom]::after{left:16px;top:-4px}`,p`.title{display:flex;align-items:center;gap:6px;padding:8px 0;--wc-icon-size: 16px}.title wc-icon{flex-shrink:0;color:var(--wc-popconfirm-icon-color, var(--color-red-1))}:host([hide-icon]) .title wc-icon{display:none}.actions{display:flex;justify-content:flex-end;gap:4px;margin-top:8px}.actions wc-button{min-width:40px;height:20px;font-size:12px}.actions wc-button:first-child{--wc-button-border-color: none}`];#t=!1;#i(s){let{left:t,top:e}=h(this),n="left",o={display:"block"},r=document.documentElement.scrollTop;if(!this.#t){if(t<260||t>260&&window.innerWidth-t>260)n="right",t-=12,t<0&&(t=0),o.left=t+"px";else{let i=window.innerWidth-t-this.clientWidth-12;i<0&&(i=0),o.right=i+"px"}if(e<160)e+=8+this.clientHeight,n+="-bottom",o.top=e+"px";else{let i=window.innerHeight-e+8;n+="-top",o.bottom=i+"px",r>0&&(o.transform=`translateY(-${r}px)`)}this.#t=!0,this.$refs.tips.setAttribute("placement",n),this.$refs.tips.style.cssText=d(o),this.$refs.tips.$animate()}}#o(){this.#t&&(this.#t=!1,this.$refs.tips.$animate(!0))}#e(){this.$emit("confirm"),this.#o()}mounted(){this._outFn=m(this,s=>this.#o()),this._scrollFn=a(document,"scroll",s=>{if(this.#t){let t=document.documentElement.scrollTop;this.$refs.tips.style.transform=`translateY(-${t}px)`}})}unmounted(){f(document,"scroll",this._scrollFn),x(this._outFn)}render(){return c` +import{css as p,html as c,Component as l,bind as a,unbind as d,styleMap as f,offset as h,outsideClick as m,clearOutsideClick as x}from"wkit";import"../base/button.js";const w="\u8BF7\u786E\u8BA4\u4F60\u7684\u64CD\u4F5C!";class b extends l{static props={title:"str!",confirmButtonType:"str!primary",disabled:!1};static styles=[p`:host{display:inline-flex}.container{position:relative}.container .wrapper{cursor:pointer}:host([disabled]){opacity:.6}:host([disabled]) .container .wrapper{cursor:not-allowed}.tooltip{display:none;position:fixed;z-index:9;justify-content:center;align-items:center;max-width:260px;min-width:32px;padding:8px 12px 12px;border-radius:3px;font-size:var(--wc-popconfirm-font, 14px);background:var(--wc-popconfirm-background, #fff);color:var(--wc-popconfirm-color, var(--color-dark-1));box-shadow:0 0 3px var(--wc-popconfirm-shadow, rgba(0, 0, 0, 0.3));word-break:break-all;-webkit-user-select:none;user-select:none}.tooltip::after{position:absolute;display:block;width:8px;height:8px;border-radius:2px;background:var(--wc-popconfirm-background, #fff);content:"";transform:rotate(45deg);box-shadow:-1px -1px 0 var(--wc-popconfirm-shadow, rgba(0, 0, 0, 0.1))}.tooltip[placement=left-top]::after{right:16px;bottom:-4px;box-shadow:1px 1px 0 var(--wc-popconfirm-shadow, rgba(0, 0, 0, 0.1))}.tooltip[placement=left-bottom]::after{right:16px;top:-4px}.tooltip[placement=right-top]::after{left:16px;bottom:-4px;box-shadow:1px 1px 0 var(--wc-popconfirm-shadow, rgba(0, 0, 0, 0.1))}.tooltip[placement=right-bottom]::after{left:16px;top:-4px}`,p`.title{display:flex;align-items:center;gap:6px;padding:8px 0;--wc-icon-size: 16px}.title wc-icon{flex-shrink:0;color:var(--wc-popconfirm-icon-color, var(--color-red-1))}:host([hide-icon]) .title wc-icon{display:none}.actions{display:flex;justify-content:flex-end;gap:4px;margin-top:8px}.actions wc-button{min-width:40px;height:20px;font-size:12px}.actions wc-button:first-child{--wc-button-border-color: none}`];#t=!1;#i(n){let{left:t,top:e}=h(this),s="left",o={display:"block"},r=document.documentElement.scrollTop;if(!(this.disabled||this.#t)){if(t<260||t>260&&window.innerWidth-t>260)s="right",t-=12,t<0&&(t=0),o.left=t+"px";else{let i=window.innerWidth-t-this.clientWidth-12;i<0&&(i=0),o.right=i+"px"}if(e<160)e+=8+this.clientHeight,s+="-bottom",o.top=e+"px";else{let i=window.innerHeight-e+8;s+="-top",o.bottom=i+"px",r>0&&(o.transform=`translateY(-${r}px)`)}this.#t=!0,this.$refs.tips.setAttribute("placement",s),this.$refs.tips.style.cssText=f(o),this.$refs.tips.$animate()}}#o(){this.#t&&(this.#t=!1,this.$refs.tips.$animate(!0))}#e(){this.$emit("confirm"),this.#o()}mounted(){this._outFn=m(this,n=>this.#o()),this._scrollFn=a(document,"scroll",n=>{if(this.#t){let t=document.documentElement.scrollTop;this.$refs.tips.style.transform=`translateY(-${t}px)`}})}unmounted(){d(document,"scroll",this._scrollFn),x(this._outFn)}render(){return c`
@@ -19,4 +19,4 @@ import{css as p,html as c,Component as l,bind as a,unbind as f,styleMap as d,off
- `}}u.reg("popconfirm"); + `}}b.reg("popconfirm"); diff --git a/usr/lib/dooke/webapp/views/home.js b/usr/lib/dooke/webapp/views/home.js index dfc4d9e..4c1ea0e 100644 --- a/usr/lib/dooke/webapp/views/home.js +++ b/usr/lib/dooke/webapp/views/home.js @@ -111,8 +111,6 @@ class Home extends Component { } .action { - cursor: pointer; - &.red { color: var(--color-red-1); } @@ -145,6 +143,7 @@ class Home extends Component { let list = await docker.containers(this.#all) list.forEach(it => { + it.disabled = false it.image = it.image.split(':') it.cmd = it.cmd.replace(/^"|"$/g, '') it.port = it.port @@ -180,10 +179,13 @@ class Home extends Component { async #toggleStat(item) { // + item.disabled = true if (item.state === STATE_RUNNING) { await docker.stop(item.id) + layer.toast('容器已经停止', 'success') } else { await docker.start(item.id) + layer.toast('容器已经启动', 'success') } this.#fetch() } @@ -255,6 +257,7 @@ class Home extends Component { it.state === STATE_RUNNING ? '停止' : '启动' }此容器?`} @confirm=${ev => this.#toggleStat(it)} + disabled=${it.disabled} > this.#remove(it)} + disabled=${it.disabled} > 🗑 diff --git a/usr/lib/dooke/webapp/views/images.js b/usr/lib/dooke/webapp/views/images.js index ca2c05f..42c2f5c 100644 --- a/usr/lib/dooke/webapp/views/images.js +++ b/usr/lib/dooke/webapp/views/images.js @@ -95,8 +95,6 @@ class Images extends Component { color: var(--color-blue-1); } .action { - cursor: pointer; - &.red { color: var(--color-red-1); } diff --git a/usr/lib/dooke/webapp/views/networks.js b/usr/lib/dooke/webapp/views/networks.js index a568ffb..1209c25 100644 --- a/usr/lib/dooke/webapp/views/networks.js +++ b/usr/lib/dooke/webapp/views/networks.js @@ -96,8 +96,6 @@ class Networks extends Component { } .action { - cursor: pointer; - &.red { color: var(--color-red-1); } diff --git a/usr/lib/dooke/webapp/views/services.js b/usr/lib/dooke/webapp/views/services.js index bc8e7bc..5903f24 100644 --- a/usr/lib/dooke/webapp/views/services.js +++ b/usr/lib/dooke/webapp/views/services.js @@ -95,8 +95,6 @@ class Services extends Component { color: var(--color-blue-1); } .action { - cursor: pointer; - &.red { color: var(--color-red-1); } diff --git a/usr/lib/dooke/webapp/views/volumes.js b/usr/lib/dooke/webapp/views/volumes.js index 0c0835f..77b4d00 100644 --- a/usr/lib/dooke/webapp/views/volumes.js +++ b/usr/lib/dooke/webapp/views/volumes.js @@ -98,8 +98,6 @@ class Volumes extends Component { } .action { - cursor: pointer; - &.red { color: var(--color-red-1); }