完成1.0版
parent
7ae24131c8
commit
ddd4892990
|
@ -5,7 +5,7 @@ Architecture: all
|
|||
Priority: optional
|
||||
Maintainer: Yutent <yutent.io@gmail.com>
|
||||
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管理面板。
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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`
|
||||
<main class="container">
|
||||
<div class="wrapper" @click=${this.#i}>
|
||||
<slot></slot>
|
||||
|
@ -19,4 +19,4 @@ import{css as p,html as c,Component as l,bind as a,unbind as f,styleMap as d,off
|
|||
</footer>
|
||||
</div>
|
||||
</main>
|
||||
`}}u.reg("popconfirm");
|
||||
`}}b.reg("popconfirm");
|
||||
|
|
|
@ -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}
|
||||
>
|
||||
<span
|
||||
class="action ${it.state === STATE_RUNNING
|
||||
|
@ -267,6 +270,7 @@ class Home extends Component {
|
|||
<wc-popconfirm
|
||||
title="是否要删除此容器?"
|
||||
@confirm=${ev => this.#remove(it)}
|
||||
disabled=${it.disabled}
|
||||
>
|
||||
<span class="action">🗑</span>
|
||||
</wc-popconfirm>
|
||||
|
|
|
@ -95,8 +95,6 @@ class Images extends Component {
|
|||
color: var(--color-blue-1);
|
||||
}
|
||||
.action {
|
||||
cursor: pointer;
|
||||
|
||||
&.red {
|
||||
color: var(--color-red-1);
|
||||
}
|
||||
|
|
|
@ -96,8 +96,6 @@ class Networks extends Component {
|
|||
}
|
||||
|
||||
.action {
|
||||
cursor: pointer;
|
||||
|
||||
&.red {
|
||||
color: var(--color-red-1);
|
||||
}
|
||||
|
|
|
@ -95,8 +95,6 @@ class Services extends Component {
|
|||
color: var(--color-blue-1);
|
||||
}
|
||||
.action {
|
||||
cursor: pointer;
|
||||
|
||||
&.red {
|
||||
color: var(--color-red-1);
|
||||
}
|
||||
|
|
|
@ -98,8 +98,6 @@ class Volumes extends Component {
|
|||
}
|
||||
|
||||
.action {
|
||||
cursor: pointer;
|
||||
|
||||
&.red {
|
||||
color: var(--color-red-1);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue