summaryrefslogtreecommitdiffstats
path: root/pyload/web/app/scripts/views
diff options
context:
space:
mode:
Diffstat (limited to 'pyload/web/app/scripts/views')
-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
5 files changed, 34 insertions, 6 deletions
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'));