diff --git a/src/app/rr-manager.js b/src/app/rr-manager.js index 87d85e3..34bc6c5 100644 --- a/src/app/rr-manager.js +++ b/src/app/rr-manager.js @@ -2033,11 +2033,13 @@ Ext.define("SYNOCOMMUNITY.RRManager.Setting.Main", { doApply: async function () { this.setStatusBusy(); try { - await this.setConf(); - await this.updateAllForm(); - await this.appWin.runScheduledTask('ApplyRRConfig'); - this.clearStatusBusy(); - this.setStatusOK(); + (async () => { + await this.setConf(); + await this.updateAllForm(); + await this.appWin.runScheduledTask('ApplyRRConfig'); + this.clearStatusBusy(); + this.setStatusOK(); + })(); } catch (e) { SYNO.Debug(e); this.clearStatusBusy(); @@ -2047,7 +2049,7 @@ Ext.define("SYNOCOMMUNITY.RRManager.Setting.Main", { }, getParams: function () { const generalTab = this.generalTab.getForm().getValues(); - const iscsiTab = this.iscsiTab.getForm().getValues(); + const rrConfigTab = this.rrConfigTab.getForm().getValues(); const synoInfoTab = this.synoInfoTab.getForm().getValues(); const synoInfoTabFixed = { @@ -2056,7 +2058,7 @@ Ext.define("SYNOCOMMUNITY.RRManager.Setting.Main", { var rrConfigJson = localStorage.getItem("rrConfig"); var rrConfig = JSON.parse(rrConfigJson); - return Object.assign(rrConfig?.user_config, generalTab, iscsiTab, synoInfoTabFixed); + return Object.assign(rrConfig?.user_config, generalTab, rrConfigTab, synoInfoTabFixed); }, getConf: function () { var rrConfigJson = localStorage.getItem("rrConfig"); diff --git a/src/app/rr-manager.js_ b/src/app/rr-manager.js_ deleted file mode 100644 index 9880d9f..0000000 --- a/src/app/rr-manager.js_ +++ /dev/null @@ -1,637 +0,0 @@ -// Namespace definition -Ext.ns('SYNOCOMMUNITY.RRManager'); - -// Application definition -Ext.define('SYNOCOMMUNITY.RRManager.AppInstance', { - extend: 'SYNO.SDS.AppInstance', - appWindowName: 'SYNOCOMMUNITY.RRManager.AppWindow', - constructor: function () { - this.callParent(arguments) - } -}); - -// Translator -_V = function (category, element) { - return _TT("SYNOCOMMUNITY.RRManager.AppInstance", category, element) -} - -formatString = function (str, ...args) { - return str.replace(/{(\d+)}/g, function (match, number) { - return typeof args[number] !== 'undefined' ? args[number] : match; - }); -} - -// Window definition -Ext.define('SYNOCOMMUNITY.RRManager.AppWindow', { - extend: "SYNO.SDS.PageListAppWindow", - // activePage: "SYNO.SDS.iSCSI.Log.Main", - defaultWinSize: { width: 1160, height: 620 }, - constructor: function (config) { - const t = this; - // t.callParent([config]); - t.callParent([t.fillConfig(config)]); - - }, - fillConfig: function (e) { - let t; - t = this.getListItems(); - const i = { - cls: "syno-app-iscsi", - width: this.defaultWinSize.width, - height: this.defaultWinSize.height, - minWidth: this.defaultWinSize.width, - minHeight: this.defaultWinSize.height, - activePage: "SYNOCOMMUNITY.RRManager.Overview.Main", - listItems: t, - }; - return Ext.apply(i, e), i; - - }, - getListItems: function () { - return [ - // { - // text: SYNO.SDS.iSCSI.Utils.T("tree", "leaf_overview"), - // iconCls: "icon-overview", - // fn: "SYNOCOMMUNITY.RRManager.Overview.Main", - // help: "overview.html", - // }, - { - text: _V('ui', 'tabAddons') ?? 'Addons', - iconCls: "icon-log", - fn: "SYNOCOMMUNITY.RRManager.Addons.Main", - // help: "overview.html", - }, - ]; - - }, - - onOpen: function (a) { - var that = this; - SYNOCOMMUNITY.RRManager.AppWindow.superclass.onOpen.call(this, a); - } -}); - -Ext.define("SYNOCOMMUNITY.RRManager.Addons.Main", { - extend: "SYNO.ux.GridPanel", - itemsPerPage: 1e3, - constructor: function (e) { - const t = this; - let i; - Ext.apply(t, e), - (i = t.fillConfig(e)), - (t.itemsPerPage = - t.appWin.appInstance.getUserSettings(t.itemId + "-dsPageLimit") || - t.itemsPerPage), - t.callParent([i]), - t.mon( - t, - "resize", - (e, i, s) => { - t.updateFbarItems(i); - }, - t - ); - }, - getPageRecordStore: function () { - return new Ext.data.SimpleStore({ - fields: ["value", "display"], - data: [ - [100, 100], - [500, 500], - [1e3, 1e3], - [3e3, 3e3], - ], - }); - }, - getCategoryStore: function () { - return new Ext.data.SimpleStore({ - fields: ["value", "display"], - data: [ - ["", SYNO.SDS.iSCSI.Utils.T("log", "log_all")], - ["general", SYNO.SDS.iSCSI.Utils.T("log", "general")], - ["connection", SYNO.SDS.iSCSI.Utils.T("log", "log_link_connection")], - ], - }); - }, - onChangeDisplayRecord: function (e, t, i) { - const s = this, - n = s.logStore; - s.itemsPerPage !== e.getValue() && - ((s.itemsPerPage = e.getValue()), - (s.paging.pageSize = s.itemsPerPage), - n.load({ params: { offset: 0, limit: s.itemsPerPage } }), - s.appWin.appInstance.setUserSettings( - s.itemId + "-dsPageLimit", - s.itemsPerPage - )); - }, - onChangeCategory: function (e, t, i) { - const s = this, - n = s.logStore, - a = e.getValue(); - a !== n.baseParams.category && - (Ext.apply(n.baseParams, { category: a }), s.loadData()); - }, - initPageComboBox: function (e) { - return new SYNO.ux.ComboBox({ - name: "page_rec", - hiddenName: "page_rec", - hiddenId: Ext.id(), - store: e, - displayField: "display", - valueField: "value", - triggerAction: "all", - value: this.itemsPerPage, - editable: !1, - width: 72, - mode: "local", - listeners: { select: { fn: this.onChangeDisplayRecord, scope: this } }, - }); - }, - initCategoryComboBox: function (e) { - return new SYNO.ux.ComboBox({ - name: "category", - store: e, - displayField: "display", - valueField: "value", - value: "", - width: 120, - mode: "local", - listeners: { select: { fn: this.onChangeCategory, scope: this } }, - }); - }, - initPagingToolbar: function () { - return new SYNO.ux.PagingToolbar({ - store: this.logStore, - displayInfo: !0, - pageSize: this.itemsPerPage, - showRefreshBtn: !0, - cls: "iscsi-log-toolbar", - items: [ - { - xtype: "tbtext", - style: "padding-right: 4px", - text: SYNO.SDS.iSCSI.Utils.T("common", "items_perpage"), - }, - this.initPageComboBox(this.getPageRecordStore()), - ], - }); - }, - initSearchForm: function () { - // return new SYNO.SDS.iSCSI.SearchFormPanel({ - // cls: "iscsi-search-panel", - // renderTo: Ext.getBody(), - // shadow: !1, - // hidden: !0, - // owner: this, - // }); - }, - initToolbar: function () { - const e = this, - t = new SYNO.ux.Toolbar(); - return ( - (e.clearButton = new SYNO.ux.Button({ - xtype: "syno_button", - text: SYNO.SDS.iSCSI.Utils.T("common", "btn_clear"), - handler: e.onLogClear, - scope: e, - })), - (e.exportButton = new SYNO.ux.SplitButton({ - xtype: "syno_splitbutton", - text: SYNO.SDS.iSCSI.Utils.T("common", "btn_export"), - handler: e.onExportHtml, - scope: e, - menu: { - items: [ - { - text: SYNO.SDS.iSCSI.Utils.T("log", "html_type"), - handler: e.onExportHtml, - scope: e, - }, - { - text: SYNO.SDS.iSCSI.Utils.T("log", "csv_type"), - handler: e.onExportCSV, - scope: e, - }, - ], - }, - })), - (e.searchField = new SYNO.SDS.iSCSI.AdvancedSearchField({ - iconStyle: "filter", - owner: e, - })), - (e.searchField.searchPanel = e.searchPanel), - t.add(e.clearButton), - t.add(e.exportButton), - t.add("->"), - t.add(e.initCategoryComboBox(e.getCategoryStore())), - t.add({ xtype: "tbspacer", width: 4 }), - t.add(e.searchField), - t - ); - }, - initEvents: function () { - // this.mon(this.searchPanel, "search", this.onSearch, this), - this.mon(this, "activate", this.onActive, this); - }, - _getLng: function (lng) { - const localeMapping = { - 'dan': 'da_DK', // Danish in Denmark - 'ger': 'de_DE', // German in Germany - 'enu': 'en_US', // English (United States) - 'spn': 'es_ES', // Spanish (Spain) - 'fre': 'fr_FR', // French in France - 'ita': 'it_IT', // Italian in Italy - 'hun': 'hu_HU', // Hungarian in Hungary - 'nld': 'nl_NL', // Dutch in The Netherlands - 'nor': 'no_NO', // Norwegian in Norway - 'plk': 'pl_PL', // Polish in Poland - 'ptg': 'pt_PT', // European Portuguese - 'ptb': 'pt_BR', // Brazilian Portuguese - 'sve': 'sv_SE', // Swedish in Sweden - 'trk': 'tr_TR', // Turkish in Turkey - 'csy': 'cs_CZ', // Czech in Czech Republic - 'gre': 'el_GR', // Greek in Greece - 'rus': 'uk-UA', - 'heb': 'he_IL', // Hebrew in Israel - 'ara': 'ar_SA', // Arabic in Saudi Arabia - 'tha': 'th_TH', // Thai in Thailand - 'jpn': 'ja_JP', // Japanese in Japan - 'chs': 'zh_CN', // Simplified Chinese in China - 'cht': 'zh_TW', // Traditional Chinese in Taiwan - 'krn': 'ko_KR', // Korean in Korea - 'vi': 'vi-VN', // Vietnam in Vietnam - }; - return Object.keys(localeMapping).indexOf(lng) > -1 - ? localeMapping[lng] : localeMapping['enu']; - }, - getStore: function () { - var gridStore = new SYNO.API.JsonStore({ - autoDestroy: true, - appWindow: this.appWin, - restful: true, - root: "result", - url: `/webman/3rdparty/rr-manager/getAddons.cgi`, - idProperty: "name", - fields: [{ - name: 'name', - type: 'string' - }, { - name: 'version', - type: 'string' - }, { - name: 'description', - type: 'object' - }, { - name: 'system', - type: 'boolean' - }, { - name: 'installed', - type: 'boolean' - }], - // reader: new Ext.data.JsonReader({ - // idProperty: "name", - - // totalProperty: "total", - // fields: [{ - // name: 'name', type: 'string',mapping: 'name' - // }, { - // name: 'version', type: 'string',mapping: 'version' - // }, { - // name: 'description', type: 'object',mapping: 'description' - // }, { - // name: 'system', type: 'boolean',mapping: 'system' - // }, { - // name: 'installed', type: 'boolean',mapping: 'installed' - // }] - // }), - listeners: { - exception: this.loadException, - beforeload: this.onBeforeStoreLoad, - load: this.onAfterStoreLoad, - scope: this, - } - }); - return gridStore; - }, - logLevelRenderer: function (e) { - switch (e) { - case "err": - return ( - "" + - SYNO.SDS.iSCSI.Utils.T("log", "error_level") + - "" - ); - case "warning": - return ( - "" + - SYNO.SDS.iSCSI.Utils.T("log", "warn_level") + - "" - ); - case "info": - return ( - "" + - SYNO.SDS.iSCSI.Utils.T("log", "info_level") + - "" - ); - default: - return "Undefined"; - } - }, - htmlTimeRender: function (e) { - const t = new Date(1e3 * e); - return SYNO.SDS.DateTimeFormatter(t, { type: "datetimesec" }); - }, - getColumnModel: function () { - var currentLngCode = this._getLng(SYNO?.SDS?.Session?.lang || "enu"); - return new Ext.grid.ColumnModel({ - columns: [ - { - header: 'Name', - width: 60, - dataIndex: 'name' - }, { - header: 'Verison', - width: 30, - dataIndex: 'version' - }, { - header: 'Description', - width: 300, - dataIndex: 'description', - renderer: function (value, metaData, record, row, col, store, gridView) { - return value[currentLngCode] ?? value['en_US']; - } - }, new SYNO.ux.EnableColumn({ - header: "System", - dataIndex: "system", - width: 100, - align: "center", - enableFastSelectAll: false, - disabled: true, - }), new SYNO.ux.EnableColumn({ - header: "Installed", - dataIndex: "installed", - width: 100, - align: "center", - enableFastSelectAll: false, - disabled: true, - }), - ], - defaults: { sortable: !1, menuDisabled: !1 }, - }); - }, - fillConfig: function (e) { - const t = this; - (t.searchPanel = t.initSearchForm()), - (t.logStore = t.getStore()), - (t.paging = t.initPagingToolbar()); - const i = { - border: !1, - trackResetOnLoad: !0, - layout: "fit", - itemId: "iscsi_log", - tbar: t.initToolbar(), - enableColumnMove: !1, - enableHdMenu: !1, - bbar: t.paging, - store: t.logStore, - colModel: t.getColumnModel(), - view: new SYNO.ux.FleXcroll.grid.BufferView({ - rowHeight: 27, - scrollDelay: 30, - borderHeight: 1, - emptyText: SYNO.SDS.iSCSI.Utils.EmptyMsgRender( - SYNO.SDS.iSCSI.Utils.T("log", "no_log_available") - ), - templates: { - cell: new Ext.XTemplate( - '