@samitouri / QOSami-HFS / commits / 16c4c123

admin/plugins/installed: dynamic update of log icon

Massimo Melina committed Mar 1, 2025 at 00:49 UTC 16c4c123d53a80e57c34777a83da16e714e56edd
4 files changed +8 -4
admin/src/InstalledPlugins.ts
+4 -3
@@ -119,10 +119,11 @@ export default function InstalledPlugins({ updates }: { updates?: true }) {
119 onClick: () => startPlugin(id),
120 }),
121 h(IconBtn, {
122 - icon: row.config || !row.started ? Settings : ListAlt,
123 - title: row.config ? "Options" : "Log",
122 + icon: row.config || !row.started || !row.log ? Settings : ListAlt,
123 + title: row.config || !row.log ? "Options" : "Log",
124 size,
125 - disabled: !row.started && "Start plugin to access options",
125 + disabled: !row.started && "Start plugin to access options"
126 + || !row.config && !row.log && "No options and no log for this plugin",
127 async onClick() {
128 const { config: lastSaved } = await apiCall('get_plugin', { id })
129 // support css values without having to wrap in sx, as in DialogProps it only supports breakpoints
src/SendList.ts
+1 -1
@@ -84,7 +84,7 @@ export class SendListReadable<T> extends Readable {
84 if (op === LIST.remove) return
85 if (op === LIST.add || op === LIST.update)
86 return Object.assign(found[op === LIST.add ? 1 : 2], change)
87 - return this._push([LIST.update, search, change])
87 + this._push([LIST.update, search, change])
88 }
89 ready() { // useful to indicate the end of an initial phase, but we leave open for updates
90 this._push([LIST.ready])
src/api.plugins.ts
+2
@@ -28,6 +28,7 @@ const apis: ApiHandlers = {
28 list.update({ id }, rest)
29 },
30 pluginUninstalled: id => list.remove({ id }),
31 + pluginLog: id => list.update({ id }, { log: true }) // SendList is already capping frequency
32 })
33 },
34
@@ -190,6 +191,7 @@ function serialize(p: Readonly<Plugin> | AvailablePlugin) {
191 : { ...p } // _.defaults mutates object, and we don't want that
192 if (typeof o.repo === 'object') // custom repo
193 o.repo = o.repo.web
194 + o.log = 'log' in p && p.log?.length > 0
195 o = produce(o, (o: any) => {
196 _.each(o.config, x => x.showIf &&= String(x.showIf))
197 })
src/plugins.ts
+1
@@ -525,6 +525,7 @@ function watchPlugin(id: string, path: string) {
525 plugin.log.unshift({ ts: new Date, msg: args.map(x => x && typeof x === 'object' ? JSON.stringify(x) : String(x)).join(' ') })
526 plugin.log.length = Math.min(100, plugin.log.length) // truncate
527 events.emit('pluginLog:' + id, plugin.log[0])
528 + events.emit('pluginLog', id, plugin.log[0])
529 })
530 },
531 getConfig(cfgKey?: string) {