From ec3a97633721bc8f86aba6c232d431d1f019b290 Mon Sep 17 00:00:00 2001 From: shy Date: Sat, 9 Mar 2024 12:23:58 +0800 Subject: [PATCH] add some --- base/web/matrix.css | 15 ++++++++------- base/web/matrix.go | 2 +- base/web/matrix.js | 24 ++++++++++++++++++++++-- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/base/web/matrix.css b/base/web/matrix.css index 736cb23c..fa3947da 100644 --- a/base/web/matrix.css +++ b/base/web/matrix.css @@ -20,13 +20,14 @@ fieldset.web.matrix>div.output>table.content div.item div.title:hover { backgrou fieldset.web.matrix>div.output>table.content div.item div.title span:hover { background-color:var(--hover-bg-color); } fieldset.web.matrix>div.output>table.content div.item div.status div.item:hover { background-color:var(--hover-bg-color); } fieldset.web.matrix>div.output>table.content div.item:hover { background-color:unset; color:unset; } -fieldset.web.matrix>div.output>table.content div.item.notice { background-color:var(--notice-bg-color); color:var(--notice-fg-color); } -fieldset.web.matrix>div.output>table.content div.item.danger { background-color:var(--danger-bg-color); color:var(--danger-fg-color); } -fieldset.web.matrix>div.output>table.content div.item.server { border:var(--notice-bg-color) solid 3px; } -fieldset.web.matrix>div.output>table.content div.item.master { border:var(--danger-bg-color) solid 3px; } -fieldset.web.matrix>div.output>table.content div.item.danger div.status div.item { color:var(--danger-fg-color); } -fieldset.web.matrix>div.output>table.content div.item.notice div.status div.item { color:var(--notice-fg-color); } -fieldset.web.matrix>div.output>table.content div.item.stop div.title>span { color:var(--disable-fg-color); } +fieldset.web.matrix>div.output:not(.process)>table.content div.item.notice { background-color:var(--notice-bg-color); color:var(--notice-fg-color); } +fieldset.web.matrix>div.output:not(.process)>table.content div.item.danger { background-color:var(--danger-bg-color); color:var(--danger-fg-color); } +fieldset.web.matrix>div.output:not(.process)>table.content div.item.server { border:var(--notice-bg-color) solid 3px; } +fieldset.web.matrix>div.output:not(.process)>table.content div.item.master { border:var(--danger-bg-color) solid 3px; } +fieldset.web.matrix>div.output:not(.process)>table.content div.item.danger div.status div.item { color:var(--danger-fg-color); } +fieldset.web.matrix>div.output:not(.process)>table.content div.item.notice div.status div.item { color:var(--notice-fg-color); } +fieldset.web.matrix>div.output:not(.process)>table.content div.item.stop div.title>span { color:var(--disable-fg-color); } +fieldset.web.matrix>div.output.process>table.content div.item.process { background-color:blue; color:var(--notice-fg-color); } fieldset.web.matrix>div.output>table.content tr:not(:hover) div.action { visibility:hidden; } body:not(.mobile) fieldset.web.matrix>div.output>table.content th:first-child { position:sticky; left:2px; z-index:2; } body:not(.mobile) fieldset.web.matrix>div.output>table.content td:first-child { background-color:var(--plugin-bg-color); position:sticky; left:2px; z-index:1; } diff --git a/base/web/matrix.go b/base/web/matrix.go index 013a3eb1..77678edc 100644 --- a/base/web/matrix.go +++ b/base/web/matrix.go @@ -150,7 +150,7 @@ func init() { } return value }) - m.Action(html.FILTER, mdb.CREATE).StatusTimeCountStats(mdb.TYPE, mdb.STATUS).Display("") + m.Action(html.FILTER, mdb.CREATE, UPGRADE).StatusTimeCountStats(mdb.TYPE, mdb.STATUS).Display("") m.Sort("type,status,name,domain", []string{MYSELF, SERVER, MASTER, WORKER, ""}, []string{cli.START, cli.STOP, ""}, ice.STR_R, ice.STR_R) ctx.Toolkit(m) return nil diff --git a/base/web/matrix.js b/base/web/matrix.js index 4529ed5f..6c4b1893 100644 --- a/base/web/matrix.js +++ b/base/web/matrix.js @@ -1,7 +1,8 @@ Volcanos(chat.ONIMPORT, { - _init: function(can, msg) { var list = {}, domain = [""] + _init: function(can, msg) { var list = {}, domain = [""], server = [] msg.Table(function(value) { var name = value.name, _domain = value.domain list[name] = list[name]||{}, list[name][_domain] = value, domain.indexOf(_domain) == -1 && domain.push(_domain) + value.type == web.SERVER && server.push(value.domain) }) can.ui = can.page.Appends(can, can._output, [{view: [wiki.CONTENT, html.TABLE], list: [ {type: html.THEAD, list: [{type: html.TR, list: can.core.List(domain, function(domain) { @@ -14,6 +15,7 @@ Volcanos(chat.ONIMPORT, { })}, ] }]), can.onmotion.delay(can, function() { can.Status(mdb.COUNT, can.core.Item(list).length+"x"+can.core.List(domain).length) }) can.onmotion.orderShow(can, can.page.SelectOne(can, can._output, "table>tbody"), "tr") + can.db.list = list, can.db.domain = domain, can.db.server = server }, void: function(can, name, domain, list) { var worker = list[name][""], server = list[""][domain] return {view: html.ACTION, _init: function(target) { @@ -31,9 +33,27 @@ Volcanos(chat.ONIMPORT, { {text: [item.text, "", "status"]}, can.onappend.buttons(can, item), ]}, - ]} + ], _init: function(target) { + item._target = target + }} }, style: function(can, item, list) { var name = item.name, domain = item.domain, worker = list[name][""] return !worker? html.NOTICE: (worker.status != cli.STOP && item.status != cli.STOP && (item.version != worker.version || item.time < worker.time))? html.DANGER: "" }, }, [""]) +Volcanos(chat.ONACTION, { + upgrade: function(event, can) { + var msg = can.request(event); if (msg.Option(mdb.NAME) || msg.Option(web.DOMAIN)) { return can.Update(event, [ctx.ACTION, code.UPGRADE]) } + can.page.ClassList.add(can, can._output, "process") + can.core.Next(can.db.server, function(server, next, index) { + can.core.Next(can.core.Item(can.db.list, function(key, value) { return value }), function(list, next, i) { + var item = list[server]; if (!item) { return next() } + if (!item.name || item.status != cli.START) { return next() } + can.page.ClassList.add(can, item._target, "process") + can.Update(can.request({}, item, {_handle: ice.TRUE}), [ctx.ACTION, code.UPGRADE], function(msg) { + next() + }) + }, next) + }, function() { can.Update() }) + }, +})