From 563275974f5cad31014d60958a5c97ecc96bd1ee Mon Sep 17 00:00:00 2001 From: Yurii Nazarenko Date: Sun, 7 Apr 2024 19:17:09 +0200 Subject: [PATCH] Add initial support for RRm widget --- Makefile | 3 +- src/app/config | 11 +++ src/app/rr-manager.widget.js | 133 +++++++++++++++++++++++++++++++++++ src/app/texts/enu/strings | 3 + 4 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 src/app/rr-manager.widget.js diff --git a/Makefile b/Makefile index abf1073..bb4cd83 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ SPK_NAME = rr-manager SPK_VERS = 2.0 -SPK_REV = 19 +SPK_REV = 20 SPK_ICON = src/rr-manager.png DSM_UI_DIR = app @@ -76,6 +76,7 @@ rr-manager_extra_install: install -m 755 src/app/checkUpdateStatus.cgi $(STAGING_DIR)/app/checkUpdateStatus.cgi install -m 644 src/app/config $(STAGING_DIR)/app/config install -m 644 src/app/rr-manager.js $(STAGING_DIR)/app/rr-manager.js + install -m 644 src/app/rr-manager.widget.js $(STAGING_DIR)/app/rr-manager.widget.js install -m 644 src/app/helptoc.conf $(STAGING_DIR)/app/helptoc.conf install -m 755 src/app/createsqlitedata.sql $(STAGING_DIR)/app/createsqlitedata.sql install -m 755 src/app/createsqlitedata.cgi $(STAGING_DIR)/app/createsqlitedata.cgi diff --git a/src/app/config b/src/app/config index f6c8a84..e4c1e46 100644 --- a/src/app/config +++ b/src/app/config @@ -17,5 +17,16 @@ "icon": "images/rr-manager-{0}.png", "texts": "texts" } + }, + "rr-manager.widget.js": { + "SYNOCOMMUNITY.RRManager.Widget": { + "type": "widget", + "title": "Customized", + "icon": "images\/{1}\/wdgt_icn_title_system_info.png", + "appInstance": "SYNO.SDS.AdminCenter.Application", + "launchParam": "{\"fn\":\"SYNO.SDS.AdminCenter.InfoCenter.Main\"}", + "depend": ["SYNO.SDS._Widget.GridPanel"], + "texts": "texts" + } } } diff --git a/src/app/rr-manager.widget.js b/src/app/rr-manager.widget.js new file mode 100644 index 0000000..661bc72 --- /dev/null +++ b/src/app/rr-manager.widget.js @@ -0,0 +1,133 @@ +// Namespace definition +Ext.ns('SYNOCOMMUNITY.RRManager'); + +// Translator +_V = function (category, element) { + return _TT("SYNOCOMMUNITY.RRManager.Widget", category, element) +} + +Ext.ns("SYNO.SDS.SystemInfoApp"); + +Ext.define("SYNOCOMMUNITY.RRManager.Widget", { + extend: "Ext.Panel", + minimizable: true, + taskButton: undefined, + constructor: function constructor(a) { + this.initializeSouthTable(); + var b = Ext.apply(this.getConfig(), a); + SYNOCOMMUNITY.SimpleExtJSApp.WidgetCustom.superclass.constructor.call(this, b); + this.westIcon = this.getIconComponent(); + this.centerContent = this.getContentComponent(); + this.isActive = false; + this.timestamp = null; + this.uptime = null; + this.appSetting = SYNO.SDS.SystemInfoApp.SystemHealthDefaultApp + }, + getConfig: function getConfig() { + return { + layout: "fit", + border: false, + defaults: { + border: false + }, + items: [this.getViewConfig()] + } + }, + getViewConfig: function getViewConfig() { + return { + itemId: "layoutPanel", + layout: "vbox", + height: "100%", + border: false, + padding: "4px 12px 5px 12px", + cls: "syno-sysinfo-system-health", + defaults: { + border: false + }, + items: [{ + xtype: "container", + itemId: "northPanel", + height: 20, + width: 296, + cls: "syno-sysinfo-system-health-status", + items: [{ + xtype: "box", + itemId: "westIcon" + }, { + xtype: "box", + itemId: "centerContent", + region: "center" + }] + }, { + region: "south", + height: 84, + width: 296, + items: this.southTable + }] + } + }, + doCollapse: function doCollapse() { + this.getEl().setHeight(84); + this.doLayout() + }, + doExpand: function doExpand() { + this.getEl().setHeight(172); + this.doLayout() + }, + setApp: function setApp(a) { + this.appSetting = a + }, + + getIconComponent: function getIconComponent() { + return this.getComponent("layoutPanel").getComponent("northPanel").getComponent("westIcon") + }, + getContentComponent: function getContentComponent() { + return this.getComponent("layoutPanel").getComponent("northPanel").getComponent("centerContent") + }, + onClickTitle: function onClickTitle() { + SYNO.SDS.AppLaunch(this.appSetting.appInstance, this.appSetting.launchParam) + }, + onActivate: function onActivate() { + this.isActive = true; + }, + onDeactivate: function onDeactivate() { + this.isActive = false; + this.unmask() + }, + mask: Ext.emptyFn, + unmask: Ext.emptyFn, + initializeSouthTable: function initializeSouthTable() { + var b = Ext.util.Format.htmlEncode(_V("widget", "message")); + var c = Ext.util.Format.htmlEncode(_S("hostname")); + this.southTable = new Ext.Panel({ + layout: "table", + itemId: "southTable", + cls: "sys-info-south-table", + margins: 0, + height: 84, + layoutConfig: { + columns: 2, + cellCls: "sys-info-row" + }, + items: [{ + xtype: "box", + html: String.format('

{0}

', b, Ext.util.Format.htmlEncode(b)) + }, { + xtype: "box", + html: String.format('

{0}

', c, Ext.util.Format.htmlEncode(c)) + }] + }) + }, + + destroy: function destroy() { + var a = this; + a.onDeactivate(); + if (a.taskButton) { + Ext.destroy(a.taskButton) + } + if (a.southGrid && a.southGrid.getStore()) { + a.southGrid.getStore().destroy() + } + SYNOCOMMUNITY.RRManager.Widget.superclass.destroy.call(this) + } +}); \ No newline at end of file diff --git a/src/app/texts/enu/strings b/src/app/texts/enu/strings index ebad67f..5483557 100644 --- a/src/app/texts/enu/strings +++ b/src/app/texts/enu/strings @@ -59,3 +59,6 @@ col_version="Verison" col_name="Name" col_description="Description" + +[widget] +message="Hello world!"