Created
February 3, 2021 13:37
-
-
Save Rhilip/e1b72f5d5974998077805e5c31f1d53d to your computer and use it in GitHub Desktop.
download.js from DSM 7.0 beta
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Copyright (c) 2020 Synology Inc. All rights reserved. */ | |
| Ext.namespace("SYNO.SDS.DownloadStation.DLM"); | |
| SYNO.SDS.DownloadStation.DLM.Util = {}; | |
| Ext.apply(SYNO.SDS.DownloadStation.DLM.Util, { | |
| timeleftCalc: function(c, b, a) { | |
| return (c === 0 ? -1 : Math.floor((b - a) / c)) | |
| }, | |
| convertTimeLeft: function(f, b) { | |
| var j = 0; | |
| var h = 0; | |
| var a = 0; | |
| var i = 0; | |
| var g = b ? "d" : _DT("download", "download_seed_days"); | |
| var d = b ? "h" : _DT("download", "download_seed_hours"); | |
| var c = b ? "m" : _DT("download", "download_seed_mins"); | |
| var e = b ? "s" : _DT("download", "download_seed_seconds"); | |
| if (f < 60) { | |
| return String.format("{0} {1}", f, e) | |
| } | |
| if (f < 3600) { | |
| a = Math.floor(f / 60); | |
| i = f - 60 * a; | |
| return String.format("{0} {1} {2} {3}", a, c, i, e) | |
| } | |
| if (f < 86400) { | |
| h = Math.floor(f / 3600); | |
| a = Math.floor((f - h * 3600) / 60); | |
| return String.format("{0} {1} {2} {3}", h, d, a, c) | |
| } | |
| j = Math.floor(f / 86400); | |
| h = Math.floor((f - j * 86400) / 3600); | |
| a = Math.floor((f - j * 86400 - h * 3600) / 60); | |
| return String.format("{0} {1} {2} {3} {4} {5}", j, g, h, d, a, c) | |
| }, | |
| nameRender: function(g, e, a, d, f, b) { | |
| var c = Ext.util.Format.htmlEncode(g); | |
| if (!Ext.isIE) { | |
| e.attr = 'ext:qtip="' + Ext.util.Format.htmlEncode(c) + '"' | |
| } | |
| return c | |
| }, | |
| startedtimeRender: function(g, e, b, d, f, c) { | |
| var h = (g === 0) ? "" : SYNO.SDS.DateTimeFormatter(new Date(g * 1000)); | |
| var a = Ext.util.Format.htmlEncode(h); | |
| e.attr = 'ext:qtip="' + Ext.util.Format.htmlEncode(a) + '"'; | |
| return a | |
| }, | |
| waitingtimeRender: function(g, e, a, c, f, b) { | |
| var d = (0 >= g) ? "" : SYNO.SDS.DownloadStation.DLM.Util.convertTimeLeft(g, true); | |
| e.attr = 'ext:qtip="' + Ext.util.Format.htmlEncode(d) + '"'; | |
| return d | |
| }, | |
| destinationRender: function(g, e, a, d, f, b) { | |
| var c = Ext.util.Format.htmlEncode(g); | |
| e.attr = 'ext:qtip="' + Ext.util.Format.htmlEncode(c) + '"'; | |
| return c | |
| }, | |
| createSeedTimeStore: function() { | |
| var b = [2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 16, 20, 24, 30, 36, 48, 60, 72, 96]; | |
| var a = [[0, _T("service", "service_dl_bt_seedopt_ignore")], [90, "90 " + _T("service", "service_dl_bt_seedopt_unit_mins")]]; | |
| for (var d = 0; d < b.length; d++) { | |
| a.push([b[d] * 60, b[d] + " " + _T("service", "service_dl_bt_seedopt_unit_hours")]) | |
| } | |
| a.push([-1, _T("service", "service_dl_bt_seedopt_forever")]); | |
| a.push([-2, _T("common", "customize")]); | |
| var c = new Ext.data.SimpleStore({ | |
| id: 0, | |
| fields: ["value", "display"], | |
| data: a | |
| }); | |
| return c | |
| }, | |
| sizeRenderer: function(e, c, d) { | |
| var b = 0; | |
| var a = [" B", " KB", " MB", " GB"]; | |
| if (!Ext.isNumber(e)) { | |
| return "" | |
| } | |
| if (0 === e) { | |
| return "0 B" | |
| } | |
| while (e >= 1024 && b < 3) { | |
| b += 1; | |
| e /= 1024 | |
| } | |
| return Ext.util.Format.htmlEncode(Ext.util.Format.number(e, "0.00") + a[b]) | |
| }, | |
| isActiveTorrentStatus: function(b) { | |
| var a = SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT; | |
| if ((a.TASK_DOWNLOADING === b) || (a.TASK_PRE_SEEDING === b) || (a.TASK_SEEDING === b) || (a.TASK_HASH_CHECKING === b)) { | |
| return true | |
| } | |
| return false | |
| }, | |
| isFinishedStatus: function(b) { | |
| var a = SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT; | |
| if ((a.TASK_FINISHED === b) || (a.TASK_FINISHING === b) || (a.TASK_EXTRACTING === b)) { | |
| return true | |
| } | |
| return false | |
| }, | |
| isSeedingStatus: function(b) { | |
| var a = SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT; | |
| if ((a.TASK_PRE_SEEDING === b) || (a.TASK_SEEDING === b)) { | |
| return true | |
| } | |
| return false | |
| }, | |
| isUnzipServiceOn: function() { | |
| if (!SYNO.SDS.DownloadStation.blUnzip && !_S("is_admin")) { | |
| return false | |
| } | |
| var a = SYNO.SDS.UserSettings.getProperty("SYNO.SDS.DownloadStation.Application", "unzip_settings"); | |
| if (!a || (a.enable_unzip !== "on" && a.enable_unzip !== true)) { | |
| return false | |
| } | |
| return true | |
| }, | |
| handleNewUnzipPW: function(e) { | |
| if (e === "") { | |
| return true | |
| } else { | |
| if (e.length > SYNO.SDS.DownloadStation.PW_MAX_LEN) { | |
| this.appWin.getMsgBox().alert(_DT("settings", "unzip_pw"), _DT("error", "unzip_pw_length")); | |
| return false | |
| } | |
| } | |
| e = e.replace(/\r/g, ""); | |
| var c = SYNO.SDS.UserSettings.getProperty("SYNO.SDS.DownloadStation.Application", "unzip_settings"); | |
| if (!c) { | |
| return false | |
| } | |
| var a = c.passwordPool; | |
| var d; | |
| if (a === "") { | |
| d = [] | |
| } else { | |
| try { | |
| d = Ext.util.JSON.decode(a) | |
| } catch (b) { | |
| d = [] | |
| } | |
| } | |
| if (d.length >= 30) { | |
| this.appWin.getMsgBox().alert(_DT("settings", "unzip_pw"), _DT("error", "unzip_pw_limit")); | |
| return false | |
| } | |
| if (d.indexOf(e) != -1) { | |
| return true | |
| } | |
| d.push(e); | |
| c.passwordPool = Ext.util.JSON.encode(d); | |
| SYNO.SDS.UserSettings.setProperty("SYNO.SDS.DownloadStation.Application", "unzip_settings", c); | |
| return true | |
| }, | |
| showErrorMessages: function(c, b, d, a) { | |
| if (b && b.code) { | |
| c.getMsgBox().alert(c.title, SYNO.SDS.DownloadStation.Utils.getErrorString(b.code), d, a) | |
| } else { | |
| c.getMsgBox().alert(c.title, _DT("common", "commfail"), d, a) | |
| } | |
| }, | |
| getLocationDestination: function() { | |
| return SYNO.SDS.DownloadStation.gData.dlm_default_destination | |
| }, | |
| setLocationDestination: function(a) { | |
| SYNO.SDS.DownloadStation.gData.dlm_default_destination = a | |
| }, | |
| checkLocationDestinationNonEmpty: function(e, b, d, c) { | |
| if (!Ext.isFunction(b)) { | |
| b = Ext.emptyFn | |
| } | |
| if (!Ext.isFunction(d)) { | |
| d = Ext.emptyFn | |
| } | |
| var a = this.getLocationDestination(); | |
| if (!Ext.isEmpty(a)) { | |
| b.call(c, a); | |
| return | |
| } | |
| e.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.Settings.Location", | |
| method: "get", | |
| version: 1, | |
| callback: function(i, g, h, f) { | |
| if (!i) { | |
| this.showErrorMessages(e, g); | |
| return | |
| } | |
| if (Ext.isEmpty(g.default_destination)) { | |
| d.call(c); | |
| e.mainPanel.alertDestinationEmptyWithLaunchingChooser() | |
| } else { | |
| this.setLocationDestination(g.default_destination); | |
| b.call(c, g.default_destination) | |
| } | |
| }, | |
| scope: this | |
| }) | |
| } | |
| }); | |
| SYNO.SDS.DLFileStationPlugin = { | |
| addTask: function(e) { | |
| var d = []; | |
| var b, a, c = e.length; | |
| for (b = 0; b < c; b++) { | |
| a = e[b].data; | |
| d.push(SYNO.API.EscapeStr(a.file_id)) | |
| } | |
| SYNO.SDS.DLFileStationPlugin._getTaskDestination().then(SYNO.SDS.DLFileStationPlugin._addTaskByLocal.bind(this, d))["catch"](SYNO.SDS.DLFileStationPlugin._onAddDownloadTaskDone.bind(this, false, { | |
| code: 406 | |
| })) | |
| }, | |
| checkPriv: function(b, c) { | |
| if (!SYNO.SDS.StatusNotifier.isAppHasPrivilege("SYNO.SDS.DownloadStation.Application")) { | |
| return false | |
| } | |
| var d = ["torrent", "nzb", "txt"]; | |
| var a = Ext.each(c, function(e) { | |
| var f = e.id.split(".").pop(); | |
| if (!Ext.isDefined(f)) { | |
| return true | |
| } | |
| if (0 > d.indexOf(f.toLowerCase())) { | |
| return false | |
| } | |
| }); | |
| return !Ext.isDefined(a) | |
| }, | |
| _onAddDownloadTaskDone: function(g, c, f, b) { | |
| var e = _T("fileaction", "add_to_download_station"); | |
| var d = _T("error", "error_error_system"); | |
| var a; | |
| if (!g) { | |
| a = c ? c.code : 100; | |
| if (a === 401) { | |
| d = _DT("download", "download_task_quota_reached") | |
| } else { | |
| if (a === 402) { | |
| d = _DT("download", "download_task_dest_deny") | |
| } else { | |
| if (a === 403) { | |
| d = _DT("download", "download_task_dest_not_exist") | |
| } else { | |
| if (a === 406) { | |
| d = _DT("download", "download_task_dest_not_exist") | |
| } else { | |
| if (a === 408) { | |
| d = _DT("error", "error_no_path") | |
| } | |
| } | |
| } | |
| } | |
| } | |
| this.showMsg(e, d) | |
| } | |
| }, | |
| _addTaskByLocal: function(b, a) { | |
| SYNO.API.currentManager.requestAPI({ | |
| api: "SYNO.DownloadStation2.Task", | |
| method: "create", | |
| version: "2", | |
| params: { | |
| type: "local", | |
| local_path: b.join(","), | |
| destination: a, | |
| create_list: false | |
| }, | |
| callback: SYNO.SDS.DLFileStationPlugin._onAddDownloadTaskDone, | |
| scope: this | |
| }) | |
| }, | |
| _getTaskDestination: function() { | |
| return new Promise(function(c, b) { | |
| var a = SYNO.SDS.DownloadStation.DLM.Util.getLocationDestination(); | |
| if (!Ext.isEmpty(a)) { | |
| return c(a) | |
| } | |
| SYNO.API.currentManager.requestAPI({ | |
| api: "SYNO.DownloadStation2.Settings.Location", | |
| method: "get", | |
| version: 1, | |
| callback: function(g, e, f, d) { | |
| if (!g || Ext.isEmpty(e.default_destination)) { | |
| return b() | |
| } | |
| return c(e.default_destination) | |
| } | |
| }) | |
| } | |
| ) | |
| } | |
| }; | |
| Ext.namespace("SYNO.SDS.DownloadStation.FileChooser"); | |
| Ext.define("SYNO.SDS.DownloadStation.FileChooser.CustTreeNodeUI", { | |
| extend: "Ext.tree.TreeNodeUI", | |
| statics: { | |
| STATE: 3, | |
| CHECKSTATE: 2, | |
| UNCHECKSTATE: 1, | |
| GRAYSTATE: 0 | |
| }, | |
| values: [null, false, true], | |
| checkedCls: ["x-checkbox-grayed", null, "x-checkbox-checked"], | |
| checkboxCls: "x-checkbox", | |
| expanded: false, | |
| err: -1, | |
| textField: null, | |
| showTextFieldAlways: false, | |
| initEvents: function() { | |
| SYNO.SDS.DownloadStation.FileChooser.CustTreeNodeUI.superclass.initEvents.apply(this, arguments); | |
| if (this.checkbox) { | |
| Ext.EventManager.on(this.checkbox, "click", this.toggleCheck, this) | |
| } | |
| }, | |
| destroy: function() { | |
| if (this.checkbox) { | |
| Ext.EventManager.un(this.checkbox, "click", this.toggleCheck, this) | |
| } | |
| SYNO.SDS.DownloadStation.FileChooser.CustTreeNodeUI.superclass.destroy.apply(this, arguments) | |
| }, | |
| getCheckIndex: function(b) { | |
| for (var a = 0; a < this.values.length; a++) { | |
| if (b.getUI() && b.getUI().checkbox && b.getUI().checkbox.checked === this.values[a]) { | |
| return a | |
| } | |
| } | |
| return this.err | |
| }, | |
| getTextValue: function(a) { | |
| return a.getUI().textField.value | |
| }, | |
| setTextValue: function(b, a) { | |
| b.getUI().textField.value = a | |
| }, | |
| clearCheck: function() { | |
| if (true === this.node.disabled) { | |
| return | |
| } | |
| this.onCheckChange(SYNO.SDS.DownloadStation.FileChooser.CustTreeNodeUI.UNCHECKSTATE) | |
| }, | |
| onCheckChange: function(a) { | |
| this.checkbox.checked = this.values[a]; | |
| this.checkbox.className = this.checkedCls[a]; | |
| if (this.node.firstChild) { | |
| this.updateChild(this.node.firstChild, a) | |
| } | |
| if (this.node.parentNode != this.root) { | |
| this.updateParent(this.node.parentNode, a) | |
| } | |
| var b = this.checkbox.checked; | |
| this.node.attributes.checked = b; | |
| this.fireEvent("checkchange", this.node, b) | |
| }, | |
| toggleCheck: function() { | |
| if (true === this.node.disabled) { | |
| return | |
| } | |
| var a = this.getCheckIndex(this.node); | |
| a = (a === SYNO.SDS.DownloadStation.FileChooser.CustTreeNodeUI.UNCHECKSTATE) ? SYNO.SDS.DownloadStation.FileChooser.CustTreeNodeUI.CHECKSTATE : SYNO.SDS.DownloadStation.FileChooser.CustTreeNodeUI.UNCHECKSTATE; | |
| this.onCheckChange(a) | |
| }, | |
| updateChild: Ext.emptyFn, | |
| updateParent: Ext.emptyFn, | |
| checkchildstate: function(b) { | |
| var a = b.firstChild; | |
| if (!a) { | |
| return this.err | |
| } | |
| while (a) { | |
| if (SYNO.SDS.DownloadStation.FileChooser.CustTreeNodeUI.UNCHECKSTATE !== this.getCheckIndex(a)) { | |
| return SYNO.SDS.DownloadStation.FileChooser.CustTreeNodeUI.GRAYSTATE | |
| } | |
| a = a.nextSibling | |
| } | |
| return SYNO.SDS.DownloadStation.FileChooser.CustTreeNodeUI.UNCHECKSTATE | |
| }, | |
| renderElements: function(e, i, h, j) { | |
| this.indentMarkup = e.parentNode ? e.parentNode.ui.getChildIndent() : ""; | |
| var f = (undefined === i.inputType) ? "text" : i.inputType; | |
| var b, c = i.href ? i.href : Ext.isGecko ? "" : "#", d = ['<li class="x-tree-node">', '<div ext:tree-node-id="', Ext.util.Format.htmlEncode(e.id), '" class="x-tree-node-el x-tree-node-leaf x-unselectable ', i.cls, '" unselectable="on">', '<span class="x-tree-node-indent">', this.indentMarkup, "</span>", '<img alt="" src="', this.emptyIcon, '" class="x-tree-ec-icon x-tree-elbow" />', '<img alt="" src="', i.icon || this.emptyIcon, '" class="x-tree-node-icon', (i.icon ? " x-tree-node-inline-icon" : ""), (i.iconCls ? " " + i.iconCls : ""), '" unselectable="on" />', '<span><img alt="" src="' + this.emptyIcon + '" style="margin:0 2px 0 2px;" class="x-checkbox" /></span>', '<a hidefocus="on" class="x-tree-node-anchor" href="', c, '" tabIndex="1" ', i.hrefTarget ? ' target="' + i.hrefTarget + '"' : "", '><span unselectable="on">', e.text, "</span></a>", '<input style="width:140px;" class="x-form-text x-form-field" type=' + f + "></input>", "</div>", '<ul class="x-tree-node-ct" style="display:none;"></ul>', "</li>"].join(""); | |
| if (j !== true && e.nextSibling && (b = e.nextSibling.ui.getEl())) { | |
| this.wrap = Ext.DomHelper.insertHtml("beforeBegin", b, d) | |
| } else { | |
| this.wrap = Ext.DomHelper.insertHtml("beforeEnd", h, d) | |
| } | |
| this.elNode = this.wrap.childNodes[0]; | |
| this.ctNode = this.wrap.childNodes[1]; | |
| var g = this.elNode.childNodes; | |
| this.indentNode = g[0]; | |
| this.ecNode = g[1]; | |
| this.iconNode = g[2]; | |
| this.checkbox = g[3]; | |
| if (i.checked === "checked") { | |
| this.checkbox.checked = this.values[SYNO.SDS.DownloadStation.FileChooser.CustTreeNodeUI.CHECKSTATE]; | |
| this.checkbox.className = this.checkedCls[SYNO.SDS.DownloadStation.FileChooser.CustTreeNodeUI.CHECKSTATE] | |
| } else { | |
| if (i.checked === "gray") { | |
| this.checkbox.checked = this.values[SYNO.SDS.DownloadStation.FileChooser.CustTreeNodeUI.GRAYSTATE]; | |
| this.checkbox.className = this.checkedCls[SYNO.SDS.DownloadStation.FileChooser.CustTreeNodeUI.GRAYSTATE] | |
| } else { | |
| if (i.checked === "unchecked") { | |
| this.checkbox.checked = this.values[SYNO.SDS.DownloadStation.FileChooser.CustTreeNodeUI.UNCHECKSTATE]; | |
| this.checkbox.className = this.checkedCls[SYNO.SDS.DownloadStation.FileChooser.CustTreeNodeUI.UNCHECKSTATE] | |
| } else { | |
| Ext.fly(this.checkbox).hide() | |
| } | |
| } | |
| } | |
| this.anchor = g[4]; | |
| this.textNode = g[4].firstChild; | |
| this.textField = g[5]; | |
| if (true !== i.showTextField) { | |
| Ext.fly(this.textField).hide() | |
| } | |
| if (i.textValue) { | |
| this.textField.value = i.textValue | |
| } | |
| this.showTextFieldAlways = i.showTextFieldAlways | |
| }, | |
| onClick: function(c) { | |
| if (this.dropping) { | |
| c.stopEvent(); | |
| return | |
| } | |
| if (this.fireEvent("beforeclick", this.node, c) !== false) { | |
| var b = c.getTarget("a"); | |
| if (!this.disabled && this.node.attributes.href && b) { | |
| this.fireEvent("click", this.node, c); | |
| return | |
| } else { | |
| if (b && c.ctrlKey) { | |
| c.stopEvent() | |
| } | |
| } | |
| c.preventDefault(); | |
| if (this.disabled) { | |
| return | |
| } | |
| if (this.node.attributes.singleClickExpand && !this.animating && this.node.isExpandable()) { | |
| this.node.toggle() | |
| } | |
| this.fireEvent("click", this.node, c); | |
| if (true === this.node.attributes.showTextField) { | |
| this.textField.focus() | |
| } | |
| } else { | |
| c.stopEvent() | |
| } | |
| }, | |
| onDisableChange: function(a, b) { | |
| this.disabled = b; | |
| if (this.checkbox) { | |
| this.checkbox.disabled = b | |
| } | |
| if (b) { | |
| this.addClass("x-tree-node-disabled") | |
| } else { | |
| this.removeClass("x-tree-node-disabled") | |
| } | |
| if (this.textField) { | |
| if (this.showTextFieldAlways) { | |
| this.textField.disabled = false | |
| } else { | |
| this.textField.disabled = b | |
| } | |
| } | |
| } | |
| }); | |
| Ext.define("SYNO.SDS.DownloadStation.FileChooser.Chooser", { | |
| extend: "SYNO.SDS.Utils.FileChooser.Chooser", | |
| initTreeLoader: function(b) { | |
| var a = this.callParent([b]); | |
| a.createNode = function(c, d) { | |
| c = SYNO.SDS.Utils.FileChooser.Utils.ParseTreeNode(c, d); | |
| if (!c.spath) { | |
| c.spath = c.path | |
| } | |
| if ((!b.enumGluster && c.is_gluster) || (!b.enumSnapshot && c.is_snapshot) || (!b.enumC2Share && c.is_c2share) || (!b.enumColdStorage && c.is_cold_storage) || (Ext.isFunction(b.treeFilter) && false === b.treeFilter(this, c))) { | |
| c.cls = (c.cls || "") + (" node_display_none"); | |
| c.hideNode = true | |
| } | |
| if (Ext.isDefined(c.children) && Ext.isArray(c.children.files) && c.children.files.length > 0) { | |
| c.expanded = true | |
| } | |
| if ("chooseDir" === b.usage.type && b.usage.multiselect) { | |
| c.uiProvider = SYNO.SDS.DownloadStation.FileChooser.CustTreeNodeUI; | |
| c.checked = b.checkRender ? b.checkRender.apply(b.callbackScope || this, [c]) : "unchecked" | |
| } | |
| return SYNO.API.TreeLoader.prototype.createNode.call(this, c) | |
| } | |
| ; | |
| return a | |
| }, | |
| onTreeBeforeSelect: function(c, a, b) { | |
| if ("chooseDir" === this.usage.type && this.usage.multiselect) { | |
| return false | |
| } | |
| return this.callParent([c, a, b]) | |
| }, | |
| applyHandlerWhenChoosingDir: function(b, c) { | |
| if (this.usage.multiselect) { | |
| b = []; | |
| var a = function() { | |
| if ("checked" === this.attributes.checked || true === this.attributes.checked) { | |
| b.push({ | |
| path: this.attributes.spath, | |
| fullpath: this.attributes.path | |
| }) | |
| } | |
| }; | |
| this.tree.root.cascade(a); | |
| this.fireEvent("choose", this, b, c) | |
| } else { | |
| this.callParent([b, c]) | |
| } | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation"); | |
| function _DT(b, a) { | |
| return _TT("SYNO.SDS.DownloadStation.Application", b, a) | |
| } | |
| SYNO.SDS.DownloadStation.PW_MAX_LEN = 1024; | |
| SYNO.SDS.DownloadStation.Utils = {}; | |
| Ext.apply(SYNO.SDS.DownloadStation.Utils, { | |
| TASK_STATUS_INT: { | |
| TASK_WAITING: 1, | |
| TASK_DOWNLOADING: 2, | |
| TASK_PAUSED: 3, | |
| TASK_FINISHING: 4, | |
| TASK_FINISHED: 5, | |
| TASK_HASH_CHECKING: 6, | |
| TASK_PRE_SEEDING: 7, | |
| TASK_SEEDING: 8, | |
| TASK_FILEHOSTING_WAITING: 9, | |
| TASK_EXTRACTING: 10, | |
| TASK_PREPROCESSING: 11, | |
| TASK_PREPROCESSPASS: 12, | |
| TASK_DOWNLOADED: 13, | |
| TASK_POSTPROCESSING: 14, | |
| TASK_CAPTCHA_NEEDED: 15, | |
| TASK_ERROR: 101, | |
| TASK_ERROR_BROKEN_LINK: 102, | |
| TASK_ERROR_DEST_NO_EXIST: 103, | |
| TASK_ERROR_DEST_DENY: 104, | |
| TASK_ERROR_DISK_FULL: 105, | |
| TASK_ERROR_QUOTA_REACHED: 106, | |
| TASK_ERROR_TIMEOUT: 107, | |
| TASK_ERROR_EXCEED_MAX_FS_SIZE: 108, | |
| TASK_ERROR_EXCEED_MAX_TEMP_FS_SIZE: 109, | |
| TASK_ERROR_EXCEED_MAX_DEST_FS_SIZE: 110, | |
| TASK_ERROR_NAME_TOO_LONG_ENCRYPTION: 111, | |
| TASK_ERROR_NAME_TOO_LONG: 112, | |
| TASK_ERROR_TORRENT_DUPLICATE: 113, | |
| TASK_ERROR_FILE_NO_EXIST: 114, | |
| TASK_ERROR_REQUIRED_PREMIUM: 115, | |
| TASK_ERROR_NOT_SUPPORT_TYPE: 116, | |
| TASK_ERROR_FTP_ENCRYPTION_NOT_SUPPORT_TYPE: 117, | |
| TASK_ERROR_EXTRACT_FAIL: 118, | |
| TASK_ERROR_EXTRACT_WRONG_PASSWORD: 119, | |
| TASK_ERROR_EXTRACT_INVALID_ARCHIVE: 120, | |
| TASK_ERROR_EXTRACT_QUOTA_REACHED: 121, | |
| TASK_ERROR_EXTRACT_DISK_FULL: 122, | |
| TASK_ERROR_TORRENT_INVALID: 123, | |
| TASK_ERROR_REQUIRED_ACCOUNT: 124, | |
| TASK_ERROR_TRY_IT_LATER: 125, | |
| TASK_ERROR_ENCRYPTION: 126, | |
| TASK_ERROR_MISSING_PYTHON: 127, | |
| TASK_ERROR_PRIVATE_VIDEO: 128, | |
| TASK_ERROR_EXTRACT_FOLDER_NOT_EXIST: 129, | |
| TASK_ERROR_NZB_MISSING_ARTICLE: 130, | |
| TASK_ERROR_ED2K_LINK_DUPLICATE: 131, | |
| TASK_ERROR_DEST_FILE_DUPLICATE: 132, | |
| TASK_ERROR_PARCHIVE_REPAIR_FAILED: 133, | |
| TASK_ERROR_INVALID_ACCOUNT_PASSWORD: 134 | |
| }, | |
| getStatusString: function(a) { | |
| switch (a) { | |
| case 1: | |
| case 11: | |
| case 12: | |
| return _DT("download", "download_task_waiting"); | |
| case 2: | |
| return _DT("download", "download_task_downloading"); | |
| case 3: | |
| return _DT("download", "download_task_paused"); | |
| case 4: | |
| case 13: | |
| case 14: | |
| return _DT("download", "download_task_finishing"); | |
| case 5: | |
| return _DT("download", "download_task_finished"); | |
| case 6: | |
| return _DT("download", "download_task_hash_checking"); | |
| case 7: | |
| return _DT("download", "download_task_preseeding"); | |
| case 8: | |
| return _DT("download", "download_task_seeding"); | |
| case 9: | |
| return _DT("download", "download_task_filehosting_waiting"); | |
| case 10: | |
| return _DT("download", "download_task_extracting"); | |
| case 15: | |
| return _DT("download", "captcha_needed"); | |
| case 102: | |
| return _DT("download", "download_task_broken_link"); | |
| case 103: | |
| return _DT("download", "download_task_dest_not_exist"); | |
| case 104: | |
| return _DT("download", "download_task_dest_deny"); | |
| case 105: | |
| return _DT("download", "download_task_disk_full"); | |
| case 106: | |
| return _DT("download", "download_task_quota_reached"); | |
| case 107: | |
| return _DT("download", "download_task_timeout"); | |
| case 108: | |
| return _DT("download", "download_error_exceed_fs_max_size_short"); | |
| case 109: | |
| return _DT("download", "download_error_exceed_temp_fs_max_size_short"); | |
| case 110: | |
| return _DT("download", "download_error_exceed_dest_fs_max_size_short"); | |
| case 111: | |
| return _DT("error", "error_encryption_long_path"); | |
| case 112: | |
| return _DT("error", "error_long_path"); | |
| case 113: | |
| return _DT("error", "error_duplicate_torrent"); | |
| case 114: | |
| return _DT("download", "download_err_no_file_to_end"); | |
| case 115: | |
| return _DT("dlqueue", "premium_account_require_status"); | |
| case 116: | |
| return _DT("download", "not_support_type"); | |
| case 117: | |
| return _DT("download", "download_ftp_encrption_not_support_type"); | |
| case 118: | |
| return _DT("download", "download_error_extract_fail"); | |
| case 119: | |
| return _DT("download", "download_error_extract_fail") + "(" + _DT("download", "wrong_password") + ")"; | |
| case 120: | |
| return _DT("download", "download_error_extract_fail") + "(" + _DT("download", "invalid_archive") + ")"; | |
| case 121: | |
| return _DT("download", "download_error_extract_fail") + "(" + _DT("download", "download_task_quota_reached") + ")"; | |
| case 122: | |
| return _DT("download", "download_error_extract_fail") + "(" + _DT("download", "download_task_disk_full") + ")"; | |
| case 123: | |
| return _DT("error", "error_invalid_torrent"); | |
| case 124: | |
| return _DT("download", "account_require_status"); | |
| case 125: | |
| return _DT("download", "download_error_try_it_later"); | |
| case 126: | |
| return _DT("dlqueue", "error_task_encryption"); | |
| case 127: | |
| return _DT("dlqueue", "error_missing_python"); | |
| case 128: | |
| return _DT("dlqueue", "error_private_video"); | |
| case 129: | |
| return _DT("download", "download_error_extract_fail") + "(" + _DT("download", "download_error_extract_folder_not_exist") + ")"; | |
| case 130: | |
| return _DT("download", "download_err_nzb_missing_article"); | |
| case 133: | |
| return _DT("download", "download_error_parchive_repair_failed"); | |
| case 134: | |
| return _DT("download", "error_invalid_account_password"); | |
| default: | |
| return _DT("download", "download_task_error") | |
| } | |
| }, | |
| getStatusCss: function(a) { | |
| switch (a) { | |
| case 1: | |
| case 11: | |
| case 12: | |
| case 15: | |
| return "syno-dl-task-waiting"; | |
| case 2: | |
| return "syno-dl-task-downloading"; | |
| case 3: | |
| return "syno-dl-task-paused"; | |
| case 4: | |
| case 13: | |
| case 14: | |
| return "syno-dl-task-finishing"; | |
| case 5: | |
| return "syno-dl-task-finished"; | |
| case 6: | |
| return "syno-dl-task-hash-checking"; | |
| case 7: | |
| return "syno-dl-task-preseeding"; | |
| case 8: | |
| return "syno-dl-task-seeding"; | |
| case 10: | |
| return "syno-dl-task-extracting"; | |
| case 101: | |
| case 102: | |
| case 103: | |
| case 104: | |
| case 105: | |
| case 106: | |
| case 107: | |
| case 108: | |
| case 109: | |
| case 110: | |
| case 111: | |
| case 112: | |
| case 113: | |
| case 114: | |
| case 115: | |
| case 116: | |
| case 117: | |
| case 118: | |
| case 119: | |
| case 120: | |
| case 121: | |
| case 122: | |
| case 123: | |
| case 124: | |
| case 125: | |
| case 126: | |
| case 127: | |
| case 128: | |
| case 129: | |
| case 130: | |
| case 131: | |
| case 132: | |
| case 133: | |
| case 134: | |
| return "syno-dl-task-error"; | |
| default: | |
| return "" | |
| } | |
| }, | |
| getTaskStatusStr: function(b) { | |
| var c; | |
| var a = SYNO.SDS.DownloadStation.Utils; | |
| if (a.TASK_STATUS_INT.TASK_EXTRACTING === b.status) { | |
| c = a.getStatusString(b.status) + "(" + b.status_extra.extract_progress + " %)" | |
| } else { | |
| c = a.getStatusString(b.status) | |
| } | |
| return c | |
| }, | |
| isTaskErrorStatus: function(a) { | |
| return a >= SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_ERROR | |
| }, | |
| canonizeURLPrefix: function(b) { | |
| var c = Ext.util.Format.lowercase(b); | |
| var a = ""; | |
| if (c.substr(0, 7) == "http://") { | |
| a = "http://" + b.substr(7) | |
| } else { | |
| if (c.substr(0, 8) == "https://") { | |
| a = "https://" + b.substr(8) | |
| } else { | |
| if (c.substr(0, 6) == "ftp://") { | |
| a = "ftp://" + b.substr(6) | |
| } else { | |
| if (c.substr(0, 7) == "ftps://") { | |
| a = "ftps://" + b.substr(7) | |
| } else { | |
| if (c.substr(0, 7) == "sftp://") { | |
| a = "sftp://" + b.substr(7) | |
| } else { | |
| if (c.substr(0, 10) == "thunder://") { | |
| a = "thunder://" + b.substr(10) | |
| } else { | |
| if (c.substr(0, 11) == "flashget://") { | |
| a = "flashget://" + b.substr(11) | |
| } else { | |
| if (c.substr(0, 7) == "qqdl://") { | |
| a = "qqdl://" + b.substr(7) | |
| } else { | |
| if ("magnet:?" === c.substr(0, 8)) { | |
| a = "magnet:?" + b.substr(8) | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| return a | |
| }, | |
| isMagnetLink: function(b) { | |
| var a = false; | |
| var c = Ext.util.Format.lowercase(b); | |
| if ("magnet:?" === c.substr(0, 8)) { | |
| a = true | |
| } | |
| return a | |
| }, | |
| showhideTab: function(b, a, c) { | |
| if (b) { | |
| if (!a) { | |
| b.hideTabStripItem(c); | |
| b.setActiveTab("download") | |
| } else { | |
| b.unhideTabStripItem(c) | |
| } | |
| } | |
| }, | |
| addUIComponents: function(d, a, c) { | |
| if (d.uicomponents) { | |
| d.uicomponents[a] = c | |
| } else { | |
| var b = {}; | |
| b[a] = c; | |
| b.uicomponents = b; | |
| d.uicomponents = b | |
| } | |
| }, | |
| fillArray: function(d, b) { | |
| if (b === 0) { | |
| return [] | |
| } | |
| var c = [d]; | |
| while (c.length * 2 <= b) { | |
| c = c.concat(c) | |
| } | |
| if (c.length < b) { | |
| c = c.concat(c.slice(0, b - c.length)) | |
| } | |
| return c | |
| }, | |
| parseJsonData: function(d, b) { | |
| var a; | |
| b = Ext.isEmpty(b) ? false : b; | |
| try { | |
| if (b) { | |
| d = Ext.util.Format.stripTags(d) | |
| } | |
| a = Ext.util.JSON.decode(d) | |
| } catch (c) { | |
| SYNO.Debug("Fail to parse json " + c) | |
| } | |
| return a | |
| }, | |
| chooseDestHandler: function(a) { | |
| var b = { | |
| title: _DT("download", "download_list_dest_folder"), | |
| folderToolbar: true, | |
| cls: "syno-dl-win", | |
| usage: { | |
| type: "chooseDir" | |
| }, | |
| treeFilter: this.folderRightFilter | |
| }; | |
| Ext.apply(b, a); | |
| if (!b.destinationField && (!b.callback || !b.callbackScope)) { | |
| SYNO.Debug("Missing destination field or callback information"); | |
| return | |
| } | |
| var c = new SYNO.SDS.DownloadStation.FileChooser.Chooser(b); | |
| if (b.callback && b.callbackScope) { | |
| c.mon(c, "choose", b.callback, b.callbackScope) | |
| } else { | |
| if (b.destinationField) { | |
| c.mon(c, "choose", function(f, e, d) { | |
| var g = e.path.substr(1); | |
| f.destinationField.setValue(g); | |
| f.close() | |
| }, this) | |
| } | |
| } | |
| c.open(); | |
| return c | |
| }, | |
| folderRightFilter: function(b, a) { | |
| if ((true === _S("is_admin")) || "true" === _S("domainUser")) { | |
| return true | |
| } | |
| if (-1 == a.spath.indexOf("/", 1)) { | |
| if ("RW" === a.right) { | |
| return true | |
| } else { | |
| return false | |
| } | |
| } | |
| if (a.aclRight & SYNO.SDS.Utils.FileChooser.Utils.Mode_Append && a.aclRight & SYNO.SDS.Utils.FileChooser.Utils.Mode_Exec && a.aclRight & SYNO.SDS.Utils.FileChooser.Utils.Mode_Read && a.aclRight & SYNO.SDS.Utils.FileChooser.Utils.Mode_Write) { | |
| return true | |
| } else { | |
| return false | |
| } | |
| }, | |
| getLocalizedString: function(b) { | |
| var a = "SYNO.SDS.DownloadStation.Application"; | |
| return (Ext.isDefined(SYNO.SDS.UIString) && Ext.isDefined(SYNO.SDS.UIString.GetLocalizedString)) ? SYNO.SDS.UIString.GetLocalizedString(b, a) : SYNO.SDS.Utils.GetLocalizedString(b, a) | |
| }, | |
| checkStateValue: function(b, k) { | |
| if (Ext.isEmpty(b)) { | |
| return false | |
| } | |
| var j = {}; | |
| var m = []; | |
| var a = []; | |
| Ext.each(k.columns, function(i) { | |
| if (Ext.isDefined(i.id)) { | |
| m.push(i.id) | |
| } | |
| if (Ext.isDefined(i.dataIndex)) { | |
| a.push(i.dataIndex) | |
| } | |
| }); | |
| if (Ext.isDefined(b.sort) && Ext.isDefined(b.sort.field) && -1 != a.indexOf(b.sort.field) && Ext.isDefined(b.sort.direction) && ("DESC" === b.sort.direction || "ASC" === b.sort.direction)) { | |
| j.sort = { | |
| field: b.sort.field, | |
| direction: b.sort.direction | |
| } | |
| } | |
| j.columns = []; | |
| var l = b.columns; | |
| for (var g = 0; g < l.length; g++) { | |
| var e = {}; | |
| if (!Ext.isDefined(l[g])) { | |
| continue | |
| } | |
| var d = l[g].id; | |
| if (!Ext.isDefined(d)) { | |
| continue | |
| } | |
| var h = m.indexOf(d); | |
| if (-1 == h) { | |
| continue | |
| } | |
| m.splice(h, 1); | |
| e.id = d; | |
| var f = l[g].width; | |
| if (Ext.isDefined(f) && Ext.isNumber(f) && 0 < f) { | |
| e.width = f | |
| } | |
| var c = l[g].hidden; | |
| if (Ext.isDefined(c) && true === c) { | |
| e.hidden = c | |
| } | |
| j.columns.push(e) | |
| } | |
| if (j.columns.length != k.columns.length) { | |
| return false | |
| } | |
| return j | |
| }, | |
| fileSize: function(a) { | |
| if (a < 1024) { | |
| return a + " bytes" | |
| } else { | |
| if (a < 1048576) { | |
| return Math.round((a * 100) / 1024) / 100 + " KB" | |
| } else { | |
| if (a < 1073741824) { | |
| return Math.round((a * 100) / 1048576) / 100 + " MB" | |
| } else { | |
| if (a < 1099511627776) { | |
| return Math.round((a * 100) / 1073741824) / 100 + " GB" | |
| } else { | |
| return Math.round((a * 100) / 1099511627776) / 100 + " TB" | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| ERROR_CODE: { | |
| SYNODL_ERR_FILE_UPLOAD_FAILED: 400, | |
| SYNODL_ERR_REACH_LIMIT: 401, | |
| SYNODL_ERR_TASK_DEST_DENY: 402, | |
| SYNODL_ERR_TASK_DEST_NOT_EXISTS: 403, | |
| SYNODL_ERR_TASK_NOT_FOUND: 404, | |
| SYNODL_ERR_ACTION_INVALID: 405, | |
| SYNODL_ERR_NO_DEFAULT_DEST: 406, | |
| SYNODL_ERR_SET_TASK_DEST_FAILED: 407, | |
| SYNODL_ERR_FILE_NOT_EXISTS: 408, | |
| SYNODL_ERR_DEMO_NOT_ALLOW: 500, | |
| SYNODL_ERR_REQUEST_PARAMETER_INVALID: 501, | |
| SYNODL_ERR_JSON_PARSE_FAILED: 502, | |
| SYNODL_ERR_FORK_FAILED: 503, | |
| SYNODL_ERR_GET_KV_FAILED: 504, | |
| SYNODL_ERR_SET_KV_FAILED: 505, | |
| SYNODL_ERR_DLINFO_GET_FAILED: 506, | |
| SYNODL_ERR_DLINFO_SET_FAILED: 507, | |
| SYNODL_ERR_ALLOC_HASH_FAILED: 508, | |
| SYNODL_ERR_GET_SECTION_FAILED: 509, | |
| SYNODL_ERR_REMOVE_SECTION_FAILED: 510, | |
| SYNODL_ERR_CURL_INIT_FAILED: 511, | |
| SYNODL_ERR_CONNECT_SERVER_FAILED: 512, | |
| SYNODL_ERR_MAIL_SERVICE_NOT_ENABLED: 513, | |
| SYNODL_ERR_HUP_SCHEDULED_FAILED: 514, | |
| SYNODL_ERR_USER2_SCHEDULED_FAILED: 515, | |
| SYNODL_ERR_CMD_FAILED: 516, | |
| SYNODL_ERR_PORT_CONFLICT: 517, | |
| SYNODL_ERR_FIREWALL_HUP_FAILED: 518, | |
| SYNODL_ERR_NETWORK: 519, | |
| SYNODL_ERR_SYSTEM: 520, | |
| SYNODL_ERR_ACTION_FAILED: 521, | |
| SYNODL_ERR_SHARE_NOT_FOUND: 522, | |
| SYNODL_ERR_QUOTA_REACH: 523, | |
| SYNODL_ERR_NO_PRIVILEGE: 524, | |
| SYNODL_ERR_DATABASE_OPERATION_FAILED: 525, | |
| SYNODL_ERR_TASK_REACH_LIMIT_ALL: 526, | |
| SYNODL_ERR_TASK_REACH_LIMIT_USER: 527, | |
| SYNODL_ERR_EMPTY_PASSWORD: 528, | |
| SYNODL_ERR_USER_NOT_FOUND: 529, | |
| SYNODL_ERR_FILE_LOCK_FAILED: 530, | |
| SYNODL_ERR_PATH_NOT_EXISTS: 531, | |
| SYNODL_ERR_MKDIR_FAILED: 532, | |
| SYNODL_ERR_MKDIR_EXISTS: 533, | |
| SYNODL_ERR_MKDIR_NO_PERMISSION: 534, | |
| SYNODL_ERR_MKDIR_PATH_NOT_EXIST: 535, | |
| SYNODL_ERR_CREATE_DSMTASK_FAILED: 536, | |
| SYNODL_ERR_UNLINK_FAILED: 537, | |
| SYNODL_ERR_KILL_FAILED: 538, | |
| SYNODL_ERR_KILL_TIMEOUT: 539, | |
| SYNODL_ERR_BAD_IP: 540, | |
| SYNODL_ERR_EMPTY_USERNAME: 541, | |
| SYNODL_ERR_EMPTY_PATH: 542, | |
| SYNODL_ERR_VOLUME_CRASHED: 543, | |
| SYNODL_ERR_TASK_NOT_EXISTS: 544, | |
| SYNODL_ERR_EMULE_NOT_IN_SCHEDULE: 545, | |
| SYNODL_ERR_CHOWN_FAILED: 546, | |
| SYNODL_ERR_CHOWN_NO_PERMISSION: 547, | |
| SYNODL_ERR_CHOWN_PATH_NOT_EXIST: 548, | |
| SYNODL_ERR_XUNLEI_OP_FAILED: 1000, | |
| SYNODL_ERR_PGSQL_NOT_RUNNING: 1001, | |
| SYNODL_ERR_STOP_SERVICE_FAILED: 1002, | |
| SYNODL_ERR_START_SERVICE_FAILED: 1003, | |
| SYNODL_ERR_SET_VOLUME_FAILED: 1004, | |
| SYNODL_ERR_MOVE_DATA_FAILED: 1005, | |
| SYNODL_ERR_NO_ENOUGH_SPACE: 1006, | |
| SYNODL_ERR_GET_MEM_FAILED: 1200, | |
| SYNODL_ERR_TMPDIR_NOT_EXISTS: 1201, | |
| SYNODL_ERR_USER_REMOVED: 1202, | |
| SYNODL_ERR_TASK_DEST_INVALID_PATH: 1203, | |
| SYNODL_ERR_TASK_DEST_ACCESS_DENIED: 1204, | |
| SYNODL_ERR_WATCH_FOLDER_INVALID_PATH: 1205, | |
| SYNODL_ERR_WATCH_FOLDER_ACCESS_DENIED: 1206, | |
| SYNODL_ERR_WATCH_FOLDER_CONFLICT: 1207, | |
| SYNODL_ERR_SET_WATCH_FOLDER_FAILED: 1208, | |
| SYNODL_ERR_SET_PORT_FAILED: 1209, | |
| SYNODL_ERR_GET_ORDER_FAILED: 1210, | |
| SYNODL_ERR_MKDIR_USERPLUGIN_FAILED: 1400, | |
| SYNODL_ERR_PLUGIN_EXISTS: 1401, | |
| SYNODL_ERR_PLUGIN_INVALID: 1402, | |
| SYNODL_ERR_UPDATE_BTSEARCH_FAILED: 1403, | |
| SYNODL_ERR_BTSERACH_LOGIN_FAILED: 1404, | |
| SYNODL_ERR_UPDATE_BTSEARCH_SEVER_ERROR: 1405, | |
| SYNODL_ERR_GET_DLVERSION_FAILED: 1406, | |
| SYNODL_ERR_PERFORM_SEARCH_FAILED: 1407, | |
| SYNODL_ERR_BTSERACH_ID_NOT_FOUND: 1408, | |
| SYNODL_ERR_GET_HOSTING_ACCOUNT_FAILED: 1600, | |
| SYNODL_ERR_SET_HOSTING_ACCOUNT_FAILED: 1601, | |
| SYNODL_ERR_SET_HOSTING_ENABLED_FAILED: 1602, | |
| SYNODL_ERR_REMOVE_HOSTING_ACCOUNT_FAILED: 1603, | |
| SYNODL_ERR_VERIFY_ACCOUNT_FAILED: 1604, | |
| SYNODL_ERR_HOSTING_NOT_EXISTS: 1605, | |
| SYNODL_ERR_HOSTING_LOGIN_FAILED: 1606, | |
| SYNODL_ERR_HOSTING_EXISTS: 1607, | |
| SYNODL_ERR_HOSTING_INVALID: 1608, | |
| SYNODL_ERR_UPDATE_HOSTING_SEVER_ERROR: 1609, | |
| SYNODL_ERR_UPDATE_HOSTING_FAILED: 1610, | |
| SYNODL_ERR_METHOD_NOT_SUPPORTED: 1611, | |
| SYNODL_ERR_UNKNOWN_HOST_TYPE: 1612, | |
| SYNODL_ERR_EMPTY_HOSTING_NAME: 1613, | |
| SYNODL_ERR_PYLOAD_REQUEST_FAILED: 1614, | |
| SYNODL_ERR_EMULE_NOT_RUNNING: 1800, | |
| SYNODL_ERR_SHARE_DIR_GET_FAILED: 1801, | |
| SYNODL_ERR_SHARE_DIR_SET_FAILED: 1802, | |
| SYNODL_ERR_EMULE_INIT_FAILED: 1803, | |
| SYNODL_ERR_INCOMING_DIR_GET_FAILED: 1804, | |
| SYNODL_ERR_EMULE_NOT_ENABLED: 1805, | |
| SYNODL_ERR_SET_EMULE_PORT_FAILED: 1806, | |
| SYNODL_ERR_WRONG_URL: 1900, | |
| SYNODL_ERR_BAD_URLS_FOUND: 1901, | |
| SYNODL_ERR_ADD_LINK_ERROR_TITLE: 1902, | |
| SYNODL_ERR_WRONG_FILE_FORMAT: 1903, | |
| SYNODL_ERR_READ_NZB_FAILED: 1904, | |
| SYNODL_ERR_READ_TORRENT_FAILED: 1905, | |
| SYNODL_ERR_ADD_ED2K: 1906, | |
| SYNODL_ERR_SERVER_ERROR: 1907, | |
| SYNODL_ERR_DL_NOT_ENABLED: 1908, | |
| SYNODL_ERR_GET_TMP_FOLDER_FAILED: 1909, | |
| SYNODL_ERR_LIST_NOT_FOUND: 1910, | |
| SYNODL_ERR_RPC_FAILED: 1911, | |
| SYNODL_ERR_SET_UNZIP_PW_FAILED: 1912, | |
| SYNODL_ERR_BT_TASK_INACTIVE: 1913, | |
| SYNODL_ERR_EXCEED_FS_MAX_SIZE: 1914, | |
| SYNODL_ERR_EMULE_DUP_LINK: 1915, | |
| SYNODL_ERR_EMULE_FILE_EXIST: 1916, | |
| SYNODL_ERR_EMULE_NO_DEFAULT_DEST: 1917, | |
| SYNODL_ERR_NO_THUMBNAIL_AVAILABLE: 2200, | |
| SYNODL_ERR_NO_MEDIA_FILE: 2201, | |
| SYNODL_ERR_CAPTCHA_NOT_NEEDED: 2300, | |
| SYNODL_ERR_WRONG_CAPTCHA_CODE: 2301, | |
| SYNODL_ERR_RSS_ID_NOT_EXISTS: 2400, | |
| SYNODL_ERR_RSS_PARAMETER_INVALID: 2401, | |
| SYNODL_ERR_RSS_CREATE_FEED_FAILED: 2402, | |
| SYNODL_ERR_RSS_CREATE_FILTER_FAILED: 2403, | |
| SYNODL_ERR_RSS_DOWNLOAD: 2404, | |
| SYNODL_ERR_RSS_FORMAT: 2405, | |
| SYNODL_ERR_RSS_GET_FEED_FAILED: 2406, | |
| SYNODL_ERR_RSS_UPDATE_FEED_FAILED: 2407, | |
| SYNODL_ERR_RSS_UPDATE_FILTER_FAILED: 2408, | |
| SYNODL_ERR_RSS_REMOVE_OLD_ITEM_FAILED: 2409, | |
| SYNODL_ERR_RSS_UPDATE_ITEM_ALL_NEW_FAILED: 2410, | |
| SYNODL_ERR_RSS_GET_FILTERED_DOWNLOAD_LIST_FAILED: 2411, | |
| SYNODL_ERR_RSS_BAD_FEED_URL: 2412, | |
| SYNODL_ERR_RSS_DELETE_FEED_FAILED: 2413, | |
| SYNODL_ERR_RSS_DELETE_FILTER_FAILED: 2414, | |
| SYNODL_ERR_RSS_DELETE_ITEM_ALL_FAILED: 2415, | |
| SYNODL_ERR_RSS_FILE_EXIST: 2416, | |
| SYNODL_ERR_RSS_GET_FEED_BY_URL: 2417, | |
| SYNODL_ERR_RSS_LIST_ITEM_FAILED: 2418, | |
| SYNODL_ERR_RSS_LIST_FILTER_FAILED: 2419, | |
| SYNODL_ERR_RSS_TEST_FILTER_FAILED: 2420, | |
| SYNODL_ERR_PACKAGE_INFO_GET_FAILED: 2500, | |
| SYNODL_ERR_NZB_FILE_LIST_OPEN_FAILED: 2600, | |
| SYNODL_ERR_NZB_FILE_LIST_READ_FAILED: 2601, | |
| SYNODL_ERR_NZB_FILE_LIST_PARSE_FAILED: 2602, | |
| SYNODL_ERR_EMULE_SEARCH_PERFORM_FAILED: 2700, | |
| SYNODL_ERR_EMULE_SEARCH_STOP_FAILED: 2701, | |
| SYNODL_ERR_EMULE_SEARCH_RESULT_GET_FAILED: 2702, | |
| SYNODL_ERR_EMULE_SEARCH_BUSY: 2703, | |
| SYNODL_ERR_EMULE_ED2K_NOT_CONNECTED: 2704, | |
| SYNODL_ERR_EMULE_KAD_NOT_CONNECTED: 2705, | |
| SYNODL_ERR_EMULE_SERVER_LIST_FAILED: 2800, | |
| SYNODL_ERR_EMULE_SERVER_ADD_FAILED: 2801, | |
| SYNODL_ERR_EMULE_SERVER_DELETE_FAILED: 2802, | |
| SYNODL_ERR_EMULE_SERVER_DUP: 2803, | |
| SYNODL_ERR_EMULE_SERVER_CONNECT_FAILED: 2804, | |
| SYNODL_ERR_EMULE_SERVER_DISCONNECT_FAILED: 2805, | |
| SYNODL_ERR_EMULE_SERVER_GET_STATUS_FAILED: 2806, | |
| SYNODL_ERR_EMULE_SERVER_UPDATE_MET_FAILED: 2807, | |
| SYNODL_ERR_XUNLEI_GET_CAPTCHA_FAILED: 2900, | |
| SYNODL_ERR_XUNLEI_SET_ACCOUNT: 2901 | |
| }, | |
| getErrorString: function(a) { | |
| switch (a) { | |
| case 401: | |
| return _DT("download", "download_msg_reach_limit"); | |
| case 402: | |
| return _DT("download", "download_task_dest_deny"); | |
| case 403: | |
| return _DT("download", "download_task_dest_not_exist"); | |
| case 502: | |
| return _DT("settings", "fail_connect_server"); | |
| case 512: | |
| return _DT("settings", "fail_connect_server"); | |
| case 519: | |
| return _DT("download", "download_err_network"); | |
| case 521: | |
| return _DT("download", "download_msg_action_failed"); | |
| case 522: | |
| return _DT("download", "download_error_share_not_found"); | |
| case 523: | |
| return _DT("download", "download_task_quota_reached"); | |
| case 531: | |
| return _DT("download", "download_err_no_file_to_end"); | |
| case 540: | |
| return _DT("common", "error_badip"); | |
| case 543: | |
| return _DT("download", "download_err_tmploc_not_exist"); | |
| case 545: | |
| return _DT("download", "download_error_not_in_dl_schedule"); | |
| case 1204: | |
| return _DT("download", "download_task_dest_deny"); | |
| case 1207: | |
| return _DT("settings", "watch_torrentnzb_conflict"); | |
| case 1401: | |
| return _DT("download", "plugin_exist"); | |
| case 1402: | |
| return _DT("download", "plugin_invaled"); | |
| case 1404: | |
| return _DT("login", "error_cantlogin"); | |
| case 1405: | |
| return _DT("settings", "fail_connect_server"); | |
| case 1607: | |
| return _DT("download", "filehosting_exist"); | |
| case 1608: | |
| return _DT("download", "filehosting_invaled"); | |
| case 1800: | |
| return _DT("server", "error_emule_not_running"); | |
| case 1803: | |
| return _DT("server", "error_emule_not_running"); | |
| case 1900: | |
| return _DT("download", "download_error_wrong_url"); | |
| case 1901: | |
| return _DT("download", "download_error_bad_urls_found"); | |
| case 1902: | |
| return _DT("download", "download_add_link_error_title"); | |
| case 1903: | |
| return _DT("download", "download_error_wrong_file_format"); | |
| case 1904: | |
| return _DT("download", "download_err_read_nzb_fail"); | |
| case 1905: | |
| return _DT("download", "download_err_read_torrent_fail"); | |
| case 1906: | |
| return _DT("download", "download_add_ed2k_error"); | |
| case 1907: | |
| return _DT("download", "download_error_server_error"); | |
| case 1908: | |
| return _DT("download", "download_dl_not_enabled"); | |
| case 1914: | |
| return _DT("download", "download_error_exceed_dest_fs_max_size_short"); | |
| case 1915: | |
| return _DT("dlqueue", "error_task_queue_add_dup_file"); | |
| case 1916: | |
| return _DT("dlqueue", "error_task_add_dup_file"); | |
| case 1917: | |
| return _DT("download", "download_warning_select_share"); | |
| case 2401: | |
| return _DT("download", "download_error_invalid_rss"); | |
| case 2404: | |
| return _DT("download", "download_error_dl_rss"); | |
| case 2405: | |
| return _DT("download", "download_error_invalid_rss"); | |
| case 2412: | |
| return _DT("download", "download_error_wrong_rss_urls"); | |
| case 2416: | |
| return _DT("download", "download_rss_file_exist"); | |
| case 2704: | |
| if (_S("is_admin")) { | |
| return _DT("search", "error_server_not_connected") | |
| } else { | |
| return _DT("search", "error_server_not_connected_normaluser") | |
| } | |
| break; | |
| case 2705: | |
| if (_S("is_admin")) { | |
| return _DT("search", "error_kad_not_connected") | |
| } else { | |
| return _DT("search", "error_kad_not_connected_normaluser") | |
| } | |
| break; | |
| case 2801: | |
| return _DT("server", "error_server_add_new_server_failed"); | |
| case 2802: | |
| return _DT("server", "error_server_remove_failed"); | |
| case 2803: | |
| return _DT("server", "error_server_add_duplicate"); | |
| case 2807: | |
| return _DT("server", "error_server_update_met_failed"); | |
| default: | |
| return String.format(_DT("error", "error_unknown_with_code"), a) | |
| } | |
| }, | |
| setErrorMask: function(d, b) { | |
| if (543 === d && _S("is_admin")) { | |
| var e = _DT("download", "download_err_tmploc_not_exist_modify"); | |
| e = String.format(e, '<a href="#">' + _DT("download", "config") + "</a>"); | |
| var a = b.getEl().mask('<span class="syno-grid-tmpcrash">' + e + "</span>"); | |
| var c = Ext.DomQuery.selectNode("span.syno-grid-tmpcrash", a.dom.nextSibling); | |
| b.mon(Ext.fly(c), "click", function() { | |
| var f = new SYNO.SDS.DownloadStation.Settings.Window({ | |
| defaultActivedFn: "SYNO.SDS.DownloadStation.Settings.GlobalGen", | |
| owner: b.ownerCt.ownerCt.appWin | |
| }); | |
| f.open() | |
| }, this) | |
| } else { | |
| b.getEl().mask(SYNO.SDS.DownloadStation.Utils.getErrorString(d)) | |
| } | |
| }, | |
| isValidExtension: function(d, b) { | |
| var a = 0; | |
| var c = d.toLowerCase(); | |
| if (!d.length || !b.length) { | |
| return false | |
| } | |
| a = c.lastIndexOf(b); | |
| if (-1 == a) { | |
| return false | |
| } | |
| if (c.length != (a + b.length)) { | |
| return false | |
| } | |
| return true | |
| }, | |
| AddTip: function() { | |
| return Ext.isDefined(SYNO.ux.AddTip) ? SYNO.ux.AddTip.apply(this, arguments) : SYNO.SDS.Utils.AddTip.apply(this, arguments) | |
| }, | |
| composeButtonCfg: function(b, a) { | |
| if (Ext.isObject(a)) { | |
| a = [a] | |
| } | |
| a.push(b); | |
| return a | |
| } | |
| }); | |
| SYNO.SDS.DownloadStation.gData = {}; | |
| Ext.apply(SYNO.SDS.DownloadStation.gData, { | |
| get: function(a) { | |
| return SYNO.SDS.DownloadStation.gData[a] | |
| }, | |
| set: function(a, b) { | |
| SYNO.SDS.DownloadStation.gData[a] = b | |
| }, | |
| remove: function(a) { | |
| if (SYNO.SDS.DownloadStation.gData[a]) { | |
| delete SYNO.SDS.DownloadStation.gData[a] | |
| } | |
| }, | |
| apply: function(a) { | |
| Ext.apply(SYNO.SDS.DownloadStation.gData, a || {}) | |
| } | |
| }); | |
| Ext.define("SYNO.SDS.DownloadStation.ShowHideCheckGroup", { | |
| extend: "SYNO.ux.Utils.EnableCheckGroup", | |
| setFieldStatus: function(d, g, c, a) { | |
| var f, e, b; | |
| if (g.inputType == "radio") { | |
| f = SYNO.ux.Utils.getRadioGroup(d, g.getName()); | |
| for (b = 0; b < f.length; b++) { | |
| if (a) { | |
| e = c ? f[b].hide() : f[b].show() | |
| } else { | |
| e = c ? f[b].show() : f[b].hide() | |
| } | |
| if (Ext.isFunction(f[b].clearInvalid)) { | |
| f[b].clearInvalid() | |
| } | |
| } | |
| } else { | |
| if (a) { | |
| e = c ? g.hide() : g.show() | |
| } else { | |
| e = c ? g.show() : g.hide() | |
| } | |
| if (Ext.isFunction(g.clearInvalid)) { | |
| g.clearInvalid() | |
| } | |
| } | |
| }, | |
| checkHandler: function() { | |
| this.callParent(arguments); | |
| this.form.owner.doLayout() | |
| }, | |
| enableHandler: function() { | |
| this.callParent(arguments) | |
| } | |
| }); | |
| Ext.define("SYNO.SDS.DownloadStation.ToolbarRateItem", { | |
| extend: "Ext.Toolbar.TextItem", | |
| constructor: function(a) { | |
| var b = this.fillConfig(a); | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| if (!Ext.isObject(a) || !Ext.isString(a.labelText)) { | |
| throw 'Config "labelText" should be given.' | |
| } | |
| this.labelText = a.labelText ? (a.labelText + ": ") : ""; | |
| delete a.labelText; | |
| return Ext.apply({ | |
| cls: "syno-dl-rate syno-paging-display-text", | |
| text: this.labelText + "N/A" | |
| }, a) | |
| }, | |
| updateTextByRate: function(a) { | |
| this.setText(this.labelText + SYNO.SDS.DownloadStation.Utils.fileSize(a) + "/s") | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation"); | |
| Ext.define("SYNO.SDS.DownloadStation.ModuleList", { | |
| extend: "SYNO.ux.ModuleList", | |
| defineUIComponents: function(a) { | |
| SYNO.SDS.DownloadStation.Utils.addUIComponents(a, "moduleList", this) | |
| }, | |
| constructor: function(b, a) { | |
| this.webapiModuleGet = { | |
| api: "SYNO.DownloadStation2.Package.Module", | |
| method: "get", | |
| version: 2 | |
| }; | |
| this.defineUIComponents(b); | |
| Ext.apply(this, b.uicomponents || {}); | |
| var c = this.fillConfig(b); | |
| this.owner = a; | |
| this.defaultActivedFn = b.defaultActivedFn; | |
| this.callParent([c]); | |
| this.removeClass("syno-ux-modulelist"); | |
| this.getSelectionModel().on("selectionchange", this.onModuleListSelect, this); | |
| this.mon(this, "beforecollapsenode", function() { | |
| return false | |
| }) | |
| }, | |
| fillConfig: function(a) { | |
| this.moduleList = {}; | |
| var c = a.folder || a.currentItem.folder; | |
| var b = { | |
| cls: "syno-dl-tree syno-ux-modulelist", | |
| requestMethod: "POST", | |
| dataUrl: a.dataUrl || this.getDataUrl(c), | |
| tbar: a.toolbarConfig, | |
| listeners: { | |
| scope: this, | |
| single: true, | |
| load: function(f) { | |
| if (!this.defaultActivedFn && f.firstChild) { | |
| f.firstChild.on("expand", function(g) { | |
| if (g.firstChild && g.firstChild.attributes.fn) { | |
| this.selectModule(g.firstChild.attributes.fn) | |
| } | |
| }, this) | |
| } else { | |
| this.defaultActivedFn = this.defaultActivedFn || "SYNO.SDS.DownloadStation.Settings.GlobalGen"; | |
| var e = function(g) { | |
| if (g.findChild("fn", this.defaultActivedFn)) { | |
| this.selectModule(this.defaultActivedFn) | |
| } | |
| }; | |
| for (var d = 0; d < f.childNodes.length; d++) { | |
| f.childNodes[d].on("expand", e, this) | |
| } | |
| } | |
| } | |
| } | |
| }; | |
| return b | |
| }, | |
| getDataUrl: function(a) { | |
| var b = { | |
| name: a | |
| }; | |
| return this.getBaseURL(Ext.apply(this.webapiModuleGet, { | |
| params: b | |
| })) | |
| }, | |
| getModule: function(fn) { | |
| var ct = this.owner.moduleCt; | |
| var module = this.moduleList[fn]; | |
| if (undefined === module) { | |
| var FnObj; | |
| eval("FnObj = " + fn + ";"); | |
| module = new FnObj({ | |
| uicomponents: this.uicomponents, | |
| cp: this, | |
| owner: this.owner | |
| }); | |
| module.cp = this; | |
| var panel = module.getPanel(); | |
| panel.module = module; | |
| panel.itemId = fn; | |
| ct.add(panel); | |
| this.moduleList[fn] = module | |
| } | |
| return module | |
| }, | |
| activateModule: function(b, c) { | |
| if (b) { | |
| var a = b.getPanel(); | |
| if (a instanceof Ext.TabPanel && Ext.isFunction(a.setActiveTab)) { | |
| a.setActiveTab(0) | |
| } | |
| if (b.activate) { | |
| b.activate(c) | |
| } | |
| this.actived = b | |
| } | |
| }, | |
| deactivateModule: function(a) { | |
| if (a) { | |
| if (a.deactivate) { | |
| a.deactivate() | |
| } | |
| } | |
| }, | |
| getCurrentModule: function() { | |
| var a = this.owner.moduleCt.layout.activeItem; | |
| if (a) { | |
| return this.getModule(a.itemId) | |
| } | |
| }, | |
| startModule: function(b, c) { | |
| var a; | |
| a = this.getModule(b); | |
| if (!a) { | |
| return false | |
| } | |
| this.deactivateModule(this.getCurrentModule()); | |
| this.owner.moduleCt.layout.setActiveItem(b); | |
| this.activateModule(a, c) | |
| }, | |
| onModuleListSelect: function(a, c) { | |
| var b; | |
| if (!c.leaf) { | |
| return | |
| } | |
| b = c.attributes.fn; | |
| if (b) { | |
| this.startModule(b, c.attributes) | |
| } else { | |
| window.alert("not implemented yet") | |
| } | |
| }, | |
| getLocalizedString: function(a) { | |
| return SYNO.SDS.DownloadStation.Utils.getLocalizedString(a) | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation"); | |
| Ext.define("SYNO.SDS.DownloadStation.BoxTip", { | |
| extend: "Ext.BoxComponent", | |
| inited: false, | |
| defaultZIndex: 13000, | |
| defaultHeight: 27, | |
| hideDelay: 500, | |
| showDelay: 500, | |
| constructor: function() { | |
| this.callParent([{ | |
| renderTo: document.body, | |
| cls: "syno-dl-boxtip", | |
| hidden: true | |
| }]); | |
| this.inited = false; | |
| this.hoverCount = 0 | |
| }, | |
| createBoxElements: function() { | |
| var b = this.getEl(), a, c; | |
| this.background = b.createChild({ | |
| cls: "syno-dl-boxtip-background" | |
| }); | |
| a = this.background; | |
| this.backgroundTc = a.createChild({ | |
| tag: "div", | |
| cls: "syno-dl-boxtip-background-tc" | |
| }); | |
| this.backgroundMl = a.createChild({ | |
| tag: "div", | |
| cls: "syno-dl-boxtip-background-ml" | |
| }); | |
| this.backgroundMc = a.createChild({ | |
| tag: "div", | |
| cls: "syno-dl-boxtip-background-mc" | |
| }); | |
| this.backgroundMr = a.createChild({ | |
| tag: "div", | |
| cls: "syno-dl-boxtip-background-mr" | |
| }); | |
| this.boxMc = b.createChild({ | |
| tag: "div", | |
| cls: "syno-dl-boxtip-mc" | |
| }); | |
| this.arrow = b.createChild({ | |
| tag: "div", | |
| cls: "syno-dl-boxtip-arrow" | |
| }); | |
| c = this.boxMc; | |
| this.desc = c.createChild({ | |
| tag: "div", | |
| cls: "syno-dl-boxtip-desc" | |
| }); | |
| this.inited = true; | |
| this.mon(Ext.get("sds-taskbar"), "click", this.onTaskbarClick, this); | |
| this.mon(Ext.get("sds-taskbar"), "contextmenu", this.onTaskbarClick, this) | |
| }, | |
| onTaskbarClick: function() { | |
| this.hideBox(true) | |
| }, | |
| showBox: function(a, b) { | |
| if (!this.isEnabled()) { | |
| return | |
| } | |
| this.needShowBox = true; | |
| this.hoverCount += 1; | |
| this.doShowBox.defer(300, this, [a, b, this.hoverCount]) | |
| }, | |
| doShowBox: function(f, h, e) { | |
| var b, a = 14.25, g, c, d = [0, 0]; | |
| if (!f) { | |
| return | |
| } | |
| if (this.hoverCount !== e) { | |
| return | |
| } | |
| if (!this.needShowBox) { | |
| return | |
| } | |
| if (!this.inited) { | |
| this.createBoxElements() | |
| } | |
| this.desc.update(h); | |
| b = this.getEl(); | |
| c = this.desc.getTextWidth() + 12; | |
| d[0] = f.getX() + (f.getWidth() / 2) - (c / 2); | |
| d[1] = f.getY() - this.defaultHeight - 7; | |
| g = c / 2 - a; | |
| this.background.setWidth(c); | |
| this.backgroundMl.setWidth(6.25 + g); | |
| this.backgroundMc.setWidth(a); | |
| this.backgroundMr.setWidth(c - 6.25 - a - g); | |
| this.arrow.setLeft(g); | |
| b.setLeftTop(d[0], d[1]); | |
| b.setOpacity(1); | |
| this.show(); | |
| this.hoverCount = 0 | |
| }, | |
| hideBox: function(a) { | |
| if (!this.isEnabled()) { | |
| return | |
| } | |
| this.needShowBox = false; | |
| (function() { | |
| if (this.needShowBox) { | |
| return | |
| } | |
| this.doHideBox(a) | |
| } | |
| ).defer((a === true) ? 0 : 300, this) | |
| }, | |
| doHideBox: function(b) { | |
| var c; | |
| var a = function() { | |
| if (this.needShowBox) { | |
| return | |
| } | |
| this.hide() | |
| }; | |
| this.hoverCount = 0; | |
| if (b === true) { | |
| a.call(this); | |
| return | |
| } | |
| c = this.getEl(); | |
| c.shift({ | |
| opacity: 0, | |
| duration: 0.2, | |
| scope: this, | |
| callback: a | |
| }) | |
| }, | |
| isEnabled: function() { | |
| return true | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation"); | |
| Ext.define("SYNO.SDS.DownloadStation.TabButton", { | |
| extend: "Ext.Button", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| if (!SYNO.SDS.DownloadStation.boxtip) { | |
| SYNO.SDS.DownloadStation.boxtip = new SYNO.SDS.DownloadStation.BoxTip() | |
| } | |
| this.callParent([a]) | |
| }, | |
| initButtonEl: function() { | |
| SYNO.SDS.DownloadStation.TabButton.superclass.initButtonEl.apply(this, arguments); | |
| this.mon(this.el, "mouseover", this.onMouseOverHandler, this); | |
| this.mon(this.el, "mouseout", this.onMouseOutHandler, this) | |
| }, | |
| onMouseOverHandler: function(a) { | |
| if (SYNO.SDS.DownloadStation.boxtip.isEnabled()) { | |
| this.setTooltip("") | |
| } | |
| SYNO.SDS.DownloadStation.boxtip.showBox(this.el, this.tooltip) | |
| }, | |
| onMouseOutHandler: function(a) { | |
| SYNO.SDS.DownloadStation.boxtip.hideBox() | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation"); | |
| Ext.define("SYNO.SDS.DownloadStation.BasicActionGroup", { | |
| extend: Ext.isDefined(SYNO.ux.Utils.ActionGroup) ? "SYNO.ux.Utils.ActionGroup" : "SYNO.SDS.Utils.ActionGroup" | |
| }); | |
| Ext.define("SYNO.SDS.DownloadStation.ActionGroup", { | |
| extend: "SYNO.SDS.DownloadStation.BasicActionGroup", | |
| setEnableBtns: function(c, b) { | |
| if (!c || (!Ext.isArray(c) && !Ext.isString(c))) { | |
| return | |
| } | |
| var a = Ext.isArray(c) ? c : [c]; | |
| Ext.each(a, function(d) { | |
| this[b ? "enable" : "disable"](d) | |
| }, this) | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation"); | |
| Ext.define("SYNO.SDS.DownloadStation.GridView", { | |
| extend: "SYNO.ux.FleXcroll.grid.GridView", | |
| updateScroller: function(a) { | |
| var b = this | |
| , f = b.scroller.dom; | |
| if (!b.autoFlexcroll) { | |
| return | |
| } | |
| b.updateScrollbar(f, a); | |
| var g = "0px"; | |
| try { | |
| if (f.fleXdata.scroller[0]) { | |
| g = "8px" | |
| } | |
| } catch (d) { | |
| SYNO.Debug("Fail to find fleXdata ") | |
| } | |
| var h = f.getElementsByClassName("x-grid3-body")[0]; | |
| if (h.style.marginBottom !== g) { | |
| h.style.marginBottom = g; | |
| b.updateScrollbar(f, a) | |
| } | |
| }, | |
| afterRenderUI: function() { | |
| var a = this; | |
| a.callParent(arguments); | |
| if (!a.autoFlexcroll) { | |
| return | |
| } | |
| a.on("flexcroll", a.syncScroll, a, { | |
| buffer: 100 | |
| }) | |
| }, | |
| onColumnWidthUpdated: function(c, a, b) { | |
| var d = this; | |
| d.callParent(arguments); | |
| d.updateScroller() | |
| }, | |
| onColumnHiddenUpdated: function(b, d, a) { | |
| var c = this; | |
| c.callParent(arguments); | |
| c.updateScroller() | |
| } | |
| }); | |
| Ext.define("SYNO.SDS.DownloadStation.RightPanel", { | |
| extend: "SYNO.ux.Panel", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| this.owner = a.owner; | |
| this.callParent(arguments); | |
| var b = { | |
| uicomponents: this.uicomponents, | |
| owner: this | |
| }; | |
| this.panel = this.createPanel(b); | |
| this.actionGroup = this.createActionGroup(); | |
| var c = this.panel.getTopToolbar(); | |
| if (typeof c !== "undefined") { | |
| c.mon(c, "afterlayout", function(d) { | |
| d.items.each(function(e) { | |
| if (e.ctCls && e.getEl() && e.getEl().parent("td")) { | |
| e.getEl().parent("td").addClass(e.ctCls) | |
| } | |
| }) | |
| }) | |
| } | |
| this.toolbar = c | |
| }, | |
| getPanel: function() { | |
| return this.panel | |
| }, | |
| createPanel: function(b) { | |
| var a = new Ext.Panel({ | |
| layout: "border", | |
| module: this, | |
| border: false, | |
| header: false, | |
| tbar: this.fillToolbarConfig({}), | |
| items: [this.upperPanel = this.createUpperPanel({ | |
| minHeight: 90, | |
| uicomponents: this.uicomponents, | |
| region: "center", | |
| module: this, | |
| border: false, | |
| owner: this | |
| }), this.lowerPanel = this.createLowerPanel({ | |
| uicomponents: this.uicomponents, | |
| id: this.lowerPanelId = Ext.id(), | |
| split: true, | |
| height: 250, | |
| floatable: false, | |
| collapsible: true, | |
| cmargins: "0 0 0 0", | |
| animCollapse: false, | |
| border: false, | |
| region: "south", | |
| module: this, | |
| owner: this | |
| })], | |
| listeners: { | |
| scope: this, | |
| resize: function(d, i, f, e, h) { | |
| if (this.lowerPanel && this.lowerPanel.isVisible()) { | |
| var c = this.lowerPanel.getHeight(); | |
| var g = c < (f - 100) ? c : (f - 100); | |
| this.lowerPanel.setHeight(g); | |
| d.removeClass("syno-dl-collapse-animate") | |
| } | |
| } | |
| } | |
| }); | |
| this.upperPanel.addClass("syno-dl-rightpanel-upper"); | |
| this.lowerPanel.addClass("syno-dl-rightpanel-lower"); | |
| this.lowerPanel.mon(this.lowerPanel, "beforecollapse", this.onLowerPanelToggle, this); | |
| return a | |
| }, | |
| onLowerPanelToggle: function(d) { | |
| var a = d.ownerCt; | |
| var e; | |
| if (!d.bodyCollapsed) { | |
| d.oriHeight = d.getHeight() - 9 | |
| } | |
| if (this.upperPanel && this.upperPanel.el) { | |
| e = this.upperPanel.el.child(".hscrollerbar") | |
| } | |
| d.bodyCollapsed = d.bodyCollapsed ? false : true; | |
| var c = d.oriHeight < (a.getHeight() - 100) ? d.oriHeight : (a.getHeight() - 100); | |
| d.setHeight(d.bodyCollapsed ? 25 : c); | |
| a[d.bodyCollapsed ? "addClass" : "removeClass"]("x-body-collapsed"); | |
| a.addClass("syno-dl-collapse-animate"); | |
| a.removeClass.defer(2000, a, ["syno-dl-collapse-animate"]); | |
| a.doLayout(); | |
| if (e) { | |
| e.setDisplayed(false) | |
| } | |
| this.upperPanel.view.layout.defer(300, this.upperPanel.view); | |
| if (e) { | |
| e.setDisplayed.defer(301, e, [true]) | |
| } | |
| var b = d.ownerCt.layout.south.getSplitBar(); | |
| b.dd[d.bodyCollapsed ? "lock" : "unlock"](); | |
| return false | |
| }, | |
| createUpperPanel: function(a) { | |
| return new SYNO.ux.Panel(a) | |
| }, | |
| createLowerPanel: function(a) { | |
| return new SYNO.ux.Panel(a) | |
| }, | |
| onActivate: function() {}, | |
| onDeactivate: function() {}, | |
| onTabActivate: function() {}, | |
| onTabDeactivate: function() {}, | |
| fillToolbarConfig: function(a) { | |
| return Ext.apply({ | |
| xtype: "toolbar", | |
| cls: "syno-dl-toolbar", | |
| items: [] | |
| }, a) | |
| }, | |
| createActionGroup: function(a, c) { | |
| var b = Ext.isDefined(a) ? a : []; | |
| return (true !== c) ? new SYNO.SDS.DownloadStation.BasicActionGroup(b) : new SYNO.SDS.DownloadStation.ActionGroup(b) | |
| }, | |
| setToolBar: function() { | |
| var a = this.toolbar; | |
| a.items.each(function(b) { | |
| b.hide() | |
| }); | |
| a.removeAll(false); | |
| a.add(this.actionGroup.getArray()); | |
| a.items.each(function(b) { | |
| if (Ext.isEmpty(b.initialConfig.hidden) || (true !== b.initialConfig.hidden)) { | |
| b.show() | |
| } | |
| }); | |
| a.doLayout() | |
| }, | |
| activate: function() { | |
| this.getPanel().items.each(function(a) { | |
| a.fireEvent("activate", a) | |
| }, this); | |
| this.setToolBar(); | |
| this.onActivate() | |
| }, | |
| deactivate: function() { | |
| this.getPanel().items.each(function(a) { | |
| a.fireEvent("deactivate", a) | |
| }, this); | |
| this.onDeactivate() | |
| }, | |
| setStatusBusy: function() { | |
| var a = this.getPanel().getEl(); | |
| if (Ext.isObject(a) && !a.isMasked()) { | |
| a.mask(_T("common", "loading"), "x-mask-loading") | |
| } | |
| }, | |
| clearStatusBusy: function() { | |
| var a = this.getPanel().getEl(); | |
| if (Ext.isObject(a)) { | |
| a.unmask() | |
| } | |
| }, | |
| getMsgBox: function() { | |
| return SYNO.SDS.DownloadStation.Window.getMsgBox() | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation"); | |
| Ext.define("SYNO.SDS.DownloadStation.PollingTask", { | |
| extend: "Ext.Component", | |
| constructor: function(a) { | |
| this.callParent(arguments); | |
| this.tasks = []; | |
| this.initPollingTask(a); | |
| this.addRunnerListener("beforestart", this.onBeforeStart); | |
| this.taskRunner.start = function(c, b) { | |
| if (this.isDestroyed) { | |
| return | |
| } | |
| if (!c.running) { | |
| if (this.fireEvent("beforestart", c) === false) { | |
| return c | |
| } | |
| SYNO.SDS.TaskMgr.start(c, b) | |
| } | |
| c.running = true; | |
| return c | |
| } | |
| }, | |
| initPollingTask: function(a) { | |
| if (a && a.tasks) { | |
| a.tasks.forEach(function(b) { | |
| this.add(b) | |
| }, this) | |
| } | |
| }, | |
| addRunnerListener: function(c, a) { | |
| var b = this.getTaskRunner(); | |
| this.mon(b, c, a, this) | |
| }, | |
| removeRunnerListener: function(c, a) { | |
| var b = this.getTaskRunner(); | |
| this.mun(b, c, a, this) | |
| }, | |
| add: function(b) { | |
| if (Ext.isArray(b)) { | |
| var a = []; | |
| Ext.each(b, function(d) { | |
| a.push(this.add(d)) | |
| }, this); | |
| return a | |
| } | |
| return this.onAdd(b) | |
| }, | |
| onAdd: function(b) { | |
| if (b.beforestart && Ext.isFunction(b.beforestart)) { | |
| b.beforestart = Ext.createDelegate(b.beforestart, b.scope) | |
| } | |
| var a; | |
| if (b.url) { | |
| a = this.addAjaxTask(b) | |
| } else { | |
| if (b.api || b.webapi) { | |
| a = this.addWebAPITask(b) | |
| } else { | |
| a = this.addTask(b) | |
| } | |
| } | |
| a.id = b.id || Ext.id(); | |
| a.taskCfg = b; | |
| this.tasks.push(a) | |
| }, | |
| startAll: function(a) { | |
| if (typeof a === "undefined") { | |
| a = true | |
| } | |
| this.stopAll(); | |
| this.tasks.forEach(function(b) { | |
| b.start(a || false) | |
| }) | |
| }, | |
| stopAll: function() { | |
| this.tasks.forEach(function(a) { | |
| a.stop() | |
| }) | |
| }, | |
| removeAll: function() { | |
| this.stopAll(); | |
| for (var b = 0, c = this.tasks.length; b < c; b++) { | |
| var a = this.tasks.pop(); | |
| if (a && a.remove) { | |
| a.remove(); | |
| a = null | |
| } | |
| } | |
| this.removeRunnerListener("beforestart", this.onBeforeStart) | |
| }, | |
| removeById: function(b) { | |
| if (Ext.isArray(b)) { | |
| var a = []; | |
| Ext.each(b, function(d) { | |
| a.push(this.removeById(d)) | |
| }, this); | |
| return a | |
| } | |
| return this.onRemoveById(b) | |
| }, | |
| onRemoveById: function(b) { | |
| var a = this.getTaskById(b); | |
| if (a) { | |
| a.stop(); | |
| a.remove(); | |
| this.tasks.remove(a); | |
| a = null | |
| } | |
| }, | |
| getTaskById: function(a) { | |
| return this.tasks.find(function(c, b, d) { | |
| return a == c.id | |
| }) | |
| }, | |
| stopById: function(b) { | |
| if (Ext.isArray(b)) { | |
| var a = []; | |
| Ext.each(b, function(d) { | |
| a.push(this.stopById(d)) | |
| }, this); | |
| return a | |
| } | |
| return this.onStopById(b) | |
| }, | |
| onStopById: function(b) { | |
| var a = this.getTaskById(b); | |
| if (a) { | |
| a.stop() | |
| } | |
| }, | |
| startById: function(c, b) { | |
| if (Ext.isArray(c)) { | |
| var a = []; | |
| Ext.each(c, function(d) { | |
| a.push(this.startById(d, b)) | |
| }, this); | |
| return a | |
| } | |
| return this.onStartById(c, b) | |
| }, | |
| onStartById: function(c, a) { | |
| if (typeof a === "undefined") { | |
| a = true | |
| } | |
| var b = this.getTaskById(c); | |
| if (b) { | |
| b.stop(); | |
| b.start(a || false) | |
| } | |
| }, | |
| onBeforeStart: function(a) { | |
| if (a.taskCfg.beforestart) { | |
| return a.taskCfg.beforestart(a) | |
| } | |
| return true | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.Settings"); | |
| Ext.define("SYNO.SDS.DownloadStation.Settings.FormPanel", { | |
| extend: "SYNO.SDS.Utils.FormPanel", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| this.ownerCt = a.owner; | |
| this.addEvents("onSetValues"); | |
| var b = Ext.applyIf(this.fillConfig(a), { | |
| buttons: SYNO.SDS.DownloadStation.Utils.composeButtonCfg({ | |
| xtype: "syno_button", | |
| btnStyle: "blue", | |
| text: _T("common", "apply"), | |
| scope: this, | |
| handler: function() { | |
| this.settingsWin.actionFlag = "APPLY"; | |
| this.settingsWin.close() | |
| }, | |
| disabled: _S("demo_mode"), | |
| tooltip: _S("demo_mode") ? _JSLIBSTR("uicommon", "error_demo") : undefined | |
| }, { | |
| xtype: "syno_button", | |
| text: _T("common", "cancel"), | |
| scope: this, | |
| handler: function() { | |
| this.settingsWin.actionFlag = "CANCEL"; | |
| this.settingsWin.close() | |
| } | |
| }) | |
| }); | |
| this.callParent([b]); | |
| this.mon(this, "afterlayout", this.enableCheckGroup, this, { | |
| single: true | |
| }); | |
| this.defineBehaviors() | |
| }, | |
| fillConfig: function(a) { | |
| return a | |
| }, | |
| activate: function() { | |
| this.loadForm() | |
| }, | |
| loadForm: function() { | |
| if (this.form && this.form.isDirty()) { | |
| return | |
| } | |
| var a = this.gData.get(this.getKeyName()); | |
| if (a) { | |
| this.form.setValues(a) | |
| } else { | |
| this.sendWebAPIGetRequest() | |
| } | |
| }, | |
| deactivate: function() { | |
| return true | |
| }, | |
| getPanel: function() { | |
| return this | |
| }, | |
| getAbsoluteURL: function(a) { | |
| return String.format("{0}/{1}", this.jsConfig.jsBaseURL, a) | |
| }, | |
| sendAjaxRequest: function(a) { | |
| this.appWin.addAjaxTask(Ext.apply({ | |
| single: true | |
| }, a)).start(true) | |
| }, | |
| isDirty: function() { | |
| return this.form.isDirty() | |
| }, | |
| isValid: function() { | |
| return this.form.isValid() | |
| }, | |
| sendWebAPIGetRequest: function() { | |
| var a = this.getWebAPIGetData(); | |
| this.setStatusBusy({ | |
| text: _T("common", "loading") | |
| }); | |
| this.sendWebAPI({ | |
| compound: { | |
| stopwhenerror: false, | |
| params: a | |
| }, | |
| callback: function(b, f, e, d) { | |
| if (undefined !== f.has_fail && false === f.has_fail) { | |
| this.postReturnData(f.result) | |
| } else { | |
| var c = _DT("common", "error_system"); | |
| if (undefined !== f.statusText && "transaction aborted" === f.statusText) { | |
| c = _DT("server", "error_emule_not_running") | |
| } else { | |
| if (undefined !== f.has_fail && true === f.has_fail) { | |
| Ext.each(f.result, function(g, h, i) { | |
| if (!g.success) { | |
| SYNO.Debug("Failed on " + g.api + " " + g.method); | |
| c = SYNO.SDS.DownloadStation.Utils.getErrorString(g.error.code); | |
| return | |
| } | |
| }, this) | |
| } | |
| } | |
| this.settingsWin.getMsgBox().alert("", c) | |
| } | |
| this.clearStatusBusy() | |
| }, | |
| scope: this | |
| }); | |
| return | |
| }, | |
| getWebAPIGetData: function() { | |
| var a = [{ | |
| api: this.getWebAPIName(), | |
| method: "get", | |
| version: this.getWebAPIVersion() | |
| }]; | |
| return a | |
| }, | |
| getWebAPISetData: function() { | |
| var a = { | |
| api: this.getWebAPIName(), | |
| method: "set", | |
| params: this.getWebAPIParam(), | |
| version: this.getWebAPIVersion() | |
| }; | |
| return (a.params ? a : undefined) | |
| }, | |
| getWebAPIVersion: function() { | |
| return 1 | |
| }, | |
| postReturnData: function(a) { | |
| this.gData.set(this.getKeyName(), a[0].data); | |
| this.form.setValues(a[0].data) | |
| }, | |
| getWebAPIParam: function() { | |
| var a = this.getFields(); | |
| var d = {}; | |
| var c = true; | |
| for (var b = 0; b < a.length; b++) { | |
| if (this.form.findField(a[b]).isDirty()) { | |
| d[a[b]] = this.form.findField(a[b]).getValue(); | |
| c = false | |
| } | |
| } | |
| return c ? undefined : d | |
| }, | |
| onSettingsApply: function() { | |
| return true | |
| }, | |
| getHelpParam: Ext.emptyFn, | |
| enableCheckGroup: Ext.emptyFn, | |
| defineBehaviors: Ext.emptyFn, | |
| getKeyName: Ext.emptyFn, | |
| getFields: Ext.emptyFn, | |
| getWebAPIName: Ext.emptyFn | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.Settings"); | |
| Ext.define("SYNO.SDS.DownloadStation.Settings.GlobalGen", { | |
| extend: "SYNO.SDS.DownloadStation.Settings.FormPanel", | |
| fillConfig: function(a) { | |
| var c = new Ext.data.SimpleStore({ | |
| fields: ["mount_point", "display", "size_free"], | |
| data: [] | |
| }); | |
| var b = { | |
| frame: false, | |
| border: false, | |
| trackResetOnLoad: true, | |
| blPython: true, | |
| items: [{ | |
| xtype: "syno_fieldset", | |
| title: _DT("common", "displayname"), | |
| items: [{ | |
| xtype: "syno_combobox", | |
| name: "download_volume", | |
| fieldLabel: _T("download", "temporary_location"), | |
| store: c, | |
| displayField: "display", | |
| width: 350, | |
| hidden: true, | |
| valueField: "mount_point" | |
| }, { | |
| xtype: "syno_textfield", | |
| name: "download_volume_text", | |
| fieldLabel: _T("download", "temporary_location"), | |
| width: 350 | |
| }, { | |
| xtype: "syno_displayfield", | |
| name: "download_volume_warning", | |
| value: "", | |
| hidden: true, | |
| cls: "message_warning" | |
| }] | |
| }, { | |
| xtype: "syno_fieldset", | |
| title: _DT("tree", "node_emule"), | |
| items: [{ | |
| xtype: "syno_checkbox", | |
| name: "enable_emule", | |
| boxLabel: _T("download", "title_enable_emule"), | |
| disabled: _S("demo_mode") | |
| }] | |
| }] | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| enableCheckGroup: Ext.emptyFn, | |
| updateVolumeItems: function(c) { | |
| var b = this.form.findField("download_volume").store; | |
| var d = 0; | |
| var a = []; | |
| Ext.each(c, function(g, e, f) { | |
| if (!d) { | |
| d = g.mount_point | |
| } | |
| a.push([g.mount_point, g.display, g.size_free]) | |
| }, this); | |
| b.loadData(a) | |
| }, | |
| isValid: function() { | |
| return (this.callParent(arguments) && this.verifyVolumeSpaceEnough()) | |
| }, | |
| verifyVolumeSpaceEnough: function() { | |
| var c, a; | |
| var d = this.getForm().findField("download_volume"); | |
| var b = 1073741824; | |
| if (d.isDirty()) { | |
| a = d.getStore(); | |
| c = a.findExact("mount_point", d.getValue()); | |
| if (b >= parseInt(a.getAt(c).get("size_free"), 10)) { | |
| this.appWin.getMsgBox().alert(_T("tree", "leaf_download"), String.format(_T("download", "volume_no_enough_free_space"), "1 " + _T("common", "size_gb"))); | |
| return false | |
| } | |
| } | |
| return true | |
| }, | |
| confirmIfVolumeChange: function(c) { | |
| var b = this.getForm().findField("download_volume"); | |
| if (b.isDirty() && this.originalHasVolume) { | |
| this.settingsWin.moduleList.selectModule("SYNO.SDS.DownloadStation.Settings.GlobalGen"); | |
| var a = String.format(_T("volume", "volume_change_this_warning"), "Download"); | |
| this.appWin.getMsgBox().confirm(_T("tree", "leaf_download"), a, function(d, e) { | |
| if (d == "yes") { | |
| c() | |
| } | |
| }, this); | |
| return | |
| } | |
| c() | |
| }, | |
| getWebAPIName: function() { | |
| return "SYNO.DownloadStation2.Settings.Global" | |
| }, | |
| getWebAPIVersion: function() { | |
| return 2 | |
| }, | |
| getKeyName: function() { | |
| return "global" | |
| }, | |
| postReturnData: function(a) { | |
| var b = a[0].data; | |
| this.originalHasVolume = (b.download_volume) ? true : false; | |
| if (!b.volume_list || 1 == b.volume_list.length) { | |
| b.download_volume_text = b.volume_list ? b.volume_list[0].display : ""; | |
| this.form.findField("download_volume").setVisible(false); | |
| this.form.findField("download_volume_text").setVisible(true); | |
| this.form.findField("download_volume_text").setDisabled(true) | |
| } else { | |
| this.form.findField("download_volume").setVisible(true); | |
| this.form.findField("download_volume_text").setVisible(false) | |
| } | |
| this.updateVolumeItems(b.volume_list); | |
| delete b.volume_list; | |
| delete b.volume_count; | |
| this.gData.set(this.getKeyName(), b); | |
| this.form.setValues(b) | |
| }, | |
| getFields: function() { | |
| var a = ["download_volume", "enable_emule"]; | |
| return a | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.Settings"); | |
| Ext.define("SYNO.SDS.DownloadStation.Settings.GlobalUnzip", { | |
| extend: "SYNO.SDS.DownloadStation.Settings.FormPanel", | |
| fillConfig: function(a) { | |
| this.select_btn = new SYNO.ux.Button({ | |
| xtype: "button", | |
| name: "unzip_btn", | |
| text: _T("common", "choose"), | |
| disabled: _S("demo_mode"), | |
| scope: this, | |
| style: "margin-left: 50px;", | |
| handler: function() { | |
| this.utils.chooseDestHandler({ | |
| owner: this.owner, | |
| title: _DT("settings", "unzip_extract_to"), | |
| destinationField: this.form.findField("unzip_folder") | |
| }) | |
| } | |
| }); | |
| this.pwPoolbtn = new SYNO.ux.Button({ | |
| xtype: "button", | |
| name: "pw_pool_btn", | |
| text: _DT("settings", "unzip_pwpool_title"), | |
| scope: this, | |
| handler: this.showPWPoolDialog | |
| }); | |
| this.current_folder_radio = new SYNO.ux.Radio({ | |
| indent: 1, | |
| boxLabel: _DT("settings", "unzip_current_folder"), | |
| name: "unzip_location", | |
| itemId: "current_folder", | |
| inputValue: "current_folder", | |
| checked: true | |
| }); | |
| this.select_folder_radio = new SYNO.ux.Radio({ | |
| indent: 1, | |
| boxLabel: _DT("settings", "unzip_extract_to"), | |
| name: "unzip_location", | |
| itemId: "select_folder", | |
| inputValue: "select_folder", | |
| listeners: { | |
| check: { | |
| fn: function(f, g) { | |
| if (this.getForm().findField("unzip_folder")) { | |
| this.getForm().findField("unzip_folder").setDisabled(!g); | |
| this.select_btn.setDisabled(!g || _S("demo_mode")) | |
| } | |
| }, | |
| scope: this | |
| } | |
| } | |
| }); | |
| var d = { | |
| xtype: "syno_fieldset", | |
| title: _DT("settings", "unzip_service_setting"), | |
| items: [{ | |
| xtype: "syno_checkbox", | |
| boxLabel: SYNO.SDS.isNSM ? _DT("settings", "unzip_allow_user_northstarplus") : _DT("settings", "unzip_allow_user"), | |
| name: "enable_unzip_service" | |
| }] | |
| }; | |
| var e = { | |
| xtype: "syno_fieldset", | |
| itemId: "personal_fieldset", | |
| title: _DT("common", "unzip_title"), | |
| items: [{ | |
| xtype: "syno_checkbox", | |
| boxLabel: _DT("settings", "unzip_enable"), | |
| name: "enable_unzip", | |
| listeners: { | |
| check: { | |
| fn: this.enableUnzipFields, | |
| scope: this | |
| } | |
| } | |
| }, this.current_folder_radio, { | |
| xtype: "syno_compositefield", | |
| itemId: "extract_selectfield", | |
| hideLabel: true, | |
| items: [this.select_folder_radio, { | |
| xtype: "syno_textfield", | |
| name: "unzip_folder", | |
| readOnly: true, | |
| allowBlank: false, | |
| width: 160, | |
| style: "margin-left: 50px;" | |
| }, this.select_btn] | |
| }, { | |
| xtype: "syno_checkbox", | |
| boxLabel: _DT("settings", "unzip_create_subfolder"), | |
| name: "create_subfolder" | |
| }, { | |
| xtype: "syno_checkbox", | |
| boxLabel: _DT("settings", "unzip_overwrite"), | |
| name: "unzip_overwrite" | |
| }, { | |
| xtype: "syno_checkbox", | |
| boxLabel: _DT("settings", "unzip_delete_archive"), | |
| name: "delete_archive" | |
| }, { | |
| xtype: "syno_displayfield", | |
| name: "password_desc", | |
| value: _DT("settings", "unzip_pwpool_title") + " - " + _DT("settings", "unzip_pwpool_short_desc") | |
| }, this.pwPoolbtn, { | |
| xtype: "hidden", | |
| name: "passwordPool" | |
| }] | |
| }; | |
| var b; | |
| if (this._S("is_admin")) { | |
| b = [d, e] | |
| } else { | |
| b = [e] | |
| } | |
| var c = { | |
| autoScroll: true, | |
| trackResetOnLoad: true, | |
| labelWidth: 200, | |
| border: false, | |
| hideMode: "offsets", | |
| items: b, | |
| listeners: {} | |
| }; | |
| Ext.apply(c, a); | |
| return SYNO.LayoutConfig.fill(c) | |
| }, | |
| defineBehaviors: function() { | |
| this.enable_service = this.getForm().findField("enable_unzip_service"); | |
| this.enable = this.getForm().findField("enable_unzip"); | |
| this.unzipFolder = this.getForm().findField("unzip_folder"); | |
| this.subfolder = this.getForm().findField("create_subfolder"); | |
| this.overwrite = this.getForm().findField("unzip_overwrite"); | |
| this.deleteArchive = this.getForm().findField("delete_archive"); | |
| this.pwDesc = this.getForm().findField("password_desc") | |
| }, | |
| enableUnzipFields: function(c, b) { | |
| this.current_folder_radio.setDisabled(!b); | |
| this.select_folder_radio.setDisabled(!b); | |
| var a = this.select_folder_radio.getValue(); | |
| if (this.getForm().findField("unzip_folder")) { | |
| this.getForm().findField("unzip_folder").setDisabled(!b || !a) | |
| } | |
| this.select_btn.setDisabled(!b || !a || _S("demo_mode")); | |
| this.subfolder.setDisabled(!b); | |
| this.overwrite.setDisabled(!b); | |
| this.deleteArchive.setDisabled(!b); | |
| this.pwPoolbtn.setDisabled(!b); | |
| this.pwDesc.setDisabled(!b) | |
| }, | |
| showPWPoolDialog: function() { | |
| var a = new SYNO.SDS.DownloadStation.Settings.PasswordPoolDialog({ | |
| uicomponents: this.uicomponents, | |
| owner: this.settingsWin, | |
| module: this, | |
| MainDownloadWin: this.appWin, | |
| passwordPool: this.getForm().findField("passwordPool").getValue() | |
| }); | |
| a.open() | |
| }, | |
| loadForm: function() { | |
| if (this.form && this.form.isDirty()) { | |
| return | |
| } | |
| if (this._S("is_admin")) { | |
| var b = this.gData.get(this.getKeyName()); | |
| if (b) { | |
| this.form.setValues(b) | |
| } else { | |
| this.sendWebAPIGetRequest() | |
| } | |
| } | |
| if (!SYNO.SDS.DownloadStation.blUnzip && !_S("is_admin")) { | |
| this.enableUnzipFields(null, false); | |
| return | |
| } | |
| var a = this.appWin.appInstance.getUserSettings("unzip_settings"); | |
| if (!a) { | |
| this.enableUnzipFields(null, false); | |
| return | |
| } | |
| this.getForm().loadRecord({ | |
| data: a | |
| }); | |
| if (!this.enable.getValue()) { | |
| this.enableUnzipFields(null, false) | |
| } | |
| }, | |
| onSettingsApply: function() { | |
| var b = this.getForm(); | |
| var a = b.getValues(); | |
| if (!a.enable_unzip) { | |
| this.enableUnzipFields(null, true); | |
| a = b.getValues(); | |
| this.enableUnzipFields(null, false); | |
| a.enable_unzip = "off" | |
| } | |
| if (b.findField("unzip_folder")) { | |
| var c = b.findField("unzip_folder").getValue(); | |
| a.unzip_folder = c | |
| } | |
| this.appWin.appInstance.setUserSettings("unzip_settings", a); | |
| return true | |
| }, | |
| userSettingIsDirty: function() { | |
| if (!this._S("is_admin")) { | |
| return this.getForm().isDirty() | |
| } | |
| this.enable_service.disable(); | |
| var a = this.getForm().isDirty(); | |
| this.enable_service.enable(); | |
| return a | |
| }, | |
| getWebAPIName: function() { | |
| return "SYNO.DownloadStation2.Settings.Global" | |
| }, | |
| getWebAPIVersion: function() { | |
| return 2 | |
| }, | |
| getKeyName: function() { | |
| return "unzip" | |
| }, | |
| postReturnData: function(a) { | |
| var b = {}; | |
| b.enable_unzip_service = a[0].data.enable_unzip_service; | |
| this.gData.set(this.getKeyName(), b); | |
| this.form.setValues(b) | |
| }, | |
| getFields: function() { | |
| return (this._S("is_admin") ? ["enable_unzip_service"] : []) | |
| } | |
| }); | |
| Ext.define("SYNO.SDS.DownloadStation.Settings.PasswordPoolDialog", { | |
| extend: "SYNO.SDS.ModalWindow", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| Ext.apply(this, a || {}); | |
| var b = this.fillConfig(); | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| var b = { | |
| owner: this.owner, | |
| cls: "syno-dl-win", | |
| width: 470, | |
| height: 424, | |
| minWidth: 400, | |
| minHeight: 250, | |
| constrainHeader: true, | |
| itemId: "passwordPoolDialog", | |
| title: _DT("settings", "unzip_pwpool_title"), | |
| layout: "fit", | |
| items: [this.genPanel()], | |
| buttons: SYNO.SDS.DownloadStation.Utils.composeButtonCfg({ | |
| text: _T("common", "apply"), | |
| scope: this, | |
| btnStyle: "blue", | |
| handler: this.onSave | |
| }, { | |
| text: _T("common", "cancel"), | |
| scope: this, | |
| handler: this.close | |
| }) | |
| }; | |
| return b | |
| }, | |
| genPanel: function() { | |
| var a = { | |
| padding: 0, | |
| itemId: "panel", | |
| border: false, | |
| items: [{ | |
| xtype: "syno_displayfield", | |
| value: _DT("settings", "unzip_pwpool_desc"), | |
| style: "height: 10;" | |
| }, { | |
| xtype: "syno_textarea", | |
| hideLabel: true, | |
| itemId: "passwordPool", | |
| autoFlexcroll: true, | |
| value: this.getDisplay(), | |
| width: 400, | |
| height: 130, | |
| anchor: "99% 80%", | |
| hidden: false, | |
| cls: "selectabletext allowDefCtxMenu" | |
| }] | |
| }; | |
| return new SYNO.ux.FormPanel(a) | |
| }, | |
| getDisplay: function() { | |
| var c; | |
| var a = this.module.getForm().findField("passwordPool").getValue(); | |
| if (a && "" !== a) { | |
| c = Ext.util.JSON.decode(a) | |
| } else { | |
| c = [] | |
| } | |
| var b = c.join("\n"); | |
| return b | |
| }, | |
| onSave: function() { | |
| var b = this.get("panel").get("passwordPool"); | |
| if (b.isDirty()) { | |
| var a = this.handlePWPoool(b.getValue()); | |
| if (!a) { | |
| return | |
| } | |
| this.module.getForm().findField("passwordPool").setValue(a) | |
| } | |
| this.close() | |
| }, | |
| handlePWPoool: function(e) { | |
| var d = e.replace(/\r/g, ""); | |
| var a = d.split("\n"); | |
| var c; | |
| if (a.length > 30) { | |
| this.owner.getMsgBox().alert(_DT("settings", "unzip_pwpool_title"), _DT("error", "unzip_pw_limit")); | |
| return false | |
| } | |
| var f = []; | |
| for (var b = 0; b < a.length; b++) { | |
| c = a[b]; | |
| if (c.length >= SYNO.SDS.DownloadStation.PW_MAX_LEN) { | |
| this.owner.getMsgBox().alert(_DT("settings", "unzip_pwpool_title"), _DT("error", "unzip_pw_length")); | |
| return false | |
| } | |
| if (c !== "" && f.indexOf(c) == -1) { | |
| f.push(c) | |
| } | |
| } | |
| d = Ext.util.JSON.encode(f); | |
| return d | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.Settings"); | |
| Ext.define("SYNO.SDS.DownloadStation.Settings.GlobalNotification", { | |
| extend: "SYNO.ux.Panel", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| var b = this.fillConfig(a); | |
| this.callParent([b]); | |
| this.addClass("syno-ux-formpanel") | |
| }, | |
| fillConfig: function(a) { | |
| this.notificationPanel = new SYNO.SDS.PersonalNotification.TabPanel({ | |
| appWin: a.uicomponents.appWin, | |
| pkgName: "DownloadStation", | |
| mobileDisabled: true, | |
| buttons: false | |
| }); | |
| var b = { | |
| layout: "fit", | |
| fbar: SYNO.SDS.DownloadStation.Utils.composeButtonCfg({ | |
| xtype: "syno_button", | |
| btnStyle: "blue", | |
| text: _T("common", "apply"), | |
| scope: this, | |
| handler: function() { | |
| a.uicomponents.settingsWin.actionFlag = "APPLY"; | |
| a.uicomponents.settingsWin.close() | |
| }, | |
| disabled: _S("demo_mode"), | |
| tooltip: _S("demo_mode") ? _JSLIBSTR("uicommon", "error_demo") : undefined | |
| }, { | |
| xtype: "syno_button", | |
| text: _T("common", "cancel"), | |
| scope: this, | |
| handler: function() { | |
| a.uicomponents.settingsWin.actionFlag = "CANCEL"; | |
| a.uicomponents.settingsWin.close() | |
| } | |
| }), | |
| items: [this.notificationPanel] | |
| }; | |
| Ext.apply(b, a); | |
| return b | |
| }, | |
| getPanel: function() { | |
| return this | |
| }, | |
| isDirty: function() { | |
| var a = this.notificationPanel.items.items; | |
| for (var b = 0; b < a.length; b++) { | |
| if (a[b].isDirty()) { | |
| return true | |
| } | |
| } | |
| return false | |
| }, | |
| isValid: function() { | |
| var a = this.notificationPanel.items.items; | |
| for (var b = 0; b < a.length; b++) { | |
| if (!a[b].isValid()) { | |
| this.notificationPanel.setActiveTab(b); | |
| return false | |
| } | |
| } | |
| return true | |
| }, | |
| getWebAPISetData: function() { | |
| return undefined | |
| }, | |
| onSettingsApply: function() { | |
| Ext.each(this.notificationPanel.items.items, function(b, a) { | |
| if (b.isDirty()) { | |
| b.action("save") | |
| } | |
| }); | |
| return true | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.Settings"); | |
| Ext.define("SYNO.SDS.DownloadStation.Settings.DLMGen", { | |
| extend: "SYNO.SDS.DownloadStation.Settings.FormPanel", | |
| fillConfig: function(a) { | |
| var d; | |
| var e = parseInt(_D("downloadlimit"), 10); | |
| if (e) { | |
| d = this.createDLLimitStore(e) | |
| } else { | |
| d = this.createDLLimitStore(20) | |
| } | |
| var f, c; | |
| if (true === _S("is_admin")) { | |
| f = { | |
| xtype: "syno_fieldset", | |
| title: _DT("service", "service_dl_start_desc"), | |
| items: [{ | |
| xtype: "syno_radio", | |
| boxLabel: _DT("service", "service_dl_now"), | |
| name: "dl_when_type", | |
| itemId: "type_now", | |
| inputValue: "now", | |
| checked: true | |
| }, { | |
| xtype: "syno_radio", | |
| boxLabel: _T("schedule", "schedule_advance"), | |
| name: "dl_when_type", | |
| itemId: "type_schedule", | |
| inputValue: "schedule" | |
| }, { | |
| id: this.btnScheduleId = Ext.id(), | |
| xtype: "syno_button", | |
| text: _T("schedule", "schedule_title"), | |
| handler: this.launchScheduleDialog, | |
| scope: this, | |
| indent: 1 | |
| }, { | |
| xtype: "hidden", | |
| name: "schedule" | |
| }, { | |
| xtype: "hidden", | |
| name: "upload_rate" | |
| }, { | |
| xtype: "hidden", | |
| name: "download_rate" | |
| }] | |
| }; | |
| c = { | |
| xtype: "syno_fieldset", | |
| title: _DT("service", "service_dl_order"), | |
| labelWidth: 250, | |
| synodefaults: { | |
| width: 160 | |
| }, | |
| items: [{ | |
| xtype: "syno_radio", | |
| boxLabel: _DT("service", "service_dl_order_by_request"), | |
| name: "order", | |
| itemId: "request", | |
| inputValue: "request", | |
| checked: true | |
| }, { | |
| xtype: "syno_radio", | |
| boxLabel: _DT("service", "service_dl_order_by_user"), | |
| name: "order", | |
| itemId: "user", | |
| inputValue: "user", | |
| checked: false | |
| }, { | |
| xtype: "syno_combobox", | |
| name: "max_tasks", | |
| fieldLabel: _DT("service", "service_dl_maximal_tasks"), | |
| store: d, | |
| displayField: "value", | |
| valueField: "value", | |
| triggerAction: "all", | |
| selectOnFocus: true, | |
| editable: false | |
| }, { | |
| xtype: "syno_displayfield", | |
| cls: "synodl-warning-error", | |
| value: _DT("service", "service_dl_hint_many_tasks") | |
| }] | |
| } | |
| } | |
| var b = { | |
| autoScroll: true, | |
| trackResetOnLoad: true, | |
| labelWidth: 200, | |
| border: false, | |
| hideMode: "offsets", | |
| items: [f, c] | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| defineBehaviors: function() { | |
| if (true === _S("is_admin")) { | |
| var a; | |
| a = new SYNO.ux.Utils.EnableCheckGroup(this.form,"type_schedule",[this.btnScheduleId]) | |
| } | |
| this.mon(this, "onSetValues", function(b, c) { | |
| this.updateDLLimitStore(c.max_tasks_limit) | |
| }, this) | |
| }, | |
| createDLLimitStore: function(c) { | |
| var a = []; | |
| var d = 1; | |
| while (d <= c) { | |
| a.push([d]); | |
| d++ | |
| } | |
| var b = new Ext.data.SimpleStore({ | |
| id: 0, | |
| fields: ["value"], | |
| data: a | |
| }); | |
| return b | |
| }, | |
| updateDLLimitStore: function(c) { | |
| var a = this.form.findField("max_tasks"); | |
| var b = []; | |
| var d = 1; | |
| while (d <= c) { | |
| b.push([d]); | |
| d++ | |
| } | |
| a.store.loadData(b) | |
| }, | |
| launchScheduleDialog: function() { | |
| var b = this.getForm(); | |
| var a = new SYNO.SDS.DownloadStation.Settings.ScheduleDialog({ | |
| owner: this.owner, | |
| limitBtnStr: _DT("download", "bt_limit_speed"), | |
| limitDescStr: _DT("download", "bt_limit_speed_setting"), | |
| noteDescStr: _DT("download", "bt_limit_speed_note"), | |
| scheduleField: b.findField("schedule"), | |
| altUploadField: b.findField("upload_rate"), | |
| altDownloadField: b.findField("download_rate") | |
| }); | |
| a.show() | |
| }, | |
| getWebAPIName: function() { | |
| return "SYNO.DownloadStation2.Settings.Scheduler" | |
| }, | |
| getKeyName: function() { | |
| return "schedule" | |
| }, | |
| postReturnData: function(a) { | |
| var b; | |
| b = a[0].data; | |
| b.dl_when_type = (b.enable_schedule) ? "schedule" : "now"; | |
| delete b.enable_schedule; | |
| this.gData.set(this.getKeyName(), b); | |
| this.form.setValues(b); | |
| this.fireEvent("onSetValues", this, b) | |
| }, | |
| getWebAPIParam: function() { | |
| var a = this.getFields(); | |
| var c = {}; | |
| for (var b = 0; b < a.length; b++) { | |
| if (this.form.findField(a[b]).isDirty()) { | |
| if ("order" === a[b]) { | |
| c.order = (this.form.findField(a[b]).getValue()) ? "request" : "user" | |
| } else { | |
| if ("dl_when_type" === a[b]) { | |
| c.enable_schedule = !this.form.findField(a[b]).getValue() | |
| } else { | |
| if (("upload_rate" === a[b]) || ("download_rate" === a[b])) { | |
| c[a[b]] = parseInt(this.form.findField(a[b]).getValue(), 10) | |
| } else { | |
| c[a[b]] = this.form.findField(a[b]).getValue() | |
| } | |
| } | |
| } | |
| } | |
| } | |
| return c | |
| }, | |
| getFields: function() { | |
| var a = ["dl_when_type", "download_rate", "upload_rate", "order", "max_tasks", "schedule"]; | |
| return a | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.Settings"); | |
| Ext.define("SYNO.SDS.DownloadStation.Settings.DLMFolder", { | |
| extend: "SYNO.SDS.DownloadStation.Settings.FormPanel", | |
| fillConfig: function(a) { | |
| var b = { | |
| xtype: "syno_fieldset", | |
| title: _DT("settings", "title_default_dest_folder"), | |
| labelWidth: 250, | |
| items: [{ | |
| xtype: "syno_compositefield", | |
| itemId: "destselectfield", | |
| fieldLabel: _DT("download", "download_list_dest_folder"), | |
| defaults: { | |
| hideLabel: true | |
| }, | |
| items: [{ | |
| xtype: "syno_textfield", | |
| name: "default_destination", | |
| readOnly: true, | |
| allowBlank: false, | |
| width: 160 | |
| }, { | |
| xtype: "syno_button", | |
| text: _T("common", "choose"), | |
| disabled: _S("demo_mode"), | |
| scope: this, | |
| handler: function() { | |
| this.utils.chooseDestHandler({ | |
| owner: this.owner, | |
| destinationField: this.form.findField("default_destination") | |
| }) | |
| } | |
| }] | |
| }] | |
| }; | |
| var d = { | |
| xtype: "syno_fieldset", | |
| title: _DT("settings", "watch_torrentnzb_title"), | |
| labelWidth: 250, | |
| itemId: "watchfieldset", | |
| hideMode: "visibility", | |
| items: [{ | |
| xtype: "syno_checkbox", | |
| boxLabel: _DT("settings", "watch_torrentnzb_enableload"), | |
| name: "enable_torrent_nzb_watch" | |
| }, { | |
| xtype: "syno_checkbox", | |
| boxLabel: _DT("settings", "watch_torrentnzb_enabledelete"), | |
| indent: 1, | |
| name: "enable_delete_torrent_nzb_watch" | |
| }, { | |
| xtype: "syno_compositefield", | |
| itemId: "watchfolderfield", | |
| indent: 1, | |
| fieldLabel: _DT("settings", "watch_torrentnzb_folder"), | |
| defaults: { | |
| hideLabel: true | |
| }, | |
| items: [{ | |
| xtype: "syno_textfield", | |
| name: "torrent_nzb_watch_folder", | |
| readOnly: true, | |
| allowBlank: false, | |
| width: 160 | |
| }, { | |
| id: this.btnwatchfolder = Ext.id(), | |
| xtype: "syno_button", | |
| text: _T("common", "choose"), | |
| disabled: _S("demo_mode"), | |
| scope: this, | |
| handler: function() { | |
| this.utils.chooseDestHandler({ | |
| owner: this.owner, | |
| title: _DT("settings", "watch_torrentnzb_folder"), | |
| destinationField: this.form.findField("torrent_nzb_watch_folder") | |
| }) | |
| } | |
| }] | |
| }] | |
| }; | |
| var c = { | |
| autoScroll: true, | |
| trackResetOnLoad: true, | |
| labelWidth: 200, | |
| border: false, | |
| hideMode: "offsets", | |
| items: [b, d], | |
| listeners: { | |
| afterlayout: { | |
| fn: function() { | |
| var f, e = ["enable_delete_torrent_nzb_watch", "watchfolderfield"]; | |
| if (!_S("demo_mode")) { | |
| e.push(this.btnwatchfolder) | |
| } | |
| f = new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"enable_torrent_nzb_watch",e) | |
| }, | |
| scope: this, | |
| single: true | |
| } | |
| } | |
| }; | |
| return Ext.apply(c, a) | |
| }, | |
| getWebAPISetData: function() { | |
| var a = this.callParent(arguments); | |
| if (Ext.isDefined(a)) { | |
| SYNO.SDS.DownloadStation.DLM.Util.setLocationDestination(undefined) | |
| } | |
| return a | |
| }, | |
| getWebAPIName: function() { | |
| return "SYNO.DownloadStation2.Settings.Location" | |
| }, | |
| getKeyName: function() { | |
| return "location" | |
| }, | |
| getFields: function() { | |
| var a = ["default_destination", "enable_torrent_nzb_watch", "enable_delete_torrent_nzb_watch", "torrent_nzb_watch_folder"]; | |
| return a | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.Settings"); | |
| Ext.define("SYNO.SDS.DownloadStation.Settings.DLMBt", { | |
| extend: "SYNO.SDS.DownloadStation.Settings.FormPanel", | |
| fillConfig: function(a) { | |
| var c = new Ext.data.SimpleStore({ | |
| id: 0, | |
| fields: ["value", "display"], | |
| data: [["auto", _DT("service", "service_dl_bt_encrypt_auto")], ["always", _DT("service", "service_dl_bt_encrypt_always")], ["disable", _DT("service", "service_dl_bt_encrypt_disable")]] | |
| }); | |
| var b = { | |
| trackResetOnLoad: true, | |
| hideMode: "offsets", | |
| border: false, | |
| autoScroll: true, | |
| items: [{ | |
| xtype: "syno_fieldset", | |
| title: _DT("service", "service_dl_bt_network_setting"), | |
| labelWidth: 250, | |
| synodefaults: { | |
| width: 130 | |
| }, | |
| items: [{ | |
| xtype: "syno_numberfield", | |
| name: "tcp_port", | |
| fieldLabel: _DT("settings", "title_tcp_port"), | |
| decimalPrecision: 0, | |
| minValue: 1, | |
| maxValue: 65535, | |
| vtype: "port", | |
| maxlength: 5, | |
| validator: function(d) { | |
| if (SYNO.SDS.Utils.isReservedPort("download", d, d)) { | |
| return _DT("service", "error_dl_port_in_used") | |
| } else { | |
| return true | |
| } | |
| } | |
| }, { | |
| xtype: "syno_compositefield", | |
| fieldLabel: _DT("service", "service_dl_bt_max_upload"), | |
| width: 360, | |
| items: [{ | |
| xtype: "syno_numberfield", | |
| name: "max_upload_rate", | |
| width: 130, | |
| allowDecimals: false, | |
| allowNegative: false, | |
| minValue: 0, | |
| maxlength: 6 | |
| }, { | |
| xtype: "syno_displayfield", | |
| value: "KB/s " + _DT("service", "service_dl_bt_rate_desc") | |
| }] | |
| }, { | |
| xtype: "syno_compositefield", | |
| fieldLabel: _DT("service", "service_dl_bt_max_download"), | |
| width: 360, | |
| items: [{ | |
| xtype: "syno_numberfield", | |
| name: "max_download_rate", | |
| width: 130, | |
| allowDecimals: false, | |
| allowNegative: false, | |
| minValue: 0, | |
| maxlength: 6 | |
| }, { | |
| xtype: "syno_displayfield", | |
| value: "KB/s " + _DT("service", "service_dl_bt_rate_desc") | |
| }] | |
| }, { | |
| xtype: "syno_combobox", | |
| fieldLabel: _DT("service", "service_dl_bt_encrypt"), | |
| name: "encrypt", | |
| store: c, | |
| displayField: "display", | |
| valueField: "value", | |
| selectOnFocus: true | |
| }, { | |
| xtype: "syno_numberfield", | |
| fieldLabel: _DT("service", "service_dl_bt_maxpeers"), | |
| name: "max_peer", | |
| minValue: 5, | |
| maxValue: 10000 | |
| }, { | |
| xtype: "syno_checkbox", | |
| boxLabel: _DT("service", "service_dl_bt_dht_enable"), | |
| name: "enable_dht" | |
| }, { | |
| xtype: "syno_numberfield", | |
| fieldLabel: _DT("service", "service_dl_bt_dht_port"), | |
| name: "dht_port", | |
| vtype: "port", | |
| decimalPrecision: 0, | |
| minValue: 1, | |
| maxValue: 65535, | |
| indent: 1, | |
| validator: function(d) { | |
| if (SYNO.SDS.Utils.isReservedPort("download", d, d)) { | |
| return _DT("service", "error_dl_port_in_used") | |
| } else { | |
| return true | |
| } | |
| } | |
| }, { | |
| xtype: "syno_checkbox", | |
| boxLabel: _DT("service", "service_dl_bt_port_forwarding_enable"), | |
| name: "enable_port_forwarding" | |
| }] | |
| }, { | |
| xtype: "syno_fieldset", | |
| title: _DT("service", "service_dl_bt_stoptask_opt"), | |
| labelWidth: 250, | |
| synodefaults: { | |
| width: 130 | |
| }, | |
| items: [{ | |
| xtype: "syno_displayfield", | |
| value: _DT("service", "service_dl_bt_stoptask_desc"), | |
| name: "bt_stoptask_desc" | |
| }, { | |
| xtype: "syno_numberfield", | |
| fieldLabel: _DT("service", "service_dl_bt_seeding_ratio"), | |
| name: "seeding_ratio", | |
| allowDecimals: false, | |
| allowNegative: false, | |
| minValue: 0, | |
| maxValue: 2147483647, | |
| maxlength: 10, | |
| value: 0 | |
| }, { | |
| xtype: "syno_compositefield", | |
| items: [{ | |
| maskRe: /[\d]/, | |
| xtype: "syno_combobox", | |
| width: 200, | |
| maxlength: 3, | |
| fieldLabel: _DT("service", "service_dl_bt_seeding_interval"), | |
| hiddenName: "seeding_interval", | |
| store: SYNO.SDS.DownloadStation.DLM.Util.createSeedTimeStore(), | |
| displayField: "display", | |
| valueField: "value", | |
| selectOnFocus: true, | |
| value: 0, | |
| initQuery: Ext.emptyFn, | |
| setValue: function(e) { | |
| SYNO.ux.ComboBox.prototype.setValue.apply(this, arguments); | |
| var d = this; | |
| var f = (("0" != e) && (-2 == e || -1 == d.store.data.keys.indexOf(e))); | |
| d.setEditable(f); | |
| d.nextSibling().setValue(f ? _T("service", "service_dl_bt_seedopt_unit_hours") : ""); | |
| if (-2 == e) { | |
| d.setRawValue() | |
| } else { | |
| if (f && e > 0) { | |
| d.setRawValue(e / 60) | |
| } | |
| } | |
| }, | |
| listeners: { | |
| scope: this, | |
| blur: function(d) { | |
| var e = d.getValue(); | |
| var f = (-2 == e || -1 == d.store.data.keys.indexOf(e)); | |
| if ("" === e || "0" === e) { | |
| d.setValue(0) | |
| } else { | |
| if (f && e > 0) { | |
| d.setValue(e * 60) | |
| } | |
| } | |
| } | |
| }, | |
| validator: function(e) { | |
| if (-1 < this.store.findExact("display", e)) { | |
| return true | |
| } | |
| var d = new RegExp("^[0-9]{0,5}$"); | |
| return d.test(e) | |
| } | |
| }, { | |
| xtype: "syno_displayfield", | |
| value: "", | |
| isDirty: function() { | |
| return false | |
| } | |
| }] | |
| }, { | |
| xtype: "syno_checkbox", | |
| boxLabel: _DT("service", "service_dl_bt_seeding_auto_remove"), | |
| name: "enable_seeding_auto_remove" | |
| }] | |
| }, { | |
| xtype: "syno_fieldset", | |
| title: _T("photo_viewer", "menu_preview"), | |
| hidden: (true === SYNO.SDS.isNSM), | |
| items: [{ | |
| xtype: "syno_checkbox", | |
| boxLabel: _DT("settings", "bt_preview_enable"), | |
| name: "enable_preview" | |
| }] | |
| }], | |
| listeners: { | |
| afterlayout: { | |
| fn: function() { | |
| new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"enable_dht",["dht_port"]); | |
| var e = this.form.findField("bt_stoptask_desc"); | |
| if (Ext.isDefined(e)) { | |
| SYNO.SDS.DownloadStation.Utils.AddTip(e.el, _DT("service", "service_dl_bt_seeding_hint")); | |
| e.disabled = true | |
| } | |
| var d = this.form.findField("enable_port_forwarding"); | |
| if (Ext.isDefined(d)) { | |
| SYNO.SDS.DownloadStation.Utils.AddTip(d.el, _DT("service", "service_dl_bt_port_forwarding_hint")) | |
| } | |
| }, | |
| scope: this, | |
| single: true | |
| } | |
| } | |
| }; | |
| Ext.apply(b, a); | |
| return SYNO.LayoutConfig.fill(b) | |
| }, | |
| defineBehaviors: function() {}, | |
| getWebAPIName: function() { | |
| return "SYNO.DownloadStation2.Settings.BT" | |
| }, | |
| getKeyName: function() { | |
| return "bt" | |
| }, | |
| postReturnData: function(a) { | |
| this.gData.set(this.getKeyName(), a[0].data); | |
| this.form.setValues(a[0].data); | |
| this.appWin.tabPanel.enable_bt_preview = a[0].data.enable_preview | |
| }, | |
| getFields: function() { | |
| var a = ["tcp_port", "max_upload_rate", "max_download_rate", "encrypt", "max_peer", "enable_dht", "dht_port", "enable_port_forwarding", "seeding_ratio", "seeding_interval", "enable_seeding_auto_remove", "enable_preview"]; | |
| return a | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.Settings"); | |
| Ext.define("SYNO.SDS.DownloadStation.Settings.DLMFTP", { | |
| extend: "SYNO.SDS.DownloadStation.Settings.FormPanel", | |
| fillConfig: function(a) { | |
| var b = { | |
| autoScroll: true, | |
| trackResetOnLoad: true, | |
| labelWidth: 200, | |
| border: false, | |
| hideMode: "offsets", | |
| items: [{ | |
| xtype: "syno_fieldset", | |
| title: _DT("service", "service_dl_ftp_setting"), | |
| items: [{ | |
| xtype: "syno_checkbox", | |
| name: "enable_ftp_max_conn", | |
| boxLabel: _DT("service", "service_enable_ftpconn") | |
| }, { | |
| xtype: "syno_numberfield", | |
| fieldLabel: _DT("service", "service_ftpmaxconn"), | |
| name: "ftp_max_conn", | |
| minValue: 1, | |
| maxValue: 65535, | |
| allowNegative: false, | |
| allowDecimals: false, | |
| allowBlank: false, | |
| indent: 1 | |
| }] | |
| }, { | |
| xtype: "syno_fieldset", | |
| title: _DT("service", "service_dl_ftp_http_setting"), | |
| items: [{ | |
| xtype: "syno_compositefield", | |
| width: 400, | |
| fieldLabel: _DT("service", "service_dl_max_download_per_task"), | |
| items: [{ | |
| xtype: "syno_numberfield", | |
| name: "ftp_http_max_download_rate", | |
| minValue: 0, | |
| maxlength: 6 | |
| }, { | |
| xtype: "syno_displayfield", | |
| value: "KB/s " + _DT("service", "service_dl_bt_rate_desc") | |
| }] | |
| }] | |
| }], | |
| listeners: { | |
| afterlayout: { | |
| fn: function() { | |
| new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"enable_ftp_max_conn",["ftp_max_conn"]) | |
| }, | |
| scope: this, | |
| single: true | |
| } | |
| } | |
| }; | |
| Ext.apply(b, a); | |
| return SYNO.LayoutConfig.fill(b) | |
| }, | |
| getWebAPIName: function() { | |
| return "SYNO.DownloadStation2.Settings.FtpHttp" | |
| }, | |
| getKeyName: function() { | |
| return "ftp_http" | |
| }, | |
| getFields: function() { | |
| var a = ["enable_ftp_max_conn", "ftp_max_conn", "ftp_http_max_download_rate"]; | |
| return a | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.Settings"); | |
| Ext.define("SYNO.SDS.DownloadStation.Settings.DLMNZB", { | |
| extend: "SYNO.SDS.DownloadStation.Settings.FormPanel", | |
| fillConfig: function(a) { | |
| var b = { | |
| autoScroll: true, | |
| trackResetOnLoad: true, | |
| labelWidth: 200, | |
| border: false, | |
| hideMode: "offsets", | |
| items: [{ | |
| xtype: "syno_fieldset", | |
| title: _DT("service", "service_dl_nzb_setting"), | |
| items: [{ | |
| xtype: "syno_displayfield", | |
| value: _DT("service", "nzb_intro") | |
| }, { | |
| xtype: "syno_textfield", | |
| fieldLabel: _DT("service", "nzb_server"), | |
| name: "server", | |
| vtype: "iporhostname", | |
| maxLength: 4096 | |
| }, { | |
| xtype: "syno_numberfield", | |
| fieldLabel: _DT("service", "nzb_server_port"), | |
| name: "port", | |
| vtype: "port", | |
| minValue: 1, | |
| maxValue: 65535 | |
| }, { | |
| xtype: "syno_checkbox", | |
| boxLabel: _DT("service", "nzb_enable_ssl"), | |
| name: "enable_encryption" | |
| }, { | |
| xtype: "syno_checkbox", | |
| boxLabel: _DT("service", "nzb_server_need_auth"), | |
| name: "enable_auth" | |
| }, { | |
| xtype: "syno_textfield", | |
| fieldLabel: _DT("service", "nzb_user"), | |
| name: "username", | |
| allowBlank: false, | |
| maxLength: 64, | |
| indent: 1 | |
| }, { | |
| xtype: "syno_textfield", | |
| textType: "password", | |
| fieldLabel: _DT("common", "password"), | |
| name: "password", | |
| maxLength: 32, | |
| indent: 1 | |
| }, { | |
| xtype: "syno_textfield", | |
| textType: "password_confirm", | |
| fieldLabel: _DT("service", "nzb_pass_confirm"), | |
| name: "password_confirm", | |
| maxlength: 4096, | |
| indent: 1, | |
| validator: (function(d) { | |
| var c = this.form.findField("password").getValue(); | |
| if ((c != d) && (c != "12345678" || d != "87654321")) { | |
| return _DT("service", "nzb_confirmpass") | |
| } | |
| return true | |
| } | |
| ).createDelegate(this) | |
| }, { | |
| xtype: "syno_displayfield", | |
| value: " " | |
| }, { | |
| xtype: "syno_numberfield", | |
| fieldLabel: _DT("service", "nzb_max_connection"), | |
| name: "conn_per_download", | |
| minValue: 1, | |
| maxValue: 65535, | |
| maxLength: 5 | |
| }, { | |
| xtype: "syno_compositefield", | |
| width: 400, | |
| fieldLabel: _DT("service", "service_dl_max_download_per_task"), | |
| items: [{ | |
| xtype: "syno_numberfield", | |
| name: "max_download_rate", | |
| minValue: 0, | |
| maxlength: 6 | |
| }, { | |
| xtype: "syno_displayfield", | |
| value: "KB/s " + _DT("service", "service_dl_bt_rate_desc") | |
| }] | |
| }, { | |
| xtype: "syno_checkbox", | |
| boxLabel: _DT("settings", "nzb_par2_repair_enable"), | |
| name: "enable_parchive" | |
| }, { | |
| xtype: "syno_checkbox", | |
| boxLabel: _DT("settings", "nzb_par2_remove_enable"), | |
| name: "enable_remove_parfiles", | |
| indent: 1 | |
| }] | |
| }], | |
| listeners: { | |
| afterlayout: { | |
| fn: function() { | |
| new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"enable_auth",["username", "password", "password_confirm"]); | |
| new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"enable_parchive",["enable_remove_parfiles"]) | |
| }, | |
| scope: this, | |
| single: true | |
| } | |
| } | |
| }; | |
| Ext.apply(b, a); | |
| return SYNO.LayoutConfig.fill(b) | |
| }, | |
| getWebAPIName: function() { | |
| return "SYNO.DownloadStation2.Settings.Nzb" | |
| }, | |
| getKeyName: function() { | |
| return "nzb" | |
| }, | |
| postReturnData: function(a) { | |
| var b; | |
| b = a[0].data; | |
| if (b.enable_auth) { | |
| b.password = "12345678"; | |
| b.password_confirm = "87654321" | |
| } | |
| this.gData.set(this.getKeyName(), b); | |
| this.form.setValues(b) | |
| }, | |
| getFields: function() { | |
| var a = ["server", "port", "enable_encryption", "enable_auth", "username", "password", "conn_per_download", "max_download_rate", "enable_parchive", "enable_remove_parfiles"]; | |
| return a | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.Settings"); | |
| Ext.define("SYNO.SDS.DownloadStation.Settings.DLMRSS", { | |
| extend: "SYNO.SDS.DownloadStation.Settings.FormPanel", | |
| fillConfig: function(a) { | |
| var b = { | |
| autoScroll: true, | |
| trackResetOnLoad: true, | |
| labelWidth: 200, | |
| border: false, | |
| hideMode: "offsets", | |
| items: [{ | |
| xtype: "syno_fieldset", | |
| title: _DT("download", "rss_feeds"), | |
| items: [{ | |
| xtype: "syno_combobox", | |
| fieldLabel: _DT("download", "update_interval"), | |
| name: "update_interval", | |
| store: this.createUpdateIntervalStore() | |
| }] | |
| }] | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| createUpdateIntervalStore: function() { | |
| var a = [10, 30, 60, 120, 240, 480, 720, 1440]; | |
| var b = []; | |
| Ext.each(a, function(e, c, d) { | |
| var g = ""; | |
| var f; | |
| if (e < 60) { | |
| g = _DT("service", "service_dl_bt_seedopt_unit_mins"); | |
| f = e | |
| } else { | |
| g = _DT("service", "service_dl_bt_seedopt_unit_hours"); | |
| f = e / 60 | |
| } | |
| b.push([e, String.format("{0} {1}", f, g)]) | |
| }, this); | |
| return b | |
| }, | |
| getWebAPIName: function() { | |
| return "SYNO.DownloadStation2.Settings.Rss" | |
| }, | |
| getKeyName: function() { | |
| return "rss" | |
| }, | |
| getFields: function() { | |
| var a = ["update_interval"]; | |
| return a | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.Settings"); | |
| Ext.define("SYNO.SDS.DownloadStation.Settings.GridPanel", { | |
| extend: "SYNO.ux.GridPanel", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| this.ownerCt = a.owner; | |
| var b = Ext.applyIf(this.fillConfig(a), { | |
| fbar: { | |
| xtype: "statusbar", | |
| defaultText: " ", | |
| statusAlign: "left", | |
| buttonAlign: "left", | |
| items: SYNO.SDS.DownloadStation.Utils.composeButtonCfg({ | |
| xtype: "syno_button", | |
| btnStyle: "blue", | |
| text: _T("common", "apply"), | |
| scope: this, | |
| handler: function() { | |
| this.settingsWin.actionFlag = "APPLY"; | |
| this.settingsWin.close() | |
| }, | |
| disabled: _S("demo_mode"), | |
| tooltip: _S("demo_mode") ? _JSLIBSTR("uicommon", "error_demo") : undefined | |
| }, { | |
| xtype: "syno_button", | |
| text: _T("common", "cancel"), | |
| scope: this, | |
| handler: function() { | |
| this.settingsWin.actionFlag = "CANCEL"; | |
| this.settingsWin.close() | |
| } | |
| }) | |
| } | |
| }); | |
| this.callParent([b]); | |
| this.addClass("syno-ux-formpanel"); | |
| this.defineBehaviors() | |
| }, | |
| fillConfig: function(a) { | |
| return a | |
| }, | |
| activate: function() { | |
| this.loadGrid() | |
| }, | |
| isDirty: function() { | |
| return this.getStore().getModifiedRecords().length > 0 | |
| }, | |
| isValid: function() { | |
| return true | |
| }, | |
| deactivate: function() { | |
| return true | |
| }, | |
| getPanel: function() { | |
| return this | |
| }, | |
| getAbsoluteURL: function(a) { | |
| return String.format("{0}/{1}", this.jsConfig.jsBaseURL, a) | |
| }, | |
| setStatus: function(d) { | |
| d = d || {}; | |
| var c = this.getFooterToolbar(); | |
| if (c && Ext.isFunction(c.setStatus)) { | |
| c.setStatus(d) | |
| } | |
| }, | |
| maskAppWin: function() { | |
| var a = this.findWindow(); | |
| if (a && Ext.isDefined(a.maskForBusy)) { | |
| a.maskForBusy() | |
| } | |
| }, | |
| unmaskAppWin: function() { | |
| var a = this.findWindow(); | |
| if (a && Ext.isDefined(a.unmask)) { | |
| a.unmask() | |
| } | |
| }, | |
| setStatusBusy: function(b) { | |
| b = b || {}; | |
| Ext.applyIf(b, { | |
| text: _T("common", "loading"), | |
| iconCls: "syno-ux-statusbar-loading" | |
| }); | |
| this.setStatus(b); | |
| this.maskAppWin() | |
| }, | |
| setStatusOK: function(b) { | |
| b = b || {}; | |
| Ext.applyIf(b, { | |
| text: _T("common", "setting_applied"), | |
| iconCls: "syno-ux-statusbar-success", | |
| clear: true | |
| }); | |
| this.setStatus(b) | |
| }, | |
| setStatusError: function(b) { | |
| b = b || {}; | |
| Ext.applyIf(b, { | |
| text: _T("common", "error_system"), | |
| iconCls: "syno-ux-statusbar-error" | |
| }); | |
| this.setStatus(b) | |
| }, | |
| clearStatus: function(c) { | |
| var d = this.getFooterToolbar(); | |
| if (d && Ext.isFunction(d.clearStatus)) { | |
| d.clearStatus(c) | |
| } | |
| }, | |
| clearStatusBusy: function(a) { | |
| this.clearStatus(a); | |
| this.unmaskAppWin() | |
| }, | |
| getWebAPISetData: function() { | |
| return undefined | |
| }, | |
| onSettingsApply: function() { | |
| return true | |
| }, | |
| getHelpParam: Ext.emptyFn, | |
| enableCheckGroup: Ext.emptyFn, | |
| defineBehaviors: Ext.emptyFn, | |
| updateGrid: Ext.emptyFn, | |
| loadGrid: Ext.emptyFn | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.Uploader.HTML5Uploader"); | |
| Ext.define("SYNO.SDS.DownloadStation.Uploader.HTMLUploaderTaskMgr", { | |
| extend: "Object", | |
| taskList: Object.create(null), | |
| taskUploadingIndex: 0, | |
| constructor: function(a) { | |
| this.uploader = a.uploader; | |
| SYNO.SDS.DownloadStation.Uploader.HTMLUploaderTaskMgr.superclass.constructor.apply(this, arguments) | |
| }, | |
| initTaskData: function() { | |
| this.taskList = Object.create(null); | |
| this.taskUploadingIndex = 0 | |
| }, | |
| getTaskSize: function() { | |
| return this.taskList ? Object.keys(this.taskList).length : 0 | |
| }, | |
| getUploadingTaskIndex: function() { | |
| return this.taskUploadingIndex | |
| }, | |
| addUploadTask: function(a) { | |
| this.taskList[this.getTaskSize()] = a | |
| }, | |
| removeOneTask: function(b) { | |
| var a = this.taskList[b]; | |
| if (a) { | |
| if (a.status === "PROCESSING") { | |
| if (this.uploader && this.uploader.conn) { | |
| this.uploader.conn.abort(a.reqId) | |
| } | |
| this.blUploading = false; | |
| if (this.uploader.clearFolderFiles) { | |
| this.uploader.clearFolderFiles(a) | |
| } | |
| this.taskUploadingIndex++; | |
| this.uploader.uploadNext() | |
| } | |
| a.file = null; | |
| a.status = "CANCEL" | |
| } | |
| }, | |
| restartOneTask: function(b) { | |
| var a = this.taskList[b]; | |
| if (a) { | |
| this.uploader.addFiles([a.file], true, false, a.params, [a.dtItem], a.isDirectory); | |
| this.removeOneTask(b) | |
| } | |
| } | |
| }); | |
| Ext.define("SYNO.SDS.DownloadStation.Uploader.HTML5Uploader", { | |
| extend: "Ext.Component", | |
| MAX_POST_FILESIZE: (Ext.isWebKit) ? -1 : ((window.console && window.console.firebug) ? 20971521 : 4294963200), | |
| FileObj: function(a, d, e, b) { | |
| var c = SYNO.Util.copy(d || {}); | |
| if (a.lastModifiedDate) { | |
| c = Ext.apply(c, { | |
| mtime: a.lastModifiedDate.getTime() | |
| }) | |
| } | |
| return { | |
| id: e, | |
| file: a, | |
| dtItem: b, | |
| name: a.name || a.fileName, | |
| size: a.size || a.fileSize, | |
| progress: 0, | |
| status: "NOT_STARTED", | |
| params: c, | |
| chunkmode: false | |
| } | |
| }, | |
| constructor: function(b, a) { | |
| this.initDefData(); | |
| this.HTMLUploaderTask = new SYNO.SDS.DownloadStation.Uploader.HTMLUploaderTaskMgr({ | |
| uploader: this | |
| }); | |
| Ext.apply(this.opts, b); | |
| SYNO.SDS.DownloadStation.Uploader.HTML5Uploader.superclass.constructor.apply(this, arguments); | |
| this.init(a) | |
| }, | |
| initDefData: function() { | |
| this.blAppenddata = false; | |
| this.nbExceed = 0; | |
| this.nbWrongType = 0; | |
| this.arrFolder = []; | |
| this.arrExceedFile = []; | |
| this.arrWrongType = []; | |
| this.arrBigFile = []; | |
| this.objErrFiles = {}; | |
| this.nbErrFiles = 0; | |
| this.opts = { | |
| bldropBody: false, | |
| instantStart: false, | |
| chunkmode: false, | |
| chunksize: 10485760, | |
| filefiledname: "file", | |
| params: {} | |
| } | |
| }, | |
| init: function(a) { | |
| a.container.mon(this, a.opts.listeners); | |
| this.initButtonEl(a.container, a.opts); | |
| this.initDragDropEl(a.container, a.opts); | |
| if (a.files) { | |
| a.container.mon(a.container.owner, "show", function() { | |
| this.dropFiles(a.files); | |
| a.files = null | |
| }, this, { | |
| single: true | |
| }) | |
| } | |
| }, | |
| onMask: function(a) { | |
| if (this.opts.dropcss) { | |
| a.addClass(this.opts.dropcss) | |
| } | |
| a.addClass("file-drag-over"); | |
| a.mask(this.opts.droptext || _T("filetable", "drop_file")) | |
| }, | |
| onUnmask: function(a) { | |
| if (this.opts.dropcss) { | |
| a.removeClass(this.opts.dropcss) | |
| } | |
| a.unmask(); | |
| a.removeClass("file-drag-over") | |
| }, | |
| initButtonEl: function(b, a) { | |
| var d = this; | |
| if (Ext.isFunction(b.getForm)) { | |
| var e = b.getForm().findField(this.opts.filefiledname); | |
| if (e) { | |
| var c = e.el; | |
| if (c && c.is("input[type=file]")) { | |
| this.textEl = b.getForm().findField("MultiText"); | |
| this.mon(c, "change", function() { | |
| d.blFolderEabled = false; | |
| d.addFiles.call(d, this.dom.files, true, false, undefined, undefined, false); | |
| var g = this.dom | |
| , f = g.disabled; | |
| g.disabled = true; | |
| g.value = ""; | |
| g.disabled = f | |
| }) | |
| } | |
| } | |
| } | |
| }, | |
| initDragDropEl: function(b, a) { | |
| var c = (b.getXType() === "grid") ? b.getView().scroller : (b.getViewEl ? b.getViewEl() : b.el); | |
| var d = this.opts.bldropBody ? (b.body || c) : c; | |
| if (!d) { | |
| return | |
| } | |
| b.mon(d, "dragover", function(f) { | |
| if (SYNO.SDS.DownloadStation.Uploader.Utils.isDragFile(f.browserEvent)) { | |
| if (!this.isDragMask) { | |
| return | |
| } | |
| f.preventDefault(); | |
| f.stopPropagation(); | |
| f.browserEvent.dataTransfer.dropEffect = "copy"; | |
| this.dragstarttime = new Date().getTime() | |
| } | |
| }, this); | |
| b.mon(Ext.getDoc(), "dragover", function(f) { | |
| if (SYNO.SDS.DownloadStation.Uploader.Utils.isDragFile(f.browserEvent)) { | |
| this.dragstarttime = new Date().getTime(); | |
| if (!this.isDragMask) { | |
| if (!b.isVisible() || b.owner && b.owner.maskCnt >= 1 || b.el.isMasked() || (b.owner && b.owner.el.isMasked()) || (b.ownerCt && b.ownerCt && b.ownerCt.el.isMasked()) || (b.ownerCt && b.ownerCt.ownerCt && b.ownerCt.ownerCt.el.isMasked()) || Ext.getBody().hasClass("x-body-masked")) { | |
| return false | |
| } | |
| if (false === this.fireEvent("onBeforeDragEnter", this, b, f)) { | |
| return false | |
| } | |
| this.isDragMask = true; | |
| if (!this.dragPollTask) { | |
| this.dragPollTask = this.addTask({ | |
| interval: 300, | |
| run: function() { | |
| if (800 < new Date().getTime() - this.dragstarttime) { | |
| this.onDragEnd(b, d) | |
| } | |
| }, | |
| scope: this | |
| }) | |
| } | |
| this.dragPollTask.start(); | |
| if (false === this.fireEvent("onDragEnter", this, b)) { | |
| return false | |
| } | |
| this.onMask(d); | |
| return | |
| } else { | |
| this.fireEvent("onDragOver", this, b) | |
| } | |
| } | |
| }, this); | |
| b.mon(Ext.getDoc(), "dragend", this.onDragEnd.createDelegate(this, [b, d], true)); | |
| b.mon(Ext.getDoc(), "drop", this.onDragEnd.createDelegate(this, [b, d], true)); | |
| b.mon(d, "drop", function(g) { | |
| if (SYNO.SDS.DownloadStation.Uploader.Utils.isDragFile(g.browserEvent)) { | |
| this.dragstarttime = undefined; | |
| this.isDragMask = false; | |
| if (false === this.fireEvent("onDrop", this, b)) { | |
| return | |
| } | |
| this.onUnmask(d); | |
| g.stopPropagation(); | |
| g.preventDefault(); | |
| g.stopEvent(); | |
| if (_S("demo_mode")) { | |
| this.fireEvent("onError", this, _JSLIBSTR("uicommon", "error_demo")); | |
| return | |
| } | |
| var f = g.browserEvent.dataTransfer; | |
| if (f && f.files && f.files.length > 0) { | |
| if (f.items && f.items[0] && f.items[0].webkitGetAsEntry) { | |
| this.blFolderEabled = !!this.blFolderEabled && true | |
| } else { | |
| this.blFolderEabled = false | |
| } | |
| this.addFiles.call(this, f.files, false, false, null, f.items) | |
| } else { | |
| this.fireEvent("onError", this, _T("error", "upload_folder_error")) | |
| } | |
| } | |
| }, this) | |
| }, | |
| onDragEnd: function() { | |
| if (this.dragPollTask && this.dragPollTask.running) { | |
| this.dragPollTask.stop(); | |
| var b = arguments[arguments.length - 1]; | |
| var a = arguments[arguments.length - 2]; | |
| if (this.isDragMask && b.isMasked()) { | |
| this.onUnmask(b) | |
| } | |
| this.isDragMask = false; | |
| if (false === this.fireEvent("onDragEnd", this, a)) { | |
| return false | |
| } | |
| } | |
| }, | |
| initTaskData: function() { | |
| this.HTMLUploaderTask.initTaskData() | |
| }, | |
| checkDirectory: function(h, b) { | |
| var c = h.file | |
| , f = null; | |
| if (b && b.getAsEntry) { | |
| f = b.getAsEntry(); | |
| if (f) { | |
| return f.isDirectory | |
| } | |
| } else { | |
| if (b && b.webkitGetAsEntry) { | |
| f = b.webkitGetAsEntry(); | |
| if (f) { | |
| return f.isDirectory | |
| } | |
| } else { | |
| if (Ext.isGecko) { | |
| try { | |
| var d; | |
| if (!!(File && File.prototype.slice)) { | |
| d = c.slice(0, 1) | |
| } else { | |
| if (!!(File && File.prototype.webkitSlice)) { | |
| d = c.webkitSlice(0, 1) | |
| } else { | |
| if (!!(File && File.prototype.mozSlice)) { | |
| d = c.mozSlice(0, 1) | |
| } else { | |
| return false | |
| } | |
| } | |
| } | |
| if (d && window.FileReader) { | |
| var a = new FileReader(); | |
| a.readAsBinaryString(d) | |
| } | |
| } catch (g) { | |
| return true | |
| } | |
| return false | |
| } else { | |
| if (Ext.isSafari) { | |
| return false | |
| } | |
| } | |
| } | |
| } | |
| return (c.size === 0) | |
| }, | |
| addFiles: function(v, a, d, s, f, q, h) { | |
| var t, p, o, n, g = [], u = [], m = f ? f : null; | |
| if (!v || 0 === v.length) { | |
| this.fireEvent("onError", this, _DT("download", "download_empty_input_file")); | |
| return | |
| } | |
| if (h) { | |
| this.blForceHtmlUpload = true | |
| } else { | |
| this.blForceHtmlUpload = false | |
| } | |
| if (!this.blAppenddata) { | |
| this.initTaskData() | |
| } | |
| this.nbExceed = 0; | |
| this.nbWrongType = 0; | |
| this.objErrFiles = {}; | |
| this.nbErrFiles = 0; | |
| this.arrExceedFile = []; | |
| this.arrWrongType = []; | |
| this.arrBigFile = []; | |
| var e = 0; | |
| var k; | |
| var b = this.getTaskSize(); | |
| var c = []; | |
| for (p = 0; p < v.length; p++) { | |
| t = v[p]; | |
| n = t.name || t.fileName; | |
| if (u[n] && false !== this.fireEvent("onNameDuplicate")) { | |
| continue | |
| } | |
| var l; | |
| u[n] = true; | |
| if (t instanceof File) { | |
| var r = (m && m[p]) ? m[p] : null; | |
| if (r) { | |
| r = (r.webkitGetAsEntry) ? r.webkitGetAsEntry() : r | |
| } | |
| l = new this.FileObj(t,s,null,r); | |
| if (Ext.isBoolean(q)) { | |
| if (Ext.isModernIE) { | |
| l.isDirectory = (l.file.size === 0) | |
| } else { | |
| l.isDirectory = q | |
| } | |
| } else { | |
| l.isDirectory = false; | |
| if (m) { | |
| for (o = p; o < m.length; o++) { | |
| if (m[o] && m[o].getAsFile && m[o].getAsFile() === t) { | |
| l.isDirectory = this.checkDirectory(l, m[o]); | |
| break | |
| } | |
| } | |
| } else { | |
| l.isDirectory = this.checkDirectory(l) | |
| } | |
| } | |
| c.push(l) | |
| } else { | |
| l = t; | |
| if (s) { | |
| Ext.apply(l.params, s) | |
| } | |
| } | |
| if (false !== this.onSelect(l)) { | |
| if (a) { | |
| k = this.getTaskSize(); | |
| l.id = k; | |
| if (false !== this.fireEvent("onSelect", this, l)) { | |
| this.HTMLUploaderTask.addUploadTask(l) | |
| } | |
| } else { | |
| g.push(l.name) | |
| } | |
| e++ | |
| } | |
| } | |
| if (false !== d && this.textEl) { | |
| this.setInputFieldValue("") | |
| } | |
| k = this.getTaskSize(); | |
| if (a) { | |
| if (this.textEl) { | |
| this.setInputFieldValue(this.getDisplayTextCorrespondingToFileCounts(e)) | |
| } | |
| this.onAllSelect(b, k) | |
| } else { | |
| if (e === 0) { | |
| this.onAllSelect(b, k) | |
| } else { | |
| this.fireEvent("onBeforeDropfile", this, g, v, { | |
| fn: this.dropFiles, | |
| files: c, | |
| scope: this | |
| }, this.onAllSelectStr()) | |
| } | |
| } | |
| }, | |
| getDisplayTextCorrespondingToFileCounts: function(a) { | |
| if (a <= 0) { | |
| return "" | |
| } else { | |
| if (a === 1) { | |
| return this.HTMLUploaderTask.taskList[0].name | |
| } else { | |
| return String.format(_DT("download", "download_files_selected"), a) | |
| } | |
| } | |
| }, | |
| dropFiles: function(a, b) { | |
| this.addFiles(a, true, true, b) | |
| }, | |
| checkAllowFiletype: function(a) { | |
| var c = this.opts.allowfilters; | |
| if (!c || 0 === c.length) { | |
| return true | |
| } | |
| var b = false; | |
| Ext.each(c, function(d) { | |
| if (SYNO.SDS.DownloadStation.Utils.isValidExtension(a, "." + d)) { | |
| b = true; | |
| return false | |
| } | |
| }); | |
| return b | |
| }, | |
| onSelect: function(b) { | |
| var a = Ext.util.Format.htmlEncode(b.name); | |
| if (this.opts.limitSize && (b.size > this.opts.limitSize)) { | |
| this.arrBigFile.push(a) | |
| } else { | |
| if (this.opts.limitFiles && ((this.getTaskSize() - this.HTMLUploaderTask.taskUploadingIndex) >= this.opts.limitFiles)) { | |
| this.nbExceed++; | |
| this.arrExceedFile.push(a) | |
| } else { | |
| if (!this.checkAllowFiletype(a)) { | |
| this.nbWrongType++; | |
| this.arrWrongType.push(a) | |
| } else { | |
| if (!this.blFolderEabled && b.isDirectory) { | |
| this.arrFolder.push(a) | |
| } else { | |
| return true | |
| } | |
| } | |
| } | |
| } | |
| return false | |
| }, | |
| getTaskSize: function() { | |
| return this.HTMLUploaderTask.getTaskSize() | |
| }, | |
| onAllSelectStr: function(c) { | |
| var d = "" | |
| , a = c ? "<br>" : ""; | |
| var b = 0; | |
| if (this.nbExceed) { | |
| d += (1 == this.nbExceed) ? _T("common", "common_unselect_file") : _T("common", "common_unselect_files"); | |
| d += a; | |
| if (1 < this.nbExceed) { | |
| d = d.replace("_NFILES_", this.nbExceed) | |
| } | |
| this.nbExceed = 0; | |
| this.arrExceedFile = [] | |
| } | |
| if (this.arrBigFile && 0 < this.arrBigFile.length) { | |
| d += _T("upload", "upload_exceed_maximum_filesize") + ": " + a; | |
| for (b = 0; (b < this.arrBigFile.length && b < 5); b++) { | |
| d += this.arrBigFile[b] + a | |
| } | |
| if (5 < this.arrBigFile.length) { | |
| d += "..." + a | |
| } | |
| d += a; | |
| this.arrBigFile = [] | |
| } | |
| if (!this.blFolderEabled && this.arrFolder && 0 < this.arrFolder.length) { | |
| d += _T("upload", Ext.isMac ? "no_folder_upload_action" : "upload_folder_error") + a; | |
| for (b = 0; (b < this.arrFolder.length && b < 5); b++) { | |
| d += this.arrFolder[b] + a | |
| } | |
| if (5 < this.arrFolder.length) { | |
| d += "..." + a | |
| } | |
| this.arrFolder = [] | |
| } | |
| if (this.nbWrongType) { | |
| d += String.format(_T("upload", "wrong_files_format"), this.nbWrongType); | |
| this.nbWrongType = 0; | |
| this.arrWrongType = [] | |
| } | |
| return d | |
| }, | |
| onAllSelect: function(b, a) { | |
| var c = this.onAllSelectStr(true); | |
| if (c && c !== "") { | |
| this.fireEvent("onError", this, c) | |
| } | |
| this.fireEvent("onAllSelect", this, b, a); | |
| if (this.getTaskSize() && this.opts.instantStart) { | |
| this.uploadNext.createDelegate(this).defer(10) | |
| } | |
| return true | |
| }, | |
| onUploadFile: function(c) { | |
| var b; | |
| if (-1 !== this.MAX_POST_FILESIZE && c.size > this.MAX_POST_FILESIZE) { | |
| this.onError(_T("error", "upload_too_large"), c); | |
| return | |
| } | |
| b = this.prepareStartFormdata(c); | |
| if (c.chunkmode) { | |
| var d = this.opts.chunksize; | |
| var a = Math.ceil(c.size / d); | |
| this.onUploadPartailFile(b, c, { | |
| start: 0, | |
| index: 0, | |
| total: a | |
| }) | |
| } else { | |
| this.sendArray(b, c) | |
| } | |
| }, | |
| prepareStartFormdata: function(d) { | |
| var f; | |
| var c; | |
| if (this.opts.chunkmode || (-1 !== this.MAX_POST_FILESIZE && d.size > this.MAX_POST_FILESIZE)) { | |
| d.chunkmode = true; | |
| var e = "----html5upload-" + new Date().getTime().toString() + Math.floor(Math.random() * 65535).toString(); | |
| var a = ""; | |
| if (this.opts.params) { | |
| for (c in this.opts.params) { | |
| if (this.opts.params.hasOwnProperty(c)) { | |
| a += "--" + e + '\r\nContent-Disposition: form-data; name="' + c + '"\r\n\r\n'; | |
| a += unescape(encodeURIComponent(this.opts.params[c])) + "\r\n" | |
| } | |
| } | |
| } | |
| if (d.params) { | |
| for (c in d.params) { | |
| if (d.params.hasOwnProperty(c)) { | |
| a += "--" + e + '\r\nContent-Disposition: form-data; name="' + c + '"\r\n\r\n'; | |
| a += unescape(encodeURIComponent(d.params[c])) + "\r\n" | |
| } | |
| } | |
| } | |
| var b = unescape(encodeURIComponent(d.name)); | |
| a += "--" + e + '\r\nContent-Disposition: form-data; name="' + (this.opts.filefiledname || "file") + '"; filename="' + b + '"\r\nContent-Type: application/octet-stream\r\n\r\n'; | |
| return { | |
| formdata: a, | |
| boundary: e | |
| } | |
| } | |
| f = new FormData(); | |
| if (this.opts.params) { | |
| for (c in this.opts.params) { | |
| if (this.opts.params.hasOwnProperty(c)) { | |
| f.append(c, this.opts.params[c]) | |
| } | |
| } | |
| } | |
| if (d.params) { | |
| for (c in d.params) { | |
| if (d.params.hasOwnProperty(c)) { | |
| f.append(c, d.params[c]) | |
| } | |
| } | |
| } | |
| return f | |
| }, | |
| onUploadPartailFile: function(f, a, d, h) { | |
| d.start = d.index * this.opts.chunksize; | |
| var c = Math.min(this.opts.chunksize, a.size - d.start); | |
| if (a.status !== "PROCESSING") { | |
| return | |
| } | |
| var b; | |
| if (!!(File && File.prototype.slice)) { | |
| if ((1 > d.total) || (d.index === d.total - 1)) { | |
| b = a.file.slice(d.start) | |
| } else { | |
| b = a.file.slice(d.start, d.start + c) | |
| } | |
| } else { | |
| if (!!(File && File.prototype.webkitSlice)) { | |
| if ((1 > d.total) || (d.index === d.total - 1)) { | |
| b = a.file.webkitSlice(d.start) | |
| } else { | |
| b = a.file.webkitSlice(d.start, d.start + c) | |
| } | |
| } else { | |
| if (!!(File && File.prototype.mozSlice)) { | |
| if ((1 > d.total) || (d.index === d.total - 1)) { | |
| b = a.file.mozSlice(d.start) | |
| } else { | |
| b = a.file.mozSlice(d.start, d.start + c) | |
| } | |
| } else { | |
| if (!!(File && File.prototype.slice)) { | |
| b = a.file.slice(d.start, c) | |
| } else { | |
| this.onError({}, a); | |
| return | |
| } | |
| } | |
| } | |
| } | |
| if (window.FileReader) { | |
| var i = this; | |
| var e = new FileReader(); | |
| var g = false; | |
| if (!Ext.isFunction(e.readAsBinaryString)) { | |
| g = true | |
| } | |
| e.onload = function(j) { | |
| if (j.target.readyState == FileReader.DONE) { | |
| i.sendArray(f, a, j.target.result, d, h) | |
| } | |
| } | |
| ; | |
| e.onerror = function() { | |
| i.onError(_DT("error", "error_privilege_not_enough"), a) | |
| } | |
| ; | |
| if (g) { | |
| e.readAsArrayBuffer(b) | |
| } else { | |
| e.readAsBinaryString(b) | |
| } | |
| } else { | |
| this.onError({}, a); | |
| return | |
| } | |
| }, | |
| sendArray: function(q, d, g, l, s) { | |
| if ("CANCEL" === d.status) { | |
| return | |
| } | |
| var c = {}; | |
| var o = {}; | |
| var k; | |
| if (true === d.chunkmode) { | |
| o = { | |
| "Content-Type": "multipart/form-data; boundary=" + q.boundary | |
| }; | |
| c = { | |
| "X-TYPE-NAME": "SLICEUPLOAD", | |
| "X-FILE-SIZE": d.size, | |
| "X-FILE-CHUNK-END": (1 > l.total) || (l.index === l.total - 1) ? "true" : "false" | |
| }; | |
| if (s) { | |
| Ext.apply(c, { | |
| "X-TMP-FILE": s | |
| }) | |
| } | |
| if (window.XMLHttpRequest.prototype.sendAsBinary) { | |
| var r = q.formdata + ("" !== g ? g : "") + "\r\n--" + q.boundary + "--\r\n"; | |
| k = r | |
| } else { | |
| if (window.Blob) { | |
| var h = 0 | |
| , f = 0 | |
| , b = 0; | |
| var a = "\r\n--" + q.boundary + "--\r\n"; | |
| var n = q.formdata.length + a.length; | |
| var e; | |
| if (!Ext.isString(g)) { | |
| b = (new Uint8Array(g)).byteLength | |
| } else { | |
| b = g.length | |
| } | |
| n += b; | |
| e = new Uint8Array(n); | |
| for (h = 0; h < q.formdata.length; h++) { | |
| e[h] = q.formdata.charCodeAt(h) | |
| } | |
| if (!Ext.isString(g)) { | |
| e.set(new Uint8Array(g), h) | |
| } else { | |
| for (f = 0; f < g.length; f++) { | |
| e[h + f] = g.charCodeAt(f) | |
| } | |
| } | |
| h += b; | |
| for (f = 0; f < a.length; f++) { | |
| e[h + f] = a.charCodeAt(f) | |
| } | |
| k = e | |
| } else { | |
| var p; | |
| if (window.MSBlobBuilder) { | |
| p = new window.MSBlobBuilder() | |
| } else { | |
| if (window.BlobBuilder) { | |
| p = new window.BlobBuilder() | |
| } | |
| } | |
| p.append(q.formdata); | |
| if ("" !== g) { | |
| p.append(g) | |
| } | |
| p.append("\r\n--" + q.boundary + "--\r\n"); | |
| k = p.getBlob(); | |
| p = null | |
| } | |
| } | |
| } else { | |
| q.append("size", d.size); | |
| if (d.name) { | |
| q.append(this.opts.filefiledname, d.file, d.name) | |
| } else { | |
| q.append(this.opts.filefiledname, d.file) | |
| } | |
| k = q | |
| } | |
| this.conn = new Ext.data.Connection({ | |
| method: "POST", | |
| url: this.url, | |
| defaultHeaders: o, | |
| timeout: null | |
| }); | |
| var m = this.conn.request({ | |
| headers: c, | |
| html5upload: true, | |
| chunkmode: d.chunkmode, | |
| uploadData: k, | |
| success: this.onSuccess.createDelegate(this, [q, d, l], true), | |
| failure: this.onFail.createDelegate(this, [d], true), | |
| progress: this.onProgress.createDelegate(this, [d, d.chunkmode ? l.start : 0], true) | |
| }); | |
| d.reqId = m; | |
| if (d.isSubFile && d.rootObj) { | |
| d.rootObj.reqId = m | |
| } | |
| k = null | |
| }, | |
| onProgress: function(d, c, b) { | |
| if (d.lengthComputable) { | |
| c.size = c.size || 0; | |
| var a = Math.min(c.size, b + d.loaded); | |
| this.fireEvent("onProgress", this, c, a, c.size) | |
| } | |
| }, | |
| onSuccess: function(b, c, e, g, a) { | |
| var d = SYNO.SDS.DownloadStation.Utils.parseJsonData(b.responseText); | |
| if (d.success) { | |
| if (true === g.chunkmode && a.index < a.total - 1) { | |
| var f = d.tmpfile || d.data.tmpfile; | |
| if (!f || "" === f) { | |
| this.onError({}, g); | |
| return | |
| } | |
| a.index++; | |
| this.onUploadPartailFile(e, g, a, f); | |
| return | |
| } | |
| this.onFinish(d, g) | |
| } else { | |
| this.onError(d, g) | |
| } | |
| }, | |
| onFinishFolderTask: function(a, b) { | |
| var c = this.HTMLUploaderTask.taskList[b.id]; | |
| b.file = null; | |
| c.finishedFile = (b.isSubFile) ? c.finishedFile + 1 : c.finishedFile; | |
| if (c.status !== "CANCEL") { | |
| this.sendNextFile(b) | |
| } | |
| if (c.finishedFile != c.fileNum) { | |
| return | |
| } | |
| b.rootObj.status = (b.rootObj.errors) ? "FAIL" : "SUCCESS"; | |
| this.HTMLUploaderTask.taskUploadingIndex++; | |
| this.HTMLUploaderTask.blUploading = false; | |
| this.fireEvent("onComplete", this, a, b); | |
| this.uploadNext() | |
| }, | |
| onFinish: function(a, b) { | |
| if (b.isSubFile || b.isSubFolder) { | |
| this.fireEvent("onCompleteFolderFile", this, a, b); | |
| this.onFinishFolderTask(a, b); | |
| return | |
| } | |
| this.HTMLUploaderTask.taskUploadingIndex++; | |
| this.HTMLUploaderTask.blUploading = false; | |
| b.status = "SUCCESS"; | |
| this.fireEvent("onComplete", this, a, b); | |
| b.file = null; | |
| this.uploadNext() | |
| }, | |
| onError: function(c, d) { | |
| var b = d.isSubFile | |
| , a = d.isSubFolder; | |
| if (!b && !a) { | |
| this.HTMLUploaderTask.taskUploadingIndex++; | |
| this.HTMLUploaderTask.blUploading = false; | |
| d.status = "FAIL" | |
| } | |
| var e = SYNO.SDS.DownloadStation.Utils.getErrorString(c ? c.error.code : undefined); | |
| if (this.blAppenddata) { | |
| this.fireEvent("onError", this, e) | |
| } else { | |
| this.nbErrFiles++; | |
| if (this.objErrFiles[e]) { | |
| this.objErrFiles[e].push(d) | |
| } else { | |
| this.objErrFiles[e] = [d] | |
| } | |
| } | |
| if (a) { | |
| this.sendNextFile(d); | |
| return | |
| } else { | |
| if (b) { | |
| this.onFinishFolderTask(c, d); | |
| return | |
| } | |
| } | |
| this.uploadNext() | |
| }, | |
| onFail: function(a, b, d) { | |
| var c = SYNO.SDS.DownloadStation.Utils.parseJsonData(a.responseText); | |
| this.onError(c, d) | |
| }, | |
| onAllDone: function() { | |
| this.setInputFieldValue(""); | |
| if (!this.blAppenddata && this.getServerErrorCount() > 0) { | |
| this.fireEvent("onError", this, this.generateIntegratedErrorMsg()); | |
| this.objErrFiles = {} | |
| } | |
| this.fireEvent("onAllDone", this) | |
| }, | |
| getServerErrorCount: function() { | |
| return this.nbErrFiles | |
| }, | |
| generateIntegratedErrorMsg: function() { | |
| var b; | |
| if (this.HTMLUploaderTask.taskUploadingIndex === 1) { | |
| for (b in this.objErrFiles) { | |
| if (this.objErrFiles.hasOwnProperty(b)) { | |
| return b | |
| } | |
| } | |
| } | |
| var d = "", c, a; | |
| d += String.format(_T("download", "download_upload_erro_files"), this.nbErrFiles); | |
| for (b in this.objErrFiles) { | |
| if (this.objErrFiles.hasOwnProperty(b)) { | |
| c = this.objErrFiles[b]; | |
| d += "<br>" + b; | |
| for (a = 0; a < c.length; a++) { | |
| d += "<br>" + Ext.util.Format.htmlEncode(c[a].name) | |
| } | |
| } | |
| } | |
| return d | |
| }, | |
| uploadNext: function() { | |
| if (true === this.HTMLUploaderTask.blUploading) { | |
| return | |
| } | |
| if (false === this.fireEvent("onBeforeSubmit", this)) { | |
| return | |
| } | |
| var c, a; | |
| var b = this.getTaskSize(); | |
| for (a = this.HTMLUploaderTask.taskUploadingIndex; a < b; a++) { | |
| c = this.HTMLUploaderTask.taskList[a]; | |
| if (c && c.status === "NOT_STARTED") { | |
| this.HTMLUploaderTask.blUploading = true; | |
| c.status = "PROCESSING"; | |
| this.fireEvent("onOpen", this, c); | |
| this.onSendFile(c); | |
| break | |
| } | |
| this.HTMLUploaderTask.taskUploadingIndex++ | |
| } | |
| if (a >= b) { | |
| this.onAllDone() | |
| } | |
| }, | |
| onSendFile: function(a) { | |
| this.onUploadFile(a) | |
| }, | |
| onSubmit: function() { | |
| if (this.HTMLUploaderTask.taskUploadingIndex >= this.getTaskSize()) { | |
| this.fireEvent("onError", this, _DT("download", "download_empty_input_file")); | |
| return | |
| } | |
| this.uploadNext() | |
| }, | |
| setInputFieldValue: function(a) { | |
| if (this.textEl && !this.textEl.isDestroyed) { | |
| this.textEl.setValue(a) | |
| } | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.Uploader.HTMLUploader"); | |
| Ext.define("SYNO.SDS.DownloadStation.Uploader.HTMLUploader", { | |
| extend: "SYNO.SDS.DownloadStation.Uploader.HTML5Uploader", | |
| init: function(a) { | |
| a.container.mon(this, a.opts.listeners) | |
| }, | |
| onAllSelect: function() { | |
| SYNO.SDS.DownloadStation.Uploader.HTMLUploader.superclass.onAllSelect.apply(this, arguments); | |
| this.initTaskData() | |
| }, | |
| onSuccess: function(a, b) { | |
| this.fireEvent("onComplete", a, b.result); | |
| this.fireEvent("onAllDone", this) | |
| }, | |
| onFailure: function(a, b) { | |
| this.fireEvent("onError", this, SYNO.SDS.DownloadStation.Utils.getErrorString(b.result.error.code)); | |
| this.fireEvent("onAllDone", this) | |
| }, | |
| onSubmit: function(a) { | |
| if (false !== this.fireEvent("onBeforeSubmit", this)) { | |
| var b = a.getForm().findField(this.opts.filefiledname).getValue(); | |
| if (b === "") { | |
| this.fireEvent("onError", this, _DT("download", "download_empty_input_file")); | |
| return | |
| } else { | |
| if (!this.checkAllowFiletype(b)) { | |
| this.fireEvent("onError", this, _T("download", "download_error_wrong_file_format")); | |
| return | |
| } | |
| } | |
| a.getForm().doAction("apply", { | |
| scope: this, | |
| success: this.onSuccess, | |
| failure: this.onFailure | |
| }) | |
| } | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.Uploader"); | |
| SYNO.SDS.DownloadStation.Uploader.Utils = {}; | |
| SYNO.SDS.DownloadStation.Uploader.Utils = Ext.apply({ | |
| getButtonTemplate: function(a) { | |
| if (SYNO.SDS.DownloadStation.Uploader.Utils.isSupportHTML5Upload()) { | |
| var b = Ext.id(); | |
| return { | |
| itemId: "htmlfield", | |
| name: "htmlfield", | |
| synotype: "indent", | |
| xtype: "syno_compositefield", | |
| hideMode: "display", | |
| fieldLabel: _T("download", "download_lbl_input_file"), | |
| defaults: { | |
| hideLabel: true | |
| }, | |
| items: [{ | |
| xtype: "syno_textfield", | |
| readOnly: true, | |
| name: "MultiText", | |
| width: 205 | |
| }, { | |
| xtype: "syno_button", | |
| text: _T("download", "upload_browse"), | |
| handler: function(c, d) { | |
| d.preventDefault(); | |
| Ext.fly(b).dom.click() | |
| } | |
| }, Ext.apply({ | |
| itemId: "htmlfield", | |
| xtype: "textfield", | |
| hideMode: "display", | |
| inputType: "file", | |
| autoCreate: { | |
| id: b, | |
| tag: "input", | |
| type: "file", | |
| multiple: "multiple", | |
| style: "width:1px;height:1px;z-index:-1;opacity: 0;filter:alpha(opacity=0);" | |
| } | |
| }, a || {})] | |
| } | |
| } else { | |
| return Ext.apply({ | |
| itemId: "htmlfield", | |
| name: "htmlfield", | |
| xtype: "syno_filebutton", | |
| fieldLabel: _T("download", "download_lbl_input_file"), | |
| buttonOnly: false, | |
| buttonMargin: 5, | |
| listeners: { | |
| afterrender: function(c) { | |
| this.updateFileInputStyle.defer(500, c) | |
| } | |
| } | |
| }, a || {}) | |
| } | |
| } | |
| }, SYNO.SDS.HTML5Utils); | |
| Ext.define("SYNO.SDS.DownloadStation.Uploader.Uploader", { | |
| extend: "Ext.util.Observable", | |
| constructor: function(a) { | |
| Ext.apply(this, a); | |
| this.addEvents("beforedrop"); | |
| SYNO.SDS.DownloadStation.Uploader.Uploader.superclass.constructor.call(this, a) | |
| }, | |
| init: function(a) { | |
| this.container = a; | |
| this.generateUploadOpts(); | |
| a.mon(a, "afterlayout", this.initUploader, this, { | |
| single: true | |
| }) | |
| }, | |
| generateUploadOpts: function() { | |
| this.opts = Ext.apply({ | |
| limitSize: 2147482624, | |
| limitFiles: 100, | |
| startId: "", | |
| url: "", | |
| listeners: this.getUploadListeners() | |
| }, this.getOpts()); | |
| this.htmlopts = Ext.apply({ | |
| dropcss: "file-drop-curved", | |
| droptext: _DT("filetable", "drop_file"), | |
| instantStart: false, | |
| bldropBody: false, | |
| listeners: { | |
| scope: this, | |
| onBeforeDropfile: this.onBeforeDropfile | |
| } | |
| }, this.getHTML5Opts()) | |
| }, | |
| getOpts: function() { | |
| return {} | |
| }, | |
| getHTML5Opts: function() { | |
| return {} | |
| }, | |
| getUploadListeners: function() { | |
| return { | |
| scope: this.container, | |
| onBeforeSubmit: this.onBeforeSubmit, | |
| onAllSelect: this.onAllSelect, | |
| onComplete: this.onComplete, | |
| onAllDone: this.onAllDone, | |
| onError: this.onError, | |
| onErrorStr: this.onErrorStr | |
| } | |
| }, | |
| formWebAPIUrl: function(b) { | |
| var a = "webapi/entry.cgi/"; | |
| if (Ext.isDefined(b)) { | |
| a += b | |
| } | |
| return a | |
| }, | |
| initUploader: function(a) { | |
| if (this.opts.startId) { | |
| var b = Ext.getCmp(this.opts.startId); | |
| if (b) { | |
| a.mon(b, "click", function(c) { | |
| this.onSubmit(a) | |
| }, this) | |
| } | |
| } | |
| if (SYNO.SDS.DownloadStation.Uploader.Utils.isSupportHTML5Upload()) { | |
| this.initHTML5Uploader(a); | |
| this.uploader.on("onApplyWebAPIParamsIntoRequest", this.applyFormDataForHTML5Uploader, this) | |
| } else { | |
| this.initHTMLUploader(a); | |
| this.uploader.on("onApplyWebAPIParamsIntoRequest", this.applyFormDataForHTMLUploader, a) | |
| } | |
| }, | |
| initHTML5Uploader: function(a) { | |
| if (!this.uploader) { | |
| this.uploader = new SYNO.SDS.DownloadStation.Uploader.HTML5Uploader(Ext.apply({ | |
| limitSize: this.opts.limitSize, | |
| limitFiles: this.opts.limitFiles | |
| }, this.htmlopts || {}),{ | |
| container: a, | |
| opts: this.opts, | |
| files: this.files | |
| }) | |
| } | |
| }, | |
| initHTMLUploader: function(a) { | |
| if (!this.uploader) { | |
| this.uploader = new SYNO.SDS.DownloadStation.Uploader.HTMLUploader(Ext.apply({ | |
| limitSize: this.opts.limitSize | |
| }, this.htmlopts || {}),{ | |
| container: a, | |
| opts: this.opts | |
| }) | |
| } | |
| }, | |
| onSubmit: function(a) { | |
| this.uploader.onSubmit(a) | |
| }, | |
| applyFormDataForHTML5Uploader: function(b) { | |
| var a = Ext.apply(this.getWebAPIInfoForHTML5Uploader.call(this.container), this.getWebAPIParamsForHTML5Uploader.call(this.container)); | |
| Ext.apply(b.opts.params, a) | |
| }, | |
| getWebAPIInfoForHTML5Uploader: function() { | |
| return { | |
| api: this.getWebAPIName(), | |
| method: this.getWebAPIMethod(), | |
| version: this.getWebAPIVersion() | |
| } | |
| }, | |
| getWebAPIParamsForHTML5Uploader: Ext.emptyFn, | |
| applyFormDataForHTMLUploader: Ext.emptyFn, | |
| onBeforeSubmit: Ext.emptyFn, | |
| onAllSelect: Ext.emptyFn, | |
| onComplete: Ext.emptyFn, | |
| onAllDone: Ext.emptyFn, | |
| onError: Ext.emptyFn, | |
| onErrorStr: Ext.emptyFn, | |
| onBeforeDropfile: function(d, c, b, a) { | |
| if (this.fireEvent("beforedrop", d, b) !== false) { | |
| a.fn.apply(a.scope, [a.files]) | |
| } | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.Settings"); | |
| Ext.define("SYNO.SDS.DownloadStation.Settings.FileUploader", { | |
| extend: "SYNO.SDS.DownloadStation.Uploader.Uploader", | |
| getOpts: function() { | |
| return { | |
| limitSize: this.container.ADD_MAXSIZE || 104857600, | |
| limitFiles: this.container.ADD_MAXLIMIT || 50, | |
| startId: this.startId | |
| } | |
| }, | |
| getHTML5Opts: function() { | |
| return { | |
| url: this.formWebAPIUrl(this.api), | |
| allowfilters: this.container.ALLOWFILTERS, | |
| filefiledname: this.container.FILEFILEDNAME | |
| } | |
| }, | |
| onBeforeSubmit: function(a) { | |
| a.fireEvent("onApplyWebAPIParamsIntoRequest", a) | |
| }, | |
| onComplete: function(b, a) { | |
| this.module.afterActionHandler(); | |
| this.owner.onCloseHandler() | |
| }, | |
| onError: function(b, a, c) { | |
| this.owner.setStatusError({ | |
| text: a, | |
| clear: true | |
| }) | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.Settings"); | |
| Ext.define("SYNO.SDS.DownloadStation.Settings.DLMFileHosting", { | |
| extend: "SYNO.SDS.DownloadStation.Settings.GridPanel", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| var b = this.getConfig(a); | |
| this.callParent([b]); | |
| this.defineBehaviors() | |
| }, | |
| getConfig: function(a) { | |
| this.webapiDelete = { | |
| api: "SYNO.DownloadStation2.Settings.FileHosting", | |
| method: "delete", | |
| version: 2 | |
| }; | |
| this.updateBtnTask = new Ext.util.DelayedTask(this.updateBtn,this); | |
| this.enableColumn = new SYNO.ux.SDS.DownloadStation.Settings.EnableColumn({ | |
| header: _DT("common", "enabled"), | |
| dataIndex: "enabled", | |
| enableFastSelectAll: true, | |
| align: "center", | |
| width: 90, | |
| isIgnore: function(f, c) { | |
| var d = c.get("can_be_disabled"); | |
| var e = Ext.isEmpty(d) ? true : d; | |
| return !e | |
| }, | |
| renderer: function(i, f, d) { | |
| var e = d.get("can_be_disabled"); | |
| var h = Ext.isEmpty(e) ? true : e; | |
| var g = (!h ? "disabled-checked" : ("gray" === i ? "grayed" : i ? "checked" : "unchecked")) | |
| , c = (g === "grayed") ? "mixed" : (g === "checked") | |
| , j = (d) ? d.id + "_" + this.dataIndex : Ext.id(); | |
| f = f || {}; | |
| f.attr = 'aria-labelledby="' + j + '" for="' + j + '"'; | |
| return String.format('<div class="syno-ux-grid-enable-column-{0}" aria-label="' + this.orgHeader + '" role="checkbox" aria-checked="{1}" tabIndex="-1" id="{2}"></div>', g, c, j) | |
| } | |
| }); | |
| this.store = this.createStore(); | |
| this.cm = this.createColModel(); | |
| this.sm = this.createSelectionModel(); | |
| var b = { | |
| border: false, | |
| enableHdMenu: false, | |
| autoExpandColumn: "description", | |
| tbar: { | |
| defaults: { | |
| xtype: "syno_button", | |
| scope: this | |
| }, | |
| items: [{ | |
| text: _T("common", "add"), | |
| itemId: "upload", | |
| handler: this.addHandler | |
| }, { | |
| text: _T("common", "alt_edit"), | |
| itemId: "edit", | |
| disabled: true, | |
| handler: this.editHandler | |
| }, { | |
| text: _DT("common", "delete"), | |
| itemId: "delete", | |
| disabled: true, | |
| handler: this.deleteHandler | |
| }, "->", { | |
| xtype: "syno_textfilter", | |
| emptyText: _DT("common", "filter_label_text"), | |
| store: this.store, | |
| localFilter: true, | |
| localFilterField: "displayname" | |
| }] | |
| }, | |
| colModel: this.cm, | |
| selModel: this.sm, | |
| store: this.store, | |
| plugins: [this.enableColumn], | |
| listeners: { | |
| scope: this, | |
| rowdblclick: function(c, f, d) { | |
| this.editHandler() | |
| } | |
| } | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| defineBehaviors: function() { | |
| var a = this.getTopToolbar(); | |
| this.btnDelete = a.getComponent("delete"); | |
| this.btnEdit = a.getComponent("edit") | |
| }, | |
| createStore: function() { | |
| var a = new SYNO.API.Store({ | |
| api: "SYNO.DownloadStation2.Settings.FileHosting", | |
| method: "list", | |
| version: 2, | |
| autoDestory: true, | |
| autoLoad: true, | |
| appWindow: this, | |
| sortInfo: { | |
| field: "name", | |
| direction: "ASC" | |
| }, | |
| reader: new Ext.data.JsonReader({ | |
| idProperty: "name", | |
| fields: [{ | |
| name: "description", | |
| convert: this.descriptionConverter | |
| }, { | |
| name: "enabled" | |
| }, { | |
| name: "name" | |
| }, { | |
| name: "type" | |
| }, { | |
| name: "displayname" | |
| }, { | |
| name: "version" | |
| }, { | |
| name: "removable" | |
| }, { | |
| name: "username" | |
| }, { | |
| name: "valid" | |
| }, { | |
| name: "auth_needed" | |
| }, { | |
| name: "can_be_disabled" | |
| }, { | |
| name: "experimental" | |
| }] | |
| }), | |
| listeners: { | |
| scope: this, | |
| beforeload: function() { | |
| this.setStatusBusy({ | |
| text: _T("common", "loading") | |
| }) | |
| }, | |
| load: function() { | |
| this.clearStatusBusy() | |
| } | |
| } | |
| }); | |
| return a | |
| }, | |
| descriptionConverter: function(b, a) { | |
| var c = b; | |
| if (true === a.experimental) { | |
| c = c + " (" + _DT("common", "experimental") + ")" | |
| } | |
| return c | |
| }, | |
| descriptionRenderer: function(f, b, d, e, h, g) { | |
| var i = Ext.util.Format.htmlEncode(d.json.description); | |
| var c = '<font ext:qtip="' + Ext.util.Format.htmlEncode(i) + '">' + i + "</font>"; | |
| if (true === d.get("experimental")) { | |
| var a = Ext.util.Format.htmlEncode(_DT("common", "experimental")); | |
| c += '<font style="color: #96A0AA" ext:qtip="' + Ext.util.Format.htmlEncode(Ext.util.Format.htmlEncode(_DT("common", "experimental_plugin_desc"))) + '"> (' + a + ")</font>" | |
| } | |
| return c | |
| }, | |
| tooltipRenderer: function(f, b, a, g, e, c) { | |
| var d = Ext.util.Format.htmlEncode(f); | |
| b.attr += 'ext:qtip="' + Ext.util.Format.htmlEncode(d) + '"'; | |
| return d | |
| }, | |
| createColModel: function() { | |
| var a = new Ext.grid.ColumnModel({ | |
| defaultSortable: true, | |
| columns: [this.enableColumn, { | |
| header: _T("service", "service_host_name"), | |
| dataIndex: "displayname", | |
| width: 100, | |
| renderer: this.tooltipRenderer, | |
| scope: this | |
| }, { | |
| header: _DT("server", "title_server_desc"), | |
| dataIndex: "description", | |
| id: "description", | |
| renderer: this.descriptionRenderer, | |
| scope: this | |
| }, { | |
| header: _DT("download", "download_auth_user"), | |
| dataIndex: "username", | |
| id: "username", | |
| renderer: this.tooltipRenderer, | |
| scope: this | |
| }, { | |
| header: _DT("service", "service_host_version"), | |
| dataIndex: "version", | |
| width: 100 | |
| }] | |
| }); | |
| return a | |
| }, | |
| createSelectionModel: function() { | |
| var a = new Ext.grid.RowSelectionModel({ | |
| listeners: { | |
| scope: this, | |
| selectionchange: function() { | |
| this.updateBtnTask.delay(100) | |
| } | |
| } | |
| }); | |
| return a | |
| }, | |
| updateBtn: function() { | |
| var c = this.getSelectionModel().getSelections(); | |
| var b = false | |
| , a = false; | |
| if (1 === c.length && c[0].get("auth_needed")) { | |
| b = true | |
| } | |
| if (0 < c.length) { | |
| a = true | |
| } | |
| this.btnEdit.setDisabled(!b); | |
| this.btnDelete.setDisabled(!a) | |
| }, | |
| addHandler: function() { | |
| var a = new SYNO.SDS.DownloadStation.Settings.AddFileHostingDialog({ | |
| owner: this.owner, | |
| module: this | |
| }); | |
| a.load() | |
| }, | |
| editHandler: function() { | |
| var b = this.getSelectionModel().getSelections(); | |
| if (1 !== b.length) { | |
| return | |
| } | |
| if (Ext.isEmpty(b[0].get("auth_needed")) || !b[0].get("auth_needed")) { | |
| return | |
| } | |
| var a = new SYNO.SDS.DownloadStation.Settings.EditFileHostingDialog({ | |
| owner: this.owner, | |
| fileHostingGridPanel: this, | |
| uicomponents: this.uicomponents, | |
| hostData: b[0].data | |
| }); | |
| a.show() | |
| }, | |
| deleteHandler: function() { | |
| var d = this.getSelectionModel().getSelections(); | |
| var b = []; | |
| if (0 === d.length) { | |
| return | |
| } | |
| for (var a = 0; a < d.length; a++) { | |
| var c = d[a].data; | |
| if (!c.removable) { | |
| this.owner.getMsgBox().alert(_DT("tree", "leaf_downloadtask"), _DT("download", "user_filehosting_undelete")); | |
| return | |
| } | |
| b.push({ | |
| hostname: c.name, | |
| type: c.type | |
| }) | |
| } | |
| this.owner.getMsgBox().confirm(_DT("tree", "leaf_downloadtask"), _DT("download", "delete_filehosting_confirm"), function(e) { | |
| if ("yes" !== e) { | |
| return | |
| } | |
| this.setStatusBusy({ | |
| text: _T("common", "saving") | |
| }); | |
| SYNO.API.Request({ | |
| webapi: Ext.apply(this.webapiDelete, { | |
| params: { | |
| host: b | |
| } | |
| }), | |
| callback: function(i, g, h, f) { | |
| this.clearStatusBusy(); | |
| if (i) { | |
| this.store.reload(); | |
| return | |
| } | |
| this.owner.getMsgBox().alert(_T("tree", "leaf_downloadtask"), _T("error", "error_system_busy")); | |
| this.store.reload() | |
| }, | |
| scope: this | |
| }) | |
| }, this) | |
| }, | |
| isDirty: function() { | |
| var a = this.store.getModifiedRecords(); | |
| if (0 === a.length) { | |
| return false | |
| } | |
| return true | |
| }, | |
| getPanel: function() { | |
| return this | |
| }, | |
| afterActionHandler: function() { | |
| this.store.reload() | |
| }, | |
| onSettingsApply: function() { | |
| var a = this.store.getModifiedRecords(); | |
| var b = []; | |
| for (var c = 0; c < a.length; c++) { | |
| var d = { | |
| api: "SYNO.DownloadStation2.Settings.FileHosting", | |
| method: "set", | |
| version: 2, | |
| params: { | |
| hostname: a[c].get("name"), | |
| type: a[c].get("type"), | |
| enabled: a[c].get("enabled") | |
| } | |
| }; | |
| b.push(d) | |
| } | |
| this.setStatusBusy({ | |
| text: _T("common", "saving") | |
| }); | |
| this.sendWebAPI({ | |
| compound: { | |
| stopwhenerror: false, | |
| params: b | |
| }, | |
| callback: function(f, e) { | |
| this.clearStatusBusy(); | |
| if (!f || e.has_fail) { | |
| this.owner.getMsgBox().alert(_T("tree", "leaf_downloadtask"), _T("error", "error_system_busy")); | |
| return false | |
| } | |
| return true | |
| }, | |
| scope: this | |
| }); | |
| return true | |
| } | |
| }); | |
| Ext.define("SYNO.SDS.DownloadStation.Settings.EditFileHostingDialog", { | |
| extend: "SYNO.SDS.ModalWindow", | |
| FAKE_PASSWORD: "12345678", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| var b = this.fillConfig(a); | |
| this.callParent([b]); | |
| this.defineBehaviors() | |
| }, | |
| fillConfig: function(a) { | |
| this.webapiSet = { | |
| api: "SYNO.DownloadStation2.Settings.FileHosting", | |
| method: "set", | |
| version: 2 | |
| }; | |
| this.webapiVerify = { | |
| api: "SYNO.DownloadStation2.Settings.FileHosting", | |
| method: "verify", | |
| version: 2 | |
| }; | |
| var c = this.createForm(a); | |
| var b = { | |
| owner: a.owner, | |
| cls: "syno-dl-win", | |
| width: 510, | |
| height: 180, | |
| minWidth: 100, | |
| minHeight: 120, | |
| collapsible: false, | |
| autoScroll: false, | |
| constrainHeader: true, | |
| monitorResize: true, | |
| layout: "fit", | |
| items: [c], | |
| buttons: SYNO.SDS.DownloadStation.Utils.composeButtonCfg({ | |
| xtype: "syno_button", | |
| btnStyle: "blue", | |
| text: _DT("common", "ok"), | |
| scope: this, | |
| handler: this.applyHandler, | |
| disabled: _S("demo_mode"), | |
| tooltip: _S("demo_mode") ? _JSLIBSTR("uicommon", "error_demo") : undefined | |
| }, { | |
| xtype: "syno_button", | |
| text: _T("common", "cancel"), | |
| scope: this, | |
| handler: function() { | |
| this.closeHandler(false) | |
| } | |
| }), | |
| listeners: { | |
| scope: this, | |
| beforeshow: this.onBeforeShow, | |
| show: this.onAfterShow | |
| } | |
| }; | |
| Ext.apply(b, a); | |
| return b | |
| }, | |
| createForm: function(a) { | |
| var c = [{ | |
| xtype: "syno_compositefield", | |
| hideLabel: false, | |
| fieldLabel: _DT("download", "download_auth_user"), | |
| width: 300, | |
| items: [{ | |
| xtype: "syno_textfield", | |
| name: "username", | |
| width: 157, | |
| tabIndex: 1, | |
| listeners: { | |
| scope: this, | |
| change: this.clearFakePassword | |
| } | |
| }, { | |
| xtype: "syno_button", | |
| text: _DT("settings", "btn_verify_account"), | |
| disabled: _S("demo_mode"), | |
| tooltip: _S("demo_mode") ? _JSLIBSTR("uicommon", "error_demo") : "", | |
| scope: this, | |
| handler: this.VerifyAccountHandler | |
| }] | |
| }, { | |
| xtype: "syno_compositefield", | |
| hideLabel: false, | |
| fieldLabel: _T("common", "password"), | |
| width: 300, | |
| items: [{ | |
| xtype: "syno_textfield", | |
| textType: "password", | |
| name: "password", | |
| width: 157, | |
| tabIndex: 2, | |
| listeners: { | |
| scope: this, | |
| focus: this.clearFakePassword | |
| } | |
| }] | |
| }]; | |
| var b = { | |
| items: c, | |
| itemId: "editformpanel", | |
| labelAlign: "left", | |
| trackResetOnLoad: true, | |
| border: false, | |
| labelWidth: 161, | |
| padding: 0 | |
| }; | |
| b = Ext.apply(b, a); | |
| return new SYNO.ux.FormPanel(b) | |
| }, | |
| onBeforeShow: function() { | |
| this.setTitle(_DT("common", "alt_edit") + " " + this.hostData.displayname); | |
| if (!Ext.isEmpty(this.hostData.username)) { | |
| this.form.setValues({ | |
| username: this.hostData.username, | |
| password: this.FAKE_PASSWORD | |
| }) | |
| } | |
| }, | |
| onAfterShow: function() { | |
| if (Ext.isEmpty(this.hostData.username)) { | |
| this.form.findField("username").focus(false, 500) | |
| } | |
| }, | |
| checkValid: function(a) { | |
| var c = Ext.isEmpty(this.fieldUsername.getValue()); | |
| var b = Ext.isEmpty(this.fieldPassword.getValue()); | |
| if (!a && c && b) { | |
| this.setStatusError({ | |
| text: _DT("download", "download_msg_invalid_user") | |
| }); | |
| return false | |
| } | |
| if (!c && b) { | |
| this.setStatusError({ | |
| text: _DT("common", "error_empty_password") | |
| }); | |
| return false | |
| } | |
| if (c && !b) { | |
| this.setStatusError({ | |
| text: _DT("download", "download_msg_invalid_user") | |
| }); | |
| return false | |
| } | |
| return true | |
| }, | |
| applyHandler: function() { | |
| if (!this.checkValid(true)) { | |
| return | |
| } | |
| if (!this.form.isDirty()) { | |
| this.close(); | |
| return | |
| } | |
| this.setStatusBusy({ | |
| text: _T("common", "saving") | |
| }); | |
| SYNO.API.Request({ | |
| webapi: Ext.apply(this.webapiSet, { | |
| params: { | |
| hostname: this.hostData.name, | |
| type: this.hostData.type, | |
| username: this.fieldUsername.getValue(), | |
| password: this.fieldPassword.getValue() | |
| } | |
| }), | |
| callback: function(d, b, c, a) { | |
| this.clearStatusBusy(); | |
| if (d) { | |
| this.closeHandler(true); | |
| return | |
| } | |
| this.setStatusError({ | |
| text: this.getErrorMessage(b.code) | |
| }) | |
| }, | |
| scope: this | |
| }) | |
| }, | |
| getErrorMessage: function(a) { | |
| return _T("error", "error_system_busy") | |
| }, | |
| closeHandler: function(a) { | |
| if (a) { | |
| this.fileHostingGridPanel.store.reload() | |
| } | |
| this.close() | |
| }, | |
| VerifyAccountHandler: function() { | |
| if (!this.checkValid(false)) { | |
| return | |
| } | |
| var a = { | |
| hostname: this.hostData.name, | |
| type: this.hostData.type, | |
| username: this.fieldUsername.getValue() | |
| }; | |
| if (!this.isFakePasswordPresent()) { | |
| a.password = this.fieldPassword.getValue() | |
| } | |
| this.setStatusBusy({ | |
| text: _DT("settings", "verifying_account") | |
| }); | |
| SYNO.API.Request({ | |
| webapi: Ext.apply(this.webapiVerify, { | |
| params: a | |
| }), | |
| callback: function(g, e, f, d) { | |
| this.clearStatusBusy(); | |
| var b = _DT("common", "error_system"); | |
| var c = ""; | |
| if (g && !Ext.isEmpty(e.status)) { | |
| switch (e.status) { | |
| case 0: | |
| b = _DT("login", "error_cantlogin"); | |
| break; | |
| case 1: | |
| c = _DT("settings", "verify_free"); | |
| break; | |
| case 2: | |
| c = _DT("settings", "verify_premium"); | |
| break; | |
| default: | |
| break | |
| } | |
| } | |
| if (!Ext.isEmpty(c)) { | |
| this.setStatusOK({ | |
| text: c | |
| }) | |
| } else { | |
| this.setStatusError({ | |
| text: b | |
| }) | |
| } | |
| return | |
| }, | |
| scope: this | |
| }) | |
| }, | |
| defineBehaviors: function() { | |
| this.form = this.get("editformpanel").form; | |
| this.fieldUsername = this.form.findField("username"); | |
| this.fieldPassword = this.form.findField("password") | |
| }, | |
| isFakePasswordPresent: function() { | |
| return this.FAKE_PASSWORD === this.fieldPassword.originalValue | |
| }, | |
| clearFakePassword: function() { | |
| if (this.isFakePasswordPresent()) { | |
| this.fieldPassword.originalValue = ""; | |
| this.fieldPassword.setValue("") | |
| } | |
| } | |
| }); | |
| Ext.define("SYNO.SDS.DownloadStation.Settings.AddFileHostingDialog", { | |
| extend: "SYNO.SDS.ModalWindow", | |
| constructor: function(a) { | |
| var b = this.fillConfig(a); | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| this.submitBtnId = Ext.id(); | |
| var b = { | |
| owner: a.owner, | |
| cls: "syno-dl-win", | |
| width: 565, | |
| height: 184, | |
| shadow: true, | |
| minWidth: 100, | |
| minHeight: 100, | |
| collapsible: false, | |
| autoScroll: false, | |
| constrainHeader: true, | |
| plain: true, | |
| monitorResize: true, | |
| title: _DT("settings", "add_filehosting_template"), | |
| layout: "fit", | |
| items: [this.createFormPanel(a)], | |
| buttons: SYNO.SDS.DownloadStation.Utils.composeButtonCfg({ | |
| id: this.submitBtnId, | |
| text: _DT("common", "addto"), | |
| btnStyle: "blue", | |
| disabled: _S("demo_mode"), | |
| tooltip: _S("demo_mode") ? _JSLIBSTR("uicommon", "error_demo") : "" | |
| }, { | |
| text: _T("common", "alt_cancel"), | |
| handler: this.onCloseHandler, | |
| scope: this | |
| }), | |
| keys: [{ | |
| key: [10, 13], | |
| fn: this.onSubmit, | |
| scope: this | |
| }, { | |
| key: 27, | |
| fn: this.onCloseHandler, | |
| scope: this | |
| }] | |
| }; | |
| Ext.apply(b, a); | |
| return b | |
| }, | |
| createFormPanel: function(a) { | |
| return new SYNO.SDS.DownloadStation.Settings.AddFileHostingForm({ | |
| owner: this, | |
| module: a.module, | |
| files: a.files, | |
| submitBtnId: this.submitBtnId | |
| }) | |
| }, | |
| onCloseHandler: function() { | |
| this.close() | |
| }, | |
| load: function() { | |
| this.show() | |
| } | |
| }); | |
| Ext.define("SYNO.SDS.DownloadStation.Settings.AddFileHostingForm", { | |
| extend: "SYNO.API.Form.FormPanel", | |
| ADD_MAXLIMIT: 1, | |
| ADD_MAXSIZE: 104857600, | |
| FILEFILEDNAME: "plugin", | |
| ALLOWFILTERS: ["host"], | |
| constructor: function(a) { | |
| var b = this.fillConfig(a); | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| var c = new SYNO.SDS.DownloadStation.Settings.FileUploader({ | |
| api: this.getWebAPIName(), | |
| files: a.files, | |
| startId: a.submitBtnId | |
| }); | |
| var b = { | |
| api: this.getWebAPIName(), | |
| method: this.getWebAPIMethod(), | |
| version: this.getWebAPIVersion(), | |
| xtype: "syno_formpanel", | |
| fileUpload: true, | |
| itemId: "formpanel", | |
| labelAlign: "left", | |
| trackResetOnLoad: true, | |
| waitMsgTarget: true, | |
| border: false, | |
| labelWidth: 161, | |
| plugins: [c], | |
| items: [SYNO.SDS.DownloadStation.Uploader.Utils.getButtonTemplate({ | |
| name: this.FILEFILEDNAME | |
| }), { | |
| xtype: "syno_displayfield", | |
| value: "( eg. filehosting.host)" | |
| }] | |
| }; | |
| Ext.apply(b, a); | |
| return b | |
| }, | |
| getWebAPIName: function() { | |
| return "SYNO.DownloadStation2.Settings.FileHosting" | |
| }, | |
| getWebAPIMethod: function() { | |
| return "create" | |
| }, | |
| getWebAPIVersion: function() { | |
| return 2 | |
| } | |
| }); | |
| Ext.define("SYNO.ux.SDS.DownloadStation.Settings.EnableColumn", { | |
| extend: "SYNO.ux.EnableColumn", | |
| onBoxClick: function() { | |
| this.callParent(arguments); | |
| return false | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.Settings"); | |
| Ext.define("SYNO.SDS.DownloadStation.Settings.DLMBtSearch", { | |
| extend: "SYNO.SDS.DownloadStation.Settings.GridPanel", | |
| fillConfig: function(a) { | |
| this.btntask = new Ext.util.DelayedTask(this.updateBtnStatus,this); | |
| var c = new SYNO.ux.EnableColumn({ | |
| align: "center", | |
| header: _DT("common", "enabled"), | |
| dataIndex: "enable", | |
| enableFastSelectAll: true, | |
| width: 90 | |
| }); | |
| this.updateEnable = true; | |
| this.CheckUpdate = false; | |
| this.store = this.createStore(); | |
| var b = { | |
| stripeRows: true, | |
| border: false, | |
| tbar: { | |
| defaults: { | |
| xtype: "syno_button", | |
| scope: this | |
| }, | |
| items: [{ | |
| text: _T("common", "add"), | |
| itemId: "upload", | |
| handler: function(d) { | |
| this.createHandler() | |
| } | |
| }, { | |
| text: _T("common", "alt_edit"), | |
| itemId: "edit", | |
| disabled: true, | |
| handler: this.editHandler | |
| }, { | |
| text: _DT("common", "delete"), | |
| itemId: "delete", | |
| disabled: true, | |
| handler: this.deleteHandler | |
| }, { | |
| text: _DT("settings", "settings_btn_check_update"), | |
| itemId: "updatecheck", | |
| disabled: _S("demo_mode") ? true : false, | |
| handler: this.CheckUpdateHandler | |
| }, { | |
| text: _DT("download", "filehost_update_all"), | |
| itemId: "updateall", | |
| disabled: true, | |
| handler: this.UpdateAllHandler | |
| }] | |
| }, | |
| selModel: new Ext.grid.RowSelectionModel({ | |
| singleSelect: false, | |
| listeners: { | |
| scope: this, | |
| selectionchange: function() { | |
| this.btntask.delay(100) | |
| } | |
| } | |
| }), | |
| colModel: new Ext.grid.ColumnModel({ | |
| columns: [c, { | |
| header: _T("common", "name"), | |
| dataIndex: "displayname", | |
| width: 120 | |
| }, { | |
| header: _DT("server", "title_server_desc"), | |
| dataIndex: "description", | |
| id: "description", | |
| renderer: function(g, e, f) { | |
| var d = Ext.util.Format.htmlEncode(g); | |
| e.attr = 'ext:qtip="' + Ext.util.Format.htmlEncode(d) + '"'; | |
| return d | |
| } | |
| }, { | |
| header: _DT("service", "service_host_version"), | |
| dataIndex: "version", | |
| width: 90, | |
| renderer: function(i, f, h, e, g, d) { | |
| if ((h.data.version < h.data.newversion) && this.updatedwlink) { | |
| i = Ext.util.Format.htmlEncode(h.data.version); | |
| i += '<span class="syno-dl-settings-btsearch"'; | |
| i += ' ext:qtip="'; | |
| i += _DT("settings", "filehosting_update_item"); | |
| i += ' "> '; | |
| i += "(" + _DT("download", "rss_update") + ")</span>" | |
| } else { | |
| if ((h.data.version === "add") && this.updatedwlink) { | |
| i = '<span class="syno-dl-settings-btsearch"'; | |
| i += ' ext:qtip="' + _T("common", "add") + ' "> '; | |
| i += _T("common", "add") + "</span>" | |
| } | |
| } | |
| return i | |
| } | |
| .createDelegate(this) | |
| }] | |
| }), | |
| plugins: [c], | |
| store: this.store, | |
| autoExpandColumn: "description", | |
| enableHdMenu: false, | |
| listeners: { | |
| scope: this, | |
| afterrender: { | |
| fn: function() { | |
| Ext.get(c.box_id).hide() | |
| }, | |
| single: true | |
| }, | |
| beforedestroy: function() { | |
| this.btntask.cancel() | |
| }, | |
| cellclick: this.UpdatePlugin, | |
| rowdblclick: function(d, g, f) { | |
| if (this._S("is_admin")) { | |
| this.editHandler() | |
| } | |
| } | |
| } | |
| }; | |
| if (SYNO.SDS.DownloadStation.Uploader.Utils.isSupportHTML5Upload()) { | |
| b.plugins.push(new SYNO.SDS.DownloadStation.Settings.FileUploader({ | |
| listeners: { | |
| scope: this, | |
| beforedrop: this.onBeforeDropFile | |
| } | |
| })) | |
| } | |
| return Ext.apply(b, a) | |
| }, | |
| createStore: function() { | |
| var a = new SYNO.API.JsonStore({ | |
| api: this.getWebAPIName(), | |
| method: "list", | |
| version: 1, | |
| autoDestroy: true, | |
| autoLoad: true, | |
| appWindow: this, | |
| sortInfo: { | |
| field: "name", | |
| direction: "ASC" | |
| }, | |
| idProperty: "name", | |
| fields: ["enable", "name", "displayname", "description", "user", "version", "newversion", "accountsupport"], | |
| root: "plugins", | |
| listeners: { | |
| scope: this, | |
| beforeload: function() { | |
| this.setStatusBusy({ | |
| text: _T("common", "loading") | |
| }) | |
| }, | |
| load: function(b) { | |
| if (true === this.updateEnable) { | |
| this.updateEnable = false; | |
| this.updateEnableColume(b) | |
| } | |
| if (true === this.CheckUpdate) { | |
| this.CheckUpdate = false; | |
| this.CheckUpdateHandler() | |
| } | |
| this.clearStatusBusy() | |
| }, | |
| exception: function(e, f, h, d, c, b) { | |
| var g = SYNO.SDS.DownloadStation.Utils.getErrorString((c && c.code) ? c.code : -1); | |
| this.owner.getMsgBox().alert(_T("tree", "leaf_downloadtask"), g); | |
| this.clearStatusBusy() | |
| } | |
| } | |
| }); | |
| return a | |
| }, | |
| onBeforeDropFile: function(b, a) { | |
| this.createHandler(a); | |
| return false | |
| }, | |
| defineBehaviors: function() { | |
| var a = this.getTopToolbar(); | |
| this.btnDelete = a.getComponent("delete"); | |
| this.btnUpload = a.getComponent("upload"); | |
| this.btnEdit = a.getComponent("edit"); | |
| this.btnUpdateAll = a.getComponent("updateall"); | |
| this.btnUndateCheck = a.getComponent("updatecheck"); | |
| if (!_S("is_admin")) { | |
| this.btnDelete.hide(); | |
| this.btnUpload.hide(); | |
| this.btnEdit.hide(); | |
| this.btnUpdateAll.hide(); | |
| this.btnUndateCheck.hide() | |
| } | |
| }, | |
| updateEnableColume: function(b) { | |
| if (0 === b.getCount()) { | |
| return | |
| } | |
| var a = this.appWin.appInstance.getUserSettings("btsearchplugins") || []; | |
| var d = {}; | |
| var f = []; | |
| for (var e = 0; e < b.getCount(); e++) { | |
| var g = b.getAt(e).data; | |
| g.enable = true; | |
| for (var c = 0; c < a.length; c++) { | |
| if (a[c].name === g.name) { | |
| g.enable = (false === a[c].enable) ? false : true; | |
| break | |
| } | |
| } | |
| f.push(g) | |
| } | |
| d.plugins = f; | |
| this.getStore().loadData(d); | |
| return | |
| }, | |
| AtLeastOneSelected: function() { | |
| var b = this.store.getRange(); | |
| for (var a = 0; a < b.length; a++) { | |
| if (b[a].data.enable === true) { | |
| return true | |
| } | |
| } | |
| return false | |
| }, | |
| editHandler: function() { | |
| var a = this.getSelectionModel(); | |
| var c = a.getSelections(); | |
| if (c.length === 1 && c[0].data.accountsupport) { | |
| var b = new SYNO.SDS.DownloadStation.Settings.EditPluginDialog({ | |
| owner: this.owner, | |
| api: this.getWebAPIName(), | |
| pluginName: c[0].data.name, | |
| displayname: c[0].data.displayname, | |
| user: c[0].data.user | |
| }); | |
| b.load() | |
| } | |
| }, | |
| CheckUpdateHandler: function() { | |
| this.owner.getEl().mask(_DT("settings", "settings_check_updating")); | |
| this.sendWebAPI({ | |
| api: this.getWebAPIName(), | |
| method: "update_check", | |
| version: 1, | |
| scope: this, | |
| callback: this.onCheckUpdateDone | |
| }) | |
| }, | |
| onCheckUpdateDone: function(g, e, c) { | |
| var f, a; | |
| var d = true; | |
| if (this.owner.getEl().isMasked()) { | |
| this.owner.getEl().unmask() | |
| } | |
| if (!g) { | |
| var b = _T("error", "error_system_busy"); | |
| if (e && e.code) { | |
| b = SYNO.SDS.DownloadStation.Utils.getErrorString(e.code) | |
| } | |
| this.owner.getMsgBox().alert(_T("tree", "leaf_downloadtask"), b) | |
| } else { | |
| this.updatedwlink = e.downloadlink; | |
| a = this.getStore(); | |
| Ext.each(e.searchplugins, function(i, h, j) { | |
| f = a.getById(i.name); | |
| if (f && (f.data.version < i.version)) { | |
| f.data.newversion = i.version; | |
| f.commit(); | |
| d = false | |
| } else { | |
| if (!f) { | |
| a.add(new a.recordType({ | |
| enable: "", | |
| name: i.name, | |
| displayname: i.name, | |
| version: "add", | |
| description: i.description, | |
| user: "no", | |
| newversion: i.version, | |
| accountsupport: "" | |
| })); | |
| d = false | |
| } | |
| } | |
| }); | |
| if (d) { | |
| this.owner.getMsgBox().alert(_DT("settings", "settings_btn_check_update"), _DT("settings", "no_btsearch_update")) | |
| } else { | |
| if (d) { | |
| this.btnUpdateAll.disable() | |
| } else { | |
| this.btnUpdateAll.enable() | |
| } | |
| } | |
| } | |
| this.owner.clearStatus() | |
| }, | |
| UpdatePlugin: function(a, i, c, g) { | |
| var f = g.getTarget(); | |
| var b = Ext.get(f); | |
| if (f && b && b.is("span[class=syno-dl-settings-btsearch]")) { | |
| var h = a.getStore().getAt(i); | |
| if (("version" === a.getColumnModel().getDataIndex(c)) && (h.data.version < h.data.newversion || "add" === h.data.version)) { | |
| var d = []; | |
| d.push(h.data.name); | |
| this.owner.getEl().mask(); | |
| this.sendWebAPI({ | |
| api: this.getWebAPIName(), | |
| method: "update", | |
| version: 1, | |
| scope: this, | |
| params: { | |
| plugin_names: d | |
| }, | |
| callback: this.UpdatePluginDone | |
| }) | |
| } | |
| } | |
| }, | |
| UpdatePluginDone: function(d, c, b) { | |
| if (this.owner.getEl().isMasked()) { | |
| this.owner.getEl().unmask() | |
| } | |
| if (!d) { | |
| var a = _T("error", "error_system_busy"); | |
| if (c && c.code) { | |
| a = SYNO.SDS.DownloadStation.Utils.getErrorString(c.code) | |
| } | |
| this.owner.getMsgBox().alert(_T("tree", "leaf_downloadtask"), a) | |
| } else { | |
| this.CheckUpdate = true; | |
| this.afterActionHandler() | |
| } | |
| }, | |
| UpdateAllHandler: function() { | |
| var d; | |
| var c = []; | |
| var a = this.getStore(); | |
| for (var b = 0; b < a.getCount(); b++) { | |
| d = a.getAt(b); | |
| if (d && ((d.data.version < d.data.newversion) || "add" === d.data.version)) { | |
| c.push(d.data.name) | |
| } | |
| } | |
| if (c.length >= 1) { | |
| this.owner.getEl().mask(_DT("download", "updating")); | |
| this.sendWebAPI({ | |
| api: this.getWebAPIName(), | |
| method: "update", | |
| version: 1, | |
| scope: this, | |
| params: { | |
| plugin_names: c | |
| }, | |
| callback: this.UpdateAllDone | |
| }) | |
| } | |
| }, | |
| UpdateAllDone: function(d, c, b) { | |
| if (this.owner.getEl().isMasked()) { | |
| this.owner.getEl().unmask() | |
| } | |
| if (!d) { | |
| var a = _T("error", "error_system_busy"); | |
| if (c && c.code) { | |
| a = SYNO.SDS.DownloadStation.Utils.getErrorString(c.code) | |
| } | |
| this.owner.getMsgBox().alert(_T("tree", "leaf_downloadtask"), a) | |
| } else { | |
| this.btnUpdateAll.disable(); | |
| this.CheckUpdate = true; | |
| this.afterActionHandler() | |
| } | |
| }, | |
| createHandler: function(b) { | |
| var a = new SYNO.SDS.DownloadStation.Settings.AddSearchPluginDialog({ | |
| owner: this.owner, | |
| module: this, | |
| files: b | |
| }); | |
| a.load() | |
| }, | |
| deleteHandler: function() { | |
| var a = this.getSelectionModel(); | |
| var d = a.getSelections(); | |
| var b = []; | |
| if (d.length < 1) { | |
| return | |
| } | |
| for (var c = 0; c < d.length; c++) { | |
| if (d[c].get("user") === true) { | |
| b.push(d[c].get("name")) | |
| } | |
| } | |
| if (b.length !== d.length) { | |
| this.owner.getMsgBox().alert(_DT("tree", "leaf_downloadtask"), _DT("download", "plugin_undelete")); | |
| return | |
| } | |
| this.owner.getMsgBox().confirm(_DT("tree", "leaf_downloadtask"), _DT("download", "delete_plugin_confirm"), function(e) { | |
| if ("yes" == e) { | |
| this.sendWebAPI({ | |
| api: this.getWebAPIName(), | |
| method: "delete", | |
| params: { | |
| plugin_names: b | |
| }, | |
| version: 1, | |
| scope: this, | |
| callback: function(i, h, g) { | |
| if (!i) { | |
| var f = _DT("common", "error_system"); | |
| if (h && h.code) { | |
| f = SYNO.SDS.DownloadStation.Utils.getErrorString(h.code) | |
| } | |
| this.owner.getMsgBox().alert(_T("tree", "leaf_downloadtask"), f) | |
| } else { | |
| this.afterActionHandler() | |
| } | |
| } | |
| }) | |
| } | |
| }, this); | |
| return | |
| }, | |
| updateBtnStatus: function() { | |
| var a = this.getSelectionModel(); | |
| var c = a.getSelections(); | |
| if (c.length > 0) { | |
| this.btnDelete.enable() | |
| } else { | |
| this.btnDelete.disable() | |
| } | |
| for (var b = 0; b < c.length; b++) { | |
| if (c[b].get("version") === "add") { | |
| this.btnDelete.disable(); | |
| break | |
| } | |
| } | |
| if (_S("is_admin")) { | |
| if (c.length === 1 && c[0].data.accountsupport === true && c[0].get("version") !== "add") { | |
| this.btnEdit.enable() | |
| } else { | |
| this.btnEdit.disable() | |
| } | |
| } | |
| }, | |
| reset: function() { | |
| this.getStore().rejectChanges() | |
| }, | |
| isDirty: function() { | |
| return this.getStore().getModifiedRecords().length > 0 | |
| }, | |
| afterActionHandler: function() { | |
| this.updateEnable = true; | |
| this.getStore().reload() | |
| }, | |
| onSettingsApply: function() { | |
| if (!this.isValid()) { | |
| return false | |
| } | |
| var a = this.getStore(); | |
| var b = []; | |
| a.each(function(c) { | |
| b.push({ | |
| enable: c.get("enable"), | |
| name: c.get("name") | |
| }) | |
| }, this); | |
| this.appWin.appInstance.setUserSettings("btsearchplugins", b); | |
| this.getStore().commitChanges(); | |
| return true | |
| }, | |
| isValid: function() { | |
| var a = []; | |
| this.getStore().each(function(b) { | |
| a.push(b.get("enable")) | |
| }, this); | |
| if (-1 === a.indexOf(true)) { | |
| this.settingsWin.getMsgBox().alert("", _DT("download", "select_one_plugin")); | |
| return false | |
| } | |
| return true | |
| }, | |
| getWebAPIName: function() { | |
| return "SYNO.DownloadStation2.Settings.BTSearch" | |
| } | |
| }); | |
| Ext.define("SYNO.SDS.DownloadStation.Settings.EditPluginDialog", { | |
| extend: "SYNO.SDS.ModalWindow", | |
| constructor: function(a) { | |
| Ext.apply(this, a || {}); | |
| var b = this.fillConfig(a); | |
| this.callParent([b]); | |
| this.defineBehaviors() | |
| }, | |
| fillConfig: function(a) { | |
| var b = { | |
| owner: a.owner, | |
| api: a.api, | |
| cls: "syno-dl-win", | |
| width: 510, | |
| height: 180, | |
| minWidth: 100, | |
| minHeight: 120, | |
| collapsible: false, | |
| autoScroll: false, | |
| constrainHeader: true, | |
| monitorResize: true, | |
| title: _DT("common", "alt_edit") + " " + this.displayname, | |
| layout: "fit", | |
| items: [this.initFormConfig()], | |
| buttons: SYNO.SDS.DownloadStation.Utils.composeButtonCfg({ | |
| text: _DT("common", "ok"), | |
| disabled: this._S("demo_mode"), | |
| btnStyle: "blue", | |
| tooltip: this._S("demo_mode") ? _JSLIBSTR("uicommon", "error_demo") : "", | |
| handler: this.Apply, | |
| scope: this | |
| }, { | |
| text: _T("common", "alt_cancel"), | |
| handler: this.onCloseHandler, | |
| scope: this | |
| }), | |
| keys: [{ | |
| key: [10, 13], | |
| fn: this.Apply, | |
| scope: this | |
| }, { | |
| key: 27, | |
| fn: this.onCloseHandler, | |
| scope: this | |
| }] | |
| }; | |
| Ext.apply(b, a); | |
| return b | |
| }, | |
| initFormConfig: function() { | |
| var a = { | |
| xtype: "syno_formpanel", | |
| itemId: "editformpanel", | |
| labelAlign: "left", | |
| trackResetOnLoad: true, | |
| waitMsgTarget: true, | |
| border: false, | |
| padding: 0, | |
| labelWidth: 161, | |
| items: [{ | |
| xtype: "syno_compositefield", | |
| hideLabel: false, | |
| fieldLabel: _DT("download", "download_auth_user"), | |
| width: 300, | |
| items: [{ | |
| xtype: "syno_textfield", | |
| name: "username", | |
| width: 157, | |
| tabIndex: 1, | |
| listeners: { | |
| scope: this, | |
| change: this.clearFakePassword | |
| } | |
| }, { | |
| xtype: "syno_button", | |
| text: _DT("settings", "btn_verify_account"), | |
| disabled: this._S("demo_mode"), | |
| tooltip: this._S("demo_mode") ? _JSLIBSTR("uicommon", "error_demo") : "", | |
| scope: this, | |
| handler: this.VerifyAccountHandler | |
| }] | |
| }, { | |
| xtype: "syno_compositefield", | |
| hideLabel: false, | |
| fieldLabel: _T("common", "password"), | |
| width: 300, | |
| items: [{ | |
| xtype: "syno_textfield", | |
| textType: "password", | |
| name: "password", | |
| enableKeyEvents: true, | |
| width: 157, | |
| tabIndex: 2, | |
| listeners: { | |
| scope: this, | |
| focus: this.clearFakePassword, | |
| change: function() { | |
| this.passwordChanged = true | |
| } | |
| } | |
| }] | |
| }] | |
| }; | |
| return a | |
| }, | |
| defineBehaviors: function() { | |
| this.form = this.get("editformpanel").form | |
| }, | |
| onCloseHandler: function() { | |
| this.close() | |
| }, | |
| Apply: function() { | |
| var b; | |
| if (this.form.isDirty() || this.passwordChanged) { | |
| var c = this.form.findField("username").getValue(); | |
| var a = this.form.findField("password").getValue(); | |
| if (!this.checkValid(c, a, true)) { | |
| return false | |
| } | |
| b = { | |
| plugin_name: this.pluginName, | |
| username: c | |
| }; | |
| if (this.passwordChanged) { | |
| b.password = a | |
| } | |
| this.setStatusBusy({ | |
| text: _DT("common", "saving") | |
| }); | |
| this.sendWebAPI({ | |
| api: this.api, | |
| method: "set", | |
| params: b, | |
| version: 1, | |
| scope: this, | |
| callback: function(g, f, e) { | |
| this.clearStatusBusy(); | |
| if (!g) { | |
| var d = _DT("common", "error_system"); | |
| if (f && f.code) { | |
| d = SYNO.SDS.DownloadStation.Utils.getErrorString(f.code) | |
| } | |
| this.setStatusError({ | |
| text: d, | |
| clear: true | |
| }) | |
| } else { | |
| this.close() | |
| } | |
| } | |
| }) | |
| } else { | |
| this.close() | |
| } | |
| }, | |
| load: function() { | |
| this.setStatusBusy({ | |
| text: _T("common", "loading") | |
| }); | |
| this.sendWebAPI({ | |
| api: this.api, | |
| method: "get", | |
| params: { | |
| plugin_name: this.pluginName | |
| }, | |
| version: 1, | |
| scope: this, | |
| callback: function(d, b, a) { | |
| this.clearStatusBusy(); | |
| if (!d) { | |
| this.setStatusError({ | |
| text: _T("common", "forminvalid"), | |
| clear: true | |
| }) | |
| } else { | |
| var c = {}; | |
| c.data = b; | |
| if (c.data.username) { | |
| c.data.password = "12345678" | |
| } | |
| this.form.loadRecord(c) | |
| } | |
| } | |
| }); | |
| this.show() | |
| }, | |
| checkValid: function(c, b, a) { | |
| if (!a && !c && !b) { | |
| this.setStatusError({ | |
| text: _DT("download", "download_msg_invalid_user"), | |
| clear: true | |
| }); | |
| return false | |
| } else { | |
| if (!c && b) { | |
| this.setStatusError({ | |
| text: _DT("download", "download_msg_invalid_user"), | |
| clear: true | |
| }); | |
| return false | |
| } else { | |
| if (c && !b) { | |
| this.setStatusError({ | |
| text: _DT("common", "error_empty_password"), | |
| clear: true | |
| }); | |
| return false | |
| } | |
| } | |
| } | |
| return true | |
| }, | |
| VerifyAccountHandler: function() { | |
| var c = this.form.findField("username").getValue(); | |
| var a = this.form.findField("password").getValue(); | |
| if (this.checkValid(c, a, false) === false) { | |
| return false | |
| } | |
| var b = { | |
| plugin_name: this.pluginName, | |
| username: c | |
| }; | |
| if (this.passwordChanged) { | |
| b.password = a | |
| } | |
| this.setStatusBusy({ | |
| text: _DT("settings", "verifying_account") | |
| }); | |
| this.sendWebAPI({ | |
| api: this.api, | |
| method: "verify", | |
| params: b, | |
| version: 1, | |
| scope: this, | |
| callback: function(g, f, e) { | |
| this.clearStatusBusy(); | |
| if (!g) { | |
| var d = _DT("common", "error_system"); | |
| if (f && f.code) { | |
| d = SYNO.SDS.DownloadStation.Utils.getErrorString(f.code) | |
| } | |
| this.setStatusError({ | |
| text: d, | |
| clear: true | |
| }) | |
| } else { | |
| this.getMsgBox().alert(_DT("common", "alt_edit") + " " + this.displayname, _DT("download", "login_success")) | |
| } | |
| } | |
| }) | |
| }, | |
| clearFakePassword: function() { | |
| if (Ext.isEmpty(this.form.findField("password").getValue()) || (true === this.passwordChanged)) { | |
| return | |
| } | |
| this.form.findField("password").setValue(""); | |
| this.passwordChanged = true | |
| } | |
| }); | |
| Ext.define("SYNO.SDS.DownloadStation.Settings.AddSearchPluginDialog", { | |
| extend: "SYNO.SDS.ModalWindow", | |
| constructor: function(a) { | |
| var b = this.fillConfig(a); | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| this.submitBtnId = Ext.id(); | |
| var b = { | |
| owner: a.owner, | |
| cls: "syno-dl-win", | |
| width: 565, | |
| height: 184, | |
| shadow: true, | |
| minWidth: 100, | |
| minHeight: 100, | |
| collapsible: false, | |
| autoScroll: false, | |
| constrainHeader: true, | |
| plain: true, | |
| monitorResize: true, | |
| title: _DT("download", "search_template"), | |
| layout: "fit", | |
| items: [this.createFormPanel(a)], | |
| buttons: SYNO.SDS.DownloadStation.Utils.composeButtonCfg({ | |
| id: this.submitBtnId, | |
| text: _DT("common", "addto"), | |
| btnStyle: "blue", | |
| disabled: _S("demo_mode"), | |
| tooltip: _S("demo_mode") ? _JSLIBSTR("uicommon", "error_demo") : "" | |
| }, { | |
| text: _T("common", "alt_cancel"), | |
| handler: this.onCloseHandler, | |
| scope: this | |
| }), | |
| keys: [{ | |
| key: [10, 13], | |
| fn: this.onSubmit, | |
| scope: this | |
| }, { | |
| key: 27, | |
| fn: this.onCloseHandler, | |
| scope: this | |
| }] | |
| }; | |
| Ext.apply(b, a); | |
| return b | |
| }, | |
| createFormPanel: function(a) { | |
| return new SYNO.SDS.DownloadStation.Settings.AddSearchPluginForm({ | |
| owner: this, | |
| module: a.module, | |
| files: a.files, | |
| submitBtnId: this.submitBtnId | |
| }) | |
| }, | |
| onCloseHandler: function() { | |
| this.close() | |
| }, | |
| load: function() { | |
| this.show() | |
| } | |
| }); | |
| Ext.define("SYNO.SDS.DownloadStation.Settings.AddSearchPluginForm", { | |
| extend: "SYNO.API.Form.FormPanel", | |
| ADD_MAXLIMIT: 1, | |
| ADD_MAXSIZE: 104857600, | |
| FILEFILEDNAME: "plugin", | |
| ALLOWFILTERS: ["dlm"], | |
| constructor: function(a) { | |
| var b = this.fillConfig(a); | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| var c = new SYNO.SDS.DownloadStation.Settings.FileUploader({ | |
| api: this.getWebAPIName(), | |
| files: a.files, | |
| startId: a.submitBtnId | |
| }); | |
| var b = { | |
| api: this.getWebAPIName(), | |
| method: this.getWebAPIMethod(), | |
| version: this.getWebAPIVersion(), | |
| xtype: "syno_formpanel", | |
| fileUpload: true, | |
| itemId: "formpanel", | |
| labelAlign: "left", | |
| trackResetOnLoad: true, | |
| waitMsgTarget: true, | |
| border: false, | |
| padding: 0, | |
| labelWidth: 161, | |
| plugins: [c], | |
| items: [SYNO.SDS.DownloadStation.Uploader.Utils.getButtonTemplate({ | |
| name: this.FILEFILEDNAME | |
| }), { | |
| xtype: "syno_displayfield", | |
| value: "( eg. search.dlm)" | |
| }] | |
| }; | |
| Ext.apply(b, a); | |
| return b | |
| }, | |
| getWebAPIName: function() { | |
| return "SYNO.DownloadStation2.Settings.BTSearch" | |
| }, | |
| getWebAPIMethod: function() { | |
| return "create" | |
| }, | |
| getWebAPIVersion: function() { | |
| return 1 | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.Settings"); | |
| Ext.define("SYNO.SDS.DownloadStation.Settings.aMuleBasic", { | |
| extend: "SYNO.SDS.DownloadStation.Settings.FormPanel", | |
| isValid: function() { | |
| var e = ""; | |
| if (!this.form || !this.form.isValid()) { | |
| e = _T("common", "forminvalid") | |
| } | |
| if (true === this._S("is_admin") && this.form.findField("emule_port_type")) { | |
| if (this.form.findField("emule_port_type").getGroupValue() == "manual_port") { | |
| var a = 0 | |
| , d = 0; | |
| var b = this.form.findField("emule_tcp_port"); | |
| var c = this.form.findField("emule_udp_port"); | |
| a = parseInt(b.getValue(), 10); | |
| d = parseInt(c.getValue(), 10); | |
| if (a == d) { | |
| e = _DT("error", "error_port_conflict") | |
| } | |
| } | |
| } | |
| if (this.form.findField("destination")) { | |
| if ("" === this.form.findField("destination").getValue()) { | |
| e = _DT("download", "download_warning_select_share") | |
| } | |
| } | |
| if ("" !== e) { | |
| this.setStatusError({ | |
| text: e, | |
| clear: true | |
| }); | |
| return false | |
| } | |
| return true | |
| }, | |
| getWebAPIName: function() { | |
| return "SYNO.DownloadStation2.Settings.Emule" | |
| }, | |
| getKeyName: function() { | |
| return "emule" | |
| }, | |
| postReturnData: function(a) { | |
| var b; | |
| b = a[0].data; | |
| b.dl_when_type = (b.enable_schedule) ? "schedule" : "now"; | |
| delete b.enable_schedule; | |
| this.gData.set(this.getKeyName(), b); | |
| this.form.setValues(b) | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.Settings"); | |
| Ext.define("SYNO.SDS.DownloadStation.Settings.aMuleGeneral", { | |
| extend: "SYNO.SDS.DownloadStation.Settings.aMuleBasic", | |
| fillConfig: function(a) { | |
| var b = { | |
| trackResetOnLoad: true, | |
| frame: false, | |
| border: false, | |
| autoScroll: true, | |
| listeners: { | |
| activate: { | |
| single: true, | |
| scope: this, | |
| fn: this.onActivate | |
| } | |
| }, | |
| items: [{ | |
| xtype: "syno_fieldset", | |
| title: _DT("settings", "title_emule_server_update"), | |
| hideLabels: false, | |
| items: [{ | |
| xtype: "syno_checkbox", | |
| boxLabel: _DT("settings", "title_emule_enable_auto_server_update"), | |
| name: "enable_server_update" | |
| }, { | |
| xtype: "syno_checkbox", | |
| boxLabel: _DT("settings", "title_emule_enable_auto_connect_server"), | |
| name: "enable_server_auto_connect" | |
| }] | |
| }, { | |
| xtype: "syno_fieldset", | |
| title: _DT("settings", "title_emule_obfuscation"), | |
| hideLabels: false, | |
| items: [{ | |
| xtype: "syno_checkbox", | |
| boxLabel: _DT("settings", "title_emule_enable_obfuscation"), | |
| name: "enable_obfuscation" | |
| }, { | |
| xtype: "syno_checkbox", | |
| indent: 1, | |
| boxLabel: _DT("settings", "title_emule_outgoing_obfuscation"), | |
| name: "enable_outgoing_obfuscation" | |
| }, { | |
| xtype: "syno_checkbox", | |
| indent: 1, | |
| boxLabel: _DT("settings", "title_emule_obfuscation_conn_only"), | |
| name: "enable_obfuscation_only" | |
| }] | |
| }] | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| onActivate: function() { | |
| var b, a = this.getForm(); | |
| b = new SYNO.ux.Utils.EnableCheckGroup(a,"enable_obfuscation",["enable_outgoing_obfuscation", "enable_obfuscation_only"]) | |
| }, | |
| getFields: function() { | |
| var a = ["enable_server_update", "enable_server_auto_connect", "enable_obfuscation", "enable_outgoing_obfuscation", "enable_obfuscation_only"]; | |
| return a | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.Settings"); | |
| Ext.define("SYNO.SDS.DownloadStation.Settings.aMuleConnect", { | |
| extend: "SYNO.SDS.DownloadStation.Settings.aMuleBasic", | |
| fillConfig: function(a) { | |
| var b = { | |
| trackResetOnLoad: true, | |
| frame: false, | |
| border: false, | |
| autoScroll: true, | |
| listeners: { | |
| activate: { | |
| scope: this, | |
| fn: this.onActivate | |
| } | |
| }, | |
| items: [{ | |
| xtype: "syno_fieldset", | |
| title: _DT("settings", "title_emule_port_setting"), | |
| hideLabels: true, | |
| items: [{ | |
| xtype: "syno_radio", | |
| boxLabel: _DT("settings", "title_default_ports"), | |
| name: "port_type", | |
| inputValue: "default_port", | |
| checked: true | |
| }, { | |
| xtype: "syno_radio", | |
| boxLabel: _DT("settings", "title_manual_ports"), | |
| name: "port_type", | |
| inputValue: "manual_port" | |
| }, { | |
| indent: 1, | |
| xtype: "syno_compositefield", | |
| hideLabel: true, | |
| items: [{ | |
| xtype: "syno_displayfield", | |
| value: _DT("settings", "title_tcp_port") + _T("common", "colon") | |
| }, { | |
| xtype: "syno_numberfield", | |
| name: "tcp_port", | |
| decimalPrecision: 0, | |
| maxLength: 5, | |
| vtype: "port", | |
| minValue: 1, | |
| maxValue: 65535, | |
| width: 66, | |
| margins: { | |
| top: 0, | |
| right: 40, | |
| bottom: 0, | |
| left: 0 | |
| }, | |
| allowBlank: false, | |
| validateOnBlur: true, | |
| validationEvent: "blur", | |
| validator: function(c) { | |
| if (SYNO.SDS.Utils.isReservedPort("emule", c, c)) { | |
| return _DT("service", "error_dl_port_in_used") | |
| } else { | |
| return true | |
| } | |
| } | |
| }, { | |
| xtype: "syno_displayfield", | |
| value: _DT("settings", "title_udp_port") + _T("common", "colon") | |
| }, { | |
| xtype: "syno_numberfield", | |
| name: "udp_port", | |
| decimalPrecision: 0, | |
| maxLength: 5, | |
| vtype: "port", | |
| minValue: 1, | |
| maxValue: 65535, | |
| width: 66, | |
| allowBlank: false, | |
| validateOnBlur: true, | |
| validationEvent: "blur", | |
| validator: function(c) { | |
| if (SYNO.SDS.Utils.isReservedPort("emule", c, c)) { | |
| return _DT("service", "error_dl_port_in_used") | |
| } else { | |
| return true | |
| } | |
| } | |
| }] | |
| }] | |
| }, { | |
| xtype: "syno_fieldset", | |
| title: _DT("settings", "title_emule_connection"), | |
| hideLabels: true, | |
| items: [{ | |
| xtype: "syno_compositefield", | |
| hideLabels: true, | |
| items: [{ | |
| xtype: "syno_displayfield", | |
| value: _DT("settings", "title_emule_max_conn") + _T("common", "colon") | |
| }, { | |
| xtype: "syno_numberfield", | |
| name: "max_conn", | |
| minValue: 100, | |
| maxValue: 500, | |
| allowBlank: false, | |
| allowNegative: false, | |
| allowDecimals: false | |
| }] | |
| }] | |
| }] | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| onActivate: function() { | |
| this.doLayout() | |
| }, | |
| isPortFieldDirty: function() { | |
| var a = ["port_type", "tcp_port", "udp_port"]; | |
| for (var b = 0; b < a.length; b++) { | |
| if (this.form.findField(a[b]).isDirty()) { | |
| return true | |
| } | |
| } | |
| return false | |
| }, | |
| getWebAPIParam: function() { | |
| var a = {}; | |
| if (this.isPortFieldDirty()) { | |
| a.port_type = (this.form.findField("port_type").getValue()) ? "default_port" : "manual_port"; | |
| a.tcp_port = this.form.findField("tcp_port").getValue(); | |
| a.udp_port = this.form.findField("udp_port").getValue() | |
| } | |
| if (this.form.findField("max_conn").isDirty()) { | |
| a.max_conn = this.form.findField("max_conn").getValue() | |
| } | |
| return a | |
| }, | |
| getFields: function() { | |
| var a = ["port_type", "tcp_port", "udp_port", "max_conn"]; | |
| return a | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.Settings"); | |
| Ext.define("SYNO.SDS.DownloadStation.Settings.aMuleLocation", { | |
| extend: "SYNO.SDS.DownloadStation.Settings.aMuleBasic", | |
| defineBehaviors: function() { | |
| var a = this.owner.jsConfig.jsBaseURL; | |
| this.sharebaseURL = a + "/../../modules/FileBrowser/"; | |
| this.BaseWebfmURL = a + "/../../../webfm/" | |
| }, | |
| fillConfig: function(a) { | |
| this.ChooseDefDest = new SYNO.ux.Button({ | |
| id: this.btnChooseDefDestId = Ext.id(), | |
| name: "choosedestbtn", | |
| text: _T("common", "choose"), | |
| scope: this, | |
| handler: function() { | |
| this.utils.chooseDestHandler({ | |
| owner: this.owner, | |
| destinationField: this.form.findField("default_destination") | |
| }) | |
| } | |
| }); | |
| var e = { | |
| xtype: "syno_fieldset", | |
| title: _DT("settings", "title_default_dest_folder"), | |
| hideLabels: true, | |
| items: [{ | |
| xtype: "syno_compositefield", | |
| hideLabel: true, | |
| fieldLabel: _DT("download", "download_list_dest_folder") + _T("common", "colon"), | |
| items: [{ | |
| xtype: "syno_textfield", | |
| name: "default_destination", | |
| width: 160, | |
| readOnly: true, | |
| allowBlank: false, | |
| cls: "selectabletext allowDefCtxMenu" | |
| }, this.ChooseDefDest] | |
| }] | |
| }; | |
| var d = { | |
| xtype: "syno_fieldset", | |
| title: _DT("settings", "title_shares_settings"), | |
| id: this.fieldsetShareId = Ext.id(), | |
| hideLabels: true, | |
| items: [{ | |
| xtype: "syno_compositefield", | |
| hideLabel: true, | |
| fieldLabel: _DT("settings", "shares_settings_desc") + _T("common", "colon"), | |
| items: [{ | |
| xtype: "syno_displayfield", | |
| value: _DT("settings", "shares_settings_desc") + _T("common", "colon") | |
| }, { | |
| xtype: "syno_button", | |
| id: this.btnChooseShareId = Ext.id(), | |
| name: "choosesharebtn", | |
| text: _T("common", "choose"), | |
| scope: this, | |
| handler: this.ChooseShareHandler | |
| }] | |
| }, { | |
| xtype: "syno_textarea", | |
| name: "sharelist", | |
| value: "", | |
| validateOnBlur: true, | |
| validationEvent: "blur", | |
| width: 480, | |
| height: 150, | |
| readOnly: true, | |
| autoScroll: true, | |
| hidden: false, | |
| cls: "selectabletext allowDefCtxMenu" | |
| }] | |
| }; | |
| var b; | |
| if (_S("is_admin")) { | |
| b = [e, d] | |
| } else { | |
| b = [e] | |
| } | |
| var c = { | |
| trackResetOnLoad: true, | |
| frame: false, | |
| border: false, | |
| autoScroll: true, | |
| items: b | |
| }; | |
| return Ext.apply(c, a) | |
| }, | |
| ChooseShareHandler: function() { | |
| this.utils.chooseDestHandler({ | |
| owner: this.owner, | |
| folderToolbar: false, | |
| padding: "16px 20px 12px", | |
| usage: { | |
| type: "chooseDir", | |
| multiselect: true | |
| }, | |
| callbackScope: this, | |
| checkRender: function(a) { | |
| var b = a.spath && a.spath.substr(1); | |
| if (-1 < this.gData.get("emule_location").shareListArray.indexOf(b)) { | |
| return "checked" | |
| } | |
| return "unchecked" | |
| }, | |
| callback: this.onChooseShareHandler | |
| }) | |
| }, | |
| onChooseShareHandler: function(h) { | |
| var g = false; | |
| var c = this.gData.get("emule_location").shareListArray; | |
| for (var b in h.tree.nodeHash) { | |
| if (h.tree.nodeHash.hasOwnProperty(b)) { | |
| var f = h.tree.nodeHash[b] | |
| , e = true === f.attributes.checked || "checked" === f.attributes.checked | |
| , d = f.attributes.spath && f.attributes.spath.substr(1) | |
| , a = c.indexOf(d); | |
| if (e && d && -1 === a) { | |
| g = true; | |
| c.push(d) | |
| } else { | |
| if (!e && -1 < a) { | |
| g = true; | |
| c.splice(a, 1) | |
| } | |
| } | |
| } | |
| } | |
| if (g) { | |
| c = c.sort(); | |
| this.form.findField("sharelist").setValue(c.join("\n")) | |
| } | |
| h.close() | |
| }, | |
| getWebAPIName: function() { | |
| return "SYNO.DownloadStation2.Settings.Emule.Location" | |
| }, | |
| getWebAPIGetData: function() { | |
| var a = [{ | |
| api: "SYNO.DownloadStation2.Settings.Emule.Location", | |
| method: "get", | |
| version: 1 | |
| }]; | |
| if (_S("is_admin")) { | |
| a.push({ | |
| api: "SYNO.DownloadStation2.Settings.Emule", | |
| method: "get", | |
| version: 1 | |
| }) | |
| } | |
| return a | |
| }, | |
| getWebAPISetData: function() { | |
| var c = []; | |
| var a = this.form.findField("default_destination"); | |
| if (a.isDirty()) { | |
| c.push({ | |
| api: "SYNO.DownloadStation2.Settings.Emule.Location", | |
| method: "set", | |
| params: { | |
| default_destination: a.getValue() | |
| }, | |
| version: 1 | |
| }); | |
| SYNO.SDS.DownloadStation.aMule.Utils.setEmuleDestination(undefined) | |
| } | |
| if (_S("is_admin")) { | |
| var d = this.form.findField("sharelist"); | |
| if (d.isDirty()) { | |
| var b = this.gData.get("emule_location").shareListArray; | |
| c.push({ | |
| api: "SYNO.DownloadStation2.Settings.Emule", | |
| method: "set", | |
| params: { | |
| share_folders: b | |
| }, | |
| version: 1 | |
| }) | |
| } | |
| } | |
| return c | |
| }, | |
| getKeyName: function() { | |
| return "emule_location" | |
| }, | |
| postReturnData: function(a) { | |
| var b = {}; | |
| Ext.each(a, function(c, d, e) { | |
| if (c.success && c.api === "SYNO.DownloadStation2.Settings.Emule.Location") { | |
| b.default_destination = c.data.default_destination | |
| } | |
| if (c.success && _S("is_admin") && (c.api === "SYNO.DownloadStation2.Settings.Emule")) { | |
| b.shareListArray = c.data.share_folders; | |
| b.sharelist = b.shareListArray.join("\n") | |
| } | |
| }, this); | |
| this.gData.set(this.getKeyName(), b); | |
| this.form.setValues(b) | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.Settings"); | |
| Ext.define("SYNO.SDS.DownloadStation.Settings.aMuleBandwidth", { | |
| extend: "SYNO.SDS.DownloadStation.Settings.aMuleBasic", | |
| fillConfig: function(a) { | |
| var b = { | |
| trackResetOnLoad: true, | |
| frame: false, | |
| border: false, | |
| autoScroll: true, | |
| listeners: { | |
| activate: { | |
| scope: this, | |
| fn: this.onActivate | |
| } | |
| }, | |
| items: [{ | |
| xtype: "syno_fieldset", | |
| title: _DT("settings", "title_emule_bandwidth"), | |
| hideLabels: true, | |
| items: [{ | |
| xtype: "syno_compositefield", | |
| hideLabel: true, | |
| items: [{ | |
| xtype: "syno_displayfield", | |
| value: _DT("service", "service_dl_bt_max_upload") + _T("common", "colon") | |
| }, { | |
| xtype: "syno_numberfield", | |
| name: "upload_rate", | |
| allowNegative: false, | |
| decimalPrecision: 0, | |
| minValue: 0, | |
| width: 80, | |
| maxLength: 6, | |
| validateOnBlur: true, | |
| validationEvent: "blur", | |
| allowBlank: false | |
| }, { | |
| xtype: "syno_displayfield", | |
| value: "KB/s " + _DT("service", "service_dl_bt_rate_desc") | |
| }] | |
| }, { | |
| xtype: "syno_compositefield", | |
| hideLabel: true, | |
| items: [{ | |
| xtype: "syno_displayfield", | |
| value: _DT("service", "service_dl_bt_max_download") + _T("common", "colon") | |
| }, { | |
| xtype: "syno_numberfield", | |
| name: "download_rate", | |
| allowNegative: false, | |
| decimalPrecision: 0, | |
| minValue: 0, | |
| width: 80, | |
| maxLength: 6, | |
| validateOnBlur: true, | |
| validationEvent: "blur", | |
| allowBlank: false | |
| }, { | |
| xtype: "syno_displayfield", | |
| value: "KB/s " + _DT("service", "service_dl_bt_rate_desc") | |
| }] | |
| }] | |
| }, { | |
| xtype: "syno_fieldset", | |
| title: _DT("service", "service_dl_start_desc"), | |
| items: [{ | |
| xtype: "syno_radio", | |
| boxLabel: _DT("service", "service_dl_now"), | |
| name: "dl_when_type", | |
| itemId: "type_now", | |
| inputValue: "now", | |
| checked: true | |
| }, { | |
| xtype: "syno_radio", | |
| boxLabel: _T("schedule", "schedule_advance"), | |
| name: "dl_when_type", | |
| itemId: "type_schedule", | |
| inputValue: "schedule" | |
| }, { | |
| id: this.btnScheduleId = Ext.id(), | |
| xtype: "syno_button", | |
| text: _T("schedule", "schedule_title"), | |
| handler: this.launchScheduleDialog, | |
| scope: this, | |
| indent: 1 | |
| }, { | |
| xtype: "hidden", | |
| name: "schedule" | |
| }, { | |
| xtype: "hidden", | |
| name: "schedule_upload_rate" | |
| }, { | |
| xtype: "hidden", | |
| name: "schedule_download_rate" | |
| }] | |
| }] | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| defineBehaviors: function() { | |
| var a; | |
| a = new SYNO.ux.Utils.EnableCheckGroup(this.form,"type_schedule",[this.btnScheduleId]) | |
| }, | |
| onActivate: Ext.emptyFn, | |
| launchScheduleDialog: function() { | |
| var b = this.getForm(); | |
| var a = new SYNO.SDS.DownloadStation.Settings.ScheduleDialog({ | |
| owner: this.owner, | |
| scheduleField: b.findField("schedule"), | |
| altUploadField: b.findField("schedule_upload_rate"), | |
| altDownloadField: b.findField("schedule_download_rate") | |
| }); | |
| a.show() | |
| }, | |
| getWebAPIParam: function() { | |
| var a = this.getFields(); | |
| var c = {}; | |
| for (var b = 0; b < a.length; b++) { | |
| if (this.form.findField(a[b]).isDirty()) { | |
| if ("dl_when_type" === a[b]) { | |
| c.enable_schedule = !this.form.findField(a[b]).getValue() | |
| } else { | |
| if (("schedule_upload_rate" === a[b]) || ("schedule_download_rate" === a[b])) { | |
| c[a[b]] = parseInt(this.form.findField(a[b]).getValue(), 10) | |
| } else { | |
| c[a[b]] = this.form.findField(a[b]).getValue() | |
| } | |
| } | |
| } | |
| } | |
| return c | |
| }, | |
| getFields: function() { | |
| var a = ["upload_rate", "download_rate", "dl_when_type", "schedule", "schedule_upload_rate", "schedule_download_rate"]; | |
| return a | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.Settings"); | |
| Ext.define("SYNO.SDS.DownloadStation.Settings.ScheduleTable", { | |
| extend: "SYNO.ux.ScheduleTable", | |
| constructor: function(a) { | |
| return this.callParent([this.fillConfig(a)]) | |
| }, | |
| fillConfig: function(a) { | |
| var b = { | |
| buttons: [{ | |
| label: _DT("download", "full_speed") | |
| }, { | |
| label: a.limitBtnStr || _DT("download", "limit_speed") | |
| }, { | |
| label: _DT("download", "no_download") | |
| }], | |
| customizeItems: [{ | |
| xtype: "syno_fieldset", | |
| labelWidth: 180, | |
| items: [{ | |
| xtype: "syno_displayfield", | |
| cls: "syno-dl-textblod", | |
| value: a.limitDescStr || _DT("download", "limit_speed_setting") | |
| }, { | |
| xtype: "syno_compositefield", | |
| width: 400, | |
| indent: 1, | |
| fieldLabel: _DT("service", "service_dl_bt_max_upload"), | |
| items: [{ | |
| xtype: "syno_numberfield", | |
| id: this.ulRateId = Ext.id(), | |
| allowDecimals: false, | |
| allowNegative: false, | |
| minValue: 0, | |
| maxlength: 6, | |
| width: 100 | |
| }, { | |
| xtype: "syno_displayfield", | |
| value: " KB/s " + _DT("service", "service_dl_bt_rate_desc") | |
| }] | |
| }, { | |
| xtype: "syno_compositefield", | |
| width: 400, | |
| indent: 1, | |
| fieldLabel: _DT("service", "service_dl_bt_max_download"), | |
| items: [{ | |
| xtype: "syno_numberfield", | |
| id: this.dlRateId = Ext.id(), | |
| allowDecimals: false, | |
| allowNegative: false, | |
| minValue: 0, | |
| maxlength: 6, | |
| width: 100 | |
| }, { | |
| xtype: "syno_displayfield", | |
| value: " KB/s " + _DT("service", "service_dl_bt_rate_desc") | |
| }] | |
| }, { | |
| xtype: "syno_displayfield", | |
| htmlEncode: false, | |
| value: a.noteDescStr ? String.format('<span class="syno-sds-cp-notification-note">{0}{1} </span>{2}', _T("common", "note"), _T("common", "colon"), a.noteDescStr) : " " | |
| }] | |
| }] | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| getSingleBtnConfig: function(b, a) { | |
| var c = { | |
| 0: 1, | |
| 1: 2, | |
| 2: 0 | |
| }; | |
| return this.callParent([b, c[a]]) | |
| }, | |
| setUlRate: function(a) { | |
| Ext.getCmp(this.ulRateId).setValue(a) | |
| }, | |
| getUlRate: function() { | |
| return Ext.getCmp(this.ulRateId).getValue() | |
| }, | |
| setDlRate: function(a) { | |
| Ext.getCmp(this.dlRateId).setValue(a) | |
| }, | |
| getDlRate: function() { | |
| return Ext.getCmp(this.dlRateId).getValue() | |
| }, | |
| isValid: function() { | |
| return Ext.getCmp(this.ulRateId).isValid() && Ext.getCmp(this.dlRateId).isValid() | |
| }, | |
| isDirty: function() { | |
| return Ext.getCmp(this.ulRateId).isDirty() || Ext.getCmp(this.dlRateId).isDirty() | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.Settings"); | |
| Ext.define("SYNO.SDS.DownloadStation.Settings.ScheduleDialog", { | |
| extend: "SYNO.SDS.ModalWindow", | |
| constructor: function(a) { | |
| this.scheduleField = a.scheduleField; | |
| this.altUploadField = a.altUploadField; | |
| this.altDownloadField = a.altDownloadField; | |
| var b = this.fillConfig(a); | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| this.scheduleTable = new SYNO.SDS.DownloadStation.Settings.ScheduleTable(a); | |
| var b = { | |
| cls: "syno-dl-win", | |
| padding: "16px 20px 0px 20px", | |
| height: 550, | |
| width: 660, | |
| title: _T("schedule", "schedule_title"), | |
| layout: "fit", | |
| items: [this.scheduleTable], | |
| buttons: SYNO.SDS.DownloadStation.Utils.composeButtonCfg({ | |
| text: _T("common", "apply"), | |
| btnStyle: "blue", | |
| scope: this, | |
| handler: this.okHandler | |
| }, { | |
| text: _T("common", "cancel"), | |
| scope: this, | |
| handler: function() { | |
| this.close() | |
| } | |
| }) | |
| }; | |
| Ext.apply(b, a); | |
| return b | |
| }, | |
| okHandler: function() { | |
| var a = this.scheduleTable; | |
| if (!a.isValid()) { | |
| this.setStatusError({ | |
| text: _T("common", "forminvalid"), | |
| clear: true | |
| }) | |
| } else { | |
| this.scheduleField.setValue(a.getSchedule()); | |
| this.altUploadField.setValue(a.getUlRate()); | |
| this.altDownloadField.setValue(a.getDlRate()); | |
| this.close() | |
| } | |
| }, | |
| onShow: function() { | |
| this.scheduleTable.setSchedule(this.scheduleField.getValue()); | |
| this.scheduleTable.setUlRate(this.altUploadField.getValue()); | |
| this.scheduleTable.setDlRate(this.altDownloadField.getValue()) | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.Settings"); | |
| Ext.define("SYNO.SDS.DownloadStation.Settings.Window", { | |
| extend: "SYNO.SDS.ModalWindow", | |
| defaultActivedFnMap: { | |
| "SYNO.SDS.DownloadStation.DLM.Main": this._S("is_admin") ? "SYNO.SDS.DownloadStation.Settings.DLMGen" : "SYNO.SDS.DownloadStation.Settings.DLMFolder", | |
| "SYNO.SDS.DownloadStation.aMule.Main": this._S("is_admin") ? "SYNO.SDS.DownloadStation.Settings.aMuleGeneral" : "SYNO.SDS.DownloadStation.Settings.aMuleLocation" | |
| }, | |
| defineUIComponents: function(a) { | |
| var c = SYNO.SDS.DownloadStation.Utils.addUIComponents; | |
| var b = new SYNO.SDS.DownloadStation.PollingTask({ | |
| owner: this | |
| }); | |
| c(a, "utils", SYNO.SDS.DownloadStation.Utils); | |
| c(a, "gData", SYNO.SDS.DownloadStation.gData); | |
| c(a, "jsConfig", a.owner.jsConfig); | |
| c(a, "settingsWin", this); | |
| c(a, "appWin", a.owner); | |
| c(a, "pollingtask", b) | |
| }, | |
| constructor: function(a) { | |
| this.defineUIComponents(a); | |
| Ext.apply(this, a.uicomponents || {}); | |
| var b = this.fillConfig(a); | |
| this.callParent([b]); | |
| this.defineBehaviors(); | |
| this.applyPostReturnDataHook(a.postReturnDataHook) | |
| }, | |
| defineBehaviors: function() { | |
| this.gData.remove("schedule"); | |
| this.gData.remove("location"); | |
| this.gData.remove("bt"); | |
| this.gData.remove("ftp_http"); | |
| this.gData.remove("nzb"); | |
| this.gData.remove("rss"); | |
| this.gData.remove("emule"); | |
| this.gData.remove("emule_location"); | |
| this.gData.remove("global"); | |
| this.gData.remove("unzip"); | |
| this.gData.remove("postReturnDataHook") | |
| }, | |
| applyPostReturnDataHook: function(a) { | |
| this.gData.postReturnDataHook = {}; | |
| Ext.each(a, function(b) { | |
| this.gData.postReturnDataHook[b] = true | |
| }, this) | |
| }, | |
| fillConfig: function(b) { | |
| var d = 920; | |
| var a = 520; | |
| var e = this.defaultActivedFnMap[b.defaultActivedFn] || b.defaultActivedFn || "SYNO.SDS.DownloadStation.Settings.GlobalGen"; | |
| var c = { | |
| owner: b.owner, | |
| closable: true, | |
| maximizable: true, | |
| fbar: false, | |
| layout: "border", | |
| title: _DT("download", "download_table_heading_setting"), | |
| constrainHeader: true, | |
| cls: "syno-dl-win syno-settings-win", | |
| dsmStyle: "v5", | |
| minWidth: d, | |
| minHeight: a, | |
| boxMinHeight: a, | |
| boxMinWidth: d, | |
| width: d, | |
| height: a, | |
| border: false, | |
| plain: true, | |
| items: [{ | |
| xtype: "panel", | |
| bodyStyle: "border: 0px;", | |
| cls: "syno-dl-leftpanel", | |
| region: "west", | |
| layout: { | |
| type: "vbox", | |
| align: "stretch" | |
| }, | |
| width: 240, | |
| items: [{ | |
| xtype: "panel", | |
| layout: "fit", | |
| border: false, | |
| flex: 1, | |
| items: [this.moduleList = new SYNO.SDS.DownloadStation.ModuleList({ | |
| owner: this, | |
| uicomponents: this.uicomponents, | |
| defaultActivedFn: e, | |
| folder: "settings" | |
| },this)] | |
| }] | |
| }, this.moduleCt = new Ext.Panel({ | |
| xtype: "syno_panel", | |
| cls: "syno-dl-rightpanel", | |
| layout: "card", | |
| border: false, | |
| frame: false, | |
| hideMode: "offsets", | |
| region: "center" | |
| })], | |
| listeners: { | |
| scope: this, | |
| beforeclose: function() { | |
| var f = this.settingsWin.actionFlag; | |
| this.settingsWin.actionFlag = ""; | |
| switch (f) { | |
| case "APPLY": | |
| if (!this.settingsWin.applyHandler()) { | |
| return false | |
| } | |
| break; | |
| case "CLOSE_WITHOUT_SAVING": | |
| break; | |
| default: | |
| if (this.settingsWin.isSettingDirty()) { | |
| this.settingsWin.cancelHandler(); | |
| return false | |
| } | |
| break | |
| } | |
| return true | |
| }, | |
| close: function(f) { | |
| f.cascade(function(g) { | |
| if (Ext.isDefined(g.onCloseHandler)) { | |
| g.onCloseHandler() | |
| } | |
| }) | |
| } | |
| } | |
| }; | |
| return c | |
| }, | |
| getModule: function(fn, cfg) { | |
| var FnObj; | |
| eval("FnObj = " + fn + ";"); | |
| FnObj.prototype.jsConfig = this.jsConfig; | |
| var module = new FnObj(cfg); | |
| return module | |
| }, | |
| mergeWebAPI: function(b, c) { | |
| if (Ext.isEmpty(c) || Ext.isEmpty(c.api) || Ext.isEmpty(c.method) || Ext.isEmpty(c.version)) { | |
| return false | |
| } | |
| var a = c.api + "_" + c.method + "_" + c.version; | |
| if (Ext.isDefined(b[a])) { | |
| Ext.apply(b[a].params, c.params) | |
| } else { | |
| b[a] = c | |
| } | |
| return true | |
| }, | |
| actionFlag: "CANCEL", | |
| applyForm: function(c) { | |
| var k, a, f; | |
| this.setStatusBusy({ | |
| text: _T("common", "saving") | |
| }); | |
| for (k in c) { | |
| if (c.hasOwnProperty(k)) { | |
| a = c[k]; | |
| if (!a.onSettingsApply()) { | |
| this.clearStatusBusy(); | |
| return | |
| } | |
| } | |
| } | |
| var b = {}; | |
| for (k in c) { | |
| if (c.hasOwnProperty(k)) { | |
| a = c[k]; | |
| var g = a.getWebAPISetData(); | |
| if (!Ext.isDefined(g)) { | |
| continue | |
| } | |
| if (k === "SYNO.SDS.DownloadStation.Settings.GlobalGen") { | |
| f = g; | |
| continue | |
| } | |
| if (Ext.isArray(g)) { | |
| for (var e = 0; e < g.length; e++) { | |
| this.mergeWebAPI(b, g[e]) | |
| } | |
| } else { | |
| this.mergeWebAPI(b, g) | |
| } | |
| } | |
| } | |
| var h = []; | |
| for (k in b) { | |
| if (b.hasOwnProperty(k)) { | |
| h.push(b[k]) | |
| } | |
| } | |
| if (f) { | |
| if (Ext.isArray(f)) { | |
| for (var d = 0; d < f.length; d++) { | |
| h.push(f[d]) | |
| } | |
| } else { | |
| h.push(f) | |
| } | |
| } | |
| if (0 === h.length) { | |
| this.clearStatusBusy(); | |
| this.settingsWin.close(); | |
| return | |
| } | |
| this.sendWebAPI({ | |
| compound: { | |
| stopwhenerror: false, | |
| params: h | |
| }, | |
| params: {}, | |
| scope: this, | |
| callback: function(i, n, m, j) { | |
| var l = false; | |
| this.clearStatusBusy(); | |
| Ext.each(n.result, function(o, p, t) { | |
| if (!o.success) { | |
| var s = _DT("common", "error_system"); | |
| if (o.error.code) { | |
| s = SYNO.SDS.DownloadStation.Utils.getErrorString(o.error.code) | |
| } | |
| SYNO.Debug("Failed on " + o.api + " " + o.method); | |
| if (1207 === o.error.code) { | |
| var r = c["SYNO.SDS.DownloadStation.Settings.DLMFolder"].form.findField("torrent_nzb_watch_folder").getValue(); | |
| s = String.format(s, r) | |
| } | |
| this.settingsWin.getMsgBox().alert("", s); | |
| return | |
| } | |
| if ("SYNO.DownloadStation2.Settings.Global" === o.api) { | |
| var q = m.compound[p].enable_emule; | |
| if (Ext.isDefined(q) && (q != this.gData.get("amule_enabled"))) { | |
| this.gData.set("amule_enabled", q ? 1 : 0); | |
| this.owner.tabPanel.setTabBtnDisabled("aMule", !q) | |
| } | |
| if (o.hasOwnProperty("data")) { | |
| l = true | |
| } | |
| } | |
| }, this); | |
| if (l) { | |
| this.settingsWin.startPolling() | |
| } | |
| } | |
| }) | |
| }, | |
| applyHandler: function() { | |
| var c, b, d = 0, a = {}; | |
| for (c in this.moduleList.moduleList) { | |
| if (this.moduleList.moduleList.hasOwnProperty(c)) { | |
| b = this.moduleList.moduleList[c]; | |
| if (b.isDirty()) { | |
| if (!this.settingsWin.verifyIsValid(b, c)) { | |
| return false | |
| } | |
| a[c] = b; | |
| d++ | |
| } | |
| } | |
| } | |
| if (0 === d) { | |
| return true | |
| } | |
| if (a.hasOwnProperty("SYNO.SDS.DownloadStation.Settings.GlobalGen")) { | |
| b = a["SYNO.SDS.DownloadStation.Settings.GlobalGen"]; | |
| b.confirmIfVolumeChange(function() { | |
| this.settingsWin.applyForm(a) | |
| } | |
| .createDelegate(b)); | |
| return true | |
| } | |
| this.settingsWin.applyForm(a); | |
| return true | |
| }, | |
| verifyIsValid: function(b, a) { | |
| if (!b.isValid()) { | |
| this.moduleList.selectModule(a); | |
| if (b.setStatusError) { | |
| b.setStatusError({ | |
| text: _DT("common", "forminvalid"), | |
| clear: true | |
| }) | |
| } | |
| return false | |
| } | |
| return true | |
| }, | |
| isSettingDirty: function() { | |
| for (var b in this.moduleList.moduleList) { | |
| if (this.moduleList.moduleList.hasOwnProperty(b)) { | |
| var a = this.moduleList.moduleList[b]; | |
| if (a.isDirty()) { | |
| return true | |
| } | |
| } | |
| } | |
| return false | |
| }, | |
| cancelHandler: function() { | |
| this.settingsWin.confirmLostChangePromise({ | |
| save: function() { | |
| this.settingsWin.actionFlag = "APPLY"; | |
| this.settingsWin.close() | |
| }, | |
| dontSave: function() { | |
| this.settingsWin.actionFlag = "CLOSE_WITHOUT_SAVING"; | |
| this.settingsWin.close() | |
| }, | |
| cancel: Ext.emptyFn | |
| }, this) | |
| }, | |
| startPolling: function() { | |
| this.settingsWin.getEl().mask(_T("common", "msg_waiting"), "x-mask-loading"); | |
| this.pollDeviceId = this.settingsWin.pollReg({ | |
| webapi: { | |
| api: "SYNO.DownloadStation2.Settings.Global", | |
| version: 2, | |
| method: "read_progress" | |
| }, | |
| interval: 3, | |
| immediate: true, | |
| scope: this, | |
| status_callback: this.settingsWin.pollingCallBack | |
| }) | |
| }, | |
| pollingCallBack: function(c, b) { | |
| if (!c) { | |
| var a = _T("common", "error_system"); | |
| if (b.code) { | |
| a = SYNO.SDS.DownloadStation.Utils.getErrorString(b.code) | |
| } | |
| this.settingsWin.getMsgBox().alert(_T("tree", "node_download"), a, function() { | |
| this.clearStatusBusy() | |
| }, this); | |
| SYNO.Debug("Failed on read_progress webapi"); | |
| return | |
| } | |
| if (1 === b.running) { | |
| return | |
| } | |
| this.pollingDone(b) | |
| }, | |
| pollingDone: function(a) { | |
| if (this.pollDeviceId) { | |
| this.settingsWin.pollUnreg(this.pollDeviceId); | |
| this.pollDeviceId = null | |
| } | |
| if ("success" === a.result) { | |
| this.unmaskAndClose() | |
| } else { | |
| this.settingsWin.getMsgBox().alert(_T("tree", "node_download"), _DT("common", "error_system"), function() { | |
| this.unmaskAndClose() | |
| }, this) | |
| } | |
| }, | |
| unmaskAndClose: function() { | |
| this.settingsWin.getEl().unmask(); | |
| this.settingsWin.close() | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation"); | |
| Ext.define("SYNO.SDS.DownloadStation.Main", { | |
| extend: "Ext.Panel", | |
| leftPanelWidth: 240, | |
| defineUIComponents: function(a) { | |
| var c = SYNO.SDS.DownloadStation.Utils.addUIComponents; | |
| var b = new SYNO.SDS.DownloadStation.PollingTask({ | |
| owner: this | |
| }); | |
| c(a, "appWin", a.appWin); | |
| c(a, "jsConfig", a.appWin.jsConfig); | |
| c(a, "mainPanel", this); | |
| c(a, "tabPanel", this.owner); | |
| c(a, "pollingtask", b); | |
| c(a, "utils", SYNO.SDS.DownloadStation.Utils); | |
| c(a, "gData", SYNO.SDS.DownloadStation.gData) | |
| }, | |
| constructor: function(c) { | |
| this.owner = c.owner; | |
| this.defineUIComponents(c); | |
| Ext.apply(this, c.uicomponents || {}); | |
| var b = c.listItems.indexOf(c.currentItem); | |
| var e = []; | |
| var h = 44; | |
| e.push(this.createSettingsBtn({ | |
| flex: 1, | |
| height: h | |
| })); | |
| for (var g = 0; g < c.listItems.length; g++) { | |
| var a = "syno-dl-tab-btn"; | |
| if (b == g) { | |
| a += " syno-dl-tab-selected" | |
| } | |
| if ("aMule" === c.listItems[g].folder && !c.enable_emule) { | |
| a += " syno-dl-tab-disabled" | |
| } | |
| var f = new Ext.Button({ | |
| index: g, | |
| flex: 1, | |
| height: h, | |
| itemId: c.listItems[g].folder, | |
| iconCls: c.listItems[g].iconCls, | |
| tooltip: this.utils.getLocalizedString(c.listItems[g].text), | |
| fn: c.listItems[g].fn, | |
| cls: a, | |
| handler: this.onTabBtnClick, | |
| scope: this, | |
| uicomponents: c.uicomponents | |
| }); | |
| e.push(f) | |
| } | |
| var d = { | |
| border: false, | |
| width: 900, | |
| itemId: c.currentItem.fn, | |
| layout: "border", | |
| cls: "syno-dl-main", | |
| items: [{ | |
| xtype: "panel", | |
| bodyStyle: "border: 0px", | |
| cls: "syno-dl-leftpanel", | |
| region: "west", | |
| layout: { | |
| type: "vbox", | |
| align: "stretch" | |
| }, | |
| width: this.leftPanelWidth, | |
| items: [{ | |
| xtype: "panel", | |
| layout: "fit", | |
| border: false, | |
| flex: 1, | |
| items: [this.moduleList = this.createModuleList(c)] | |
| }, this.btnTabPanel = new SYNO.ux.Panel({ | |
| xtype: "panel", | |
| layout: "hbox", | |
| align: "stretch", | |
| border: false, | |
| cls: "syno-dl-button-panel", | |
| items: e | |
| })] | |
| }, this.moduleCt = new Ext.Panel({ | |
| xtype: "syno_panel", | |
| cls: "syno-dl-rightpanel", | |
| layout: "card", | |
| border: false, | |
| frame: false, | |
| hideMode: "offsets", | |
| region: "center" | |
| })], | |
| listeners: { | |
| scope: this, | |
| afterrender: function() {}, | |
| destroy: function() {}, | |
| activate: function() { | |
| var i; | |
| if (!this.moduleList || !this.moduleList.moduleList) { | |
| return | |
| } | |
| for (var j in this.moduleList.moduleList) { | |
| if (this.moduleList.moduleList.hasOwnProperty(j)) { | |
| i = this.moduleList.moduleList[j]; | |
| if (i === this.moduleList.actived) { | |
| if (i.activate) { | |
| i.activate() | |
| } | |
| if (i.onTabActivate) { | |
| i.onTabActivate() | |
| } | |
| break | |
| } | |
| } | |
| } | |
| }, | |
| deactivate: function() { | |
| var i; | |
| if (!this.moduleList || !this.moduleList.moduleList) { | |
| return | |
| } | |
| for (var j in this.moduleList.moduleList) { | |
| if (this.moduleList.moduleList.hasOwnProperty(j)) { | |
| i = this.moduleList.moduleList[j]; | |
| if (i === this.moduleList.actived) { | |
| if (i.deactivate) { | |
| i.deactivate() | |
| } | |
| if (i.onTabDeactivate) { | |
| i.onTabDeactivate() | |
| } | |
| break | |
| } | |
| } | |
| } | |
| } | |
| } | |
| }; | |
| this.callParent([Ext.apply(d, c)]) | |
| }, | |
| onTabBtnClick: function(a, b) { | |
| var c = this.owner; | |
| if (a.el.hasClass("syno-dl-tab-disabled")) { | |
| if (this._S("is_admin") !== true) { | |
| this.appWin.getMsgBox().alert("", _DT("download", "download_emule_not_enabled")); | |
| return | |
| } | |
| this.appWin.getMsgBox().confirm("", _DT("download", "amule_stopped_hint"), function(d) { | |
| if ("yes" === d) { | |
| var e = new SYNO.SDS.DownloadStation.Settings.Window({ | |
| defaultActivedFn: "SYNO.SDS.DownloadStation.Settings.GlobalGen", | |
| owner: this.appWin | |
| }); | |
| e.open() | |
| } | |
| }, this) | |
| } else { | |
| if (a.index !== c.items.indexOf(this)) { | |
| c.setActiveTab(a.index) | |
| } | |
| } | |
| }, | |
| createModuleList: function(a) { | |
| var b = Ext.apply({ | |
| toolbarConfig: { | |
| xtype: "toolbar", | |
| cls: "syno-dl-toolbar", | |
| items: [this.getSearchField()] | |
| } | |
| }, a); | |
| return new SYNO.SDS.DownloadStation.ModuleList(b,this) | |
| }, | |
| createSettingsBtn: function(a) { | |
| var b = new Ext.Button(Ext.apply({ | |
| iconCls: "syno-dl-tab_settings", | |
| tooltip: _DT("tree", "leaf_setting"), | |
| cls: "syno-dl-tab-btn", | |
| handler: this.onSettingsBtnClick, | |
| scope: this | |
| }, a)); | |
| return b | |
| }, | |
| onSettingsBtnClick: function() { | |
| var a = new SYNO.SDS.DownloadStation.Settings.Window({ | |
| defaultActivedFn: this.mainPanel.itemId, | |
| owner: this.appWin | |
| }); | |
| a.open() | |
| }, | |
| onCloseHandler: function() { | |
| this.pollingtask.removeAll() | |
| }, | |
| unmask: function() { | |
| if (this.getEl().isMasked()) { | |
| this.getEl().unmask() | |
| } | |
| }, | |
| mask: function(a) { | |
| if (!this.getEl().isMasked()) { | |
| this.getEl().mask(a) | |
| } | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.DLM"); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.QueueAddFileUploader", { | |
| extend: "SYNO.SDS.DownloadStation.Uploader.Uploader", | |
| getOpts: function() { | |
| return { | |
| limitSize: SYNO.SDS.DownloadStation.DLM.QueueBasic.prototype.ADDTASK_MAXSIZE, | |
| limitFiles: SYNO.SDS.DownloadStation.DLM.QueueBasic.prototype.ADDTASK_MAXLIMIT, | |
| startId: this.startId | |
| } | |
| }, | |
| getHTML5Opts: function() { | |
| return { | |
| url: this.formWebAPIUrl(this.api), | |
| allowfilters: ["torrent", "nzb", "txt"], | |
| filefiledname: this.container.FILEFILEDNAME | |
| } | |
| }, | |
| onBeforeSubmit: function(a) { | |
| if (_S("demo_mode")) { | |
| this.showMsgIfActive(_T("common", "webman_options"), _JSLIBSTR("uicommon", "error_demo")); | |
| return | |
| } | |
| if (this.handleUnzipPW() === false) { | |
| return false | |
| } | |
| if (!this.isAddurlOmissibleOrValid()) { | |
| return false | |
| } | |
| this.appWin.appInstance.setUserSettings("showFileInfo", this.form.findField("create_list").getValue()); | |
| if (this.isSetStatusBusy !== true) { | |
| this.isSetStatusBusy = true; | |
| this.owner.setStatusBusy({ | |
| text: _T("common", "saving") | |
| }) | |
| } | |
| a.fireEvent("onApplyWebAPIParamsIntoRequest", a) | |
| }, | |
| getWebAPIParamsForHTML5Uploader: function() { | |
| var b = { | |
| type: this.form.findField("type").getValue(), | |
| file: this.form.findField("file").getValue(), | |
| destination: Ext.encode(this.form.findField("destination_field").getValue()), | |
| create_list: this.form.findField("create_list").getValue() | |
| }; | |
| var a = this.getExtractPasswordIfExisted(); | |
| if (!Ext.isEmpty(a)) { | |
| b.extract_password = Ext.encode(a) | |
| } | |
| return b | |
| }, | |
| applyFormDataForHTMLUploader: function(b) { | |
| this.form.findField("destination").setValue(Ext.encode(this.form.findField("destination_field").getValue())); | |
| var a = this.getExtractPasswordIfExisted(); | |
| if (!Ext.isEmpty(a)) { | |
| this.form.findField("extract_password").setValue(Ext.encode(a)) | |
| } | |
| }, | |
| onComplete: function(b, a) { | |
| this.updateCreateInfo(a.data.list_id) | |
| }, | |
| onAllDone: function(a) { | |
| if (this.isSetStatusBusy) { | |
| this.isSetStatusBusy = false; | |
| this.owner.clearStatusBusy(); | |
| this.owner.clearStatus() | |
| } | |
| if (this.isAnyUploadError) { | |
| this.owner.clearCreatedLists() | |
| } else { | |
| this.owner.onApplyHandler(true) | |
| } | |
| }, | |
| onError: function(a, b, c) { | |
| if (_S("demo_mode")) { | |
| this.showMsgIfActive(_T("common", "webman_options"), _JSLIBSTR("uicommon", "error_demo")); | |
| return | |
| } | |
| if (!this.isVisible() && _DT("download", "download_empty_input_file") === b) { | |
| this.owner.onApplyHandler(false); | |
| return | |
| } | |
| this.isAnyUploadError = true; | |
| if (this instanceof SYNO.SDS.DownloadStation.DLM.QueueAddFile) { | |
| this.setMeActive(); | |
| this.showMsgIfActive(_DT("tree", "leaf_downloadtask"), b) | |
| } else { | |
| this.findAppWindow().getMsgBox().alert(_DT("tree", "leaf_downloadtask"), b) | |
| } | |
| }, | |
| onErrorStr: function(a, b) { | |
| this.showMsgIfActive(_DT("tree", "leaf_downloadtask"), b) | |
| }, | |
| onSubmit: function(a) { | |
| a.isAnyUploadError = false; | |
| this.callParent([a]) | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.DLM"); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.EditBtFileDialog", { | |
| extend: "SYNO.SDS.ModalWindow", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| Ext.apply(this, { | |
| listIds: a.listIds, | |
| destinations: a.destinations, | |
| extractPasswords: a.extractPasswords | |
| }); | |
| var b = this.fillConfig(a); | |
| this.callParent([b]); | |
| this.defineBehaviors() | |
| }, | |
| defineBehaviors: function() { | |
| this.panel = this.get("formpanel"); | |
| this.newform = this.panel.form; | |
| this.grid = this.panel.get("gridpanel"); | |
| this.btnBack = this.fbar.get("back"); | |
| this.btnNext = this.fbar.get("next") | |
| }, | |
| fillConfig: function(a) { | |
| var b = { | |
| owner: this.appWin, | |
| cls: "syno-dl-win syno-dl-add-fileinfo-dailog", | |
| width: 640, | |
| height: 510, | |
| minWidth: 520, | |
| minHeight: 460, | |
| constrainHeader: true, | |
| plain: true, | |
| monitorResize: true, | |
| title: _DT("tree", "leaf_downloadtask"), | |
| layout: "fit", | |
| items: [this.initFormConfig(a)], | |
| fbar: { | |
| cls: "x-statusbar", | |
| defaultText: " ", | |
| buttonAlign: "left", | |
| items: this.getFbarItemsCfg() | |
| } | |
| }; | |
| Ext.apply(b, a); | |
| return b | |
| }, | |
| getFbarItemsCfg: function(b) { | |
| var c, a; | |
| c = [{ | |
| itemId: "back", | |
| tooltip: _T("common", "back"), | |
| iconCls: "syno-dlm-tbar-back", | |
| disabled: true, | |
| scope: this, | |
| handler: function() { | |
| this.curIndex--; | |
| this.switchPage() | |
| } | |
| }, { | |
| itemId: "next", | |
| tooltip: _T("common", "next"), | |
| iconCls: "syno-dlm-tbar-next", | |
| disabled: true, | |
| scope: this, | |
| handler: function() { | |
| this.curIndex++; | |
| this.switchPage() | |
| } | |
| }, { | |
| itemId: "page_index", | |
| xtype: "displayfield", | |
| hideLabel: true, | |
| value: "", | |
| style: { | |
| marginLeft: "20px", | |
| fontSize: "10pt" | |
| } | |
| }, "->"]; | |
| a = SYNO.SDS.DownloadStation.Utils.composeButtonCfg({ | |
| btnStyle: "blue", | |
| xtype: "syno_button", | |
| itemId: "create", | |
| text: _DT("download", "download_btn_new"), | |
| scope: this, | |
| handler: this.onBeforeSubmit | |
| }, { | |
| text: _DT("common", "cancel"), | |
| xtype: "syno_button", | |
| scope: this, | |
| handler: function() { | |
| this.onCloseHandler(false, 0, 0) | |
| } | |
| }); | |
| return c.concat(a) | |
| }, | |
| updateSwitchPageBtnState: function() { | |
| this.btnNext.setDisabled(this.curIndex === this.listIds.length - 1); | |
| this.btnBack.setDisabled(this.curIndex === 0) | |
| }, | |
| switchPage: function() { | |
| this.updateSwitchPageBtnState(); | |
| if (this.listData[this.curIndex]) { | |
| this.store.loadData(this.listData[this.curIndex]) | |
| } else { | |
| this.store.reload() | |
| } | |
| }, | |
| initFormConfig: function(a) { | |
| var b = { | |
| xtype: "syno_formpanel", | |
| itemId: "formpanel", | |
| autoFlexcroll: false, | |
| labelAlign: "left", | |
| trackResetOnLoad: true, | |
| waitMsgTarget: true, | |
| border: false, | |
| labelWidth: 160, | |
| items: [{ | |
| xtype: "syno_compositefield", | |
| itemId: "destselectfield", | |
| fieldLabel: _DT("download", "download_list_dest_folder"), | |
| defaults: { | |
| hideLabel: true | |
| }, | |
| items: [{ | |
| xtype: "syno_textfield", | |
| readOnly: true, | |
| name: "destination", | |
| width: 209 | |
| }, { | |
| xtype: "syno_button", | |
| text: _DT("download", "download_btn_change"), | |
| scope: this, | |
| handler: function() { | |
| this.utils.chooseDestHandler({ | |
| owner: this.owner, | |
| callback: this.onDestChanged, | |
| callbackScope: this | |
| }) | |
| } | |
| }] | |
| }, { | |
| xtype: "syno_displayfield", | |
| width: "auto", | |
| fieldLabel: _DT("download", "download_list_filename"), | |
| name: "name" | |
| }, { | |
| xtype: "syno_displayfield", | |
| width: "auto", | |
| fieldLabel: _DT("download", "download_list_filesize"), | |
| name: "size" | |
| }, { | |
| xtype: "syno_checkbox", | |
| boxLabel: _DT("download", "task_list_create_subfolder"), | |
| checked: true, | |
| name: "subfolder_check", | |
| listeners: { | |
| scope: this, | |
| check: this.onSubfolderChecked | |
| } | |
| }, this.initGridConfig(a)] | |
| }; | |
| return b | |
| }, | |
| onDestChanged: function(c, b, a) { | |
| var d = b.path.substr(1); | |
| this.newform.findField("destination").setValue(d); | |
| this.destinations[this.curIndex] = d; | |
| c.close() | |
| }, | |
| onSubfolderChecked: function(b, c, a) { | |
| this.subfolder[this.curIndex] = c | |
| }, | |
| initGridConfig: function(a) { | |
| this.enableColumn = new SYNO.ux.EnableColumn({ | |
| align: "center", | |
| dataIndex: "enable", | |
| width: 50, | |
| enableFastSelectAll: true, | |
| isIgnore: this.onCheckEnabled.createDelegate(this) | |
| }); | |
| this.colmd = this.createColModel(); | |
| this.store = this.createStore(); | |
| var b = { | |
| xtype: "syno_gridpanel", | |
| name: "files_grid", | |
| itemId: "gridpanel", | |
| height: 307, | |
| cls: "without-dirty-red-grid", | |
| stripeRows: true, | |
| loadMask: true, | |
| autoExpandColumn: "dl-files", | |
| enableColumnMove: false, | |
| enableColLock: false, | |
| enableColumnHide: false, | |
| enableHdMenu: false, | |
| bbar: this.paging, | |
| selModel: new Ext.grid.RowSelectionModel({ | |
| singleSelect: false | |
| }), | |
| colModel: this.colmd, | |
| store: this.store, | |
| plugins: [this.enableColumn] | |
| }; | |
| return b | |
| }, | |
| createColModel: function() { | |
| var a = new Ext.grid.ColumnModel({ | |
| defaultSortable: false, | |
| columns: [this.enableColumn, { | |
| id: "dl-files", | |
| header: _DT("download", "download_list_filename"), | |
| dataIndex: "name", | |
| sortable: true, | |
| renderer: SYNO.SDS.DownloadStation.DLM.Util.nameRender.createDelegate(this) | |
| }, { | |
| header: _DT("download", "download_list_filesize"), | |
| dataIndex: "size", | |
| sortable: true, | |
| width: 120, | |
| renderer: SYNO.SDS.DownloadStation.DLM.Util.sizeRenderer | |
| }] | |
| }); | |
| return a | |
| }, | |
| createStore: function() { | |
| var a = new SYNO.API.JsonStore({ | |
| api: "SYNO.DownloadStation2.Task.List", | |
| method: "get", | |
| version: 2, | |
| autoLoad: true, | |
| autoDestroy: true, | |
| remoteSort: false, | |
| pruneModifiedRecords: false, | |
| appWindow: this, | |
| idProperty: "index", | |
| fields: [{ | |
| name: "name", | |
| sortType: "asNaturalUCString" | |
| }, "size", "index", "download_url", { | |
| name: "enable", | |
| mapping: "enable", | |
| defaultValue: true | |
| }], | |
| root: "files", | |
| listeners: { | |
| scope: this, | |
| beforeload: this.onBeforeLoad, | |
| load: this.onLoad, | |
| exception: this.onRequestException | |
| } | |
| }); | |
| return a | |
| }, | |
| onRequestException: function(d, e, f, c, b, a) { | |
| if (b.code) { | |
| if (!this.grid.getGridEl().isMasked()) { | |
| this.grid.getGridEl().mask(SYNO.SDS.DownloadStation.Utils.getErrorString(b.code)) | |
| } | |
| } | |
| }, | |
| updateTitle: function() { | |
| var a = (this.listIds.length > 1) ? String.format("({0}/{1})", this.curIndex + 1, this.listIds.length) : ""; | |
| this.setTitle(_DT("tree", "leaf_downloadtask") + a) | |
| }, | |
| onBeforeLoad: function(a, b) { | |
| this.updateTitle(); | |
| if (!this.listIds[this.curIndex]) { | |
| return false | |
| } | |
| b.params.list_id = this.listIds[this.curIndex]; | |
| return true | |
| }, | |
| onLoad: function(a, c, b) { | |
| if (this.listData[this.curIndex]) { | |
| this.onLoadByData(a) | |
| } else { | |
| this.onLoadByApi(a) | |
| } | |
| }, | |
| onLoadByApi: function(a) { | |
| this.listData[this.curIndex] = a.reader.jsonData; | |
| this.updateFormDisplay(a.reader.jsonData); | |
| this.initFilesSelectedState(a); | |
| if (this.grid.getGridEl()) { | |
| this.grid.getGridEl().unmask() | |
| } | |
| }, | |
| onLoadByData: function(a) { | |
| this.updateTitle(); | |
| this.updateFormDisplay(a.reader.jsonData) | |
| }, | |
| updateFormDisplay: function(a) { | |
| this.newform.setValues({ | |
| destination: this.destinations[this.curIndex] | |
| }); | |
| var b = a.type === "bt"; | |
| this.newform.findField("subfolder_check").setVisible(!b); | |
| if (!b) { | |
| this.newform.findField("subfolder_check").setValue(this.subfolder[this.curIndex]) | |
| } | |
| this.newform.setValues({ | |
| name: a.title | |
| }); | |
| this.colmd.setHidden(2, !b); | |
| this.newform.findField("size").setVisible(b); | |
| if (b) { | |
| this.newform.setValues({ | |
| size: Ext.util.Format.fileSize(a.size) | |
| }) | |
| } | |
| }, | |
| initFilesSelectedState: function(a) { | |
| var c = a.reader.jsonData.files; | |
| var b = a.reader.jsonData.selected; | |
| if (Ext.isArray(b)) { | |
| c.forEach(function(e, d) { | |
| e.enable = (-1 !== b.indexOf(e.index)) | |
| }); | |
| delete a.reader.jsonData.selected | |
| } else { | |
| c.forEach(function(d) { | |
| d.enable = true | |
| }) | |
| } | |
| this.updateSelectionByFileInfos(a, c) | |
| }, | |
| updateSelectionByFileInfos: function(a, b) { | |
| a.each(function(c, d) { | |
| c.data.enable = b[c.get("index")].enable | |
| }); | |
| a.fireEvent("datachanged", this) | |
| }, | |
| onBeforeSubmit: function() { | |
| var b = this.getMsgBox().alert.createDelegate(this.getMsgBox(), [_DT("download", "download_btn_downloadstation"), _DT("download", "download_error_rss_no_selection")]); | |
| if (this.isNoFileSelection(this.listData[this.curIndex])) { | |
| b(); | |
| return | |
| } | |
| for (var a = 0; a < this.listIds.length; a++) { | |
| if (this.listData[a] && this.isNoFileSelection(this.listData[a])) { | |
| this.curIndex = a; | |
| this.switchPage(); | |
| b(); | |
| return | |
| } | |
| } | |
| this.onSubmit() | |
| }, | |
| onSubmit: function() { | |
| this.getEl().mask(_DT("common", "saving"), "x-mask-loading"); | |
| this.requestSuccessCount = 0; | |
| this.requestDoneCount = 0; | |
| for (var a = 0; a < this.listIds.length; a++) { | |
| this.sendWebAPIForSpecificList(a) | |
| } | |
| }, | |
| sendWebAPIForSpecificList: function(a) { | |
| var b = { | |
| list_id: this.listIds[a], | |
| destination: this.destinations[a], | |
| create_subfolder: this.subfolder[a] | |
| }; | |
| if (!Ext.isEmpty(this.listData[a])) { | |
| b.selected = this.generateAPIParamsSelected(this.listData[a].files) | |
| } | |
| if (!Ext.isEmpty(this.extractPasswords[a])) { | |
| b.extract_password = this.extractPasswords[a] | |
| } | |
| this.downloadPollingStart(b) | |
| }, | |
| downloadPollingStart: function(a) { | |
| this.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.Task.List.Polling", | |
| method: "download", | |
| version: 2, | |
| params: a, | |
| callback: function(c, b) { | |
| if (true !== c) { | |
| this.onSubmitDone(false, b, a.list_id); | |
| return | |
| } | |
| this.downloadPollingStatus(b.task_id, a.list_id) | |
| }, | |
| scope: this | |
| }) | |
| }, | |
| downloadPollingStatus: function(a, b) { | |
| this.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.Task.List.Polling", | |
| method: "download_status", | |
| version: 2, | |
| params: { | |
| task_id: a | |
| }, | |
| callback: function(d, c) { | |
| if (true !== d) { | |
| this.downloadPollingDone(a, { | |
| success: false, | |
| error: c | |
| }, b); | |
| return | |
| } | |
| if (!c.finish) { | |
| Ext.defer(function() { | |
| this.downloadPollingStatus(a, b) | |
| }, 1000, this) | |
| } else { | |
| this.downloadPollingDone(a, c, b) | |
| } | |
| }, | |
| scope: this | |
| }) | |
| }, | |
| downloadPollingDone: function(a, b, c) { | |
| this.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.Task.List.Polling", | |
| method: "download_stop", | |
| version: 2, | |
| params: { | |
| task_id: a | |
| }, | |
| callback: function(e, d) { | |
| if (true !== e) { | |
| this.onSubmitDone(false, d, c); | |
| return | |
| } | |
| this.onSubmitDone(b.success, b.success ? b.data : b.error, c) | |
| }, | |
| scope: this | |
| }) | |
| }, | |
| generateAPIParamsSelected: function(b) { | |
| var a = []; | |
| b.forEach(function(c) { | |
| if (c.enable) { | |
| a.push(c.index) | |
| } | |
| }); | |
| return a | |
| }, | |
| onSubmitDone: function(b, a, d) { | |
| this.requestDoneCount++; | |
| if (b) { | |
| this.requestSuccessCount++; | |
| var c = this.listIds.indexOf(d); | |
| this.listIds[c] = undefined | |
| } else { | |
| this.getMsgBox().alert(_DT("download", "download_btn_downloadstation"), SYNO.SDS.DownloadStation.Utils.getErrorString(a.code)) | |
| } | |
| if (this.requestDoneCount === this.listIds.length) { | |
| this.onAllSubmitDone() | |
| } | |
| }, | |
| onAllSubmitDone: function() { | |
| this.getEl().unmask(); | |
| if (this.requestSuccessCount === this.listIds.length) { | |
| this.queueGrid.preSelectLastRecord(); | |
| this.queueGrid.updateRecords(true); | |
| this.close(); | |
| return | |
| } | |
| this.removeCompletedList(); | |
| this.curIndex = 0; | |
| this.switchPage() | |
| }, | |
| removeCompletedList: function() { | |
| var c = [] | |
| , b = [] | |
| , d = [] | |
| , a = []; | |
| Ext.each(this.listIds, function(e, f) { | |
| if (e) { | |
| c.push(this.listIds[f]); | |
| b.push(this.destinations[f]); | |
| d.push(this.subfolder[f]); | |
| a.push(this.listData[f]) | |
| } | |
| }, this); | |
| this.listIds = c; | |
| this.destinations = b; | |
| this.subfolder = d; | |
| this.listData = a | |
| }, | |
| onCloseHandler: function() { | |
| var a = []; | |
| Ext.each(this.listIds, function(b) { | |
| a.push({ | |
| api: "SYNO.DownloadStation2.Task.List", | |
| method: "delete", | |
| version: 2, | |
| params: { | |
| list_id: b | |
| } | |
| }) | |
| }); | |
| this.sendWebAPI({ | |
| compound: { | |
| stopwhenerror: false, | |
| params: a | |
| }, | |
| callback: this.onDeletionDone | |
| }); | |
| this.close() | |
| }, | |
| onDeletionDone: function(d, a, c, b) { | |
| if (!d || !a.has_fail) { | |
| return | |
| } | |
| Ext.each(a.result, function(e, f) { | |
| if (!e.success) { | |
| SYNO.Debug(String.format("Failed on {0}#{1}, with list_id {2} and error code {3}", e.api, e.method, c.compound[f].list_id, e.error.code)) | |
| } | |
| }) | |
| }, | |
| onCheckEnabled: function(b, a) { | |
| if (b !== "cell" && b !== "all") { | |
| return false | |
| } | |
| a.json.enable = !a.get("enable"); | |
| return false | |
| }, | |
| load: function() { | |
| this.curIndex = 0; | |
| this.subfolder = this.utils.fillArray(true, this.listIds.length); | |
| this.listData = this.utils.fillArray(undefined, this.listIds.length); | |
| this.updateSwitchPageBtnState(); | |
| this.show() | |
| }, | |
| isNoFileSelection: function(b) { | |
| var a = Ext.each(b.files, function(c) { | |
| return c.enable !== true | |
| }); | |
| return undefined === a | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.DLM"); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.QueueAddDialog", { | |
| extend: "SYNO.SDS.ModalWindow", | |
| hideTabHeader: false, | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| var b = this.fillConfig(a); | |
| this.callParent([b]); | |
| this.defineBehaviors(a) | |
| }, | |
| defineBehaviors: function(a) { | |
| this.listIds = []; | |
| this.destinations = []; | |
| this.extractPasswords = [] | |
| }, | |
| fillConfig: function(a) { | |
| a.startButtonId = Ext.id(); | |
| var b = { | |
| owner: this.appWin, | |
| cls: "syno-dl-win", | |
| width: 580, | |
| height: 468, | |
| minWidth: 200, | |
| minHeight: 200, | |
| constrainHeader: true, | |
| title: _DT("tree", "leaf_downloadtask"), | |
| layout: "fit", | |
| items: [this.getTabPanel(a)], | |
| buttons: SYNO.SDS.DownloadStation.Utils.composeButtonCfg({ | |
| btnStyle: "blue", | |
| text: _T("common", "apply"), | |
| id: a.startButtonId, | |
| scope: this, | |
| disabled: _S("demo_mode"), | |
| tooltip: _S("demo_mode") ? _JSLIBSTR("uicommon", "error_demo") : undefined | |
| }, { | |
| text: _T("common", "cancel"), | |
| scope: this, | |
| handler: this.close | |
| }), | |
| keys: [{ | |
| key: 27, | |
| scope: this, | |
| handler: this.close | |
| }], | |
| listeners: { | |
| scope: this, | |
| close: this.onClose, | |
| beforeclose: this.onBeforeClose | |
| } | |
| }; | |
| Ext.apply(b, a); | |
| return b | |
| }, | |
| onClose: function() { | |
| this.pollingtask.startById("updateTask", true) | |
| }, | |
| onBeforeClose: function() { | |
| if (!Ext.isEmpty(this.listIds)) { | |
| var a = new SYNO.SDS.DownloadStation.DLM.EditBtFileDialog({ | |
| uicomponents: this.uicomponents, | |
| listIds: this.listIds, | |
| destinations: this.destinations, | |
| extractPasswords: this.extractPasswords | |
| }); | |
| a.load() | |
| } | |
| }, | |
| onApplyHandler: function(a) { | |
| this.getTabPanel().applyHandler(a) | |
| }, | |
| getTabPanel: function(a) { | |
| if (!this.addTabPanel) { | |
| var d = new SYNO.SDS.DownloadStation.DLM.QueueAddFile({ | |
| startButtonId: a.startButtonId, | |
| files: a.files, | |
| owner: this, | |
| uicomponents: this.uicomponents, | |
| itemId: "addfile", | |
| title: _DT("download", "download_lbl_input_file") | |
| }); | |
| var c = new SYNO.SDS.DownloadStation.DLM.QueueAddURL({ | |
| owner: this, | |
| urls: a.urls, | |
| padding: a.hideTabHeader ? 0 : undefined, | |
| uicomponents: this.uicomponents, | |
| itemId: "addurl", | |
| title: _DT("download", "download_lbl_input_url") | |
| }); | |
| var b = { | |
| owner: this, | |
| height: 550, | |
| layoutOnTabChange: true, | |
| activeTab: (a && a.activeTab) ? a.activeTab : 0, | |
| items: [d, c] | |
| }; | |
| if (a.hideTabHeader) { | |
| b.headerCfg = { | |
| style: "display:none;" | |
| }; | |
| b.bodyCfg = { | |
| padding: 0 | |
| } | |
| } | |
| this.addTabPanel = new SYNO.SDS.DownloadStation.DLM.QueueAddTabPanel(b) | |
| } | |
| return this.addTabPanel | |
| }, | |
| clearCreatedLists: function() { | |
| this.deleteCreatedLists(); | |
| this.listIds = []; | |
| this.destinations = []; | |
| this.extractPasswords = [] | |
| }, | |
| deleteCreatedLists: function() { | |
| if (this.listIds.length === 0) { | |
| return | |
| } | |
| var a = []; | |
| Ext.each(this.listIds, function(b) { | |
| a.push({ | |
| api: "SYNO.DownloadStation2.Task.List", | |
| method: "delete", | |
| version: 2, | |
| params: { | |
| list_id: b | |
| } | |
| }) | |
| }); | |
| this.sendWebAPI({ | |
| compound: { | |
| stopwhenerror: false, | |
| params: a | |
| }, | |
| callback: this.onDeletionDone | |
| }) | |
| }, | |
| onDeletionDone: function(d, a, c, b) { | |
| if (!d || !a.has_fail) { | |
| return | |
| } | |
| Ext.each(a.result, function(e, f) { | |
| if (!e.success) { | |
| SYNO.Debug(String.format("Failed on {0}#{1}, with list_id {2} and error code {3}", e.api, e.method, c.compound[f].list_id, e.error.code)) | |
| } | |
| }) | |
| } | |
| }); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.QueueAddTabPanel", { | |
| extend: "SYNO.ux.TabPanel", | |
| constructor: function(a) { | |
| var b = { | |
| plain: true, | |
| height: 300, | |
| deferredRender: false, | |
| autoWidth: true, | |
| listeners: { | |
| scope: this, | |
| tabchange: this.onTabchange | |
| } | |
| }; | |
| Ext.apply(b, a || {}); | |
| this.callParent([b]) | |
| }, | |
| applyHandler: function(a) { | |
| var c = this.get("addurl"), b; | |
| if (a && c.isEmptyUrl()) { | |
| this.onCreateSuccess(); | |
| return | |
| } | |
| b = c.getWebAPICreateData(); | |
| if (Ext.isEmpty(b)) { | |
| return | |
| } | |
| this.owner.setStatusBusy({ | |
| text: _T("common", "saving") | |
| }); | |
| this.sendWebAPI({ | |
| webapi: b, | |
| callback: function(f, d, e) { | |
| this.owner.clearStatusBusy(); | |
| if (f && d.list_id) { | |
| c.updateCreateInfo(d.list_id); | |
| this.onCreateSuccess() | |
| } else { | |
| c.setMeActive(); | |
| this.onCreateFailure(d); | |
| this.owner.clearCreatedLists() | |
| } | |
| }, | |
| scope: this | |
| }) | |
| }, | |
| onCreateSuccess: function(a, b) { | |
| this.owner.setStatusOK(); | |
| this.owner.queueGrid.preSelectLastRecord(); | |
| this.owner.close() | |
| }, | |
| onCreateFailure: function(a) { | |
| if (this.isDestroyed) { | |
| return | |
| } | |
| this.owner.getMsgBox().alert(_T("helptoc", "settings"), SYNO.SDS.DownloadStation.Utils.getErrorString(a.code)) | |
| }, | |
| onTabchange: function() { | |
| this.owner.clearStatus() | |
| } | |
| }); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.QueueAddSubPanleCommon", { | |
| statics: { | |
| getUnzipPWConfig: function() { | |
| if (SYNO.SDS.DownloadStation.DLM.Util.isUnzipServiceOn()) { | |
| return { | |
| xtype: "syno_textfield", | |
| fieldLabel: _DT("settings", "unzip_add_pw"), | |
| name: "extract_password_field", | |
| width: 205 | |
| } | |
| } else { | |
| return [] | |
| } | |
| }, | |
| getExtractPasswordIfExisted: function() { | |
| if (SYNO.SDS.DownloadStation.DLM.Util.isUnzipServiceOn()) { | |
| return this.form.findField("extract_password_field").getValue() | |
| } else { | |
| return "" | |
| } | |
| }, | |
| handleUnzipPW: function() { | |
| if (SYNO.SDS.DownloadStation.DLM.Util.isUnzipServiceOn()) { | |
| var a = this.form.findField("extract_password_field").getValue(); | |
| return SYNO.SDS.DownloadStation.DLM.Util.handleNewUnzipPW.createDelegate(this, [a])() | |
| } | |
| return true | |
| }, | |
| getCreateListFromUserSettings: function() { | |
| if (this.appWin.appInstance.getUserSettings("showFileInfo") === false) { | |
| return false | |
| } else { | |
| return true | |
| } | |
| }, | |
| showMsgIfActive: function(d, c, b, a) { | |
| if (this.owner.getTabPanel().activeTab == this) { | |
| this.owner.getMsgBox().alert(d, c, b, a) | |
| } | |
| }, | |
| setMeActive: function() { | |
| this.owner.getTabPanel().activate(this) | |
| }, | |
| updateCreateInfo: function(b, a) { | |
| if (!this.form.findField("create_list").getValue()) { | |
| return | |
| } | |
| this.owner.listIds = this.owner.listIds.concat(b); | |
| this.owner.destinations = this.owner.destinations.concat(this.utils.fillArray(a, b.length)); | |
| var c = this.getExtractPasswordIfExisted(); | |
| this.owner.extractPasswords = this.owner.extractPasswords.concat(this.utils.fillArray(c, b.length)) | |
| } | |
| } | |
| }); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.QueueAddFile", { | |
| extend: "SYNO.ux.FormPanel", | |
| FILEFILEDNAME: "torrent", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| var b = this.fillConfig(a); | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| var c = new SYNO.SDS.DownloadStation.DLM.QueueAddFileUploader({ | |
| startId: a.startButtonId, | |
| files: a.files, | |
| api: this.getWebAPIName() | |
| }); | |
| var b = { | |
| border: false, | |
| xtype: "form", | |
| fileUpload: true, | |
| frame: false, | |
| trackResetOnLoad: true, | |
| labelWidth: 161, | |
| plugins: [c], | |
| api: this.getWebAPIName(), | |
| method: this.getWebAPIMethod(), | |
| version: this.getWebAPIVersion(), | |
| items: [{ | |
| xtype: "syno_compositefield", | |
| itemId: "destselectfield", | |
| fieldLabel: _DT("download", "download_list_dest_folder"), | |
| defaults: { | |
| hideLabel: true | |
| }, | |
| items: [{ | |
| xtype: "syno_textfield", | |
| name: "destination_field", | |
| readOnly: true, | |
| value: SYNO.SDS.DownloadStation.DLM.Util.getLocationDestination(), | |
| width: 205 | |
| }, { | |
| xtype: "syno_button", | |
| text: _T("common", "choose"), | |
| disabled: _S("demo_mode"), | |
| scope: this, | |
| handler: function() { | |
| this.utils.chooseDestHandler({ | |
| owner: this.owner, | |
| destinationField: this.form.findField("destination_field") | |
| }) | |
| } | |
| }, { | |
| xtype: "hidden", | |
| name: "destination" | |
| }] | |
| }, { | |
| xtype: "hidden", | |
| value: Ext.encode("file"), | |
| name: "type" | |
| }, { | |
| xtype: "hidden", | |
| value: Ext.encode([this.FILEFILEDNAME]), | |
| name: "file" | |
| }, SYNO.SDS.DownloadStation.Uploader.Utils.getButtonTemplate({ | |
| name: this.FILEFILEDNAME | |
| }), { | |
| xtype: "syno_displayfield", | |
| value: "( eg. download.torrent, download.nzb, urls.txt )", | |
| hideLabel: false | |
| }, this.getUnzipPWConfig(), this.getHiddenUnzipPWConfig(), { | |
| xtype: "syno_checkbox", | |
| submitValue: false, | |
| boxLabel: _DT("download", "show_file_info_desc"), | |
| name: "create_list", | |
| checked: this.getCreateListFromUserSettings() | |
| }] | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| isAddurlOmissibleOrValid: function() { | |
| var a = this.ownerCt.get("addurl"); | |
| if ((a !== this.ownerCt.activeTab) && a.isEmptyUrl()) { | |
| return true | |
| } | |
| return !Ext.isEmpty(a.getWebAPICreateData()) | |
| }, | |
| getUnzipPWConfig: function() { | |
| return SYNO.SDS.DownloadStation.DLM.QueueAddSubPanleCommon.getUnzipPWConfig.call(this) | |
| }, | |
| getHiddenUnzipPWConfig: function() { | |
| if (SYNO.SDS.DownloadStation.DLM.Util.isUnzipServiceOn()) { | |
| return { | |
| xtype: "hidden", | |
| value: "", | |
| name: "extract_password" | |
| } | |
| } else { | |
| return [] | |
| } | |
| }, | |
| getExtractPasswordIfExisted: function() { | |
| return SYNO.SDS.DownloadStation.DLM.QueueAddSubPanleCommon.getExtractPasswordIfExisted.call(this) | |
| }, | |
| handleUnzipPW: function() { | |
| return SYNO.SDS.DownloadStation.DLM.QueueAddSubPanleCommon.handleUnzipPW.call(this) | |
| }, | |
| getCreateListFromUserSettings: function() { | |
| return SYNO.SDS.DownloadStation.DLM.QueueAddSubPanleCommon.getCreateListFromUserSettings.call(this) | |
| }, | |
| showMsgIfActive: function(d, c, b, a) { | |
| SYNO.SDS.DownloadStation.DLM.QueueAddSubPanleCommon.showMsgIfActive.call(this, d, c, b, a) | |
| }, | |
| setMeActive: function() { | |
| SYNO.SDS.DownloadStation.DLM.QueueAddSubPanleCommon.setMeActive.call(this) | |
| }, | |
| updateCreateInfo: function(b) { | |
| var a = this.form.findField("destination_field").getValue(); | |
| SYNO.SDS.DownloadStation.DLM.QueueAddSubPanleCommon.updateCreateInfo.call(this, b, a) | |
| }, | |
| getWebAPIName: function() { | |
| return "SYNO.DownloadStation2.Task" | |
| }, | |
| getWebAPIMethod: function() { | |
| return "create" | |
| }, | |
| getWebAPIVersion: function() { | |
| return 2 | |
| } | |
| }); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.QueueAddURL", { | |
| extend: "SYNO.ux.FormPanel", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| var b = this.fillConfig(a); | |
| this.callParent([b]); | |
| this.defineBehaviors(); | |
| this.ADDTASK_MAXLIMIT = SYNO.SDS.DownloadStation.DLM.QueueBasic.prototype.ADDTASK_MAXLIMIT | |
| }, | |
| fillConfig: function(a) { | |
| var d = a.urls; | |
| var c = "( http://, https://, ftp://, ftps://, sftp://, magnet:, thunder://, flashget://, qqdl://)"; | |
| var b = { | |
| border: false, | |
| trackResetOnLoad: true, | |
| height: 430, | |
| labelWidth: 161, | |
| items: [{ | |
| xtype: "hidden", | |
| value: "url", | |
| name: "type" | |
| }, { | |
| xtype: "syno_compositefield", | |
| itemId: "destselectfield", | |
| fieldLabel: _DT("download", "download_list_dest_folder"), | |
| defaults: { | |
| hideLabel: true | |
| }, | |
| items: [{ | |
| xtype: "syno_textfield", | |
| name: "destination", | |
| readOnly: true, | |
| value: SYNO.SDS.DownloadStation.DLM.Util.getLocationDestination(), | |
| width: 205 | |
| }, { | |
| xtype: "syno_button", | |
| text: _T("common", "choose"), | |
| disabled: _S("demo_mode"), | |
| scope: this, | |
| handler: function() { | |
| this.utils.chooseDestHandler({ | |
| owner: this.owner, | |
| destinationField: this.form.findField("destination") | |
| }) | |
| } | |
| }] | |
| }, { | |
| xtype: "syno_textarea", | |
| cls: "selectabletext allowDefCtxMenu", | |
| fieldLabel: _DT("download", "download_lbl_input_url"), | |
| name: "url", | |
| submitValue: false, | |
| autoFlexcroll: true, | |
| value: (d && d.length) ? d.join("\n") : "", | |
| width: 299, | |
| height: 100 | |
| }, { | |
| xtype: "syno_displayfield", | |
| value: c, | |
| hideLabel: false | |
| }, { | |
| xtype: "syno_checkbox", | |
| boxLabel: _DT("download", "download_need_auth"), | |
| hideLabel: false, | |
| name: "dlauth" | |
| }, { | |
| xtype: "syno_textfield", | |
| fieldLabel: _DT("download", "download_auth_user"), | |
| labelStyle: "padding-left: 136px; width: 121px;", | |
| name: "username", | |
| allowBlank: false, | |
| validateOnBlur: true, | |
| validationEvent: "blur", | |
| maxlength: 128, | |
| width: 169, | |
| indent: 1 | |
| }, { | |
| xtype: "syno_textfield", | |
| fieldLabel: _DT("download", "download_auth_pass"), | |
| labelStyle: "padding-left: 136px; width: 121px;", | |
| name: "password", | |
| inputType: "password", | |
| maxlength: 128, | |
| width: 169, | |
| indent: 1 | |
| }, this.getUnzipPWConfig(), { | |
| xtype: "syno_checkbox", | |
| boxLabel: _DT("download", "show_file_info_desc"), | |
| name: "create_list", | |
| checked: this.getCreateListFromUserSettings() | |
| }] | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| defineBehaviors: function() { | |
| new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"dlauth",["username", "password"]); | |
| new SYNO.SDS.DownloadStation.ShowHideCheckGroup(this.getForm(),"dlauth",["username", "password"]); | |
| this.mon(this, "activate", function(b) { | |
| var a = this.form.findField("url"); | |
| a.focus.defer(300, a) | |
| }, this) | |
| }, | |
| getWebAPICreateData: function() { | |
| var a = this.getWebAPICreateParams(); | |
| if (Ext.isEmpty(a)) { | |
| return | |
| } | |
| return { | |
| api: "SYNO.DownloadStation2.Task", | |
| method: "create", | |
| version: 2, | |
| params: a | |
| } | |
| }, | |
| getWebAPICreateParams: function() { | |
| if (!this.form.isValid()) { | |
| return | |
| } | |
| var a = this.getValidURL(); | |
| if (false === a) { | |
| return | |
| } | |
| var c = this.form.getValues(); | |
| c.url = a; | |
| delete c.dlauth; | |
| if (true === this.form.findField("dlauth").getValue()) { | |
| c.username = encodeURIComponent(c.username); | |
| c.password = encodeURIComponent(c.password) | |
| } | |
| c.create_list = (c.create_list === "true"); | |
| if (!this.handleUnzipPW()) { | |
| return | |
| } | |
| var b = this.getExtractPasswordIfExisted(); | |
| if (!Ext.isEmpty(b)) { | |
| c.extract_password = b | |
| } | |
| this.appWin.appInstance.setUserSettings("showFileInfo", c.create_list); | |
| return c | |
| }, | |
| getValidURL: function() { | |
| var c = false, b = [], d, a; | |
| d = this.form.findField("url").getValue(); | |
| d = Ext.util.Format.trim(d); | |
| if ("" === d) { | |
| this.setMeActive(); | |
| this.showMsgIfActive(_DT("tree", "leaf_downloadtask"), _DT("download", "download_empty_input_url")); | |
| return false | |
| } | |
| Ext.each(d.split("\n"), function(e) { | |
| e = Ext.util.Format.trim(e); | |
| if (e.length < 1) { | |
| return true | |
| } | |
| a = SYNO.SDS.DownloadStation.Utils.canonizeURLPrefix(e); | |
| if (a) { | |
| b.push(a) | |
| } else { | |
| c = true | |
| } | |
| }, this); | |
| if (b.length < 1) { | |
| this.setMeActive(); | |
| this.showMsgIfActive(_DT("tree", "leaf_downloadtask"), _DT("download", "download_error_wrong_url")); | |
| return false | |
| } else { | |
| if (b.length > this.ADDTASK_MAXLIMIT) { | |
| this.setMeActive(); | |
| this.showMsgIfActive(_DT("tree", "leaf_downloadtask"), String.format(_DT("dlqueue", "error_task_add_exceed_maxnumber"), this.ADDTASK_MAXLIMIT)); | |
| return false | |
| } | |
| } | |
| if (c) { | |
| this.showMsgIfActive(_DT("tree", "leaf_downloadtask"), _DT("download", "download_error_bad_urls_found")) | |
| } | |
| return b | |
| }, | |
| isEmptyUrl: function() { | |
| var a = this.form.findField("url").getValue(); | |
| a = Ext.util.Format.trim(a); | |
| return "" === a | |
| }, | |
| getUnzipPWConfig: function() { | |
| return SYNO.SDS.DownloadStation.DLM.QueueAddSubPanleCommon.getUnzipPWConfig.call(this) | |
| }, | |
| getExtractPasswordIfExisted: function() { | |
| return SYNO.SDS.DownloadStation.DLM.QueueAddSubPanleCommon.getExtractPasswordIfExisted.call(this) | |
| }, | |
| handleUnzipPW: function() { | |
| return SYNO.SDS.DownloadStation.DLM.QueueAddSubPanleCommon.handleUnzipPW.call(this) | |
| }, | |
| getCreateListFromUserSettings: function() { | |
| return SYNO.SDS.DownloadStation.DLM.QueueAddSubPanleCommon.getCreateListFromUserSettings.call(this) | |
| }, | |
| showMsgIfActive: function(d, c, b, a) { | |
| SYNO.SDS.DownloadStation.DLM.QueueAddSubPanleCommon.showMsgIfActive.call(this, d, c, b, a) | |
| }, | |
| setMeActive: function() { | |
| SYNO.SDS.DownloadStation.DLM.QueueAddSubPanleCommon.setMeActive.call(this) | |
| }, | |
| updateCreateInfo: function(b) { | |
| var a = this.form.findField("destination").getValue(); | |
| SYNO.SDS.DownloadStation.DLM.QueueAddSubPanleCommon.updateCreateInfo.call(this, b, a) | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.DLM"); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.QueueEditBtDialog", { | |
| extend: "SYNO.SDS.ModalWindow", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| this.selections = this.queueGrid.getSelectionModel().getSelections(); | |
| this.isSingle = (1 === this.selections.length) ? true : false; | |
| this.isEditActiveTorrent = this.isAllActiveTorrent(); | |
| var b = this.fillConfig(a); | |
| this.callParent([b]); | |
| this.mon(this, "afterlayout", this.onAddTip, this, { | |
| single: true | |
| }); | |
| this.defineBehaviors() | |
| }, | |
| fillConfig: function(a) { | |
| var b = { | |
| owner: this.appWin, | |
| cls: "syno-dl-win", | |
| width: this.isEditActiveTorrent ? 720 : 560, | |
| minWidth: 640, | |
| autoHeight: true, | |
| resizable: false, | |
| title: _DT("tree", "leaf_downloadtask"), | |
| layout: "fit", | |
| items: [this.initFormConfig()], | |
| buttons: SYNO.SDS.DownloadStation.Utils.composeButtonCfg({ | |
| btnStyle: "blue", | |
| text: _T("common", "ok"), | |
| scope: this, | |
| handler: this.saveSetting | |
| }, { | |
| text: _T("common", "cancel"), | |
| scope: this, | |
| handler: this.onCloseHandler | |
| }), | |
| keys: [{ | |
| key: [10, 13], | |
| fn: this.saveSetting, | |
| scope: this | |
| }, { | |
| key: 27, | |
| fn: this.onCloseHandler, | |
| scope: this | |
| }] | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| defineBehaviors: function() { | |
| this.settingform = this.get("property").form | |
| }, | |
| onAddTip: function() { | |
| var a = this.settingform.findField("stoptask_desc"); | |
| if (a) { | |
| SYNO.SDS.DownloadStation.Utils.AddTip(a.getEl(), _DT("service", "service_dl_bt_seeding_hint")); | |
| a.originalValue = a.getValue() | |
| } | |
| }, | |
| initFormConfig: function() { | |
| var a = [{ | |
| xtype: "syno_compositefield", | |
| itemId: "destinationField", | |
| width: 340, | |
| defaults: { | |
| hideLabel: true | |
| }, | |
| fieldLabel: _DT("download", "download_list_dest_folder"), | |
| items: [{ | |
| xtype: "syno_textfield", | |
| name: "destination", | |
| width: 200, | |
| readOnly: true | |
| }, { | |
| xtype: "syno_button", | |
| text: _T("common", "choose"), | |
| scope: this, | |
| handler: function() { | |
| this.utils.chooseDestHandler({ | |
| owner: this.owner, | |
| destinationField: this.settingform.findField("destination") | |
| }) | |
| } | |
| }] | |
| }, { | |
| xtype: "syno_textfield", | |
| fieldLabel: _DT("settings", "unzip_pw"), | |
| itemId: "extract_password", | |
| name: "extract_password" | |
| }]; | |
| if (true === this.isEditActiveTorrent) { | |
| a = a.concat([{ | |
| xtype: "syno_displayfield", | |
| name: "stoptask_desc", | |
| submitValue: false, | |
| width: 700, | |
| value: _DT("service", "service_dl_bt_stoptask_desc") | |
| }, { | |
| xtype: "syno_numberfield", | |
| indent: 1, | |
| fieldLabel: _DT("service", "service_dl_bt_seeding_ratio"), | |
| name: "seeding_ratio", | |
| allowBlank: true, | |
| allowDecimals: false, | |
| allowNegative: false, | |
| minValue: 0, | |
| maxValue: 2147483647, | |
| maxLength: 10 | |
| }, { | |
| xtype: "syno_compositefield", | |
| name: "seeding_interval_compositefield", | |
| indent: 1, | |
| items: [{ | |
| maskRe: /[\d]/, | |
| xtype: "syno_combobox", | |
| width: 200, | |
| maxlength: 3, | |
| fieldLabel: _DT("service", "service_dl_bt_seeding_interval"), | |
| name: "seeding_interval", | |
| store: SYNO.SDS.DownloadStation.DLM.Util.createSeedTimeStore(), | |
| displayField: "display", | |
| valueField: "value", | |
| selectOnFocus: true, | |
| value: 0, | |
| initQuery: Ext.emptyFn, | |
| setValue: function(d) { | |
| SYNO.ux.ComboBox.prototype.setValue.apply(this, arguments); | |
| var c = this; | |
| var e = (("0" != d) && (-2 == d || -1 == c.store.data.keys.indexOf(d))); | |
| c.setEditable(e); | |
| c.nextSibling().setValue(e ? _T("service", "service_dl_bt_seedopt_unit_hours") : ""); | |
| if (-2 == d) { | |
| c.setRawValue() | |
| } else { | |
| if (e && d > 0) { | |
| c.setRawValue(d / 60) | |
| } | |
| } | |
| }, | |
| listeners: { | |
| scope: this, | |
| blur: function(c) { | |
| var d = c.getValue(); | |
| var e = (-2 == d || -1 == c.store.data.keys.indexOf(d)); | |
| if ("" === d || "0" === d) { | |
| c.setValue(0) | |
| } else { | |
| if (e && d > 0) { | |
| c.setValue(d * 60) | |
| } | |
| } | |
| } | |
| }, | |
| validator: function(d) { | |
| if (-1 < this.store.findExact("display", d)) { | |
| return true | |
| } | |
| var c = new RegExp("^[1-9][0-9]{0,4}$"); | |
| return c.test(d) | |
| } | |
| }, { | |
| xtype: "syno_displayfield", | |
| value: "", | |
| isDirty: function() { | |
| return false | |
| } | |
| }] | |
| }, { | |
| xtype: "syno_numberfield", | |
| name: "max_upload_rate", | |
| allowBlank: true, | |
| allowDecimals: false, | |
| allowNegative: false, | |
| minValue: 0, | |
| maxLength: 6, | |
| fieldLabel: _DT("service", "service_dl_bt_max_upload") + String.format("[0: {0}]", _DT("common", "default")) | |
| }, { | |
| xtype: "syno_numberfield", | |
| name: "max_download_rate", | |
| allowBlank: true, | |
| allowDecimals: false, | |
| allowNegative: false, | |
| minValue: 0, | |
| maxLength: 6, | |
| fieldLabel: _DT("service", "service_dl_bt_max_download") + String.format("[0: {0}]", _DT("common", "default")) | |
| }, { | |
| xtype: "syno_combobox", | |
| name: "priority", | |
| allowBlank: true, | |
| fieldLabel: _DT("dlqueue", "title_dl_priority"), | |
| store: [["high", _DT("dlqueue", "dl_priority_high")], ["normal", _DT("dlqueue", "dl_priority_normal")], ["low", _DT("dlqueue", "dl_priority_low")]] | |
| }, { | |
| xtype: "syno_numberfield", | |
| name: "max_peers", | |
| allowBlank: true, | |
| allowDecimals: false, | |
| allowNegative: false, | |
| minValue: 5, | |
| maxValue: 10000, | |
| maxLength: 5, | |
| fieldLabel: _DT("service", "service_dl_bt_maxpeers") | |
| }]) | |
| } | |
| var b = { | |
| xtype: "form", | |
| padding: "0 0 14px 0", | |
| autoHeight: true, | |
| fileUpload: false, | |
| itemId: "property", | |
| labelAlign: "left", | |
| trackResetOnLoad: true, | |
| waitMsgTarget: true, | |
| border: false, | |
| labelWidth: this.isEditActiveTorrent ? 340 : 180, | |
| layoutConfig: { | |
| trackLabels: true | |
| }, | |
| defaults: { | |
| width: 200 | |
| }, | |
| items: a | |
| }; | |
| return b | |
| }, | |
| load: function() { | |
| if (SYNO.SDS.DownloadStation.DLM.Util.isUnzipServiceOn()) { | |
| this.setUnzipFieldVisible(true) | |
| } else { | |
| this.setUnzipFieldVisible(false) | |
| } | |
| this.taskIds = []; | |
| Ext.each(this.selections, function(c, a, b) { | |
| this.taskIds.push(c.get("task_id")) | |
| }, this); | |
| if (this.isSingle) { | |
| this.setTitle(_DT("tree", "leaf_downloadtask") + (" - " + this.selections[0].get("filename"))); | |
| this.appWin.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.Task.BT", | |
| method: "get", | |
| params: { | |
| task_id: this.selections[0].get("task_id") | |
| }, | |
| version: 2, | |
| scope: this, | |
| callback: function(d, b, c, a) { | |
| this.settingform.setValues(b); | |
| if (false === b.is_active_torrent) { | |
| this.setTorrentFieldsVisible(false); | |
| this.setDstFieldVisible(true) | |
| } else { | |
| if (SYNO.SDS.DownloadStation.DLM.Util.isSeedingStatus(this.selections[0].get("status"))) { | |
| this.setDstFieldVisible(false) | |
| } | |
| } | |
| this.show() | |
| } | |
| }) | |
| } else { | |
| this.setTitle(_DT("tree", "leaf_downloadtask")); | |
| this.show() | |
| } | |
| }, | |
| onCloseHandler: function(a, c, b) { | |
| this.settingform.reset(); | |
| this.close() | |
| }, | |
| saveSetting: function() { | |
| if (this.isEditActiveTorrent) { | |
| this.saveTorrentSetting() | |
| } else { | |
| this.saveDestination() | |
| } | |
| }, | |
| saveTorrentSetting: function() { | |
| var b, a; | |
| if (!this.settingform.isValid()) { | |
| this.setStatusError({ | |
| text: _T("common", "forminvalid"), | |
| clear: true | |
| }); | |
| return | |
| } | |
| if (!this.settingform.isDirty()) { | |
| this.onCloseHandler(); | |
| return | |
| } | |
| b = { | |
| task_id: this.taskIds | |
| }; | |
| a = this._getBTSetFieldValues(); | |
| if (this.handlePassword(a) === false) { | |
| return | |
| } | |
| if (0 === Object.keys(a).length) { | |
| this.onCloseHandler(); | |
| return | |
| } | |
| Ext.apply(b, a); | |
| this.setStatusBusy({ | |
| text: _T("common", "saving") | |
| }); | |
| this.appWin.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.Task.BT", | |
| method: "set", | |
| params: b, | |
| version: 2, | |
| scope: this, | |
| callback: function(f, d, e, c) { | |
| this.clearStatusBusy(); | |
| if (!f) { | |
| this.getMsgBox().alert(this.title, SYNO.SDS.DownloadStation.Utils.getErrorString(d.code)) | |
| } else { | |
| this.close() | |
| } | |
| } | |
| }) | |
| }, | |
| handlePassword: function(c) { | |
| if (SYNO.SDS.DownloadStation.DLM.Util.isUnzipServiceOn()) { | |
| var b = this.settingform.findField("extract_password"); | |
| if (b && b.isDirty()) { | |
| var a = b.getValue(); | |
| if (false === SYNO.SDS.DownloadStation.DLM.Util.handleNewUnzipPW.createDelegate(this, [a])()) { | |
| return false | |
| } | |
| c.extract_password = a | |
| } | |
| } | |
| return true | |
| }, | |
| saveDestination: function() { | |
| var a; | |
| if (!this.settingform.isDirty()) { | |
| this.onCloseHandler() | |
| } else { | |
| a = { | |
| id: this.taskIds, | |
| destination: this.settingform.findField("destination").getValue() | |
| }; | |
| if (this.handlePassword(a) === false) { | |
| return false | |
| } | |
| this.setStatusBusy({ | |
| text: _T("common", "saving") | |
| }); | |
| this.appWin.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.Task", | |
| method: "edit", | |
| params: a, | |
| version: 2, | |
| scope: this, | |
| callback: function(e, c, d, b) { | |
| this.clearStatusBusy(); | |
| if (!e) { | |
| this.getMsgBox().alert(this.title, SYNO.SDS.DownloadStation.Utils.getErrorString(c.code)) | |
| } else { | |
| this.close() | |
| } | |
| } | |
| }) | |
| } | |
| return a | |
| }, | |
| setTorrentFieldsVisible: function(b) { | |
| var a = this.get("property"); | |
| a.items.each(function(e, c, d) { | |
| if (e.itemId !== "destinationField" && e.itemId !== "extract_password") { | |
| e.setVisible(b); | |
| e.setDisabled(!b) | |
| } | |
| }, this) | |
| }, | |
| setDstFieldVisible: function(c) { | |
| var a = this.get("property"); | |
| var b = a.get("destinationField"); | |
| b.setVisible(c); | |
| b.setDisabled(!c) | |
| }, | |
| setUnzipFieldVisible: function(c) { | |
| var a = this.get("property"); | |
| var b = a.get("extract_password"); | |
| b.setVisible(c); | |
| b.setDisabled(!c) | |
| }, | |
| isAllActiveTorrent: function() { | |
| var a = true; | |
| console.log("here"); | |
| Ext.each(this.selections, function(d, b, c) { | |
| if ("bt" !== d.get("type") || !SYNO.SDS.DownloadStation.DLM.Util.isActiveTorrentStatus(d.get("status"))) { | |
| a = false; | |
| return false | |
| } | |
| }, this); | |
| return a | |
| }, | |
| _getBTSetFieldValues: function() { | |
| var c, b; | |
| var a = this.settingform.getFieldValues(true); | |
| if ("undefined" !== typeof a.seeding_interval_compositefield) { | |
| delete a.seeding_interval_compositefield; | |
| a.seeding_interval = this.settingform.findField("seeding_interval").getValue() | |
| } | |
| c = this.settingform.findField("destination"); | |
| if (c.isDirty()) { | |
| a.destination = c.getValue() | |
| } | |
| b = ["seeding_ratio", "max_upload_rate", "max_download_rate", "max_peers"]; | |
| b.forEach(function(d) { | |
| if ("" === a[d]) { | |
| delete a[d] | |
| } | |
| }); | |
| return a | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.DLM"); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.QueueActionGroup", { | |
| extend: "SYNO.SDS.DownloadStation.ActionGroup", | |
| stopable: [SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_DOWNLOADING, SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_WAITING, SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_FILEHOSTING_WAITING, SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_SEEDING, SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_HASH_CHECKING], | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| this.owner = a.owner; | |
| this.callParent([this.fillConfig(a)]) | |
| }, | |
| fillConfig: function(a) { | |
| var b = [new Ext.Button({ | |
| tooltip: _DT("download", "download_add_from_file"), | |
| iconCls: "syno-dl-a_bt_create", | |
| itemId: "add_file", | |
| scope: this, | |
| handler: function() { | |
| var d = function(e) { | |
| var f = new SYNO.SDS.DownloadStation.DLM.QueueAddDialog({ | |
| uicomponents: this.uicomponents, | |
| activeTab: 0 | |
| }); | |
| f.open() | |
| }; | |
| SYNO.SDS.DownloadStation.DLM.Util.checkLocationDestinationNonEmpty(this.owner, d, undefined, this) | |
| } | |
| }), new Ext.Button({ | |
| tooltip: _DT("download", "download_add_from_url"), | |
| iconCls: "syno-dl-a_bt_add", | |
| itemId: "add_url", | |
| scope: this, | |
| handler: function() { | |
| var d = function(e) { | |
| var f = new SYNO.SDS.DownloadStation.DLM.QueueAddDialog({ | |
| uicomponents: this.uicomponents, | |
| activeTab: 1 | |
| }); | |
| f.open() | |
| }; | |
| SYNO.SDS.DownloadStation.DLM.Util.checkLocationDestinationNonEmpty(this.owner, d, undefined, this) | |
| } | |
| }), new Ext.Button({ | |
| tooltip: _DT("download", "download_tip_resume"), | |
| iconCls: "syno-dl-a_bt_resume", | |
| itemId: "resume", | |
| disabled: true, | |
| scope: this, | |
| handler: function() { | |
| this.onStartAction("resume") | |
| } | |
| }), new Ext.Button({ | |
| tooltip: _DT("download", "download_tip_stop"), | |
| iconCls: "syno-dl-a_bt_pause", | |
| itemId: "pause", | |
| disabled: true, | |
| scope: this, | |
| handler: function() { | |
| this.onStartAction("pause") | |
| } | |
| }), new Ext.Button({ | |
| tooltip: _DT("download", "download_tip_end"), | |
| iconCls: "syno-dl-a_bt_end", | |
| itemId: "end", | |
| disabled: true, | |
| scope: this, | |
| handler: function() { | |
| this.onStartAction("end") | |
| } | |
| }), new Ext.Button({ | |
| tooltip: _T("common", "alt_edit"), | |
| iconCls: "syno-dl-a_bt_edit", | |
| itemId: "edit", | |
| disabled: true, | |
| scope: this, | |
| handler: function() { | |
| this.launchTaskEditDialog() | |
| } | |
| }), new Ext.Button({ | |
| tooltip: _DT("download", "download_tip_clear"), | |
| iconCls: "syno-dl-a_bt_clear", | |
| itemId: "clear", | |
| disabled: true, | |
| scope: this, | |
| handler: function() { | |
| this.onStartAction("clear") | |
| } | |
| }), new Ext.Button({ | |
| tooltip: _DT("download", "download_tip_remove"), | |
| iconCls: "syno-dl-a_bt_delete", | |
| itemId: "delete", | |
| disabled: true, | |
| scope: this, | |
| handler: function() { | |
| this.appWin.getMsgBox().confirm(_DT("tree", "leaf_downloadtask"), _DT("download", "download_cfrm_remove"), function(d, e) { | |
| if (d == "yes") { | |
| this.onStartAction("delete") | |
| } | |
| }, this) | |
| } | |
| })]; | |
| var c = new SYNO.ux.Menu({ | |
| autoDestroy: true, | |
| items: [{ | |
| text: _DT("download", "download_btn_resume_all"), | |
| scope: this, | |
| handler: function() { | |
| this.onStartAction("resume_all") | |
| } | |
| }, { | |
| text: _DT("download", "download_btn_pause_all"), | |
| scope: this, | |
| handler: function() { | |
| this.onStartAction("pause_all") | |
| } | |
| }, { | |
| text: _DT("download", "download_btn_remove_all"), | |
| scope: this, | |
| handler: function() { | |
| this.appWin.getMsgBox().confirm(_DT("tree", "leaf_downloadtask"), _DT("download", "download_remove_all_confirm"), function(d, e) { | |
| if (d === "yes") { | |
| this.onStartAction("delete_all") | |
| } | |
| }, this) | |
| } | |
| }] | |
| }); | |
| b.push(new Ext.Button({ | |
| tooltip: _DT("common", "action"), | |
| cls: "syno-dl-menu-btn", | |
| iconCls: "syno-dl-a_bt_action", | |
| itemId: "action", | |
| disabled: true, | |
| menu: c | |
| }), "->", { | |
| xtype: "syno_button", | |
| tooltip: _DT("download", "captcha_needed"), | |
| text: "0", | |
| itemId: "captcha", | |
| hidden: true, | |
| cls: "captcha-toolbar", | |
| scope: this, | |
| handler: this.launchCaptchaEnterDialog, | |
| disabled: false | |
| }, new SYNO.ux.TextFilter({ | |
| cls: "syno-ux-textfilter-text syno-dl-dlm-filter-icon", | |
| itemId: "filter", | |
| emptyText: _DT("common", "filter_label_text"), | |
| store: this.owner.grid.getStore(), | |
| pageSize: this.owner.grid.getBottomToolbar().pageSize | |
| })); | |
| return b | |
| }, | |
| endRequest: function(a) { | |
| this.owner.getMsgBox().show({ | |
| title: _DT("tree", "leaf_downloadtask"), | |
| msg: _DT("common", "msg_waiting"), | |
| width: 300, | |
| progress: false | |
| }); | |
| this.endPollingStart(a) | |
| }, | |
| getTaskIDArray: function(b, c) { | |
| var d = []; | |
| var a = SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT; | |
| c.forEach(function(f) { | |
| var e = f.get("status"); | |
| if ("clear" === b && a.TASK_FINISHED !== e) { | |
| return | |
| } else { | |
| if (("pause" === b || "pause_all" === b) && -1 === this.stopable.indexOf(e)) { | |
| return | |
| } else { | |
| if (("resume" === b || "resume_all" === b) && !(a.TASK_FINISHED === e && "bt" === f.get("type")) && !SYNO.SDS.DownloadStation.Utils.isTaskErrorStatus(e) && (a.TASK_PAUSED !== e)) { | |
| return | |
| } | |
| } | |
| } | |
| d.push(f.get("task_id")) | |
| }, this); | |
| return d | |
| }, | |
| onStartActionEnd: function() { | |
| var c = false | |
| , a = []; | |
| var b = this._checkEndableSelections(); | |
| if ((false === b) || Ext.isEmpty(b)) { | |
| return | |
| } | |
| Ext.each(b, function(d) { | |
| if (!c && SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_SEEDING !== d.get("status")) { | |
| c = true | |
| } | |
| a.push(d.get("task_id")) | |
| }); | |
| if (c) { | |
| this.owner.getMsgBox().confirm(_DT("tree", "leaf_downloadtask"), _DT("download", "download_end_warning"), function(d, e) { | |
| if (d == "yes") { | |
| this.endRequest(a) | |
| } | |
| }, this) | |
| } else { | |
| this.endRequest(a) | |
| } | |
| }, | |
| onStartAction: function(c) { | |
| var e = ["clear", "delete_all", "pause_all", "resume_all"]; | |
| var d = (-1 !== e.indexOf(c)); | |
| var f = this.owner.grid.getSelectionModel(); | |
| if (!d && false === f.hasSelection()) { | |
| this.owner.getMsgBox().alert(_DT("tree", "leaf_downloadtask"), _DT("download", "download_warning_select_items")); | |
| return | |
| } | |
| if ("end" === c) { | |
| this.onStartActionEnd(); | |
| return | |
| } | |
| var a = []; | |
| if (!d) { | |
| var b = f.getSelections(); | |
| a = this.getTaskIDArray(c, b); | |
| if (Ext.isEmpty(a)) { | |
| return | |
| } | |
| } | |
| this.onActionRequest(c, a) | |
| }, | |
| stopPollingTask: function() { | |
| this.pollingtask.stopById("updateTask"); | |
| this.pollingtask.stopById("infoTask"); | |
| this.resumeTaskList = []; | |
| var a = ["bt_tracker_poll_task", "bt_peer_poll_task", "QueueInfoFile"]; | |
| Ext.each(a, function(b) { | |
| var c = this.pollingtask.getTaskById(b); | |
| if (!Ext.isDefined(c) || !Ext.isDefined(c.running) || !c.running) { | |
| return | |
| } | |
| this.pollingtask.stopById(b); | |
| this.resumeTaskList.push(b) | |
| }, this) | |
| }, | |
| resumePollingTask: function() { | |
| this.pollingtask.startById("updateTask"); | |
| this.pollingtask.startById("infoTask"); | |
| this.pollingtask.startById(this.resumeTaskList, false); | |
| this.resumeTaskList = [] | |
| }, | |
| onActionRequest: function(c, a) { | |
| this.stopPollingTask(); | |
| this.queueGrid.getGridEl().mask(); | |
| var b = { | |
| id: a | |
| }; | |
| switch (c) { | |
| case "delete": | |
| Ext.apply(b, { | |
| force_complete: false | |
| }); | |
| break; | |
| case "clear": | |
| c = "delete_condition"; | |
| b = { | |
| type: ["emule"], | |
| type_inverse: true, | |
| status: [SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_FINISHED] | |
| }; | |
| break; | |
| case "delete_all": | |
| c = "delete_condition"; | |
| b = { | |
| type: ["emule"], | |
| type_inverse: true | |
| }; | |
| break; | |
| case "pause_all": | |
| c = "pause_condition"; | |
| b = { | |
| type: ["emule"], | |
| type_inverse: true | |
| }; | |
| break; | |
| case "resume_all": | |
| c = "resume_condition"; | |
| b = { | |
| type: ["emule"], | |
| type_inverse: true | |
| }; | |
| break; | |
| default: | |
| } | |
| this.appWin.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.Task", | |
| method: c, | |
| params: b, | |
| version: 2, | |
| scope: this, | |
| callback: this.onActionDone | |
| }) | |
| }, | |
| endPollingStart: function(a) { | |
| this.stopPollingTask(); | |
| this.queueGrid.getGridEl().mask(); | |
| this.appWin.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.Task.Complete", | |
| method: "start", | |
| version: 1, | |
| params: { | |
| id: a | |
| }, | |
| callback: function(e, c, d, b) { | |
| if (true !== e) { | |
| this.onActionDone(false, c, d, b); | |
| return | |
| } | |
| this.endPollingStatus(c.task_id) | |
| }, | |
| scope: this | |
| }) | |
| }, | |
| endPollingStatus: function(a) { | |
| this.appWin.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.Task.Complete", | |
| method: "status", | |
| version: 1, | |
| params: { | |
| task_id: a | |
| }, | |
| callback: function(c, b) { | |
| if (true !== c) { | |
| this.endPollingStop(a, { | |
| success: false, | |
| error: b | |
| }); | |
| return | |
| } | |
| if (!b.finish) { | |
| Ext.defer(function() { | |
| this.endPollingStatus(a) | |
| }, 5000, this) | |
| } else { | |
| this.endPollingStop(a, b) | |
| } | |
| }, | |
| scope: this | |
| }) | |
| }, | |
| endPollingStop: function(a, b) { | |
| this.appWin.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.Task.Complete", | |
| method: "stop", | |
| version: 1, | |
| params: { | |
| task_id: a | |
| }, | |
| callback: function(f, d, e, c) { | |
| this.hideMsg(); | |
| if (true !== f) { | |
| this.onActionDone(false, d, e, c); | |
| return | |
| } | |
| this.onActionDone(b.success, b.success ? b.data : b.error, e, c) | |
| }, | |
| scope: this | |
| }) | |
| }, | |
| onActionDone: function(e, c, d, b) { | |
| this.queueGrid.getGridEl().unmask(); | |
| if (e) { | |
| if ("delete" === b.params.method) { | |
| var a = this.queueGrid; | |
| a.forceSelectIdx = a.store.indexOf(a.selModel.getSelected()) | |
| } | |
| } else { | |
| this.appWin.getMsgBox().alert(_DT("tree", "leaf_downloadtask"), SYNO.SDS.DownloadStation.Utils.getErrorString(c.code)) | |
| } | |
| this.resumePollingTask() | |
| }, | |
| _checkEndableSelections: function() { | |
| var b = this.owner.grid.getSelectionModel(); | |
| var e = b.getSelections(); | |
| var c = b.grid.StatusNotEndable; | |
| var a = ""; | |
| var d = []; | |
| Ext.each(e, function(f) { | |
| if (-1 !== c.indexOf(f.get("status"))) { | |
| a = _DT("download", "download_end_note_finished"); | |
| return false | |
| } else { | |
| if (0 === f.get("current_size")) { | |
| a = _DT("download", "download_end_note_no_file"); | |
| return false | |
| } | |
| } | |
| d.push(f) | |
| }); | |
| if ("" !== a) { | |
| this.owner.getMsgBox().alert(_DT("tree", "leaf_downloadtask"), a); | |
| return false | |
| } | |
| return d | |
| }, | |
| updateBtns: function(b) { | |
| this.setEnableBtns(["clear", "action"], 0 !== b.grid.store.getCount()); | |
| var a = b.grid.updateBtnStatus(); | |
| this.setEnableBtns(["pause"], a.blStop); | |
| this.setEnableBtns(["resume"], a.blResume); | |
| this.setEnableBtns(["end"], a.blEnd); | |
| this.setEnableBtns(["delete"], a.blDelete); | |
| this.setEnableBtns(["edit"], a.blEdit) | |
| }, | |
| launchTaskEditDialog: function() { | |
| var a = new SYNO.SDS.DownloadStation.DLM.QueueEditBtDialog({ | |
| uicomponents: this.uicomponents | |
| }); | |
| a.load() | |
| }, | |
| launchCaptchaEnterDialog: function() { | |
| var a = new SYNO.SDS.DownloadStation.DLM.CaptchaEnterDialog({ | |
| uicomponents: this.uicomponents | |
| }); | |
| a.show() | |
| }, | |
| hideMsg: function() { | |
| if (!(this.owner && this.owner.isDestroyed)) { | |
| this.owner.getMsgBox().hide() | |
| } | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.DLM"); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.InfoGeneral", { | |
| extend: "SYNO.ux.FormPanel", | |
| constructor: function(a) { | |
| this.owner = a.owner; | |
| var b = this.fillConfig(a); | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| var b = { | |
| border: false, | |
| frame: false, | |
| defaults: { | |
| xtype: "syno_displayfield" | |
| }, | |
| items: [{ | |
| fieldLabel: _DT("download", "download_list_filename"), | |
| name: "filename", | |
| cls: "selectabletext allowDefCtxMenu" | |
| }, { | |
| fieldLabel: _DT("download", "download_list_dest_folder"), | |
| name: "destination" | |
| }, { | |
| fieldLabel: _DT("download", "download_list_filesize"), | |
| name: "filesize" | |
| }, { | |
| fieldLabel: _DT("download", "download_list_username"), | |
| name: "username", | |
| hidden: this._S("is_admin") ? false : true | |
| }, { | |
| fieldLabel: _DT("download", "download_list_url"), | |
| name: "url", | |
| cls: "selectabletext allowDefCtxMenu" | |
| }, { | |
| fieldLabel: _DT("download", "download_list_created_time"), | |
| name: "create_time" | |
| }, { | |
| fieldLabel: _DT("download", "download_list_completed_time"), | |
| name: "completed_time" | |
| }, { | |
| fieldLabel: _DT("download", "download_list_expected_waiting_time"), | |
| name: "waiting_seconds" | |
| }, { | |
| fieldLabel: _DT("download", "download_orgtorrent_field"), | |
| name: "orgtorrent", | |
| cls: "allowDefCtxMenu", | |
| htmlEncode: false | |
| }] | |
| }; | |
| Ext.apply(b, a); | |
| return b | |
| }, | |
| resetForm: function() { | |
| var a = this.getForm(); | |
| if (a) { | |
| a.findField("orgtorrent").hide(); | |
| a.reset() | |
| } | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.DLM"); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.InfoTransfer", { | |
| extend: "SYNO.ux.FormPanel", | |
| constructor: function(a) { | |
| this.owner = a.owner; | |
| var b = this.fillConfig(a); | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| var b = { | |
| border: false, | |
| frame: false, | |
| defaults: { | |
| xtype: "syno_displayfield" | |
| }, | |
| items: [{ | |
| fieldLabel: _DT("download", "download_list_status"), | |
| ctCls: "syno-dl-info-table-cell-20", | |
| name: "task_status" | |
| }, { | |
| fieldLabel: _DT("download", "download_list_transfered"), | |
| name: "transfered" | |
| }, { | |
| fieldLabel: _DT("download", "download_list_progress"), | |
| name: "progress" | |
| }, { | |
| fieldLabel: _DT("download", "download_list_speed"), | |
| name: "speed" | |
| }, { | |
| fieldLabel: _DT("download", "download_list_peer"), | |
| name: "totalpeer" | |
| }, { | |
| fieldLabel: _DT("download", "download_list_connected_peers"), | |
| name: "currpeer" | |
| }, { | |
| fieldLabel: _DT("download", "download_list_total_pieces"), | |
| name: "totalpieces" | |
| }, { | |
| fieldLabel: _DT("download", "download_list_downloaded_pieces"), | |
| name: "currpieces" | |
| }, { | |
| fieldLabel: _DT("download", "download_seed_elapsed"), | |
| name: "seed_elapsed" | |
| }, { | |
| fieldLabel: _T("download", "download_seeders") + "/" + _T("download", "download_leechers"), | |
| name: "seeders_leechers" | |
| }, { | |
| fieldLabel: _DT("download", "download_list_started_time"), | |
| name: "start_time" | |
| }, { | |
| fieldLabel: _DT("download", "download_time_left"), | |
| name: "time_left" | |
| }] | |
| }; | |
| Ext.apply(b, a); | |
| return b | |
| }, | |
| resetForm: function() { | |
| var a = this.getForm(); | |
| if (a) { | |
| a.findField("seed_elapsed").hide(); | |
| a.findField("seeders_leechers").hide(); | |
| a.findField("time_left").show(); | |
| a.reset() | |
| } | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.DLM"); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.InfoTracker", { | |
| extend: "SYNO.ux.GridPanel", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| this.owner = a.owner; | |
| this.NUM_REC_PER_PAGE = 50; | |
| this.gStart = 0; | |
| var b = this.fillConfig(a); | |
| this.callParent([b]); | |
| this.createPollingTask() | |
| }, | |
| fillConfig: function(a) { | |
| var b = this.createStore(); | |
| this.paging = this.createPagingToolbar(b); | |
| this.createActions(); | |
| var c = { | |
| border: false, | |
| view: new SYNO.ux.FleXcroll.grid.GridView({ | |
| forceFit: true | |
| }), | |
| stripeRows: true, | |
| autoExpandColumn: "url", | |
| enableColumnMove: false, | |
| enableColLock: false, | |
| enableColumnHide: false, | |
| enableHdMenu: false, | |
| enableColumnResize: true, | |
| tbar: { | |
| items: [this.btnAdd, this.btnRemove] | |
| }, | |
| bbar: this.paging, | |
| colModel: new Ext.grid.ColumnModel({ | |
| columns: [{ | |
| id: "url", | |
| header: _DT("download", "download_list_url"), | |
| dataIndex: "url" | |
| }, { | |
| header: _DT("download", "download_list_status"), | |
| dataIndex: "status", | |
| width: 65 | |
| }, { | |
| header: _DT("download", "update_in"), | |
| dataIndex: "update", | |
| width: 45, | |
| renderer: this.updateRenderer | |
| }, { | |
| header: _DT("download", "seeds"), | |
| dataIndex: "seeds", | |
| width: 20, | |
| renderer: this.seedPeerRenderer | |
| }, { | |
| header: _DT("download", "download_list_peer"), | |
| dataIndex: "peers", | |
| width: 20, | |
| renderer: this.seedPeerRenderer | |
| }] | |
| }), | |
| selModel: new Ext.grid.RowSelectionModel({ | |
| singleSelect: false, | |
| listeners: { | |
| scope: this, | |
| selectionchange: this.onSelectionChange | |
| } | |
| }), | |
| store: b, | |
| listeners: { | |
| scope: this, | |
| activate: this.onActivate, | |
| deactivate: this.onDeactivate, | |
| rowcontextmenu: this.onRowContextMenu | |
| } | |
| }; | |
| return Ext.apply(c, a) | |
| }, | |
| createPollingTask: function() { | |
| this.pollingtask.add({ | |
| id: "bt_tracker_poll_task", | |
| api: "SYNO.DownloadStation2.Task.BT.Tracker", | |
| method: "list", | |
| version: 2, | |
| interval: 10000, | |
| autoJsonDecode: true, | |
| beforestart: this.onBeforePollingTaskStart, | |
| callback: this.updateTrackers, | |
| scope: this | |
| }) | |
| }, | |
| onBeforePollingTaskStart: function(a) { | |
| a.reqConfig.params = { | |
| task_id: this.getSelectedTaskId(), | |
| offset: this.gStart || 0, | |
| limit: this.NUM_REC_PER_PAGE | |
| } | |
| }, | |
| updateTrackers: function(g, e, f, c) { | |
| var b; | |
| if (g && f.task_id === this.getSelectedTaskId() && this.isCountMatched(e)) { | |
| for (var a = 0; a < e.items.length; a++) { | |
| var d = this.store.getAt(a); | |
| if (!d || (d.get("url") != e.items[a].url)) { | |
| b = true; | |
| break | |
| } | |
| d.set("status", e.items[a].status); | |
| d.set("update", e.items[a].update); | |
| d.set("seeds", e.items[a].seeds); | |
| d.set("peers", e.items[a].peers); | |
| d.commit() | |
| } | |
| } else { | |
| b = true | |
| } | |
| if (b) { | |
| this.getStore().reload() | |
| } | |
| }, | |
| isCountMatched: function(a) { | |
| return (a.total === this.store.getTotalCount()) && (a.total > 0) | |
| }, | |
| createActions: function() { | |
| this.actionAdd = new Ext.Action({ | |
| text: _DT("common", "addto"), | |
| itemId: "add", | |
| scope: this, | |
| handler: this.addHandler | |
| }); | |
| this.actionRemove = new Ext.Action({ | |
| text: _DT("common", "remove"), | |
| itemId: "remove", | |
| scope: this, | |
| handler: this.removeHandler | |
| }); | |
| this.btnAdd = new SYNO.ux.Button({ | |
| text: _DT("common", "addto"), | |
| itemId: "add", | |
| scope: this, | |
| handler: this.addHandler | |
| }); | |
| this.btnRemove = new SYNO.ux.Button({ | |
| disabled: true, | |
| text: _DT("common", "remove"), | |
| itemId: "remove", | |
| scope: this, | |
| handler: this.removeHandler | |
| }) | |
| }, | |
| createStore: function() { | |
| return new SYNO.API.JsonStore({ | |
| api: "SYNO.DownloadStation2.Task.BT.Tracker", | |
| appWindow: this.appWin, | |
| method: "list", | |
| version: 2, | |
| root: "items", | |
| fields: ["url", "status", "update", "seeds", "peers"], | |
| autoLoad: false, | |
| baseParams: { | |
| limit: this.NUM_REC_PER_PAGE | |
| }, | |
| paramNames: { | |
| start: "offset", | |
| limit: "limit" | |
| }, | |
| totalProperty: "total", | |
| listeners: { | |
| scope: this, | |
| beforeload: this.onBeforeLoad, | |
| load: function(a, c, b) { | |
| if (this.getGridEl()) { | |
| this.getGridEl().unmask() | |
| } | |
| this.pollingtask.startById("bt_tracker_poll_task", false); | |
| this.onSelectionChange() | |
| }, | |
| exception: function(d, e, f, c, b, a) { | |
| if (!this.getGridEl().isMasked()) { | |
| this.getGridEl().mask(SYNO.SDS.DownloadStation.Utils.getErrorString(b.code)) | |
| } | |
| } | |
| } | |
| }) | |
| }, | |
| createPagingToolbar: function(a) { | |
| return new SYNO.ux.PagingToolbar({ | |
| store: a, | |
| pageSize: this.NUM_REC_PER_PAGE, | |
| displayInfo: true | |
| }) | |
| }, | |
| onBeforeLoad: function(a, b) { | |
| this.pollingtask.stopById("bt_tracker_poll_task"); | |
| var c = this.getSelectedTaskId(); | |
| if (!c) { | |
| return false | |
| } | |
| b.params.task_id = c; | |
| if ("undefined" !== typeof (b.params.offset)) { | |
| this.gStart = b.params.offset | |
| } else { | |
| this.gStart = 0 | |
| } | |
| }, | |
| getSelectedTaskId: function() { | |
| var a = this.owner.grid.selModel.getSelected(); | |
| if (!a || !a.get("task_id")) { | |
| return undefined | |
| } | |
| return a.get("task_id") | |
| }, | |
| onActivate: function() { | |
| this.getStore().reload() | |
| }, | |
| onDeactivate: function() { | |
| this.pollingtask.stopById("bt_tracker_poll_task") | |
| }, | |
| onSelectionChange: function() { | |
| var a = this.getSelectionModel(); | |
| if (0 === a.getCount()) { | |
| this.btnRemove.disable() | |
| } else { | |
| this.btnRemove.enable() | |
| } | |
| }, | |
| getContextMenu: function() { | |
| if (!this.contextMenu) { | |
| this.contextMenu = new SYNO.ux.Menu({ | |
| items: [this.actionAdd, this.actionRemove], | |
| listeners: { | |
| scope: this, | |
| show: function() { | |
| this.pollingtask.stopById("bt_tracker_poll_task") | |
| }, | |
| hide: function() { | |
| this.pollingtask.startById("bt_tracker_poll_task") | |
| } | |
| } | |
| }); | |
| this.addManagedComponent(this.contextMenu) | |
| } | |
| return this.contextMenu | |
| }, | |
| onRowContextMenu: function(b, d, a) { | |
| var c = b.getSelectionModel(); | |
| c.selectRow(d, c.isSelected(d)); | |
| this.getContextMenu().showAt(a.getXY()); | |
| a.preventDefault() | |
| }, | |
| getSelectionUrls: function() { | |
| var a = this.getSelectionModel().getSelections(); | |
| var b = []; | |
| Ext.each(a, function(e, c, d) { | |
| b.push(e.get("url")) | |
| }, this); | |
| return b | |
| }, | |
| removeTrackers: function(a) { | |
| if (!a || (0 === a.length)) { | |
| return | |
| } | |
| this.pollingtask.stopById("bt_tracker_poll_task"); | |
| this.appWin.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.Task.BT.Tracker", | |
| method: "delete", | |
| params: { | |
| task_id: this.getSelectedTaskId(), | |
| tracker: a | |
| }, | |
| version: 2, | |
| scope: this, | |
| callback: function(e, c, d, b) { | |
| this.pollingtask.startById("bt_tracker_poll_task") | |
| } | |
| }) | |
| }, | |
| addHandler: function() { | |
| var a = new SYNO.SDS.DownloadStation.DLM.AddTrackerDialog({ | |
| owner: this.appWin, | |
| task_id: this.getSelectedTaskId() | |
| }); | |
| a.mon(a, "close", function() { | |
| this.pollingtask.startById("bt_tracker_poll_task") | |
| }, this); | |
| this.pollingtask.stopById("bt_tracker_poll_task"); | |
| a.show() | |
| }, | |
| removeHandler: function() { | |
| var a = this.getSelectionUrls(); | |
| this.removeTrackers(a) | |
| }, | |
| seedPeerRenderer: function(d, b, c) { | |
| var a = Ext.util.Format.htmlEncode(d); | |
| return (d < 0) ? "" : a | |
| }, | |
| updateRenderer: function(c, a, b) { | |
| if (c === 0) { | |
| return "" | |
| } | |
| return Ext.util.Format.htmlEncode(SYNO.SDS.DownloadStation.DLM.Util.convertTimeLeft(c, false)) | |
| } | |
| }); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.AddTrackerDialog", { | |
| extend: "SYNO.SDS.ModalWindow", | |
| constructor: function(a) { | |
| this.owner = a.owner; | |
| this.task_id = a.task_id; | |
| var b = { | |
| owner: a.owner, | |
| cls: "syno-dl-win", | |
| title: _DT("download", "tracker") + " - " + _DT("common", "addto"), | |
| layout: "fit", | |
| width: 360, | |
| height: 320, | |
| items: { | |
| xtype: "syno_formpanel", | |
| padding: "0 0 12px 0", | |
| itemId: "form", | |
| border: false, | |
| height: "196px", | |
| layout: "fit", | |
| items: [{ | |
| xtype: "syno_textarea", | |
| cls: "selectabletext allowDefCtxMenu", | |
| hideLabel: true, | |
| name: "tracker", | |
| readOnly: false | |
| }] | |
| }, | |
| buttons: SYNO.SDS.DownloadStation.Utils.composeButtonCfg({ | |
| text: _T("common", "ok"), | |
| scope: this, | |
| btnStyle: "blue", | |
| handler: this.addTrackers | |
| }, { | |
| text: _T("common", "cancel"), | |
| scope: this, | |
| handler: this.close | |
| }) | |
| }; | |
| Ext.apply(b, a); | |
| this.callParent([b]); | |
| this.trackersForm = this.get("form").getForm() | |
| }, | |
| addTrackers: function() { | |
| var a, d, b = false; | |
| b = this.trackersForm.isDirty(); | |
| if (b) { | |
| d = { | |
| task_id: this.task_id | |
| }; | |
| a = this.trackersForm.getValues(); | |
| if (a.tracker) { | |
| var c = []; | |
| Ext.each(a.tracker.split(/\s+/), function(h, f, g) { | |
| var e = h.trim(); | |
| var i = e.toLowerCase(); | |
| if (0 === i.indexOf("http://") || 0 === i.indexOf("https://") || 0 === i.indexOf("udp://")) { | |
| c.push(e) | |
| } | |
| }, this); | |
| if (0 === c.length) { | |
| this.getMsgBox().alert(this.title, _DT("download", "tracker_wrong_url")); | |
| return | |
| } | |
| d.tracker = c | |
| } | |
| this.setStatusBusy({ | |
| text: _T("common", "saving") | |
| }); | |
| this.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.Task.BT.Tracker", | |
| method: "add", | |
| params: d, | |
| version: 2, | |
| scope: this, | |
| callback: function(h, f, g, e) { | |
| this.clearStatusBusy(); | |
| if (!h) { | |
| this.getMsgBox().alert(this.title, _T("common", "commfail")) | |
| } else { | |
| this.close() | |
| } | |
| } | |
| }) | |
| } | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.DLM"); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.InfoFile", { | |
| extend: "SYNO.ux.GridPanel", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| this.owner = a.owner; | |
| this.NUM_REC_PER_PAGE = 50; | |
| this.gStart = 0; | |
| this.createActions(); | |
| var b = this.fillConfig(a); | |
| this.callParent([b]); | |
| this.defineBehaviors() | |
| }, | |
| createActions: function() { | |
| var a = new Ext.menu.Menu({ | |
| items: [{ | |
| text: _DT("dlqueue", "dl_priority_high"), | |
| itemId: "high" | |
| }, { | |
| text: _DT("dlqueue", "dl_priority_normal"), | |
| itemId: "normal" | |
| }, { | |
| text: _DT("dlqueue", "dl_priority_low"), | |
| itemId: "low" | |
| }], | |
| listeners: { | |
| scope: this, | |
| itemclick: this.onPriorityItemClick | |
| } | |
| }); | |
| this.actionPriority = new Ext.Action({ | |
| text: _DT("dlqueue", "title_dl_priority"), | |
| itemId: "priority", | |
| menu: a | |
| }); | |
| this.actionSkip = new Ext.Action({ | |
| text: _T("common", "skip"), | |
| itemId: "skip", | |
| scope: this, | |
| handler: this.skipHandler | |
| }); | |
| this.actionCopyTo = new Ext.Action({ | |
| text: _DT("download", "copy_to"), | |
| itemId: "copy_to", | |
| scope: this, | |
| handler: this.copyToHandler | |
| }); | |
| this.btnPriority = new SYNO.ux.Button({ | |
| text: _DT("dlqueue", "title_dl_priority"), | |
| itemId: "priority", | |
| disabled: true, | |
| menu: a | |
| }); | |
| this.btnSkip = new SYNO.ux.Button({ | |
| text: _T("common", "skip"), | |
| itemId: "skip", | |
| disabled: true, | |
| scope: this, | |
| handler: this.skipHandler | |
| }); | |
| this.btnCopyTo = new SYNO.ux.Button({ | |
| text: _DT("download", "copy_to"), | |
| itemId: "copy_to", | |
| disabled: true, | |
| scope: this, | |
| handler: this.copyToHandler | |
| }) | |
| }, | |
| fillConfig: function(a) { | |
| this.dsFileList = this.createStore(); | |
| this.paging = this.createPagingToolbar(this.dsFileList); | |
| var b = { | |
| border: false, | |
| cls: "without-dirty-red-grid", | |
| view: new SYNO.ux.FleXcroll.grid.GridView({ | |
| forceFit: true | |
| }), | |
| stripeRows: true, | |
| autoExpandColumn: "dl-torrent-files", | |
| enableColumnMove: false, | |
| enableColLock: false, | |
| enableColumnHide: false, | |
| enableHdMenu: false, | |
| enableColumnResize: true, | |
| tbar: { | |
| items: [this.btnPriority, this.btnSkip, this.btnCopyTo, "->", this.btnQuery = new SYNO.TextFilter({ | |
| itemId: "search", | |
| width: 150, | |
| emptyText: _DT("tree", "leaf_search"), | |
| queryAction: "list_file", | |
| enumAction: "list_file", | |
| pageSize: this.NUM_REC_PER_PAGE, | |
| store: this.dsFileList | |
| })] | |
| }, | |
| bbar: this.paging, | |
| selModel: new Ext.grid.RowSelectionModel({ | |
| singleSelect: false, | |
| listeners: { | |
| scope: this, | |
| selectionchange: this.onGridSelectionChanged | |
| } | |
| }), | |
| colModel: new Ext.grid.ColumnModel({ | |
| defaultSortable: true, | |
| columns: [{ | |
| id: "dl-torrent-files", | |
| header: _DT("download", "download_list_filename"), | |
| dataIndex: "name", | |
| renderer: SYNO.SDS.DownloadStation.DLM.Util.nameRender.createDelegate(this) | |
| }, { | |
| header: _DT("download", "download_list_filesize"), | |
| dataIndex: "size", | |
| width: 30, | |
| renderer: SYNO.SDS.DownloadStation.DLM.Util.sizeRenderer | |
| }, { | |
| header: _DT("download", "download_list_completed"), | |
| dataIndex: "size_downloaded", | |
| width: 30, | |
| renderer: SYNO.SDS.DownloadStation.DLM.Util.sizeRenderer | |
| }, { | |
| header: _DT("download", "download_list_progress"), | |
| dataIndex: "progress", | |
| width: 30, | |
| renderer: this.calculateProgressRenderer | |
| }, { | |
| header: _DT("dlqueue", "title_dl_priority"), | |
| dataIndex: "priority", | |
| width: 30, | |
| renderer: this.priorityRenderer | |
| }] | |
| }), | |
| store: this.dsFileList, | |
| listeners: { | |
| scope: this, | |
| rowclick: { | |
| fn: function(d, g, f) { | |
| var c = this.owner.grid.selModel.getSelected().get("status"); | |
| if (c !== SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_DOWNLOADING || this.dsFileList.getTotalCount() == 1) { | |
| return | |
| } | |
| if (f && !f.hasModifier()) { | |
| d.getSelectionModel().selectRow(g) | |
| } | |
| } | |
| }, | |
| rowcontextmenu: this.onRowContextMenu, | |
| activate: this.onActivate, | |
| deactivate: this.onDeactivate | |
| } | |
| }; | |
| Ext.apply(b, a); | |
| return SYNO.LayoutConfig.fill(b) | |
| }, | |
| createStore: function() { | |
| return new SYNO.API.JsonStore({ | |
| api: "SYNO.DownloadStation2.Task.BT.File", | |
| appWindow: this.appWin, | |
| method: "list", | |
| version: 2, | |
| root: "items", | |
| autoDestroy: true, | |
| fields: ["index", "name", "size", "size_downloaded", "progress", "priority", "wanted"], | |
| remoteSort: true, | |
| baseParams: { | |
| limit: this.NUM_REC_PER_PAGE | |
| }, | |
| totalProperty: "total", | |
| paramNames: { | |
| start: "offset", | |
| limit: "limit", | |
| sort: "sort_by", | |
| dir: "order" | |
| }, | |
| sortInfo: { | |
| field: "name", | |
| direction: "ASC" | |
| }, | |
| pruneModifiedRecords: false, | |
| listeners: { | |
| scope: this, | |
| beforeload: this.onBeforeLoad, | |
| load: function() { | |
| if (this.getGridEl()) { | |
| this.getGridEl().unmask() | |
| } | |
| this.onGridSelectionChanged(); | |
| this.pollingtask.startById("QueueInfoFile", false) | |
| }, | |
| exception: function(d, e, f, c, b, a) { | |
| this.onGridSelectionChanged(); | |
| if (!this.getGridEl().isMasked()) { | |
| this.getGridEl().mask(SYNO.SDS.DownloadStation.Utils.getErrorString(b.code)) | |
| } | |
| } | |
| } | |
| }) | |
| }, | |
| onGridSelectionChanged: function() { | |
| this.btnPriority.enable(); | |
| this.btnSkip.enable(); | |
| var a = this.getSelectionModel(); | |
| var b = false; | |
| if (a.getCount() === 0) { | |
| this.btnPriority.disable(); | |
| this.btnSkip.disable(); | |
| b = true | |
| } | |
| a.selections.each(function(c) { | |
| if (c.data.size_downloaded !== c.data.size) { | |
| b = true | |
| } | |
| }, this); | |
| this.btnCopyTo.setDisabled(b); | |
| this.actionCopyTo.setDisabled(b) | |
| }, | |
| defineBehaviors: function() { | |
| this.btnPriority = this.getTopToolbar().get("priority"); | |
| this.btnSkip = this.getTopToolbar().get("skip"); | |
| this.btnCopyTo = this.getTopToolbar().get("copy_to"); | |
| this.createPollingTask() | |
| }, | |
| createPagingToolbar: function(a) { | |
| return new SYNO.ux.PagingToolbar({ | |
| store: a, | |
| pageSize: this.NUM_REC_PER_PAGE, | |
| displayInfo: true | |
| }) | |
| }, | |
| getTorrentFileSelection: function(c) { | |
| var a = []; | |
| for (var b = 0; b < c.length; b++) { | |
| a.push({ | |
| name: c[b].get("name") | |
| }) | |
| } | |
| return a | |
| }, | |
| onBeforeLoad: function(a, b) { | |
| var c = this.getSelectedTaskId(); | |
| if (!c) { | |
| return false | |
| } | |
| this.pollingtask.stopById("QueueInfoFile"); | |
| b.params.task_id = c; | |
| if ("undefined" !== typeof (b.params.offset)) { | |
| this.gStart = b.params.offset | |
| } else { | |
| this.gStart = 0 | |
| } | |
| }, | |
| getSelectedTaskId: function() { | |
| var a = this.owner.grid.selModel.getSelected(); | |
| if (!a || !a.get("task_id")) { | |
| return undefined | |
| } | |
| return a.get("task_id") | |
| }, | |
| createPollingTask: function() { | |
| this.pollingtask.add({ | |
| id: "QueueInfoFile", | |
| api: "SYNO.DownloadStation2.Task.BT.File", | |
| method: "list", | |
| version: 2, | |
| interval: 5000, | |
| autoJsonDecode: true, | |
| beforestart: this.onBeforePollingTaskStart, | |
| callback: this.updateTasks, | |
| scope: this | |
| }) | |
| }, | |
| onBeforePollingTaskStart: function(a) { | |
| a.reqConfig.params = { | |
| task_id: this.getSelectedTaskId(), | |
| offset: this.gStart || 0, | |
| limit: this.NUM_REC_PER_PAGE, | |
| sort_by: this.getStore().sortInfo.field, | |
| order: this.getStore().sortInfo.direction, | |
| query: this.btnQuery.getValue() | |
| } | |
| }, | |
| updateTasks: function(g, e, f, c) { | |
| var b; | |
| if (g && f.task_id === this.getSelectedTaskId() && (e.total === this.store.getTotalCount() && e.total > 0)) { | |
| if (this.getGridEl()) { | |
| this.getGridEl().unmask() | |
| } | |
| for (var a = 0; a < e.items.length; a++) { | |
| var d = this.store.getAt(a); | |
| if (!d || (d.get("index") != e.items[a].index)) { | |
| b = true; | |
| break | |
| } | |
| d.set("name", e.items[a].name); | |
| d.set("size", e.items[a].size); | |
| d.set("size_downloaded", e.items[a].size_downloaded); | |
| d.set("priority", e.items[a].priority); | |
| d.set("wanted", e.items[a].wanted); | |
| d.commit() | |
| } | |
| } else { | |
| b = true | |
| } | |
| if (b) { | |
| this.getStore().reload() | |
| } | |
| }, | |
| isExpectedTask: function(a) { | |
| return a.success && a.task_id === this.getSelectedTaskId() | |
| }, | |
| onActivate: function() { | |
| this.pollingtask.startById("QueueInfoFile", true) | |
| }, | |
| onDeactivate: function() { | |
| this.pollingtask.stopById("QueueInfoFile") | |
| }, | |
| getContextMenu: function() { | |
| if (!this.contextMenu) { | |
| this.contextMenu = new SYNO.ux.Menu({ | |
| items: [this.actionPriority, this.actionSkip, this.actionCopyTo], | |
| listeners: { | |
| scope: this, | |
| show: function() { | |
| this.pollingtask.stopById("QueueInfoFile") | |
| }, | |
| hide: function() { | |
| this.pollingtask.startById("QueueInfoFile", true) | |
| } | |
| } | |
| }); | |
| this.addManagedComponent(this.contextMenu) | |
| } | |
| return this.contextMenu | |
| }, | |
| onRowContextMenu: function(b, d, a) { | |
| var c = b.getSelectionModel(); | |
| c.selectRow(d, c.isSelected(d)); | |
| this.getContextMenu().showAt(a.getXY()); | |
| a.preventDefault() | |
| }, | |
| getSelectionIndexes: function() { | |
| var b = this.getSelectionModel().getSelections(); | |
| var a = []; | |
| Ext.each(b, function(e, c, d) { | |
| a.push(e.get("index")) | |
| }, this); | |
| return a | |
| }, | |
| skipHandler: function() { | |
| var a = { | |
| task_id: this.getSelectedTaskId(), | |
| index: this.getSelectionIndexes(), | |
| wanted: false | |
| }; | |
| this.setFiles(a) | |
| }, | |
| copyToHandler: function() { | |
| this.utils.chooseDestHandler({ | |
| owner: this.appWin, | |
| callback: function(c, b, a) { | |
| if (b) { | |
| this.applyCopyTo(b.path.substr(1)) | |
| } | |
| c.close() | |
| }, | |
| callbackScope: this | |
| }) | |
| }, | |
| applyCopyTo: function(a) { | |
| this.mask(_T("common", "saving")); | |
| this.pollingtask.stopById("QueueInfoFile"); | |
| this.appWin.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.Task.BT.File", | |
| method: "copy", | |
| version: 2, | |
| params: { | |
| task_id: this.getSelectedTaskId(), | |
| index: this.getSelectionIndexes(), | |
| destination: a | |
| }, | |
| scope: this, | |
| callback: function(g, d, f, c) { | |
| this.unmask(); | |
| var e = _T("common", "commfail"); | |
| var b = []; | |
| if (g) { | |
| this.selModel.selections.each(function(h) { | |
| b.push(h.data.name) | |
| }, this); | |
| e = String.format(_T("filebrowser", "filebrowser_copy_completed"), b.join(", ")) | |
| } else { | |
| if (d.code) { | |
| e = SYNO.SDS.DownloadStation.Utils.getErrorString(d.code) | |
| } else { | |
| if (d.copy_failed && 0 < d.copy_failed.length) { | |
| e = String.format(_T("filebrowser", "filebrowser_copy_failed"), d.copy_failed.join(", "), "") | |
| } | |
| } | |
| } | |
| this.appWin.getMsgBox().alert("", e); | |
| this.pollingtask.startById("QueueInfoFile", true) | |
| } | |
| }) | |
| }, | |
| onPriorityItemClick: function(b, a) { | |
| var c = { | |
| task_id: this.getSelectedTaskId(), | |
| index: this.getSelectionIndexes(), | |
| priority: b.itemId | |
| }; | |
| this.setFiles(c) | |
| }, | |
| setFiles: function(a) { | |
| if (!a.index || (0 === a.index.length)) { | |
| return | |
| } | |
| this.pollingtask.stopById("QueueInfoFile"); | |
| this.appWin.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.Task.BT.File", | |
| method: "set", | |
| version: 2, | |
| params: a, | |
| scope: this, | |
| callback: function(e, c, d, b) { | |
| this.pollingtask.startById("QueueInfoFile", true) | |
| } | |
| }) | |
| }, | |
| calculateProgressRenderer: function(f, d, e) { | |
| var c = e.get("size"); | |
| var a = e.get("size_downloaded"); | |
| var b; | |
| if (0 === c) { | |
| b = 1 | |
| } else { | |
| b = a / c | |
| } | |
| if (1 > b && 0.9994 < b) { | |
| b = 0.9994 | |
| } | |
| return Ext.util.Format.htmlEncode(Ext.util.Format.number((b * 100), "0.0") + " %") | |
| }, | |
| priorityRenderer: function(d, b, c) { | |
| var a = c.get("wanted"); | |
| if (!a) { | |
| return _T("common", "skip") | |
| } | |
| if ("normal" === d) { | |
| return _DT("dlqueue", "dl_priority_normal") | |
| } else { | |
| if ("high" === d) { | |
| return _DT("dlqueue", "dl_priority_high") | |
| } else { | |
| if ("low" === d) { | |
| return _DT("dlqueue", "dl_priority_low") | |
| } | |
| } | |
| } | |
| return "" | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.DLM"); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.InfoPreview", { | |
| extend: "SYNO.ux.Panel", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| var b = this.fillConfig(a); | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| this.webapiGet = { | |
| api: "SYNO.DownloadStation2.Thumbnail", | |
| method: "get", | |
| version: 2 | |
| }; | |
| this.webapiDownload = { | |
| api: "SYNO.DownloadStation2.Thumbnail", | |
| method: "download", | |
| version: 2 | |
| }; | |
| this.previewIndex = -1; | |
| this.tpl = new Ext.XTemplate('<tpl for=".">','<div class="thumb-wrap">','<div class="thumb">',"{[this.getImgHtml(values)]}","</div>",'<span class="thumb-filename" ext:qtip="{[this.getToolTip(values.name)]}">{name}</span>',"</div>","</tpl>",{ | |
| compile: true, | |
| disableFormat: true, | |
| getImgHtml: this.getImgHtml.createDelegate(this), | |
| getToolTip: this.getToolTip | |
| }); | |
| this.videoStore = this.getStore(); | |
| this.photoStore = this.getStore(); | |
| this.videoDataView = this.getVideoDataView(this.videoStore); | |
| this.photoDataView = this.getPhotoDataView(this.photoStore); | |
| var b = { | |
| cls: "preview-panel", | |
| autoFlexcroll: true, | |
| items: [{ | |
| xtype: "syno_fieldset", | |
| title: _T("mediaservice", "class_video"), | |
| itemId: "video_fieldset", | |
| hidden: true, | |
| items: [this.videoDataView] | |
| }, { | |
| xtype: "syno_fieldset", | |
| title: _T("mediaservice", "class_photo"), | |
| itemId: "photo_fieldset", | |
| hidden: true, | |
| items: [this.photoDataView] | |
| }], | |
| listeners: { | |
| scope: this, | |
| activate: this.onActivate, | |
| deactivate: this.onDeactivate | |
| } | |
| }; | |
| Ext.apply(b, a); | |
| return b | |
| }, | |
| getStore: function() { | |
| return new Ext.data.JsonStore({ | |
| fields: ["name", "url", "show_first_url"] | |
| }) | |
| }, | |
| getVideoDataView: function(a) { | |
| return new SYNO.ux.FleXcroll.DataView({ | |
| store: a, | |
| tpl: this.tpl, | |
| autoHeight: true, | |
| autoFlexcroll: false, | |
| trackOver: true, | |
| itemSelector: "div.thumb", | |
| listeners: { | |
| scope: this, | |
| click: this.onClick, | |
| mouseleave: this.onMouseLeave | |
| } | |
| }) | |
| }, | |
| getPhotoDataView: function(a) { | |
| return new SYNO.ux.FleXcroll.DataView({ | |
| store: a, | |
| tpl: this.tpl, | |
| autoHeight: true, | |
| autoFlexcroll: false, | |
| itemSelector: "div.thumb" | |
| }) | |
| }, | |
| onClick: function(d, a, b, c) { | |
| if (0 <= this.previewIndex) { | |
| if (this.previewIndex == a) { | |
| this.stopPreview(d, a); | |
| return | |
| } | |
| this.stopPreview(d, this.previewIndex) | |
| } | |
| this.startPreview(d, a, b) | |
| }, | |
| onMouseLeave: function(d, a, b, c) { | |
| d.overClass = "synodl-thumbnail-mouse-over" | |
| }, | |
| startPreview: function(c, b) { | |
| this.previewIndex = b; | |
| var a = c.store.getRange(b, b)[0].data; | |
| a.show_first_url = false; | |
| c.tpl.override(c.getNode(b), a); | |
| c.overClass = undefined; | |
| c.refresh(); | |
| this.pollingtask.add({ | |
| id: "change_thumbnail_task", | |
| interval: 1000, | |
| run: this.changeShowedImage, | |
| args: [b], | |
| scope: this | |
| }); | |
| this.pollingtask.startById("change_thumbnail_task", false) | |
| }, | |
| stopPreview: function(c, b) { | |
| this.previewIndex = -1; | |
| var a = c.store.getRange(b, b)[0].data; | |
| a.show_first_url = true; | |
| c.tpl.override(c.getNode(b), a); | |
| c.refresh(); | |
| this.pollingtask.stopById("change_thumbnail_task"); | |
| this.resetShowedImage(b) | |
| }, | |
| changeShowedImage: function(c) { | |
| var b = this.videoDataView.getNodes(); | |
| var d = b[c]; | |
| if (!Ext.isDefined(d)) { | |
| return | |
| } | |
| var a = d.getElementsByClassName("show-thumbnail")[0]; | |
| a.classList.remove("show-thumbnail"); | |
| var e = a.nextSibling; | |
| if (null === e) { | |
| e = d.getElementsByTagName("img")[0] | |
| } | |
| e.classList.add("show-thumbnail") | |
| }, | |
| resetShowedImage: function(c) { | |
| var b = this.videoDataView.getNodes(); | |
| var d = b[c]; | |
| if (!Ext.isDefined(d)) { | |
| return | |
| } | |
| var a = d.getElementsByClassName("show-thumbnail")[0]; | |
| a.classList.remove("show-thumbnail"); | |
| var e = d.getElementsByTagName("img")[0]; | |
| e.classList.add("show-thumbnail") | |
| }, | |
| getToolTip: function(a) { | |
| return Ext.util.Format.htmlEncode(a) | |
| }, | |
| getImgHtml: function(b) { | |
| var c = ""; | |
| var a = []; | |
| if (b.show_first_url) { | |
| a = [b.url[0]]; | |
| if (1 < b.url.length) { | |
| c += '<div class="cover-play"></div>' | |
| } | |
| } else { | |
| a = b.url; | |
| c += '<div class="cover-stop"></div>' | |
| } | |
| Ext.each(a, function(e, d) { | |
| if (0 === d) { | |
| c += '<img src="' + e + '" class="show-thumbnail">' | |
| } else { | |
| c += '<img src="' + e + '" class="">' | |
| } | |
| }, this); | |
| return c | |
| }, | |
| onActivate: function() { | |
| this.el.unmask(); | |
| this.getAvailbleThumbnail() | |
| }, | |
| onDeactivate: function() { | |
| this.pollingtask.stopById("change_thumbnail_task"); | |
| if (0 <= this.previewIndex) { | |
| this.stopPreview(this.videoDataView, this.previewIndex) | |
| } | |
| }, | |
| getAvailbleThumbnail: function() { | |
| var a = this.getTaskId(); | |
| if (false === a) { | |
| this.setErrorMessage(null); | |
| return | |
| } | |
| SYNO.API.Request({ | |
| webapi: Ext.apply(this.webapiGet, { | |
| params: { | |
| id: a | |
| } | |
| }), | |
| callback: function(e, c, d, b) { | |
| if (!e) { | |
| this.setErrorMessage(c.code); | |
| return | |
| } | |
| this.setThumbnail(c) | |
| }, | |
| scope: this | |
| }) | |
| }, | |
| getTaskId: function() { | |
| var a = this.owner.grid.selModel.getSelected(); | |
| if (!Ext.isDefined(a) || !Ext.isDefined(a.get("task_id"))) { | |
| return false | |
| } | |
| return a.get("task_id") | |
| }, | |
| resetPreviewPanel: function() { | |
| this.videoData = []; | |
| this.photoData = []; | |
| this.videoStore.loadData(this.videoData); | |
| this.photoStore.loadData(this.photoData) | |
| }, | |
| setErrorMessage: function(a) { | |
| this.resetPreviewPanel(); | |
| this.showHideFieldSet(); | |
| this.el.mask(this.getErrorMessageByCode(a)) | |
| }, | |
| getThumbnailURL: function(a) { | |
| return this.getBaseURL(Ext.apply(this.webapiDownload, { | |
| params: { | |
| thumbnail_id: a | |
| } | |
| })) | |
| }, | |
| getExtension: function(a) { | |
| return a.split(".").pop() | |
| }, | |
| isPhoto: function(a) { | |
| var c = this.getExtension(a); | |
| if (!Ext.isDefined(c)) { | |
| return false | |
| } | |
| var b = ["jpg", "jpeg", "jpe", "bmp", "png", "tif", "tiff", "gif", "arw", "srf", "sr2", "dcr", "k25", "kdc", "cr2", "crw", "nef", "mrw", "ptx", "pef", "raf", "3fr", "erf", "mef", "mos", "orf", "rw2", "dng", "x3f", "raw"]; | |
| return (b.indexOf(c.toLowerCase()) > -1) | |
| }, | |
| getFileName: function(a) { | |
| return a.split("/").pop() | |
| }, | |
| showHideFieldSet: function() { | |
| var b = (0 === this.videoData.length); | |
| var a = (0 === this.photoData.length); | |
| this.getComponent("video_fieldset").setVisible(!b); | |
| this.getComponent("photo_fieldset").setVisible(!a) | |
| }, | |
| setThumbnail: function(a) { | |
| if (!Ext.isDefined(a) || !Ext.isArray(a) || 0 >= a.length) { | |
| this.setErrorMessage(null); | |
| return | |
| } | |
| this.videoData = []; | |
| this.photoData = []; | |
| Ext.each(a, function(d, c) { | |
| var b = {}; | |
| b.name = this.getFileName(d.file_name); | |
| b.show_first_url = true; | |
| b.url = []; | |
| Ext.each(d.thumbnail_list, function(f, e) { | |
| b.url.push(this.getThumbnailURL(f.thumbnail_id)) | |
| }, this); | |
| if (this.isPhoto(b.name)) { | |
| this.photoData.push(b) | |
| } else { | |
| this.videoData.push(b) | |
| } | |
| }, this); | |
| this.videoStore.loadData(this.videoData); | |
| this.photoStore.loadData(this.photoData); | |
| this.showHideFieldSet() | |
| }, | |
| getErrorMessageByCode: function(b) { | |
| var a = _DT("common", "error_system"); | |
| switch (b) { | |
| case 2200: | |
| a = _DT("download", "preview_image_not_ready"); | |
| break; | |
| case 2201: | |
| a = _DT("download", "task_not_support_preview"); | |
| break; | |
| default: | |
| } | |
| return a | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.DLM"); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.InfoPeer", { | |
| extend: "SYNO.ux.GridPanel", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| this.owner = a.owner; | |
| this.NUM_REC_PER_PAGE = 50; | |
| var b = this.createStore(); | |
| this.paging = this.createPagingToolbar(b); | |
| var c = { | |
| border: false, | |
| view: new SYNO.ux.FleXcroll.grid.GridView({ | |
| forceFit: true | |
| }), | |
| stripeRows: true, | |
| autoExpandColumn: "ip", | |
| enableColumnMove: false, | |
| enableColLock: false, | |
| enableColumnHide: false, | |
| enableHdMenu: false, | |
| enableColumnResize: true, | |
| bbar: this.paging, | |
| colModel: new Ext.grid.ColumnModel({ | |
| columns: [{ | |
| id: "ip", | |
| header: _DT("download", "peer_ip"), | |
| dataIndex: "ip" | |
| }, { | |
| header: _DT("download", "peer_client"), | |
| dataIndex: "client", | |
| width: 60 | |
| }, { | |
| header: _DT("download", "download_list_progress"), | |
| dataIndex: "progress", | |
| width: 30, | |
| renderer: this.progressRenderer | |
| }, { | |
| header: _DT("download", "download_list_upload_rate"), | |
| dataIndex: "speed_upload", | |
| width: 40, | |
| renderer: this.rateRenderer | |
| }, { | |
| header: _DT("download", "download_list_down_rate"), | |
| dataIndex: "speed_download", | |
| width: 40, | |
| renderer: this.rateRenderer | |
| }] | |
| }), | |
| store: b, | |
| listeners: { | |
| scope: this, | |
| activate: this.onActivate, | |
| deactivate: this.onDeactivate | |
| } | |
| }; | |
| Ext.apply(c, a); | |
| this.callParent([c]); | |
| this.createPollingTask() | |
| }, | |
| createStore: function(a) { | |
| return new SYNO.API.JsonStore({ | |
| api: "SYNO.DownloadStation2.Task.BT.Peer", | |
| appWindow: this.appWin, | |
| method: "list", | |
| version: 2, | |
| root: "items", | |
| baseParams: { | |
| limit: this.NUM_REC_PER_PAGE | |
| }, | |
| paramNames: { | |
| start: "offset", | |
| limit: "limit" | |
| }, | |
| totalProperty: "total", | |
| fields: ["ip", "client", "progress", "speed_upload", "speed_download"], | |
| listeners: { | |
| scope: this, | |
| beforeload: this.onBeforeLoad, | |
| load: function(b, d, c) { | |
| if (this.getGridEl() && this.getGridEl().isMasked()) { | |
| this.getGridEl().unmask() | |
| } | |
| }, | |
| exception: function(e, f, g, d, c, b) { | |
| if (!this.getGridEl().isMasked()) { | |
| this.getGridEl().mask(SYNO.SDS.DownloadStation.Utils.getErrorString(c.code)) | |
| } | |
| } | |
| } | |
| }) | |
| }, | |
| createPagingToolbar: function(a) { | |
| return new SYNO.ux.PagingToolbar({ | |
| store: a, | |
| pageSize: this.NUM_REC_PER_PAGE, | |
| displayInfo: true | |
| }) | |
| }, | |
| createPollingTask: function() { | |
| this.pollingtask.add({ | |
| id: "bt_peer_poll_task", | |
| interval: 5000, | |
| scope: this, | |
| run: function() { | |
| this.getStore().reload() | |
| } | |
| }) | |
| }, | |
| onActivate: function() { | |
| this.pollingtask.startById("bt_peer_poll_task") | |
| }, | |
| onDeactivate: function() { | |
| this.pollingtask.stopById("bt_peer_poll_task") | |
| }, | |
| onBeforeLoad: function(a, b) { | |
| var c = this.getSelectedTaskId(); | |
| if (!c) { | |
| return false | |
| } | |
| b.params.task_id = c | |
| }, | |
| getSelectedTaskId: function() { | |
| var a = this.owner.grid.selModel.getSelected(); | |
| if (!a || !a.get("task_id")) { | |
| return undefined | |
| } | |
| return a.get("task_id") | |
| }, | |
| progressRenderer: function(c, a, b) { | |
| c *= 100; | |
| return Ext.util.Format.htmlEncode(Ext.util.Format.number(c, "0.0") + "%") | |
| }, | |
| rateRenderer: function(d, a, c) { | |
| var b = Ext.util.Format.number(d / 1024, "0.0") + " KB/s"; | |
| return (d > 0) ? Ext.util.Format.htmlEncode(b) : "" | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.DLM"); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.InfoNZBFile", { | |
| extend: "SYNO.ux.GridPanel", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| this.owner = a.owner; | |
| this.NUM_REC_PER_PAGE = 50; | |
| this.gStart = 0; | |
| var b = this.fillConfig(a); | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| this.dsFileList = this.createStore(); | |
| this.paging = this.createPagingToolbar(this.dsFileList); | |
| var b = { | |
| border: false, | |
| cls: "without-dirty-red-grid", | |
| stripeRows: true, | |
| loadMask: true, | |
| autoExpandColumn: "filename", | |
| enableColumnMove: false, | |
| enableColLock: false, | |
| enableColumnHide: false, | |
| bbar: this.paging, | |
| view: new SYNO.ux.FleXcroll.grid.GridView({ | |
| forceFit: true | |
| }), | |
| selModel: new Ext.grid.RowSelectionModel({ | |
| singleSelect: false | |
| }), | |
| colModel: new Ext.grid.ColumnModel({ | |
| defaultSortable: false, | |
| columns: [{ | |
| id: "filename", | |
| header: _DT("download", "download_list_filename"), | |
| dataIndex: "name", | |
| renderer: SYNO.SDS.DownloadStation.DLM.Util.nameRender.createDelegate(this) | |
| }, { | |
| header: _DT("download", "download_list_filesize"), | |
| dataIndex: "size", | |
| width: 100, | |
| renderer: SYNO.SDS.DownloadStation.Utils.fileSize | |
| }] | |
| }), | |
| store: this.dsFileList, | |
| listeners: { | |
| scope: this, | |
| activate: this.onActivate, | |
| deactivate: this.onDeactivate | |
| } | |
| }; | |
| Ext.apply(b, a); | |
| return SYNO.LayoutConfig.fill(b) | |
| }, | |
| createStore: function() { | |
| return new SYNO.API.JsonStore({ | |
| api: "SYNO.DownloadStation2.Task.NZB.File", | |
| method: "list", | |
| appWindow: this.appWin, | |
| version: 1, | |
| root: "items", | |
| autoDestroy: true, | |
| fields: ["name", "size"], | |
| autoLoad: true, | |
| remoteSort: false, | |
| baseParams: { | |
| limit: this.NUM_REC_PER_PAGE | |
| }, | |
| totalProperty: "total", | |
| pruneModifiedRecords: false, | |
| paramNames: { | |
| start: "offset", | |
| limit: "limit" | |
| }, | |
| listeners: { | |
| scope: this, | |
| beforeload: this.onBeforeLoad, | |
| load: function() { | |
| if (this.getGridEl()) { | |
| this.getGridEl().unmask() | |
| } | |
| this.dsFileListLoaded = true | |
| }, | |
| exception: function(d, e, f, c, b, a) { | |
| if (!this.getGridEl().isMasked()) { | |
| this.getGridEl().mask(SYNO.SDS.DownloadStation.Utils.getErrorString(b.code)) | |
| } | |
| } | |
| } | |
| }) | |
| }, | |
| createPagingToolbar: function(a) { | |
| return new SYNO.ux.PagingToolbar({ | |
| store: a, | |
| pageSize: this.NUM_REC_PER_PAGE, | |
| displayInfo: true | |
| }) | |
| }, | |
| onActivate: function() { | |
| if (!this.dsFileListLoaded) { | |
| this.dsFileList.load({ | |
| waitMsg: _DT("common", "loading") | |
| }) | |
| } | |
| }, | |
| onDeactivate: function() { | |
| this.dsFileList.removeAll(); | |
| this.dsFileListLoaded = false | |
| }, | |
| onBeforeLoad: function(a, b) { | |
| var d = this.owner.grid.selModel.getSelected(); | |
| if (!d || !d.get("task_id")) { | |
| return false | |
| } | |
| var c = d.get("task_id"); | |
| b.params.task_id = c; | |
| if ("undefined" !== typeof (b.params.offset)) { | |
| this.gStart = b.params.offset | |
| } else { | |
| this.gStart = 0 | |
| } | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.DLM"); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.InfoLog", { | |
| extend: "SYNO.ux.FormPanel", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| this.owner = a.owner; | |
| var b = this.fillConfig(a); | |
| this.callParent([b]); | |
| this.defineBehaviors() | |
| }, | |
| fillConfig: function(a) { | |
| var b = { | |
| border: false, | |
| layout: "fit", | |
| bodyStyle: "padding: 10px 20px 10px 20px;", | |
| tbar: { | |
| items: [{ | |
| xtype: "syno_button", | |
| text: _T("common", "refresh"), | |
| handler: this.load, | |
| scope: this | |
| }] | |
| }, | |
| items: [{ | |
| xtype: "syno_textarea", | |
| hideLabel: true, | |
| name: "nzblog", | |
| autoCreate: { | |
| tag: "textarea", | |
| autocomplete: "off", | |
| wrap: "off" | |
| }, | |
| readOnly: true, | |
| cls: "selectabletext allowDefCtxMenu" | |
| }], | |
| listeners: { | |
| scope: this, | |
| activate: this.onActivate | |
| } | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| defineBehaviors: function() { | |
| this.nzblogform = this.form | |
| }, | |
| getTaskId: function() { | |
| var a = this.owner.grid.selModel.getSelected(); | |
| if (!a || !a.get("task_id")) { | |
| return 0 | |
| } | |
| return a.get("task_id") | |
| }, | |
| load: function() { | |
| this.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.Task.NZB.Log", | |
| method: "get", | |
| params: { | |
| task_id: this.getTaskId() | |
| }, | |
| version: 1, | |
| scope: this, | |
| callback: function(e, c, d, a) { | |
| if (!e) { | |
| this.getMsgBox().alert(this.title, SYNO.SDS.DownloadStation.Utils.getErrorString(c.code)) | |
| } else { | |
| var b = this.nzblogform.findField("nzblog"); | |
| b.setValue(c.nzblog) | |
| } | |
| } | |
| }) | |
| }, | |
| onActivate: function() { | |
| if (this.nzblogform.findField("nzblog").getValue("nzblog").length === 0) { | |
| this.load() | |
| } | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.DLM"); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.QueueInfoPanel", { | |
| extend: "SYNO.ux.TabPanel", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| this.owner = a.owner; | |
| var b = this.fillConfig(a); | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| this.webapiDownloadTorrent = { | |
| api: "SYNO.DownloadStation2.Task.Source", | |
| method: "download", | |
| version: 2 | |
| }; | |
| this.infoGeneral = new SYNO.SDS.DownloadStation.DLM.InfoGeneral({ | |
| owner: this.owner, | |
| itemId: "info", | |
| title: _DT("download", "download_table_heading_general") | |
| }); | |
| this.infoTransfer = new SYNO.SDS.DownloadStation.DLM.InfoTransfer({ | |
| owner: this.owner, | |
| itemId: "transfer", | |
| title: _DT("download", "download_table_heading_transfer") | |
| }); | |
| this.infoTracker = new SYNO.SDS.DownloadStation.DLM.InfoTracker({ | |
| uicomponents: this.uicomponents, | |
| owner: this.owner, | |
| itemId: "tracker", | |
| title: _DT("download", "tracker") | |
| }); | |
| this.infoPeer = new SYNO.SDS.DownloadStation.DLM.InfoPeer({ | |
| uicomponents: this.uicomponents, | |
| owner: this.owner, | |
| itemId: "peer", | |
| title: _DT("download", "download_list_peer") | |
| }); | |
| this.infoFile = new SYNO.SDS.DownloadStation.DLM.InfoFile({ | |
| uicomponents: this.uicomponents, | |
| owner: this.owner, | |
| itemId: "file", | |
| title: _DT("download", "download_table_heading_file") | |
| }); | |
| this.infoPreview = new SYNO.SDS.DownloadStation.DLM.InfoPreview({ | |
| uicomponents: this.uicomponents, | |
| owner: this.owner, | |
| itemId: "preview", | |
| title: _T("photo_viewer", "menu_preview") | |
| }); | |
| this.infoNZBFile = new SYNO.SDS.DownloadStation.DLM.InfoNZBFile({ | |
| uicomponents: this.uicomponents, | |
| owner: this.owner, | |
| itemId: "nzb_file", | |
| title: _DT("download", "download_table_heading_file") | |
| }); | |
| this.infoLog = new SYNO.SDS.DownloadStation.DLM.InfoLog({ | |
| uicomponents: this.uicomponents, | |
| owner: this.owner, | |
| itemId: "log", | |
| title: _DT("download", "nzblog_title") | |
| }); | |
| var b = { | |
| border: false, | |
| cls: "syno-dl-infotab", | |
| collapsed: this.appWin.appInstance.getUserSettings("downloadinfo") === true ? true : false, | |
| activeTab: 0, | |
| items: [this.infoGeneral, this.infoTransfer, this.infoTracker, this.infoPeer, this.infoFile, this.infoPreview, this.infoNZBFile, this.infoLog], | |
| listeners: { | |
| scope: this, | |
| beforecollapse: this.onRecordCollapse, | |
| afterrender: { | |
| fn: this.onAfterRender, | |
| scope: this, | |
| single: true | |
| } | |
| } | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| onAfterRender: function() { | |
| this.resetForm(); | |
| this.items.each(function(b) { | |
| Ext.get(b.tabEl).on("click", function() { | |
| var c = this.moduleList.actived; | |
| if (c.lowerPanel.bodyCollapsed) { | |
| c.onLowerPanelToggle(c.lowerPanel) | |
| } | |
| }, this) | |
| }, this); | |
| this.pollingtask.add({ | |
| id: "infoTask", | |
| interval: 5000, | |
| api: "SYNO.DownloadStation2.Task", | |
| version: 2, | |
| autoJsonDecode: true, | |
| method: "get", | |
| single: false, | |
| callback: this.onUpdateForm, | |
| scope: this, | |
| beforestart: function(b) { | |
| var c = this.owner.grid.selModel.getSelected(); | |
| this.taskID = c && c.get("task_id"); | |
| var d = { | |
| id: [this.taskID], | |
| additional: ["detail", "transfer"] | |
| }; | |
| b.reqConfig.params = d | |
| } | |
| }); | |
| var a = this.owner.grid.getSelectionModel(); | |
| this.mon(a, "rowSelectionChanged", function(b) { | |
| if (1 !== b.getCount()) { | |
| this.pollingtask.stopById("infoTask"); | |
| this.resetForm(); | |
| this.setActiveTab(0); | |
| return | |
| } | |
| this.load(b.getSelected()) | |
| }, this) | |
| }, | |
| onRecordCollapse: function(a) { | |
| var b = ("undefined" === typeof a.bodyCollapsed) ? true : !a.bodyCollapsed; | |
| this.appWin.appInstance.setUserSettings("downloadinfo", b) | |
| }, | |
| updateGeneralForm: function(e) { | |
| var c = this.infoGeneral.getForm(), g, k = {}; | |
| k.filename = e.title; | |
| k.destination = e.additional.detail.destination; | |
| k.filesize = (0 === e.size) ? _DT("download", "download_status_unknown") : SYNO.SDS.DownloadStation.Utils.fileSize(e.size); | |
| k.username = e.username; | |
| k.url = e.additional.detail.uri; | |
| g = (0 !== e.additional.detail.created_time) ? SYNO.SDS.DateTimeFormatter(new Date(e.additional.detail.created_time * 1000)) : _DT("download", "download_status_not_available"); | |
| k.create_time = g; | |
| g = (0 !== e.additional.detail.completed_time) ? SYNO.SDS.DateTimeFormatter(new Date(e.additional.detail.completed_time * 1000)) : _DT("download", "download_status_not_available"); | |
| k.completed_time = g; | |
| var l = (0 === e.additional.detail.waiting_seconds) ? "" : SYNO.SDS.DownloadStation.DLM.Util.convertTimeLeft(e.waiting_seconds, false); | |
| g = ("" === l) ? _DT("download", "download_status_not_available") : l; | |
| k.waiting_seconds = g; | |
| c.setValues(k); | |
| if ("bt" === e.type) { | |
| var h = c.findField("orgtorrent"); | |
| var d = c.findField("url").getValue(); | |
| if (!h.isVisible() && !SYNO.SDS.DownloadStation.Utils.isMagnetLink(d)) { | |
| var a = e.title + ".torrent"; | |
| var i = e.id; | |
| var b = this.getBaseURL(Ext.apply(this.webapiDownloadTorrent, { | |
| params: { | |
| id: i, | |
| t: (new Date()).getTime() | |
| } | |
| }), true, a); | |
| var j = Ext.util.Format.htmlEncode(b); | |
| var f = String.format('<a target="_blank" href="{0}">{1}</a>', j, _DT("download", "download_orgtorrent_desc")); | |
| h.setRawValue(f); | |
| h.show() | |
| } | |
| } | |
| }, | |
| updateTransferForm: function(e) { | |
| var a = this.infoTransfer.getForm(), f, j = {}, i = SYNO.SDS.DownloadStation.Utils; | |
| j.task_status = i.getTaskStatusStr(e); | |
| var h = SYNO.SDS.DownloadStation.Utils.fileSize(e.additional.transfer.size_downloaded); | |
| if ("bt" === e.type) { | |
| h = SYNO.SDS.DownloadStation.Utils.fileSize(e.additional.transfer.size_uploaded) + " / " + h; | |
| var g = (0 === e.additional.transfer.size_downloaded) ? 0 : Ext.util.Format.number(100 * e.additional.transfer.size_uploaded / e.additional.transfer.size_downloaded, "0.0"); | |
| h = h + " (" + g + "%)" | |
| } | |
| j.transfered = h; | |
| if ((i.TASK_STATUS_INT.TASK_DOWNLOADING || 0 !== e.additional.transfer.size_downloaded) && 0 < e.size) { | |
| j.progress = Ext.util.Format.number(100 * e.additional.transfer.size_downloaded / e.size, "0.0") + "%" | |
| } else { | |
| j.progress = _DT("download", "download_status_unknown") | |
| } | |
| var c = _DT("download", "download_status_not_available"); | |
| if (SYNO.SDS.DownloadStation.DLM.Util.isActiveTorrentStatus(e.status)) { | |
| if ("bt" === e.type && e.additional.detail.total_pieces > 0) { | |
| c = SYNO.SDS.DownloadStation.Utils.fileSize(e.additional.transfer.speed_upload) + "/s / " + SYNO.SDS.DownloadStation.Utils.fileSize(e.additional.transfer.speed_download) + "/s" | |
| } else { | |
| if ("bt" !== e.type) { | |
| c = SYNO.SDS.DownloadStation.Utils.fileSize(e.additional.transfer.speed_download) + "/s" | |
| } | |
| } | |
| } | |
| j.speed = c; | |
| j.totalpeer = (0 === e.additional.detail.total_peers) ? _DT("download", "download_status_not_available") : e.additional.detail.total_peers; | |
| j.currpeer = (0 === e.additional.detail.connected_peers) ? _DT("download", "download_status_not_available") : e.additional.detail.connected_peers; | |
| j.totalpieces = e.additional.detail.total_pieces + " x 2MB"; | |
| j.currpieces = e.additional.transfer.downloaded_pieces; | |
| f = (0 !== e.additional.detail.started_time) ? SYNO.SDS.DateTimeFormatter(new Date(e.additional.detail.started_time * 1000)) : _DT("download", "download_status_not_available"); | |
| j.start_time = f; | |
| var d = SYNO.SDS.DownloadStation.DLM.Util.timeleftCalc(e.additional.transfer.speed_download, e.size, e.additional.transfer.size_downloaded); | |
| var b = (d == -1) ? _DT("download", "download_status_not_available") : SYNO.SDS.DownloadStation.DLM.Util.convertTimeLeft(d, false); | |
| j.time_left = b; | |
| j.seed_elapsed = e.additional.detail.seed_elapsed; | |
| a.setValues(j); | |
| if ("bt" === e.type) { | |
| a.findField("seed_elapsed").show(); | |
| if (e.additional.detail.seed_elapsed > 0) { | |
| a.findField("time_left").hide(); | |
| a.findField("seed_elapsed").setValue(this.convertSeedElapsed(e.additional.detail.seed_elapsed)) | |
| } | |
| if (SYNO.SDS.DownloadStation.DLM.Util.isActiveTorrentStatus(e.status)) { | |
| var k = e.additional.detail.connected_seeders + "/" + e.additional.detail.connected_leechers; | |
| a.findField("seeders_leechers").setValue(k); | |
| a.findField("seeders_leechers").show() | |
| } | |
| } | |
| }, | |
| onUpdateForm: function(e, c, d, a) { | |
| this.unmask(); | |
| if (!this.infoTransfer) { | |
| return | |
| } | |
| if (!e) { | |
| return | |
| } else { | |
| if (c.code) { | |
| this.appWin.getMsgBox().alert("", SYNO.SDS.DownloadStation.Utils.getErrorString(c.code)); | |
| return | |
| } | |
| } | |
| if (!this.taskID || d.id[0] != this.taskID) { | |
| return | |
| } | |
| this.checkUpdateData(c.task[0]); | |
| var b = c.task[0]; | |
| this.isTorrentTask = ("bt" === b.type); | |
| this.updateGeneralForm(b); | |
| this.updateTransferForm(b); | |
| this.doLayout() | |
| }, | |
| resetForm: function() { | |
| this.hideTabStripItem("tracker"); | |
| this.hideTabStripItem("peer"); | |
| this.hideTabStripItem("file"); | |
| this.hideTabStripItem("preview"); | |
| this.hideTabStripItem("nzb_file"); | |
| this.hideTabStripItem("log"); | |
| this.infoGeneral.resetForm(); | |
| this.infoTransfer.resetForm(); | |
| this.infoLog.nzblogform.findField("nzblog").reset() | |
| }, | |
| load: function(a) { | |
| this.pollingtask.stopById("infoTask"); | |
| this.resetForm(); | |
| this.mask(_DT("common", "loading")); | |
| this.pollingtask.startById("infoTask"); | |
| this.infoNZBFile.dsFileListLoaded = false; | |
| if ("nzb" === a.get("type")) { | |
| if (this.getActiveTab() !== this.infoNZBFile && this.getActiveTab() !== this.infoTransfer && this.getActiveTab() !== this.infoLog && this.getActiveTab() !== this.infoGeneral) { | |
| this.setActiveTab(0) | |
| } | |
| this.unhideNZBTabs(); | |
| if (Ext.isDefined(this.getActiveTab().onDeactivate)) { | |
| this.getActiveTab().onDeactivate() | |
| } | |
| if (Ext.isDefined(this.getActiveTab().onActivate)) { | |
| this.getActiveTab().onActivate() | |
| } | |
| } else { | |
| if ("bt" === a.get("type")) { | |
| if (this.getActiveTab() !== this.infoGeneral && this.getActiveTab() !== this.infoTransfer && this.getActiveTab() !== this.infoTracker && this.getActiveTab() !== this.infoPeer && this.getActiveTab() !== this.infoFile && this.getActiveTab() !== this.infoPreview) { | |
| this.setActiveTab(0) | |
| } | |
| if (SYNO.SDS.DownloadStation.DLM.Util.isActiveTorrentStatus(a.get("status"))) { | |
| this.unhideTorrentTabs() | |
| } else { | |
| if (this.getActiveTab() === this.infoTracker || this.getActiveTab() === this.infoPeer || this.getActiveTab() === this.infoFile || this.getActiveTab() === this.infoPreview) { | |
| this.setActiveTab(0) | |
| } | |
| } | |
| if (Ext.isDefined(this.getActiveTab().onDeactivate)) { | |
| this.getActiveTab().onDeactivate() | |
| } | |
| if (Ext.isDefined(this.getActiveTab().onActivate)) { | |
| this.getActiveTab().onActivate() | |
| } | |
| } else { | |
| if (this.getActiveTab() !== this.infoGeneral && this.getActiveTab() !== this.infoTransfer) { | |
| this.setActiveTab(0) | |
| } | |
| } | |
| } | |
| }, | |
| checkUpdateData: function(e) { | |
| var d = this.lastData | |
| , c = false | |
| , b = false | |
| , a = SYNO.SDS.DownloadStation.DLM.Util; | |
| this.lastData = e; | |
| if (!d || !e) { | |
| return | |
| } | |
| c = a.isActiveTorrentStatus(e.status); | |
| b = a.isActiveTorrentStatus(d.status); | |
| if ("bt" !== d.type && "bt" === e.type && c) { | |
| this.unhideTorrentTabs() | |
| } | |
| if ("nzb" !== d.type && "nzb" === e.type) { | |
| this.unhideNZBTabs() | |
| } | |
| if ("bt" === e.type && (d.status !== e.status)) { | |
| if (b && !c) { | |
| this.hideTorrentTabs(); | |
| if (this.getActiveTab() !== this.infoGeneral) { | |
| this.setActiveTab("info") | |
| } | |
| } else { | |
| if (!b && c) { | |
| this.unhideTorrentTabs() | |
| } | |
| } | |
| } | |
| }, | |
| convertSeedElapsed: function(b) { | |
| var d = 0; | |
| var a = 0; | |
| var c = 0; | |
| if (b < 3600) { | |
| return Math.floor(b / 60) + " " + _DT("download", "download_seed_mins") | |
| } | |
| if (b < 86400) { | |
| a = Math.floor(b / 3600); | |
| c = Math.floor((b - a * 3600) / 60); | |
| return String.format("{0} {1} {2} {3}", a, _DT("download", "download_seed_hours"), c, _DT("download", "download_seed_mins")) | |
| } | |
| d = Math.floor(b / 86400); | |
| a = Math.floor((b - d * 86400) / 3600); | |
| c = Math.floor((b - d * 86400 - a * 3600) / 60); | |
| return String.format("{0} {1} {2} {3} {4} {5}", d, _DT("download", "download_seed_days"), a, _DT("download", "download_seed_hours"), c, _DT("download", "download_seed_mins")) | |
| }, | |
| unhideNZBTabs: function() { | |
| this.unhideTabStripItem("nzb_file"); | |
| this.unhideTabStripItem("log") | |
| }, | |
| hideTorrentTabs: function() { | |
| this.hideTabStripItem("tracker"); | |
| this.hideTabStripItem("peer"); | |
| this.hideTabStripItem("file"); | |
| this.hideTabStripItem("preview") | |
| }, | |
| unhideTorrentTabs: function() { | |
| this.unhideTabStripItem("tracker"); | |
| this.unhideTabStripItem("peer"); | |
| this.unhideTabStripItem("file"); | |
| if (this.appWin.tabPanel.enable_bt_preview) { | |
| this.unhideTabStripItem("preview") | |
| } else { | |
| if (this.getActiveTab() === this.infoPreview) { | |
| this.setActiveTab(0) | |
| } | |
| } | |
| }, | |
| unmask: function() { | |
| if (this.getEl().isMasked()) { | |
| this.getEl().unmask() | |
| } | |
| }, | |
| mask: function(a) { | |
| if (!this.getEl().isMasked()) { | |
| this.getEl().mask(a) | |
| } | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.DLM"); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.CaptchaEnterDialog", { | |
| extend: "SYNO.SDS.ModalWindow", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| var b = this.fillConfig(a); | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| this.webapiList = { | |
| api: "SYNO.DownloadStation2.Captcha", | |
| method: "list", | |
| version: 2 | |
| }; | |
| this.webapiSet = { | |
| api: "SYNO.DownloadStation2.Captcha", | |
| method: "set", | |
| version: 2 | |
| }; | |
| this.webapiDownload = { | |
| api: "SYNO.DownloadStation2.Captcha", | |
| method: "download", | |
| version: 2 | |
| }; | |
| this.webapiGet = { | |
| api: "SYNO.DownloadStation2.Task", | |
| method: "get", | |
| version: 2 | |
| }; | |
| this.formPanel = this.createForm(a); | |
| this.submitButton = this.formPanel.getFooterToolbar().getComponent("submit"); | |
| var b = { | |
| owner: this.appWin, | |
| width: 640, | |
| height: 437, | |
| resizable: false, | |
| title: _DT("download", "require_captcha"), | |
| useStatusBar: false, | |
| layout: "fit", | |
| cls: "syno-dl-captcha-win download-captcha-formpanel", | |
| items: [this.formPanel] | |
| }; | |
| Ext.apply(b, a); | |
| return b | |
| }, | |
| createForm: function(a) { | |
| this.statusImageClass = ""; | |
| this.statusImage = new SYNO.ux.Button({ | |
| cls: "status-image", | |
| disabled: true, | |
| value: "" | |
| }); | |
| var b = { | |
| hidden: true, | |
| blSubmitted: false, | |
| buttons: SYNO.SDS.DownloadStation.Utils.composeButtonCfg({ | |
| xtype: "syno_button", | |
| itemId: "submit", | |
| btnStyle: "blue", | |
| text: _DT("common", "submit"), | |
| scope: this, | |
| handler: this.onSubmit, | |
| disabled: _S("demo_mode"), | |
| tooltip: _S("demo_mode") ? _JSLIBSTR("uicommon", "error_demo") : undefined | |
| }, { | |
| xtype: "syno_button", | |
| text: _T("common", "cancel"), | |
| scope: this, | |
| handler: this.close | |
| }), | |
| items: [{ | |
| xtype: "syno_displayfield", | |
| name: "task_id", | |
| hidden: true | |
| }, { | |
| xtype: "syno_displayfield", | |
| name: "filename", | |
| fieldLabel: _DT("download", "download_list_filename"), | |
| cls: "captcha-info", | |
| value: "" | |
| }, { | |
| xtype: "syno_displayfield", | |
| name: "url", | |
| fieldLabel: _DT("download", "download_list_url"), | |
| cls: "captcha-info", | |
| value: "" | |
| }, { | |
| xtype: "syno_displayfield", | |
| name: "image", | |
| hideLabel: true, | |
| ctCls: "captcha-image-field", | |
| value: "", | |
| htmlEncode: false | |
| }, { | |
| xtype: "syno_displayfield", | |
| hideLabel: true, | |
| value: _DT("download", "enter_captcha") + ":" | |
| }, { | |
| xtype: "syno_compositefield", | |
| hideLabel: true, | |
| items: [{ | |
| xtype: "syno_textfield", | |
| name: "captcha_code", | |
| allowBlank: false | |
| }, this.statusImage] | |
| }, { | |
| xtype: "syno_displayfield", | |
| name: "message", | |
| hideLabel: true, | |
| cls: "captcha-error-message", | |
| value: "" | |
| }] | |
| }; | |
| b = Ext.apply(b, a); | |
| return new SYNO.ux.FormPanel(b) | |
| }, | |
| onShow: function() { | |
| if (Ext.isEmpty(this.taskId)) { | |
| this.listCaptchaTask() | |
| } else { | |
| this.getTaskInfo(this.taskId) | |
| } | |
| }, | |
| onSubmit: function() { | |
| var a = this.formPanel.getForm(); | |
| if (!a.blSubmitted) { | |
| if (!a.isValid()) { | |
| return | |
| } | |
| a.blSubmitted = true; | |
| this.setCaptchaResult(a.findField("task_id").getValue(), a.findField("captcha_code").getValue()) | |
| } else { | |
| a.blSubmitted = false; | |
| this.listCaptchaTask() | |
| } | |
| }, | |
| getCaptchaImageURL: function(a) { | |
| return this.getBaseURL(Ext.apply(this.webapiDownload, { | |
| params: { | |
| task_id: a, | |
| t: (new Date()).getTime() | |
| } | |
| })) | |
| }, | |
| getImgHtml: function(a) { | |
| return '<img class="captcha" src="' + a + '">' | |
| }, | |
| getTaskInfo: function(a) { | |
| this.getEl().mask(_DT("common", "loading"), "x-mask-loading"); | |
| SYNO.API.Request({ | |
| webapi: Ext.apply(this.webapiGet, { | |
| params: { | |
| id: [a], | |
| additional: ["detail"] | |
| } | |
| }), | |
| callback: function(e, c, d, b) { | |
| this.getEl().unmask(); | |
| if (!e) { | |
| this.close(); | |
| return | |
| } | |
| this.getTaskInfoCallback(c) | |
| }, | |
| scope: this | |
| }) | |
| }, | |
| getTaskInfoCallback: function(c) { | |
| var b = {}; | |
| var a; | |
| if (Ext.isEmpty(c.task) || Ext.isEmpty(c.task[0])) { | |
| this.close(); | |
| return | |
| } | |
| a = c.task[0]; | |
| b.taskId = a.id; | |
| b.filename = a.title; | |
| b.url = a.additional.detail.uri; | |
| this.setTaskInfo(b) | |
| }, | |
| setStatusImageClass: function(a) { | |
| this.statusImage.removeClass(this.statusImageClass); | |
| this.statusImage.addClass(a); | |
| this.statusImageClass = a | |
| }, | |
| setTaskInfo: function(b) { | |
| var d = this.formPanel.getForm(); | |
| if (!Ext.isEmpty(b.taskId)) { | |
| d.findField("task_id").setValue(b.taskId); | |
| var a = this.getCaptchaImageURL(b.taskId); | |
| d.findField("image").setValue(this.getImgHtml(a)) | |
| } | |
| if (!Ext.isEmpty(b.filename)) { | |
| d.findField("filename").setValue(b.filename) | |
| } | |
| if (!Ext.isEmpty(b.url)) { | |
| d.findField("url").setValue(b.url) | |
| } | |
| if (!Ext.isEmpty(b.message)) { | |
| d.findField("message").setValue(b.message) | |
| } else { | |
| d.findField("message").setValue("") | |
| } | |
| var c; | |
| if (d.blSubmitted) { | |
| c = b.success ? _DT("download", "next_one") : _T("common", "skip"); | |
| if (b.success) { | |
| this.setStatusImageClass("status-success") | |
| } else { | |
| this.setStatusImageClass("status-error") | |
| } | |
| } else { | |
| c = _DT("common", "submit"); | |
| d.findField("captcha_code").reset(); | |
| this.setStatusImageClass("") | |
| } | |
| this.submitButton.setText(c); | |
| this.formPanel.setVisible(true) | |
| }, | |
| listCaptchaTask: function() { | |
| this.getEl().mask(_DT("common", "loading"), "x-mask-loading"); | |
| SYNO.API.Request({ | |
| webapi: this.webapiList, | |
| callback: function(d, b, c, a) { | |
| this.getEl().unmask(); | |
| if (!d) { | |
| this.close(); | |
| return | |
| } | |
| this.listCaptchaTaskCallback(b) | |
| }, | |
| scope: this | |
| }) | |
| }, | |
| listCaptchaTaskCallback: function(b) { | |
| var a = b.task_ids; | |
| if (!Array.isArray(a) || 0 === a.length) { | |
| this.close(); | |
| return | |
| } | |
| this.getTaskInfo(a[0]) | |
| }, | |
| setCaptchaResult: function(a, b) { | |
| this.setStatusImageClass("status-loading"); | |
| this.submitButton.setDisabled(true); | |
| SYNO.API.Request({ | |
| webapi: Ext.apply(this.webapiSet, { | |
| params: { | |
| task_id: a, | |
| code: b | |
| } | |
| }), | |
| callback: function(f, d, e, c) { | |
| this.setStatusImageClass(""); | |
| this.submitButton.setDisabled(false); | |
| this.setCaptchaResultCallback(f, d) | |
| }, | |
| scope: this | |
| }) | |
| }, | |
| setCaptchaResultCallback: function(c, b) { | |
| var a = {}; | |
| if (!c) { | |
| a.message = this.getErrorMessage(b.code); | |
| a.success = false | |
| } else { | |
| a.success = true | |
| } | |
| this.setTaskInfo(a); | |
| if (c) { | |
| this.onSubmit() | |
| } | |
| }, | |
| getErrorMessage: function(b) { | |
| var a = _DT("common", "error_system"); | |
| switch (b) { | |
| case 2301: | |
| a = _DT("download", "download_error_wrong_captcha"); | |
| break; | |
| default: | |
| break | |
| } | |
| return a | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.DLM"); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.QueueGridPanel", { | |
| extend: "SYNO.ux.GridPanel", | |
| statics: { | |
| COLUMN_ID: { | |
| TASK_ID: "task_id", | |
| FILENAME: "filename", | |
| TOTAL_SIZE: "total_size", | |
| CURRENT_SIZE: "current_size", | |
| TOTAL_UPLOAD: "total_upload", | |
| PROGRESS: "progress", | |
| UPLOAD_RATE: "upload_rate", | |
| CURRENT_RATE: "current_rate", | |
| TIMELEFT: "timeleft", | |
| STATUS: "status", | |
| DESTINATION: "destination", | |
| STARTED_TIME: "started_time", | |
| COMPLETED_TIME: "completed_time", | |
| WAITING_SECONDS: "waiting_seconds", | |
| USERNAME: "username" | |
| } | |
| }, | |
| StatusNotEndable: [SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_FINISHED, SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_FINISHING, SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_HASH_CHECKING, SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_PRE_SEEDING], | |
| StatusFinished: [SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_FINISHED, SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_PRE_SEEDING, SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_SEEDING], | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| this.owner = a.owner; | |
| this.owner.updateConcreteConfig(this); | |
| this.NUM_REC_PER_PAGE = 25; | |
| this.gStart = 0; | |
| this.jsConfig = a.owner.jsConfig; | |
| this.webapiTaskList = { | |
| api: "SYNO.DownloadStation2.Task", | |
| method: "list", | |
| version: 2 | |
| }; | |
| this.webapiCaptchaList = { | |
| api: "SYNO.DownloadStation2.Captcha", | |
| method: "list", | |
| version: 2 | |
| }; | |
| this.webapiTotalStatistic = { | |
| api: "SYNO.DownloadStation2.Task.Statistic", | |
| method: "get", | |
| version: 1, | |
| params: { | |
| type: ["emule"], | |
| type_inverse: true | |
| } | |
| }; | |
| this.stateManager = new SYNO.SDS.DownloadStation.DLM.QueueGridPanelStateManager({ | |
| owner: this | |
| }); | |
| var b = this.fillConfig(a); | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(b) { | |
| var a = this.initColumnModel(); | |
| var d = this.createSelectionModel(); | |
| this.store = this.createStore(); | |
| this.paging = this.createPagingToolbar(); | |
| var c = { | |
| ds: this.store, | |
| bbar: this.paging, | |
| selModel: d, | |
| minHeight: 90, | |
| stripeRows: true, | |
| colModel: a, | |
| view: new SYNO.SDS.DownloadStation.GridView(), | |
| stateful: true, | |
| stateEvents: ["columnmove", "columnresize", "sortchange"], | |
| initState: function() { | |
| this.stateManager.initState() | |
| }, | |
| saveState: function() { | |
| this.stateManager.saveState() | |
| }, | |
| listeners: { | |
| scope: this, | |
| rowcontextmenu: function(f, j, h) { | |
| var i = f.getSelectionModel(); | |
| if (!i.isSelected(j)) { | |
| i.selectRow(j) | |
| } | |
| this.gridCtxMenu.showAt(h.getXY()); | |
| h.preventDefault() | |
| }, | |
| rowdblclick: this.onRowDblClick, | |
| afterlayout: { | |
| fn: function() { | |
| this.fieldFilter = this.owner.actionGroup.get("filter"); | |
| this.gridCtxMenu = this.createCtxMenu(); | |
| this.addManagedComponent(this.gridCtxMenu); | |
| this.pollingtask.add({ | |
| id: "updateTask", | |
| interval: 5000, | |
| webapi: { | |
| api: "SYNO.Entry.Request", | |
| version: 1, | |
| method: "request", | |
| compound: { | |
| stopwhenerror: false | |
| } | |
| }, | |
| single: false, | |
| callback: this.onUpdateRecordsTask, | |
| beforestart: this.onBeforeStart, | |
| scope: this | |
| }); | |
| this.pollingtask.add({ | |
| id: "updateStatistic", | |
| interval: 5000, | |
| webapi: this.webapiTotalStatistic, | |
| single: false, | |
| callback: this.onUpdateTotalStatistic, | |
| scope: this | |
| }) | |
| }, | |
| scope: this, | |
| single: true | |
| } | |
| } | |
| }; | |
| return Ext.apply(c, b) | |
| }, | |
| createCtxMenu: function() { | |
| var a = []; | |
| var c = [{ | |
| itemId: "resume", | |
| text: _DT("download", "download_btn_resume"), | |
| iconCls: "" | |
| }, { | |
| itemId: "pause", | |
| text: _DT("download", "download_btn_stop"), | |
| iconCls: "" | |
| }, { | |
| itemId: "end", | |
| text: _DT("download", "download_btn_end"), | |
| iconCls: "" | |
| }, { | |
| itemId: "delete", | |
| text: _DT("download", "download_btn_remove"), | |
| iconCls: "" | |
| }, { | |
| itemId: "edit", | |
| text: _DT("common", "alt_edit"), | |
| iconCls: "" | |
| }]; | |
| for (var b = 0; b < c.length; b++) { | |
| var d = this.owner.actionGroup.get(c[b].itemId).initialConfig; | |
| a.push(Ext.apply(d, c[b])) | |
| } | |
| a.push({ | |
| itemId: "open", | |
| iconCls: "", | |
| text: _T("fbbrower", "open_folder"), | |
| handler: this.onOpenContainingFolder, | |
| scope: this | |
| }); | |
| var e = new SYNO.ux.Menu({ | |
| cls: "syno-dlm-menu", | |
| items: a, | |
| listeners: { | |
| scope: this, | |
| beforeshow: function(g) { | |
| var f = this.updateBtnStatus(); | |
| g.get("pause").setDisabled(!f.blStop); | |
| g.get("resume").setDisabled(!f.blResume); | |
| g.get("end").setDisabled(!f.blEnd); | |
| g.get("delete").setDisabled(!f.blDelete); | |
| g.get("edit").setDisabled(!f.blEdit); | |
| g.get("open").setDisabled(!f.blOpen) | |
| } | |
| } | |
| }); | |
| return e | |
| }, | |
| onRowDblClick: function() { | |
| var b = this.getSelectionModel().getSelections(); | |
| var c = b.length; | |
| var a; | |
| if (0 === c || 1 < c) { | |
| return | |
| } | |
| a = b[0]; | |
| if (SYNO.SDS.DownloadStation.DLM.Util.isFinishedStatus(a.get("status"))) { | |
| return | |
| } | |
| this.owner.actionGroup.launchTaskEditDialog() | |
| }, | |
| updateBtnStatus: function() { | |
| var f = false | |
| , k = false | |
| , h = false | |
| , l = false | |
| , g = false | |
| , a = false; | |
| var c = this.getSelectionModel(); | |
| var j = SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT; | |
| if (c.hasSelection()) { | |
| l = true; | |
| a = true; | |
| var b = c.getSelections(); | |
| var d = ""; | |
| var e; | |
| if ((-1 !== this.StatusFinished.indexOf(b[0].get("status"))) && "" !== b[0].get("destination")) { | |
| g = true | |
| } | |
| for (e = 0; e < b.length; e++) { | |
| d = b[e].get("status"); | |
| if (d === j.TASK_FINISHED && ("bt" === b[e].get("type")) || SYNO.SDS.DownloadStation.Utils.isTaskErrorStatus(d)) { | |
| f = true | |
| } else { | |
| if (d === j.TASK_PAUSED) { | |
| f = true; | |
| h = true | |
| } else { | |
| if (d === j.TASK_WAITING || d === j.TASK_DOWNLOADING || d === j.TASK_FILEHOSTING_WAITING || d === j.TASK_SEEDING) { | |
| k = true; | |
| h = true | |
| } else { | |
| if (d === j.TASK_HASH_CHECKING || d === j.TASK_PRE_SEEDING) { | |
| k = true | |
| } | |
| } | |
| } | |
| } | |
| if (SYNO.SDS.DownloadStation.DLM.Util.isFinishedStatus(d)) { | |
| l = false | |
| } | |
| } | |
| } | |
| return { | |
| blResume: f, | |
| blStop: k, | |
| blEnd: h, | |
| blEdit: l, | |
| blDelete: a, | |
| blOpen: g | |
| } | |
| }, | |
| createSelectionModel: function() { | |
| var a = new Ext.grid.RowSelectionModel({ | |
| singleSelect: false, | |
| listeners: { | |
| selectionchange: { | |
| scope: this, | |
| fn: this.gridSelectionChange | |
| } | |
| } | |
| }); | |
| a.addEvents({ | |
| rowSelectionChanged: true | |
| }); | |
| return a | |
| }, | |
| gridSelectionChange: function(a) { | |
| if (!this.gridSelectionChangeTask) { | |
| this.gridSelectionChangeTask = new Ext.util.DelayedTask(function() { | |
| a.fireEvent("rowSelectionChanged", a) | |
| } | |
| ,a) | |
| } | |
| this.gridSelectionChangeTask.delay(300) | |
| }, | |
| initColumnModel: function() { | |
| var a = this.self.COLUMN_ID; | |
| var b = [{ | |
| id: a.FILENAME, | |
| header: _DT("download", "download_list_filename"), | |
| width: 180, | |
| dataIndex: "filename", | |
| renderer: SYNO.SDS.DownloadStation.Renderers.fileNameWithStatusRenderer | |
| }, { | |
| header: _DT("download", "download_list_filesize"), | |
| dataIndex: "total_size", | |
| id: a.TOTAL_SIZE, | |
| width: 80, | |
| renderer: SYNO.SDS.DownloadStation.Renderers.SizeRenderer | |
| }, { | |
| header: _DT("download", "download_list_completed"), | |
| dataIndex: "current_size", | |
| id: a.CURRENT_SIZE, | |
| width: 80, | |
| renderer: SYNO.SDS.DownloadStation.Renderers.SizeRenderer | |
| }, { | |
| header: _DT("download", "download_list_uploaded"), | |
| dataIndex: "total_upload", | |
| id: a.TOTAL_UPLOAD, | |
| width: 65, | |
| renderer: SYNO.SDS.DownloadStation.Renderers.SizeRenderer | |
| }, { | |
| header: _DT("download", "download_list_progress"), | |
| dataIndex: "progress", | |
| id: a.PROGRESS, | |
| width: 65, | |
| renderer: SYNO.SDS.DownloadStation.Renderers.ProgressRenderer | |
| }, { | |
| header: _DT("download", "download_list_upload_rate"), | |
| dataIndex: "upload_rate", | |
| id: a.UPLOAD_RATE, | |
| width: 68, | |
| renderer: SYNO.SDS.DownloadStation.Renderers.RateRenderer | |
| }, { | |
| header: _DT("download", "download_list_down_rate"), | |
| dataIndex: "current_rate", | |
| id: a.CURRENT_RATE, | |
| width: 68, | |
| renderer: SYNO.SDS.DownloadStation.Renderers.RateRenderer | |
| }, { | |
| id: a.TIMELEFT, | |
| header: _DT("download", "download_time_left"), | |
| dataIndex: "timeleft", | |
| width: 80, | |
| renderer: function(d) { | |
| var c = (d == -1) ? "" : SYNO.SDS.DownloadStation.DLM.Util.convertTimeLeft(d, true); | |
| return Ext.util.Format.htmlEncode(c) | |
| } | |
| }, { | |
| id: a.STATUS, | |
| header: _DT("download", "download_list_status"), | |
| dataIndex: "status", | |
| width: 70, | |
| renderer: SYNO.SDS.DownloadStation.Renderers.StatusRenderer, | |
| listeners: { | |
| scope: this, | |
| click: function(f, d, h, g) { | |
| var c = this.store.getAt(h); | |
| if (SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_CAPTCHA_NEEDED === c.get("status")) { | |
| this.launchCaptchaEnterDialog(c.get("task_id")) | |
| } | |
| } | |
| } | |
| }, { | |
| id: a.DESTINATION, | |
| header: _DT("download", "download_list_dest_folder"), | |
| dataIndex: "destination", | |
| width: 90, | |
| renderer: SYNO.SDS.DownloadStation.DLM.Util.destinationRender.createDelegate(this) | |
| }, { | |
| id: a.STARTED_TIME, | |
| header: _DT("download", "download_list_started_time"), | |
| dataIndex: "started_time", | |
| renderer: SYNO.SDS.DownloadStation.DLM.Util.startedtimeRender.createDelegate(this) | |
| }, { | |
| id: a.COMPLETED_TIME, | |
| header: _DT("download", "download_list_completed_time"), | |
| dataIndex: "completed_time", | |
| renderer: SYNO.SDS.DownloadStation.DLM.Util.startedtimeRender.createDelegate(this) | |
| }, { | |
| id: a.WAITING_SECONDS, | |
| header: _DT("download", "download_list_expected_waiting_time"), | |
| dataIndex: "waiting_seconds", | |
| renderer: SYNO.SDS.DownloadStation.DLM.Util.waitingtimeRender.createDelegate(this) | |
| }]; | |
| if ((true === _S("is_admin")) && !_S("diskless")) { | |
| b.push({ | |
| id: a.USERNAME, | |
| header: _DT("download", "download_list_username"), | |
| dataIndex: "username" | |
| }) | |
| } | |
| return new Ext.grid.ColumnModel({ | |
| defaults: { | |
| sortable: true, | |
| width: 100 | |
| }, | |
| columns: b | |
| }) | |
| }, | |
| createStore: function() { | |
| var a = [{ | |
| name: "task_id", | |
| mapping: "id" | |
| }, { | |
| name: "filename", | |
| mapping: "title" | |
| }, { | |
| name: "total_size", | |
| mapping: "size" | |
| }, { | |
| name: "current_size", | |
| convert: function(d, c) { | |
| return c.additional.transfer.size_downloaded | |
| } | |
| }, { | |
| name: "total_upload", | |
| convert: function(d, c) { | |
| return c.additional.transfer.size_uploaded | |
| } | |
| }, { | |
| name: "progress", | |
| convert: function(d, c) { | |
| return (0 === c.size) ? 0 : (c.additional.transfer.size_downloaded / c.size) * 100 | |
| } | |
| }, { | |
| name: "current_rate", | |
| convert: function(d, c) { | |
| return c.additional.transfer.speed_download | |
| } | |
| }, { | |
| name: "upload_rate", | |
| convert: function(d, c) { | |
| return c.additional.transfer.speed_upload | |
| } | |
| }, { | |
| name: "username", | |
| mapping: "username" | |
| }, { | |
| name: "status", | |
| mapping: "status" | |
| }, { | |
| name: "status_extra", | |
| mapping: "status_extra" | |
| }, { | |
| name: "timeleft", | |
| convert: function(d, c) { | |
| return SYNO.SDS.DownloadStation.DLM.Util.timeleftCalc(c.additional.transfer.speed_download, c.size, c.additional.transfer.size_downloaded) | |
| } | |
| }, { | |
| name: "type", | |
| mapping: "type" | |
| }, { | |
| name: "destination", | |
| convert: function(d, c) { | |
| return c.additional.detail.destination | |
| } | |
| }, { | |
| name: "started_time", | |
| convert: function(d, c) { | |
| return c.additional.detail.started_time | |
| } | |
| }, { | |
| name: "completed_time", | |
| convert: function(d, c) { | |
| return c.additional.detail.completed_time | |
| } | |
| }, { | |
| name: "waiting_seconds", | |
| convert: function(d, c) { | |
| return c.additional.detail.waiting_seconds | |
| } | |
| }]; | |
| var b = new SYNO.API.JsonStore({ | |
| api: this.webapiTaskList.api, | |
| method: this.webapiTaskList.method, | |
| version: this.webapiTaskList.version, | |
| baseParams: { | |
| type: ["emule"], | |
| type_inverse: true, | |
| limit: this.NUM_REC_PER_PAGE, | |
| additional: ["detail", "transfer"] | |
| }, | |
| pruneModifiedRecords: true, | |
| appWindow: this, | |
| autoLoad: false, | |
| root: "task", | |
| totalProperty: "total", | |
| remoteSort: true, | |
| fields: a, | |
| sortInfo: { | |
| field: this.self.COLUMN_ID.TASK_ID, | |
| direction: "ASC" | |
| }, | |
| paramNames: { | |
| start: "offset", | |
| limit: "limit", | |
| sort: "sort_by", | |
| dir: "order" | |
| }, | |
| listeners: { | |
| scope: this, | |
| beforeload: this.beforeloadStore, | |
| load: this.onLoadStore, | |
| loadexception: this.onStoreLoadException | |
| } | |
| }); | |
| this.addManagedComponent(b); | |
| return b | |
| }, | |
| onStoreLoadException: function(b, c, a) { | |
| this.owner.clearStatusBusy(); | |
| this.onLoadStoreError(a.code) | |
| }, | |
| getSortParam: function() { | |
| var a = this.getStore().getSortState().field; | |
| switch (a) { | |
| case "source": | |
| return "connected_peers"; | |
| case "waiting_seconds": | |
| return "waiting_until_time"; | |
| default: | |
| return a | |
| } | |
| }, | |
| getLoadParams: function() { | |
| var b = { | |
| offset: this.gStart || 0, | |
| limit: this.NUM_REC_PER_PAGE, | |
| sort_by: this.getSortParam(), | |
| order: this.getStore().getSortState().direction, | |
| additional: ["detail", "transfer"], | |
| type: ["emule"], | |
| type_inverse: true | |
| }; | |
| if ("undefined" !== typeof (this.filterStatus)) { | |
| b.status = this.filterStatus | |
| } | |
| if ("undefined" !== typeof (this.filterInverse)) { | |
| b.status_inverse = this.filterInverse | |
| } | |
| var a = this.fieldFilter.getValue(); | |
| if (a) { | |
| b.keyword = a | |
| } | |
| return b | |
| }, | |
| beforeloadStore: function(b, c) { | |
| var a; | |
| this.pollingtask.stopById("updateTask"); | |
| if ("undefined" !== typeof (c.params.offset)) { | |
| this.gStart = c.params.offset | |
| } else { | |
| this.gStart = 0 | |
| } | |
| a = this.fieldFilter.getValue(); | |
| if (!Ext.isEmpty(a)) { | |
| b.baseParams.keyword = a | |
| } else { | |
| delete b.baseParams.keyword | |
| } | |
| b.baseParams.status = this.filterStatus; | |
| b.baseParams.status_inverse = this.filterInverse; | |
| this.owner.setStatusBusy(); | |
| this.pollingtask.startById("updateStatistic") | |
| }, | |
| onLoadStore: function(a, d, b) { | |
| this.owner.clearStatusBusy(); | |
| if (this.getStore().getTotalCount() <= this.gStart && 0 < this.gStart) { | |
| var c = Math.ceil((this.getStore().getTotalCount() - this.NUM_REC_PER_PAGE) / this.NUM_REC_PER_PAGE); | |
| this.getStore().load({ | |
| params: { | |
| offset: (c * this.NUM_REC_PER_PAGE), | |
| limit: this.NUM_REC_PER_PAGE | |
| } | |
| }); | |
| this.forceSelectIdx = -1; | |
| return | |
| } | |
| this.pollingtask.startById("updateTask", false); | |
| return this.onFirstSelectRow() | |
| }, | |
| onFirstSelectRow: function() { | |
| if (this.getStore().getCount() < 1) { | |
| this.owner.info.resetForm() | |
| } else { | |
| if (this.forceSelectIdx && 0 < this.forceSelectIdx) { | |
| this.selModel.selectRow(this.forceSelectIdx); | |
| this.getView().focusRow(this.forceSelectIdx); | |
| this.forceSelectIdx = -1; | |
| return false | |
| } else { | |
| if (!this.getSelectionModel().hasSelection()) { | |
| this.getSelectionModel().selectFirstRow() | |
| } | |
| } | |
| } | |
| }, | |
| onLoadStoreError: function(a) { | |
| SYNO.SDS.DownloadStation.Utils.setErrorMask(a, this.owner.panel); | |
| this.pollingtask.startById("updateTask", false) | |
| }, | |
| isSameParams: function(b) { | |
| var a = this.fieldFilter.getValue(); | |
| return (typeof b !== "undefined" && b.sort_by === this.getSortParam() && b.order === this.getStore().getSortState().direction && b.status === this.filterStatus && b.status_inverse === this.filterInverse && b.offset === this.gStart && (!a || b.keyword === a) && (!b.keyword || b.keyword === a)) | |
| }, | |
| createPagingToolbar: function() { | |
| this.itemTotalDownRate = new SYNO.SDS.DownloadStation.ToolbarRateItem({ | |
| labelText: "DL" | |
| }); | |
| this.itemTotalUpRate = new SYNO.SDS.DownloadStation.ToolbarRateItem({ | |
| labelText: "UL" | |
| }); | |
| return new SYNO.ux.PagingToolbar({ | |
| store: this.store, | |
| pageSize: this.NUM_REC_PER_PAGE, | |
| displayInfo: true, | |
| items: [this.itemTotalDownRate, "-", this.itemTotalUpRate, "-"] | |
| }) | |
| }, | |
| updateTotalRate: function(a) { | |
| this.itemTotalDownRate.updateTextByRate(a.download_rate); | |
| this.itemTotalUpRate.updateTextByRate(a.upload_rate) | |
| }, | |
| updateRecords: function(a) { | |
| this.pollingtask.startById("updateTask", a) | |
| }, | |
| updateCaptchaNumber: function(a) { | |
| var d = false; | |
| var c = "0"; | |
| var b = this.owner.toolbar.find("itemId", "captcha")[0]; | |
| if (!Ext.isDefined(b)) { | |
| return | |
| } | |
| if (!Ext.isEmpty(a) && 0 < a) { | |
| d = true; | |
| c = a.toString() | |
| } | |
| b.setVisible(d); | |
| b.setText(c) | |
| }, | |
| getSelectedTaskIds: function() { | |
| var a = []; | |
| Ext.iterate(this.getSelectionModel().getSelections(), function(b) { | |
| a.push(b.get("task_id")) | |
| }, this); | |
| return a | |
| }, | |
| onUpdateRecordsTask: function(e, a, u, k) { | |
| if (!this.getStore()) { | |
| return | |
| } | |
| if (!e) { | |
| return | |
| } | |
| if (a.has_fail) { | |
| var f; | |
| Ext.each(a.result, function(j, i) { | |
| if (false === j.success) { | |
| f = j.error.code | |
| } | |
| }, this); | |
| this.onLoadStoreError(f); | |
| return | |
| } | |
| this.unmask(); | |
| this.owner.panel.el.unmask(); | |
| for (var p = 0; p < a.result.length; p++) { | |
| var h = a.result[p]; | |
| if (this.webapiCaptchaList.api === h.api) { | |
| this.updateCaptchaNumber(h.data.task_ids.length) | |
| } else { | |
| if (this.webapiTotalStatistic.api === h.api) { | |
| this.updateTotalRate(h.data) | |
| } else { | |
| if (this.webapiTaskList.api === h.api) { | |
| if (!this.isSameParams(u.compound[p])) { | |
| this.pollingtask.startById("updateTask"); | |
| return | |
| } | |
| this.unmask(); | |
| var m = false; | |
| var l = false; | |
| var c = this.getStore(); | |
| var s = this.getSelectionModel(); | |
| if (h.data.total != c.getTotalCount()) { | |
| m = true | |
| } else { | |
| var b = []; | |
| var o = false; | |
| var d = []; | |
| var q = c.reader.readRecords(h.data).records; | |
| b = this.getSelectedTaskIds(); | |
| if (1 === b.length) { | |
| o = true; | |
| s.suspendEvents(false) | |
| } | |
| for (var n = 0; n < q.length; n++) { | |
| var r = q[n]; | |
| var g = r.id; | |
| var v = c.getById(g); | |
| if (v) { | |
| var t = c.getAt(n); | |
| if (-1 !== b.indexOf(g)) { | |
| d.push(g) | |
| } | |
| l |= ((v.data.status !== r.data.status) && -1 !== b.indexOf(g)); | |
| Ext.apply(v.data, r.data); | |
| v.commit(); | |
| if (b.length < 2 && t && r.id != t.get("task_id")) { | |
| c.remove(v); | |
| c.insert(n, v) | |
| } | |
| } else { | |
| c.removeAt(n); | |
| c.insert(n, new Ext.data.Record(r.data,r.id)) | |
| } | |
| } | |
| if (true === o) { | |
| if (1 === d.length) { | |
| s.selectRecords([c.getById(d[0])]) | |
| } | |
| s.resumeEvents() | |
| } | |
| } | |
| if (m) { | |
| this.getStore().reload() | |
| } else { | |
| if (l) { | |
| this.getSelectionModel().fireEvent("rowSelectionChanged", this.getSelectionModel()) | |
| } | |
| } | |
| this.onFirstSelectRow() | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| onUpdateTotalStatistic: function(d, b, c, a) { | |
| this.pollingtask.stopById("updateStatistic"); | |
| if (!d) { | |
| this.onLoadStoreError(b.code); | |
| return | |
| } | |
| this.updateTotalRate(b) | |
| }, | |
| launchCaptchaEnterDialog: function(b) { | |
| var a = new SYNO.SDS.DownloadStation.DLM.CaptchaEnterDialog({ | |
| uicomponents: this.uicomponents, | |
| taskId: b | |
| }); | |
| a.show() | |
| }, | |
| onBeforeStart: function(a) { | |
| a.taskCfg.webapi.compound.params = [Ext.apply(this.webapiTaskList, { | |
| params: this.getLoadParams() | |
| }), this.webapiCaptchaList, this.webapiTotalStatistic] | |
| }, | |
| onOpenContainingFolder: function() { | |
| var b = this.getSelectionModel().getSelected(); | |
| if (-1 === this.StatusFinished.indexOf(b.get("status"))) { | |
| return | |
| } | |
| var a = b.get("destination"); | |
| if (a === "") { | |
| this.owner.getMsgBox().alert(_T("fbbrower", "open_folder"), _T("error", "error_dest_no_path")); | |
| return | |
| } | |
| if (true === this._S("is_admin") && (a === "home" || a.substr(0, 5) === "home/")) { | |
| if (b.get("username") !== _S("user")) { | |
| a = (a.length > 4) ? "/" + a.substr(5) : ""; | |
| a = "homes/" + b.get("username") + a | |
| } | |
| } | |
| SYNO.SDS.AppLaunch("SYNO.SDS.App.FileStation3.Instance", { | |
| openfile: "/" + a + "/" + b.get("filename") | |
| }) | |
| }, | |
| addQuickURL: function(a) { | |
| var b = function(c) { | |
| var d = { | |
| type: "url", | |
| url: [a], | |
| destination: c, | |
| create_list: false | |
| }; | |
| this.getGridEl().mask(_DT("common", "saving")); | |
| this.appWin.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.Task", | |
| method: "create", | |
| params: d, | |
| version: 2, | |
| scope: this, | |
| callback: function(h, f, g, e) { | |
| this.owner.clearStatusBusy(); | |
| if (!h) { | |
| this.appWin.getMsgBox().alert(this.title, SYNO.SDS.DownloadStation.Utils.getErrorString(f.code)) | |
| } else { | |
| this.preSelectLastRecord(); | |
| this.updateRecords(true) | |
| } | |
| } | |
| }) | |
| }; | |
| SYNO.SDS.DownloadStation.DLM.Util.checkLocationDestinationNonEmpty(this, b, undefined, this) | |
| }, | |
| preSelectLastRecord: function() { | |
| if (this.store.sortInfo && (this.self.COLUMN_ID.TASK_ID === this.store.sortInfo.field) && ("ASC" === this.store.sortInfo.direction)) { | |
| var a = Math.floor(this.store.getTotalCount() / this.NUM_REC_PER_PAGE); | |
| this.gStart = a * this.NUM_REC_PER_PAGE; | |
| this.forceSelectIdx = (this.store.getTotalCount() % this.NUM_REC_PER_PAGE) | |
| } | |
| }, | |
| unmask: function() { | |
| if (this.getGridEl().isMasked()) { | |
| this.getGridEl().unmask() | |
| } | |
| }, | |
| mask: function(a) { | |
| if (!this.getGridEl().isMasked()) { | |
| this.getGridEl().mask(a) | |
| } | |
| }, | |
| getDefaultHiddenColumns: function() { | |
| throw "Should be a overwritten function." | |
| }, | |
| updateCurrentState: function() { | |
| this.stateManager.updateCurrentState(); | |
| this._refitColumns() | |
| }, | |
| _refitColumns: function() { | |
| this.getColumnModel().totalWidth = null; | |
| this.getView().fitColumns() | |
| } | |
| }); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.QueueGridPanelStateManager", { | |
| extend: "Object", | |
| constructor: function(a) { | |
| Ext.apply(this, a || {}); | |
| this.callParent([a]) | |
| }, | |
| initState: function() { | |
| this._migradeOldState(); | |
| this._updateCurrentState() | |
| }, | |
| saveState: function() { | |
| var a, b; | |
| a = this.owner.getState(); | |
| b = this._cloneSeparatedState(a); | |
| if (false !== b) { | |
| this._setUserCommonState(b.common); | |
| this._setUserCategoryState(b.category) | |
| } | |
| }, | |
| updateCurrentState: function() { | |
| this._updateCurrentState() | |
| }, | |
| _getUserSettings: function(a) { | |
| return this.owner.appWin.appInstance.getUserSettings(a) | |
| }, | |
| _setUserSettings: function(a, b) { | |
| return this.owner.appWin.appInstance.setUserSettings(a, b) | |
| }, | |
| _getUserCommonState: function() { | |
| var a = this.owner.owner.getGridCommonStateKey(); | |
| return this._getUserSettings(a) | |
| }, | |
| _setUserCommonState: function(b) { | |
| var a = this.owner.owner.getGridCommonStateKey(); | |
| return this._setUserSettings(a, b) | |
| }, | |
| _getUserCategoryState: function() { | |
| var a = this.owner.gridCategoryStateKey; | |
| return this._getUserSettings(a) | |
| }, | |
| _setUserCategoryState: function(b) { | |
| var a = this.owner.gridCategoryStateKey; | |
| return this._setUserSettings(a, b) | |
| }, | |
| _checkStateValue: function(a) { | |
| return SYNO.SDS.DownloadStation.Utils.checkStateValue(a, this.owner.colModel) | |
| }, | |
| _migradeOldState: function() { | |
| var a, b; | |
| a = this._getUserSettings("dlmqueuegridstates"); | |
| if (Ext.isEmpty(a)) { | |
| return | |
| } | |
| this._setUserSettings("dlmqueuegridstates", undefined); | |
| b = this._cloneSeparatedState(a); | |
| if (false !== b) { | |
| this._setUserCommonState(b.common); | |
| this._setUserCategoryState(b.category) | |
| } | |
| }, | |
| _updateCurrentState: function() { | |
| var c, a, b; | |
| c = this._getUserCommonState(); | |
| if (Ext.isEmpty(c)) { | |
| c = this.owner.getState() | |
| } | |
| a = this._getUserCategoryState(); | |
| if (Ext.isEmpty(a)) { | |
| a = { | |
| hiddenColumns: this.owner.getDefaultHiddenColumns() | |
| } | |
| } | |
| b = this._cloneAndMergeStates(c, a); | |
| if (false === b) { | |
| return | |
| } | |
| this._applyState(b) | |
| }, | |
| _cloneAndMergeStates: function(d, b) { | |
| var c; | |
| var a = this._checkStateValue(d); | |
| if (false === a) { | |
| return false | |
| } | |
| if (Ext.isDefined(b.sort)) { | |
| a.sort = { | |
| field: b.sort.field, | |
| direction: b.sort.direction | |
| } | |
| } else { | |
| a.sort = { | |
| field: this.owner.self.COLUMN_ID.TASK_ID, | |
| direction: "ASC" | |
| } | |
| } | |
| c = b.hiddenColumns; | |
| if (!Ext.isEmpty(c) && Ext.isArray(c)) { | |
| a.columns.forEach(function(e) { | |
| if (-1 !== c.indexOf(e.id)) { | |
| e.hidden = true | |
| } else { | |
| if (undefined !== e.hidden) { | |
| delete e.hidden | |
| } | |
| } | |
| }) | |
| } | |
| return a | |
| }, | |
| _applyState: function(a) { | |
| if (a) { | |
| if (this.owner.fireEvent("beforestaterestore", this.owner, a) !== false) { | |
| this.owner.applyState(Ext.apply({}, a)); | |
| this.owner.fireEvent("staterestore", this.owner, a) | |
| } | |
| } | |
| }, | |
| _cloneSeparatedState: function(c) { | |
| var a = { | |
| hiddenColumns: [] | |
| }; | |
| var b = this._checkStateValue(c); | |
| if (false === b) { | |
| return false | |
| } | |
| if (Ext.isDefined(b.sort)) { | |
| a.sort = b.sort; | |
| delete b.sort | |
| } | |
| b.columns.forEach(function(d) { | |
| if (undefined !== d.hidden) { | |
| if (true === d.hidden) { | |
| a.hiddenColumns.push(d.id) | |
| } | |
| delete d.hidden | |
| } | |
| }); | |
| return { | |
| common: b, | |
| category: a | |
| } | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.DLM"); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.QueueBasic", { | |
| extend: "SYNO.SDS.DownloadStation.RightPanel", | |
| ADDTASK_MAXLIMIT: 50, | |
| ADDTASK_MAXSIZE: 104857600, | |
| NUM_REC_PER_PAGE: 25, | |
| GRID_STATE_CATEGORY_ID: "default", | |
| constructor: function(a) { | |
| this.callParent(arguments) | |
| }, | |
| createPanel: function() { | |
| var a = this.cp; | |
| if (!a.QueuePanel) { | |
| a.QueuePanel = this.callParent(arguments) | |
| } | |
| return a.QueuePanel | |
| }, | |
| createActionGroup: function() { | |
| var a = this.cp; | |
| if (!a.QueueActionGroup) { | |
| this.actionGroup = new SYNO.SDS.DownloadStation.DLM.QueueActionGroup({ | |
| uicomponents: this.uicomponents, | |
| owner: this.panel.module | |
| }); | |
| a.QueueActionGroup = this.actionGroup; | |
| this.grid.mon(this.grid.getSelectionModel(), "rowSelectionChanged", this.actionGroup.updateBtns, this.actionGroup) | |
| } | |
| return a.QueueActionGroup | |
| }, | |
| createUpperPanel: function(a) { | |
| this.grid = new SYNO.SDS.DownloadStation.DLM.QueueGridPanel(a); | |
| this.utils.addUIComponents(this, "queueGrid", this.grid); | |
| return this.grid | |
| }, | |
| createLowerPanel: function(a) { | |
| Ext.apply(a, { | |
| owner: this | |
| }); | |
| this.info = new SYNO.SDS.DownloadStation.DLM.QueueInfoPanel(a); | |
| return this.info | |
| }, | |
| onTabDeactivate: function() { | |
| if (this.pollingtask) { | |
| this.pollingtask.stopAll() | |
| } | |
| }, | |
| onActivate: function() { | |
| this.upperPanel = this.panel.items.get(0); | |
| this.lowerPanel = this.panel.items.get(1); | |
| this.updateConcreteConfig(this.upperPanel); | |
| this.upperPanel.updateCurrentState(); | |
| this.upperPanel.gStart = 0; | |
| this.upperPanel.getStore().reload() | |
| }, | |
| onDeactivate: function() { | |
| if (this.pollingtask) { | |
| this.pollingtask.stopAll() | |
| } | |
| }, | |
| updateConcreteConfig: function(a) { | |
| a.filterStatus = this.filterStatus; | |
| a.filterInverse = this.filterInverse; | |
| a.gridCategoryStateKey = this.getGridCategoryStateKey(); | |
| a.getDefaultHiddenColumns = this.getDefaultHiddenColumns | |
| }, | |
| getGridCommonStateKey: function() { | |
| return "dlm_queue_grid_state_common" | |
| }, | |
| getGridCategoryStateKey: function() { | |
| return "dlm_queue_grid_state_" + this.GRID_STATE_CATEGORY_ID | |
| }, | |
| getDefaultHiddenColumns: function() { | |
| var a = SYNO.SDS.DownloadStation.DLM.QueueGridPanel.COLUMN_ID; | |
| return [a.TOTAL_UPLOAD, a.TIMELEFT, a.STARTED_TIME, a.COMPLETED_TIME, a.WAITING_SECONDS, a.USERNAME] | |
| } | |
| }); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.QueueAll", { | |
| extend: "SYNO.SDS.DownloadStation.DLM.QueueBasic", | |
| filterStatus: undefined, | |
| filterInverse: undefined | |
| }); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.QueueDownloading", { | |
| extend: "SYNO.SDS.DownloadStation.DLM.QueueBasic", | |
| filterStatus: [SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_DOWNLOADING, SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_HASH_CHECKING, SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_FINISHING, SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_DOWNLOADED, SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_POSTPROCESSING], | |
| filterInverse: false, | |
| GRID_STATE_CATEGORY_ID: "downloading", | |
| getDefaultHiddenColumns: function() { | |
| var a = SYNO.SDS.DownloadStation.DLM.QueueGridPanel.COLUMN_ID; | |
| return [a.TOTAL_UPLOAD, a.UPLOAD_RATE, a.COMPLETED_TIME, a.WAITING_SECONDS, a.USERNAME] | |
| } | |
| }); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.QueueFinished", { | |
| extend: "SYNO.SDS.DownloadStation.DLM.QueueBasic", | |
| filterStatus: [SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_PRE_SEEDING, SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_SEEDING, SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_FINISHED], | |
| filterInverse: false, | |
| GRID_STATE_CATEGORY_ID: "finished", | |
| getDefaultHiddenColumns: function() { | |
| var a = SYNO.SDS.DownloadStation.DLM.QueueGridPanel.COLUMN_ID; | |
| return [a.CURRENT_SIZE, a.PROGRESS, a.CURRENT_RATE, a.TIMELEFT, a.STARTED_TIME, a.WAITING_SECONDS, a.USERNAME] | |
| } | |
| }); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.QueueActive", { | |
| extend: "SYNO.SDS.DownloadStation.DLM.QueueBasic", | |
| filterStatus: [SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_DOWNLOADING, SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_HASH_CHECKING, SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_PRE_SEEDING, SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_SEEDING], | |
| filterInverse: false, | |
| GRID_STATE_CATEGORY_ID: "active", | |
| getDefaultHiddenColumns: function() { | |
| var a = SYNO.SDS.DownloadStation.DLM.QueueGridPanel.COLUMN_ID; | |
| return [a.COMPLETED_TIME, a.WAITING_SECONDS, a.USERNAME] | |
| } | |
| }); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.QueueInactive", { | |
| extend: "SYNO.SDS.DownloadStation.DLM.QueueBasic", | |
| filterStatus: [SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_DOWNLOADING, SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_HASH_CHECKING, SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_PRE_SEEDING, SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_SEEDING], | |
| filterInverse: true, | |
| GRID_STATE_CATEGORY_ID: "inactive", | |
| getDefaultHiddenColumns: function() { | |
| var a = SYNO.SDS.DownloadStation.DLM.QueueGridPanel.COLUMN_ID; | |
| return [a.TOTAL_UPLOAD, a.UPLOAD_RATE, a.CURRENT_RATE, a.TIMELEFT, a.STARTED_TIME, a.COMPLETED_TIME, a.USERNAME] | |
| } | |
| }); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.QueueStopped", { | |
| extend: "SYNO.SDS.DownloadStation.DLM.QueueBasic", | |
| filterStatus: [SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_PAUSED], | |
| filterInverse: false, | |
| GRID_STATE_CATEGORY_ID: "paused", | |
| getDefaultHiddenColumns: function() { | |
| var a = SYNO.SDS.DownloadStation.DLM.QueueGridPanel.COLUMN_ID; | |
| return [a.TOTAL_UPLOAD, a.UPLOAD_RATE, a.CURRENT_RATE, a.TIMELEFT, a.STATUS, a.STARTED_TIME, a.COMPLETED_TIME, a.WAITING_SECONDS, a.USERNAME] | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation"); | |
| Ext.define("SYNO.SDS.DownloadStation.SearchGridPanel", { | |
| extend: "SYNO.ux.GridPanel", | |
| constructor: function(a) { | |
| Ext.applyIf(this, a.uicomponents || {}); | |
| this.callParent(arguments) | |
| }, | |
| getSelectedRows: function() { | |
| var n = this.getView().getRows(); | |
| var g = Ext.getBody().createChild({ | |
| tag: "div", | |
| cls: "download_dup_row", | |
| style: "z-index: 99999; position:absolute" | |
| }); | |
| var j = this.getColumnModel(); | |
| var h = []; | |
| var a = this.getView(); | |
| var f = true; | |
| if (Ext.isEmpty(j)) { | |
| return null | |
| } | |
| Ext.each(j.columns, function(i) { | |
| h.push("x-grid3-col-" + i.id) | |
| }); | |
| for (var e = 0; e < n.length; ++e) { | |
| var m = n.item(e); | |
| if (!Ext.fly(m).hasClass(a.selectedRowClass)) { | |
| continue | |
| } | |
| if (f) { | |
| g.setLeft(Ext.fly(m).getLeft()); | |
| g.setTop(Ext.fly(m).getTop()) | |
| } | |
| var l = []; | |
| var k, d, c; | |
| for (k = 0; k < h.length; k++) { | |
| d = Ext.fly(m).child("div[class=x-grid3-cell-inner " + h[k] + " x-unselectable]"); | |
| c = d.getWidth(); | |
| l.push(c) | |
| } | |
| var b = Ext.fly(m.cloneNode(true)); | |
| b.removeClass(a.selectedRowClass); | |
| b.removeClass("x-grid3-row-over"); | |
| g.appendChild(b.dom); | |
| for (k = 0; k < h.length; k++) { | |
| d = b.child("div[class=x-grid3-cell-inner " + h[k] + " x-unselectable]"); | |
| c = l[k]; | |
| if (d && c > 0) { | |
| d.setWidth(c) | |
| } | |
| } | |
| f = false | |
| } | |
| if (true === f) { | |
| return null | |
| } | |
| return g | |
| }, | |
| animateRows: function() { | |
| var d = this.getSelectedRows(); | |
| if (!d) { | |
| return | |
| } | |
| var b = this.moduleList; | |
| var a = { | |
| x: d.getLeft(), | |
| y: d.getTop() | |
| }; | |
| var c = { | |
| x: b.getEl().getLeft(), | |
| y: b.getEl().getTop() | |
| }; | |
| var e = [{ | |
| toPos: { | |
| x: a.x, | |
| y: a.y - 13 | |
| }, | |
| toScale: 1, | |
| duration: 0.65, | |
| opacity: 1, | |
| origin: "50% 50%" | |
| }, { | |
| toPos: { | |
| x: c.x, | |
| y: c.y + 20 | |
| }, | |
| toScale: 0.2, | |
| duration: 0.55, | |
| opacity: 0.8, | |
| origin: "0% 0%" | |
| }, { | |
| toPos: { | |
| x: c.x, | |
| y: c.y + 20 | |
| }, | |
| toScale: 0, | |
| duration: 0.3, | |
| opacity: 0, | |
| origin: "0% 0%" | |
| }]; | |
| var f = "-webkit-transform-origin: {5}; -moz-transform-origin: {5}; -o-transform-origin: {5}; "; | |
| f += "-webkit-transition-property: left top -webkit-transform opacity;"; | |
| f += "-moz-transition-property: left top -moz-transform opacity;"; | |
| f += "-o-transition-property: left top -o-transform opacity;"; | |
| f += "z-index: 99999; position: absolute; left: {0}px; top: {1}px; opacity: {4};"; | |
| f += "-webkit-transform: scale({2}); -moz-transform: scale({2}); -o-transform: scale({2}); -ms-transform: scale({2});"; | |
| f += "-webkit-transition-duration: {3}; -moz-transition-duration: {3}; -o-transition-duration: {3}; -ms-transition-duration: {3};"; | |
| d.dom.style.cssText = String.format(f, a.x, a.y, 1, "0s", 1, "50% 50%"); | |
| d.frameIdx = 0; | |
| d.animTo = function(h) { | |
| if (!h) { | |
| return | |
| } | |
| if (Ext.isIE) { | |
| if (h.toScale != 1) { | |
| d.animScale(h.duration * 1000, h.toScale) | |
| } | |
| this.shift({ | |
| x: h.toPos.x, | |
| y: h.toPos.y, | |
| easing: "easeOut", | |
| duration: h.duration, | |
| opacity: h.opacity, | |
| scope: this, | |
| callback: this.endTransition | |
| }) | |
| } else { | |
| var g = String.format(f, h.toPos.x, h.toPos.y, h.toScale, h.duration + "s", h.opacity, h.origin); | |
| this.dom.style.cssText = g; | |
| this.endTransition.defer(h.duration * 1000) | |
| } | |
| } | |
| .createDelegate(d); | |
| d.endTransition = function(g) { | |
| if (d.frameIdx++ >= e.length - 1) { | |
| try { | |
| document.body.removeChild(d.dom) | |
| } catch (h) {} | |
| return | |
| } | |
| d.animTo(e[d.frameIdx]) | |
| } | |
| ; | |
| if (Ext.isIE) { | |
| d.animScale = function(h, g, i) { | |
| if (this.timer) { | |
| window.clearInterval(this.timer) | |
| } | |
| this.framerate = 25; | |
| this.from = this.currentScale ? this.currentScale : 1; | |
| this.to = g; | |
| this.currentScale = g; | |
| this.from_to = this.to - this.from; | |
| this.duration = h; | |
| this.frameCount = 0; | |
| this.endFrame = Math.ceil(this.duration / 1000 * this.framerate); | |
| this.stepperframe = this.from_to / this.endFrame; | |
| this.currentVal = this.from; | |
| this.interval = 1 / this.framerate; | |
| this._tick = function() { | |
| var j = String.format("progid:DXImageTransform.Microsoft.Matrix(M11={0}, M12=0, M21=0, M22={0}, SizingMethod='auto expand')", (this.currentVal += this.stepperframe)); | |
| this.setStyle("-ms-filter", j); | |
| this.setStyle("filter", j); | |
| if (this.frameCount++ > this.endFrame) { | |
| window.clearInterval(this.timer); | |
| if (i) { | |
| i() | |
| } | |
| } | |
| } | |
| .createDelegate(this); | |
| this.timer = window.setInterval(this._tick, this.interval * 1000) | |
| } | |
| .createDelegate(d) | |
| } | |
| d.animTo(e[0]) | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.DLM"); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.SearchGridPanel", { | |
| extend: "SYNO.SDS.DownloadStation.SearchGridPanel", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| this.owner = a.owner; | |
| this.keyword = a.keyword; | |
| this.maxRequestTimes = 120; | |
| this.itemsPerPage = a.owner.itemsPerPage; | |
| this.callParent([this.fillConfig(a)]) | |
| }, | |
| fillConfig: function(a) { | |
| this.webapiCompound = { | |
| api: "SYNO.Entry.Request", | |
| method: "request", | |
| version: 1 | |
| }; | |
| this.webapiStart = { | |
| api: "SYNO.DownloadStation2.BTSearch", | |
| method: "start", | |
| version: 1 | |
| }; | |
| this.webapiStop = { | |
| api: "SYNO.DownloadStation2.BTSearch", | |
| method: "stop", | |
| version: 1 | |
| }; | |
| this.webapiList = { | |
| api: "SYNO.DownloadStation2.BTSearch", | |
| method: "list", | |
| version: 1 | |
| }; | |
| this.webapiListCategory = { | |
| api: "SYNO.DownloadStation2.BTSearch", | |
| method: "list_category", | |
| version: 1 | |
| }; | |
| this.store = this.createStore(); | |
| var b = { | |
| title: Ext.util.Format.htmlEncode(this.keyword), | |
| tabTip: Ext.util.Format.htmlEncode(this.keyword), | |
| store: this.store, | |
| colModel: this.createColModel(), | |
| bbar: this.createBottombar(), | |
| selModel: new Ext.grid.RowSelectionModel({ | |
| singleSelect: false | |
| }), | |
| viewConfig: { | |
| trackResetOnLoad: false | |
| }, | |
| closable: true, | |
| loadMask: true, | |
| stripeRows: true, | |
| border: false, | |
| enableColumnMove: true, | |
| stateful: true, | |
| stateEvents: ["columnmove", "columnresize", "sortchange"], | |
| initState: (function() { | |
| var d = this.appWin.appInstance.getUserSettings("dlmsearchgridstates"); | |
| var c = SYNO.SDS.DownloadStation.Utils.checkStateValue(d, this.colModel); | |
| if (c) { | |
| if (this.fireEvent("beforestaterestore", this, c) !== false) { | |
| this.applyState(Ext.apply({}, c)); | |
| this.fireEvent("staterestore", this, c) | |
| } | |
| } | |
| } | |
| ).createDelegate(this), | |
| saveState: (function() { | |
| var c = this.getState(); | |
| this.appWin.appInstance.setUserSettings("dlmsearchgridstates", c) | |
| } | |
| ).createDelegate(this), | |
| listeners: { | |
| scope: this, | |
| afterlayout: { | |
| single: true, | |
| fn: function() { | |
| this.gridCtxMenu = this.createCtxMenu(); | |
| this.addManagedComponent(this.gridCtxMenu); | |
| this.sendSearchRequest() | |
| } | |
| }, | |
| beforeclose: this.onBeforeClose, | |
| celldblclick: { | |
| scope: this.owner, | |
| fn: this.owner.beforeDownloadSelected | |
| }, | |
| rowcontextmenu: function(c, h, d) { | |
| d.preventDefault(); | |
| var f = c.getSelectionModel(); | |
| if (!f.isSelected(h)) { | |
| f.selectRow(h) | |
| } | |
| if (f.getCount() > 1) { | |
| this.gridCtxMenu.getComponent("mitem_extlink").disable() | |
| } else { | |
| this.gridCtxMenu.getComponent("mitem_extlink").enable() | |
| } | |
| this.gridCtxMenu.showAt(d.getXY()) | |
| }, | |
| activate: function(i) { | |
| if ("" === this.keyword) { | |
| return | |
| } | |
| var h = i.getGridEl(); | |
| var d = this.owner.actionGroup.get("filter"); | |
| var f = this.owner.actionGroup.get("search_category"); | |
| var c = this.categories || []; | |
| var g = this.categoryVal || "_allcat_"; | |
| if (h.isMasked()) { | |
| h.child(".ext-el-mask-msg").center(h) | |
| } | |
| d.store = this.getStore(); | |
| if (this.filterWord) { | |
| d.setValue(this.filterWord); | |
| d.trigger.show() | |
| } | |
| this.loadCategoryStore(c); | |
| f.setValue(g); | |
| f.mon(f, "select", this.onCategoreySelect, this) | |
| }, | |
| deactivate: function(e) { | |
| if ("" === this.keyword) { | |
| return | |
| } | |
| var c = this.owner.actionGroup.get("filter"); | |
| var d = this.owner.actionGroup.get("search_category"); | |
| this.filterWord = c.getValue(); | |
| c.reset(); | |
| this.categoryVal = d.getValue(); | |
| d.mun(d, "select", this.onCategoreySelect, this); | |
| d.getStore().loadData([["_allcat_", _DT("download", "download_allcategory")]], false); | |
| d.setValue("_allcat_") | |
| } | |
| } | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| createCtxMenu: function() { | |
| var a = []; | |
| var c = [{ | |
| itemId: "downloadnow", | |
| text: _DT("download", "download_now"), | |
| style: "", | |
| iconCls: "" | |
| }, { | |
| itemId: "downloadto", | |
| text: _DT("download", "download_to"), | |
| iconCls: "" | |
| }]; | |
| for (var b = 0; b < c.length; b++) { | |
| var d = this.owner.actionGroup.get(c[b].itemId).initialConfig; | |
| a.push(Ext.apply(d, c[b])) | |
| } | |
| a.push({ | |
| text: _DT("download", "open_extenallink"), | |
| handler: this.openTorrentLink, | |
| itemId: "mitem_extlink", | |
| scope: this | |
| }); | |
| var e = new SYNO.ux.Menu({ | |
| cls: "syno-dlm-menu", | |
| items: a, | |
| listeners: { | |
| scope: this, | |
| beforeshow: function(g) { | |
| var f = this.owner.updateBtnStatus(); | |
| g.get("downloadnow").setDisabled(!f.blAdd); | |
| g.get("downloadto").setDisabled(!f.blAdd) | |
| } | |
| } | |
| }); | |
| return e | |
| }, | |
| openTorrentLink: function() { | |
| var a = this.getSelectionModel().getSelected(); | |
| if (a) { | |
| window.open(a.get("page")) | |
| } | |
| }, | |
| createBottombar: function() { | |
| this.txtSearching = new Ext.Toolbar.TextItem(""); | |
| var a = new SYNO.ux.PagingToolbar({ | |
| store: this.store, | |
| displayInfo: true, | |
| pageSize: this.itemsPerPage, | |
| refreshText: _DT("download", "download_btn_refresh"), | |
| items: this.txtSearching, | |
| autoDestroy: true | |
| }); | |
| return a | |
| }, | |
| createColModel: function() { | |
| var a = new Ext.grid.ColumnModel({ | |
| columns: [{ | |
| id: "title", | |
| header: _DT("download", "download_list_filename"), | |
| dataIndex: "title", | |
| width: 260, | |
| renderer: SYNO.SDS.DownloadStation.DLM.Util.nameRender.createDelegate(this) | |
| }, { | |
| id: "size", | |
| header: _DT("download", "download_list_filesize"), | |
| dataIndex: "size", | |
| width: 105, | |
| renderer: SYNO.SDS.DownloadStation.Renderers.SizeRenderer | |
| }, { | |
| id: "date", | |
| header: _T("time", "time_time"), | |
| dataIndex: "date", | |
| width: 155, | |
| renderer: function(g, e, b, d, f, c) { | |
| return SYNO.SDS.DateTimeFormatter(new Date(g), { | |
| type: "date" | |
| }) | |
| } | |
| }, { | |
| id: "seeds", | |
| header: _DT("download", "seeds"), | |
| dataIndex: "seeds", | |
| width: 85, | |
| renderer: function(c) { | |
| var b = Ext.util.Format.htmlEncode(c); | |
| return ((c < 0) ? _DT("download", "download_status_unknown") : b) | |
| } | |
| }, { | |
| id: "peers", | |
| width: 85, | |
| header: _DT("download", "download_list_peer"), | |
| dataIndex: "peers", | |
| renderer: function(c) { | |
| var b = Ext.util.Format.htmlEncode(c); | |
| return ((c < 0) ? _DT("download", "download_status_unknown") : b) | |
| } | |
| }, { | |
| id: "provider", | |
| header: _DT("download", "download_search_provider"), | |
| dataIndex: "provider", | |
| hidden: true, | |
| width: 120 | |
| }], | |
| defaults: { | |
| sortable: true, | |
| menuDisabled: false, | |
| align: "left" | |
| } | |
| }); | |
| return a | |
| }, | |
| createStore: function() { | |
| var a = [{ | |
| name: "title" | |
| }, { | |
| name: "size" | |
| }, { | |
| name: "date" | |
| }, { | |
| name: "seeds" | |
| }, { | |
| name: "peers" | |
| }, { | |
| name: "provider" | |
| }, { | |
| name: "dlurl" | |
| }, { | |
| name: "page" | |
| }]; | |
| var b = new SYNO.API.JsonStore({ | |
| api: this.webapiList.api, | |
| method: this.webapiList.method, | |
| version: this.webapiList.version, | |
| pruneModifiedRecords: true, | |
| appWindow: this, | |
| autoLoad: false, | |
| root: "results", | |
| idProperty: "result_id", | |
| totalProperty: "total", | |
| remoteSort: true, | |
| fields: a, | |
| sortInfo: { | |
| field: "seeds", | |
| direction: "DESC" | |
| }, | |
| paramNames: { | |
| start: "offset", | |
| limit: "limit", | |
| sort: "sort_by", | |
| dir: "order" | |
| }, | |
| listeners: { | |
| scope: this, | |
| beforeload: this.onBeforeStoreLoad, | |
| load: this.onStoreLoad, | |
| exception: function(d, e, f, c, g) { | |
| this.showErrorMessage(g.code) | |
| } | |
| } | |
| }); | |
| this.addManagedComponent(b); | |
| return b | |
| }, | |
| getCategoryValue: function() { | |
| var a = this.owner.actionGroup.get("search_category").getValue(); | |
| if (!Ext.isEmpty(a) && "_allcat_" !== a) { | |
| return a | |
| } | |
| return undefined | |
| }, | |
| getFilterValue: function() { | |
| var a = this.owner.actionGroup.get("filter").getValue(); | |
| if (!Ext.isEmpty(a)) { | |
| return a | |
| } | |
| return undefined | |
| }, | |
| onBeforeStoreLoad: function(a, b) { | |
| if ("" === this.title) { | |
| return false | |
| } | |
| this.pollingtask.stopById(this.searchTaskID); | |
| if (Ext.isDefined(this.gridStartPosition)) { | |
| this.gridStartPosition = b.params.start | |
| } else { | |
| this.gridStartPosition = 0 | |
| } | |
| b.params.id = this.searchTaskID; | |
| var d = this.getCategoryValue(); | |
| if (Ext.isDefined(d)) { | |
| b.params.categories = [d] | |
| } else { | |
| delete b.params.categories | |
| } | |
| var c = this.getFilterValue(); | |
| if (Ext.isDefined(c)) { | |
| b.params.keyword = c | |
| } else { | |
| delete b.params.keyword | |
| } | |
| }, | |
| onStoreLoad: function() { | |
| this.updateGridElMaskByRecords(); | |
| this.pollingtask.startById(this.searchTaskID, false) | |
| }, | |
| updateGridElMaskByRecords: function() { | |
| if (this.isDestroyed || this.stillRunning) { | |
| return | |
| } | |
| if (0 === this.getStore().getCount()) { | |
| this.getGridEl().mask(_DT("search", "no_match_search_item")) | |
| } else { | |
| this.getGridEl().unmask() | |
| } | |
| }, | |
| onBeforeClose: function(a) { | |
| a.fireEvent("deactivate", a); | |
| this.stopSearch(true); | |
| this.onCloseHandler() | |
| }, | |
| onCloseHandler: function() { | |
| if (this.searchTaskID) { | |
| this.cleanResult() | |
| } | |
| }, | |
| getDisabledPlugins: function() { | |
| var a = this.appWin.appInstance.getUserSettings("btsearchplugins") || []; | |
| var c = []; | |
| for (var b = 0; b < a.length; b++) { | |
| if (a[b].enable === false) { | |
| c.push(a[b].name) | |
| } | |
| } | |
| return c | |
| }, | |
| sendSearchRequest: function() { | |
| if (!this.keyword || "" === this.keyword) { | |
| return | |
| } | |
| if (this.searchTaskID) { | |
| this.pollingtask.removeById(this.searchTaskID); | |
| this.pollingtask.removeById("btsearchingtext" + this.searchTaskID) | |
| } | |
| var b = { | |
| action: "search", | |
| keyword: this.keyword | |
| }; | |
| var a = this.getDisabledPlugins(); | |
| if (!Ext.isEmpty(a)) { | |
| Ext.apply(b, { | |
| plugins: a, | |
| plugin_inverse: true | |
| }) | |
| } | |
| if (this.getGridEl().isMasked()) { | |
| this.getGridEl().unmask() | |
| } | |
| if (!this.getEl().isMasked()) { | |
| this.getEl().mask(_DT("search", "title_searching"), "x-mask-loading") | |
| } | |
| this.txtSearching.getEl().update(_DT("common", "searching")); | |
| SYNO.API.Request({ | |
| webapi: Ext.apply(this.webapiStart, { | |
| params: b | |
| }), | |
| callback: function(f, d, e, c) { | |
| if (!f) { | |
| this.showErrorMessage(d.code); | |
| if (!this.txtSearching.isDestroyed) { | |
| this.txtSearching.getEl().update("") | |
| } | |
| return | |
| } | |
| this.searchTaskID = d.id; | |
| if (this.isDestroyed) { | |
| this.stopSearch(true); | |
| this.cleanResult() | |
| } else { | |
| this.startSearch() | |
| } | |
| }, | |
| scope: this | |
| }) | |
| }, | |
| stopSearch: function(a) { | |
| if (this.searchTaskID) { | |
| this.pollingtask.removeById(this.searchTaskID); | |
| this.pollingtask.removeById("btsearchingtext" + this.searchTaskID) | |
| } | |
| if (this.getEl().isMasked()) { | |
| this.getEl().unmask() | |
| } | |
| this.stillRunning = false; | |
| this.updateGridElMaskByRecords(); | |
| if (!this.txtSearching.isDestroyed) { | |
| this.txtSearching.getEl().update("") | |
| } | |
| }, | |
| startSearch: function(b) { | |
| this.stillRunning = true; | |
| this.requestTimes = 0; | |
| var c = { | |
| id: this.searchTaskID | |
| }; | |
| var a = { | |
| stopwhenerror: false, | |
| params: [Ext.apply(this.webapiList, { | |
| params: c | |
| }), Ext.apply(this.webapiListCategory, { | |
| params: c | |
| })] | |
| }; | |
| this.pollingtask.add([{ | |
| id: this.searchTaskID, | |
| interval: 5000, | |
| webapi: Ext.apply(this.webapiCompound, { | |
| compound: a | |
| }), | |
| single: false, | |
| autoJsonDecode: true, | |
| beforestart: this.beforeSearchPolling, | |
| callback: this.updateBySearchPolling, | |
| scope: this | |
| }, { | |
| id: "btsearchingtext" + this.searchTaskID, | |
| interval: 1000, | |
| scope: this, | |
| run: function() { | |
| if (this.txtSearching.isDestroyed) { | |
| return | |
| } | |
| var e = this.txtSearching.getEl(); | |
| var f = _DT("search", "title_searching") | |
| , d = e.dom.innerHTML.replace(f, "").indexOf(" ") | |
| , h = this.utils.fillArray(" ", 3); | |
| for (var g = 0; g <= d; g++) { | |
| h[g] = "." | |
| } | |
| e.update(f + h.join("")) | |
| } | |
| }]); | |
| this.pollingtask.getTaskById(this.searchTaskID).interval = 2000; | |
| this.pollingtask.startById(this.searchTaskID, false); | |
| this.pollingtask.startById("btsearchingtext" + this.searchTaskID) | |
| }, | |
| beforeSearchPolling: function(a) { | |
| if (this.isDestroyed || !this.searchTaskID) { | |
| return false | |
| } | |
| var e = { | |
| sort_by: this.store.sortInfo.field, | |
| order: this.store.sortInfo.direction, | |
| offset: Ext.isDefined(this.gridStartPosition) ? this.gridStartPosition : 0, | |
| limit: this.itemsPerPage, | |
| id: this.searchTaskID | |
| }; | |
| var d = this.getCategoryValue(); | |
| if (Ext.isDefined(d)) { | |
| Ext.apply(e, { | |
| categories: [d] | |
| }) | |
| } | |
| var c = this.getFilterValue(); | |
| if (!Ext.isEmpty(c)) { | |
| Ext.apply(e, { | |
| keyword: c | |
| }) | |
| } | |
| for (var b = 0; b < a.taskCfg.webapi.compound.params.length; b++) { | |
| var f = a.taskCfg.webapi.compound.params[b]; | |
| if (this.webapiList.api === f.api && this.webapiList.method === f.method) { | |
| f.params = e | |
| } | |
| } | |
| }, | |
| updateBySearchPolling: function(g, e, f, c) { | |
| if (this.isDestroyed || !this.searchTaskID) { | |
| return false | |
| } | |
| var a; | |
| var b; | |
| if (e.has_fail) { | |
| var d; | |
| Ext.iterate(e.result, function(i, h) { | |
| if (!i.success && Ext.isDefined(i.error.code)) { | |
| d = i.error.code | |
| } | |
| }, this); | |
| this.stopSearch(); | |
| this.showErrorMessage(d); | |
| return | |
| } | |
| Ext.iterate(e.result, function(i, h) { | |
| if (this.webapiList.api === i.api && this.webapiList.method == i.method) { | |
| a = i | |
| } else { | |
| if (this.webapiListCategory.api === i.api && this.webapiListCategory.method == i.method) { | |
| b = i | |
| } | |
| } | |
| }, this); | |
| if (g) { | |
| this.updateByResponse(a, b); | |
| this.updateGridElMaskByRecords() | |
| } | |
| this.requestTimes = this.requestTimes ? (this.requestTimes + 1) : 1; | |
| if (false === a.data.is_running || this.requestTimes >= this.maxRequestTimes) { | |
| this.stopSearch() | |
| } | |
| }, | |
| updateByResponse: function(a, b) { | |
| if (!Ext.isEmpty(b.data.categories)) { | |
| this.loadCategoryStore(b.data.categories) | |
| } | |
| if (a.data.total > 0 && this.getEl().isMasked()) { | |
| this.getEl().unmask() | |
| } | |
| if (this.store.getTotalCount() != a.data.total) { | |
| this.updateGrid(a.data) | |
| } | |
| }, | |
| updateGrid: function(a) { | |
| this.store.loadData(a, false); | |
| this.ensureLastSelectionVisible() | |
| }, | |
| ensureLastSelectionVisible: function() { | |
| var a, b, c; | |
| a = this.getSelectionModel().getSelections(); | |
| if (Ext.isEmpty(a)) { | |
| return | |
| } | |
| b = a[a.length - 1]; | |
| c = this.store.indexOf(b); | |
| this.getView().ensureVisible(c) | |
| }, | |
| loadCategoryStore: function(b) { | |
| var d = this.owner.actionGroup.get("search_category"); | |
| var a = [["_allcat_", _DT("download", "download_allcategory")]]; | |
| for (var c = 0; c < b.length; c++) { | |
| a.push([b[c], b[c]]) | |
| } | |
| this.categories = b; | |
| d.getStore().loadData(a, false) | |
| }, | |
| cleanResult: function() { | |
| SYNO.API.Request({ | |
| webapi: Ext.apply(this.webapiStop, { | |
| params: { | |
| id: this.searchTaskID | |
| } | |
| }), | |
| callback: function(d, b, c, a) { | |
| if (!d) { | |
| SYNO.Debug("Failed to stop task " + b.code); | |
| return | |
| } | |
| }, | |
| scope: this | |
| }) | |
| }, | |
| onCategoreySelect: function() { | |
| var a = { | |
| start: 0, | |
| limit: this.itemsPerPage | |
| }; | |
| this.store.load({ | |
| params: a | |
| }) | |
| }, | |
| showErrorMessage: function(a) { | |
| if (this.getEl().isMasked()) { | |
| this.getEl().unmask() | |
| } | |
| this.getGridEl().mask(SYNO.SDS.DownloadStation.Utils.getErrorString(a)) | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation"); | |
| Ext.define("SYNO.SDS.DownloadStation.SearchTabPanel", { | |
| extend: "SYNO.ux.TabPanel", | |
| createScrollers: function() { | |
| this.callParent(arguments); | |
| this.scrollLeft.insertFirst({ | |
| cls: "x-tab-strip x-tab-strip-top" | |
| }); | |
| this.scrollRight.insertFirst({ | |
| cls: "x-tab-strip x-tab-strip-top" | |
| }) | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.DLM"); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.Search", { | |
| extend: "SYNO.SDS.DownloadStation.RightPanel", | |
| MAXTABCOUNT: 5, | |
| constructor: function(a) { | |
| this.itemsPerPage = 50; | |
| this.callParent(arguments); | |
| this.webapiAddTask = { | |
| api: "SYNO.DownloadStation2.Task", | |
| method: "create", | |
| version: 2 | |
| } | |
| }, | |
| createPanel: function() { | |
| this.tabPanel = new SYNO.SDS.DownloadStation.SearchTabPanel({ | |
| enableTabScroll: true, | |
| items: [], | |
| cls: "syno-dl-searchpanel", | |
| listeners: { | |
| scope: this, | |
| add: this.updateHeaderVisible, | |
| remove: this.updateHeaderVisible | |
| } | |
| }); | |
| return new SYNO.ux.Panel({ | |
| tbar: this.fillToolbarConfig(), | |
| layout: "fit", | |
| items: [this.tabPanel] | |
| }) | |
| }, | |
| onActivate: function() { | |
| this.updateHeaderVisible() | |
| }, | |
| createActionGroup: function() { | |
| var a = []; | |
| a.push(new Ext.Button({ | |
| tooltip: _DT("download", "download_now"), | |
| disabled: true, | |
| iconCls: "syno-dl-a_bt_download", | |
| itemId: "downloadnow", | |
| handler: this.beforeDownloadSelected, | |
| scope: this | |
| }), new Ext.Button({ | |
| tooltip: _DT("download", "download_to"), | |
| disabled: true, | |
| iconCls: "syno-dl-a_bt_download_to", | |
| itemId: "downloadto", | |
| handler: this.downloadSelectedTo, | |
| scope: this | |
| }), "->", new SYNO.ux.ComboBox({ | |
| ctCls: "syno-dl-search-category", | |
| itemId: "search_category", | |
| store: new Ext.data.ArrayStore({ | |
| autoDestroy: true, | |
| idIndex: 0, | |
| fields: ["value", "display"], | |
| data: [["_allcat_", _DT("download", "download_allcategory")]] | |
| }), | |
| tplHtmlEncode: true, | |
| displayField: "display", | |
| valueField: "value", | |
| editable: false, | |
| triggerAction: "all", | |
| value: "_allcat_", | |
| resizable: false, | |
| mode: "local" | |
| }), new SYNO.ux.TextFilter({ | |
| cls: "syno-ux-textfilter-text syno-dl-dlm-filter-icon", | |
| itemId: "filter", | |
| emptyText: _DT("common", "filter_label_text"), | |
| store: null | |
| })); | |
| return this.callParent([a, true]) | |
| }, | |
| beforeDownloadSelected: function() { | |
| if (this.panel.getEl().isMasked()) { | |
| return | |
| } | |
| SYNO.SDS.DownloadStation.DLM.Util.checkLocationDestinationNonEmpty(this, this.downloadSelected, undefined, this) | |
| }, | |
| downloadSelected: function(a) { | |
| var d = this.tabPanel.getActiveTab(); | |
| var b = d.getSelectionModel().getSelections(); | |
| var c = []; | |
| var e = false; | |
| Ext.each(b, function(i) { | |
| var h; | |
| var g = Ext.util.Format.trim(i.get("dlurl")); | |
| if (1 > g.length) { | |
| return true | |
| } | |
| h = SYNO.SDS.DownloadStation.Utils.canonizeURLPrefix(g); | |
| if (h) { | |
| c.push(h) | |
| } else { | |
| e = true | |
| } | |
| }, this); | |
| if (e) { | |
| this.appWin.getMsgBox().alert(this.title, _DT("download", "download_error_bad_urls_found")); | |
| if (0 === c.length) { | |
| return | |
| } | |
| } | |
| if (!Ext.isDefined(a)) { | |
| SYNO.Debug("destination does not exists"); | |
| return | |
| } | |
| var f = { | |
| type: "url", | |
| url: c, | |
| destination: a, | |
| create_list: false | |
| }; | |
| this.mask(_DT("common", "saving")); | |
| SYNO.API.Request({ | |
| webapi: Ext.apply(this.webapiAddTask, { | |
| params: f | |
| }), | |
| callback: function(l, i, k, h) { | |
| this.unmask(); | |
| this.tabPanel.getActiveTab().unmask(); | |
| if (!l) { | |
| var j = SYNO.SDS.DownloadStation.Utils.getErrorString(i.code); | |
| this.appWin.getMsgBox().alert(this.title, j); | |
| return | |
| } | |
| var g = this.tabPanel.getActiveTab(); | |
| g.animateRows.defer(200, g) | |
| }, | |
| scope: this | |
| }) | |
| }, | |
| downloadSelectedTo: function() { | |
| if (this.panel.getEl().isMasked()) { | |
| return | |
| } | |
| var a = function(b) { | |
| var c = this.tabPanel.getActiveTab().getSelectionModel().getSelections(); | |
| var e = []; | |
| for (var d = 0; d < c.length; d++) { | |
| e.push(c[d].get("dlurl")) | |
| } | |
| this.mainPanel.launchTaskDialog(1, null, e, true) | |
| }; | |
| SYNO.SDS.DownloadStation.DLM.Util.checkLocationDestinationNonEmpty(this, a, undefined, this) | |
| }, | |
| createSearchTab: function(a) { | |
| a = Ext.util.Format.trim(a); | |
| for (var c = 0; c < this.tabPanel.items.items.length; c++) { | |
| if (a && a === this.tabPanel.items.get(c).title) { | |
| this.tabPanel.setActiveTab(c); | |
| return | |
| } | |
| } | |
| if (this.tabPanel.items.items.length >= this.MAXTABCOUNT) { | |
| this.appWin.getMsgBox().alert("", String.format(_DT("search", "search_tab_reach_limit"), this.MAXTABCOUNT)); | |
| return | |
| } | |
| var b = { | |
| uicomponents: this.uicomponents, | |
| owner: this, | |
| keyword: a, | |
| cls: !a ? "syno-dl-no-padding-grid" : "" | |
| }; | |
| var d = new SYNO.SDS.DownloadStation.DLM.SearchGridPanel(b); | |
| this.tabPanel.add(d); | |
| this.tabPanel.setActiveTab(d); | |
| this.mon(this.tabPanel.getActiveTab().getSelectionModel(), "selectionchange", this.updateBtns, this) | |
| }, | |
| updateHeaderVisible: function() { | |
| var a = true; | |
| var c = this.tabPanel.items.items.length; | |
| if (0 === c) { | |
| a = false; | |
| this.createSearchTab("") | |
| } else { | |
| if (1 === c) { | |
| a = ("" === this.tabPanel.items.items[0].title) ? false : true | |
| } else { | |
| this.tabPanel.items.each(function(d) { | |
| if ("" === d.title) { | |
| this.tabPanel.remove(d) | |
| } | |
| }, this) | |
| } | |
| } | |
| this.tabPanel.header.setVisibilityMode(Ext.Element.DISPLAY).setVisible(a); | |
| var b = Math.max(0, this.tabPanel.lastSize.height - this.tabPanel.getFrameHeight()); | |
| this.tabPanel.body.setHeight(b); | |
| this.tabPanel.doLayout() | |
| }, | |
| getDisabledPlugins: function() { | |
| var a = this.owner.appInstance.getUserSettings("btsearchplugins") || []; | |
| var c = []; | |
| for (var b = 0; b < a.length; b++) { | |
| if (a[b].enable === false) { | |
| c.push(a[b].name) | |
| } | |
| } | |
| return c.join(",") | |
| }, | |
| updateBtnStatus: function() { | |
| var a = this.tabPanel.getActiveTab().getSelectionModel().hasSelection() && !this.tabPanel.getActiveTab().getEl().isMasked() && !this.panel.getEl().isMasked(); | |
| return { | |
| blAdd: a | |
| } | |
| }, | |
| updateBtns: function() { | |
| this.actionGroup.setEnableBtns(["downloadnow", "downloadto"], this.updateBtnStatus().blAdd) | |
| }, | |
| mask: function() { | |
| this.panel.getEl().mask.apply(this.panel.getEl(), arguments); | |
| this.updateBtns() | |
| }, | |
| unmask: function() { | |
| if (this.panel.getEl().isMasked()) { | |
| this.panel.getEl().unmask() | |
| } | |
| this.updateBtns() | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.DLM"); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.RSSGridPanel", { | |
| extend: "SYNO.ux.GridPanel", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| Ext.apply(this, a || {}); | |
| this.itemsPerPage = 50; | |
| var b = this.fillConfig(a); | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| this.api = "SYNO.DownloadStation2.RSS.Feed"; | |
| this.store = this.createStore(); | |
| var b = { | |
| store: this.store, | |
| colModel: this.createColModel(), | |
| bbar: this.createBottombar(), | |
| view: this.createGridView(), | |
| selModel: this.createSelectionModel(), | |
| loadMask: true, | |
| stripeRows: true, | |
| border: false, | |
| enableColumnMove: true, | |
| stateful: true, | |
| enableHdMenu: false, | |
| stateEvents: ["columnmove", "columnresize", "sortchange"], | |
| height: 500, | |
| layout: "fit", | |
| initState: (function() { | |
| var d = this.appWin.appInstance.getUserSettings("dlmrssgridstates"); | |
| var c = SYNO.SDS.DownloadStation.Utils.checkStateValue(d, this.colModel); | |
| if (c) { | |
| if (this.fireEvent("beforestaterestore", this, c) !== false) { | |
| this.applyState(Ext.apply({}, c)); | |
| this.fireEvent("staterestore", this, c) | |
| } | |
| } | |
| } | |
| ).createDelegate(this), | |
| saveState: (function() { | |
| var c = this.getState(); | |
| this.appWin.appInstance.setUserSettings("dlmrssgridstates", c) | |
| } | |
| ).createDelegate(this), | |
| scope: this, | |
| listeners: { | |
| scope: this, | |
| afterrender: { | |
| scope: this, | |
| fn: this.onAfterRender, | |
| single: true | |
| }, | |
| rowcontextmenu: function(c, g, d) { | |
| d.preventDefault(); | |
| var f = c.getSelectionModel(); | |
| if (!f.isSelected(g)) { | |
| f.selectRow(g) | |
| } | |
| this.gridCtxMenu.showAt(d.getXY()) | |
| } | |
| } | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| onAfterRender: function() { | |
| this.gridCtxMenu = this.createCtxMenu(); | |
| this.addManagedComponent(this.gridCtxMenu) | |
| }, | |
| createCtxMenu: function() { | |
| var h = new SYNO.ux.Menu(); | |
| var f = this.owner.actionGroup.list; | |
| var b = ["edit", "remove", "update"]; | |
| for (var g = 0; g < f.length; g++) { | |
| if (-1 !== b.indexOf(f[g].initialConfig.itemId)) { | |
| var e = f[g].initialConfig; | |
| e.text = e.tooltip; | |
| e.iconCls = ""; | |
| h.addMenuItem(e) | |
| } | |
| } | |
| var d = h.items.get("edit"); | |
| var c = h.items.get("remove"); | |
| var a = h.items.get("update"); | |
| this.owner.setMonDisabled(d, c, a); | |
| return h | |
| }, | |
| createStore: function() { | |
| return new SYNO.API.JsonStore({ | |
| api: this.api, | |
| method: "list", | |
| appWindow: this.appWin, | |
| version: 1, | |
| baseParams: { | |
| limit: this.itemsPerPage | |
| }, | |
| autoLoad: false, | |
| root: "items", | |
| fields: ["id", "title", "url", "last_update", "is_updating", "username"], | |
| paramNames: { | |
| start: "offset", | |
| limit: "limit" | |
| }, | |
| listeners: { | |
| scope: this, | |
| beforeload: this.onBeforeStoreLoad, | |
| load: this.onStoreLoad | |
| } | |
| }) | |
| }, | |
| onBeforeStoreLoad: function(a, b) { | |
| if ("undefined" != typeof (b.params.offset)) { | |
| this.gridStartPosition = b.params.offset | |
| } else { | |
| this.gridStartPosition = 0 | |
| } | |
| this.pollingtask.stopById("RSSGrid") | |
| }, | |
| onStoreLoad: function(c, a, d) { | |
| if (this.store.getTotalCount() <= this.gridStartPosition && this.gridStartPosition > 0) { | |
| var f = Math.ceil((this.store.getTotalCount() - this.itemsPerPage) / this.itemsPerPage); | |
| this.store.load({ | |
| params: { | |
| offset: (f * this.itemsPerPage), | |
| limit: this.itemsPerPage | |
| } | |
| }); | |
| return | |
| } | |
| var b = this.store.data.items; | |
| var e; | |
| for (e = 0; e < b.length; e++) { | |
| if (b[e].json.is_updating) { | |
| break | |
| } | |
| } | |
| if (e === b.length) { | |
| this.pollingtask.stopById("RSSGrid") | |
| } else { | |
| this.pollingtask.startById("RSSGrid", false) | |
| } | |
| }, | |
| createColModel: function() { | |
| var a = new Ext.grid.ColumnModel({ | |
| columns: [{ | |
| header: _T("common", "name"), | |
| id: "title", | |
| width: 135, | |
| dataIndex: "title" | |
| }, { | |
| id: "url", | |
| header: _DT("download", "download_list_url"), | |
| width: 220, | |
| dataIndex: "url" | |
| }, { | |
| id: "last_update", | |
| header: _DT("download", "rss_last_update"), | |
| width: 160, | |
| dataIndex: "last_update", | |
| renderer: function(f, e, b, g, d, c) { | |
| if (b.get("is_updating")) { | |
| return _DT("download", "updating") | |
| } else { | |
| return Ext.util.Format.htmlEncode(SYNO.SDS.DateTimeFormatter(new Date(f * 1000))) | |
| } | |
| } | |
| }, { | |
| id: "username", | |
| header: _DT("download", "download_list_username"), | |
| width: 100, | |
| hidden: !_S("is_admin"), | |
| dataIndex: "username" | |
| }] | |
| }); | |
| return a | |
| }, | |
| createBottombar: function() { | |
| var a = new SYNO.ux.PagingToolbar({ | |
| store: this.store, | |
| displayInfo: true, | |
| pageSize: this.itemsPerPage, | |
| refreshText: _DT("download", "download_btn_refresh") | |
| }); | |
| return a | |
| }, | |
| createGridView: function() { | |
| return new SYNO.ux.FleXcroll.grid.GridView() | |
| }, | |
| createSelectionModel: function() { | |
| var a = new Ext.grid.RowSelectionModel({ | |
| singleSelect: false, | |
| listeners: { | |
| selectionchange: { | |
| scope: this, | |
| fn: this.gridSelectionChange | |
| } | |
| } | |
| }); | |
| a.addEvents({ | |
| rowSelectionChanged: true | |
| }); | |
| return a | |
| }, | |
| gridSelectionChange: function(a) { | |
| if (!this.gridSelectionChangeTask) { | |
| this.gridSelectionChangeTask = new Ext.util.DelayedTask(function(b) { | |
| a.fireEvent("rowSelectionChanged", a) | |
| } | |
| ,a) | |
| } | |
| this.gridSelectionChangeTask.delay(300) | |
| }, | |
| onBeforeGridPollingStart: function(a) { | |
| a.reqConfig.params = this.getLoadParams() | |
| }, | |
| getLoadParams: function() { | |
| var a = { | |
| offset: this.gridStartPosition || 0, | |
| limit: this.itemsPerPage | |
| }; | |
| return a | |
| }, | |
| onUpdateRecordsTask: function(l, i, e, a) { | |
| var c = false; | |
| var d = false; | |
| var f = false; | |
| if (!l || !this.getStore()) { | |
| return | |
| } | |
| if (this.store.getTotalCount() != i.total || 0 >= i.total) { | |
| c = true | |
| } else { | |
| for (var g = 0; g < i.items.length; g++) { | |
| var k = this.store.getById(i.items[g].id); | |
| var h = this.store.getAt(g); | |
| if (!k || !h || i.items[g].id != h.get("id")) { | |
| c = true; | |
| break | |
| } | |
| d |= ((k.data.is_updating !== i.items[g].is_updating) && (this.getSelectionModel().isSelected(k))); | |
| f |= i.items[g].is_updating; | |
| k.set("title", i.items[g].title); | |
| k.set("url", i.items[g].url); | |
| k.set("last_update", i.items[g].last_update); | |
| k.set("is_updating", i.items[g].is_updating); | |
| k.set("username", i.items[g].username); | |
| k.commit() | |
| } | |
| } | |
| if (c) { | |
| this.store.reload(); | |
| return | |
| } | |
| if (d) { | |
| var b = this.getSelectionModel(); | |
| b.fireEvent("rowSelectionChanged", b) | |
| } | |
| if (!f) { | |
| this.pollingtask.stopById("RSSGrid") | |
| } | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.DLM"); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.RSSItemList", { | |
| extend: "SYNO.ux.GridPanel", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| Ext.apply(this, a || {}); | |
| this.itemsPerPage = 50; | |
| var b = this.fillConfig(a); | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| this.store = this.createStore(); | |
| var b = { | |
| store: this.store, | |
| colModel: this.createColModel(), | |
| tbar: this.createTopbar(), | |
| bbar: this.createBottombar(), | |
| view: this.createGridView(), | |
| selModel: this.createSelectionModel(), | |
| loadMask: true, | |
| stripeRows: true, | |
| border: false, | |
| enableColumnMove: true, | |
| enableHdMenu: false, | |
| autoExpandColumn: "title", | |
| listeners: { | |
| scope: this, | |
| afterrender: { | |
| scope: this, | |
| fn: this.onAfterRender, | |
| single: true | |
| }, | |
| rowcontextmenu: function(c, g, d) { | |
| d.preventDefault(); | |
| var f = c.getSelectionModel(); | |
| if (!f.isSelected(g)) { | |
| f.selectRow(g) | |
| } | |
| this.gridCtxMenu.showAt(d.getXY()) | |
| }, | |
| rowdblclick: { | |
| scope: this, | |
| fn: this.beforeActionDownload | |
| } | |
| } | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| onAfterRender: function() { | |
| this.gridCtxMenu = this.createCtxMenu(); | |
| this.addManagedComponent(this.gridCtxMenu) | |
| }, | |
| createCtxMenu: function() { | |
| var f = new SYNO.ux.Menu(); | |
| var d = this.topToolbar.initialConfig.items; | |
| var a = ["download", "downloadto"]; | |
| for (var e = 0; e < d.length; e++) { | |
| if (!d[e].initialConfig) { | |
| continue | |
| } | |
| if (-1 !== a.indexOf(d[e].initialConfig.itemId)) { | |
| var c = d[e].initialConfig; | |
| c.disabled = false; | |
| f.addMenuItem(c) | |
| } | |
| } | |
| f.addMenuItem({ | |
| itemId: "external", | |
| text: _DT("download", "open_extenallink"), | |
| scope: this, | |
| handler: this.actionExternalHandler | |
| }); | |
| var b = f.get("external"); | |
| b.mon(this.getSelectionModel(), "selectionchange", function(g) { | |
| if (1 === g.getCount() && g.getSelected().get("link")) { | |
| b.enable() | |
| } else { | |
| b.disable() | |
| } | |
| }, b); | |
| return f | |
| }, | |
| actionExternalHandler: function() { | |
| var a = this.getSelectionModel().getSelections(); | |
| if (0 === a.length || !a[0].get("link")) { | |
| return | |
| } | |
| window.open(a[0].get("link"), "_blank") | |
| }, | |
| createStore: function() { | |
| return new SYNO.API.JsonStore({ | |
| api: "SYNO.DownloadStation2.RSS.Item", | |
| method: "list", | |
| appWindow: this.appWin, | |
| version: 1, | |
| baseParams: { | |
| limit: this.itemsPerPage | |
| }, | |
| autoLoad: false, | |
| root: "items", | |
| totalProperty: "total", | |
| fields: ["id", "feed_id", "title", "url", "link", "date", "size", "is_new"], | |
| paramNames: { | |
| start: "offset", | |
| limit: "limit" | |
| }, | |
| listeners: { | |
| scope: this, | |
| beforeload: this.onBeforeStoreLoad, | |
| load: this.onStoreLoad | |
| } | |
| }) | |
| }, | |
| onBeforeStoreLoad: function(a, b) { | |
| var c = this.owner.upperPanel.getSelectionModel().getSelections(); | |
| if (1 !== c.length) { | |
| return false | |
| } | |
| b.params.feed_id = c[0].id | |
| }, | |
| onStoreLoad: function(b, a, c) { | |
| if (0 < b.getTotalCount()) { | |
| this.btnClear.enable() | |
| } else { | |
| this.btnClear.disable() | |
| } | |
| }, | |
| createColModel: function() { | |
| var a = new Ext.grid.ColumnModel({ | |
| columns: [{ | |
| id: "title", | |
| header: _T("common", "name"), | |
| dataIndex: "title" | |
| }, { | |
| id: "size", | |
| header: _DT("download", "download_list_filesize"), | |
| dataIndex: "size", | |
| width: 100, | |
| renderer: function(c) { | |
| var b = parseInt(c, 10); | |
| return SYNO.SDS.DownloadStation.DLM.Util.sizeRenderer(b) | |
| } | |
| }, { | |
| id: "date", | |
| header: _T("time", "time_time"), | |
| dataIndex: "date", | |
| width: 180, | |
| renderer: function(b) { | |
| return Ext.util.Format.htmlEncode(SYNO.SDS.DateTimeFormatter(new Date(b * 1000))) | |
| } | |
| }] | |
| }); | |
| return a | |
| }, | |
| createTopbar: function() { | |
| this.btnDownload = new Ext.Action({ | |
| itemId: "download", | |
| text: _DT("download", "download_subject"), | |
| disabled: true, | |
| scope: this, | |
| handler: this.beforeActionDownload | |
| }); | |
| this.btnDownloadTo = new Ext.Action({ | |
| itemId: "downloadto", | |
| text: _DT("download", "download_to"), | |
| disabled: true, | |
| scope: this, | |
| handler: this.beforeActionDownloadTo | |
| }); | |
| this.btnClear = new Ext.Action({ | |
| itemId: "clear", | |
| text: _DT("common", "clean"), | |
| disabled: true, | |
| scope: this, | |
| handler: this.actionClear | |
| }); | |
| this.filter = new SYNO.ux.TextFilter({ | |
| itemId: "search", | |
| width: 170, | |
| emptyText: _DT("common", "filter_label_text"), | |
| cls: "syno-ux-textfilter-text syno-dl-dlm-filter-icon", | |
| queryAction: "rss_item_list", | |
| queryParam: "keyword", | |
| enumAction: "rss_item_list", | |
| pageSize: this.itemsPerPage, | |
| store: this.store | |
| }); | |
| var a = { | |
| cls: "syno-dl-toolbar", | |
| items: [this.btnDownload, this.btnDownloadTo, this.btnClear, "->", this.filter] | |
| }; | |
| return new SYNO.ux.Toolbar(a) | |
| }, | |
| beforeActionDownload: function() { | |
| var a = this.getSelectionUrls(); | |
| if (!a || 0 === a.length) { | |
| return | |
| } | |
| SYNO.SDS.DownloadStation.DLM.Util.checkLocationDestinationNonEmpty(this, this.actionDownload, undefined, this) | |
| }, | |
| actionDownload: function(a) { | |
| var b = { | |
| type: "url", | |
| url: this.getSelectionUrls(), | |
| destination: a, | |
| create_list: false | |
| }; | |
| this.owner.setStatusBusy(_DT("common"), "saving"); | |
| this.appWin.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.Task", | |
| method: "create", | |
| params: b, | |
| version: 2, | |
| scope: this, | |
| callback: function(f, d, e, c) { | |
| this.owner.clearStatusBusy(); | |
| if (!f) { | |
| this.appWin.getMsgBox().alert(this.title, SYNO.SDS.DownloadStation.Utils.getErrorString(d.code)) | |
| } | |
| } | |
| }) | |
| }, | |
| getSelectionUrls: function() { | |
| var a = this.getSelectionModel().getSelections(); | |
| var b = []; | |
| Ext.each(a, function(e, c, d) { | |
| b.push(e.get("url")) | |
| }, this); | |
| return b | |
| }, | |
| beforeActionDownloadTo: function() { | |
| if (0 === this.getSelectionModel().getSelections().length) { | |
| return | |
| } | |
| SYNO.SDS.DownloadStation.DLM.Util.checkLocationDestinationNonEmpty(this, this.actionDownloadTo, undefined, this) | |
| }, | |
| actionDownloadTo: function(a) { | |
| var d = this.getSelectionModel().getSelections(); | |
| var c = []; | |
| for (var b = 0; b < d.length; b++) { | |
| c.push(d[b].get("url")) | |
| } | |
| this.mainPanel.launchTaskDialog(1, null, c, true) | |
| }, | |
| actionClear: function() { | |
| var a = this.owner.upperPanel.getSelectionModel().getSelections(); | |
| if (!a || 1 !== a.length) { | |
| return | |
| } | |
| this.filter.reset(); | |
| this.owner.setStatusBusy(_DT("common"), "saving"); | |
| this.appWin.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.RSS.Item", | |
| method: "clear", | |
| params: { | |
| feed_id: a[0].id | |
| }, | |
| version: 1, | |
| scope: this, | |
| callback: function(e, c, d, b) { | |
| this.owner.clearStatusBusy(); | |
| if (!e) { | |
| this.appWin.getMsgBox().alert(this.title, SYNO.SDS.DownloadStation.Utils.getErrorString(c.code)) | |
| } | |
| this.store.load() | |
| } | |
| }) | |
| }, | |
| createBottombar: function() { | |
| var a = new SYNO.ux.PagingToolbar({ | |
| store: this.store, | |
| displayInfo: true, | |
| pageSize: this.itemsPerPage, | |
| refreshText: _DT("download", "download_btn_refresh") | |
| }); | |
| return a | |
| }, | |
| createGridView: function() { | |
| return new SYNO.ux.FleXcroll.grid.GridView() | |
| }, | |
| createSelectionModel: function() { | |
| var a = new Ext.grid.RowSelectionModel({ | |
| singleSelect: false, | |
| listeners: { | |
| selectionchange: { | |
| scope: this, | |
| fn: this.gridSelectionChange | |
| } | |
| } | |
| }); | |
| return a | |
| }, | |
| gridSelectionChange: function() { | |
| var a = this.getSelectionModel().getCount(); | |
| if (0 === a) { | |
| this.btnDownload.disable(); | |
| this.btnDownloadTo.disable() | |
| } else { | |
| this.btnDownload.enable(); | |
| this.btnDownloadTo.enable() | |
| } | |
| }, | |
| resetGridPanel: function() { | |
| this.btnDownload.disable(); | |
| this.btnDownloadTo.disable(); | |
| this.btnClear.disable(); | |
| this.store.removeAll() | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.DLM"); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.RSSFilterList", { | |
| extend: "SYNO.ux.GridPanel", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| Ext.apply(this, a || {}); | |
| this.itemsPerPage = 50; | |
| var b = this.fillConfig(a); | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| this.store = this.createStore(); | |
| var b = { | |
| store: this.store, | |
| colModel: this.createColModel(), | |
| tbar: this.createTopbar(), | |
| bbar: this.createBottombar(), | |
| view: this.createGridView(), | |
| selModel: this.createSelectionModel(), | |
| loadMask: true, | |
| stripeRows: true, | |
| border: false, | |
| enableColumnMove: true, | |
| autoExpandColumn: "name", | |
| enableHdMenu: false, | |
| listeners: { | |
| scope: this, | |
| afterrender: { | |
| scope: this, | |
| fn: this.onAfterRender, | |
| single: true | |
| }, | |
| rowcontextmenu: function(c, g, d) { | |
| d.preventDefault(); | |
| var f = c.getSelectionModel(); | |
| if (!f.isSelected(g)) { | |
| f.selectRow(g) | |
| } | |
| this.gridCtxMenu.showAt(d.getXY()) | |
| }, | |
| rowdblclick: { | |
| scope: this, | |
| fn: this.actionEdit | |
| } | |
| } | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| onAfterRender: function() { | |
| this.gridCtxMenu = this.createCtxMenu(); | |
| this.addManagedComponent(this.gridCtxMenu) | |
| }, | |
| createCtxMenu: function() { | |
| var e = new SYNO.ux.Menu(); | |
| var c = this.topToolbar.initialConfig.items; | |
| var a = ["edit", "delete"]; | |
| for (var d = 0; d < c.length; d++) { | |
| if (-1 !== a.indexOf(c[d].initialConfig.itemId)) { | |
| var b = c[d].initialConfig; | |
| b.disabled = false; | |
| e.addMenuItem(b) | |
| } | |
| } | |
| return e | |
| }, | |
| createStore: function() { | |
| var a = new SYNO.API.JsonStore({ | |
| api: "SYNO.DownloadStation2.RSS.Filter", | |
| method: "list", | |
| appWindow: this.appWin, | |
| version: 1, | |
| baseParams: { | |
| limit: this.itemsPerPage, | |
| sort_by: "name" | |
| }, | |
| autoLoad: false, | |
| root: "items", | |
| totalProperty: "total", | |
| fields: ["id", "feed_id", "name", "match", "not_match", "destination", "enable", "is_regex"], | |
| paramNames: { | |
| start: "offset", | |
| limit: "limit" | |
| }, | |
| listeners: { | |
| scope: this, | |
| beforeload: this.onBeforeStoreLoad, | |
| load: this.onStoreLoad | |
| } | |
| }); | |
| return a | |
| }, | |
| onBeforeStoreLoad: function(a, b) { | |
| var c = this.owner.upperPanel.getSelectionModel().getSelections(); | |
| if (1 !== c.length) { | |
| return false | |
| } | |
| b.params.feed_id = c[0].id; | |
| if ("undefined" != typeof (b.params.offset)) { | |
| this.gridStartPosition = b.params.offset | |
| } else { | |
| this.gridStartPosition = 0 | |
| } | |
| }, | |
| onStoreLoad: function(b, a, c) { | |
| if (this.store.getTotalCount() <= this.gridStartPosition && this.gridStartPosition > 0) { | |
| var d = Math.ceil((this.store.getTotalCount() - this.itemsPerPage) / this.itemsPerPage); | |
| this.store.load({ | |
| params: { | |
| offset: (d * this.itemsPerPage), | |
| limit: this.itemsPerPage | |
| } | |
| }); | |
| return | |
| } | |
| this.btnAdd.enable() | |
| }, | |
| createColModel: function() { | |
| var a = new Ext.grid.ColumnModel({ | |
| columns: [{ | |
| id: "name", | |
| header: _T("common", "name"), | |
| dataIndex: "name" | |
| }] | |
| }); | |
| return a | |
| }, | |
| createTopbar: function() { | |
| this.btnAdd = new Ext.Action({ | |
| itemId: "add", | |
| text: _DT("common", "addto"), | |
| disabled: true, | |
| scope: this, | |
| handler: this.actionAdd | |
| }); | |
| this.btnEdit = new Ext.Action({ | |
| itemId: "edit", | |
| text: _DT("common", "alt_edit"), | |
| disabled: true, | |
| scope: this, | |
| handler: this.actionEdit | |
| }); | |
| this.btnDelete = new Ext.Action({ | |
| itemId: "delete", | |
| text: _DT("common", "delete"), | |
| disabled: true, | |
| scope: this, | |
| handler: this.actionDelete | |
| }); | |
| var a = { | |
| items: [this.btnAdd, this.btnEdit, this.btnDelete] | |
| }; | |
| return new SYNO.ux.Toolbar(a) | |
| }, | |
| actionAdd: function() { | |
| var c = this.owner.upperPanel.getSelectionModel().getSelections(); | |
| if (1 !== c.length || !c[0] || !c[0].id) { | |
| return | |
| } | |
| var a = { | |
| uicomponents: this.uicomponents, | |
| store: this.store, | |
| feedId: c[0].id | |
| }; | |
| var b = new SYNO.SDS.DownloadStation.DLM.RSSAddFilterDialog(a); | |
| b.open() | |
| }, | |
| actionEdit: function() { | |
| var d = this.owner.upperPanel.getSelectionModel().getSelections(); | |
| if (1 !== d.length || !d[0] || !d[0].id) { | |
| return | |
| } | |
| var a = { | |
| uicomponents: this.uicomponents, | |
| store: this.store | |
| }; | |
| var b = this.getSelectionModel().getSelections(); | |
| if (1 !== b.length || !b[0]) { | |
| return | |
| } else { | |
| a.record = b[0] | |
| } | |
| var c = new SYNO.SDS.DownloadStation.DLM.RSSAddFilterDialog(a); | |
| c.open() | |
| }, | |
| actionDelete: function() { | |
| var b = this.getSelectionModel().getSelections(); | |
| if (!b || 0 >= b.length) { | |
| return | |
| } | |
| var a = []; | |
| Ext.each(b, function(e, c, d) { | |
| a.push(e.get("id")) | |
| }, this); | |
| this.owner.getMsgBox().confirm(_DT("download", "rss_feeds"), _DT("common", "remove_cfrmrmv"), function(c, d) { | |
| if (c !== "yes") { | |
| return | |
| } | |
| this.owner.setStatusBusy(); | |
| this.appWin.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.RSS.Filter", | |
| method: "delete", | |
| params: { | |
| id: a | |
| }, | |
| version: 1, | |
| scope: this, | |
| callback: function(h, f, g, e) { | |
| this.owner.clearStatusBusy(); | |
| if (!h) { | |
| this.appWin.getMsgBox().alert(this.title, SYNO.SDS.DownloadStation.Utils.getErrorString(f.code)); | |
| return | |
| } | |
| this.getStore().reload() | |
| } | |
| }) | |
| }, this) | |
| }, | |
| createBottombar: function() { | |
| var a = new SYNO.ux.PagingToolbar({ | |
| store: this.store, | |
| displayInfo: true, | |
| pageSize: this.itemsPerPage, | |
| refreshText: _DT("download", "download_btn_refresh") | |
| }); | |
| return a | |
| }, | |
| createGridView: function() { | |
| return new SYNO.ux.FleXcroll.grid.GridView() | |
| }, | |
| createSelectionModel: function() { | |
| var a = new Ext.grid.RowSelectionModel({ | |
| singleSelect: false, | |
| listeners: { | |
| selectionchange: { | |
| scope: this, | |
| fn: this.gridSelectionChange | |
| } | |
| } | |
| }); | |
| return a | |
| }, | |
| gridSelectionChange: function() { | |
| var a = this.getSelectionModel().getCount(); | |
| if (0 === a) { | |
| this.btnEdit.disable(); | |
| this.btnDelete.disable() | |
| } else { | |
| if (1 === a) { | |
| this.btnEdit.enable(); | |
| this.btnDelete.enable() | |
| } else { | |
| this.btnEdit.disable(); | |
| this.btnDelete.enable() | |
| } | |
| } | |
| }, | |
| resetGridPanel: function() { | |
| this.btnAdd.disable(); | |
| this.btnEdit.disable(); | |
| this.btnDelete.disable(); | |
| this.store.removeAll() | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.DLM"); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.RSSAddFilterDialog", { | |
| extend: "SYNO.SDS.ModalWindow", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| Ext.apply(this, a || {}); | |
| var b = this.fillConfig(a); | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| this.formPanel = this.createForm(a); | |
| var b = { | |
| title: (this.record) ? _DT("common", "alt_edit") : _DT("common", "addto"), | |
| owner: this.appWin, | |
| cls: "syno-dl-win", | |
| resizable: false, | |
| width: 540, | |
| height: 315, | |
| layout: "fit", | |
| items: this.formPanel, | |
| buttons: SYNO.SDS.DownloadStation.Utils.composeButtonCfg({ | |
| xtype: "syno_button", | |
| btnStyle: "blue", | |
| text: _DT("common", "alt_apply"), | |
| scope: this, | |
| handler: this.applyHandler | |
| }, { | |
| xtype: "syno_button", | |
| text: _DT("common", "close"), | |
| scope: this, | |
| handler: this.closeHandler | |
| }) | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| createForm: function(a) { | |
| var b = { | |
| trackResetOnLoad: false, | |
| bodyStyle: "padding: 0", | |
| keys: [{ | |
| key: [10, 13], | |
| fn: this.applyHandler, | |
| scope: this | |
| }, { | |
| key: 27, | |
| fn: this.closeHandler, | |
| scope: this | |
| }], | |
| items: [{ | |
| xtype: "syno_textfield", | |
| itemId: "name", | |
| name: "name", | |
| allowBlank: false, | |
| hideLabel: false, | |
| fieldLabel: _DT("server", "title_server_name") | |
| }, { | |
| xtype: "syno_textfield", | |
| itemId: "match", | |
| name: "match", | |
| hideLabel: false, | |
| fieldLabel: _DT("download", "rss_filter_match") | |
| }, { | |
| xtype: "syno_textfield", | |
| itemId: "not_match", | |
| name: "not_match", | |
| hideLabel: false, | |
| fieldLabel: _DT("download", "rss_filter_not_match") | |
| }, { | |
| xtype: "syno_compositefield", | |
| hideLabel: false, | |
| fieldLabel: _DT("download", "download_list_dest_folder"), | |
| items: [{ | |
| xtype: "syno_textfield", | |
| name: "destination", | |
| readOnly: true, | |
| width: 200, | |
| allowBlank: false | |
| }, { | |
| xtype: "syno_button", | |
| text: _T("common", "choose"), | |
| scope: this, | |
| handler: function() { | |
| this.utils.chooseDestHandler({ | |
| owner: this, | |
| destinationField: this.formPanel.form.findField("destination") | |
| }) | |
| } | |
| }] | |
| }, { | |
| xtype: "syno_checkbox", | |
| itemId: "is_regex", | |
| name: "is_regex", | |
| boxLabel: _DT("download", "rss_parse_regex") | |
| }, { | |
| xtype: "syno_button", | |
| text: _DT("download", "test_filter"), | |
| scope: this, | |
| handler: this.onLaunchTestingTool | |
| }] | |
| }; | |
| return new SYNO.ux.FormPanel(b) | |
| }, | |
| applyHandler: function() { | |
| if (!this.formPanel.form.isValid()) { | |
| this.getMsgBox().alert(this.title, _T("common", "forminvalid")); | |
| return | |
| } | |
| if (!this.formPanel.form.isDirty()) { | |
| this.close(); | |
| return | |
| } | |
| var b = {}; | |
| var a; | |
| b.feed_id = this.feedId; | |
| if (this.record) { | |
| a = "set"; | |
| b.id = this.record.get("id") | |
| } else { | |
| a = "add"; | |
| if (!Ext.isDefined(this.feedId)) { | |
| return | |
| } | |
| b.feed_id = this.feedId | |
| } | |
| Ext.apply(b, this.formPanel.form.getValues()); | |
| b.is_regex = this.formPanel.form.findField("is_regex").getValue(); | |
| this.setStatusBusy({ | |
| text: _T("common", "saving") | |
| }); | |
| this.appWin.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.RSS.Filter", | |
| method: a, | |
| params: b, | |
| version: 1, | |
| scope: this, | |
| callback: function(f, d, e, c) { | |
| this.clearStatusBusy(); | |
| if (!f) { | |
| this.appWin.getMsgBox().alert(this.title, SYNO.SDS.DownloadStation.Utils.getErrorString(d.code)); | |
| return | |
| } | |
| this.store.reload(); | |
| this.close() | |
| } | |
| }) | |
| }, | |
| closeHandler: function() { | |
| this.close() | |
| }, | |
| onLaunchTestingTool: function() { | |
| var a = new SYNO.SDS.DownloadStation.DLM.RSSAddFilterTestingTool({ | |
| owner: this, | |
| uicomponents: this.uicomponents | |
| }); | |
| a.open() | |
| }, | |
| onShow: function() { | |
| this.formPanel.form.trackResetOnLoad = true; | |
| if (this.record) { | |
| this.formPanel.form.setValues(this.record.data) | |
| } else { | |
| var a = function(b) { | |
| this.formPanel.form.findField("destination").setValue(b) | |
| }; | |
| SYNO.SDS.DownloadStation.DLM.Util.checkLocationDestinationNonEmpty(this, a, this.closeHandler, this) | |
| } | |
| this.formPanel.form.trackResetOnLoad = false | |
| } | |
| }); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.RSSAddFilterTestingTool", { | |
| extend: "SYNO.SDS.ModalWindow", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| Ext.apply(this, a || {}); | |
| var b = this.fillConfig(a); | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| this.formPanel = this.createForm(a); | |
| var b = { | |
| title: _DT("download", "test_filter"), | |
| owner: a.owner, | |
| cls: "syno-dl-win", | |
| resizable: false, | |
| width: 450, | |
| height: 290, | |
| border: false, | |
| layout: "fit", | |
| items: this.formPanel, | |
| buttons: SYNO.SDS.DownloadStation.Utils.composeButtonCfg({ | |
| xtype: "syno_button", | |
| btnStyle: "blue", | |
| text: _T("common", "save"), | |
| scope: this, | |
| handler: this.saveHandler | |
| }, { | |
| xtype: "syno_button", | |
| text: _DT("common", "cancel"), | |
| scope: this, | |
| handler: this.closeHandler | |
| }) | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| createForm: function() { | |
| var a = { | |
| padding: 0, | |
| trackResetOnLoad: true, | |
| keys: [{ | |
| key: [10, 13], | |
| fn: this.saveHandler, | |
| scope: this | |
| }, { | |
| key: 27, | |
| fn: this.closeHandler, | |
| scope: this | |
| }], | |
| items: [{ | |
| xtype: "syno_textfield", | |
| itemId: "test_string", | |
| name: "test_string", | |
| hideLabel: false, | |
| fieldLabel: _DT("download", "rss_filter_test_title"), | |
| emptyText: _DT("download", "rss_filter_test_title"), | |
| allowBlank: false | |
| }, { | |
| xtype: "syno_textfield", | |
| itemId: "match", | |
| name: "match", | |
| hideLabel: false, | |
| fieldLabel: _DT("download", "rss_filter_match") | |
| }, { | |
| xtype: "syno_textfield", | |
| itemId: "not_match", | |
| name: "not_match", | |
| hideLabel: false, | |
| fieldLabel: _DT("download", "rss_filter_not_match") | |
| }, { | |
| xtype: "syno_checkbox", | |
| itemId: "is_regex", | |
| name: "is_regex", | |
| boxLabel: _DT("download", "rss_parse_regex") | |
| }, { | |
| xtype: "syno_button", | |
| text: _DT("download", "test_filter"), | |
| scope: this, | |
| handler: this.onTest | |
| }] | |
| }; | |
| return new SYNO.ux.FormPanel(a) | |
| }, | |
| onTest: function() { | |
| if (!this.formPanel.form.isValid()) { | |
| this.setStatusError({ | |
| text: _DT("error", "error_bad_field"), | |
| clear: true | |
| }); | |
| return | |
| } | |
| var a = {}; | |
| Ext.apply(a, this.formPanel.form.getValues()); | |
| a.is_regex = this.formPanel.form.findField("is_regex").getValue(); | |
| this.setStatusBusy({ | |
| text: _T("common", "loading") | |
| }); | |
| this.appWin.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.RSS.Filter", | |
| method: "test", | |
| params: a, | |
| version: 1, | |
| scope: this, | |
| callback: this.onTestDone | |
| }) | |
| }, | |
| onTestDone: function(d, b, c, a) { | |
| this.clearStatusBusy(); | |
| if (!d) { | |
| this.appWin.getMsgBox().alert(this.title, SYNO.SDS.DownloadStation.Utils.getErrorString(b.code)); | |
| return | |
| } | |
| if (b.matched) { | |
| this.setStatusOK({ | |
| text: _DT("download", "rss_filter_matched"), | |
| clear: true | |
| }) | |
| } else { | |
| this.setStatusError({ | |
| text: _DT("download", "rss_fileter_not_match"), | |
| clear: true | |
| }) | |
| } | |
| }, | |
| onShow: function() { | |
| this.formPanel.form.setValues(this.owner.formPanel.form.getValues()) | |
| }, | |
| saveHandler: function() { | |
| this.owner.formPanel.form.setValues(this.formPanel.form.getValues()); | |
| this.close() | |
| }, | |
| closeHandler: function() { | |
| this.close() | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.DLM"); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.RSSInfoTabPanel", { | |
| extend: "SYNO.ux.TabPanel", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| this.owner = a.owner; | |
| var b = this.fillConfig(a); | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| this.itemList = new SYNO.SDS.DownloadStation.DLM.RSSItemList({ | |
| owner: this.owner, | |
| uicomponents: a.uicomponents, | |
| title: _DT("download", "rss_feeds") | |
| }); | |
| this.filterList = new SYNO.SDS.DownloadStation.DLM.RSSFilterList({ | |
| owner: this.owner, | |
| uicomponents: a.uicomponents, | |
| title: _DT("download", "rss_auto_download") | |
| }); | |
| var b = { | |
| border: false, | |
| cls: "syno-dl-infotab", | |
| activeTab: 0, | |
| deferredRender: false, | |
| collapsed: false, | |
| items: [this.itemList, this.filterList], | |
| listeners: { | |
| scope: this, | |
| afterrender: { | |
| fn: this.onAfterRender, | |
| scope: this, | |
| single: true | |
| } | |
| } | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| onAfterRender: function() { | |
| var a = this.owner.upperPanel.getSelectionModel(); | |
| this.mon(a, "rowSelectionChanged", function(b) { | |
| if (1 !== b.getCount()) { | |
| if (this.el.isMasked()) { | |
| this.el.unmask() | |
| } | |
| this.resetInfoTabPanel(); | |
| return | |
| } | |
| this.load(b.getSelections()) | |
| }, this) | |
| }, | |
| load: function(a) { | |
| this.resetInfoTabPanel(); | |
| this.itemList.store.reload(); | |
| this.filterList.store.reload() | |
| }, | |
| resetInfoTabPanel: function() { | |
| this.itemList.resetGridPanel(); | |
| this.filterList.resetGridPanel() | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.DLM"); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.RSSAddDialog", { | |
| extend: "SYNO.SDS.ModalWindow", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| var b = this.fillConfig(a); | |
| this.store = a.store; | |
| this.callParent([b]); | |
| var c = ["desttext"]; | |
| if (!_S("demo_mode")) { | |
| c.push(this.dstChooseBtnId) | |
| } | |
| new SYNO.ux.Utils.EnableCheckGroup(this.formPanel.getForm(),"dl_all",c) | |
| }, | |
| fillConfig: function(a) { | |
| this.formPanel = this.createForm(a); | |
| var b = { | |
| owner: this.appWin, | |
| cls: "syno-dl-win", | |
| resizable: false, | |
| title: _DT("common", "addto"), | |
| width: 530, | |
| height: 264, | |
| border: false, | |
| layout: "fit", | |
| items: this.formPanel, | |
| buttons: SYNO.SDS.DownloadStation.Utils.composeButtonCfg({ | |
| xtype: "syno_button", | |
| btnStyle: "blue", | |
| text: _DT("common", "addto"), | |
| disabled: _S("demo_mode"), | |
| scope: this, | |
| handler: this.addRss | |
| }, { | |
| xtype: "syno_button", | |
| text: _DT("common", "close"), | |
| scope: this, | |
| handler: this.close | |
| }), | |
| keys: [{ | |
| key: 27, | |
| scope: this, | |
| handler: this.close | |
| }] | |
| }; | |
| Ext.apply(b, a); | |
| return b | |
| }, | |
| onShow: function() { | |
| this.formPanel.getForm().findField("url").focus(false, 500); | |
| var a = function(b) { | |
| this.formPanel.getForm().findField("desttext").setValue(b) | |
| }; | |
| SYNO.SDS.DownloadStation.DLM.Util.checkLocationDestinationNonEmpty(this, a, this.close, this) | |
| }, | |
| createForm: function(a) { | |
| var b = { | |
| trackResetOnLoad: true, | |
| bodyStyle: "padding: 0", | |
| frame: false, | |
| border: false, | |
| method: "POST", | |
| items: [{ | |
| xtype: "syno_displayfield", | |
| value: _DT("download", "download_lbl_input_rss_url") + _T("common", "colon") | |
| }, { | |
| xtype: "syno_textfield", | |
| name: "url", | |
| itemId: "url", | |
| hideLabel: true, | |
| width: 450 | |
| }, { | |
| xtype: "syno_checkbox", | |
| name: "dl_all", | |
| itemId: "dl_all", | |
| boxLabel: _DT("download", "rss_dl_all") | |
| }, { | |
| xtype: "syno_compositefield", | |
| indent: 1, | |
| hideLabel: false, | |
| itemId: "destselectfield", | |
| fieldLabel: _DT("download", "download_list_dest_folder"), | |
| autoFlexcroll: false, | |
| items: [{ | |
| xtype: "syno_textfield", | |
| name: "desttext", | |
| readOnly: true, | |
| width: 205 | |
| }, { | |
| xtype: "syno_button", | |
| id: this.dstChooseBtnId = Ext.id(), | |
| text: _T("common", "choose"), | |
| disabled: _S("demo_mode"), | |
| scope: this, | |
| handler: function() { | |
| this.utils.chooseDestHandler({ | |
| owner: this, | |
| destinationField: this.formPanel.form.findField("desttext") | |
| }) | |
| } | |
| }] | |
| }] | |
| }; | |
| b = Ext.apply(b, a); | |
| return new SYNO.ux.FormPanel(b) | |
| }, | |
| addRss: function() { | |
| var c = {}; | |
| var b = this.formPanel.getForm(); | |
| var a = b.findField("url").getValue(); | |
| a = a.trim(); | |
| b.findField("url").setValue(a); | |
| if (b.findField("dl_all").getValue()) { | |
| c.enable_auto_download = true; | |
| c.destination = b.findField("desttext").getValue(); | |
| if ("" === c.destination) { | |
| this.getMsgBox().alert(this.title, _T("common", "forminvalid")); | |
| return | |
| } | |
| } | |
| if (!b.isValid()) { | |
| this.getMsgBox().alert(this.title, _T("common", "forminvalid")); | |
| return | |
| } | |
| this.setStatusBusy({ | |
| text: _DT("common", "saving") | |
| }); | |
| c.url = b.findField("url").getValue(); | |
| this.appWin.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.RSS.Feed", | |
| method: "add", | |
| params: c, | |
| version: 1, | |
| scope: this, | |
| callback: this.addRssDone | |
| }) | |
| }, | |
| addRssDone: function(d, b, c, a) { | |
| this.clearStatusBusy(); | |
| if (!d) { | |
| this.appWin.getMsgBox().alert(this.title, SYNO.SDS.DownloadStation.Utils.getErrorString(b.code)); | |
| return | |
| } | |
| this.store.reload(); | |
| this.close() | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.DLM"); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.RSSEditDialog", { | |
| extend: "SYNO.SDS.ModalWindow", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| Ext.apply(this, a || {}); | |
| var b = this.fillConfig(a); | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| this.formPanel = this.createForm(a); | |
| var b = { | |
| title: _T("common", "alt_edit"), | |
| owner: this.appWin, | |
| cls: "syno-dl-win", | |
| dsmStyle: "v5", | |
| resizable: false, | |
| width: 500, | |
| height: 264, | |
| border: false, | |
| layout: "fit", | |
| buttons: SYNO.SDS.DownloadStation.Utils.composeButtonCfg({ | |
| xtype: "syno_button", | |
| btnStyle: "blue", | |
| text: _DT("common", "alt_apply"), | |
| scope: this, | |
| handler: this.applyHandler | |
| }, { | |
| xtype: "syno_button", | |
| text: _DT("common", "close"), | |
| scope: this, | |
| handler: this.close | |
| }), | |
| items: this.formPanel | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| onShow: function() { | |
| this.formPanel.getForm().findField("title").focus(true, 500) | |
| }, | |
| createForm: function(a) { | |
| var b = { | |
| trackResetOnLoad: true, | |
| bodyStyle: "padding: 0", | |
| items: [{ | |
| xtype: "syno_displayfield", | |
| value: _DT("download", "rss_name") + _T("common", "colon") | |
| }, { | |
| xtype: "syno_textfield", | |
| itemId: "title", | |
| name: "title", | |
| allowBlank: false, | |
| hideLabel: true, | |
| width: 460, | |
| value: this.record.get("title") | |
| }, { | |
| xtype: "syno_displayfield", | |
| value: _DT("download", "rss_url") + _T("common", "colon") | |
| }, { | |
| xtype: "syno_textfield", | |
| itemId: "url", | |
| name: "url", | |
| allowBlank: false, | |
| hideLabel: true, | |
| width: 460, | |
| value: this.record.get("url") | |
| }] | |
| }; | |
| b = Ext.apply(b, a); | |
| return new SYNO.ux.FormPanel(b) | |
| }, | |
| applyHandler: function() { | |
| var a = this.formPanel.getForm(); | |
| if (!a.isValid()) { | |
| this.getMsgBox().alert(this.title, _T("common", "forminvalid")); | |
| return | |
| } | |
| if (!a.isDirty()) { | |
| this.close(); | |
| return | |
| } | |
| this.setStatusBusy(); | |
| var b = { | |
| id: this.record.get("id") | |
| }; | |
| Ext.apply(b, a.getValues()); | |
| this.appWin.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.RSS.Feed", | |
| method: "set", | |
| params: b, | |
| version: 1, | |
| scope: this, | |
| callback: function(f, d, e, c) { | |
| this.clearStatusBusy(); | |
| if (!f) { | |
| this.appWin.getMsgBox().alert(this.title, SYNO.SDS.DownloadStation.Utils.getErrorString(d.code)); | |
| return | |
| } | |
| this.store.reload(); | |
| this.close() | |
| } | |
| }) | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.DLM"); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.RSS", { | |
| extend: "SYNO.SDS.DownloadStation.RightPanel", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| this.owner = a.owner; | |
| this.callParent(arguments); | |
| this.createPollingTask() | |
| }, | |
| createUpperPanel: function(a) { | |
| return new SYNO.SDS.DownloadStation.DLM.RSSGridPanel(a) | |
| }, | |
| createLowerPanel: function(a) { | |
| return new SYNO.SDS.DownloadStation.DLM.RSSInfoTabPanel(a) | |
| }, | |
| createPollingTask: function() { | |
| this.pollingtask.add({ | |
| id: "RSSGrid", | |
| interval: 5000, | |
| api: this.upperPanel.api, | |
| method: "list", | |
| version: 1, | |
| autoJsonDecode: true, | |
| beforestart: this.upperPanel.onBeforeGridPollingStart, | |
| callback: this.upperPanel.onUpdateRecordsTask, | |
| scope: this.upperPanel | |
| }) | |
| }, | |
| createActionGroup: function() { | |
| var c, b, a; | |
| var d = [new Ext.Button({ | |
| tooltip: _DT("common", "addto"), | |
| iconCls: "syno-dl-a_bt_create", | |
| itemId: "create", | |
| scope: this, | |
| handler: this.actionCreate | |
| }), c = new Ext.Button({ | |
| tooltip: _DT("common", "alt_edit"), | |
| iconCls: "syno-dl-a_bt_edit", | |
| disabled: true, | |
| itemId: "edit", | |
| scope: this, | |
| handler: this.actionEdit | |
| }), a = new Ext.Button({ | |
| tooltip: _DT("download", "rss_update"), | |
| iconCls: "syno-dl-a_bt_update", | |
| disabled: true, | |
| itemId: "update", | |
| scope: this, | |
| handler: this.actionUpdate | |
| }), new Ext.Button({ | |
| tooltip: _DT("download", "rss_update_all"), | |
| iconCls: "syno-dl-a_bt_update_all", | |
| itemId: "update_all", | |
| scope: this, | |
| handler: this.actionUpdateAll | |
| }), b = new Ext.Button({ | |
| tooltip: _DT("download", "download_tip_remove"), | |
| iconCls: "syno-dl-a_bt_delete", | |
| disabled: true, | |
| itemId: "remove", | |
| scope: this, | |
| handler: this.actionRemove | |
| })]; | |
| this.setMonDisabled(c, b, a); | |
| return this.callParent([d, false]) | |
| }, | |
| setMonDisabled: function(c, b, a) { | |
| c.mon(this.upperPanel.getSelectionModel(), "rowSelectionChanged", function(e) { | |
| var d = e.getSelections(); | |
| if (1 !== d.length) { | |
| this.setDisabled(true); | |
| return | |
| } else { | |
| if (false !== d[0].data.is_updating) { | |
| this.setDisabled(true); | |
| return | |
| } | |
| } | |
| this.setDisabled(false) | |
| }, c); | |
| b.mon(this.upperPanel.getSelectionModel(), "rowSelectionChanged", function(e) { | |
| var d = e.getSelections(); | |
| if (0 === d.length) { | |
| this.setDisabled(true); | |
| return | |
| } | |
| this.setDisabled(false) | |
| }, b); | |
| a.mon(this.upperPanel.getSelectionModel(), "rowSelectionChanged", function(f) { | |
| var e = f.getSelections(); | |
| if (0 === e.length) { | |
| this.setDisabled(true); | |
| return | |
| } | |
| for (var d = 0; d < e.length; d++) { | |
| if (false === e[d].data.is_updating) { | |
| break | |
| } | |
| } | |
| this.setDisabled((d === e.length) ? true : false) | |
| }, a) | |
| }, | |
| actionCreate: function() { | |
| var a = { | |
| uicomponents: this.uicomponents, | |
| store: this.upperPanel.store | |
| }; | |
| var b = new SYNO.SDS.DownloadStation.DLM.RSSAddDialog(a); | |
| b.open() | |
| }, | |
| actionEdit: function() { | |
| var a = { | |
| uicomponents: this.uicomponents, | |
| store: this.upperPanel.store, | |
| record: this.upperPanel.getSelectionModel().getSelected() | |
| }; | |
| var b = new SYNO.SDS.DownloadStation.DLM.RSSEditDialog(a); | |
| b.open() | |
| }, | |
| actionRemove: function() { | |
| var b = {}; | |
| var a = this.getSelectedTaskIDArray(); | |
| if (0 === a) { | |
| return | |
| } | |
| b.id = a; | |
| this.getMsgBox().confirm(_DT("download", "rss_feeds"), _DT("common", "remove_cfrmrmv"), function(c, d) { | |
| if ("yes" === c) { | |
| this.sendRequest("delete", b) | |
| } | |
| }, this) | |
| }, | |
| actionUpdate: function() { | |
| var b = {}; | |
| var a = this.getSelectedTaskIDArray(); | |
| if (0 === a) { | |
| return | |
| } | |
| b.id = a; | |
| this.sendRequest("update", b) | |
| }, | |
| actionUpdateAll: function() { | |
| this.sendRequest("updateall") | |
| }, | |
| getSelectedTaskIDArray: function() { | |
| var c = this.upperPanel.getSelectionModel().getSelections(); | |
| var a = []; | |
| for (var b = 0; b < c.length; b++) { | |
| a[b] = c[b].get("id") | |
| } | |
| return a | |
| }, | |
| sendRequest: function(a, b) { | |
| this.pollingtask.stopById("RSSGrid"); | |
| if (!this.upperPanel.getEl().isMasked()) { | |
| this.upperPanel.getEl().mask(_DT("common", "loading"), "x-mask-loading") | |
| } | |
| this.appWin.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.RSS.Feed", | |
| method: a, | |
| params: b, | |
| version: 1, | |
| scope: this, | |
| callback: this.requestDone | |
| }) | |
| }, | |
| requestDone: function(d, b, c, a) { | |
| this.upperPanel.getEl().unmask(); | |
| this.pollingtask.startById("RSSGrid"); | |
| if (!d) { | |
| this.appWin.getMsgBox().alert(this.title, SYNO.SDS.DownloadStation.Utils.getErrorString(b.code)); | |
| return | |
| } | |
| this.upperPanel.store.reload() | |
| }, | |
| onActivate: function() { | |
| if (this.panel.getEl().isMasked()) { | |
| this.panel.getEl().unmask() | |
| } | |
| if (0 === this.upperPanel.store.getCount()) { | |
| this.upperPanel.store.reload() | |
| } else { | |
| this.pollingtask.startById("RSSGrid", false) | |
| } | |
| }, | |
| onDeactivate: function() { | |
| this.pollingtask.stopById("RSSGrid") | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.DLM"); | |
| Ext.define("SYNO.SDS.DownloadStation.DLM.Main", { | |
| extend: "SYNO.SDS.DownloadStation.Main", | |
| constructor: function(a) { | |
| var b = this.fillConfig(a); | |
| this.owner = a.owner; | |
| this.callParent([b]); | |
| this.webapiLocationGet = { | |
| api: "SYNO.DownloadStation2.Settings.Location", | |
| method: "get", | |
| version: 1 | |
| }; | |
| this.webapiLocationSet = { | |
| api: "SYNO.DownloadStation2.Settings.Location", | |
| method: "set", | |
| version: 1 | |
| }; | |
| this.getSettings() | |
| }, | |
| fillConfig: function(a) { | |
| var b = {}; | |
| if (SYNO.SDS.DownloadStation.Uploader.Utils.isSupportHTML5Upload()) { | |
| b.plugins = [new SYNO.SDS.DownloadStation.DLM.QueueAddFileUploader({ | |
| listeners: { | |
| scope: this, | |
| beforedrop: this.onBeforeDropFile | |
| } | |
| })] | |
| } | |
| return Ext.apply(b, a) | |
| }, | |
| onBeforeDropFile: function(b, a) { | |
| this.launchTaskDialog(0, a); | |
| return false | |
| }, | |
| launchTaskDialog: function(b, c, e, a) { | |
| var d = function(f) { | |
| var g = new SYNO.SDS.DownloadStation.DLM.QueueAddDialog({ | |
| uicomponents: this.uicomponents, | |
| files: c, | |
| urls: e, | |
| hideTabHeader: a, | |
| activeTab: b | |
| }); | |
| g.open() | |
| }; | |
| SYNO.SDS.DownloadStation.DLM.Util.checkLocationDestinationNonEmpty(this, d, undefined, this) | |
| }, | |
| createSearchCategoryStore: function() { | |
| var a = new Ext.data.ArrayStore({ | |
| autoDestroy: true, | |
| idIndex: 0, | |
| fields: ["value", "display"], | |
| data: [["_allcat_", _DT("download", "download_allcategory")]] | |
| }); | |
| return a | |
| }, | |
| getSearchField: function() { | |
| if (!this.gSearch) { | |
| this.gSearch = new SYNO.TextFilter({ | |
| ctCls: "syno-textfilter syno-dl-toolbar-dlm-search", | |
| itemId: "global_search", | |
| emptyText: _DT("download", "quickurl_hint"), | |
| enableKeyEvents: true, | |
| width: 215, | |
| listeners: { | |
| scope: this, | |
| keypress: function(d, b) { | |
| if (b.getKey() == Ext.EventObject.ENTER) { | |
| var c = d.getValue().trim(); | |
| if (c) { | |
| var a = SYNO.SDS.DownloadStation.Utils.canonizeURLPrefix(c); | |
| if (a) { | |
| this.moduleList.selectModule("SYNO.SDS.DownloadStation.DLM.QueueAll"); | |
| this.uicomponents.queueGrid.addQuickURL(a); | |
| d.reset() | |
| } else { | |
| this.moduleList.selectModule("SYNO.SDS.DownloadStation.DLM.Search"); | |
| this.moduleList.actived.createSearchTab(c); | |
| d.focus() | |
| } | |
| } | |
| } | |
| } | |
| } | |
| }) | |
| } | |
| return this.gSearch | |
| }, | |
| getSettings: function() { | |
| SYNO.API.Request({ | |
| webapi: this.webapiLocationGet, | |
| callback: this.onGetSettings, | |
| scope: this | |
| }) | |
| }, | |
| onGetSettings: function(d, b, c, a) { | |
| if (!d) { | |
| SYNO.Debug("Failed on " + c.api + " " + c.method); | |
| return | |
| } | |
| SYNO.SDS.DownloadStation.DLM.Util.setLocationDestination(b.default_destination); | |
| if (Ext.isEmpty(b.default_destination) && this.appWin.isVisible()) { | |
| this.alertDestinationEmptyWithLaunchingChooser() | |
| } | |
| }, | |
| alertDestinationEmptyWithLaunchingChooser: function() { | |
| this.appWin.getMsgBox().alert(this.owner.title, _DT("download", "download_warning_select_share"), function(a, b) { | |
| if (a == "ok") { | |
| this.launchDownloadShareChooser() | |
| } | |
| }, this) | |
| }, | |
| launchDownloadShareChooser: function() { | |
| this.utils.chooseDestHandler({ | |
| owner: this.appWin, | |
| callback: function(c, b, a) { | |
| if (b) { | |
| this.applyShare(b.path.substr(1)) | |
| } | |
| c.close() | |
| }, | |
| callbackScope: this | |
| }) | |
| }, | |
| applyShare: function(a) { | |
| this.mask(_T("common", "saving")); | |
| SYNO.API.Request({ | |
| webapi: Ext.apply(this.webapiLocationSet, { | |
| params: { | |
| default_destination: a | |
| } | |
| }), | |
| callback: this.onApplyShareDone, | |
| scope: this | |
| }) | |
| }, | |
| onApplyShareDone: function(d, b, c, a) { | |
| this.unmask(); | |
| if (!d) { | |
| this.appWin.getMsgBox().alert(this.title, SYNO.SDS.DownloadStation.Utils.getErrorString(b.code)); | |
| return | |
| } | |
| SYNO.SDS.DownloadStation.DLM.Util.setLocationDestination(c.default_destination) | |
| } | |
| }); | |
| Ext.namespace("SYNO.SDS.DownloadStation.aMule"); | |
| SYNO.SDS.DownloadStation.aMule.Utils = {}; | |
| Ext.apply(SYNO.SDS.DownloadStation.aMule.Utils, { | |
| generalColTipRenderer: function(g, e, a, d, f, b) { | |
| var c = Ext.util.Format.htmlEncode(g); | |
| e.attr = 'ext:qtip="' + Ext.util.Format.htmlEncode(c) + '"'; | |
| return c | |
| }, | |
| isValidED2KLink: function(b, g) { | |
| var f; | |
| try { | |
| f = decodeURI(Ext.util.Format.trim(g)).toLowerCase() | |
| } catch (d) { | |
| SYNO.Debug("Fail to decodeURL " + d); | |
| return false | |
| } | |
| var c, a; | |
| if (f.length < 1) { | |
| return false | |
| } | |
| if (f.substr(0, 7) != "ed2k://") { | |
| return false | |
| } | |
| if (b == "server") { | |
| c = new RegExp(/ed2k:\/\/\|(server[^\|]*)\|([^\|]*)\|((\d+)\|)?\//); | |
| a = f.match(c); | |
| if (!a) { | |
| return false | |
| } | |
| } else { | |
| if (b == "file") { | |
| if (f.substr(8, 4) != "file") { | |
| return false | |
| } else { | |
| if (f.match(/\|/g).length < 5) { | |
| return false | |
| } | |
| } | |
| c = new RegExp(/ed2k:\/\/\|file\|(.*)\|(\d+)\|/); | |
| a = f.match(c); | |
| if (!a || (0 < a.length && "0" === a[2])) { | |
| return false | |
| } | |
| } else { | |
| return false | |
| } | |
| } | |
| return true | |
| }, | |
| isValidMetLink: function(c) { | |
| var a = 0; | |
| var b = Ext.util.Format.trim(c).toLowerCase(); | |
| if (b.length < 1) { | |
| return false | |
| } | |
| if (b.substr(0, 7) != "http://" && b.substr(0, 8) != "https://") { | |
| return false | |
| } | |
| if ((a = b.lastIndexOf(".")) == -1) { | |
| return false | |
| } | |
| if (b.substr(a + 1, 4) != "met" && b.substr(a + 1, 4) != "met?") { | |
| return false | |
| } | |
| return true | |
| }, | |
| serverColRenderer: function(g, e, a, d, f, b) { | |
| var c = Ext.util.Format.htmlEncode(g); | |
| if (a.data.CONNECTED) { | |
| return "<font color=#057FEB>" + c + "</font>" | |
| } else { | |
| return c | |
| } | |
| }, | |
| serverColTipRenderer: function(g, e, a, d, f, b) { | |
| var c = Ext.util.Format.htmlEncode(g); | |
| e.attr = 'ext:qtip="' + Ext.util.Format.htmlEncode(c) + '"'; | |
| if (a.data.CONNECTED) { | |
| return "<font color=#057FEB>" + c + "</font>" | |
| } else { | |
| return c | |
| } | |
| }, | |
| serverColUnitRenderer: function(b, f, d, h, a, g) { | |
| var i = b; | |
| var c = parseFloat(b); | |
| if (c >= 1000000) { | |
| i = (c / 1000000).toFixed(2) + "M" | |
| } else { | |
| if (c >= 1000) { | |
| i = (c / 1000).toFixed(2) + "k" | |
| } | |
| } | |
| var e = Ext.util.Format.htmlEncode(i); | |
| if (d.data.CONNECTED) { | |
| return "<font color=#057FEB>" + e + "</font>" | |
| } else { | |
| return e | |
| } | |
| }, | |
| getSearchFileTypeDS: function() { | |
| var a = new Ext.data.ArrayStore({ | |
| fields: ["value", "display"], | |
| data: [["any", _DT("search", "title_file_type_any")], ["audio", _DT("search", "title_file_type_audio")], ["video", _DT("search", "title_file_type_video")], ["image", _DT("search", "title_file_type_pic")], ["doc", _DT("search", "title_file_type_doc")], ["prog", _DT("search", "title_file_type_program")], ["archive", _DT("search", "title_file_type_archive")], ["iso", _DT("search", "title_file_type_image")]], | |
| autoDestroy: true | |
| }); | |
| return a | |
| }, | |
| getSearchTypeDS: function() { | |
| var a = new Ext.data.ArrayStore({ | |
| fields: ["value", "display"], | |
| data: [["local", _DT("search", "title_method_local")], ["global", _DT("search", "title_method_global")], ["kad", _DT("search", "title_method_kad")]], | |
| autoDestroy: true | |
| }); | |
| return a | |
| }, | |
| searchColTipRenderer: function(g, e, a, d, f, b) { | |
| var c = Ext.util.Format.htmlEncode(g); | |
| e.attr = 'ext:qtip="' + Ext.util.Format.htmlEncode(c) + '"'; | |
| if (a.data.file_has_downloaded === true) { | |
| return "<font color=#E64040>" + c + "</font>" | |
| } else { | |
| if (parseInt(a.data.source, 10) >= 50) { | |
| return "<font color=#057FEB>" + c + "</font>" | |
| } else { | |
| return c | |
| } | |
| } | |
| }, | |
| searchColSourceRenderer: function(h, e, a, d, g, b) { | |
| var f = h; | |
| if (0 !== a.get("completed_source")) { | |
| f = f + " (" + a.get("completed_source") + ")" | |
| } | |
| var c = Ext.util.Format.htmlEncode(f); | |
| if (a.data.file_has_downloaded === true) { | |
| return "<font color=#E64040>" + c + "</font>" | |
| } else { | |
| if (parseInt(a.data.source, 10) >= 50) { | |
| return "<font color=#057FEB>" + c + "</font>" | |
| } else { | |
| return c | |
| } | |
| } | |
| }, | |
| searchColSizeRenderer: function(g, f, a, h, d, b) { | |
| var e = SYNO.SDS.DownloadStation.Utils.fileSize(g); | |
| var c = Ext.util.Format.htmlEncode(e); | |
| if (a.data.file_has_downloaded === true) { | |
| return "<font color=#E64040>" + c + "</font>" | |
| } else { | |
| if (parseInt(a.data.source, 10) >= 50) { | |
| return "<font color=#057FEB>" + c + "</font>" | |
| } else { | |
| return c | |
| } | |
| } | |
| }, | |
| IsKadSearchKeywordValid: function(d) { | |
| var c = d.split(/[ ()\[\]{}<>,._!?:;\\\/-]+/); | |
| var b, a; | |
| for (b = 0, | |
| a = c.length; b < a; b++) { | |
| if (c[b].length >= 3) { | |
| return true | |
| } | |
| } | |
| return false | |
| }, | |
| getPriorityDS: function(b) { | |
| var a = ""; | |
| switch (b) { | |
| case "low": | |
| a = _DT("dlqueue", "dl_priority_low"); | |
| break; | |
| case "normal": | |
| a = _DT("dlqueue", "dl_priority_normal"); | |
| break; | |
| case "high": | |
| a = _DT("dlqueue", "dl_priority_high"); | |
| break; | |
| default: | |
| a = _DT("dlqueue", "dl_priority_auto"); | |
| break | |
| } | |
| return a | |
| }, | |
| showErrorMessages: function(c, b, d, a) { | |
| if (b && b.errno && b.errno.section && b.errno.key) { | |
| c.getMsgBox().alert(c.title, _DT(b.errno.section, b.errno.key), d, a) | |
| } else { | |
| if (b && b.code) { | |
| c.getMsgBox().alert(c.title, SYNO.SDS.DownloadStation.Utils.getErrorString(b.code), d, a) | |
| } else { | |
| c.getMsgBox().alert(c.title, _DT("common", "commfail"), d, a) | |
| } | |
| } | |
| }, | |
| timeRender: function(e) { | |
| var d = false | |
| , b = false | |
| , a = false; | |
| var f = ""; | |
| var c = parseFloat(e); | |
| if (c < 1) { | |
| return _DT("download", "download_status_unknown") | |
| } | |
| if (c >= (60 * 60 * 24)) { | |
| f += Math.floor(c / (60 * 60 * 24)) + " " + _DT("ulqueue", "time_day"); | |
| c = c % (60 * 60 * 24); | |
| d = true | |
| } | |
| if (c >= (60 * 60)) { | |
| f += Math.floor(c / (60 * 60)) + ":"; | |
| c = e % (60 * 60); | |
| b = true | |
| } | |
| if (c >= 60) { | |
| if (Math.floor(c / 60) < 10 && (b || d)) { | |
| f += "0" | |
| } | |
| f += Math.floor(c / 60) + ":"; | |
| a = true | |
| } | |
| if (c % 60 < 10 && (b || d || a)) { | |
| f += "0" | |
| } | |
| f += c % 60; | |
| if (b) { | |
| f += " " + _DT("ulqueue", "time_hour") | |
| } else { | |
| if (a) { | |
| f += " " + _DT("ulqueue", "time_min") | |
| } else { | |
| f += " " + _DT("ulqueue", "time_sec") | |
| } | |
| } | |
| return Ext.util.Format.htmlEncode(f) | |
| }, | |
| getEmuleDestination: function() { | |
| return SYNO.SDS.DownloadStation.gData.emule_default_destination | |
| }, | |
| setEmuleDestination: function(a) { | |
| SYNO.SDS.DownloadStation.gData.emule_default_destination = a | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.aMule"); | |
| Ext.define("SYNO.SDS.DownloadStation.aMule.DownloadGridPanel", { | |
| extend: "SYNO.ux.GridPanel", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| Ext.apply(this, a || {}); | |
| this.itemsPerPage = 50; | |
| var b = this.fillConfig(a); | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| this.DLStore = this.createStore(); | |
| var b = { | |
| store: this.DLStore, | |
| colModel: this.createColModel(), | |
| bbar: this.createBottombar(), | |
| view: this.createGridView(), | |
| selModel: this.createSelectionModel(), | |
| loadMask: true, | |
| stripeRows: true, | |
| border: false, | |
| enableColumnMove: true, | |
| stateful: true, | |
| stateEvents: ["columnmove", "columnresize", "sortchange"], | |
| initState: (function() { | |
| var d = this.appWin.appInstance.getUserSettings("amuledlqueuegridstates"); | |
| var c = SYNO.SDS.DownloadStation.Utils.checkStateValue(d, this.colModel); | |
| if (c) { | |
| if (this.fireEvent("beforestaterestore", this, c) !== false) { | |
| this.applyState(Ext.apply({}, c)); | |
| this.fireEvent("staterestore", this, c) | |
| } | |
| } | |
| } | |
| ).createDelegate(this), | |
| saveState: (function() { | |
| var c = this.getState(); | |
| this.appWin.appInstance.setUserSettings("amuledlqueuegridstates", c) | |
| } | |
| ).createDelegate(this), | |
| height: 500, | |
| layout: "fit", | |
| scope: this, | |
| listeners: { | |
| scope: this, | |
| afterrender: { | |
| scope: this, | |
| fn: this.onAfterRender, | |
| single: true | |
| }, | |
| rowcontextmenu: function(c, g, d) { | |
| d.preventDefault(); | |
| var f = c.getSelectionModel(); | |
| if (!f.isSelected(g)) { | |
| f.selectRow(g) | |
| } | |
| this.gridCtxMenu.showAt(d.getXY()) | |
| }, | |
| rowdblclick: { | |
| scope: this.owner, | |
| fn: this.owner.actionEdit | |
| } | |
| } | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| createStore: function() { | |
| var a = [{ | |
| name: "task_id", | |
| mapping: "id" | |
| }, { | |
| name: "file_id", | |
| convert: function(d, c) { | |
| return c.additional.detail.hash | |
| } | |
| }, { | |
| name: "filename", | |
| mapping: "title" | |
| }, { | |
| name: "total_size", | |
| mapping: "size" | |
| }, { | |
| name: "current_size", | |
| convert: function(d, c) { | |
| return c.additional.transfer.size_downloaded | |
| } | |
| }, { | |
| name: "progress", | |
| convert: function(d, c) { | |
| return (0 === c.size) ? 0 : (c.additional.transfer.size_downloaded / c.size) * 100 | |
| } | |
| }, { | |
| name: "current_rate", | |
| convert: function(d, c) { | |
| return c.additional.transfer.speed_download | |
| } | |
| }, { | |
| name: "connected_peers", | |
| convert: function(d, c) { | |
| return c.additional.detail.connected_peers + "(" + c.additional.detail.total_peers + ")" | |
| } | |
| }, { | |
| name: "status" | |
| }, { | |
| name: "username" | |
| }, { | |
| name: "destination", | |
| convert: function(d, c) { | |
| return c.additional.detail.destination | |
| } | |
| }, { | |
| name: "priority", | |
| convert: function(d, c) { | |
| return c.additional.detail.priority | |
| } | |
| }, { | |
| name: "status_extra" | |
| }]; | |
| var b = new SYNO.API.JsonStore({ | |
| api: "SYNO.DownloadStation2.Task", | |
| method: "list", | |
| version: 2, | |
| autoDestory: true, | |
| autoLoad: false, | |
| appWindow: this, | |
| sortInfo: { | |
| field: "filename", | |
| direction: "ASC" | |
| }, | |
| remoteSort: true, | |
| idProperty: "id", | |
| fields: a, | |
| root: "task", | |
| totalProperty: "total", | |
| baseParams: { | |
| type: ["emule"], | |
| limit: this.itemsPerPage, | |
| additional: ["detail", "transfer"] | |
| }, | |
| paramNames: { | |
| start: "offset", | |
| limit: "limit", | |
| sort: "sort_by", | |
| dir: "order" | |
| }, | |
| listeners: { | |
| scope: this, | |
| beforeload: this.onBeforeStoreLoad, | |
| load: this.onStoreLoad, | |
| loadexception: this.onStoreLoadException | |
| } | |
| }); | |
| this.addManagedComponent(b); | |
| return b | |
| }, | |
| onStoreLoadException: function(b, c, a) { | |
| this.owner.apiErrorHandler(a.code); | |
| this.pollingtask.startById("DownloadGrid", false) | |
| }, | |
| createColModel: function() { | |
| var a = new Ext.grid.ColumnModel({ | |
| columns: [{ | |
| id: "filename", | |
| header: _DT("download", "download_list_filename"), | |
| dataIndex: "filename", | |
| width: 150, | |
| renderer: SYNO.SDS.DownloadStation.Renderers.fileNameWithStatusRenderer | |
| }, { | |
| id: "total_size", | |
| header: _DT("download", "download_list_filesize"), | |
| dataIndex: "total_size", | |
| width: 70, | |
| renderer: SYNO.SDS.DownloadStation.Renderers.SizeRenderer | |
| }, { | |
| id: "current_size", | |
| header: _DT("download", "download_list_completed"), | |
| dataIndex: "current_size", | |
| width: 80, | |
| renderer: SYNO.SDS.DownloadStation.Renderers.SizeRenderer | |
| }, { | |
| id: "progress", | |
| header: _DT("download", "download_list_progress"), | |
| dataIndex: "progress", | |
| width: 80, | |
| renderer: SYNO.SDS.DownloadStation.Renderers.ProgressRenderer | |
| }, { | |
| id: "current_rate", | |
| header: _DT("download", "download_list_speed"), | |
| dataIndex: "current_rate", | |
| width: 70, | |
| hidden: true, | |
| renderer: SYNO.SDS.DownloadStation.Renderers.RateRenderer | |
| }, { | |
| id: "connected_peers", | |
| header: _DT("dlqueue", "title_dl_source"), | |
| dataIndex: "connected_peers", | |
| width: 60, | |
| hidden: true | |
| }, { | |
| id: "status", | |
| header: _DT("download", "download_list_status"), | |
| dataIndex: "status", | |
| width: 80, | |
| hidden: true, | |
| renderer: SYNO.SDS.DownloadStation.Renderers.StatusRenderer | |
| }, { | |
| id: "username", | |
| header: _DT("download", "download_list_username"), | |
| dataIndex: "username", | |
| width: 80, | |
| hidden: true | |
| }, { | |
| id: "priority", | |
| header: _DT("dlqueue", "title_dl_priority"), | |
| dataIndex: "priority", | |
| width: 80, | |
| hidden: true, | |
| renderer: this.getPriorityRender | |
| }], | |
| defaults: { | |
| sortable: true | |
| } | |
| }); | |
| return a | |
| }, | |
| getSortParam: function() { | |
| return this.DLStore.getSortState().field | |
| }, | |
| getPriorityRender: function(f, d, a, c, e, b) { | |
| return Ext.util.Format.htmlEncode(SYNO.SDS.DownloadStation.aMule.Utils.getPriorityDS(f)) | |
| }, | |
| createBottombar: function() { | |
| this.itemTotalDownRate = new SYNO.SDS.DownloadStation.ToolbarRateItem({ | |
| labelText: "DL" | |
| }); | |
| var a = new SYNO.ux.PagingToolbar({ | |
| store: this.DLStore, | |
| displayInfo: true, | |
| pageSize: this.itemsPerPage, | |
| refreshText: _DT("download", "download_btn_refresh"), | |
| itemCls: "syno-dl-gridpanel-bbaritem", | |
| items: [this.itemTotalDownRate, "-"], | |
| autoDestroy: true | |
| }); | |
| return a | |
| }, | |
| createGridView: function() { | |
| return new SYNO.SDS.DownloadStation.GridView() | |
| }, | |
| createSelectionModel: function() { | |
| var a = new Ext.grid.RowSelectionModel({ | |
| singleSelect: false, | |
| listeners: { | |
| selectionchange: { | |
| scope: this, | |
| fn: this.gridSelectionChange | |
| } | |
| } | |
| }); | |
| a.addEvents({ | |
| rowSelectionChanged: true | |
| }); | |
| return a | |
| }, | |
| gridSelectionChange: function(a) { | |
| if (!this.gridSelectionChangeTask) { | |
| this.gridSelectionChangeTask = new Ext.util.DelayedTask(function(b) { | |
| a.fireEvent("rowSelectionChanged", a) | |
| } | |
| ,a) | |
| } | |
| this.gridSelectionChangeTask.delay(300) | |
| }, | |
| onAfterRender: function() { | |
| this.gridCtxMenu = this.createCtxMenu(); | |
| this.addManagedComponent(this.gridCtxMenu) | |
| }, | |
| createCtxMenu: function() { | |
| var e = new SYNO.ux.Menu(); | |
| var c = this.owner.actionGroup.list; | |
| var a = ["dl_resume", "dl_stop", "dl_remove", "dl_edit"]; | |
| for (var d = 0; d < c.length; d++) { | |
| if (-1 !== a.indexOf(c[d].initialConfig.itemId)) { | |
| var b = c[d].initialConfig; | |
| b.text = b.tooltip; | |
| b.iconCls = ""; | |
| e.addMenuItem(b) | |
| } | |
| } | |
| e.addMenuItem({ | |
| itemId: "open", | |
| text: _T("fbbrower", "open_folder"), | |
| handler: this.actionOpenContainingFolder, | |
| scope: this | |
| }); | |
| e.items.items.forEach(function(f) { | |
| if ("open" === f.itemId) { | |
| f.mon(this.getSelectionModel(), "rowSelectionChanged", function(h) { | |
| var g = true; | |
| if (1 === h.getCount() && SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_FINISHED === h.getSelections()[0].get("status")) { | |
| g = false | |
| } | |
| this.setDisabled(g) | |
| }, f); | |
| return | |
| } | |
| this.owner.setMonDisabledByStatus(f) | |
| }, this); | |
| return e | |
| }, | |
| actionOpenContainingFolder: function() { | |
| var b = this.getSelectionModel().getSelected(); | |
| if (SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_FINISHED !== b.get("status")) { | |
| return | |
| } | |
| var a = b.get("destination"); | |
| if ("" === a) { | |
| this.getMsgBox().alert(_T("fbbrower", "open_folder"), _T("error", "error_dest_no_path")); | |
| return | |
| } | |
| if (true === _S("is_admin") && (a === "home" || a.substr(0, 5) === "home/")) { | |
| if (b.get("username") !== _S("user")) { | |
| a = (a.length > 4) ? "/" + a.substr(5) : ""; | |
| a = "homes/" + b.get("username") + a | |
| } | |
| } | |
| SYNO.SDS.AppLaunch("SYNO.SDS.App.FileStation3.Instance", { | |
| openfile: "/" + a + "/" + b.get("filename") | |
| }) | |
| }, | |
| onBeforeStoreLoad: function(a, b) { | |
| if (!this.isVisible()) { | |
| return false | |
| } | |
| if ("undefined" !== typeof (b.params.offset)) { | |
| this.gridStartPosition = b.params.offset | |
| } else { | |
| this.gridStartPosition = 0 | |
| } | |
| this.pollingtask.stopById("DownloadGrid"); | |
| this.pollingtask.startById("DownloadStatistic") | |
| }, | |
| onStoreLoad: function(b, a, c) { | |
| if (this.DLStore.getTotalCount() <= this.gridStartPosition && this.gridStartPosition > 0) { | |
| var d = Math.ceil((this.DLStore.getTotalCount() - this.itemsPerPage) / this.itemsPerPage); | |
| this.DLStore.load({ | |
| params: { | |
| offset: (d * this.itemsPerPage), | |
| limit: this.itemsPerPage | |
| } | |
| }); | |
| return | |
| } | |
| if (0 < this.DLStore.getTotalCount()) { | |
| this.owner.actionGroup.enable("dl_clear") | |
| } else { | |
| this.owner.actionGroup.disable("dl_clear") | |
| } | |
| this.pollingtask.startById("DownloadGrid", false) | |
| }, | |
| updateDownloadRate: function(a) { | |
| this.itemTotalDownRate.updateTextByRate(a) | |
| }, | |
| updateGridByCommit: function(f) { | |
| var a = this.getSelectedTaskIds(); | |
| var k = []; | |
| var b = false; | |
| var d = this.DLStore.reader.readRecords(f).records; | |
| for (var e = 0; e < d.length; e++) { | |
| var c = d[e]; | |
| var i = this.DLStore.getById(c.id); | |
| if (!i) { | |
| this.DLStore.removeAt(e); | |
| this.DLStore.insert(e, new Ext.data.Record(c.data,c.id)); | |
| continue | |
| } | |
| var h = this.DLStore.getAt(e); | |
| if (-1 !== a.indexOf(c.id)) { | |
| k.push(i); | |
| b |= (i.data.status !== c.data.status) | |
| } | |
| Ext.apply(i.data, c.data); | |
| i.commit(); | |
| if (a.length < 2 && h && c.id != h.get("task_id")) { | |
| this.DLStore.remove(i); | |
| this.DLStore.insert(e, i) | |
| } | |
| } | |
| this.updateSelections(a, k); | |
| if (b) { | |
| var g = this.getSelectionModel(); | |
| g.fireEvent("rowSelectionChanged", g) | |
| } | |
| }, | |
| getSelectedTaskIds: function() { | |
| var a = []; | |
| Ext.iterate(this.getSelectionModel().getSelections(), function(b) { | |
| a.push(b.get("task_id")) | |
| }, this); | |
| return a | |
| }, | |
| updateSelections: function(c, a) { | |
| var b = this.getSelectionModel(); | |
| if (1 === c.length && 1 === a.length) { | |
| b.suspendEvents(false); | |
| b.selectRecords([a[0]]); | |
| b.resumeEvents() | |
| } | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.aMule"); | |
| Ext.define("SYNO.SDS.DownloadStation.aMule.CreateTaskWindow", { | |
| extend: "SYNO.SDS.ModalWindow", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| this.webapiDestinationGet = { | |
| api: "SYNO.DownloadStation2.Settings.Emule.Location", | |
| method: "get", | |
| version: 1 | |
| }; | |
| this.webapiTaskCreate = { | |
| api: "SYNO.DownloadStation2.Task", | |
| method: "create", | |
| version: 2 | |
| }; | |
| var b = this.fillConfig(a); | |
| this.ADDTASK_MAXLIMIT = 50; | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| this.formPanel = new SYNO.SDS.DownloadStation.aMule.CreateTaskForm({ | |
| owner: this | |
| }); | |
| var b = { | |
| owner: a.owner, | |
| cls: "syno-dl-win", | |
| dsmStyle: "v5", | |
| resizable: false, | |
| title: _DT("download", "download_cap_new_download"), | |
| width: 580, | |
| height: 462, | |
| layout: "fit", | |
| buttons: SYNO.SDS.DownloadStation.Utils.composeButtonCfg({ | |
| xtype: "syno_button", | |
| btnStyle: "blue", | |
| text: _DT("download", "download_btn_new"), | |
| scope: this, | |
| handler: this.addTask | |
| }, { | |
| xtype: "syno_button", | |
| text: _DT("common", "close"), | |
| scope: this, | |
| handler: this.close | |
| }), | |
| items: this.formPanel | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| onShow: function() { | |
| var b = SYNO.SDS.DownloadStation.aMule.Utils; | |
| this.formPanel.getForm().findField("url").focus(false, 500); | |
| var a = b.getEmuleDestination(); | |
| if (!Ext.isEmpty(a)) { | |
| this.formPanel.getForm().findField("destination_display").setValue(a); | |
| return | |
| } | |
| this.setStatusBusy({ | |
| text: _T("common", "loading") | |
| }); | |
| this.sendWebAPI({ | |
| webapi: this.webapiDestinationGet, | |
| scope: this, | |
| callback: function(e, d, c) { | |
| if (!e) { | |
| b.showErrorMessages(this, d, function() { | |
| this.close() | |
| }, this); | |
| return | |
| } | |
| b.setEmuleDestination(d.default_destination); | |
| if (Ext.isEmpty(d.default_destination)) { | |
| this.mainPanel.alertDestinationEmptyWithLaunchingChooser(this, this.close, this); | |
| return | |
| } | |
| this.formPanel.getForm().findField("destination_display").setValue(d.default_destination); | |
| this.clearStatusBusy() | |
| } | |
| }) | |
| }, | |
| addTask: function() { | |
| var a = this.formPanel.getForm(); | |
| var b = !a.findField("url").disabled; | |
| if (b) { | |
| this.addTaskByUrl(a) | |
| } else { | |
| this.addTaskByFile(a) | |
| } | |
| }, | |
| addTaskByUrl: function(b) { | |
| var c = this.formValidUrl(b.findField("url")); | |
| if (Ext.isEmpty(c)) { | |
| return | |
| } | |
| var a = b.findField("extract_password_display").getValue(); | |
| if (false === SYNO.SDS.DownloadStation.DLM.Util.handleNewUnzipPW.createDelegate(this, [a])()) { | |
| return | |
| } | |
| var d = { | |
| type: Ext.decode(b.findField("type").getValue()), | |
| destination: b.findField("destination_display").getValue(), | |
| url: c, | |
| create_list: Ext.decode(b.findField("create_list").getValue()) | |
| }; | |
| if (!Ext.isEmpty(a)) { | |
| d.extract_password = a | |
| } | |
| this.setStatusBusy({ | |
| text: _DT("common", "saving") | |
| }); | |
| this.sendWebAPI({ | |
| webapi: Ext.apply(this.webapiTaskCreate, { | |
| params: d | |
| }), | |
| scope: this, | |
| callback: this.addTaskDone | |
| }) | |
| }, | |
| formValidUrl: function(g) { | |
| var e = g.getValue(); | |
| e = Ext.util.Format.trim(e); | |
| g.setValue(e); | |
| if (0 === e.length) { | |
| this.getMsgBox().alert(this.title, _DT("server", "error_server_empty_link")); | |
| return | |
| } | |
| var b = []; | |
| var f = e.split("\n"); | |
| var d = false; | |
| for (var c = 0; c < f.length; c++) { | |
| if (0 === Ext.util.Format.trim(f[c]).length) { | |
| continue | |
| } | |
| if (!SYNO.SDS.DownloadStation.aMule.Utils.isValidED2KLink("file", f[c])) { | |
| d = true; | |
| continue | |
| } | |
| b.push("ed2k://" + f[c].substr(7)) | |
| } | |
| if (0 === b.length) { | |
| this.getMsgBox().alert(this.title, _DT("server", "error_server_invalid_link")); | |
| return | |
| } | |
| if (b.length > this.ADDTASK_MAXLIMIT) { | |
| this.getMsgBox().alert(this.title, _DT("dlqueue", "error_task_add_exceed_maxnumber").replace("{0}", this.ADDTASK_MAXLIMIT)); | |
| return | |
| } | |
| if (d) { | |
| this.getMsgBox().alert(this.title, _DT("server", "error_invalid_link_found")) | |
| } | |
| var a = b.join(""); | |
| a = a.replace(/\r/g, ""); | |
| a = a.replace(/\n/g, ""); | |
| g.setValue(a); | |
| return b | |
| }, | |
| addTaskByFile: function(a) { | |
| var d = this.formPanel.FILEFILEDNAME; | |
| var c = a.findField(d).getValue(); | |
| if (c === "") { | |
| this.getMsgBox().alert(this.title, _DT("download", "download_empty_input_file")); | |
| return | |
| } else { | |
| if (!SYNO.SDS.DownloadStation.Utils.isValidExtension(c, ".txt")) { | |
| var b = _DT("download", "download_error_wrong_file_extension"); | |
| b = b.replace("%1", ".txt"); | |
| this.getMsgBox().alert(this.title, b); | |
| return | |
| } | |
| } | |
| a.doAction("apply") | |
| }, | |
| addTaskDone: function(c, b) { | |
| this.clearStatusBusy(); | |
| if (!c) { | |
| switch (b.code) { | |
| case this.utils.ERROR_CODE.SYNODL_ERR_REACH_LIMIT: | |
| SYNO.SDS.DownloadStation.aMule.Utils.showErrorMessages(this, b); | |
| return; | |
| case this.utils.ERROR_CODE.SYNODL_ERR_EMULE_FILE_EXIST: | |
| case this.utils.ERROR_CODE.SYNODL_ERR_EMULE_DUP_LINK: | |
| case this.utils.TASK_ERROR_EXCEED_MAX_TEMP_FS_SIZE: | |
| var a = _DT("download", "download_add_link_error_title") + _DT("common", "colon") + "<br />" + this.utils.getErrorString(b.code); | |
| this.getMsgBox().alert(this.title, a, this.close, this); | |
| return; | |
| default: | |
| SYNO.SDS.DownloadStation.aMule.Utils.showErrorMessages(this, b, this.close, this); | |
| return | |
| } | |
| } | |
| this.close() | |
| } | |
| }); | |
| Ext.define("SYNO.SDS.DownloadStation.aMule.CreateTaskForm", { | |
| extend: "SYNO.ux.FormPanel", | |
| FILEFILEDNAME: "emule", | |
| constructor: function(a) { | |
| this.owner = a.owner; | |
| var b = this.fillConfig(a); | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| var b = { | |
| bodyStyle: "padding: 0", | |
| frame: false, | |
| border: false, | |
| fileUpload: true, | |
| api: this.owner.webapiTaskCreate.api, | |
| method: this.owner.webapiTaskCreate.method, | |
| version: this.owner.webapiTaskCreate.version, | |
| url: "webapi/entry.cgi/" + this.owner.webapiTaskCreate.api, | |
| listeners: { | |
| beforeaction: { | |
| scope: this.owner, | |
| fn: this.onBeforeAction | |
| }, | |
| actioncomplete: { | |
| scope: this.owner, | |
| fn: this.onActionComplete | |
| }, | |
| actionfailed: { | |
| scope: this.owner, | |
| fn: this.onActionFailed | |
| } | |
| }, | |
| items: [{ | |
| xtype: "hidden", | |
| value: Ext.encode("url"), | |
| name: "type" | |
| }, { | |
| xtype: "hidden", | |
| value: Ext.encode([this.FILEFILEDNAME]), | |
| name: "file" | |
| }, { | |
| xtype: "hidden", | |
| value: false, | |
| name: "create_list" | |
| }, { | |
| xtype: "syno_compositefield", | |
| hideLabel: false, | |
| fieldLabel: _DT("download", "download_list_dest_folder"), | |
| autoFlexcroll: false, | |
| items: [{ | |
| xtype: "syno_textfield", | |
| name: "destination_display", | |
| readOnly: true, | |
| width: 201 | |
| }, { | |
| xtype: "syno_button", | |
| text: _T("common", "choose"), | |
| scope: this, | |
| handler: function() { | |
| this.owner.utils.chooseDestHandler({ | |
| owner: this.owner, | |
| destinationField: this.form.findField("destination_display") | |
| }) | |
| } | |
| }, { | |
| xtype: "hidden", | |
| name: "destination" | |
| }] | |
| }, { | |
| xtype: "syno_compositefield", | |
| hideLabel: false, | |
| fieldLabel: _DT("settings", "unzip_pw"), | |
| hidden: !SYNO.SDS.DownloadStation.DLM.Util.isUnzipServiceOn(), | |
| items: [{ | |
| xtype: "syno_textfield", | |
| name: "extract_password_display", | |
| width: 201 | |
| }, { | |
| xtype: "hidden", | |
| name: "extract_password" | |
| }] | |
| }, { | |
| xtype: "syno_compositefield", | |
| hideLabel: true, | |
| items: [{ | |
| xtype: "syno_radio", | |
| width: 180, | |
| boxLabel: _DT("download", "download_lbl_input_file") + _T("common", "colon"), | |
| name: "type_radio", | |
| inputValue: "file" | |
| }, { | |
| xtype: "syno_filebutton", | |
| hideLabel: true, | |
| buttonOnly: false, | |
| name: this.FILEFILEDNAME, | |
| disabled: true | |
| }] | |
| }, { | |
| xtype: "syno_compositefield", | |
| hideLabel: true, | |
| items: [{ | |
| xtype: "syno_displayfield", | |
| width: 180, | |
| value: "" | |
| }, { | |
| xtype: "syno_displayfield", | |
| value: "( eg. emule.txt )" | |
| }] | |
| }, { | |
| xtype: "syno_compositefield", | |
| hideLabel: true, | |
| items: [{ | |
| xtype: "syno_radio", | |
| checked: true, | |
| width: 180, | |
| boxLabel: _DT("download", "download_lbl_input_url") + _T("common", "colon"), | |
| name: "type_radio", | |
| inputValue: "url", | |
| listeners: { | |
| check: { | |
| fn: function(c, e) { | |
| var d = Ext.encode(e ? "url" : "file"); | |
| this.form.findField("type").setValue(d); | |
| this.form.findField(this.FILEFILEDNAME).setDisabled(e); | |
| this.form.findField("url").setDisabled(!e) | |
| }, | |
| scope: this | |
| } | |
| } | |
| }, { | |
| xtype: "syno_textarea", | |
| fieldLabel: _DT("download", "download_list_url"), | |
| name: "url", | |
| validateOnBlur: true, | |
| validationEvent: "blur", | |
| width: 285, | |
| height: 175, | |
| cls: "selectabletext allowDefCtxMenu" | |
| }] | |
| }, { | |
| xtype: "syno_compositefield", | |
| hideLabel: true, | |
| items: [{ | |
| xtype: "syno_displayfield", | |
| width: 180, | |
| value: "" | |
| }, { | |
| xtype: "syno_displayfield", | |
| width: 410, | |
| value: "( eg. ed2k://|file|<filename>|<filesize>|<file hash>|/ )" | |
| }] | |
| }] | |
| }; | |
| b = Ext.apply(b, a); | |
| return b | |
| }, | |
| createForm: function() { | |
| var a = Ext.applyIf({ | |
| appWindow: this, | |
| listeners: {} | |
| }, this.initialConfig); | |
| return new SYNO.API.Form.BasicForm(null,a) | |
| }, | |
| onBeforeAction: function(c, d) { | |
| if ("submit" !== d.type) { | |
| return | |
| } | |
| var b = c.findField("extract_password_display").getValue(); | |
| if (false === SYNO.SDS.DownloadStation.DLM.Util.handleNewUnzipPW.createDelegate(this, [b])()) { | |
| return false | |
| } | |
| c.findField("extract_password").setValue(Ext.encode(b)); | |
| var a = Ext.encode(c.findField("destination_display").getValue()); | |
| c.findField("destination").setValue(a); | |
| this.setStatusBusy({ | |
| text: _DT("common", "saving") | |
| }) | |
| }, | |
| onActionComplete: function(a, b) { | |
| this.addTaskDone(b.result.success, b.result.data) | |
| }, | |
| onActionFailed: function(a, b) { | |
| this.addTaskDone(b.result.success, b.result.error) | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.aMule"); | |
| Ext.define("SYNO.SDS.DownloadStation.aMule.EditTaskWindow", { | |
| extend: "SYNO.SDS.ModalWindow", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| Ext.apply(this, a || {}); | |
| var b = this.fillConfig(a); | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| this.formPanel = this.createForm(a); | |
| var c = _DT("common", "alt_edit") + ((this.selections.length > 1) ? ": batch" : ""); | |
| var b = { | |
| owner: a.owner, | |
| cls: "syno-dl-win", | |
| dsmStyle: "v5", | |
| resizable: false, | |
| title: c, | |
| width: 500, | |
| height: 210, | |
| layout: "fit", | |
| buttons: SYNO.SDS.DownloadStation.Utils.composeButtonCfg({ | |
| xtype: "syno_button", | |
| btnStyle: "blue", | |
| text: _DT("common", "ok"), | |
| scope: this, | |
| handler: this.applyHandler | |
| }, { | |
| xtype: "syno_button", | |
| text: _DT("common", "cancel"), | |
| scope: this, | |
| handler: this.close | |
| }), | |
| items: this.formPanel | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| onShow: function() { | |
| this.setStatusBusy({ | |
| text: _T("common", "loading") | |
| }); | |
| this.appWin.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.Task", | |
| method: "get", | |
| params: { | |
| id: [this.selections[0].get("task_id")], | |
| additional: ["detail"] | |
| }, | |
| version: 2, | |
| scope: this, | |
| callback: function(e, c, d, a) { | |
| var b = {}; | |
| this.clearStatusBusy(); | |
| if (!e) { | |
| SYNO.SDS.DownloadStation.aMule.Utils.showErrorMessages(this, c, function() { | |
| this.close() | |
| }, this); | |
| return | |
| } | |
| b.priority = c.task[0].additional.detail.priority; | |
| b.destination = c.task[0].additional.detail.destination; | |
| b.unzipPW = c.task[0].additional.detail.extract_password; | |
| this.formPanel.getForm().setValues(b) | |
| } | |
| }) | |
| }, | |
| createForm: function(a) { | |
| var b = { | |
| trackResetOnLoad: true, | |
| items: [{ | |
| xtype: "syno_compositefield", | |
| hideLabel: false, | |
| fieldLabel: _DT("dlqueue", "title_dl_priority"), | |
| items: [{ | |
| xtype: "syno_combobox", | |
| name: "priority", | |
| store: this.getPriorityDS(), | |
| displayField: "display", | |
| valueField: "value", | |
| triggerAction: "all", | |
| mode: "local", | |
| value: "auto", | |
| editable: false, | |
| width: 160 | |
| }] | |
| }, { | |
| xtype: "syno_compositefield", | |
| hideLabel: false, | |
| fieldLabel: _DT("download", "download_list_dest_folder"), | |
| items: [{ | |
| xtype: "syno_textfield", | |
| name: "destination", | |
| width: 160, | |
| readOnly: true, | |
| cls: "selectabletext allowDefCtxMenu" | |
| }, { | |
| xtype: "syno_button", | |
| name: "choosedestbtn", | |
| text: _T("common", "choose"), | |
| scope: this, | |
| handler: function() { | |
| this.utils.chooseDestHandler({ | |
| owner: this, | |
| destinationField: this.formPanel.form.findField("destination") | |
| }) | |
| } | |
| }] | |
| }, { | |
| xtype: "syno_compositefield", | |
| hideLabel: false, | |
| fieldLabel: _DT("settings", "unzip_pw"), | |
| hidden: !SYNO.SDS.DownloadStation.DLM.Util.isUnzipServiceOn(), | |
| items: [{ | |
| xtype: "syno_textfield", | |
| name: "unzipPW", | |
| width: 160 | |
| }] | |
| }] | |
| }; | |
| b = Ext.apply(b, a); | |
| return new SYNO.ux.FormPanel(b) | |
| }, | |
| applyHandler: function() { | |
| var b = []; | |
| var e = ""; | |
| var a = ""; | |
| for (var c = 0; c < this.selections.length; c++) { | |
| b[c] = this.selections[c].get("task_id") | |
| } | |
| e = this.formPanel.getForm().findField("priority").getValue(); | |
| a = this.formPanel.getForm().findField("destination").getValue(); | |
| if (!e || !a) { | |
| this.getMsgBox().alert(this.title, _DT("error", "error_bad_field")); | |
| return | |
| } | |
| var g = { | |
| id: b, | |
| priority: e, | |
| destination: a | |
| }; | |
| if (SYNO.SDS.DownloadStation.DLM.Util.isUnzipServiceOn()) { | |
| var f = this.formPanel.getForm().findField("unzipPW"); | |
| if (f && f.isDirty()) { | |
| var d = f.getValue(); | |
| if (false === SYNO.SDS.DownloadStation.DLM.Util.handleNewUnzipPW.createDelegate(this, [d])()) { | |
| return false | |
| } | |
| g.extract_password = d | |
| } | |
| } | |
| this.setStatusBusy({ | |
| text: _T("common", "loading") | |
| }); | |
| this.appWin.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.Task", | |
| method: "edit", | |
| params: g, | |
| version: 2, | |
| scope: this, | |
| callback: this.afterApply | |
| }) | |
| }, | |
| afterApply: function(d, b, c, a) { | |
| this.clearStatusBusy(); | |
| if (!d) { | |
| SYNO.SDS.DownloadStation.aMule.Utils.showErrorMessages(this, b); | |
| return | |
| } | |
| this.close() | |
| }, | |
| getPriorityDS: function() { | |
| var a = new Ext.data.ArrayStore({ | |
| fields: ["value", "display"], | |
| data: [["low", _DT("dlqueue", "dl_priority_low")], ["normal", _DT("dlqueue", "dl_priority_normal")], ["high", _DT("dlqueue", "dl_priority_high")], ["auto", _DT("dlqueue", "dl_priority_auto")]], | |
| autoDestroy: true | |
| }); | |
| return a | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.aMule"); | |
| Ext.define("SYNO.SDS.DownloadStation.aMule.DownloadInfoTabPanel", { | |
| extend: "SYNO.ux.TabPanel", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| this.owner = a.owner; | |
| var b = this.fillConfig(a); | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| this.infoGeneral = this.createInfoGeneral(a); | |
| this.infoTransfer = this.createInfoTransfer(a); | |
| var b = { | |
| border: false, | |
| cls: "syno-dl-infotab", | |
| activeTab: 0, | |
| deferredRender: true, | |
| collapsed: this.appWin.appInstance.getUserSettings("amuledlinfo") === true ? true : false, | |
| items: [this.infoGeneral, this.infoTransfer], | |
| listeners: { | |
| scope: this, | |
| afterrender: { | |
| fn: this.onAfterRender, | |
| scope: this, | |
| single: true | |
| }, | |
| beforecollapse: this.onRecordCollapse | |
| } | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| onAfterRender: function() { | |
| this.items.each(function(b) { | |
| Ext.get(b.tabEl).on("click", function() { | |
| var c = this.moduleList.actived; | |
| if (c.lowerPanel.bodyCollapsed) { | |
| c.onLowerPanelToggle(c.lowerPanel) | |
| } | |
| }, this) | |
| }, this); | |
| this.createPollingTask(); | |
| var a = this.owner.upperPanel.getSelectionModel(); | |
| this.mon(a, "rowSelectionChanged", function(b) { | |
| if (1 !== b.getCount()) { | |
| this.pollingtask.stopById("DownloadInfo"); | |
| if (this.el.isMasked()) { | |
| this.el.unmask() | |
| } | |
| this.resetForm(); | |
| return | |
| } | |
| this.load(b.getSelections()) | |
| }, this) | |
| }, | |
| onRecordCollapse: function(a) { | |
| var b = ("undefined" === typeof a.bodyCollapsed) ? true : !a.bodyCollapsed; | |
| this.appWin.appInstance.setUserSettings("amuledlinfo", b) | |
| }, | |
| load: function(a) { | |
| this.resetForm(); | |
| this.getEl().mask(_DT("common", "loading")); | |
| this.pollingtask.stopById("DownloadInfo"); | |
| this.pollingtask.startById("DownloadInfo") | |
| }, | |
| resetForm: function() { | |
| this.infoGeneral.getForm().reset(); | |
| this.infoTransfer.getForm().reset() | |
| }, | |
| createInfoGeneral: function(a) { | |
| var b = (true === _S("is_admin")) ? true : false; | |
| var c = { | |
| itemId: "general", | |
| title: _DT("download", "download_table_heading_general"), | |
| border: false, | |
| frame: false, | |
| defaults: { | |
| xtype: "syno_displayfield" | |
| }, | |
| items: [{ | |
| fieldLabel: _DT("download", "download_list_filename"), | |
| name: "filename", | |
| cls: "selectabletext allowDefCtxMenu" | |
| }, { | |
| fieldLabel: _DT("server", "title_server_link"), | |
| name: "link", | |
| cls: "selectabletext allowDefCtxMenu" | |
| }, { | |
| fieldLabel: _DT("dlqueue", "title_file_hash"), | |
| name: "hash" | |
| }, { | |
| fieldLabel: _DT("download", "download_list_filesize"), | |
| name: "filesize", | |
| hidden: this._S("is_admin") ? false : true | |
| }, { | |
| fieldLabel: _DT("dlqueue", "title_dl_priority"), | |
| name: "priority" | |
| }, { | |
| fieldLabel: _DT("download", "download_list_username"), | |
| name: "username", | |
| hidden: b ? false : true | |
| }, { | |
| fieldLabel: _DT("download", "download_list_dest_folder"), | |
| name: "destination", | |
| cls: "selectabletext allowDefCtxMenu" | |
| }] | |
| }; | |
| return new SYNO.ux.FormPanel(c) | |
| }, | |
| createInfoTransfer: function() { | |
| var a = { | |
| itemId: "transfer", | |
| title: _DT("download", "download_table_heading_transfer"), | |
| border: false, | |
| frame: false, | |
| defaults: { | |
| xtype: "syno_displayfield" | |
| }, | |
| items: [{ | |
| fieldLabel: _DT("download", "download_list_status"), | |
| name: "status" | |
| }, { | |
| fieldLabel: _DT("dlqueue", "title_dl_source"), | |
| name: "source" | |
| }, { | |
| fieldLabel: _DT("dlqueue", "title_dl_transferred"), | |
| name: "transferred" | |
| }, { | |
| fieldLabel: _DT("download", "download_list_completed"), | |
| name: "completed" | |
| }, { | |
| fieldLabel: _DT("dlqueue", "title_dl_remaining"), | |
| name: "remain" | |
| }, { | |
| fieldLabel: _DT("download", "download_list_progress"), | |
| name: "progress" | |
| }, { | |
| fieldLabel: _DT("download", "download_list_speed"), | |
| name: "speed" | |
| }, { | |
| fieldLabel: _DT("dlqueue", "title_dl_last_seen"), | |
| name: "lastseen" | |
| }] | |
| }; | |
| return new SYNO.ux.FormPanel(a) | |
| }, | |
| createPollingTask: function() { | |
| this.pollingtask.add({ | |
| id: "DownloadInfo", | |
| interval: 5000, | |
| api: "SYNO.DownloadStation2.Task", | |
| autoJsonDecode: true, | |
| method: "get", | |
| single: false, | |
| version: 2, | |
| callback: this.onUpdateForm, | |
| scope: this, | |
| beforestart: function(b) { | |
| var c = this.owner.upperPanel.getSelectionModel().getSelected(); | |
| if (!Ext.isDefined(c)) { | |
| return false | |
| } | |
| var a = []; | |
| a.push(c && c.get("task_id")); | |
| var d = { | |
| id: a, | |
| additional: ["detail", "transfer"] | |
| }; | |
| b.reqConfig.params = d | |
| } | |
| }) | |
| }, | |
| onUpdateForm: function(e, d, c) { | |
| this.getEl().unmask(); | |
| if (!e) { | |
| return | |
| } | |
| var a = d.task[0]; | |
| var b = {}; | |
| b.filename = a.title; | |
| b.link = a.additional.detail.uri; | |
| b.hash = a.additional.detail.hash; | |
| b.filesize = SYNO.SDS.DownloadStation.Utils.fileSize(a.size); | |
| b.priority = SYNO.SDS.DownloadStation.aMule.Utils.getPriorityDS(a.additional.detail.priority); | |
| b.username = a.username; | |
| b.destination = a.additional.detail.destination; | |
| b.status = SYNO.SDS.DownloadStation.Utils.getTaskStatusStr(a); | |
| b.source = a.additional.detail.connected_peers + "(" + a.additional.detail.total_peers + ")"; | |
| b.transferred = SYNO.SDS.DownloadStation.Utils.fileSize(a.additional.transfer.size_uploaded); | |
| b.completed = SYNO.SDS.DownloadStation.Utils.fileSize(a.additional.transfer.size_downloaded); | |
| b.remain = SYNO.SDS.DownloadStation.Utils.fileSize(a.size - a.additional.transfer.size_downloaded); | |
| b.progress = SYNO.SDS.DownloadStation.Renderers.ProgressRenderer((a.additional.transfer.size_downloaded / a.size) * 100); | |
| b.speed = (0 === a.additional.transfer.speed_download) ? _DT("download", "download_status_unknown") : SYNO.SDS.DownloadStation.Utils.fileSize(a.additional.transfer.speed_download) + "/s"; | |
| b.lastseen = SYNO.SDS.DateTimeFormatter(new Date(a.additional.detail.last_seen_complete * 1000)); | |
| Ext.each(this.items.items, function(h, f, g) { | |
| if (h.getForm) { | |
| h.getForm().setValues(b) | |
| } | |
| }, this); | |
| if (0 === d.task.length) { | |
| this.pollingtask.stopById("DownloadInfo") | |
| } | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.aMule"); | |
| Ext.define("SYNO.SDS.DownloadStation.aMule.Download", { | |
| extend: "SYNO.SDS.DownloadStation.RightPanel", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| this.owner = a.owner; | |
| this.webapiEmuleLocation = { | |
| api: "SYNO.DownloadStation2.Settings.Emule.Location", | |
| method: "get", | |
| version: 1 | |
| }; | |
| this.webapiTaskList = { | |
| api: "SYNO.DownloadStation2.Task", | |
| method: "list", | |
| version: 2 | |
| }; | |
| this.webapiDownloadStatistic = { | |
| api: "SYNO.DownloadStation2.Task.Statistic", | |
| method: "get", | |
| version: 1, | |
| params: { | |
| type: ["emule"] | |
| } | |
| }; | |
| this.callParent(arguments); | |
| this.createPollingTask() | |
| }, | |
| createUpperPanel: function(a) { | |
| return new SYNO.SDS.DownloadStation.aMule.DownloadGridPanel(a) | |
| }, | |
| createLowerPanel: function(a) { | |
| return new SYNO.SDS.DownloadStation.aMule.DownloadInfoTabPanel(a) | |
| }, | |
| createActionGroup: function() { | |
| var a = [new Ext.Button({ | |
| tooltip: _DT("download", "download_btn_new"), | |
| iconCls: "syno-dl-a_bt_create", | |
| itemId: "dl_create", | |
| scope: this, | |
| handler: this.actionCreate | |
| }), new Ext.Button({ | |
| tooltip: _DT("download", "download_tip_resume"), | |
| iconCls: "syno-dl-a_bt_resume", | |
| itemId: "dl_resume", | |
| disabled: true, | |
| scope: this, | |
| handler: this.actionResume | |
| }), new Ext.Button({ | |
| tooltip: _DT("download", "download_tip_stop"), | |
| iconCls: "syno-dl-a_bt_pause", | |
| itemId: "dl_stop", | |
| disabled: true, | |
| scope: this, | |
| handler: this.actionPause | |
| }), new Ext.Button({ | |
| tooltip: _DT("common", "alt_edit"), | |
| iconCls: "syno-dl-a_bt_edit", | |
| disabled: true, | |
| itemId: "dl_edit", | |
| scope: this, | |
| handler: this.actionEdit | |
| }), new Ext.Button({ | |
| tooltip: _DT("download", "download_tip_clear"), | |
| iconCls: "syno-dl-a_bt_clear", | |
| disabled: true, | |
| itemId: "dl_clear", | |
| scope: this, | |
| handler: this.actionClear | |
| }), new Ext.Button({ | |
| tooltip: _DT("download", "download_tip_remove"), | |
| iconCls: "syno-dl-a_bt_delete", | |
| disabled: true, | |
| itemId: "dl_remove", | |
| scope: this, | |
| handler: this.actionRemove | |
| })]; | |
| a.forEach(function(b) { | |
| this.setMonDisabledByStatus(b) | |
| }, this); | |
| return this.callParent([a, false]) | |
| }, | |
| statusArray: function() { | |
| var a = SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT; | |
| return { | |
| dl_resume: { | |
| status: [a.TASK_ERROR, a.TASK_ERROR_BROKEN_LINK, a.TASK_ERROR_DEST_NO_EXIST, a.TASK_ERROR_DEST_DENY, a.TASK_ERROR_DISK_FULL, a.TASK_ERROR_QUOTA_REACHED, a.TASK_ERROR_TIMEOUT, a.TASK_PAUSED, a.TASK_ERROR_EXCEED_MAX_FS_SIZE, a.TASK_ERROR_EXCEED_MAX_TEMP_FS_SIZE, a.TASK_ERROR_EXCEED_MAX_DEST_FS_SIZE, a.TASK_ERROR_NAME_TOO_LONG_ENCRYPTION, a.TASK_ERROR_NAME_TOO_LONG, a.TASK_ERROR_QUOTA_REACHED], | |
| disabled: false | |
| }, | |
| dl_stop: { | |
| status: [a.TASK_WAITING, a.TASK_DOWNLOADING, a.TASK_HASH_CHECKING], | |
| disabled: false | |
| }, | |
| dl_remove: { | |
| status: [], | |
| disabled: true | |
| }, | |
| dl_edit: { | |
| status: [a.TASK_FINISHING, a.TASK_FINISHED], | |
| disabled: true | |
| } | |
| } | |
| }, | |
| setMonDisabledByStatus: function(b) { | |
| var a = this.statusArray()[b.itemId]; | |
| if (!Ext.isDefined(a) || !Ext.isDefined(a.status) || !Ext.isDefined(a.disabled)) { | |
| return | |
| } | |
| var d = a.status; | |
| var c = a.disabled; | |
| b.mon(this.upperPanel.getSelectionModel(), "rowSelectionChanged", function(g) { | |
| var f = g.getSelections(); | |
| if (0 === f.length) { | |
| this.setDisabled(true); | |
| return | |
| } | |
| for (var e = 0; e < f.length; e++) { | |
| if (-1 !== d.indexOf(f[e].get("status"))) { | |
| break | |
| } | |
| } | |
| this.setDisabled((e === f.length) ? !c : c) | |
| }, b) | |
| }, | |
| actionCreate: function() { | |
| var a = { | |
| owner: this.appWin, | |
| uicomponents: this.uicomponents | |
| }; | |
| var b = new SYNO.SDS.DownloadStation.aMule.CreateTaskWindow(a); | |
| b.open() | |
| }, | |
| actionResume: function() { | |
| this.sendRequest("resume", this.getSelectedTaskIDArray()) | |
| }, | |
| actionPause: function() { | |
| this.sendRequest("pause", this.getSelectedTaskIDArray()) | |
| }, | |
| actionRemove: function() { | |
| this.getMsgBox().confirm(_DT("tree", "leaf_dlqueue"), _DT("download", "download_cfrm_remove"), function(a, b) { | |
| if (a == "yes") { | |
| this.sendRequest("delete", this.getSelectedTaskIDArray()); | |
| this.upperPanel.DLStore.reload() | |
| } | |
| }, this) | |
| }, | |
| actionEdit: function() { | |
| var b = SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT; | |
| var f = this.upperPanel.getSelectionModel().getSelections(); | |
| var a = false; | |
| for (var d = 0; d < f.length; d++) { | |
| if (f[d].get("status") !== b.TASK_FINISHED && f[d].get("status") !== b.TASK_FINISHING) { | |
| a = true | |
| } | |
| } | |
| if (false === a) { | |
| return | |
| } | |
| var c = { | |
| owner: this.appWin, | |
| selections: f, | |
| uicomponents: this.uicomponents | |
| }; | |
| var e = new SYNO.SDS.DownloadStation.aMule.EditTaskWindow(c); | |
| e.open() | |
| }, | |
| actionClear: function() { | |
| this.sendRequest("clear", []) | |
| }, | |
| getSelectedTaskIDArray: function() { | |
| var c = this.upperPanel.getSelectionModel().getSelections(); | |
| var a = []; | |
| for (var b = 0; b < c.length; b++) { | |
| a[b] = c[b].get("task_id") | |
| } | |
| return a | |
| }, | |
| sendRequest: function(b, c) { | |
| this.pollingtask.stopById("DownloadGrid"); | |
| var a = {}; | |
| a.id = c; | |
| if ("delete" === b) { | |
| a.force_complete = false | |
| } | |
| if ("clear" === b) { | |
| b = "delete_condition"; | |
| a = { | |
| type: ["emule"], | |
| type_inverse: false, | |
| status: [SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT.TASK_FINISHED], | |
| status_inverse: false | |
| } | |
| } | |
| if (!this.upperPanel.getEl().isMasked()) { | |
| this.upperPanel.getEl().mask(_DT("common", "loading"), "x-mask-loading") | |
| } | |
| this.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.Task", | |
| method: b, | |
| params: a, | |
| version: 2, | |
| scope: this, | |
| callback: this.requestDone | |
| }) | |
| }, | |
| requestDone: function(c, b, a) { | |
| this.upperPanel.getEl().unmask(); | |
| if (!c) { | |
| SYNO.SDS.DownloadStation.aMule.Utils.showErrorMessages(this, b) | |
| } | |
| this.pollingtask.startById("DownloadGrid") | |
| }, | |
| checkDestSettings: function() { | |
| if (!this.owner.isVisible()) { | |
| return | |
| } | |
| if (this.onceCheckedDestSettings) { | |
| return | |
| } | |
| this.onceCheckedDestSettings = true; | |
| this.setStatusBusy({ | |
| text: _T("common", "loading") | |
| }); | |
| this.sendWebAPI({ | |
| webapi: this.webapiEmuleLocation, | |
| callback: this.onCheckSettings, | |
| scope: this | |
| }) | |
| }, | |
| onCheckSettings: function(e, b, d, a) { | |
| this.clearStatusBusy(); | |
| var c = SYNO.SDS.DownloadStation.aMule.Utils; | |
| if (!e) { | |
| c.showErrorMessages(this, b); | |
| return | |
| } | |
| c.setEmuleDestination(b.default_destination); | |
| if (Ext.isEmpty(b.default_destination)) { | |
| this.mainPanel.alertDestinationEmptyWithLaunchingChooser(this.appWin) | |
| } | |
| }, | |
| onActivate: function() { | |
| if (this.panel.getEl().isMasked()) { | |
| this.panel.getEl().unmask() | |
| } | |
| this.checkDestSettings(); | |
| if (0 === this.upperPanel.store.getCount()) { | |
| this.upperPanel.DLStore.load({ | |
| params: { | |
| start: 0, | |
| limit: this.upperPanel.itemsPerPage | |
| } | |
| }) | |
| } else { | |
| this.pollingtask.startById("DownloadGrid", true); | |
| this.pollingtask.startById("DownloadInfo", true) | |
| } | |
| }, | |
| onDeactivate: function() { | |
| this.pollingtask.stopById("DownloadGrid"); | |
| this.pollingtask.stopById("DownloadInfo") | |
| }, | |
| createPollingTask: function() { | |
| this.pollingtask.add({ | |
| id: "DownloadGrid", | |
| interval: 5000, | |
| webapi: { | |
| api: "SYNO.Entry.Request", | |
| version: 1, | |
| method: "request", | |
| compound: { | |
| stopwhenerror: false | |
| } | |
| }, | |
| single: false, | |
| autoJsonDecode: true, | |
| beforestart: this.onBeforeGridPollingStart, | |
| callback: this.updateGrid, | |
| scope: this | |
| }); | |
| this.pollingtask.add({ | |
| id: "DownloadStatistic", | |
| interval: 5000, | |
| webapi: this.webapiDownloadStatistic, | |
| single: false, | |
| callback: this.updateDownloadStatistic, | |
| scope: this | |
| }) | |
| }, | |
| getGridPollingParams: function() { | |
| return { | |
| sort_by: this.upperPanel.getSortParam(), | |
| order: this.upperPanel.DLStore.getSortState().direction, | |
| offset: this.upperPanel.gridStartPosition || 0, | |
| limit: this.upperPanel.itemsPerPage, | |
| additional: ["detail", "transfer"], | |
| type: ["emule"] | |
| } | |
| }, | |
| onBeforeGridPollingStart: function(a) { | |
| a.taskCfg.webapi.compound.params = [Ext.apply(this.webapiTaskList, { | |
| params: this.getGridPollingParams() | |
| }), this.webapiDownloadStatistic] | |
| }, | |
| updateGrid: function(f, d, e, c) { | |
| if (!d.has_fail) { | |
| if (this.panel.getEl().isMasked()) { | |
| this.panel.getEl().unmask() | |
| } | |
| this.actionGroup.enable("global_search"); | |
| this.actionGroup.enable("dl_create") | |
| } | |
| for (var b = 0; b < d.result.length; b++) { | |
| var a = d.result[b]; | |
| if (!a.success) { | |
| this.apiErrorHandler(a.error.code); | |
| return | |
| } | |
| if (this.webapiTaskList.api === a.api) { | |
| if (this.upperPanel.DLStore.getTotalCount() != a.data.total) { | |
| this.upperPanel.DLStore.reload() | |
| } else { | |
| if (0 < a.data.total) { | |
| this.upperPanel.updateGridByCommit(a.data) | |
| } | |
| } | |
| if (this.upperPanel.DLStore.getTotalCount() > 0) { | |
| this.actionGroup.enable("dl_clear") | |
| } else { | |
| this.actionGroup.disable("dl_clear") | |
| } | |
| } else { | |
| if (this.webapiDownloadStatistic.api === a.api) { | |
| this.upperPanel.updateDownloadRate(a.data.download_rate) | |
| } | |
| } | |
| } | |
| }, | |
| apiErrorHandler: function(a) { | |
| SYNO.SDS.DownloadStation.Utils.setErrorMask(a, this.panel); | |
| this.upperPanel.selModel.clearSelections(); | |
| this.actionGroup.disableAll() | |
| }, | |
| updateDownloadStatistic: function(d, b, c, a) { | |
| this.pollingtask.stopById("DownloadStatistic"); | |
| if (!d) { | |
| this.apiErrorHandler(b.code); | |
| return | |
| } | |
| this.upperPanel.updateDownloadRate(b.download_rate) | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.aMule"); | |
| Ext.define("SYNO.SDS.DownloadStation.aMule.UploadGridPanel", { | |
| extend: "SYNO.ux.GridPanel", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| Ext.apply(this, a || {}); | |
| this.itemsPerPage = 50; | |
| var b = this.fillConfig(a); | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| this.store = this.createStore(); | |
| var b = { | |
| store: this.store, | |
| cls: "syno-dl-no-padding-grid", | |
| colModel: this.createColModel(), | |
| bbar: this.createBottombar(), | |
| view: this.createGridView(), | |
| selModel: this.createSelectionModel(), | |
| loadMask: true, | |
| stripeRows: true, | |
| border: false, | |
| enableColumnMove: true, | |
| stateful: true, | |
| stateEvents: ["columnmove", "columnresize", "sortchange"], | |
| initState: (function() { | |
| var d = this.appWin.appInstance.getUserSettings("amuleulqueuegridstates"); | |
| var c = SYNO.SDS.DownloadStation.Utils.checkStateValue(d, this.colModel); | |
| if (c) { | |
| if (this.fireEvent("beforestaterestore", this, c) !== false) { | |
| this.applyState(Ext.apply({}, c)); | |
| this.fireEvent("staterestore", this, c) | |
| } | |
| } | |
| } | |
| ).createDelegate(this), | |
| saveState: (function() { | |
| var c = this.getState(); | |
| this.appWin.appInstance.setUserSettings("amuleulqueuegridstates", c) | |
| } | |
| ).createDelegate(this), | |
| height: 500, | |
| layout: "fit" | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| createStore: function() { | |
| var a = [{ | |
| name: "client_name" | |
| }, { | |
| name: "file_name" | |
| }, { | |
| name: "upload_speed" | |
| }, { | |
| name: "size_uploaded" | |
| }, { | |
| name: "wait_time" | |
| }, { | |
| name: "upload_time" | |
| }]; | |
| var b = new SYNO.API.JsonStore({ | |
| api: "SYNO.DownloadStation2.Task.eMule", | |
| method: "list_upload", | |
| version: 1, | |
| pruneModifiedRecords: true, | |
| appWindow: this, | |
| autoLoad: false, | |
| root: "task", | |
| totalProperty: "total", | |
| remoteSort: true, | |
| fields: a, | |
| sortInfo: { | |
| field: "id", | |
| direction: "ASC" | |
| }, | |
| paramNames: { | |
| start: "offset", | |
| limit: "limit", | |
| sort: "sort_by", | |
| dir: "order" | |
| }, | |
| listeners: { | |
| scope: this, | |
| beforeload: this.onBeforeStoreLoad, | |
| load: this.onStoreLoad, | |
| loadexception: this.onStoreLoadException | |
| } | |
| }); | |
| this.addManagedComponent(b); | |
| return b | |
| }, | |
| onBeforeStoreLoad: function() { | |
| this.pollingtask.stopById("UploadGrid"); | |
| this.pollingtask.startById("UploadStatistic") | |
| }, | |
| onStoreLoad: function() { | |
| if (this.store.getTotalCount() <= this.gridStartPosition && this.gridStartPosition > 0) { | |
| var a = Math.ceil((this.store.getTotalCount() - this.itemsPerPage) / this.itemsPerPage); | |
| this.store.load({ | |
| params: { | |
| start: (a * this.itemsPerPage), | |
| limit: this.itemsPerPage | |
| } | |
| }); | |
| return | |
| } | |
| this.pollingtask.startById("UploadGrid", false) | |
| }, | |
| onStoreLoadException: function(b, c, a) { | |
| this.owner.errorHandler(a.code); | |
| this.pollingtask.startById("UploadGrid", false) | |
| }, | |
| createColModel: function() { | |
| var a = new Ext.grid.ColumnModel({ | |
| columns: [{ | |
| id: "client_name", | |
| header: _DT("download", "download_list_username"), | |
| dataIndex: "client_name", | |
| width: 135, | |
| renderer: SYNO.SDS.DownloadStation.aMule.Utils.generalColTipRenderer | |
| }, { | |
| id: "file_name", | |
| header: _DT("download", "download_list_filename"), | |
| dataIndex: "file_name", | |
| renderer: SYNO.SDS.DownloadStation.aMule.Utils.generalColTipRenderer | |
| }, { | |
| id: "size_uploaded", | |
| header: _DT("dlqueue", "title_dl_transferred"), | |
| dataIndex: "size_uploaded", | |
| width: 100, | |
| renderer: SYNO.SDS.DownloadStation.Renderers.SizeRenderer | |
| }, { | |
| id: "upload_speed", | |
| header: _DT("download", "download_list_speed"), | |
| dataIndex: "upload_speed", | |
| width: 85, | |
| renderer: function(f, e, b, g, d, c) { | |
| if (0 === f) { | |
| return ("upload_rate" === e.id) ? "" : "0.00 KB/s" | |
| } | |
| return SYNO.SDS.DownloadStation.Renderers.SizeRenderer(f, e, b, g, d, c) + "/s" | |
| } | |
| }, { | |
| id: "wait_time", | |
| header: _DT("ulqueue", "title_time_waited"), | |
| dataIndex: "wait_time", | |
| width: 100, | |
| renderer: SYNO.SDS.DownloadStation.aMule.Utils.timeRender | |
| }, { | |
| id: "upload_time", | |
| header: _DT("ulqueue", "title_time_upload"), | |
| dataIndex: "upload_time", | |
| width: 100, | |
| renderer: SYNO.SDS.DownloadStation.aMule.Utils.timeRender | |
| }], | |
| defaults: { | |
| sortable: true | |
| } | |
| }); | |
| return a | |
| }, | |
| createBottombar: function() { | |
| this.itemTotalUpRate = new SYNO.SDS.DownloadStation.ToolbarRateItem({ | |
| labelText: "UL" | |
| }); | |
| var a = new SYNO.ux.PagingToolbar({ | |
| store: this.store, | |
| displayInfo: true, | |
| pageSize: this.itemsPerPage, | |
| refreshText: _DT("download", "download_btn_refresh"), | |
| items: [this.itemTotalUpRate, "-"], | |
| autoDestroy: true | |
| }); | |
| return a | |
| }, | |
| updateUploadRate: function(a) { | |
| this.itemTotalUpRate.updateTextByRate(a) | |
| }, | |
| createGridView: function() { | |
| return new SYNO.SDS.DownloadStation.GridView() | |
| }, | |
| createSelectionModel: function() { | |
| var a = new Ext.grid.RowSelectionModel({ | |
| singleSelect: false | |
| }); | |
| return a | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.aMule"); | |
| Ext.define("SYNO.SDS.DownloadStation.aMule.Upload", { | |
| extend: "SYNO.SDS.DownloadStation.RightPanel", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| this.webapiUpload = { | |
| api: "SYNO.DownloadStation2.Task.eMule", | |
| method: "list_upload", | |
| version: 1 | |
| }; | |
| this.webapiStatistic = { | |
| api: "SYNO.DownloadStation2.Task.Statistic", | |
| method: "get", | |
| version: 1 | |
| }; | |
| this.createPollingTask(); | |
| this.callParent(arguments) | |
| }, | |
| createPanel: function(a) { | |
| var b = Ext.apply({ | |
| tbar: this.fillToolbarConfig() | |
| }, a); | |
| return new SYNO.SDS.DownloadStation.aMule.UploadGridPanel(b) | |
| }, | |
| createActionGroup: function() { | |
| var a = []; | |
| a.push(new Ext.Button({ | |
| tooltip: _DT("download", "download_btn_refresh"), | |
| iconCls: "syno-dl-a_bt_refresh", | |
| itemId: "refresh", | |
| scope: this, | |
| handler: this.actionRefresh | |
| })); | |
| return this.callParent([a, false]) | |
| }, | |
| actionRefresh: function() { | |
| this.panel.store.reload() | |
| }, | |
| onActivate: function() { | |
| if (this.panel.getEl().isMasked()) { | |
| this.panel.getEl().unmask() | |
| } | |
| if (0 === this.getPanel().store.getCount()) { | |
| this.panel.store.load({ | |
| params: { | |
| start: 0, | |
| limit: this.panel.itemsPerPage | |
| } | |
| }) | |
| } else { | |
| this.pollingtask.startById("UploadGrid", true) | |
| } | |
| }, | |
| onDeactivate: function() { | |
| this.pollingtask.stopById("UploadGrid"); | |
| this.pollingtask.stopById("UploadStatistic") | |
| }, | |
| createPollingTask: function() { | |
| this.pollingtask.add({ | |
| id: "UploadGrid", | |
| interval: 5000, | |
| webapi: { | |
| api: "SYNO.Entry.Request", | |
| version: 1, | |
| method: "request", | |
| compound: { | |
| stopwhenerror: false | |
| } | |
| }, | |
| single: false, | |
| beforestart: this.onBeforeGridPollingStart, | |
| callback: this.updateGrid, | |
| scope: this | |
| }); | |
| this.pollingtask.add({ | |
| id: "UploadStatistic", | |
| interval: 5000, | |
| webapi: Ext.apply(this.webapiStatistic, { | |
| params: { | |
| type: ["emule"], | |
| type_inverse: false | |
| } | |
| }), | |
| single: false, | |
| callback: this.updateStatistic, | |
| scope: this | |
| }) | |
| }, | |
| updateStatistic: function(d, b, c, a) { | |
| this.pollingtask.stopById("UploadStatistic"); | |
| if (!d) { | |
| return | |
| } | |
| this.panel.updateUploadRate(b.upload_rate) | |
| }, | |
| onBeforeGridPollingStart: function(a) { | |
| a.taskCfg.webapi.compound.params = [Ext.apply(this.webapiStatistic, { | |
| params: { | |
| type: ["emule"], | |
| type_inverse: false | |
| } | |
| }), Ext.apply(this.webapiUpload, { | |
| params: this.getGridPollingParams() | |
| })] | |
| }, | |
| updateGrid: function(g, e, f, c) { | |
| if (!g) { | |
| this.errorHandler(e.error.code); | |
| return | |
| } | |
| if (e.has_fail) { | |
| var d; | |
| Ext.each(e.result, function(i, h) { | |
| if (false === i.success) { | |
| d = i.error.code | |
| } | |
| }, this); | |
| this.errorHandler(d); | |
| return | |
| } | |
| if (this.panel.getEl().isMasked()) { | |
| this.panel.getEl().unmask() | |
| } | |
| this.actionGroup.enableAll(); | |
| var b; | |
| var a; | |
| Ext.each(e.result, function(i, h) { | |
| if (i.api === this.webapiUpload.api) { | |
| b = i.data | |
| } else { | |
| if (i.api === this.webapiStatistic.api) { | |
| a = i.data | |
| } | |
| } | |
| }, this); | |
| if (Ext.isDefined(b)) { | |
| this.updateStore(b) | |
| } | |
| if (Ext.isDefined(a)) { | |
| this.panel.updateUploadRate(a.upload_rate) | |
| } | |
| }, | |
| updateStore: function(c) { | |
| var b = c.task; | |
| if (this.panel.store.getCount() != b.length) { | |
| this.panel.store.loadData(c, false) | |
| } else { | |
| if (0 < b.length) { | |
| for (var a = 0; a < b.length; a++) { | |
| var d = this.panel.store.getAt(a); | |
| d.data.client_name = b[a].client_name; | |
| d.data.file_name = b[a].file_name; | |
| d.data.size_uploaded = b[a].size_uploaded; | |
| d.data.wait_time = b[a].wait_time; | |
| d.data.upload_time = b[a].upload_time; | |
| d.data.upload_speed = b[a].upload_speed; | |
| d.commit() | |
| } | |
| } | |
| } | |
| }, | |
| getGridPollingParams: function() { | |
| return { | |
| sort_by: this.panel.getStore().getSortState().field, | |
| order: this.panel.getStore().getSortState().direction, | |
| offset: this.panel.getStore().lastOptions.params.offset || 0, | |
| limit: this.panel.itemsPerPage | |
| } | |
| }, | |
| errorHandler: function(a) { | |
| SYNO.SDS.DownloadStation.Utils.setErrorMask(a, this.panel); | |
| this.panel.selModel.clearSelections(); | |
| this.actionGroup.disableAll() | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.aMule"); | |
| Ext.define("SYNO.SDS.DownloadStation.aMule.ServerGridPanel", { | |
| extend: "SYNO.ux.GridPanel", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| Ext.apply(this, a || {}); | |
| this.itemsPerPage = 50; | |
| var b = this.fillConfig(a); | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| this.webapiList = { | |
| api: "SYNO.DownloadStation2.eMule.Server", | |
| method: "list", | |
| version: 1 | |
| }; | |
| this.store = this.createStore(); | |
| var b = { | |
| scope: this, | |
| store: this.store, | |
| cls: "syno-dl-no-padding-grid", | |
| colModel: this.createColModel(), | |
| bbar: this.createBottombar(), | |
| view: this.createGridView(), | |
| selModel: this.createSelectionModel(), | |
| loadMask: true, | |
| stripeRows: true, | |
| border: false, | |
| enableColumnMove: true, | |
| stateful: true, | |
| stateEvents: ["columnmove", "columnresize", "sortchange"], | |
| initState: (function() { | |
| var d = this.appWin.appInstance.getUserSettings("amuleservergridstates"); | |
| var c = SYNO.SDS.DownloadStation.Utils.checkStateValue(d, this.colModel); | |
| if (c) { | |
| if (this.fireEvent("beforestaterestore", this, c) !== false) { | |
| this.applyState(Ext.apply({}, c)); | |
| this.fireEvent("staterestore", this, c) | |
| } | |
| } | |
| } | |
| ).createDelegate(this), | |
| saveState: (function() { | |
| var c = this.getState(); | |
| this.appWin.appInstance.setUserSettings("amuleservergridstates", c) | |
| } | |
| ).createDelegate(this), | |
| height: 500, | |
| layout: "fit", | |
| listeners: { | |
| celldblclick: { | |
| scope: this.owner, | |
| fn: function(f, g, d) { | |
| var c = this.panel.store.getAt(g); | |
| this.connectServerByIP(c) | |
| } | |
| } | |
| } | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| createStore: function() { | |
| var a = [{ | |
| name: "id" | |
| }, { | |
| name: "ip" | |
| }, { | |
| name: "port" | |
| }, { | |
| name: "name" | |
| }, { | |
| name: "description" | |
| }, { | |
| name: "ping" | |
| }, { | |
| name: "user_count" | |
| }, { | |
| name: "user_max" | |
| }, { | |
| name: "file_count" | |
| }]; | |
| var b = new SYNO.API.JsonStore({ | |
| api: this.webapiList.api, | |
| method: this.webapiList.method, | |
| version: this.webapiList.version, | |
| pruneModifiedRecords: true, | |
| appWindow: this, | |
| autoLoad: false, | |
| root: "results", | |
| totalProperty: "total", | |
| remoteSort: true, | |
| fields: a, | |
| sortInfo: { | |
| field: "user", | |
| direction: "DESC" | |
| }, | |
| paramNames: { | |
| start: "offset", | |
| limit: "limit", | |
| sort: "sort_by", | |
| dir: "order" | |
| }, | |
| listeners: { | |
| scope: this, | |
| beforeload: this.onBeforeStoreLoad, | |
| load: this.onStoreLoad, | |
| loadexception: this.onStoreLoadException | |
| } | |
| }); | |
| this.addManagedComponent(b); | |
| return b | |
| }, | |
| createColModel: function() { | |
| var a = new Ext.grid.ColumnModel({ | |
| columns: [{ | |
| id: "ip", | |
| header: _DT("server", "title_server_ip_address"), | |
| dataIndex: "ip", | |
| width: 120, | |
| renderer: SYNO.SDS.DownloadStation.aMule.Utils.serverColRenderer | |
| }, { | |
| id: "name", | |
| header: _DT("server", "title_server_name"), | |
| dataIndex: "name", | |
| width: 180, | |
| renderer: SYNO.SDS.DownloadStation.aMule.Utils.serverColTipRenderer | |
| }, { | |
| id: "description", | |
| header: _DT("server", "title_server_desc"), | |
| dataIndex: "description", | |
| renderer: SYNO.SDS.DownloadStation.aMule.Utils.serverColTipRenderer | |
| }, { | |
| id: "port", | |
| header: _DT("server", "title_server_port"), | |
| dataIndex: "port", | |
| width: 60, | |
| renderer: SYNO.SDS.DownloadStation.aMule.Utils.serverColRenderer | |
| }, { | |
| id: "ping", | |
| header: _DT("server", "title_server_ping"), | |
| dataIndex: "ping", | |
| width: 60, | |
| renderer: SYNO.SDS.DownloadStation.aMule.Utils.serverColRenderer | |
| }, { | |
| id: "user_count", | |
| header: _DT("server", "title_server_user_count"), | |
| dataIndex: "user_count", | |
| width: 80, | |
| renderer: SYNO.SDS.DownloadStation.aMule.Utils.serverColUnitRenderer | |
| }, { | |
| id: "user_max", | |
| header: _DT("server", "title_server_max_user"), | |
| dataIndex: "user_max", | |
| width: 80, | |
| renderer: SYNO.SDS.DownloadStation.aMule.Utils.serverColUnitRenderer | |
| }, { | |
| id: "file_count", | |
| header: _DT("server", "title_server_file_count"), | |
| dataIndex: "file_count", | |
| width: 80, | |
| renderer: SYNO.SDS.DownloadStation.aMule.Utils.serverColUnitRenderer | |
| }], | |
| defaults: { | |
| sortable: true | |
| } | |
| }); | |
| return a | |
| }, | |
| createBottombar: function() { | |
| return new SYNO.ux.Panel({ | |
| height: "50", | |
| layoutConfig: { | |
| type: "vbox", | |
| align: "stretch" | |
| }, | |
| items: [this.createConnectBar(), this.createPageBar()] | |
| }) | |
| }, | |
| createConnectBar: function() { | |
| this.txtED2KConn = new Ext.Toolbar.TextItem("<b>ED2K: </b>"); | |
| this.txtKadConn = new Ext.Toolbar.TextItem("<b>Kad: </b>"); | |
| var a = new Ext.Toolbar({ | |
| items: [this.txtED2KConn, "-", this.txtKadConn] | |
| }); | |
| return a | |
| }, | |
| createPageBar: function() { | |
| var a = new SYNO.ux.PagingToolbar({ | |
| store: this.store, | |
| displayInfo: true, | |
| pageSize: this.itemsPerPage, | |
| refreshText: _DT("download", "download_btn_refresh"), | |
| autoDestroy: true | |
| }); | |
| return a | |
| }, | |
| createGridView: function() { | |
| return new SYNO.SDS.DownloadStation.GridView() | |
| }, | |
| createSelectionModel: function() { | |
| var a = new Ext.grid.RowSelectionModel({ | |
| singleSelect: false, | |
| listeners: { | |
| selectionchange: { | |
| scope: this, | |
| fn: this.gridSelectionChange | |
| } | |
| } | |
| }); | |
| a.addEvents({ | |
| rowSelectionChanged: true | |
| }); | |
| return a | |
| }, | |
| gridSelectionChange: function(a) { | |
| if (!this.gridSelectionChangeTask) { | |
| this.gridSelectionChangeTask = new Ext.util.DelayedTask(function() { | |
| a.fireEvent("rowSelectionChanged", a) | |
| } | |
| ,a) | |
| } | |
| this.gridSelectionChangeTask.delay(300) | |
| }, | |
| onBeforeStoreLoad: function(a, b) { | |
| if ("undefined" != typeof (b.params.start)) { | |
| this.gridStartPosition = b.params.start | |
| } else { | |
| this.gridStartPosition = 0 | |
| } | |
| this.pollingtask.stopById("ServerGrid"); | |
| this.pollingtask.startById("UploadServerStatus") | |
| }, | |
| onStoreLoad: function(b, a, c) { | |
| if (this.store.getTotalCount() <= this.gridStartPosition && this.gridStartPosition > 0) { | |
| var d = Math.ceil((this.store.getTotalCount() - this.itemsPerPage) / this.itemsPerPage); | |
| this.store.load({ | |
| params: { | |
| start: (d * this.itemsPerPage), | |
| limit: this.itemsPerPage | |
| } | |
| }); | |
| return | |
| } | |
| this.pollingtask.startById("ServerGrid", false) | |
| }, | |
| onStoreLoadException: function(b, c, a) { | |
| this.owner.errorHandler(a.code); | |
| this.pollingtask.startById("ServerGrid", false) | |
| }, | |
| applyColorToString: function(b, a) { | |
| switch (a) { | |
| case "red": | |
| return "<font color=#E64040>" + b + "</font>"; | |
| case "green": | |
| return "<font color=#009E05>" + b + "</font>"; | |
| default: | |
| return b | |
| } | |
| }, | |
| updateStatusED2K: function(b) { | |
| var c = this.txtED2KConn.getEl(); | |
| var a = "<b>ED2K:</b> "; | |
| if ("connected" === b.status) { | |
| a += this.applyColorToString(_DT("server", "title_server_connected"), "green") + " [" + b.server_name + " [" + b.server_id + "] "; | |
| if (b.is_high_id === true) { | |
| a += " (" + _DT("server", "title_peer_high_id") + ")" | |
| } else { | |
| a += " " + this.applyColorToString("(" + _DT("server", "title_peer_low_id") + ")", "red") | |
| } | |
| a += "]"; | |
| this.highLightServer(b.server_id, true) | |
| } else { | |
| if ("connecting" == b.status) { | |
| a += _DT("server", "title_server_connecting") | |
| } else { | |
| a += this.applyColorToString(_DT("server", "title_server_not_connected"), "red") | |
| } | |
| } | |
| c.update(a) | |
| }, | |
| updateStatusKad: function(c) { | |
| var b = this.txtKadConn.getEl(); | |
| var a = "<b>Kad:</b> "; | |
| if ("connected" === c.status) { | |
| a += this.applyColorToString(_DT("server", "title_server_connected"), "green"); | |
| if (c.firewalled) { | |
| a += " " + this.applyColorToString("(" + _DT("server", "title_kad_firewall") + ")", "red") | |
| } | |
| } else { | |
| if ("connecting" == c.status) { | |
| a += _DT("server", "title_server_connecting") | |
| } else { | |
| a += this.applyColorToString(_DT("server", "title_server_not_connected"), "red") | |
| } | |
| } | |
| b.update(a) | |
| }, | |
| updateConnectionStatus: function(b) { | |
| var c = b.ED2K; | |
| var a = b.Kad; | |
| this.owner.gDataED2K = c; | |
| this.owner.gDataKad = a; | |
| if (0 === this.store.getTotalCount()) { | |
| this.owner.actionGroup.disable("connection") | |
| } else { | |
| this.owner.actionGroup.enable("connection") | |
| } | |
| if ("not connected" !== c.status || "not connected" !== a.status) { | |
| this.owner.actionGroup.enable("disconnect") | |
| } else { | |
| this.owner.actionGroup.disable("disconnect") | |
| } | |
| this.updateStatusED2K(c); | |
| this.updateStatusKad(a) | |
| }, | |
| highLightServer: function(c, a) { | |
| var b = this.store.getById(c); | |
| if (b) { | |
| b.set("CONNECTED", a); | |
| this.store.commitChanges() | |
| } | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.aMule"); | |
| Ext.define("SYNO.SDS.DownloadStation.aMule.AddServerWindow", { | |
| extend: "SYNO.SDS.ModalWindow", | |
| constructor: function(a) { | |
| var b = this.fillConfig(a); | |
| this.store = a.store; | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| this.formPanel = this.createForm(a); | |
| this.webapiAdd = { | |
| api: "SYNO.DownloadStation2.eMule.Server", | |
| method: "add", | |
| version: 1 | |
| }; | |
| var b = { | |
| owner: a.owner, | |
| cls: "syno-dl-win", | |
| dsmStyle: "v5", | |
| resizable: false, | |
| title: _DT("server", "title_add_new_server"), | |
| width: 488, | |
| height: 383, | |
| layout: "fit", | |
| buttons: SYNO.SDS.DownloadStation.Utils.composeButtonCfg({ | |
| xtype: "syno_button", | |
| btnStyle: "blue", | |
| text: _DT("common", "addto"), | |
| scope: this, | |
| handler: this.addServer | |
| }, { | |
| xtype: "syno_button", | |
| text: _DT("common", "close"), | |
| scope: this, | |
| handler: this.close | |
| }), | |
| items: this.formPanel | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| createForm: function(a) { | |
| var b = { | |
| trackResetOnLoad: true, | |
| bodyStyle: "padding: 0", | |
| frame: false, | |
| border: false, | |
| method: "POST", | |
| listeners: { | |
| afterlayout: { | |
| single: true, | |
| scope: this, | |
| fn: this.onAfterLayout | |
| } | |
| }, | |
| items: [{ | |
| xtype: "syno_radio", | |
| boxLabel: _DT("server", "title_server_ip"), | |
| name: "add_type", | |
| inputValue: "IP", | |
| checked: true | |
| }, { | |
| xtype: "syno_compositefield", | |
| indent: 1, | |
| hideLabel: true, | |
| items: [{ | |
| xtype: "syno_displayfield", | |
| value: _DT("server", "title_server_ip_address") + _T("common", "colon") | |
| }, { | |
| xtype: "syno_textfield", | |
| name: "IP", | |
| value: "", | |
| validateOnBlur: true, | |
| validationEvent: "blur", | |
| width: 120, | |
| maxLength: 15, | |
| vtype: "ip" | |
| }, { | |
| xtype: "syno_displayfield", | |
| value: _DT("server", "title_server_port") + _T("common", "colon"), | |
| indent: 1 | |
| }, { | |
| xtype: "syno_numberfield", | |
| indent: 1, | |
| name: "port", | |
| value: "", | |
| validateOnBlur: true, | |
| validationEvent: "blur", | |
| width: 80, | |
| maxLength: 5, | |
| vtype: "port" | |
| }] | |
| }, { | |
| xtype: "syno_radio", | |
| boxLabel: _DT("server", "title_server_link"), | |
| name: "add_type", | |
| inputValue: "ED2KLINK", | |
| checked: false | |
| }, { | |
| xtype: "syno_textfield", | |
| hideLabel: true, | |
| indent: 1, | |
| name: "link", | |
| value: "", | |
| maxlength: 4096, | |
| width: 400 | |
| }, { | |
| xtype: "syno_displayfield", | |
| indent: 1, | |
| value: "( eg. ed2k://|server|<IP>|<port>|/ )" | |
| }, { | |
| xtype: "syno_radio", | |
| boxLabel: _DT("server", "title_server_met_link"), | |
| name: "add_type", | |
| inputValue: "METURL", | |
| checked: false | |
| }, { | |
| xtype: "syno_textfield", | |
| hideLabel: true, | |
| indent: 1, | |
| name: "meturl", | |
| value: "", | |
| maxlength: 4096, | |
| width: 400 | |
| }, { | |
| xtype: "syno_displayfield", | |
| indent: 1, | |
| value: "( eg. http://www.synology.com/server.met)" | |
| }] | |
| }; | |
| b = Ext.apply(b, a); | |
| return new SYNO.ux.FormPanel(b) | |
| }, | |
| onAfterLayout: function() { | |
| var a = this.formPanel.getForm(); | |
| new SYNO.ux.Utils.EnableRadioGroup(a,"add_type",{ | |
| IP: ["IP", "port"], | |
| ED2KLINK: ["link"], | |
| METURL: ["meturl"] | |
| }) | |
| }, | |
| addServer: function() { | |
| var c = this.formPanel.getForm(); | |
| var e = c.findField("add_type").getGroupValue(); | |
| var g = {}; | |
| if ("IP" === e) { | |
| var f = c.findField("IP").getValue(); | |
| var b = c.findField("port").getValue(); | |
| f = Ext.util.Format.trim(f); | |
| c.findField("IP").setValue(f); | |
| if ("" === f) { | |
| this.getMsgBox().alert(_DT("tree", "leaf_server"), _DT("server", "error_server_empty_ip")); | |
| return | |
| } else { | |
| if ("" === b) { | |
| this.getMsgBox().alert(_DT("tree", "leaf_server"), _DT("server", "error_server_empty_port")); | |
| return | |
| } else { | |
| if (!c.findField("IP").isValid() || !c.findField("port").isValid()) { | |
| this.getMsgBox().alert(_DT("tree", "leaf_server"), _DT("common", "forminvalid")); | |
| return | |
| } | |
| } | |
| } | |
| g = { | |
| type: "ip", | |
| ip: f, | |
| port: b | |
| } | |
| } else { | |
| if ("ED2KLINK" === e) { | |
| var d = c.findField("link").getValue(); | |
| d = Ext.util.Format.trim(d); | |
| c.findField("link").setValue(d); | |
| if ("" === d) { | |
| this.getMsgBox().alert(_DT("tree", "leaf_server"), _DT("server", "error_server_empty_link")); | |
| return | |
| } else { | |
| if (!SYNO.SDS.DownloadStation.aMule.Utils.isValidED2KLink("server", d)) { | |
| this.getMsgBox().alert(_DT("tree", "leaf_server"), _DT("server", "error_server_invalid_link")); | |
| return | |
| } | |
| } | |
| g = { | |
| type: "ed2k_link", | |
| ed2k_link: d | |
| } | |
| } else { | |
| if ("METURL" === e) { | |
| var a = c.findField("meturl").getValue(); | |
| a = Ext.util.Format.trim(a); | |
| c.findField("meturl").setValue(a); | |
| if ("" === a) { | |
| this.getMsgBox().alert(_DT("tree", "leaf_server"), _DT("download", "download_empty_input_url")); | |
| return | |
| } else { | |
| if (!SYNO.SDS.DownloadStation.aMule.Utils.isValidMetLink(a)) { | |
| this.getMsgBox().alert(_DT("tree", "leaf_server"), _DT("server", "error_server_invalid_met_url")); | |
| return | |
| } | |
| } | |
| g = { | |
| type: "met_link", | |
| met_link: a | |
| } | |
| } | |
| } | |
| } | |
| this.doAddServer(g) | |
| }, | |
| doAddServer: function(a) { | |
| this.setStatusBusy({ | |
| text: _DT("common", "saving") | |
| }); | |
| SYNO.API.Request({ | |
| webapi: Ext.apply(this.webapiAdd, { | |
| params: a | |
| }), | |
| callback: this.addServerDone, | |
| scope: this | |
| }) | |
| }, | |
| addServerDone: function(d, b, c, a) { | |
| this.clearStatusBusy(); | |
| if (!d) { | |
| SYNO.SDS.DownloadStation.aMule.Utils.showErrorMessages(this, b); | |
| return | |
| } | |
| this.store.reload(); | |
| this.close() | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.aMule"); | |
| Ext.define("SYNO.SDS.DownloadStation.aMule.Server", { | |
| extend: "SYNO.SDS.DownloadStation.RightPanel", | |
| constructor: function(a) { | |
| Ext.apply(this, a.uicomponents || {}); | |
| this.owner = a.owner; | |
| this.webapiList = { | |
| api: "SYNO.DownloadStation2.eMule.Server", | |
| method: "list", | |
| version: 1 | |
| }; | |
| this.webapiGetStatus = { | |
| api: "SYNO.DownloadStation2.eMule.Server", | |
| method: "get_status", | |
| version: 1 | |
| }; | |
| this.webapiDelete = { | |
| api: "SYNO.DownloadStation2.eMule.Server", | |
| method: "delete", | |
| version: 1 | |
| }; | |
| this.webapiConnect = { | |
| api: "SYNO.DownloadStation2.eMule.Server", | |
| method: "connect", | |
| version: 1 | |
| }; | |
| this.webapiConnectKad = { | |
| api: "SYNO.DownloadStation2.eMule.Server", | |
| method: "connect_kad", | |
| version: 1 | |
| }; | |
| this.webapiDisconnect = { | |
| api: "SYNO.DownloadStation2.eMule.Server", | |
| method: "disconnect", | |
| version: 1 | |
| }; | |
| this.createPollingTask(); | |
| this.callParent(arguments) | |
| }, | |
| createPanel: function(a) { | |
| var b = Ext.apply({ | |
| tbar: this.fillToolbarConfig() | |
| }, a); | |
| return new SYNO.SDS.DownloadStation.aMule.ServerGridPanel(b) | |
| }, | |
| createActionGroup: function() { | |
| var c, b; | |
| var a = [new Ext.Button({ | |
| tooltip: _DT("server", "title_add_new_server"), | |
| iconCls: "syno-dl-a_bt_create", | |
| itemId: "create", | |
| scope: this, | |
| handler: this.actionCreate | |
| }), b = new Ext.Button({ | |
| tooltip: _DT("server", "tooltip_server_connecting"), | |
| iconCls: "syno-dl-a_bt_connect", | |
| itemId: "connect", | |
| scope: this, | |
| handler: this.actionConnect | |
| }), new Ext.Button({ | |
| tooltip: _DT("server", "tooltip_server_disconnect"), | |
| iconCls: "syno-dl-a_bt_disconnect", | |
| itemId: "disconnect", | |
| scope: this, | |
| handler: this.actionDisconnect | |
| }), c = new Ext.Button({ | |
| tooltip: _DT("server", "tooltip_server_delete"), | |
| iconCls: "syno-dl-a_bt_delete", | |
| disabled: true, | |
| itemId: "remove", | |
| scope: this, | |
| handler: this.actionRemove | |
| })]; | |
| c.mon(this.panel.getSelectionModel(), "rowSelectionChanged", function(e) { | |
| var d = true; | |
| if (e.getCount() >= 1) { | |
| d = false | |
| } | |
| this.setDisabled(d) | |
| }, c); | |
| b.mon(this.panel.getSelectionModel(), "rowSelectionChanged", function(e) { | |
| var d = true; | |
| if (1 === e.getCount()) { | |
| d = false | |
| } | |
| this.setDisabled(d) | |
| }, b); | |
| return this.callParent([a, false]) | |
| }, | |
| onActivate: function() { | |
| if (this.panel.getEl().isMasked()) { | |
| this.panel.getEl().unmask() | |
| } | |
| this.panel.store.load({ | |
| params: { | |
| start: 0, | |
| limit: this.panel.itemsPerPage | |
| } | |
| }) | |
| }, | |
| onDeactivate: function() { | |
| this.pollingtask.stopById("ServerGrid") | |
| }, | |
| createPollingTask: function() { | |
| this.pollingtask.add({ | |
| id: "ServerGrid", | |
| interval: 5000, | |
| webapi: { | |
| api: "SYNO.Entry.Request", | |
| version: 1, | |
| method: "request", | |
| compound: { | |
| stopwhenerror: false | |
| } | |
| }, | |
| single: false, | |
| beforestart: this.onBeforeGridPollingStart, | |
| callback: this.updateGrid, | |
| scope: this | |
| }); | |
| this.pollingtask.add({ | |
| id: "UploadServerStatus", | |
| interval: 5000, | |
| webapi: this.webapiGetStatus, | |
| single: false, | |
| callback: this.updateServerStatus, | |
| scope: this | |
| }) | |
| }, | |
| updateServerStatus: function(d, b, c, a) { | |
| this.pollingtask.stopById("UploadServerStatus"); | |
| if (!d) { | |
| this.errorHandler(b.code); | |
| return | |
| } | |
| this.panel.updateConnectionStatus(b) | |
| }, | |
| onBeforeGridPollingStart: function(a) { | |
| a.taskCfg.webapi.compound.params = [this.webapiGetStatus, Ext.apply(this.webapiList, { | |
| params: this.getGridPollingParams() | |
| })] | |
| }, | |
| getGridPollingParams: function() { | |
| return { | |
| sort_by: this.panel.store.sortInfo.field, | |
| order: this.panel.store.sortInfo.direction, | |
| start: this.panel.gridStartPosition, | |
| limit: this.panel.itemsPerPage | |
| } | |
| }, | |
| updateGrid: function(g, e, f, c) { | |
| if (!g) { | |
| this.errorHandler(e.error.code); | |
| return | |
| } | |
| if (e.has_fail) { | |
| var d; | |
| Ext.each(e.result, function(i, h) { | |
| if (false === i.success) { | |
| d = i.error.code | |
| } | |
| }, this); | |
| this.errorHandler(d); | |
| return | |
| } | |
| if (this.panel.getEl().isMasked()) { | |
| this.panel.getEl().unmask() | |
| } | |
| this.actionGroup.enable("global_search"); | |
| this.actionGroup.enable("create"); | |
| this.actionGroup.enable("connect"); | |
| var b; | |
| var a; | |
| Ext.each(e.result, function(i, h) { | |
| if (i.method === this.webapiList.method) { | |
| b = i.data | |
| } else { | |
| if (i.method === this.webapiGetStatus.method) { | |
| a = i.data | |
| } | |
| } | |
| }, this); | |
| if (Ext.isDefined(b)) { | |
| this.updateStore(b) | |
| } | |
| if (Ext.isDefined(a)) { | |
| this.panel.updateConnectionStatus(a) | |
| } | |
| }, | |
| updateStore: function(c) { | |
| var e = false; | |
| var b = c.results; | |
| if (this.panel.store.getCount() != b.length) { | |
| e = true | |
| } else { | |
| if (0 < b.length) { | |
| for (var a = 0; a < b.length; a++) { | |
| var d = this.panel.store.getAt(a); | |
| if (!d) { | |
| e = true; | |
| break | |
| } | |
| d.data.id = b[a].id; | |
| d.data.ip = b[a].ip; | |
| d.data.port = b[a].port; | |
| d.data.name = b[a].name; | |
| d.data.description = b[a].description; | |
| d.data.ping = b[a].ping; | |
| d.data.user_count = b[a].user_count; | |
| d.data.user_max = b[a].user_max; | |
| d.data.file_count = b[a].file_count; | |
| d.commit() | |
| } | |
| } | |
| } | |
| if (e) { | |
| this.panel.store.loadData(c, false) | |
| } | |
| }, | |
| actionCreate: function() { | |
| var a = { | |
| owner: this.appWin, | |
| store: this.panel.store | |
| }; | |
| var b = new SYNO.SDS.DownloadStation.aMule.AddServerWindow(a); | |
| b.open() | |
| }, | |
| actionRemove: function() { | |
| if (!this.panel.getSelectionModel().hasSelection()) { | |
| this.getMsgBox().alert(_DT("tree", "leaf_server"), _DT("download", "download_warning_select_items")); | |
| return | |
| } | |
| var a = this.panel.getSelectionModel().getSelections(); | |
| this.getMsgBox().confirm(_DT("tree", "leaf_server"), _DT("server", "title_server_delete_cfrm"), function(b, c) { | |
| if (b == "yes") { | |
| this.deleteServer(a) | |
| } | |
| }, this) | |
| }, | |
| deleteServer: function(b) { | |
| var a = []; | |
| for (var c = 0; c < b.length; c++) { | |
| a.push(b[c].id) | |
| } | |
| this.sendRequest(Ext.apply(this.webapiDelete, { | |
| params: { | |
| id: a | |
| } | |
| })) | |
| }, | |
| actionConnect: function() { | |
| if (this.panel.getSelectionModel().hasSelection()) { | |
| this.connectServerByIP(this.panel.getSelectionModel().getSelected()) | |
| } else { | |
| this.connectServer() | |
| } | |
| }, | |
| connectServerByIP: function(a) { | |
| var b = { | |
| api: "SYNO.Entry.Request", | |
| version: 1, | |
| method: "request", | |
| compound: { | |
| stopwhenerror: false, | |
| params: [Ext.apply(this.webapiConnect, { | |
| params: { | |
| id: a.get("id") | |
| } | |
| }), this.webapiConnectKad] | |
| } | |
| }; | |
| this.sendRequest(b) | |
| }, | |
| connectServer: function() { | |
| if (0 >= this.panel.store.getTotalCount()) { | |
| return | |
| } | |
| this.sendRequest(this.webapiConnect) | |
| }, | |
| actionDisconnect: function() { | |
| if ("connected" == this.gDataED2K.status || "connected" == this.gDataKad.status || "connecting" == this.gDataED2K.status || "connecting" == this.gDataKad.status) { | |
| this.disconnectServer() | |
| } | |
| }, | |
| disconnectServer: function() { | |
| this.sendRequest(Ext.apply(this.webapiDisconnect, { | |
| params: { | |
| type: "all" | |
| } | |
| })) | |
| }, | |
| sendRequest: function(a) { | |
| this.pollingtask.stopById("ServerGrid"); | |
| this.setStatusBusy({ | |
| text: _DT("common", "loading") | |
| }); | |
| SYNO.API.Request({ | |
| webapi: a, | |
| callback: this.requestDone, | |
| scope: this | |
| }) | |
| }, | |
| requestDone: function(e, b, d, a) { | |
| this.clearStatusBusy(); | |
| if (!e) { | |
| SYNO.SDS.DownloadStation.aMule.Utils.showErrorMessages(this, b) | |
| } | |
| if (Ext.isDefined(b) && b.has_fail) { | |
| var c; | |
| Ext.each(b.result, function(g, f) { | |
| if (false === g.success) { | |
| c = g.error | |
| } | |
| }, this); | |
| SYNO.SDS.DownloadStation.aMule.Utils.showErrorMessages(this, c) | |
| } | |
| this.panel.store.reload() | |
| }, | |
| errorHandler: function(a) { | |
| SYNO.SDS.DownloadStation.Utils.setErrorMask(a, this.panel); | |
| this.panel.selModel.clearSelections(); | |
| this.actionGroup.disableAll() | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.aMule"); | |
| Ext.define("SYNO.SDS.DownloadStation.aMule.SearchGridPanel", { | |
| extend: "SYNO.ux.GridPanel", | |
| constructor: function(a, c) { | |
| this.requestParams = c; | |
| this.maxRequestTimes = 5; | |
| Ext.apply(this, a.uicomponents || {}); | |
| Ext.apply(this, a || {}); | |
| this.itemsPerPage = 50; | |
| var b = this.fillConfig(a); | |
| this.callParent([b]) | |
| }, | |
| fillConfig: function(a) { | |
| this.webapiStart = { | |
| api: "SYNO.DownloadStation2.eMule.Search", | |
| method: "start", | |
| version: 1 | |
| }; | |
| this.webapiStop = { | |
| api: "SYNO.DownloadStation2.eMule.Search", | |
| method: "stop", | |
| version: 1 | |
| }; | |
| this.webapiList = { | |
| api: "SYNO.DownloadStation2.eMule.Search", | |
| method: "list", | |
| version: 1 | |
| }; | |
| this.store = this.createStore(); | |
| var b = { | |
| store: this.store, | |
| colModel: this.createColModel(), | |
| bbar: this.createBottombar(), | |
| view: this.createGridView(), | |
| selModel: this.createSelectionModel(), | |
| loadMask: true, | |
| stripeRows: true, | |
| border: false, | |
| enableColumnMove: true, | |
| stateful: true, | |
| stateEvents: ["columnmove", "columnresize", "sortchange"], | |
| initState: (function() { | |
| var d = this.appWin.appInstance.getUserSettings("amulesearchgridstates"); | |
| var c = SYNO.SDS.DownloadStation.Utils.checkStateValue(d, this.colModel); | |
| if (c) { | |
| if (this.fireEvent("beforestaterestore", this, c) !== false) { | |
| this.applyState(Ext.apply({}, c)); | |
| this.fireEvent("staterestore", this, c) | |
| } | |
| } | |
| } | |
| ).createDelegate(this), | |
| saveState: (function() { | |
| var c = this.getState(); | |
| this.appWin.appInstance.setUserSettings("amulesearchgridstates", c) | |
| } | |
| ).createDelegate(this), | |
| listeners: { | |
| afterlayout: { | |
| single: true, | |
| scope: this, | |
| fn: function() { | |
| this.sendSearchRequest() | |
| } | |
| }, | |
| beforeclose: { | |
| scope: this, | |
| fn: this.onBeforeClose | |
| }, | |
| celldblclick: { | |
| scope: this.owner, | |
| fn: this.owner.actionDownload | |
| }, | |
| activate: function(d) { | |
| var c = d.getEl(); | |
| if (c.isMasked()) { | |
| c.child(".ext-el-mask-msg").center(c) | |
| } | |
| } | |
| } | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| createStore: function() { | |
| this.gridStartPosition = 0; | |
| var a = [{ | |
| name: "file_id" | |
| }, { | |
| name: "filename" | |
| }, { | |
| name: "file_size" | |
| }, { | |
| name: "source" | |
| }, { | |
| name: "completed_source" | |
| }, { | |
| name: "file_type" | |
| }, { | |
| name: "file_has_downloaded" | |
| }]; | |
| var b = new SYNO.API.JsonStore({ | |
| api: this.webapiList.api, | |
| method: this.webapiList.method, | |
| version: this.webapiList.version, | |
| pruneModifiedRecords: true, | |
| appWindow: this, | |
| autoLoad: false, | |
| root: "results", | |
| totalProperty: "total", | |
| remoteSort: true, | |
| fields: a, | |
| sortInfo: { | |
| field: "source", | |
| direction: "DESC" | |
| }, | |
| paramNames: { | |
| start: "offset", | |
| limit: "limit", | |
| sort: "sort_by", | |
| dir: "order" | |
| }, | |
| listeners: { | |
| scope: this, | |
| beforeload: this.onBeforeStoreLoad, | |
| load: this.onStoreLoad, | |
| loadexception: this.onStoreLoadException | |
| } | |
| }); | |
| this.addManagedComponent(b); | |
| return b | |
| }, | |
| onBeforeStoreLoad: function(a, b) { | |
| if (!this.requestParams || "" === this.requestParams) { | |
| return false | |
| } | |
| this.pollingtask.stopById("search-" + this.requestParams.id) | |
| }, | |
| onStoreLoad: function(b, a, c) { | |
| this.pollingtask.startById("search-" + this.requestParams.id, false) | |
| }, | |
| onStoreLoadException: function(b, c, a) { | |
| this.errorHandler(a.code) | |
| }, | |
| onBeforeClose: function() { | |
| var a = this.requestParams.id; | |
| if (0 === a) { | |
| this.pollingtask.removeById("search-request" + this.requestParams.keyword) | |
| } else { | |
| if (0 < a) { | |
| this.pollingtask.removeById("search-" + a); | |
| this.stopSearch(a) | |
| } | |
| } | |
| }, | |
| stopSearch: function(b) { | |
| var a = {}; | |
| if (Ext.isDefined(b)) { | |
| a.id = b | |
| } else { | |
| a.id = 0 | |
| } | |
| SYNO.API.Request({ | |
| webapi: Ext.apply(this.webapiStop, { | |
| params: a | |
| }), | |
| callback: function(f, d, e, c) { | |
| if (!f) { | |
| SYNO.Debug("Failed to stop search " + d.code); | |
| return | |
| } | |
| }, | |
| scope: this | |
| }) | |
| }, | |
| createColModel: function() { | |
| var a = new Ext.grid.ColumnModel({ | |
| columns: [{ | |
| id: "filename", | |
| dataIndex: "filename", | |
| header: _DT("download", "download_list_filename"), | |
| width: 275, | |
| renderer: SYNO.SDS.DownloadStation.aMule.Utils.searchColTipRenderer | |
| }, { | |
| id: "file_size", | |
| dataIndex: "file_size", | |
| header: _DT("download", "download_list_filesize"), | |
| width: 120, | |
| renderer: SYNO.SDS.DownloadStation.aMule.Utils.searchColSizeRenderer | |
| }, { | |
| id: "source", | |
| dataIndex: "source", | |
| header: _DT("dlqueue", "title_dl_source"), | |
| width: 100, | |
| renderer: SYNO.SDS.DownloadStation.aMule.Utils.searchColSourceRenderer | |
| }, { | |
| id: "file_type", | |
| dataIndex: "file_type", | |
| header: _DT("search", "title_file_type"), | |
| width: 120, | |
| renderer: this.fileTypeRender | |
| }], | |
| defaults: { | |
| sortable: true | |
| } | |
| }); | |
| return a | |
| }, | |
| fileTypeRender: function(h, f, a, e, g, b) { | |
| var c = _DT("search", "title_file_type_any"); | |
| switch (h) { | |
| case "audio": | |
| c = _DT("search", "title_file_type_audio"); | |
| break; | |
| case "video": | |
| c = _DT("search", "title_file_type_video"); | |
| break; | |
| case "image": | |
| c = _DT("search", "title_file_type_pic"); | |
| break; | |
| case "doc": | |
| c = _DT("search", "title_file_type_doc"); | |
| break; | |
| case "prog": | |
| c = _DT("search", "title_file_type_program"); | |
| break; | |
| case "archive": | |
| c = _DT("search", "title_file_type_archive"); | |
| break; | |
| case "iso": | |
| c = _DT("search", "title_file_type_image"); | |
| break; | |
| default: | |
| c = _DT("search", "title_file_type_any") | |
| } | |
| var d = Ext.util.Format.htmlEncode(c); | |
| if (a.data.file_has_downloaded === true) { | |
| d = "<font color=#E64040>" + d + "</font>" | |
| } else { | |
| if (parseInt(a.data.source, 10) >= 50) { | |
| d = "<font color=#057FEB>" + d + "</font>" | |
| } | |
| } | |
| return d | |
| }, | |
| createBottombar: function() { | |
| this.txtSearching = new Ext.Toolbar.TextItem(""); | |
| var a = new SYNO.ux.PagingToolbar({ | |
| store: this.store, | |
| displayInfo: true, | |
| pageSize: this.itemsPerPage, | |
| refreshText: _DT("download", "download_btn_refresh"), | |
| items: this.txtSearching, | |
| autoDestroy: true | |
| }); | |
| return a | |
| }, | |
| createGridView: function() { | |
| return new SYNO.SDS.DownloadStation.GridView() | |
| }, | |
| createSelectionModel: function() { | |
| var a = new Ext.grid.RowSelectionModel({ | |
| singleSelect: false | |
| }); | |
| return a | |
| }, | |
| sendSearchRequest: function(b) { | |
| var a; | |
| if (!this.requestParams || "" === this.requestParams) { | |
| return | |
| } | |
| if (Ext.isObject(b)) { | |
| a = b | |
| } else { | |
| a = this.requestParams | |
| } | |
| this.pollingtask.add({ | |
| id: "search-request" + this.requestParams.keyword, | |
| interval: 5000, | |
| webapi: Ext.apply(this.webapiStart, { | |
| params: a | |
| }), | |
| single: false, | |
| beforestart: this.beforeRequest, | |
| callback: this.requestDone, | |
| scope: this | |
| }); | |
| this.pollingtask.startById("search-request" + this.requestParams.keyword) | |
| }, | |
| beforeRequest: function() { | |
| if (this.requestParams && this.requestParams.id && 0 < this.requestParams.id) { | |
| this.pollingtask.removeById("search-" + this.requestParams.id) | |
| } | |
| if (this.getEl().isMasked()) { | |
| this.getEl().unmask() | |
| } | |
| this.getEl().mask(_DT("search", "title_searching"), "x-mask-loading") | |
| }, | |
| requestDone: function(d, b, c, a) { | |
| if (this.isDestroyed || !this.store) { | |
| return | |
| } | |
| if (!this.store) { | |
| if (d && b.id) { | |
| this.stopSearch(b.id) | |
| } | |
| return | |
| } | |
| if (!d) { | |
| if (2703 === b.code) { | |
| return | |
| } | |
| this.pollingtask.removeById("search-request" + this.requestParams.keyword); | |
| this.errorHandler(b.code); | |
| return | |
| } | |
| this.pollingtask.removeById("search-request" + this.requestParams.keyword); | |
| this.requestParams.id = b.id; | |
| this.store.baseParams.id = b.id; | |
| this.createPollingTask(b); | |
| this.pollingtask.startById.defer(3000, this.pollingtask, ["search-" + b.id]); | |
| this.updateSearchingTextTask.start() | |
| }, | |
| createPollingTask: function(a) { | |
| this.pollingtask.add({ | |
| id: "search-" + a.id, | |
| interval: 5000, | |
| webapi: this.webapiList, | |
| single: false, | |
| autoJsonDecode: true, | |
| beforestart: this.onBeforeGridPollingStart, | |
| callback: this.updateGrid, | |
| scope: this | |
| }); | |
| this.updateSearchingTextTask = this.addTask({ | |
| id: "updateSearchingTextTask", | |
| interval: 1000, | |
| scope: this, | |
| run: this.updateSearchingText | |
| }) | |
| }, | |
| onBeforeGridPollingStart: function(a) { | |
| if (this.isDestroyed || !this.store) { | |
| return false | |
| } | |
| a.taskCfg.webapi.params = { | |
| sort_by: this.store.sortInfo.field, | |
| order: this.store.sortInfo.direction, | |
| offset: this.gridStartPosition, | |
| limit: this.itemsPerPage, | |
| id: this.requestParams.id | |
| } | |
| }, | |
| updateGrid: function(e, c, d, b) { | |
| if (this.isDestroyed || !this.store) { | |
| return | |
| } | |
| if (!e) { | |
| this.errorHandler(c.code); | |
| return | |
| } | |
| var a = this.txtSearching.getEl(); | |
| if (Ext.isDefined(this.requestTimes)) { | |
| this.requestTimes = 1 | |
| } | |
| if (c.search_done || (this.requestTimes >= this.maxRequestTimes)) { | |
| this.requestTimes = 1; | |
| this.pollingtask.removeById("search-" + d.id); | |
| this.updateSearchingTextTask.stop(); | |
| if (this.getEl().isMasked()) { | |
| this.getEl().unmask() | |
| } | |
| if (c.total < 1) { | |
| this.getEl().mask(_DT("search", "no_match_search_item")) | |
| } | |
| a.update("") | |
| } else { | |
| this.requestTimes++ | |
| } | |
| if (c.total > 0 && this.getEl().isMasked()) { | |
| this.getEl().unmask() | |
| } | |
| if (this.store.getTotalCount() != c.total) { | |
| this.store.loadData(c, false) | |
| } | |
| }, | |
| updateSearchingText: function() { | |
| var a = this.txtSearching.getEl(); | |
| if ("undefined" === typeof (this.gDotCount)) { | |
| this.gDotCount = -1 | |
| } | |
| switch (this.gDotCount) { | |
| case 0: | |
| a.update(_DT("search", "title_searching") + ". "); | |
| this.gDotCount++; | |
| break; | |
| case 1: | |
| a.update(_DT("search", "title_searching") + ".. "); | |
| this.gDotCount++; | |
| break; | |
| case 2: | |
| a.update(_DT("search", "title_searching") + "..."); | |
| this.gDotCount++; | |
| break; | |
| default: | |
| a.update(_DT("search", "title_searching") + " "); | |
| this.gDotCount = 0; | |
| break | |
| } | |
| }, | |
| errorHandler: function(a) { | |
| SYNO.SDS.DownloadStation.Utils.setErrorMask(a, this) | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.aMule"); | |
| Ext.define("SYNO.SDS.DownloadStation.aMule.AdvancedSearchPanel", { | |
| extend: "SYNO.ux.FormPanel", | |
| fieldWidth: 217, | |
| constructor: function(a) { | |
| Ext.apply(this, a || {}); | |
| var b = this.fillConfig(a); | |
| this.callParent([b]); | |
| this.keywordField = this.getForm().findField("keyword") | |
| }, | |
| fillConfig: function(a) { | |
| var b = { | |
| cls: "syno-amule-search-panel", | |
| width: 450, | |
| autoFlexcroll: false, | |
| buttons: SYNO.SDS.DownloadStation.Utils.composeButtonCfg({ | |
| xtype: "syno_button", | |
| btnStyle: "blue", | |
| text: _DT("tree", "leaf_search"), | |
| scope: this, | |
| handler: this.onSearch | |
| }, [{ | |
| xtype: "syno_button", | |
| text: _DT("common", "reset"), | |
| scope: this, | |
| handler: this.onReset | |
| }, { | |
| xtype: "syno_button", | |
| text: _DT("common", "close"), | |
| minWidth: 80, | |
| scope: this, | |
| handler: this.onClose | |
| }]), | |
| items: [{ | |
| xtype: "syno_fieldset", | |
| padding: 0, | |
| items: [{ | |
| xtype: "syno_textfield", | |
| hideLabel: false, | |
| fieldLabel: _DT("search", "title_keyword"), | |
| name: "keyword", | |
| allowBlank: false, | |
| validator: function(d) { | |
| if (0 === Ext.util.Format.trim(d).length) { | |
| return _DT("search", "error_search_key_empty") | |
| } | |
| var c = this.nextSibling().nextSibling().getValue(); | |
| if ("kad" === c && !SYNO.SDS.DownloadStation.aMule.Utils.IsKadSearchKeywordValid(d)) { | |
| return _DT("search", "error_search_key_too_short") | |
| } | |
| return true | |
| }, | |
| value: "", | |
| listeners: { | |
| single: true, | |
| scope: this, | |
| render: function() { | |
| this.keywordField.getEl().on("keypress", function(c, d) { | |
| if (c.getKey() == Ext.EventObject.ENTER) { | |
| this.onSearch() | |
| } | |
| }, this) | |
| } | |
| } | |
| }, { | |
| xtype: "syno_combobox", | |
| hideLabel: false, | |
| name: "filetype", | |
| fieldLabel: _DT("search", "title_file_type"), | |
| store: SYNO.SDS.DownloadStation.aMule.Utils.getSearchFileTypeDS(), | |
| listClass: "x-menu syno-ux-combobox-list", | |
| value: "any", | |
| valueField: "value", | |
| displayField: "display", | |
| mode: "local", | |
| triggerAction: "all", | |
| editable: false | |
| }, { | |
| xtype: "syno_combobox", | |
| hideLabel: false, | |
| name: "type", | |
| fieldLabel: _DT("search", "title_search_method"), | |
| store: SYNO.SDS.DownloadStation.aMule.Utils.getSearchTypeDS(), | |
| listClass: "x-menu syno-ux-combobox-list", | |
| value: "local", | |
| valueField: "value", | |
| displayField: "display", | |
| mode: "local", | |
| triggerAction: "all", | |
| editable: false, | |
| listeners: { | |
| scope: this, | |
| select: function() { | |
| this.keywordField.validate() | |
| } | |
| } | |
| }, { | |
| xtype: "syno_numberfield", | |
| hideLabel: false, | |
| fieldLabel: _DT("search", "title_search_min_size"), | |
| name: "min_size", | |
| maxLength: 6, | |
| allowBlank: true, | |
| allowDecimals: false, | |
| allowNegative: false | |
| }, { | |
| xtype: "syno_numberfield", | |
| hideLabel: false, | |
| fieldLabel: _DT("search", "title_search_max_size"), | |
| name: "max_size", | |
| maxLength: 6, | |
| allowBlank: true, | |
| allowDecimals: false, | |
| allowNegative: false | |
| }, { | |
| xtype: "syno_numberfield", | |
| hideLabel: false, | |
| fieldLabel: _DT("search", "title_min_source"), | |
| name: "avil", | |
| maxLength: 5, | |
| allowBlank: true, | |
| allowDecimals: false, | |
| allowNegative: false | |
| }, { | |
| xtype: "syno_textfield", | |
| hideLabel: false, | |
| fieldLabel: _DT("search", "title_extension"), | |
| name: "extension", | |
| maxLength: 4096 | |
| }, { | |
| xtype: "syno_displayfield", | |
| hideLabel: false, | |
| fieldLabel: "", | |
| value: "(eg. avi, jpg, iso)" | |
| }] | |
| }] | |
| }; | |
| return Ext.apply(b, a) | |
| }, | |
| onSearch: function() { | |
| var e, f, j; | |
| var a = this.getForm(); | |
| e = this.keywordField.getValue(); | |
| e = Ext.util.Format.trim(e); | |
| this.keywordField.setValue(e); | |
| if (!a.isValid()) { | |
| return | |
| } | |
| f = a.findField("type").getValue(); | |
| j = a.findField("filetype").getValue(); | |
| var c = { | |
| keyword: e, | |
| search_type: f, | |
| file_type: j | |
| }; | |
| var g = a.findField("min_size"); | |
| if (g.isDirty()) { | |
| Ext.apply(c, { | |
| file_size_min: g.getValue() | |
| }) | |
| } | |
| var d = a.findField("max_size"); | |
| if (d.isDirty()) { | |
| Ext.apply(c, { | |
| file_size_max: d.getValue() | |
| }) | |
| } | |
| var i = a.findField("avil"); | |
| if (i.isDirty()) { | |
| Ext.apply(c, { | |
| source_num_min: i.getValue() | |
| }) | |
| } | |
| var b = a.findField("extension"); | |
| if (b.isDirty()) { | |
| var h = Ext.util.Format.trim(b.getValue()); | |
| if (!Ext.isEmpty(h)) { | |
| Ext.apply(c, { | |
| file_extension: h | |
| }) | |
| } | |
| } | |
| this.owner.setValue(e); | |
| this.owner.owner.actionSearch(c); | |
| this.onClose() | |
| }, | |
| onReset: function() { | |
| this.keywordField.originalValue = ""; | |
| this.form.reset(); | |
| this.keywordField.focus() | |
| }, | |
| onClose: function() { | |
| this.owner.hideMenu() | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.aMule"); | |
| Ext.define("SYNO.SDS.DownloadStation.aMule.Search", { | |
| extend: "SYNO.SDS.DownloadStation.RightPanel", | |
| constructor: function(a) { | |
| this.cfg = a; | |
| Ext.apply(this, a.uicomponents || {}); | |
| this.owner = a.owner; | |
| this.webapiDownload = { | |
| api: "SYNO.DownloadStation2.eMule.Search", | |
| method: "download", | |
| version: 1 | |
| }; | |
| this.maxTabNumber = 5; | |
| this.callParent(arguments) | |
| }, | |
| createPanel: function(a) { | |
| var b = { | |
| enableTabScroll: true, | |
| items: [], | |
| cls: "syno-dl-searchpanel", | |
| listeners: { | |
| scope: this, | |
| add: this.showHideTabPanel, | |
| remove: this.showHideTabPanel | |
| } | |
| }; | |
| this.tabPanel = new SYNO.SDS.DownloadStation.SearchTabPanel(Ext.apply(b, a)); | |
| return new SYNO.ux.Panel({ | |
| tbar: this.fillToolbarConfig(), | |
| layout: "fit", | |
| items: [this.tabPanel] | |
| }) | |
| }, | |
| showHideTabPanel: function() { | |
| var a = true; | |
| var c = this.tabPanel.items.items.length; | |
| if (0 === c) { | |
| a = false; | |
| this.createSearchTab("") | |
| } else { | |
| if (1 === c) { | |
| a = ("" === this.tabPanel.items.items[0].requestParams) ? false : true | |
| } else { | |
| this.tabPanel.items.each(function(d) { | |
| if ("" === d.requestParams) { | |
| this.tabPanel.remove(d) | |
| } | |
| }, this) | |
| } | |
| } | |
| this.tabPanel.header.setVisibilityMode(Ext.Element.DISPLAY).setVisible(a); | |
| var b = Math.max(0, this.tabPanel.lastSize.height - this.tabPanel.getFrameHeight()); | |
| this.tabPanel.body.setHeight(b); | |
| this.tabPanel.doLayout() | |
| }, | |
| onActivate: function() { | |
| this.showHideTabPanel(); | |
| if (this.panel.getEl().isMasked()) { | |
| this.panel.getEl().unmask() | |
| } | |
| }, | |
| createSearchTab: function(d) { | |
| var c = this.findSameSearchParams(d); | |
| if (false !== c) { | |
| this.tabPanel.setActiveTab(c); | |
| this.tabPanel.getActiveTab().sendSearchRequest(d); | |
| return | |
| } | |
| if (this.tabPanel.items.items.length >= this.maxTabNumber) { | |
| this.getMsgBox().alert(this.searchtitle, String.format(_DT("search", "search_tab_reach_limit"), this.maxTabNumber)); | |
| return | |
| } | |
| var a = { | |
| uicomponents: this.uicomponents, | |
| owner: this, | |
| title: Ext.util.Format.htmlEncode(d.keyword), | |
| tabTip: Ext.util.Format.htmlEncode(d.keyword), | |
| cls: !d.keyword ? "syno-dl-no-padding-grid" : "", | |
| closable: true | |
| }; | |
| var b = new SYNO.SDS.DownloadStation.aMule.SearchGridPanel(a,d); | |
| this.tabPanel.add(b); | |
| this.tabPanel.setActiveTab(b); | |
| this.downloadButton.mon(this.tabPanel.getActiveTab().getSelectionModel(), "selectionchange", this.updateBtn, this) | |
| }, | |
| createActionGroup: function() { | |
| var a = []; | |
| a.push(this.downloadButton = new Ext.Button({ | |
| tooltip: _DT("search", "tooltip_download_file"), | |
| iconCls: "syno-dl-a_bt_download", | |
| itemId: "download", | |
| disabled: true, | |
| scope: this, | |
| handler: this.actionDownload | |
| })); | |
| this.mainPanel.gSearch.mon(this.tabPanel, "tabchange", this.updateBtn, this); | |
| return this.callParent([a, false]) | |
| }, | |
| updateBtn: function() { | |
| var b = true; | |
| var a = this.tabPanel.getActiveTab(); | |
| if (a) { | |
| if (a.getSelectionModel().hasSelection()) { | |
| b = false | |
| } | |
| } | |
| if (!b) { | |
| this.actionGroup.enable("download") | |
| } else { | |
| this.actionGroup.disable("download") | |
| } | |
| }, | |
| actionSearch: function(a) { | |
| if (Ext.isEmpty(a)) { | |
| this.getMsgBox().alert(this.searchtitle, _DT("search", "error_syste")); | |
| return | |
| } | |
| a.keyword = Ext.util.Format.trim(a.keyword); | |
| if (Ext.isEmpty(a.keyword)) { | |
| this.getMsgBox().alert(this.searchtitle, _DT("search", "error_search_key_empty")); | |
| return | |
| } | |
| if ("kad" === a.searchType && !SYNO.SDS.DownloadStation.aMule.Utils.IsKadSearchKeywordValid(a.keyword)) { | |
| this.getMsgBox().alert(this.searchtitle, _DT("search", "error_search_key_too_short")); | |
| return | |
| } | |
| this.createSearchTab(a) | |
| }, | |
| findSameSearchParams: function(d) { | |
| var c = this.tabPanel.items.items; | |
| var a; | |
| for (var b = 0; b < c.length; b++) { | |
| a = c[b].requestParams; | |
| if (a.keyword === d.keyword) { | |
| return b | |
| } | |
| } | |
| return false | |
| }, | |
| actionDownload: function() { | |
| var e = this.tabPanel.getActiveTab().getSelectionModel(); | |
| var b; | |
| var c = []; | |
| if (false === e.hasSelection()) { | |
| this.getMsgBox().alert(this.searchtitle, _DT("download", "download_warning_select_items")); | |
| return | |
| } | |
| b = e.getSelections(); | |
| for (var a = 0; a < b.length; a++) { | |
| c.push(b[a].get("file_id")) | |
| } | |
| var d = { | |
| file_id: c | |
| }; | |
| this.setStatusBusy(_DT("common", "loading")); | |
| SYNO.API.Request({ | |
| webapi: Ext.apply(this.webapiDownload, { | |
| params: d | |
| }), | |
| callback: this.onDownloadDone, | |
| scope: this | |
| }) | |
| }, | |
| onDownloadDone: function(e, b, d, a) { | |
| this.clearStatusBusy(); | |
| if (!e) { | |
| if (1917 === b.code) { | |
| this.appWin.getMsgBox().alert(this.title, _DT("download", "download_warning_select_share"), function() { | |
| var f = new SYNO.SDS.DownloadStation.Settings.Window({ | |
| defaultActivedFn: "SYNO.SDS.DownloadStation.Settings.aMuleLocation", | |
| owner: this.appWin | |
| }); | |
| f.open() | |
| }, this); | |
| return | |
| } | |
| var c = _DT("download", "download_add_link_error_title") + _DT("common", "colon"); | |
| c = c + "<br />" + SYNO.SDS.DownloadStation.Utils.getErrorString(b.code); | |
| this.getMsgBox().alert(this.title, c) | |
| } | |
| this.tabPanel.getActiveTab().store.reload() | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.aMule"); | |
| Ext.define("SYNO.SDS.DownloadStation.aMule.Main", { | |
| extend: "SYNO.SDS.DownloadStation.Main", | |
| constructor: function(a) { | |
| this.owner = a.owner; | |
| this.callParent([a]) | |
| }, | |
| getSearchField: function() { | |
| if (!this.gSearch) { | |
| this.gSearch = new SYNO.SDS.DownloadStation.aMule.SearchField({ | |
| itemId: "global_search", | |
| owner: this, | |
| width: 215, | |
| listeners: { | |
| scope: this, | |
| keypress: function(b, a) { | |
| if (a.getKey() == Ext.EventObject.ENTER) { | |
| this.onSearchFieldEnter(b) | |
| } | |
| } | |
| } | |
| }) | |
| } | |
| return this.gSearch | |
| }, | |
| onSearchFieldEnter: function(e) { | |
| var c = e.getValue().trim(); | |
| if (!c) { | |
| return | |
| } | |
| var a = ""; | |
| var d = Ext.util.Format.trim(c).toLowerCase(); | |
| var f = d.split(" "); | |
| for (var b = 0; b < f.length; b++) { | |
| if (Ext.util.Format.trim(f[b]).length < 1) { | |
| continue | |
| } | |
| if (SYNO.SDS.DownloadStation.aMule.Utils.isValidED2KLink("file", f[b])) { | |
| a = "ed2k://" + f[b].substr(7); | |
| break | |
| } | |
| } | |
| if (a) { | |
| this.checkDestSettingsBeforeAddTaskByURL(a, e, this.moduleCt.items.get(0).module.upperPanel.DLStore) | |
| } else { | |
| e.syncToAdvSearchPanel(); | |
| e.getAdvSearchPanel().onSearch(); | |
| e.focus() | |
| } | |
| }, | |
| actionSearch: function(a) { | |
| this.moduleList.selectModule("SYNO.SDS.DownloadStation.aMule.Search"); | |
| this.moduleList.actived.actionSearch(a) | |
| }, | |
| checkDestSettingsBeforeAddTaskByURL: function(c, d, b) { | |
| var e = SYNO.SDS.DownloadStation.aMule.Utils; | |
| var a = e.getEmuleDestination(); | |
| if (!Ext.isEmpty(a)) { | |
| this.addTaskByURL(c, a, d, b); | |
| return | |
| } | |
| this.setStatusBusy({ | |
| text: _T("common", "loading") | |
| }); | |
| this.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.Settings.Emule.Location", | |
| method: "get", | |
| version: 1, | |
| scope: this, | |
| callback: function(g, f) { | |
| this.clearStatusBusy(); | |
| if (!g) { | |
| e.showErrorMessages(this.appWin, f); | |
| return | |
| } | |
| e.setEmuleDestination(f.default_destination); | |
| if (Ext.isEmpty(f.default_destination)) { | |
| this.alertDestinationEmptyWithLaunchingChooser(this.appWin); | |
| return | |
| } | |
| this.addTaskByURL(c, f.default_destination, d, b) | |
| } | |
| }) | |
| }, | |
| addTaskByURL: function(c, b, d, a) { | |
| this.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.Task", | |
| method: "create", | |
| version: 2, | |
| params: { | |
| type: "url", | |
| url: [c], | |
| destination: b, | |
| create_list: false | |
| }, | |
| scope: this, | |
| callback: function(f, e) { | |
| if (!f) { | |
| SYNO.SDS.DownloadStation.aMule.Utils.showErrorMessages(this.appWin, e); | |
| return | |
| } | |
| a.reload(); | |
| d.reset() | |
| } | |
| }) | |
| }, | |
| alertDestinationEmptyWithLaunchingChooser: function(b, c, a) { | |
| b.getMsgBox().alert(_DT("tree", "node_emule"), _DT("download", "download_warning_select_share"), function() { | |
| if (Ext.isFunction(c)) { | |
| c.call(a) | |
| } | |
| this.launchEmuleShareChooser() | |
| }, this) | |
| }, | |
| launchEmuleShareChooser: function() { | |
| this.utils.chooseDestHandler({ | |
| owner: this.appWin, | |
| callback: function(c, b, a) { | |
| if (b) { | |
| this.applyEmuleShare(b.path.substr(1)) | |
| } | |
| c.close() | |
| }, | |
| callbackScope: this | |
| }) | |
| }, | |
| applyEmuleShare: function(a) { | |
| this.mask(_T("common", "saving")); | |
| this.sendWebAPI({ | |
| api: "SYNO.DownloadStation2.Settings.Emule.Location", | |
| method: "set", | |
| version: 1, | |
| params: { | |
| default_destination: a | |
| }, | |
| callback: this.onApplyEmuleShareDone, | |
| scope: this | |
| }) | |
| }, | |
| onApplyEmuleShareDone: function(d, b, c, a) { | |
| this.unmask(); | |
| if (!d) { | |
| this.appWin.getMsgBox().alert(this.title, SYNO.SDS.DownloadStation.Utils.getErrorString(b.code)); | |
| return | |
| } | |
| SYNO.SDS.DownloadStation.aMule.Utils.setEmuleDestination(c.default_destination) | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation"); | |
| Ext.define("SYNO.SDS.DownloadStation.Application", { | |
| extend: "SYNO.SDS.AppInstance", | |
| appWindowName: "SYNO.SDS.DownloadStation.MainWindow" | |
| }); | |
| var jsDebug = Ext.urlDecode(document.URL.split("?")[1]).jsDebug; | |
| Ext.define("SYNO.SDS.DownloadStation.MainWindow", { | |
| extend: "SYNO.SDS.AppWindow", | |
| constructor: function(a) { | |
| SYNO.SDS.DownloadStation.Window = this; | |
| this.webapiCompound = { | |
| api: "SYNO.Entry.Request", | |
| method: "request", | |
| version: 1, | |
| compound: { | |
| stopwhenerror: false | |
| } | |
| }; | |
| this.webapiModuleList = { | |
| api: "SYNO.DownloadStation2.Package.Module", | |
| method: "list", | |
| version: 2 | |
| }; | |
| this.webapiServiceGet = { | |
| api: "SYNO.DownloadStation2.Package.Service", | |
| method: "get", | |
| version: 2 | |
| }; | |
| this.appInstance = a.appInstance; | |
| var b = this.fillConfig(a); | |
| this.callParent([b]); | |
| this.setStatusBusy(); | |
| this.CheckServiceEnable() | |
| }, | |
| fillConfig: function(b) { | |
| var d = 830; | |
| var a = 510; | |
| var c = { | |
| layout: "fit", | |
| cls: "syno-dl-win", | |
| dsmStyle: "v5", | |
| minWidth: d, | |
| minHeight: a, | |
| boxMinHeight: a, | |
| boxMinWidth: d, | |
| width: 980, | |
| height: 580, | |
| html: "", | |
| border: false, | |
| plain: true, | |
| listeners: { | |
| scope: this, | |
| show: function() { | |
| if (this.tabPanel) { | |
| this.tabPanel.activeTab.fireEvent("activate") | |
| } | |
| }, | |
| hide: function() { | |
| if (this.tabPanel) { | |
| this.tabPanel.items.each(function(e) { | |
| e.fireEvent("deactivate") | |
| }) | |
| } | |
| }, | |
| close: function(e) { | |
| e.cascade(function(f) { | |
| if (Ext.isDefined(f.onCloseHandler)) { | |
| f.onCloseHandler() | |
| } | |
| }) | |
| } | |
| } | |
| }; | |
| Ext.apply(c, b); | |
| return c | |
| }, | |
| delayConstructor: function(a, d) { | |
| if (this.isDestroyed) { | |
| return | |
| } | |
| if (!this.rendered) { | |
| this.delayConstructor.defer(10, this, arguments); | |
| return | |
| } | |
| this.clearStatusBusy(); | |
| if (!a || !a.listItems || !a.listItems.length || 0 === a.listItems.length) { | |
| return | |
| } | |
| a.appWin = this; | |
| a.owner = this; | |
| this.tabPanel = new SYNO.SDS.DownloadStation.DownloadTab(a); | |
| a.owner = this.tabPanel; | |
| SYNO.SDS.DownloadStation.gData.amule_enabled = a.enable_emule || false; | |
| if (!jsDebug) { | |
| for (var c = 0; c < a.listItems.length; c++) { | |
| a.currentItem = a.listItems[c]; | |
| var b = this.getModule(a.listItems[c].fn, a); | |
| this.tabPanel.add(b) | |
| } | |
| } else { | |
| a.currentItem = a.listItems[0]; | |
| a.folder = "dlm"; | |
| this.tabPanel.add(new SYNO.SDS.DownloadStation.DLM.Main(a)); | |
| a.folder = "aMule"; | |
| a.currentItem = a.listItems[1]; | |
| this.tabPanel.add(new SYNO.SDS.DownloadStation.aMule.Main(a)) | |
| } | |
| this.removeAll(); | |
| this.add(this.tabPanel); | |
| this.doLayout() | |
| }, | |
| CheckServiceEnable: function() { | |
| var a = [this.webapiModuleList, this.webapiServiceGet]; | |
| SYNO.API.Request({ | |
| webapi: Ext.apply(this.webapiCompound, { | |
| compound: { | |
| params: a | |
| } | |
| }), | |
| callback: this.onCheckServiceEnable, | |
| scope: this | |
| }) | |
| }, | |
| onCheckServiceEnable: function(g, d, f, c) { | |
| if (!g) { | |
| this.CheckServiceEnable.defer(5000, this); | |
| return | |
| } | |
| if (d.has_fail) { | |
| this.CheckServiceEnable.defer(5000, this); | |
| return | |
| } | |
| var b; | |
| var e; | |
| Ext.each(d.result, function(i, h) { | |
| if (i.api === this.webapiModuleList.api) { | |
| b = i.data | |
| } else { | |
| if (i.api === this.webapiServiceGet.api) { | |
| e = i.data | |
| } | |
| } | |
| }, this); | |
| this.setServiceData(e); | |
| var a = b; | |
| Ext.apply(a, e); | |
| this.delayConstructor(a) | |
| }, | |
| setServiceData: function(a) { | |
| SYNO.SDS.DownloadStation.blUnzip = a.enable_unzip | |
| }, | |
| getModule: function(fn, cfg) { | |
| var FnObj; | |
| eval("FnObj = " + fn + ";"); | |
| FnObj.prototype.jsConfig = this.jsConfig; | |
| var module = new FnObj(cfg); | |
| return module | |
| } | |
| }); | |
| Ext.define("SYNO.SDS.DownloadStation.DownloadTab", { | |
| extend: "SYNO.SDS.Utils.TabPanel", | |
| constructor: function(a) { | |
| this.owner = a.owner; | |
| this.appWin = a.appWin; | |
| var b = { | |
| cls: "syno-dlm-tabpanel", | |
| deferredRender: false, | |
| activeTab: 0, | |
| border: false, | |
| headerCfg: { | |
| style: "display:none;" | |
| }, | |
| defaults: { | |
| hideMode: "offsets" | |
| }, | |
| listeners: { | |
| scope: this, | |
| tabchange: this.onTabChange | |
| }, | |
| items: [] | |
| }; | |
| Ext.apply(b, a); | |
| this.callParent([b]) | |
| }, | |
| onTmpCrashSettingClick: function() { | |
| if (!_S("is_admin")) { | |
| return | |
| } | |
| var a = new SYNO.SDS.DownloadStation.Settings.Window({ | |
| defaultActivedFn: "SYNO.SDS.DownloadStation.Settings.GlobalGen", | |
| owner: this.appWin | |
| }); | |
| a.open() | |
| }, | |
| onTabChange: function(d, b) { | |
| if (!Ext.isDefined(b.btnTabPanel)) { | |
| return | |
| } | |
| var a = SYNO.SDS.DownloadStation.gData.get("amule_enabled") || false; | |
| var c; | |
| if (Ext.isDefined(c = b.btnTabPanel.get("aMule"))) { | |
| c[!a ? "addClass" : "removeClass"]("syno-dl-tab-disabled") | |
| } | |
| }, | |
| setTabBtnDisabled: function(d, c) { | |
| for (var b = 0; b < this.listItems.length; b++) { | |
| var a = this.get(b).btnTabPanel.get(d); | |
| if (!a) { | |
| continue | |
| } | |
| if (c && this.items.indexOf(this.activeTab) == a.index) { | |
| this.setActiveTab(0) | |
| } | |
| a[c ? "addClass" : "removeClass"]("syno-dl-tab-disabled") | |
| } | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation"); | |
| SYNO.SDS.DownloadStation.Renderers = {}; | |
| Ext.apply(SYNO.SDS.DownloadStation.Renderers, { | |
| SizeRenderer: function(e, d, a, f, c, b) { | |
| if (0 === e) { | |
| return ("total_upload" === d.id) ? "" : _DT("download", "download_status_unknown") | |
| } | |
| return SYNO.SDS.DownloadStation.Utils.fileSize(e) | |
| }, | |
| RateRenderer: function(f, e, a, g, d, b) { | |
| var c = SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT; | |
| if (c.TASK_DOWNLOADING !== a.get("status") && c.TASK_SEEDING !== a.get("status")) { | |
| return "" | |
| } | |
| if (c.TASK_SEEDING === a.get("status") && "current_rate" === e.id) { | |
| return "" | |
| } | |
| if (0 === f) { | |
| return "0.00 KB/s" | |
| } | |
| return SYNO.SDS.DownloadStation.Renderers.SizeRenderer(f, e, a, g, d, b) + "/s" | |
| }, | |
| ProgressRenderer: function(e, d, a, f, c, b) { | |
| if (0 === e) { | |
| return _DT("download", "download_status_unknown") | |
| } | |
| return Ext.util.Format.number(e, "0.0") + "%" | |
| }, | |
| StatusRenderer: function(a, e, c, g, i, h) { | |
| var f = SYNO.SDS.DownloadStation.Utils.TASK_STATUS_INT; | |
| var b = SYNO.SDS.DownloadStation.Utils.getTaskStatusStr(c.data); | |
| var d = Ext.util.Format.htmlEncode(b); | |
| e.attr = 'ext:qtip="' + Ext.util.Format.htmlEncode(d) + '"'; | |
| if (SYNO.SDS.DownloadStation.Utils.isTaskErrorStatus(a)) { | |
| e.attr += 'style="color:#E64040;"' | |
| } else { | |
| if (f.TASK_CAPTCHA_NEEDED === a) { | |
| e.attr += 'style="color:#E64040; cursor:pointer; cursor:hand;"' | |
| } else { | |
| if (f.TASK_FINISHED === a) { | |
| e.attr += 'style="color:#009E05;"' | |
| } else { | |
| if (f.TASK_FINISHING === a || f.TASK_DOWNLOADING === a || f.TASK_SEEDING === a) { | |
| e.attr += 'style="color:#057FEB;"' | |
| } else { | |
| if (f.TASK_WAITING === a) { | |
| e.attr += 'style="color:#F58414;"' | |
| } | |
| } | |
| } | |
| } | |
| } | |
| return d | |
| }, | |
| fileNameWithStatusRenderer: function(g, e, a, d, f, b) { | |
| var c = Ext.util.Format.htmlEncode(g); | |
| e.attr = 'ext:qtip="' + Ext.util.Format.htmlEncode(c) + '"'; | |
| e.css += " " + SYNO.SDS.DownloadStation.Utils.getStatusCss(a.data.status); | |
| return c | |
| } | |
| }); | |
| Ext.ns("SYNO.SDS.DownloadStation.aMule"); | |
| Ext.define("SYNO.SDS.DownloadStation.aMule.SearchField", { | |
| extend: "SYNO.ux.SearchField", | |
| constructor: function(a) { | |
| this.callParent([this.fillConfig(a || {})]) | |
| }, | |
| fillConfig: function(a) { | |
| var b = { | |
| ctCls: "syno-ux-textfilter syno-dl-toolbar-amule-search", | |
| emptyText: _DT("download", "quickurl_hint"), | |
| enableKeyEvents: true | |
| }; | |
| Ext.apply(b, a); | |
| return b | |
| }, | |
| onRender: function(b, a) { | |
| this.doc = Ext.isIE ? Ext.getBody() : Ext.getDoc(); | |
| Ext.form.TriggerField.superclass.onRender.call(this, b, a); | |
| this.wrap = this.el.wrap({ | |
| tag: "div", | |
| cls: "x-form-field-wrap x-form-field-trigger-wrap", | |
| style: "display:block;width:100%;border-collapse:collapse;table-layout: fixed;margin-right: 1px;", | |
| cn: [{ | |
| tag: "div", | |
| cls: "x-form-field-wrap-center-img", | |
| style: "display:inline-block;vertical-align:top;" | |
| }] | |
| }); | |
| this.inputWrap = this.el.wrap({ | |
| tag: "div", | |
| style: "display:inline-block;vertical-align:top; width: unset", | |
| cls: "syno-dl-amule-search-input-box" | |
| }); | |
| this.trigger = this.inputWrap.createChild(this.triggerConfig || { | |
| tag: "img", | |
| src: Ext.BLANK_IMAGE_URL, | |
| alt: "", | |
| cls: "x-form-trigger " + this.triggerClass, | |
| style: "display:inline-block;vertical-align:top;" | |
| }); | |
| this.searchtriggerfocusEl = this.wrap.createChild({ | |
| tag: "button", | |
| cls: "syno-search-condition-focus-el", | |
| "aria-label": _JSLIBSTR("uicommon", "advanced_search") | |
| }); | |
| this.initTrigger(); | |
| this.searchtrigger = this.wrap.child(".x-form-field-wrap-center-img"); | |
| this.mon(this.searchtrigger, "click", this.onSearchTriggerClick, this); | |
| this.mon(this.searchtriggerfocusEl, "click", this.onSearchTriggerClick, this); | |
| if (!this.width) { | |
| this.wrap.setWidth(this.el.getWidth() + this.trigger.getWidth()) | |
| } | |
| this.resizeEl = this.positionEl = this.wrap; | |
| this.el.setWidth(this.el.getWidth() - this.trigger.getWidth()); | |
| this.container.addClass("syno-ux-searchfield") | |
| }, | |
| getAdvSearchPanel: function() { | |
| if (!this.advSearchPanel) { | |
| this.advSearchPanel = new SYNO.SDS.DownloadStation.aMule.AdvancedSearchPanel({ | |
| owner: this | |
| }) | |
| } | |
| return this.advSearchPanel | |
| }, | |
| getMenu: function() { | |
| if (!this.menu) { | |
| this.menu = new SYNO.ux.Menu({ | |
| cls: "syno-dl-amule-search-menu", | |
| items: this.getAdvSearchPanel() | |
| }); | |
| this.menu.on("beforeshow", function() { | |
| this.syncToAdvSearchPanel() | |
| }, this); | |
| this.menu.on("show", function() { | |
| this.advSearchPanel.keywordField.clearInvalid(); | |
| this.advSearchPanel.keywordField.focus() | |
| }, this) | |
| } | |
| return this.menu | |
| }, | |
| syncToAdvSearchPanel: function() { | |
| var a = this.advSearchPanel.keywordField; | |
| a.setValue(this.getValue()) | |
| }, | |
| hideMenu: function() { | |
| this.menu.hide() | |
| }, | |
| reset: function() { | |
| this.callParent() | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment