forked from x/icebergs
opt toast icon
This commit is contained in:
parent
a69a06dc5e
commit
2832fe1819
@ -151,18 +151,21 @@ func ToastProcess(m *ice.Message, arg ...ice.Any) func() {
|
||||
}
|
||||
func GoToast(m *ice.Message, title string, cb func(toast func(name string, count, total int)) []string) *ice.Message {
|
||||
_total := 0
|
||||
icon := "🕑"
|
||||
toast := func(name string, count, total int) {
|
||||
kit.If(total == 0, func() { total = 1 })
|
||||
Toast(m,
|
||||
kit.Format("%s %s/%s", name, strings.TrimSuffix(kit.FmtSize(int64(count)), "B"), strings.TrimSuffix(kit.FmtSize(int64(total)), "B")),
|
||||
kit.Format("%s %d%%", kit.Select(m.ActionKey(), title), count*100/total), "3000", count*100/total,
|
||||
kit.Format("%s %s %s/%s", icon, kit.JoinWord(m.ActionKey(), name), strings.TrimSuffix(kit.FmtSize(int64(count)), "B"), strings.TrimSuffix(kit.FmtSize(int64(total)), "B")),
|
||||
kit.Format("%s %d%%", kit.Select(m.ActionKey(), title), count*100/total), m.OptionDefault(ice.TOAST_DURATION, "30000"), count*100/total,
|
||||
)
|
||||
_total = total
|
||||
}
|
||||
if list := cb(toast); len(list) > 0 {
|
||||
Toast(m, strings.Join(list, lex.NL), ice.FAILURE, "30s")
|
||||
} else {
|
||||
toast(kit.JoinWord(m.ActionKey(), ice.SUCCESS, "✅"), _total, _total)
|
||||
m.Option(ice.TOAST_DURATION, "3000")
|
||||
icon = "✅"
|
||||
toast(ice.SUCCESS, _total, _total)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
35
conf.go
35
conf.go
@ -226,23 +226,24 @@ const ( // MSG
|
||||
MSG_USERZONE = "user.zone"
|
||||
MSG_LANGUAGE = "user.lang"
|
||||
|
||||
MSG_BG = "sess.bg"
|
||||
MSG_FG = "sess.fg"
|
||||
MSG_MODE = "sess.mode"
|
||||
MSG_THEME = "sess.theme"
|
||||
MSG_TITLE = "sess.title"
|
||||
MSG_RIVER = "sess.river"
|
||||
MSG_STORM = "sess.storm"
|
||||
MSG_COUNT = "sess.count"
|
||||
MSG_DAEMON = "sess.daemon"
|
||||
MSG_REFERER = "sess.referer"
|
||||
MSG_FILES = "file.system"
|
||||
LOG_DISABLE = "log.disable"
|
||||
LOG_TRACEID = "log.id"
|
||||
YAC_MESSAGE = "yac.message"
|
||||
YAC_STACK = "yac.stack"
|
||||
SSH_ALIAS = "ssh.alias"
|
||||
SSH_TARGET = "ssh.target"
|
||||
MSG_BG = "sess.bg"
|
||||
MSG_FG = "sess.fg"
|
||||
MSG_MODE = "sess.mode"
|
||||
MSG_THEME = "sess.theme"
|
||||
MSG_TITLE = "sess.title"
|
||||
MSG_RIVER = "sess.river"
|
||||
MSG_STORM = "sess.storm"
|
||||
MSG_COUNT = "sess.count"
|
||||
MSG_DAEMON = "sess.daemon"
|
||||
MSG_REFERER = "sess.referer"
|
||||
MSG_FILES = "file.system"
|
||||
LOG_DISABLE = "log.disable"
|
||||
LOG_TRACEID = "log.id"
|
||||
YAC_MESSAGE = "yac.message"
|
||||
YAC_STACK = "yac.stack"
|
||||
SSH_ALIAS = "ssh.alias"
|
||||
SSH_TARGET = "ssh.target"
|
||||
TOAST_DURATION = "toast.duration"
|
||||
)
|
||||
const ( // RENDER
|
||||
RENDER_BUTTON = "_button"
|
||||
|
@ -109,7 +109,7 @@ func _repos_each(m *ice.Message, title string, cb func(*git.Repository, ice.Maps
|
||||
web.GoToast(m, kit.Select(m.CommandKey(), title), func(toast func(string, int, int)) (list []string) {
|
||||
count, total := 0, msg.Length()
|
||||
msg.Table(func(value ice.Maps) {
|
||||
toast(kit.JoinWord(m.ActionKey(), value[REPOS]), count, total)
|
||||
toast(value[REPOS], count, total)
|
||||
if err := cb(_repos_open(m, value[REPOS]), value); err != nil && err != git.NoErrAlreadyUpToDate {
|
||||
web.Toast(m, err.Error(), "error: "+value[REPOS], "", "3s").Sleep3s()
|
||||
list = append(list, value[REPOS])
|
||||
|
@ -292,8 +292,8 @@ func PushShell(m *ice.Message, cmds []string, cb func(string)) {
|
||||
defer lock.Lock()()
|
||||
list = append(list, []string{cmd})
|
||||
})
|
||||
m.Sleep3s()
|
||||
fmt.Fprintln(w, cli.EXIT)
|
||||
defer fmt.Fprintln(w, cli.EXIT)
|
||||
m.Sleep(m.OptionDefault("interval", "3s"))
|
||||
})
|
||||
kit.For(r, func(res []byte) {
|
||||
m.Debug("res %v", string(res))
|
||||
|
@ -221,7 +221,7 @@ func (s relay) Install(m *ice.Message, arg ...string) {
|
||||
}
|
||||
func (s relay) Upgrade(m *ice.Message, arg ...string) {
|
||||
if len(arg) == 0 && m.Option(MACHINE) == "" {
|
||||
m.Options(ice.CMD, m.Template(UPGRADE_SH), cli.DELAY, "0")
|
||||
m.Options(ice.CMD, m.Template(UPGRADE_SH), cli.DELAY, "0", "interval", "10s")
|
||||
s.ForFlow(m)
|
||||
} else {
|
||||
s.shell(m, m.Template(UPGRADE_SH), arg...)
|
||||
|
Loading…
x
Reference in New Issue
Block a user