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