diff --git a/Makefile b/Makefile index cf594c5..f1c7e3f 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ SPK_NAME = rr-manager SPK_VERS = 2.0 -SPK_REV = 74 +SPK_REV = 75 SPK_ICON = src/rr-manager.png DSM_UI_DIR = app diff --git a/src/src/appWindow.js b/src/src/appWindow.js index 0e89281..638f351 100644 --- a/src/src/appWindow.js +++ b/src/src/appWindow.js @@ -17,8 +17,8 @@ export default defaultWinSize: { width: 1160, height: 620 }, constructor: function (config) { const t = this; - t.callParent([t.fillConfig(config)]); this.apiProvider.init(this.sendWebAPI.bind(this)); + t.callParent([t.fillConfig(config)]); }, fillConfig: function (e) { let tabs = this.getListItems(); @@ -35,54 +35,64 @@ export default }, getListItems: function () { - return [ + let items = [ { text: this.helper.V('ui', 'tab_general'), iconCls: "icon-rr-overview", fn: "SYNOCOMMUNITY.RRManager.Overview.Main", - // help: "overview.html", }, { text: this.helper.V('ui', 'tab_addons'), iconCls: "icon-rr-addons", fn: "SYNOCOMMUNITY.RRManager.Addons.Main", - // help: "overview.html", }, { text: this.helper.V('ui', 'tab_debug'), iconCls: "icon-debug", fn: "SYNOCOMMUNITY.RRManager.Debug.Main", - // help: "setting.html", }, { text: 'Console', iconCls: "icon-terminal-and-SNMP", fn: "SYNOCOMMUNITY.RRManager.Ssh.Main", - // help: "setting.html", }, { text: this.helper.V('ui', 'tab_configuration'), iconCls: "icon-rr-setting", fn: "SYNOCOMMUNITY.RRManager.Setting.Main", - // help: "setting.html", - } + } ]; - }, + // // Fetch conditionally add a tab if `ttydPackage` is available + // this.apiProvider.getPackagesList().then((response) => { + // let ttydPackage = response.packages.find((pkg) => pkg.id === 'TTYD'); + // if (ttydPackage) { + // let newTab = { + // text: "Console", + // iconCls: "icon-terminal-and-SNMP", + // fn: "SYNOCOMMUNITY.RRManager.Ssh.Main", + // }; + // // Check if the tab already exists to prevent duplicates + // if (!items.find(tab => tab.fn === newTab.fn)) { + // items.push(newTab); + // } + // } + // return items; + // }); + return items; + }, onOpen: function (a) { - //Apply style to the main page const t = this; t.mon(t.getPageList().getSelectionModel(), "selectionchange", t.onSelectionModelChange, t); - //this.apiProvider.runScheduledTask('MountLoaderDisk'); SYNOCOMMUNITY.RRManager.AppWindow.superclass.onOpen.call(this, a); }, onDestroy: function (e) { //this.apiProvider.runScheduledTask('UnMountLoaderDisk'); SYNOCOMMUNITY.RRManager.AppWindow.superclass.onDestroy.call(this); }, - onSelectionModelChange: function() { + onSelectionModelChange: function () { const e = this - , t = e.getActivePage(); - t && ("SYNOCOMMUNITY.RRManager.Overview.Main" === t.itemId ? e.getPageCt().addClass("iscsi-overview-panel") : e.getPageCt().removeClass("iscsi-overview-panel")) + , t = e.getActivePage(); + t && ("SYNOCOMMUNITY.RRManager.Overview.Main" === t.itemId ? e.getPageCt().addClass("iscsi-overview-panel") : e.getPageCt().removeClass("iscsi-overview-panel")); }, }); \ No newline at end of file diff --git a/src/src/panels/settings/rrManagerConfigTab.js b/src/src/panels/settings/rrManagerConfigTab.js index e69215e..d7a9736 100644 --- a/src/src/panels/settings/rrManagerConfigTab.js +++ b/src/src/panels/settings/rrManagerConfigTab.js @@ -7,17 +7,24 @@ export default fillConfig: function (e) { this.suspendLcwPrompt = !1; const t = { + //TODO: implement localization title: "RR Manager Settings", items: [ new SYNO.ux.FieldSet({ title: 'RR Manager', collapsible: true, name: 'rrManager', + //TODO: implement localization items: [ { boxLabel: 'Check for updates on App Startup', name: 'checkForUpdates', xtype: 'syno_checkbox', + }, + { + boxLabel: 'Enable TTYD package integration', + name: 'checkForUpdates', + xtype: 'syno_checkbox', } ] }) diff --git a/src/src/tabs/main.js b/src/src/tabs/main.js index 24aa247..71ce897 100644 --- a/src/src/tabs/main.js +++ b/src/src/tabs/main.js @@ -230,57 +230,67 @@ export default onActivate: function () { const self = this; if (this.loaded) return; - self.appWin.setStatusBusy(null, null, 50); + //TODO: implement localization + self.appWin.setStatusBusy({ text: 'Loading system info...' }); (async () => { - const [systemInfo, packages, rrCheckVersion] = await Promise.all([ - self.apiProvider.getSytemInfo(), - self.apiProvider.getPackagesList(), - self.apiProvider.checkRRVersion() - ]); + // handle the error during the initialization + try { + //await self.apiProvider.init(self.sendWebAPI.bind(self)); - if (systemInfo && packages) { - self.rrCheckVersion = rrCheckVersion; - self.systemInfoTxt = `Welcome to RR Manager!`; // - const rrManagerPackage = packages.packages.find((packageInfo) => packageInfo.id == 'rr-manager'); + const [systemInfo, packages, rrCheckVersion] = await Promise.all([ + self.apiProvider.getSytemInfo(), + self.apiProvider.getPackagesList(), + self.apiProvider.checkRRVersion() + ]); + if (systemInfo && packages) { + self.rrCheckVersion = rrCheckVersion; + //TODO: implement localization + self.systemInfoTxt = `Welcome to RR Manager!`; // + const rrManagerPackage = packages.packages.find((packageInfo) => packageInfo.id == 'rr-manager'); - self.panels?.healthPanel?.fireEvent( - "select", - self.panels?.healthPanel?.clickedBox - ); - self.panels.statusBoxsPanel.fireEvent( - "select", - self.panels.statusBoxsPanel.clickedBox - ); - await self.updateAllForm(); - var data = { - text: `Model: ${systemInfo?.model}`, - text2: `RAM: ${systemInfo?.ram} MB`, - text3: `DSM version: ${systemInfo?.version_string}`, - rrManagerVersion: `${rrManagerPackage?.version}`, - rrVersion: self.rrConfig.rr_version - }; - Ext.apply(data, self.data); - if (!self.installed) { - //create rr tmp folder - self.rrManagerConfig = self.rrConfig.rr_manager_config; - SYNO.API.currentManager.requestAPI('SYNO.FileStation.CreateFolder', "create", "2", { - folder_path: `/${self.rrManagerConfig.SHARE_NAME}`, - name: self.rrManagerConfig.RR_TMP_DIR, - force_parent: false - }); - self.installed = true; + self.panels?.healthPanel?.fireEvent( + "select", + self.panels?.healthPanel?.clickedBox + ); + self.panels.statusBoxsPanel.fireEvent( + "select", + self.panels.statusBoxsPanel.clickedBox + ); + await self.updateAllForm(); + var data = { + text: `Model: ${systemInfo?.model}`, + text2: `RAM: ${systemInfo?.ram} MB`, + text3: `DSM version: ${systemInfo?.version_string}`, + rrManagerVersion: `${rrManagerPackage?.version}`, + rrVersion: self.rrConfig.rr_version + }; + Ext.apply(data, self.data); + if (!self.installed) { + //create rr tmp folder + self.rrManagerConfig = self.rrConfig.rr_manager_config; + SYNO.API.currentManager.requestAPI('SYNO.FileStation.CreateFolder', "create", "2", { + folder_path: `/${self.rrManagerConfig.SHARE_NAME}`, + name: self.rrManagerConfig.RR_TMP_DIR, + force_parent: false + }); + self.installed = true; + } + self.panels?.healthPanel?.fireEvent("data_ready"); + self.panels?.statusBoxsPanel?.fireEvent("data_ready", data); + self.loaded = true; } - self.panels?.healthPanel?.fireEvent("data_ready"); - self.panels?.statusBoxsPanel?.fireEvent("data_ready", data); - self.loaded = true; - } - if (self.isUpdateAvailable(rrCheckVersion)) { - self.showPrompt(self.helper.V('ui', 'prompt_update_available_title'), - self.helper.formatString(self.helper.V('ui', 'prompt_update_available_message'), rrCheckVersion.tag), - rrCheckVersion.notes, self.donwloadUpdate.bind(self)); + if (self.isUpdateAvailable(rrCheckVersion)) { + self.showPrompt(self.helper.V('ui', 'prompt_update_available_title'), + self.helper.formatString(self.helper.V('ui', 'prompt_update_available_message'), rrCheckVersion.tag), + rrCheckVersion.notes, self.donwloadUpdate.bind(self)); + } + } catch (error) { + self.appWin.clearStatusBusy(); + self.showMsg(`Error during RRM initialization: ${error}`); + return; } })(); self.__checkDownloadFolder(self.__checkRequiredTasks.bind(self));