summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
Diffstat (limited to 'module')
-rw-r--r--module/web/static/css/default/dashboard.less5
-rw-r--r--module/web/static/js/app.js5
-rw-r--r--module/web/static/js/models/File.js13
-rw-r--r--module/web/static/js/models/Package.js15
-rw-r--r--module/web/static/js/utils/animations.js12
-rw-r--r--module/web/static/js/views/abstract/itemView.js11
-rw-r--r--module/web/static/js/views/dashboardView.js20
-rw-r--r--module/web/static/js/views/fileView.js6
-rw-r--r--module/web/static/js/views/packageView.js23
-rw-r--r--module/web/static/js/views/selectionView.js19
-rw-r--r--module/web/templates/default/dashboard.html28
11 files changed, 106 insertions, 51 deletions
diff --git a/module/web/static/css/default/dashboard.less b/module/web/static/css/default/dashboard.less
index 4d504fdc3..1cd9a1bc5 100644
--- a/module/web/static/css/default/dashboard.less
+++ b/module/web/static/css/default/dashboard.less
@@ -108,6 +108,11 @@
i.iconf-trash:hover {
color: @red;
}
+
+ .dropdown-menu {
+ text-shadow: none;
+ }
+
}
// Tag area with different effect on hover
diff --git a/module/web/static/js/app.js b/module/web/static/js/app.js
index d39ef6a63..dcc9594af 100644
--- a/module/web/static/js/app.js
+++ b/module/web/static/js/app.js
@@ -27,6 +27,11 @@ define([
// Add Global Helper functions
_.extend(Application.prototype, Backbone.Events, {
+ restartFailed: function(pids, options) {
+ options || (options = {});
+ options.url = 'api/restartFailed';
+ $.ajax(options);
+ }
});
diff --git a/module/web/static/js/models/File.js b/module/web/static/js/models/File.js
index 66d9ef050..efea23254 100644
--- a/module/web/static/js/models/File.js
+++ b/module/web/static/js/models/File.js
@@ -23,13 +23,24 @@ define(['jquery', 'backbone', 'underscore'], function($, Backbone, _) {
},
+ destroy: function() {
+
+ },
+
+ restart: function(options) {
+ options || (options = {});
+ options.url = 'api/restartFile/' + this.get('fid');
+
+ return $.ajax(options);
+ },
+
// Any time a model attribute is set, this method is called
validate: function(attrs) {
},
isDownload : function() {
- return this.has('download')
+ return this.has('download');
}
});
diff --git a/module/web/static/js/models/Package.js b/module/web/static/js/models/Package.js
index 24f04519e..c5eb3eaac 100644
--- a/module/web/static/js/models/Package.js
+++ b/module/web/static/js/models/Package.js
@@ -54,6 +54,16 @@ define(['jquery', 'backbone', 'underscore', 'collections/FileList', 'require'],
return Backbone.Model.prototype.destroy.call(this, options);
},
+ restart: function(options) {
+ options || (options = {});
+ var self = this;
+ options.url = 'api/restartPackage/' + this.get('pid');
+ options.success = function() {
+ self.fetch();
+ };
+ return $.ajax(options);
+ },
+
parse: function(resp) {
// Package is loaded from tree collection
if (_.has(resp, 'root')) {
@@ -75,11 +85,6 @@ define(['jquery', 'backbone', 'underscore', 'collections/FileList', 'require'],
return Backbone.model.prototype.parse.call(this, resp);
},
- // Package data is complete when it contains collection for containing files or packs
- isLoaded: function() {
- return this.has('files');
- },
-
// Any time a model attribute is set, this method is called
validate: function(attrs) {
diff --git a/module/web/static/js/utils/animations.js b/module/web/static/js/utils/animations.js
index 798f69358..789359e0c 100644
--- a/module/web/static/js/utils/animations.js
+++ b/module/web/static/js/utils/animations.js
@@ -38,7 +38,7 @@ define(['jquery', 'underscore', 'transit'], function(jQuery, _) {
if (animation === true)
element.fadeIn();
- element.calculateHeight();
+// element.calculateHeight();
return this;
};
@@ -61,6 +61,7 @@ define(['jquery', 'underscore', 'transit'], function(jQuery, _) {
return this;
};
+ // TODO: carry arguments, optional height argument
jQuery.fn.slideOut = function() {
var o = jQuery(this[0]);
o.animate({height: o.data('height'), opacity: 'show'});
@@ -73,6 +74,15 @@ define(['jquery', 'underscore', 'transit'], function(jQuery, _) {
return this;
};
+ jQuery.fn.initTooltips = function(placement) {
+ placement || (placement = 'top');
+
+ var o = jQuery(this[0]);
+ o.find('[data-toggle="tooltip"]').tooltip({delay: {show: 500, hide: 100}, placement: placement});
+
+ return this;
+ };
+
jQuery.fn._transit = jQuery.fn.transit;
// Overriding transit plugin to support hide and show
diff --git a/module/web/static/js/views/abstract/itemView.js b/module/web/static/js/views/abstract/itemView.js
index 1c14e7dc3..75b058874 100644
--- a/module/web/static/js/views/abstract/itemView.js
+++ b/module/web/static/js/views/abstract/itemView.js
@@ -8,14 +8,13 @@ define(['jquery', 'backbone', 'underscore'], function($, Backbone, _) {
destroy: function() {
this.undelegateEvents();
this.unbind();
- if (this.onDestroy){
+ if (this.onDestroy) {
this.onDestroy();
}
this.$el.removeData().unbind();
this.remove();
},
-
hide: function() {
this.$el.slideUp();
},
@@ -25,9 +24,15 @@ define(['jquery', 'backbone', 'underscore'], function($, Backbone, _) {
},
deleteItem: function(e) {
- if(e)
+ if (e)
e.stopPropagation();
this.model.destroy();
+ },
+
+ restart: function(e) {
+ if(e)
+ e.stopPropagation();
+ this.model.restart();
}
});
diff --git a/module/web/static/js/views/dashboardView.js b/module/web/static/js/views/dashboardView.js
index 7f2b9809a..9d5b62cc6 100644
--- a/module/web/static/js/views/dashboardView.js
+++ b/module/web/static/js/views/dashboardView.js
@@ -8,7 +8,6 @@ define(['jquery', 'backbone', 'underscore', 'app', 'models/TreeCollection',
el: '#content',
events: {
- 'click #show_active': 'filter'
},
// <ul> holding the packages
@@ -64,7 +63,10 @@ define(['jquery', 'backbone', 'underscore', 'app', 'models/TreeCollection',
packs.each(_.bind(this.appendPackage, this));
this.fileUL = this.$('.file-list');
- this.files.each(_.bind(this.appendFile, this));
+ if (this.files.length === 0)
+ this.fileUL.append($('<li>No package selected</li>'));
+ else
+ this.files.each(_.bind(this.appendFile, this));
return this;
},
@@ -115,19 +117,5 @@ define(['jquery', 'backbone', 'underscore', 'app', 'models/TreeCollection',
this.fileUL.fadeIn();
App.vent.trigger('dashboard:show', this.files);
},
-
- // TODO: remove this debug stuff
- toggle: false,
- filter: function(e) {
- var self = this;
- this.tree.get('packages').each(function(item) {
- if (!self.toggle)
- item.trigger('filter:added');
- else
- item.trigger('filter:removed');
-
- });
- self.toggle ^= true;
- }
});
}); \ No newline at end of file
diff --git a/module/web/static/js/views/fileView.js b/module/web/static/js/views/fileView.js
index 86f7b33d2..c7b87e871 100644
--- a/module/web/static/js/views/fileView.js
+++ b/module/web/static/js/views/fileView.js
@@ -13,13 +13,11 @@ define(['jquery', 'backbone', 'underscore', 'app', 'views/abstract/itemView'],
},
initialize: function() {
- this.model.on('change', this.render, this);
- this.model.on('remove', this.destroy, this);
+ this.listenTo(this.model, 'change', this.render);
+ this.listenTo(this.model, 'remove', this.destroy);
},
onDestroy: function() {
- this.model.off('change', this.render);
- this.model.off('remove', this.destroy);
},
render: function() {
diff --git a/module/web/static/js/views/packageView.js b/module/web/static/js/views/packageView.js
index eb3edccd8..93ebfb7e4 100644
--- a/module/web/static/js/views/packageView.js
+++ b/module/web/static/js/views/packageView.js
@@ -10,6 +10,7 @@ define(['jquery', 'app', 'views/abstract/itemView', 'underscore'],
events: {
'click .package-name': 'open',
'click .iconf-trash': 'deleteItem',
+ 'click .iconf-refresh': 'restart',
'click .select': 'select'
},
@@ -19,19 +20,31 @@ define(['jquery', 'app', 'views/abstract/itemView', 'underscore'],
expanded: false,
initialize: function() {
- this.model.on('filter:added', this.hide, this);
- this.model.on('filter:removed', this.show, this);
- this.model.on('change', this.render, this);
- this.model.on('remove', this.unrender, this);
+ this.listenTo(this.model, 'filter:added', this.hide);
+ this.listenTo(this.model, 'filter:removed', this.show);
+ this.listenTo(this.model, 'change', this.render);
+ this.listenTo(this.model, 'remove', this.unrender);
+
+ // Clear drop down menu
+ var self = this;
+ this.$el.on('mouseleave', function() {
+ self.$('.dropdown-menu').hide();
+ });
},
onDestroy: function() {
- this.model.off('filter:added', this.hide); // TODO
},
// Render everything, optional only the fileViews
render: function() {
this.$el.html(this.template(this.model.toJSON()));
+ this.$el.initTooltips();
+
+ // Init the dropdown-menu
+ var self = this;
+ this.$('.iconf-chevron-down').click(function() {
+ self.$('.dropdown-menu').stop(true, true).delay(200).animate({opacity: 'toggle'});
+ });
return this;
},
diff --git a/module/web/static/js/views/selectionView.js b/module/web/static/js/views/selectionView.js
index 673753cba..8dbd069bd 100644
--- a/module/web/static/js/views/selectionView.js
+++ b/module/web/static/js/views/selectionView.js
@@ -10,7 +10,7 @@ define(['jquery', 'backbone', 'underscore', 'app'],
'click .iconf-check': 'deselect',
'click .iconf-pause': 'pause',
'click .iconf-trash': 'trash',
- 'click .iconf-refresh': 'refresh'
+ 'click .iconf-refresh': 'restart'
},
// available packages
@@ -48,8 +48,10 @@ define(['jquery', 'backbone', 'underscore', 'app'],
var files = this.get_files().length;
var packs = this.get_packs().length;
- if (files + packs > 0)
+ if (files + packs > 0) {
this.$el.html(this.template({files: files, packs: packs}));
+ this.$el.initTooltips('bottom');
+ }
if (files + packs > 0 && this.current === 0)
this.$el.slideOut();
@@ -90,11 +92,18 @@ define(['jquery', 'backbone', 'underscore', 'app'],
pack.destroy();
});
- this.render();
+ this.deselect();
},
- refresh: function() {
- // TODO
+ restart: function() {
+ this.get_files().map(function(file) {
+ file.restart();
+ });
+ this.get_packs().map(function(pack) {
+ pack.restart();
+ });
+
+ this.deselect();
}
});
}); \ No newline at end of file
diff --git a/module/web/templates/default/dashboard.html b/module/web/templates/default/dashboard.html
index 1d4412846..2de3a999d 100644
--- a/module/web/templates/default/dashboard.html
+++ b/module/web/templates/default/dashboard.html
@@ -28,15 +28,21 @@
<span class="badge badge-success badge-ghost"><i class="iconf-tag"></i> Add Tag</span>
</div>
<div class="package-indicator">
- <i class="iconf-pause"></i>
- <i class="iconf-refresh"></i>
+ <i class="iconf-pause" data-toggle="tooltip" title="Pause Package"></i>
+ <i class="iconf-refresh" data-toggle="tooltip" title="Restart Package"></i>
<%= if shared %>
- <i class="iconf-eye-open"></i>
+ <i class="iconf-eye-open" data-toggle="tooltip" title="Package is public"></i>
<% else %>
- <i class="iconf-eye-close"></i>
+ <i class="iconf-eye-close" data-toggle="tooltip" title="Package is private"></i>
<%/if%>
- <i class="iconf-trash"></i>
- <i class="iconf-chevron-down"></i>
+ <i class="iconf-trash" data-toggle="tooltip" title="Delete Package"></i>
+ <i class="iconf-chevron-down" data-toggle="dropdown">
+ </i>
+ <ul class="dropdown-menu">
+ <li><a>Link</a></li>
+ <li><a>Link</a></li>
+ <li><a>Link</a></li>
+ </ul>
</div>
<div class="progress">
<div class="bar bar-info" style="width: 50%">
@@ -60,7 +66,7 @@
<i class="icon-file icon-white"></i>&nbsp;
<span class="name">
- File <% fid %>: <% name %>
+ <% name %>
</span>
</div>
<div class="file-row second">
@@ -76,7 +82,7 @@
</script>
<script type="text/template" id="template-select">
- <i class="iconf-check"></i>&nbsp;
+ <i class="iconf-check" data-toggle="tooltip" title="Deselect"></i>&nbsp;
<%= if packs %>
<% packs %> packages
<%/if %>
@@ -85,9 +91,9 @@
<%/if %>
selected
&nbsp;|&nbsp;
- <i class="iconf-pause"></i>&nbsp;
- <i class="iconf-trash"></i>&nbsp;
- <i class="iconf-refresh"></i>
+ <i class="iconf-pause" data-toggle="tooltip" title="Pause"></i>&nbsp;
+ <i class="iconf-trash" data-toggle="tooltip" title="Delete"></i>&nbsp;
+ <i class="iconf-refresh" data-toggle="tooltip" title="Restart"></i>
</script>
{% endblock %}