master
yutent 2024-01-19 18:46:14 +08:00
parent 34667c6f56
commit ae5ad33a75
4 changed files with 42 additions and 21 deletions

View File

@ -61,11 +61,20 @@ class Application(Gtk.Application):
case 'images':
output = client.images()
case 'services':
output = client.services()
case 'volumns':
output = client.volumns()
case 'networks':
output = client.networks()
case 'rm':
client.rm(params.get('id'))
_error = client.rm(params.get('id'))
case 'rmi':
client.rmi(params.get('id'))
_error = client.rmi(params.get('id'))

View File

@ -8,18 +8,32 @@ import { nextTick } from 'wkit'
export function noop() {}
export function getContainers(all = true) {
return native.handler('docker', { action: 'containers', all })
}
export const docker = {
containers(all = true) {
return native.handler('docker', { action: 'containers', all })
},
export function getImages() {
return native.handler('docker', { action: 'images' })
}
images() {
return native.handler('docker', { action: 'images' })
},
export function removeContainer(id) {
return native.handler('docker', { action: 'rm', id })
}
volumns() {
return native.handler('docker', { action: 'volumns' })
},
export function removeImage(id) {
return native.handler('docker', { action: 'rmi', id })
networks() {
return native.handler('docker', { action: 'networks' })
},
services() {
return native.handler('docker', { action: 'services' })
},
rm(id) {
return native.handler('docker', { action: 'rm', id })
},
rmi(id) {
return native.handler('docker', { action: 'rmi', id })
}
}

View File

@ -5,7 +5,7 @@
*/
import { html, css, Component, classMap, nextTick, outsideClick } from 'wkit'
import { getContainers, removeContainer } from '../utils/index.js'
import { docker } from '../utils/index.js'
class Home extends Component {
static props = {
@ -138,7 +138,7 @@ class Home extends Component {
}
async #fetch() {
let list = await getContainers(this.#all)
let list = await docker.containers(this.#all)
list.forEach(it => {
it.image = it.image.split(':')
@ -171,7 +171,7 @@ class Home extends Component {
}
async #remove(item) {
await removeContainer(item.id)
await docker.rm(item.id)
this.#fetch()
}

View File

@ -5,7 +5,7 @@
*/
import { html, css, Component, classMap, nextTick, outsideClick } from 'wkit'
import { getImages, removeImage } from '../utils/index.js'
import { docker } from '../utils/index.js'
class Images extends Component {
static props = {
@ -112,13 +112,11 @@ class Images extends Component {
#input = ''
async mounted() {
let list = await getImages()
this.#fetch()
}
async #fetch() {
let list = await getImages()
let list = await docker.images()
this.images = list
}
@ -132,7 +130,7 @@ class Images extends Component {
}
async #remove(item) {
await removeImage(item.id)
await docker.rmi(item.id)
this.#fetch()
}