Skip to content

Commit

Permalink
Minor changes. Added Error handling during RRM init
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriiNazarenkoTine committed Nov 15, 2024
1 parent 026a237 commit d16656b
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 59 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
38 changes: 24 additions & 14 deletions src/src/appWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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"));
},
});
7 changes: 7 additions & 0 deletions src/src/panels/settings/rrManagerConfigTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
]
})
Expand Down
98 changes: 54 additions & 44 deletions src/src/tabs/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit d16656b

Please sign in to comment.