summaryrefslogtreecommitdiffstats
path: root/pyload/web
diff options
context:
space:
mode:
Diffstat (limited to 'pyload/web')
-rw-r--r--pyload/web/app/scripts/models/CollectorPackage.js40
-rw-r--r--pyload/web/app/scripts/views/dashboard/dashboardView.js15
-rw-r--r--pyload/web/app/scripts/views/dashboard/packageView.js1
-rw-r--r--pyload/web/app/scripts/views/headerView.js8
-rw-r--r--pyload/web/app/scripts/views/linkgrabber/collectorView.js4
-rw-r--r--pyload/web/app/scripts/views/linkgrabber/modalView.js12
-rwxr-xr-xpyload/web/app/templates/default/linkgrabber/modal.html7
-rw-r--r--pyload/web/bower.json14
8 files changed, 76 insertions, 25 deletions
diff --git a/pyload/web/app/scripts/models/CollectorPackage.js b/pyload/web/app/scripts/models/CollectorPackage.js
index 9582c6af8..17a3a1551 100644
--- a/pyload/web/app/scripts/models/CollectorPackage.js
+++ b/pyload/web/app/scripts/models/CollectorPackage.js
@@ -8,7 +8,8 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'collection
name: 'Unnamed package',
password: null,
new_name: null,
- links: null
+ links: null,
+ pid: null
},
initialize: function() {
@@ -39,16 +40,33 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'collection
add: function() {
var self = this;
var links = this.get('links').pluck('url');
-
- $.ajax(App.apiRequest('addPackage',
- {name: this.getName(),
- links: links,
- password: this.get('password')},
- {success: function() {
- self.destroy();
- App.vent.trigger('package:added');
- }}));
-
+ var pid = this.get('pid');
+
+ if (pid !== null && _.isNumber(pid)) {
+ console.log('Adding links to package', pid);
+ $.ajax(App.apiRequest('addLinks',
+ {
+ pid: pid,
+ links: links
+ },
+ {
+ success: function() {
+ self.destroy();
+ App.vent.trigger('collectorPackage:added');
+ }}));
+ }
+ else
+ $.ajax(App.apiRequest('addPackage',
+ {
+ name: this.getName(),
+ links: links,
+ password: this.get('password')
+ },
+ {
+ success: function() {
+ self.destroy();
+ App.vent.trigger('collectorPackage:added');
+ }}));
},
updateLinks: function(links) {
diff --git a/pyload/web/app/scripts/views/dashboard/dashboardView.js b/pyload/web/app/scripts/views/dashboard/dashboardView.js
index 7c176ae64..3b224040d 100644
--- a/pyload/web/app/scripts/views/dashboard/dashboardView.js
+++ b/pyload/web/app/scripts/views/dashboard/dashboardView.js
@@ -28,9 +28,9 @@ define(['jquery', 'backbone', 'underscore', 'app', 'models/TreeCollection', 'col
var self = this;
// When package is added we reload the data
- this.listenTo(App.vent, 'package:added', _.bind(this.fetch, this));
this.listenTo(App.vent, 'package:inserted', _.bind(this.fetch, this));
- this.listenTo(App.vent, 'package:destroyed', _.bind(this.packageDestroyed, this));
+ this.listenTo(App.vent, 'package:destroyed', _.bind(this.onPackageDestroyed, this));
+ this.listenTo(App.vent, 'package:updated', _.bind(this.onPackageUpdated, this));
this.listenTo(App.vent, 'file:updated', _.bind(this.fileUpdated, this));
@@ -46,6 +46,7 @@ define(['jquery', 'backbone', 'underscore', 'app', 'models/TreeCollection', 'col
// TODO: put in separated function
// TODO: order of elements?
// Init the tree and callback for package added
+ // open newly added package in dashboard
this.tree.fetch({success: function() {
self.update();
self.tree.get('packages').on('add', function(pack) {
@@ -174,10 +175,18 @@ define(['jquery', 'backbone', 'underscore', 'app', 'models/TreeCollection', 'col
},
// destroys files when opened package is deleted
- packageDestroyed: function(pack) {
+ onPackageDestroyed: function(pack) {
// TODO: could be improved
if (pack.get('files') === this.files)
App.vent.trigger('dashboard:destroyContent');
+ },
+
+ // TODO: render inserted files
+ // reload the package
+ onPackageUpdated: function(pid) {
+ var pack = this.tree.get('packages').get(pid);
+ if (pack)
+ pack.fetch();
}
});
}); \ No newline at end of file
diff --git a/pyload/web/app/scripts/views/dashboard/packageView.js b/pyload/web/app/scripts/views/dashboard/packageView.js
index 89972f284..2de5412f7 100644
--- a/pyload/web/app/scripts/views/dashboard/packageView.js
+++ b/pyload/web/app/scripts/views/dashboard/packageView.js
@@ -90,6 +90,7 @@ define(['jquery', 'app', 'views/abstract/itemView', 'underscore', 'hbs!tpl/dashb
},
add: function() {
+ App.vent.trigger('linkgrabber:open', this.model);
},
loadMenu: function() {
diff --git a/pyload/web/app/scripts/views/headerView.js b/pyload/web/app/scripts/views/headerView.js
index 60a47ad62..1fad32642 100644
--- a/pyload/web/app/scripts/views/headerView.js
+++ b/pyload/web/app/scripts/views/headerView.js
@@ -56,6 +56,11 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/ServerStatus', 'colle
self.ui.progress.appendWithAnimation(new ProgressView({model: model}).render().el);
});
+ // Listen to open the link grabber
+ this.listenTo(App.vent, 'linkgrabber:open', function(pack) {
+ self.open_grabber(null, pack);
+ });
+
// TODO: button to start stop refresh
var ws = App.openWebSocket('/async');
ws.onopen = function() {
@@ -170,12 +175,13 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/ServerStatus', 'colle
this.$('.popover').animate({opacity: 'toggle'});
},
- open_grabber: function() {
+ open_grabber: function(e, model) {
var self = this;
_.requireOnce(['views/linkgrabber/modalView'], function(ModalView) {
if (self.grabber === null)
self.grabber = new ModalView();
+ self.grabber.setModel(model);
self.grabber.show();
});
},
diff --git a/pyload/web/app/scripts/views/linkgrabber/collectorView.js b/pyload/web/app/scripts/views/linkgrabber/collectorView.js
index 08b426aff..ba1bbbf69 100644
--- a/pyload/web/app/scripts/views/linkgrabber/collectorView.js
+++ b/pyload/web/app/scripts/views/linkgrabber/collectorView.js
@@ -21,6 +21,10 @@ define(['jquery', 'underscore', 'backbone', 'app', './packageView'],
self.collection.add(pack);
}
+ // set destination pid
+ if (self.model)
+ pack.set('pid', self.model.get('pid'));
+
// Remove links from other packages and delete empty ones
self.collection.each(function(pack2) {
console.log(pack2, links);
diff --git a/pyload/web/app/scripts/views/linkgrabber/modalView.js b/pyload/web/app/scripts/views/linkgrabber/modalView.js
index 8e24f259b..950c0ce2f 100644
--- a/pyload/web/app/scripts/views/linkgrabber/modalView.js
+++ b/pyload/web/app/scripts/views/linkgrabber/modalView.js
@@ -23,7 +23,15 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/CollectorPackage', 'v
initialize: function() {
// Inherit parent events
this.events = _.extend({}, modalView.prototype.events, this.events);
- this.listenTo(App.vent, 'package:added', _.bind(this.onAdded, this));
+ this.listenTo(App.vent, 'collectorPackage:added', _.bind(this.onAdded, this));
+ },
+
+ // sets a new models as target and render
+ setModel: function(model) {
+ if (this.model !== model) {
+ this.model = model;
+ this.render();
+ }
},
addOnKeyUp: function(e) {
@@ -106,7 +114,7 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/CollectorPackage', 'v
onRender: function() {
// anonymous collection
- this.collectorView = new CollectorView({collection: new (Backbone.Collection.extend({
+ this.collectorView = new CollectorView({model: this.model, collection: new (Backbone.Collection.extend({
model: CollectorPackage
}))()});
this.collectorView.setElement(this.$('.prepared-packages'));
diff --git a/pyload/web/app/templates/default/linkgrabber/modal.html b/pyload/web/app/templates/default/linkgrabber/modal.html
index 3c50aa037..c07d8beb1 100755
--- a/pyload/web/app/templates/default/linkgrabber/modal.html
+++ b/pyload/web/app/templates/default/linkgrabber/modal.html
@@ -29,7 +29,12 @@
</div>
<legend>
- {{_ "Packages" }} <button class="btn btn-danger btn-small btn-remove-all"><i class="icon-trash"></i></button>
+ {{#if name}}
+ {{_ "Adding links to package: %s" name}}
+ {{else}}
+ {{_ "Packages" }}
+ {{/if}}
+ &nbsp;<button class="btn btn-danger btn-small btn-remove-all"><i class="icon-trash"></i></button>
</legend>
<div class="container-fluid prepared-packages">
diff --git a/pyload/web/bower.json b/pyload/web/bower.json
index 4da3634a0..fe5641cb2 100644
--- a/pyload/web/bower.json
+++ b/pyload/web/bower.json
@@ -3,21 +3,21 @@
"version": "0.1.0",
"dependencies": {
"pyload-common": "https://github.com/pyload/pyload-common.git",
- "requirejs": "~2.1.6",
+ "requirejs": "2.1.9",
"requirejs-text": "*",
"require-handlebars-plugin": "*",
"jquery": "~1.9.1",
"jquery.transit": "~0.9.9",
"jquery.cookie": "~1.3.1",
"jquery.animate-enhanced": "*",
- "flot": "~0.8.1",
- "underscore": "~1.5.1",
- "backbone": "~1.0.0",
- "backbone.marionette": "~1.1.0",
+ "flot": "~0.8.2",
+ "underscore": "~1.5.0",
+ "backbone": "1.1.0",
+ "backbone.marionette": "1.4.0",
"handlebars.js": "1.0.0-rc.3",
"jed": "~0.5.4",
- "select2": "~3.4.0",
- "momentjs": "~2.1.0"
+ "select2": "~3.4.5",
+ "momentjs": "~2.4.0"
},
"devDependencies": {}
}