From c7db93e9543a46d18cf43d915139283b481e3756 Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Sun, 12 Jul 2009 23:33:54 +0000 Subject: [PATCH] rebuild docs --- deluge/ui/web/docs/files.html | 2 +- deluge/ui/web/docs/index.html | 2 +- deluge/ui/web/docs/symbols/Deluge.Events.html | 2 +- .../web/docs/symbols/Deluge.Formatters.html | 2 +- deluge/ui/web/docs/symbols/Deluge.Keys.html | 2 +- .../docs/symbols/Deluge.OptionsManager.html | 2 +- deluge/ui/web/docs/symbols/Deluge.UI.html | 2 +- .../docs/symbols/Ext.deluge.TorrentGrid.html | 2 +- .../docs/symbols/Ext.ux.FullProgressBar.html | 2 +- deluge/ui/web/docs/symbols/_global_.html | 2 +- .../web/docs/symbols/src/Deluge.Add.js.html | 852 +++++++++++------- .../docs/symbols/src/Deluge.Client.js.html | 10 +- .../src/Deluge.ConnectionManager.js.html | 701 +++++++------- .../src/Deluge.Details.Options.js.html | 12 +- .../symbols/src/Deluge.OptionsManager.js.html | 327 +++---- .../symbols/src/ext-extensions-debug.js.html | 38 +- 16 files changed, 1099 insertions(+), 861 deletions(-) diff --git a/deluge/ui/web/docs/files.html b/deluge/ui/web/docs/files.html index 977edadb7..3443294c3 100644 --- a/deluge/ui/web/docs/files.html +++ b/deluge/ui/web/docs/files.html @@ -644,7 +644,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 16 2009 19:13:09 GMT+0100 (BST) + Documentation generated by JsDoc Toolkit 2.1.0 on Mon Jul 13 2009 00:34:03 GMT+0100 (BST)
\ No newline at end of file diff --git a/deluge/ui/web/docs/index.html b/deluge/ui/web/docs/index.html index bff485210..3fab6c1b4 100644 --- a/deluge/ui/web/docs/index.html +++ b/deluge/ui/web/docs/index.html @@ -260,7 +260,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 16 2009 19:13:09 GMT+0100 (BST) + Documentation generated by JsDoc Toolkit 2.1.0 on Mon Jul 13 2009 00:34:03 GMT+0100 (BST)
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/Deluge.Events.html b/deluge/ui/web/docs/symbols/Deluge.Events.html index bbfdf85be..3caec31c4 100644 --- a/deluge/ui/web/docs/symbols/Deluge.Events.html +++ b/deluge/ui/web/docs/symbols/Deluge.Events.html @@ -306,7 +306,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 16 2009 19:13:09 GMT+0100 (BST) + Documentation generated by JsDoc Toolkit 2.1.0 on Mon Jul 13 2009 00:34:03 GMT+0100 (BST)
diff --git a/deluge/ui/web/docs/symbols/Deluge.Formatters.html b/deluge/ui/web/docs/symbols/Deluge.Formatters.html index 735bc27c9..ce8ef8af4 100644 --- a/deluge/ui/web/docs/symbols/Deluge.Formatters.html +++ b/deluge/ui/web/docs/symbols/Deluge.Formatters.html @@ -592,7 +592,7 @@ if seconds < 0
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 16 2009 19:13:09 GMT+0100 (BST) + Documentation generated by JsDoc Toolkit 2.1.0 on Mon Jul 13 2009 00:34:03 GMT+0100 (BST)
diff --git a/deluge/ui/web/docs/symbols/Deluge.Keys.html b/deluge/ui/web/docs/symbols/Deluge.Keys.html index 3f5228c7b..a47681426 100644 --- a/deluge/ui/web/docs/symbols/Deluge.Keys.html +++ b/deluge/ui/web/docs/symbols/Deluge.Keys.html @@ -528,7 +528,7 @@ by Deluge.Keys.Grid.
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 16 2009 19:13:09 GMT+0100 (BST) + Documentation generated by JsDoc Toolkit 2.1.0 on Mon Jul 13 2009 00:34:03 GMT+0100 (BST)
diff --git a/deluge/ui/web/docs/symbols/Deluge.OptionsManager.html b/deluge/ui/web/docs/symbols/Deluge.OptionsManager.html index 24f9293b5..a24b10c58 100644 --- a/deluge/ui/web/docs/symbols/Deluge.OptionsManager.html +++ b/deluge/ui/web/docs/symbols/Deluge.OptionsManager.html @@ -306,7 +306,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 16 2009 19:13:09 GMT+0100 (BST) + Documentation generated by JsDoc Toolkit 2.1.0 on Mon Jul 13 2009 00:34:03 GMT+0100 (BST)
diff --git a/deluge/ui/web/docs/symbols/Deluge.UI.html b/deluge/ui/web/docs/symbols/Deluge.UI.html index 387470c49..6fbb60008 100644 --- a/deluge/ui/web/docs/symbols/Deluge.UI.html +++ b/deluge/ui/web/docs/symbols/Deluge.UI.html @@ -523,7 +523,7 @@ and set up various events that the UI will utilise.
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 16 2009 19:13:09 GMT+0100 (BST) + Documentation generated by JsDoc Toolkit 2.1.0 on Mon Jul 13 2009 00:34:03 GMT+0100 (BST)
diff --git a/deluge/ui/web/docs/symbols/Ext.deluge.TorrentGrid.html b/deluge/ui/web/docs/symbols/Ext.deluge.TorrentGrid.html index a18fb5e20..39a348341 100644 --- a/deluge/ui/web/docs/symbols/Ext.deluge.TorrentGrid.html +++ b/deluge/ui/web/docs/symbols/Ext.deluge.TorrentGrid.html @@ -319,7 +319,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 16 2009 19:13:09 GMT+0100 (BST) + Documentation generated by JsDoc Toolkit 2.1.0 on Mon Jul 13 2009 00:34:03 GMT+0100 (BST)
diff --git a/deluge/ui/web/docs/symbols/Ext.ux.FullProgressBar.html b/deluge/ui/web/docs/symbols/Ext.ux.FullProgressBar.html index 915963149..567797cad 100644 --- a/deluge/ui/web/docs/symbols/Ext.ux.FullProgressBar.html +++ b/deluge/ui/web/docs/symbols/Ext.ux.FullProgressBar.html @@ -319,7 +319,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 16 2009 19:13:09 GMT+0100 (BST) + Documentation generated by JsDoc Toolkit 2.1.0 on Mon Jul 13 2009 00:34:03 GMT+0100 (BST)
diff --git a/deluge/ui/web/docs/symbols/_global_.html b/deluge/ui/web/docs/symbols/_global_.html index 7a2d6716f..640ed6ca2 100644 --- a/deluge/ui/web/docs/symbols/_global_.html +++ b/deluge/ui/web/docs/symbols/_global_.html @@ -847,7 +847,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 16 2009 19:13:08 GMT+0100 (BST) + Documentation generated by JsDoc Toolkit 2.1.0 on Mon Jul 13 2009 00:34:03 GMT+0100 (BST)
diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Add.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Add.js.html index ff4b19b68..b912b7ea5 100644 --- a/deluge/ui/web/docs/symbols/src/Deluge.Add.js.html +++ b/deluge/ui/web/docs/symbols/src/Deluge.Add.js.html @@ -41,349 +41,515 @@ 34 35 Ext.namespace('Ext.deluge.add'); 36 Ext.deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, { - 37 - 38 constructor: function(config) { - 39 config = Ext.apply({ - 40 region: 'south', - 41 margins: '5 5 5 5', - 42 activeTab: 0, - 43 height: 220 - 44 }, config); - 45 Ext.deluge.add.OptionsPanel.superclass.constructor.call(this, config); - 46 }, - 47 - 48 initComponent: function() { - 49 Ext.deluge.add.OptionsPanel.superclass.initComponent.call(this); - 50 this.files = this.add(new Ext.tree.ColumnTree({ - 51 layout: 'fit', - 52 title: _('Files'), - 53 rootVisible: false, - 54 autoScroll: true, - 55 height: 170, - 56 border: false, - 57 animate: false, - 58 - 59 columns: [{ - 60 header: _('Filename'), - 61 width: 275, - 62 dataIndex: 'filename' - 63 },{ - 64 header: _('Size'), - 65 width: 80, - 66 dataIndex: 'size' - 67 }], - 68 - 69 root: new Ext.tree.AsyncTreeNode({ - 70 text: 'Files' - 71 }) - 72 })); - 73 new Ext.tree.TreeSorter(this.files, { - 74 folderSort: true - 75 }); - 76 - 77 this.form = this.add({ - 78 xtype: 'form', - 79 labelWidth: 1, - 80 frame: false, - 81 title: _('Options'), - 82 bodyStyle: 'padding: 5px;', - 83 border: false, - 84 - 85 - 86 items: [{ - 87 xtype: 'fieldset', - 88 title: _('Download Location'), - 89 border: false, - 90 defaultType: 'textfield', - 91 labelWidth: 1, - 92 items: [{ - 93 fieldLabel: '', - 94 labelSeperator: '', - 95 name: 'download_location', - 96 width: 330 - 97 }] - 98 }] - 99 }); -100 }, -101 -102 clear: function() { -103 this.clearFiles(); -104 }, -105 -106 clearFiles: function() { -107 var root = this.files.getRootNode(); -108 if (!root.hasChildNodes()) return; -109 root.cascade(function(node) { -110 if (!node.parentNode || !node.getOwnerTree()) return; -111 node.remove(); -112 }); -113 }, -114 -115 getDefaults: function() { -116 var keys = [ -117 'add_paused', -118 'compact_allocation', -119 'download_location', -120 'max_connections_per_torrent', -121 'max_download_speed_per_torrent', -122 'max_upload_slots_per_torrent', -123 'max_upload_speed_per_torrent', -124 'prioritize_first_last_pieces' -125 ] -126 Deluge.Client.core.get_config_values(keys, { -127 success: function(config) { -128 this.defaults = config; -129 for (var key in config) { -130 var field = this.form.findField(key); -131 if (!field) return; -132 field.setValue(config[key]); -133 } -134 var field = this.form.findField('compact_allocation'); -135 if (config['compact_allocation']) { -136 field.items.get('compact_allocation_true').setValue(true); -137 field.items.get('compact_allocation_false').setValue(false); -138 } else { -139 field.items.get('compact_allocation_false').setValue(true); -140 field.items.get('compact_allocation_true').setValue(false); -141 } -142 }, -143 scope: this -144 }); -145 } -146 }); -147 -148 Ext.deluge.add.Window = Ext.extend(Ext.Window, { -149 initComponent: function() { -150 Ext.deluge.add.Window.superclass.initComponent.call(this); -151 this.addEvents( -152 'beforeadd', -153 'add' -154 ); -155 }, -156 -157 createTorrentId: function() { -158 return new Date().getTime(); -159 } -160 }); -161 -162 Ext.deluge.add.AddWindow = Ext.extend(Ext.deluge.add.Window, { -163 -164 torrents: {}, -165 -166 constructor: function(config) { -167 config = Ext.apply({ -168 title: _('Add Torrents'), -169 layout: 'border', -170 width: 470, -171 height: 450, -172 bodyStyle: 'padding: 10px 5px;', -173 buttonAlign: 'right', -174 closeAction: 'hide', -175 closable: true, -176 plain: true, -177 iconCls: 'x-deluge-add-window-icon' -178 }, config); -179 Ext.deluge.add.AddWindow.superclass.constructor.call(this, config); -180 }, -181 -182 initComponent: function() { -183 Ext.deluge.add.AddWindow.superclass.initComponent.call(this); -184 -185 this.addButton(_('Cancel'), this.onCancel, this); -186 this.addButton(_('Add'), this.onAdd, this); -187 -188 function torrentRenderer(value, p, r) { -189 if (r.data['info_hash']) { -190 return String.format('<div class="x-deluge-add-torrent-name">{0}</div>', value); -191 } else { -192 return String.format('<div class="x-deluge-add-torrent-name-loading">{0}</div>', value); -193 } -194 } -195 -196 this.grid = this.add({ -197 xtype: 'grid', -198 region: 'center', -199 store: new Ext.data.SimpleStore({ -200 fields: [ -201 {name: 'info_hash', mapping: 1}, -202 {name: 'text', mapping: 2} -203 ], -204 id: 0 -205 }), -206 columns: [{ -207 id: 'torrent', -208 width: 150, -209 sortable: true, -210 renderer: torrentRenderer, -211 dataIndex: 'text' -212 }], -213 stripeRows: true, -214 selModel: new Ext.grid.RowSelectionModel({ -215 singleSelect: true, -216 listeners: { -217 'rowselect': { -218 fn: this.onSelect, -219 scope: this -220 } -221 } -222 }), -223 hideHeaders: true, -224 autoExpandColumn: 'torrent', -225 deferredRender: false, -226 autoScroll: true, -227 margins: '5 5 5 5', -228 bbar: new Ext.Toolbar({ -229 items: [{ -230 id: 'file', -231 cls: 'x-btn-text-icon', -232 iconCls: 'x-deluge-add-file', -233 text: _('File'), -234 handler: this.onFile, -235 scope: this -236 }, { -237 id: 'url', -238 cls: 'x-btn-text-icon', -239 text: _('Url'), -240 icon: '/icons/add_url.png', -241 handler: this.onUrl, -242 scope: this -243 }, { -244 id: 'infohash', -245 cls: 'x-btn-text-icon', -246 text: _('Infohash'), -247 icon: '/icons/add_magnet.png', -248 disabled: true -249 }, '->', { -250 id: 'remove', -251 cls: 'x-btn-text-icon', -252 text: _('Remove'), -253 icon: '/icons/remove.png', -254 handler: this.onRemove, -255 scope: this -256 }] -257 }) -258 }); -259 -260 this.options = this.add(new Ext.deluge.add.OptionsPanel()); -261 this.on('show', this.onShow, this); + 37 + 38 torrents: {}, + 39 + 40 constructor: function(config) { + 41 config = Ext.apply({ + 42 region: 'south', + 43 margins: '5 5 5 5', + 44 activeTab: 0, + 45 height: 220 + 46 }, config); + 47 Ext.deluge.add.OptionsPanel.superclass.constructor.call(this, config); + 48 }, + 49 + 50 initComponent: function() { + 51 Ext.deluge.add.OptionsPanel.superclass.initComponent.call(this); + 52 this.files = this.add(new Ext.tree.ColumnTree({ + 53 layout: 'fit', + 54 title: _('Files'), + 55 rootVisible: false, + 56 autoScroll: true, + 57 height: 170, + 58 border: false, + 59 animate: false, + 60 + 61 columns: [{ + 62 header: _('Filename'), + 63 width: 275, + 64 dataIndex: 'filename' + 65 },{ + 66 header: _('Size'), + 67 width: 80, + 68 dataIndex: 'size' + 69 }], + 70 + 71 root: new Ext.tree.AsyncTreeNode({ + 72 text: 'Files' + 73 }) + 74 })); + 75 new Ext.tree.TreeSorter(this.files, { + 76 folderSort: true + 77 }); + 78 + 79 this.optionsManager = new Deluge.OptionsManager({ + 80 defaults: { + 81 'add_paused': false, + 82 'compact_allocation': false, + 83 'download_location': '', + 84 'max_connections_per_torrent': -1, + 85 'max_download_speed_per_torrent': -1, + 86 'max_upload_slots_per_torrent': -1, + 87 'max_upload_speed_per_torrent': -1, + 88 'prioritize_first_last_pieces': false, + 89 'file_priorities': [] + 90 } + 91 }); + 92 + 93 this.form = this.add({ + 94 xtype: 'form', + 95 labelWidth: 1, + 96 title: _('Options'), + 97 bodyStyle: 'padding: 5px;', + 98 border: false, + 99 height: 170 +100 }); +101 +102 var fieldset = this.form.add({ +103 xtype: 'fieldset', +104 title: _('Download Location'), +105 border: false, +106 autoHeight: true, +107 defaultType: 'textfield', +108 labelWidth: 1, +109 fieldLabel: '' +110 }); +111 this.optionsManager.bind('download_location', fieldset.add({ +112 fieldLabel: '', +113 name: 'download_location', +114 width: 400, +115 labelSeparator: '' +116 })); +117 +118 var panel = this.form.add({ +119 border: false, +120 layout: 'column', +121 defaultType: 'fieldset' +122 }); +123 fieldset = panel.add({ +124 title: _('Allocation'), +125 border: false, +126 autoHeight: true, +127 defaultType: 'radio', +128 width: 100 +129 }); +130 +131 this.optionsManager.bind('compact_allocation', fieldset.add({ +132 xtype: 'radiogroup', +133 columns: 1, +134 vertical: true, +135 labelSeparator: '', +136 items: [{ +137 name: 'compact_allocation', +138 value: false, +139 inputValue: false, +140 boxLabel: _('Full'), +141 fieldLabel: '', +142 labelSeparator: '' +143 }, { +144 name: 'compact_allocation', +145 value: true, +146 inputValue: true, +147 boxLabel: _('Compact'), +148 fieldLabel: '', +149 labelSeparator: '', +150 }] +151 })); +152 +153 fieldset = panel.add({ +154 title: _('Bandwidth'), +155 border: false, +156 autoHeight: true, +157 labelWidth: 100, +158 width: 200, +159 defaultType: 'uxspinner' +160 }); +161 this.optionsManager.bind('max_download_speed_per_torrent', fieldset.add({ +162 fieldLabel: _('Max Down Speed'), +163 /*labelStyle: 'margin-left: 10px',*/ +164 name: 'max_download_speed_per_torrent', +165 width: 60 +166 })); +167 this.optionsManager.bind('max_upload_speed_per_torrent', fieldset.add({ +168 fieldLabel: _('Max Up Speed'), +169 /*labelStyle: 'margin-left: 10px',*/ +170 name: 'max_upload_speed_per_torrent', +171 width: 60 +172 })); +173 this.optionsManager.bind('max_connections_per_torrent', fieldset.add({ +174 fieldLabel: _('Max Connections'), +175 /*labelStyle: 'margin-left: 10px',*/ +176 name: 'max_connections_per_torrent', +177 width: 60 +178 })); +179 this.optionsManager.bind('max_upload_slots_per_torrent', fieldset.add({ +180 fieldLabel: _('Max Upload Slots'), +181 /*labelStyle: 'margin-left: 10px',*/ +182 name: 'max_upload_slots_per_torrent', +183 width: 60 +184 })); +185 +186 fieldset = panel.add({ +187 title: _('General'), +188 border: false, +189 autoHeight: true, +190 defaultType: 'checkbox' +191 }); +192 this.optionsManager.bind('add_paused', fieldset.add({ +193 name: 'add_paused', +194 boxLabel: _('Add In Paused State'), +195 fieldLabel: '', +196 labelSeparator: '', +197 })); +198 this.optionsManager.bind('prioritize_first_last_pieces', fieldset.add({ +199 name: 'prioritize_first_last_pieces', +200 boxLabel: _('Prioritize First/Last Pieces'), +201 fieldLabel: '', +202 labelSeparator: '', +203 })); +204 +205 this.form.on('render', this.onFormRender, this); +206 this.form.disable(); +207 }, +208 +209 onFormRender: function(form) { +210 form.layout = new Ext.layout.FormLayout(); +211 form.layout.setContainer(form); +212 form.doLayout(); +213 +214 this.optionsManager.changeId(null); +215 }, +216 +217 addTorrent: function(torrent) { +218 this.torrents[torrent['info_hash']] = torrent; +219 var fileIndexes = {}; +220 this.walkFileTree(torrent['files_tree'], function(filename, type, entry, parent) { +221 if (type != 'file') return; +222 fileIndexes[entry[0]] = entry[2]; +223 }, this); +224 +225 var priorities = []; +226 Ext.each(Ext.keys(fileIndexes), function(index) { +227 priorities[index] = fileIndexes[index]; +228 }); +229 this.optionsManager.set(torrent['info_hash'], 'file_priorities', priorities); +230 }, +231 +232 clear: function() { +233 this.clearFiles(); +234 }, +235 +236 clearFiles: function() { +237 var root = this.files.getRootNode(); +238 if (!root.hasChildNodes()) return; +239 root.cascade(function(node) { +240 if (!node.parentNode || !node.getOwnerTree()) return; +241 node.remove(); +242 }); +243 }, +244 +245 getDefaults: function() { +246 var keys = ['add_paused','compact_allocation','download_location', +247 'max_connections_per_torrent','max_download_speed_per_torrent', +248 'max_upload_slots_per_torrent','max_upload_speed_per_torrent', +249 'prioritize_first_last_pieces']; +250 +251 Deluge.Client.core.get_config_values(keys, { +252 success: function(config) { +253 config['file_priorities'] = []; +254 this.optionsManager.defaults = config; +255 }, +256 scope: this +257 }); +258 }, +259 +260 getFilename: function(torrentId) { +261 return this.torrents[torrentId]['filename']; 262 }, 263 -264 clear: function() { -265 this.torrents = {}; -266 this.grid.getStore().removeAll(); -267 this.options.clear(); -268 }, -269 -270 onAdd: function() { -271 torrents = []; -272 for (var id in this.torrents) { -273 var info = this.torrents[id]; -274 torrents.push({ -275 path: info['filename'], -276 options: {} -277 }); -278 } -279 Deluge.Client.web.add_torrents(torrents, { -280 success: function(result) { -281 } -282 }) -283 this.clear(); -284 this.hide(); -285 }, -286 -287 onCancel: function() { -288 this.clear(); -289 this.hide(); -290 }, -291 -292 onFile: function() { -293 this.file.show(); -294 }, -295 -296 onRemove: function() { -297 var selection = this.grid.getSelectionModel(); -298 if (!selection.hasSelection()) return; -299 var torrent = selection.getSelected(); -300 -301 delete this.torrents[torrent.id]; -302 this.grid.getStore().remove(torrent); -303 this.options.clear(); -304 }, -305 -306 onSelect: function(selModel, rowIndex, record) { -307 var torrentInfo = this.torrents[record.get('info_hash')]; -308 -309 function walk(files, parent) { -310 for (var file in files) { -311 var item = files[file]; -312 -313 if (Ext.type(item) == 'object') { -314 var child = new Ext.tree.TreeNode({ -315 text: file -316 }); -317 walk(item, child); -318 parent.appendChild(child); -319 } else { -320 parent.appendChild(new Ext.tree.TreeNode({ -321 filename: file, -322 text: file, // this needs to be here for sorting reasons -323 size: fsize(item[0]), -324 leaf: true, -325 checked: item[1], -326 iconCls: 'x-deluge-file', -327 uiProvider: Ext.tree.ColumnNodeUI -328 })); -329 } -330 } -331 } -332 -333 this.options.clearFiles(); -334 var root = this.options.files.getRootNode(); -335 walk(torrentInfo['files_tree'], root); -336 root.firstChild.expand(); -337 }, -338 -339 onShow: function() { -340 if (!this.url) { -341 this.url = new Ext.deluge.add.UrlWindow(); -342 this.url.on('beforeadd', this.onTorrentBeforeAdd, this); -343 this.url.on('add', this.onTorrentAdd, this); -344 } -345 -346 if (!this.file) { -347 this.file = new Ext.deluge.add.FileWindow(); -348 this.file.on('beforeadd', this.onTorrentBeforeAdd, this); -349 this.file.on('add', this.onTorrentAdd, this); -350 } -351 }, -352 -353 onTorrentBeforeAdd: function(torrentId, text) { -354 var store = this.grid.getStore(); -355 store.loadData([[torrentId, null, text]], true); -356 }, +264 getOptions: function(torrentId) { +265 var options = this.optionsManager.get(torrentId); +266 Ext.each(options['file_priorities'], function(priority, index) { +267 options['file_priorities'][index] = (priority) ? 1 : 0; +268 }); +269 return options; +270 }, +271 +272 setTorrent: function(torrentId) { +273 this.torrentId = torrentId; +274 this.optionsManager.changeId(torrentId); +275 +276 this.clearFiles(); +277 var root = this.files.getRootNode(); +278 var priorities = this.optionsManager.get(this.torrentId, 'file_priorities'); +279 +280 this.walkFileTree(this.torrents[torrentId]['files_tree'], function(filename, type, entry, parent) { +281 if (type == 'dir') { +282 var folder = new Ext.tree.TreeNode({ +283 text: filename, +284 checked: true +285 }); +286 folder.on('checkchange', this.onFolderCheck, this); +287 parent.appendChild(folder); +288 return folder; +289 } else { +290 var node = new Ext.tree.TreeNode({ +291 filename: filename, +292 fileindex: entry[0], +293 text: filename, // this needs to be here for sorting reasons +294 size: fsize(entry[1]), +295 leaf: true, +296 checked: priorities[entry[0]], +297 iconCls: 'x-deluge-file', +298 uiProvider: Ext.tree.ColumnNodeUI +299 }); +300 node.on('checkchange', this.onNodeCheck, this); +301 parent.appendChild(node); +302 } +303 }, this, root); +304 root.firstChild.expand(); +305 }, +306 +307 walkFileTree: function(files, callback, scope, parent) { +308 for (var filename in files) { +309 var entry = files[filename]; +310 var type = (Ext.type(entry) == 'object') ? 'dir' : 'file'; +311 +312 if (scope) { +313 var ret = callback.apply(scope, [filename, type, entry, parent]); +314 } else { +315 var ret = callback(filename, type, entry, parent); +316 } +317 +318 if (type == 'dir') this.walkFileTree(entry, callback, scope, ret); +319 } +320 }, +321 +322 onFolderCheck: function(node, checked) { +323 var priorities = this.optionsManager.get(this.torrentId, 'file_priorities'); +324 node.cascade(function(child) { +325 if (!child.ui.checkbox) { +326 child.attributes.checked = checked; +327 } else { +328 child.ui.checkbox.checked = checked; +329 } +330 priorities[child.attributes.fileindex] = checked; +331 }, this); +332 this.optionsManager.update(this.torrentId, 'file_priorities', priorities); +333 }, +334 +335 onNodeCheck: function(node, checked) { +336 var priorities = this.optionsManager.get(this.torrentId, 'file_priorities'); +337 priorities[node.attributes.fileindex] = checked; +338 this.optionsManager.update(this.torrentId, 'file_priorities', priorities); +339 } +340 }); +341 +342 Ext.deluge.add.Window = Ext.extend(Ext.Window, { +343 initComponent: function() { +344 Ext.deluge.add.Window.superclass.initComponent.call(this); +345 this.addEvents( +346 'beforeadd', +347 'add' +348 ); +349 }, +350 +351 createTorrentId: function() { +352 return new Date().getTime(); +353 } +354 }); +355 +356 Ext.deluge.add.AddWindow = Ext.extend(Ext.deluge.add.Window, { 357 -358 onTorrentAdd: function(torrentId, info) { -359 if (!info) { -360 Ext.MessageBox.show({ -361 title: _('Error'), -362 msg: _('Not a valid torrent'), -363 buttons: Ext.MessageBox.OK, -364 modal: false, -365 icon: Ext.MessageBox.ERROR, -366 iconCls: 'x-deluge-icon-error' -367 }); -368 return; -369 } -370 -371 var r = this.grid.getStore().getById(torrentId); -372 r.set('info_hash', info['info_hash']); -373 r.set('text', info['name']); -374 this.grid.getStore().commitChanges(); -375 this.torrents[info['info_hash']] = info; -376 }, -377 -378 onUrl: function(button, event) { -379 this.url.show(); -380 } -381 }); -382 Deluge.Add = new Ext.deluge.add.AddWindow(); \ No newline at end of file +358 constructor: function(config) { +359 config = Ext.apply({ +360 title: _('Add Torrents'), +361 layout: 'border', +362 width: 470, +363 height: 450, +364 bodyStyle: 'padding: 10px 5px;', +365 buttonAlign: 'right', +366 closeAction: 'hide', +367 closable: true, +368 plain: true, +369 iconCls: 'x-deluge-add-window-icon' +370 }, config); +371 Ext.deluge.add.AddWindow.superclass.constructor.call(this, config); +372 }, +373 +374 initComponent: function() { +375 Ext.deluge.add.AddWindow.superclass.initComponent.call(this); +376 +377 this.addButton(_('Cancel'), this.onCancel, this); +378 this.addButton(_('Add'), this.onAdd, this); +379 +380 function torrentRenderer(value, p, r) { +381 if (r.data['info_hash']) { +382 return String.format('<div class="x-deluge-add-torrent-name">{0}</div>', value); +383 } else { +384 return String.format('<div class="x-deluge-add-torrent-name-loading">{0}</div>', value); +385 } +386 } +387 +388 this.grid = this.add({ +389 xtype: 'grid', +390 region: 'center', +391 store: new Ext.data.SimpleStore({ +392 fields: [ +393 {name: 'info_hash', mapping: 1}, +394 {name: 'text', mapping: 2} +395 ], +396 id: 0 +397 }), +398 columns: [{ +399 id: 'torrent', +400 width: 150, +401 sortable: true, +402 renderer: torrentRenderer, +403 dataIndex: 'text' +404 }], +405 stripeRows: true, +406 selModel: new Ext.grid.RowSelectionModel({ +407 singleSelect: true, +408 listeners: { +409 'rowselect': { +410 fn: this.onSelect, +411 scope: this +412 } +413 } +414 }), +415 hideHeaders: true, +416 autoExpandColumn: 'torrent', +417 deferredRender: false, +418 autoScroll: true, +419 margins: '5 5 5 5', +420 bbar: new Ext.Toolbar({ +421 items: [{ +422 id: 'file', +423 cls: 'x-btn-text-icon', +424 iconCls: 'x-deluge-add-file', +425 text: _('File'), +426 handler: this.onFile, +427 scope: this +428 }, { +429 id: 'url', +430 cls: 'x-btn-text-icon', +431 text: _('Url'), +432 icon: '/icons/add_url.png', +433 handler: this.onUrl, +434 scope: this +435 }, { +436 id: 'infohash', +437 cls: 'x-btn-text-icon', +438 text: _('Infohash'), +439 icon: '/icons/add_magnet.png', +440 disabled: true +441 }, '->', { +442 id: 'remove', +443 cls: 'x-btn-text-icon', +444 text: _('Remove'), +445 icon: '/icons/remove.png', +446 handler: this.onRemove, +447 scope: this +448 }] +449 }) +450 }); +451 +452 this.optionsPanel = this.add(new Ext.deluge.add.OptionsPanel()); +453 this.on('show', this.onShow, this); +454 }, +455 +456 clear: function() { +457 this.torrents = {}; +458 this.grid.getStore().removeAll(); +459 }, +460 +461 onAdd: function() { +462 var torrents = []; +463 this.grid.getStore().each(function(r) { +464 var id = r.get('info_hash'); +465 torrents.push({ +466 path: this.optionsPanel.getFilename(id), +467 options: this.optionsPanel.getOptions(id) +468 }); +469 }, this); +470 +471 Deluge.Client.web.add_torrents(torrents, { +472 success: function(result) { +473 } +474 }) +475 this.clear(); +476 this.hide(); +477 }, +478 +479 onCancel: function() { +480 this.clear(); +481 this.hide(); +482 }, +483 +484 onFile: function() { +485 this.file.show(); +486 }, +487 +488 onRemove: function() { +489 var selection = this.grid.getSelectionModel(); +490 if (!selection.hasSelection()) return; +491 var torrent = selection.getSelected(); +492 +493 delete this.torrents[torrent.id]; +494 this.grid.getStore().remove(torrent); +495 this.options.clear(); +496 }, +497 +498 onSelect: function(selModel, rowIndex, record) { +499 this.optionsPanel.setTorrent(record.get('info_hash')); +500 }, +501 +502 onShow: function() { +503 if (!this.url) { +504 this.url = new Ext.deluge.add.UrlWindow(); +505 this.url.on('beforeadd', this.onTorrentBeforeAdd, this); +506 this.url.on('add', this.onTorrentAdd, this); +507 } +508 +509 if (!this.file) { +510 this.file = new Ext.deluge.add.FileWindow(); +511 this.file.on('beforeadd', this.onTorrentBeforeAdd, this); +512 this.file.on('add', this.onTorrentAdd, this); +513 } +514 +515 this.optionsPanel.getDefaults(); +516 }, +517 +518 onTorrentBeforeAdd: function(torrentId, text) { +519 var store = this.grid.getStore(); +520 store.loadData([[torrentId, null, text]], true); +521 }, +522 +523 onTorrentAdd: function(torrentId, info) { +524 if (!info) { +525 Ext.MessageBox.show({ +526 title: _('Error'), +527 msg: _('Not a valid torrent'), +528 buttons: Ext.MessageBox.OK, +529 modal: false, +530 icon: Ext.MessageBox.ERROR, +531 iconCls: 'x-deluge-icon-error' +532 }); +533 return; +534 } +535 +536 var r = this.grid.getStore().getById(torrentId); +537 r.set('info_hash', info['info_hash']); +538 r.set('text', info['name']); +539 this.grid.getStore().commitChanges(); +540 this.optionsPanel.addTorrent(info); +541 }, +542 +543 onUrl: function(button, event) { +544 this.url.show(); +545 } +546 }); +547 Deluge.Add = new Ext.deluge.add.AddWindow(); +548 \ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Client.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Client.js.html index df274fe71..1ab70606b 100644 --- a/deluge/ui/web/docs/symbols/src/Deluge.Client.js.html +++ b/deluge/ui/web/docs/symbols/src/Deluge.Client.js.html @@ -108,13 +108,13 @@ 101 errorObj = { 102 id: options.id, 103 result: null, -104 error: 'HTTP' + response.status +104 error: 'HTTP: ' + response.status + ' ' + response.statusText 105 } 106 if (Ext.type(options.failure) != 'function') return; 107 if (options.scope) { -108 options.failure.call(options.scope, responseObj.error, responseObj, response); +108 options.failure.call(options.scope, errorObj, response, requestOptions); 109 } else { -110 options.failure(responseObj.error, responseObj, response); +110 options.failure(errorObj, response, requestOptions); 111 } 112 }, 113 @@ -124,9 +124,9 @@ 117 if (responseObj.error) { 118 if (Ext.type(options.failure) != 'function') return; 119 if (options.scope) { -120 options.failure.call(options.scope, responseObj.error, responseObj, response, requestOptions); +120 options.failure.call(options.scope, responseObj, response, requestOptions); 121 } else { -122 options.failure(responseObj.error, responseObj, response, requestOptions); +122 options.failure(responseObj, response, requestOptions); 123 } 124 } else { 125 if (Ext.type(options.success) != 'function') return; diff --git a/deluge/ui/web/docs/symbols/src/Deluge.ConnectionManager.js.html b/deluge/ui/web/docs/symbols/src/Deluge.ConnectionManager.js.html index 7f1b96e98..db55e8ce4 100644 --- a/deluge/ui/web/docs/symbols/src/Deluge.ConnectionManager.js.html +++ b/deluge/ui/web/docs/symbols/src/Deluge.ConnectionManager.js.html @@ -43,341 +43,366 @@ 36 var hostRenderer = function(value, p, r) { 37 return value + ':' + r.data['port'] 38 } - 39 - 40 Ext.deluge.ConnectionManager = Ext.extend(Ext.Window, { - 41 - 42 layout: 'fit', - 43 width: 300, - 44 height: 220, - 45 bodyStyle: 'padding: 10px 5px;', - 46 buttonAlign: 'right', - 47 closeAction: 'hide', - 48 closable: true, - 49 plain: true, - 50 title: _('Connection Manager'), - 51 iconCls: 'x-deluge-connect-window-icon', - 52 - 53 initComponent: function() { - 54 Ext.deluge.ConnectionManager.superclass.initComponent.call(this); - 55 this.on({ - 56 'hide': this.onHide, - 57 'show': this.onShow - 58 }); - 59 Deluge.Events.on('login', this.onLogin, this); - 60 Deluge.Events.on('logout', this.onLogout, this); - 61 - 62 this.addButton(_('Close'), this.onClose, this); - 63 this.addButton(_('Connect'), this.onConnect, this); - 64 - 65 this.grid = this.add({ - 66 xtype: 'grid', - 67 store: new Ext.data.SimpleStore({ - 68 fields: [ - 69 {name: 'status', mapping: 3}, - 70 {name: 'host', mapping: 1}, - 71 {name: 'port', mapping: 2}, - 72 {name: 'version', mapping: 4} - 73 ], - 74 id: 0 - 75 }), - 76 columns: [{ - 77 header: _('Status'), - 78 width: 65, - 79 sortable: true, - 80 renderer: fplain, - 81 dataIndex: 'status' - 82 }, { - 83 id:'host', - 84 header: _('Host'), - 85 width: 150, - 86 sortable: true, - 87 renderer: hostRenderer, - 88 dataIndex: 'host' - 89 }, { - 90 header: _('Version'), - 91 width: 75, - 92 sortable: true, - 93 renderer: fplain, - 94 dataIndex: 'version' - 95 }], - 96 stripeRows: true, - 97 selModel: new Ext.grid.RowSelectionModel({ - 98 singleSelect: true, - 99 listeners: { -100 'rowselect': {fn: this.onSelect, scope: this} -101 } -102 }), -103 autoExpandColumn: 'host', -104 deferredRender:false, -105 autoScroll:true, -106 margins: '0 0 0 0', -107 bbar: new Ext.Toolbar({ -108 items: [ -109 { -110 id: 'add', -111 cls: 'x-btn-text-icon', -112 text: _('Add'), -113 icon: '/icons/add.png', -114 handler: this.onAdd, -115 scope: this -116 }, { -117 id: 'remove', -118 cls: 'x-btn-text-icon', -119 text: _('Remove'), -120 icon: '/icons/remove.png', -121 handler: this.onRemove, -122 scope: this -123 }, '->', { -124 id: 'stop', -125 cls: 'x-btn-text-icon', -126 text: _('Stop Daemon'), -127 icon: '/icons/error.png', -128 handler: this.onStop, -129 scope: this -130 } -131 ] -132 }) -133 }); -134 }, -135 -136 disconnect: function() { -137 Deluge.Events.fire('disconnect'); -138 }, -139 -140 runCheck: function(callback, scope) { -141 callback = callback || this.onGetHosts; -142 scope = scope || this; -143 Deluge.Client.web.get_hosts({ -144 success: callback, -145 scope: scope -146 }); -147 }, -148 -149 onAdd: function(button, e) { -150 //Deluge.Connections.Add.show(); -151 }, -152 -153 onAddHost: function() { -154 var form = Deluge.Connections.Add.items.first(); -155 var host = form.items.get('host').getValue(); -156 var port = form.items.get('port').getValue(); -157 var username = form.items.get('username').getValue(); -158 var password = form.items.get('_password').getValue(); -159 -160 Deluge.Client.web.add_host(host, port, username, password, { -161 onSuccess: function(result) { -162 if (!result[0]) { -163 Ext.MessageBox.show({ -164 title: _('Error'), -165 msg: "Unable to add host: " + result[1], -166 buttons: Ext.MessageBox.OK, -167 modal: false, -168 icon: Ext.MessageBox.ERROR, -169 iconCls: 'x-deluge-icon-error' -170 }); -171 } else { -172 this.runCheck(); -173 } -174 Deluge.Connections.Add.hide(); -175 } -176 }); -177 }, -178 -179 onAddWindowHide: function() { -180 // Tidy up the form to ensure all the values are default. -181 var form = Deluge.Connections.Add.items.first(); -182 form.items.get('host').reset(); -183 form.items.get('port').reset(); -184 form.items.get('username').reset(); -185 form.items.get('_password').reset(); -186 }, -187 -188 onClose: function(e) { -189 if (this.running) window.clearInterval(this.running); -190 this.hide(); -191 }, -192 -193 onConnect: function(e) { -194 var selected = this.grid.getSelectionModel().getSelected(); -195 if (!selected) return; -196 -197 if (selected.get('status') == _('Connected')) { -198 Deluge.Client.web.disconnect({ -199 success: function(result) { -200 this.runCheck(); -201 Deluge.Events.fire('disconnect'); -202 }, -203 scope: this -204 }); -205 } else { -206 var id = selected.id; -207 Deluge.Client.web.connect(id, { -208 success: function(methods) { -209 Deluge.Client.reloadMethods(); -210 Deluge.Client.on('connected', function(e) { -211 Deluge.Events.fire('connect'); -212 }, this, {single: true}); -213 } -214 }); -215 if (this.running) window.clearInterval(this.running); -216 this.hide(); -217 } -218 }, -219 -220 onGetHosts: function(hosts) { -221 this.grid.getStore().loadData(hosts); -222 var selection = this.grid.getSelectionModel(); -223 selection.selectRow(this.selectedRow); -224 }, -225 -226 onLogin: function() { -227 Deluge.Client.web.connected({ -228 success: function(connected) { -229 if (connected) { -230 Deluge.Events.fire('connect'); -231 } else { -232 this.show(); -233 } -234 }, -235 scope: this -236 }); -237 }, -238 -239 onLogout: function() { -240 this.disconnect(); -241 if (!this.hidden && this.rendered) { -242 this.hide(); -243 } -244 }, -245 -246 onRemove: function(button) { -247 var connection = Deluge.Connections.Grid.getSelectionModel().getSelected(); -248 Deluge.Client.web.remove_host(connection.id, { -249 onSuccess: function(result) { -250 if (!result) { -251 Ext.MessageBox.show({ -252 title: _('Error'), -253 msg: result[1], -254 buttons: Ext.MessageBox.OK, -255 modal: false, -256 icon: Ext.MessageBox.ERROR, -257 iconCls: 'x-deluge-icon-error' -258 }); -259 } else { -260 Deluge.Connections.Grid.store.remove(connection); -261 } -262 } -263 }); -264 }, -265 -266 onSelect: function(selModel, rowIndex, record) { -267 this.selectedRow = rowIndex; -268 var button = this.buttons[1]; -269 if (record.get('status') == _('Connected')) { -270 button.setText(_('Disconnect')); -271 } else { -272 button.setText(_('Connect')); -273 } -274 }, -275 -276 onShow: function() { -277 this.runCheck(); -278 this.running = window.setInterval(this.runCheck, 2000); -279 }, -280 -281 onStop: function(button, e) { -282 var connection = this.grid.getSelectionModel().getSelected(); -283 Deluge.Client.web.stop_daemon(connection.id, { -284 success: function(result) { -285 if (!result[0]) { -286 Ext.MessageBox.show({ -287 title: _('Error'), -288 msg: result[1], -289 buttons: Ext.MessageBox.OK, -290 modal: false, -291 icon: Ext.MessageBox.ERROR, -292 iconCls: 'x-deluge-icon-error' -293 }); -294 } -295 } -296 }); -297 } -298 }); -299 Deluge.ConnectionManager = new Ext.deluge.ConnectionManager(); -300 })(); -301 -302 /*Deluge.Connections = { -303 -304 loginShow: function() { -305 }, -306 -307 , -308 -309 -310 } -311 -312 Deluge.Connections.Store ; -313 -314 -315 -316 Deluge.Connections.Grid = new Ext.grid.GridPanel(); -317 -318 Deluge.Connections.Add = new Ext.Window({ -319 layout: 'fit', -320 width: 300, -321 height: 195, -322 bodyStyle: 'padding: 10px 5px;', -323 buttonAlign: 'right', -324 closeAction: 'hide', -325 closable: true, -326 plain: true, -327 title: _('Add Connection'), -328 iconCls: 'x-deluge-add-window-icon', -329 items: [new Ext.form.FormPanel({ -330 defaultType: 'textfield', -331 id: 'connectionAddForm', -332 baseCls: 'x-plain', -333 labelWidth: 55, -334 items: [{ -335 fieldLabel: _('Host'), -336 id: 'host', -337 name: 'host', -338 anchor: '100%', -339 listeners: {} -340 },{ -341 fieldLabel: _('Port'), -342 id: 'port', -343 xtype: 'uxspinner', -344 ctCls: 'x-form-uxspinner', -345 name: 'port', -346 strategy: Ext.ux.form.Spinner.NumberStrategy(), -347 value: '58846', -348 anchor: '50%', -349 listeners: {} -350 }, { -351 fieldLabel: _('Username'), -352 id: 'username', -353 name: 'username', -354 anchor: '100%', -355 listeners: {} -356 },{ -357 fieldLabel: _('Password'), -358 anchor: '100%', -359 id: '_password', -360 name: '_password', -361 inputType: 'password' -362 }] -363 })], -364 buttons: [{ -365 text: _('Close'), -366 handler: function() { -367 Deluge.Connections.Add.hide(); -368 } -369 },{ -370 text: _('Add'), -371 handler: Deluge.Connections.onAddHost -372 }], -373 listeners: { -374 'hide': Deluge.Connections.onAddWindowHide -375 } -376 });*/ \ No newline at end of file + 39 + 40 Ext.deluge.AddConnectionWindow = Ext.extend(Ext.Window, { + 41 + 42 constructor: function(config) { + 43 config = Ext.apply({ + 44 layout: 'fit', + 45 width: 300, + 46 height: 195, + 47 bodyStyle: 'padding: 10px 5px;', + 48 buttonAlign: 'right', + 49 closeAction: 'hide', + 50 closable: true, + 51 plain: true, + 52 title: _('Add Connection'), + 53 iconCls: 'x-deluge-add-window-icon' + 54 }, config); + 55 Ext.deluge.AddConnectionWindow.superclass.constructor.call(this, config); + 56 }, + 57 + 58 initComponent: function() { + 59 Ext.deluge.AddConnectionWindow.superclass.initComponent.call(this); + 60 + 61 this.addEvents('hostadded'); + 62 + 63 this.addButton(_('Close'), this.hide, this); + 64 this.addButton(_('Add'), this.onAdd, this); + 65 + 66 this.on('hide', this.onHide, this); + 67 + 68 this.form = this.add({ + 69 xtype: 'form', + 70 defaultType: 'textfield', + 71 id: 'connectionAddForm', + 72 baseCls: 'x-plain', + 73 labelWidth: 55 + 74 }); + 75 + 76 this.hostField = this.form.add({ + 77 fieldLabel: _('Host'), + 78 id: 'host', + 79 name: 'host', + 80 anchor: '100%', + 81 value: '' + 82 }); + 83 + 84 this.portField = this.form.add({ + 85 fieldLabel: _('Port'), + 86 id: 'port', + 87 xtype: 'uxspinner', + 88 ctCls: 'x-form-uxspinner', + 89 name: 'port', + 90 strategy: Ext.ux.form.Spinner.NumberStrategy(), + 91 value: '58846', + 92 anchor: '50%' + 93 }); + 94 + 95 this.usernameField = this.form.add({ + 96 fieldLabel: _('Username'), + 97 id: 'username', + 98 name: 'username', + 99 anchor: '100%', +100 value: '' +101 }); +102 +103 this.passwordField = this.form.add({ +104 fieldLabel: _('Password'), +105 anchor: '100%', +106 id: '_password', +107 name: '_password', +108 inputType: 'password', +109 value: '' +110 }); +111 }, +112 +113 onAdd: function() { +114 var host = this.hostField.getValue(); +115 var port = this.portField.getValue(); +116 var username = this.usernameField.getValue(); +117 var password = this.passwordField.getValue(); +118 +119 Deluge.Client.web.add_host(host, port, username, password, { +120 success: function(result) { +121 if (!result[0]) { +122 Ext.MessageBox.show({ +123 title: _('Error'), +124 msg: "Unable to add host: " + result[1], +125 buttons: Ext.MessageBox.OK, +126 modal: false, +127 icon: Ext.MessageBox.ERROR, +128 iconCls: 'x-deluge-icon-error' +129 }); +130 } else { +131 this.fireEvent('hostadded'); +132 } +133 this.hide(); +134 }, +135 scope: this +136 }); +137 }, +138 +139 onHide: function() { +140 this.form.getForm().reset(); +141 } +142 }); +143 +144 Ext.deluge.ConnectionManager = Ext.extend(Ext.Window, { +145 +146 layout: 'fit', +147 width: 300, +148 height: 220, +149 bodyStyle: 'padding: 10px 5px;', +150 buttonAlign: 'right', +151 closeAction: 'hide', +152 closable: true, +153 plain: true, +154 title: _('Connection Manager'), +155 iconCls: 'x-deluge-connect-window-icon', +156 +157 initComponent: function() { +158 Ext.deluge.ConnectionManager.superclass.initComponent.call(this); +159 this.on({ +160 'hide': this.onHide, +161 'show': this.onShow +162 }); +163 Deluge.Events.on('login', this.onLogin, this); +164 Deluge.Events.on('logout', this.onLogout, this); +165 +166 this.addButton(_('Close'), this.onClose, this); +167 this.addButton(_('Connect'), this.onConnect, this); +168 +169 this.grid = this.add({ +170 xtype: 'grid', +171 store: new Ext.data.SimpleStore({ +172 fields: [ +173 {name: 'status', mapping: 3}, +174 {name: 'host', mapping: 1}, +175 {name: 'port', mapping: 2}, +176 {name: 'version', mapping: 4} +177 ], +178 id: 0 +179 }), +180 columns: [{ +181 header: _('Status'), +182 width: 65, +183 sortable: true, +184 renderer: fplain, +185 dataIndex: 'status' +186 }, { +187 id:'host', +188 header: _('Host'), +189 width: 150, +190 sortable: true, +191 renderer: hostRenderer, +192 dataIndex: 'host' +193 }, { +194 header: _('Version'), +195 width: 75, +196 sortable: true, +197 renderer: fplain, +198 dataIndex: 'version' +199 }], +200 stripeRows: true, +201 selModel: new Ext.grid.RowSelectionModel({ +202 singleSelect: true, +203 listeners: { +204 'rowselect': {fn: this.onSelect, scope: this} +205 } +206 }), +207 autoExpandColumn: 'host', +208 deferredRender:false, +209 autoScroll:true, +210 margins: '0 0 0 0', +211 bbar: new Ext.Toolbar({ +212 items: [ +213 { +214 id: 'add', +215 cls: 'x-btn-text-icon', +216 text: _('Add'), +217 icon: '/icons/add.png', +218 handler: this.onAdd, +219 scope: this +220 }, { +221 id: 'remove', +222 cls: 'x-btn-text-icon', +223 text: _('Remove'), +224 icon: '/icons/remove.png', +225 handler: this.onRemove, +226 scope: this +227 }, '->', { +228 id: 'stop', +229 cls: 'x-btn-text-icon', +230 text: _('Stop Daemon'), +231 icon: '/icons/error.png', +232 handler: this.onStop, +233 scope: this +234 } +235 ] +236 }) +237 }); +238 }, +239 +240 disconnect: function() { +241 Deluge.Events.fire('disconnect'); +242 }, +243 +244 loadHosts: function() { +245 Deluge.Client.web.get_hosts({ +246 success: this.onGetHosts, +247 scope: this +248 }); +249 }, +250 +251 update: function(self) { +252 self.grid.getStore().each(function(r) { +253 Deluge.Client.web.get_host_status(r.id, { +254 success: self.onGetHostStatus, +255 scope: self +256 }); +257 }, this); +258 }, +259 +260 onAdd: function(button, e) { +261 if (!this.addWindow) { +262 this.addWindow = new Ext.deluge.AddConnectionWindow(); +263 this.addWindow.on('hostadded', this.onHostAdded, this); +264 } +265 this.addWindow.show(); +266 }, +267 +268 onHostAdded: function() { +269 this.runCheck(); +270 }, +271 +272 onClose: function(e) { +273 if (this.running) window.clearInterval(this.running); +274 this.hide(); +275 }, +276 +277 onConnect: function(e) { +278 var selected = this.grid.getSelectionModel().getSelected(); +279 if (!selected) return; +280 +281 if (selected.get('status') == _('Connected')) { +282 Deluge.Client.web.disconnect({ +283 success: function(result) { +284 this.update(); +285 Deluge.Events.fire('disconnect'); +286 }, +287 scope: this +288 }); +289 } else { +290 var id = selected.id; +291 Deluge.Client.web.connect(id, { +292 success: function(methods) { +293 Deluge.Client.reloadMethods(); +294 Deluge.Client.on('connected', function(e) { +295 Deluge.Events.fire('connect'); +296 }, this, {single: true}); +297 } +298 }); +299 if (this.running) window.clearInterval(this.running); +300 this.hide(); +301 } +302 }, +303 +304 onGetHosts: function(hosts) { +305 var store = this.grid.getStore(); +306 Ext.each(hosts, function(host) { +307 var record = store.getById(host[0]); +308 if (!record) { +309 store.loadData([host], true); +310 } +311 Deluge.Client.web.get_host_status(host[0], { +312 success: this.onGetHostStatus, +313 scope: this +314 }); +315 }, this); +316 }, +317 +318 onGetHostStatus: function(host) { +319 var record = this.grid.getStore().getById(host[0]); +320 record.set('status', host[3]) +321 record.set('version', host[4]) +322 record.commit(); +323 }, +324 +325 onLogin: function() { +326 Deluge.Client.web.connected({ +327 success: function(connected) { +328 if (connected) { +329 Deluge.Events.fire('connect'); +330 } else { +331 this.show(); +332 } +333 }, +334 scope: this +335 }); +336 }, +337 +338 onLogout: function() { +339 this.disconnect(); +340 if (!this.hidden && this.rendered) { +341 this.hide(); +342 } +343 }, +344 +345 onRemove: function(button) { +346 var connection = this.grid.getSelectionModel().getSelected(); +347 Deluge.Client.web.remove_host(connection.id, { +348 success: function(result) { +349 if (!result) { +350 Ext.MessageBox.show({ +351 title: _('Error'), +352 msg: result[1], +353 buttons: Ext.MessageBox.OK, +354 modal: false, +355 icon: Ext.MessageBox.ERROR, +356 iconCls: 'x-deluge-icon-error' +357 }); +358 } else { +359 this.grid.getStore().remove(connection); +360 } +361 }, +362 scope: this +363 }); +364 }, +365 +366 onSelect: function(selModel, rowIndex, record) { +367 this.selectedRow = rowIndex; +368 var button = this.buttons[1]; +369 if (record.get('status') == _('Connected')) { +370 button.setText(_('Disconnect')); +371 } else { +372 button.setText(_('Connect')); +373 } +374 }, +375 +376 onShow: function() { +377 this.loadHosts(); +378 this.running = window.setInterval(this.update, 2000, this); +379 }, +380 +381 onStop: function(button, e) { +382 var connection = this.grid.getSelectionModel().getSelected(); +383 Deluge.Client.web.stop_daemon(connection.id, { +384 success: function(result) { +385 if (!result[0]) { +386 Ext.MessageBox.show({ +387 title: _('Error'), +388 msg: result[1], +389 buttons: Ext.MessageBox.OK, +390 modal: false, +391 icon: Ext.MessageBox.ERROR, +392 iconCls: 'x-deluge-icon-error' +393 }); +394 } +395 } +396 }); +397 } +398 }); +399 Deluge.ConnectionManager = new Ext.deluge.ConnectionManager(); +400 })(); +401 \ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Details.Options.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Details.Options.js.html index 6d2c321d9..885c27d70 100644 --- a/deluge/ui/web/docs/symbols/src/Deluge.Details.Options.js.html +++ b/deluge/ui/web/docs/symbols/src/Deluge.Details.Options.js.html @@ -366,12 +366,12 @@ 359 }, 360 361 clear: function() { -362 this.optionsManager.resetOptions(this.torrentId); +362 this.optionsManager.changeId(null); 363 }, 364 365 reset: function() { 366 if (this.torrentId) { -367 this.optionsManager.resetOptions(this.torrentId); +367 this.optionsManager.reset(this.torrentId); 368 } 369 }, 370 @@ -389,15 +389,15 @@ 382 var value = changed['prioritize_first_last']; 383 Deluge.Client.core.set_torrent_prioritize_first_last(this.torrentId, value, { 384 success: function() { -385 this.optionsManager.setOption(this.torrentId, 'prioritize_first_last', value); +385 this.optionsManager.set(this.torrentId, 'prioritize_first_last', value); 386 }, 387 scope: this 388 }); 389 } 390 Deluge.Client.core.set_torrent_options([this.torrentId], changed, { 391 success: function() { -392 this.optionsManager.setOptions(this.torrentId, changed); -393 this.optionsManager.resetOptions(this.torrentId); +392 this.optionsManager.set(this.torrentId, changed); +393 this.optionsManager.reset(this.torrentId); 394 }, 395 scope: this 396 }); @@ -418,7 +418,7 @@ 411 this.fields['private'].setDisabled(!torrent['private']); 412 delete torrent['private']; 413 -414 this.optionsManager.updateOptions(this.torrentId, torrent); +414 this.optionsManager.update(this.torrentId, torrent); 415 } 416 }); 417 Deluge.Details.add(new Ext.deluge.details.OptionsTab()); diff --git a/deluge/ui/web/docs/symbols/src/Deluge.OptionsManager.js.html b/deluge/ui/web/docs/symbols/src/Deluge.OptionsManager.js.html index c2a70e01d..20e86c971 100644 --- a/deluge/ui/web/docs/symbols/src/Deluge.OptionsManager.js.html +++ b/deluge/ui/web/docs/symbols/src/Deluge.OptionsManager.js.html @@ -50,8 +50,8 @@ 43 this.changed = {}; 44 this.defaults = config['defaults'] || {}; 45 this.options = {}; - 46 - 47 + 46 this.currentId = null; + 47 48 this.addEvents({ 49 'add': true, 50 'changed': true, @@ -82,164 +82,175 @@ 75 76 switch (field.getXType()) { 77 case 'checkbox': - 78 field.on('check', this.onFieldChange, this); - 79 break; - 80 case 'uxspinner': - 81 field.on('spin', this.onFieldChange, this); - 82 field.on('keypress', this.onFieldChange, this); - 83 break; - 84 default: - 85 break; - 86 } - 87 }, - 88 - 89 /** - 90 * Returns the changed values for a specified id. - 91 * @param {String} id - 92 * @returns {Object} the changed options + 78 case 'radiogroup': + 79 field.on('check', this.onFieldChange, this); + 80 break; + 81 case 'uxspinner': + 82 field.on('spin', this.onFieldChange, this); + 83 field.on('keypress', this.onFieldChange, this); + 84 break; + 85 default: + 86 break; + 87 } + 88 }, + 89 + 90 /** + 91 * Changes bound fields to use the specified id. + 92 * @param {String} id 93 */ - 94 getChanged: function(id) { - 95 return (this.changed[id]) ? this.changed[id] : {}; - 96 }, - 97 - 98 /** - 99 * Get the default value for an option given an id and option name. -100 * @param {String} id -101 * @param {String} option -102 * @returns {Object} the value of the option -103 */ -104 getOption: function(id, option) { -105 return (this.hasOption(id, option)) ? this.options[id][option] : this.defaults[option]; -106 }, -107 -108 /** -109 * Get the value for an option given an id and option name. -110 * @param {String} id -111 * @param {String} option -112 * @returns {Object} the options value. -113 */ -114 getValue: function(id, option) { -115 return (this.hasChanged(id, option)) ? this.changed[id][option] : this.getOption(id, option); -116 }, -117 -118 /** -119 * Check to see if the option has been changed. -120 * @param {String} id -121 * @param {String} option -122 * @returns {Boolean} true if the option has been changed, else false. -123 */ -124 hasChanged: function(id, option) { -125 return (this.changed[id] && !Ext.isEmpty(this.changed[id][option])); -126 }, -127 -128 /** -129 * Check to see if an id has had an option set to something other than the -130 * default value. + 94 changeId: function(id) { + 95 this.currentId = id; + 96 for (var option in this.defaults) { + 97 if (!this.binds[option]) continue; + 98 this.binds[option].setValue(this.get(id, option)); + 99 } +100 }, +101 +102 /** +103 * Get the value for an option +104 * @param {String} id +105 * @param {String|Array} [option] A single option or an array of options to return. +106 * @returns {Object} the options value. +107 */ +108 get: function(id, option) { +109 if (!option) { +110 var values = {}; +111 for (var key in this.defaults) { +112 values[key] = this.get(id, key); +113 } +114 return values; +115 } else { +116 return (this.hasChanged(id, option)) ? this.changed[id][option] : this.getDefault(id, option); +117 } +118 }, +119 +120 /** +121 * Returns the changed values. +122 * @param {String} id +123 * @returns {Object} the changed options +124 */ +125 getChanged: function(id) { +126 return (this.changed[id]) ? this.changed[id] : {}; +127 }, +128 +129 /** +130 * Get the default value for an option. 131 * @param {String} id -132 * @param {String} option -133 * @returns {Boolean} true if the id has an option, else false. +132 * @param {String|Array} [option] A single option or an array of options to return. +133 * @returns {Object} the value of the option 134 */ -135 hasOption: function(id, option) { -136 return (this.options[id] && !Ext.isEmpty(this.options[id][option])); +135 getDefault: function(id, option) { +136 return (this.hasOption(id, option)) ? this.options[id][option] : this.defaults[option]; 137 }, -138 -139 /** -140 * Reset the options back to the default values for the specified id. +138 +139 /** +140 * Check to see if the option has been changed. 141 * @param {String} id -142 */ -143 resetOptions: function(id) { -144 if (!this.changed[id]) return; -145 delete this.changed[id]; -146 }, -147 -148 /** -149 * Set the specified option for the passed in id. -150 * @param {String} id -151 * @param {String} option -152 * @param {Object} value The value for the option -153 */ -154 setOption: function(id, option, value) { -155 this.options[id][option] = value; -156 }, -157 -158 /** -159 * Set the specified options for the passed in id. -160 * @param {String} id -161 * @param {Object} options The option values to change. -162 */ -163 setOptions: function(id, options) { -164 if (!this.changed[id]) this.changed[id] = {}; -165 for (var key in options) { -166 this.setOption(id, key, options[key]); -167 } -168 }, -169 -170 /** -171 * Update the value for the specified option and id. -172 * @param {String} id -173 * @param {String} option -174 * @param {Object} value; -175 */ -176 updateOption: function(id, option, value) { -177 if (!this.changed[id]) this.changed[id] = {}; -178 -179 var oldValue = this.getValue(id, option); -180 if (oldValue == value) return; -181 -182 var defaultValue = this.getOption(id, option); -183 if (defaultValue == value) { -184 if (!Ext.isEmpty(this.changed[id][option])) delete this.changed[id][option]; -185 this.fireEvent('changed', id, option, value, oldValue); -186 return; -187 } -188 -189 if (Ext.type(defaultValue) != Ext.type(value)) { -190 switch (Ext.type(defaultValue)) { -191 case 'string': -192 value = String(value); -193 break; -194 case 'number': -195 value = Number(value); -196 break; -197 case 'boolean': -198 value = Boolean(value); -199 break; -200 } -201 } -202 -203 this.changed[id][option] = value; -204 this.fireEvent('changed', id, option, value, oldValue); -205 }, -206 -207 /** -208 * Update the options for the specified id. -209 * @param {String} id -210 * @param {Object} options The options to change. -211 */ -212 updateOptions: function(id, options) { -213 for (var key in options) { -214 this.updateOption(id, key, options[key]); -215 } -216 }, -217 -218 /* Event Handlers */ -219 -220 /** -221 * Stops a form fields value from being blocked by the change functions -222 * @param {Ext.form.Field} field -223 * @private -224 */ -225 onFieldChange: function(field) { -226 var option = this.binds[field]; -227 //alert(option); -228 }, -229 -230 onChange: function(id, option, newValue, oldValue) { -231 // If we don't have a bind there's nothing to do. -232 if (Ext.isEmpty(this.binds[option])) return; -233 -234 // Set the form field to the new value. -235 this.binds[option].setValue(newValue); -236 } -237 }); -238 \ No newline at end of file +142 * @param {String} option +143 * @returns {Boolean} true if the option has been changed, else false. +144 */ +145 hasChanged: function(id, option) { +146 return (this.changed[id] && !Ext.isEmpty(this.changed[id][option])); +147 }, +148 +149 /** +150 * Check to see if an id has had an option set to something other than the +151 * default value. +152 * @param {String} id +153 * @param {String} option +154 * @returns {Boolean} true if the id has an option, else false. +155 */ +156 hasOption: function(id, option) { +157 return (this.options[id] && !Ext.isEmpty(this.options[id][option])); +158 }, +159 +160 /** +161 * Reset the options back to the default values for the specified id. +162 * @param {String} id +163 */ +164 reset: function(id) { +165 if (!this.changed[id]) return; +166 delete this.changed[id]; +167 }, +168 +169 /** +170 * Sets the value of specified option for the passed in id. +171 * @param {String} id +172 * @param {String} option +173 * @param {Object} value The value for the option +174 */ +175 set: function(id, option, value) { +176 if (typeof value === undefined) { +177 for (var key in option) { +178 this.set(id, key, option[key]); +179 } +180 } else { +181 if (!this.options[id]) this.options[id] = {}; +182 this.options[id][option] = value; +183 } +184 }, +185 +186 /** +187 * Update the value for the specified option and id. +188 * @param {String} id +189 * @param {String|Object} option or options to update +190 * @param {Object} [value]; +191 */ +192 update: function(id, option, value) { +193 if (typeof value === undefined) { +194 for (var key in option) { +195 this.update(id, key, option[key]); +196 } +197 } else { +198 if (!this.changed[id]) this.changed[id] = {}; +199 +200 var oldValue = this.get(id, option); +201 if (oldValue == value) return; +202 +203 var defaultValue = this.getDefault(id, option); +204 if (defaultValue == value) { +205 if (this.hasChanged(id, option)) delete this.changed[id][option]; +206 this.fireEvent('changed', id, option, value, oldValue); +207 return; +208 } +209 +210 if (Ext.type(defaultValue) != Ext.type(value)) { +211 switch (Ext.type(defaultValue)) { +212 case 'string': +213 value = String(value); +214 break; +215 case 'number': +216 value = Number(value); +217 break; +218 case 'boolean': +219 value = Boolean(value); +220 break; +221 } +222 } +223 +224 this.changed[id][option] = value; +225 this.fireEvent('changed', id, option, value, oldValue); +226 } +227 }, +228 +229 /* Event Handlers */ +230 +231 /** +232 * Stops a form fields value from being blocked by the change functions +233 * @param {Ext.form.Field} field +234 * @private +235 */ +236 onFieldChange: function(field) { +237 var option = this.binds[field]; +238 this.update(this.currentId, option, field.getValue()); +239 }, +240 +241 onChange: function(id, option, newValue, oldValue) { +242 // If we don't have a bind there's nothing to do. +243 if (Ext.isEmpty(this.binds[option])) return; +244 +245 // Set the form field to the new value. +246 this.binds[option].setValue(newValue); +247 } +248 }); +249 \ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/ext-extensions-debug.js.html b/deluge/ui/web/docs/symbols/src/ext-extensions-debug.js.html index 104591783..35573d07b 100644 --- a/deluge/ui/web/docs/symbols/src/ext-extensions-debug.js.html +++ b/deluge/ui/web/docs/symbols/src/ext-extensions-debug.js.html @@ -752,4 +752,40 @@ 745 return this; 746 } 747 }); -748 Ext.reg('fullprogressbar', Ext.ux.FullProgressBar); \ No newline at end of file +748 Ext.reg('fullprogressbar', Ext.ux.FullProgressBar); +749 +750 +751 // Allow radiogroups to be treated as a single form element. +752 Ext.override(Ext.form.RadioGroup, { +753 +754 afterRender: function() { +755 var that = this; +756 this.items.each(function(i) { +757 that.relayEvents(i, ['check']); +758 }); +759 Ext.form.RadioGroup.superclass.afterRender.call(this) +760 }, +761 +762 getName: function() { +763 return this.items.first().getName(); +764 }, +765 +766 getValue: function() { +767 var v; +768 +769 this.items.each(function(item) { +770 v = item.getRawValue(); +771 return !item.getValue(); +772 }); +773 +774 return v; +775 }, +776 +777 setValue: function(v) { +778 if (!this.items.each) return; +779 this.items.each(function(item) { +780 item.setValue((item.getRawValue() === 'true') == v); +781 }); +782 } +783 }); +784 \ No newline at end of file