mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-24 22:35:39 -04:00
UI Cleanup - Updated Shared and Shims subtrees.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
var Marionette = require('marionette');
|
||||
|
||||
module.exports = Marionette.CompositeView.extend({template : 'Shared/FileBrowser/EmptyViewTemplate'});
|
||||
module.exports = Marionette.CompositeView.extend({
|
||||
template : 'Shared/FileBrowser/EmptyViewTemplate'
|
||||
});
|
||||
@@ -5,12 +5,13 @@ var FileBrowserModel = require('./FileBrowserModel');
|
||||
module.exports = Backbone.Collection.extend({
|
||||
model : FileBrowserModel,
|
||||
url : window.NzbDrone.ApiRoot + '/filesystem',
|
||||
parse : function(response){
|
||||
|
||||
parse : function(response) {
|
||||
var contents = [];
|
||||
if(response.parent || response.parent === '') {
|
||||
if (response.parent || response.parent === '') {
|
||||
var type = 'parent';
|
||||
var name = '...';
|
||||
if(response.parent === '') {
|
||||
if (response.parent === '') {
|
||||
type = 'computer';
|
||||
name = 'My Computer';
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var _ = require('underscore');
|
||||
var _ = require('underscore');
|
||||
var vent = require('vent');
|
||||
var Marionette = require('marionette');
|
||||
var Backgrid = require('backgrid');
|
||||
@@ -13,19 +13,25 @@ var LoadingView = require('../LoadingView');
|
||||
require('../../Mixins/DirectoryAutoComplete');
|
||||
|
||||
module.exports = Marionette.Layout.extend({
|
||||
template : "Shared/FileBrowser/FileBrowserLayoutTemplate",
|
||||
regions : {browser : "#x-browser"},
|
||||
ui : {
|
||||
path : ".x-path",
|
||||
indicator : ".x-indicator"
|
||||
template : 'Shared/FileBrowser/FileBrowserLayoutTemplate',
|
||||
|
||||
regions : {
|
||||
browser : '#x-browser'
|
||||
},
|
||||
events : {
|
||||
"typeahead:selected .x-path" : "_pathChanged",
|
||||
"typeahead:autocompleted .x-path" : "_pathChanged",
|
||||
"keyup .x-path" : "_inputChanged",
|
||||
"click .x-ok" : "_selectPath"
|
||||
|
||||
ui : {
|
||||
path : '.x-path',
|
||||
indicator : '.x-indicator'
|
||||
},
|
||||
initialize : function(options){
|
||||
|
||||
events : {
|
||||
'typeahead:selected .x-path' : '_pathChanged',
|
||||
'typeahead:autocompleted .x-path' : '_pathChanged',
|
||||
'keyup .x-path' : '_inputChanged',
|
||||
'click .x-ok' : '_selectPath'
|
||||
},
|
||||
|
||||
initialize : function(options) {
|
||||
this.collection = new FileBrowserCollection();
|
||||
this.collection.showFiles = options.showFiles || false;
|
||||
this.collection.showLastModified = options.showLastModified || false;
|
||||
@@ -34,25 +40,30 @@ module.exports = Marionette.Layout.extend({
|
||||
this.listenTo(this.collection, "sync", this._showGrid);
|
||||
this.listenTo(this.collection, "filebrowser:folderselected", this._rowSelected);
|
||||
},
|
||||
onRender : function(){
|
||||
|
||||
onRender : function() {
|
||||
this.browser.show(new LoadingView());
|
||||
this.ui.path.directoryAutoComplete();
|
||||
this._fetchCollection(this.input.val());
|
||||
this._updatePath(this.input.val());
|
||||
},
|
||||
_setColumns : function(){
|
||||
this.columns = [{
|
||||
name : "type",
|
||||
label : "",
|
||||
sortable : false,
|
||||
cell : FileBrowserTypeCell
|
||||
}, {
|
||||
name : "name",
|
||||
label : "Name",
|
||||
sortable : false,
|
||||
cell : FileBrowserNameCell
|
||||
}];
|
||||
if(this.collection.showLastModified) {
|
||||
|
||||
_setColumns : function() {
|
||||
this.columns = [
|
||||
{
|
||||
name : "type",
|
||||
label : "",
|
||||
sortable : false,
|
||||
cell : FileBrowserTypeCell
|
||||
},
|
||||
{
|
||||
name : "name",
|
||||
label : "Name",
|
||||
sortable : false,
|
||||
cell : FileBrowserNameCell
|
||||
}
|
||||
];
|
||||
if (this.collection.showLastModified) {
|
||||
this.columns.push({
|
||||
name : "lastModified",
|
||||
label : "Last Modified",
|
||||
@@ -60,7 +71,7 @@ module.exports = Marionette.Layout.extend({
|
||||
cell : RelativeDateCell
|
||||
});
|
||||
}
|
||||
if(this.collection.showFiles) {
|
||||
if (this.collection.showFiles) {
|
||||
this.columns.push({
|
||||
name : "size",
|
||||
label : "Size",
|
||||
@@ -69,17 +80,19 @@ module.exports = Marionette.Layout.extend({
|
||||
});
|
||||
}
|
||||
},
|
||||
_fetchCollection : function(path){
|
||||
|
||||
_fetchCollection : function(path) {
|
||||
this.ui.indicator.show();
|
||||
var data = {includeFiles : this.collection.showFiles};
|
||||
if(path) {
|
||||
var data = { includeFiles : this.collection.showFiles };
|
||||
if (path) {
|
||||
data.path = path;
|
||||
}
|
||||
this.collection.fetch({data : data});
|
||||
this.collection.fetch({ data : data });
|
||||
},
|
||||
_showGrid : function(){
|
||||
|
||||
_showGrid : function() {
|
||||
this.ui.indicator.hide();
|
||||
if(this.collection.models.length === 0) {
|
||||
if (this.collection.models.length === 0) {
|
||||
this.browser.show(new EmptyView());
|
||||
return;
|
||||
}
|
||||
@@ -91,27 +104,32 @@ module.exports = Marionette.Layout.extend({
|
||||
});
|
||||
this.browser.show(grid);
|
||||
},
|
||||
_rowSelected : function(model){
|
||||
|
||||
_rowSelected : function(model) {
|
||||
var path = model.get("path");
|
||||
this._updatePath(path);
|
||||
this._fetchCollection(path);
|
||||
},
|
||||
_pathChanged : function(e, path){
|
||||
|
||||
_pathChanged : function(e, path) {
|
||||
this._fetchCollection(path.value);
|
||||
this._updatePath(path.value);
|
||||
},
|
||||
_inputChanged : function(){
|
||||
|
||||
_inputChanged : function() {
|
||||
var path = this.ui.path.val();
|
||||
if(path === "" || path.endsWith("\\") || path.endsWith("/")) {
|
||||
if (path === "" || path.endsWith("\\") || path.endsWith("/")) {
|
||||
this._fetchCollection(path);
|
||||
}
|
||||
},
|
||||
_updatePath : function(path){
|
||||
if(path !== undefined || path !== null) {
|
||||
|
||||
_updatePath : function(path) {
|
||||
if (path !== undefined || path !== null) {
|
||||
this.ui.path.val(path);
|
||||
}
|
||||
},
|
||||
_selectPath : function(){
|
||||
|
||||
_selectPath : function() {
|
||||
this.input.val(this.ui.path.val());
|
||||
this.input.trigger("change");
|
||||
vent.trigger(vent.Commands.CloseFileBrowser);
|
||||
|
||||
@@ -3,44 +3,48 @@ var Backbone = require('backbone');
|
||||
var Marionette = require('marionette');
|
||||
require('bootstrap');
|
||||
|
||||
module.exports = (function(){
|
||||
var region = Marionette.Region.extend({
|
||||
el : '#file-browser-modal-region',
|
||||
constructor : function(){
|
||||
Backbone.Marionette.Region.prototype.constructor.apply(this, arguments);
|
||||
this.on('show', this.showModal, this);
|
||||
},
|
||||
getEl : function(selector){
|
||||
var $el = $(selector);
|
||||
$el.on('hidden', this.close);
|
||||
return $el;
|
||||
},
|
||||
showModal : function(){
|
||||
this.$el.addClass('modal fade');
|
||||
this.$el.attr('tabindex', '-1');
|
||||
this.$el.css('z-index', '1060');
|
||||
this.$el.modal({
|
||||
show : true,
|
||||
keyboard : true,
|
||||
backdrop : true
|
||||
});
|
||||
this.$el.on('hide.bs.modal', $.proxy(this._closing, this));
|
||||
this.$el.on('shown.bs.modal', function(){
|
||||
$('.modal-backdrop:last').css('z-index', 1059);
|
||||
});
|
||||
this.currentView.$el.addClass('modal-dialog');
|
||||
},
|
||||
closeModal : function(){
|
||||
$(this.el).modal('hide');
|
||||
this.reset();
|
||||
},
|
||||
_closing : function(){
|
||||
if(this.$el) {
|
||||
this.$el.off('hide.bs.modal');
|
||||
this.$el.off('shown.bs.modal');
|
||||
}
|
||||
this.reset();
|
||||
var region = Marionette.Region.extend({
|
||||
el : '#file-browser-modal-region',
|
||||
|
||||
constructor : function() {
|
||||
Backbone.Marionette.Region.prototype.constructor.apply(this, arguments);
|
||||
this.on('show', this.showModal, this);
|
||||
},
|
||||
|
||||
getEl : function(selector) {
|
||||
var $el = $(selector);
|
||||
$el.on('hidden', this.close);
|
||||
return $el;
|
||||
},
|
||||
|
||||
showModal : function() {
|
||||
this.$el.addClass('modal fade');
|
||||
this.$el.attr('tabindex', '-1');
|
||||
this.$el.css('z-index', '1060');
|
||||
this.$el.modal({
|
||||
show : true,
|
||||
keyboard : true,
|
||||
backdrop : true
|
||||
});
|
||||
this.$el.on('hide.bs.modal', $.proxy(this._closing, this));
|
||||
this.$el.on('shown.bs.modal', function() {
|
||||
$('.modal-backdrop:last').css('z-index', 1059);
|
||||
});
|
||||
this.currentView.$el.addClass('modal-dialog');
|
||||
},
|
||||
|
||||
closeModal : function() {
|
||||
$(this.el).modal('hide');
|
||||
this.reset();
|
||||
},
|
||||
|
||||
_closing : function() {
|
||||
if (this.$el) {
|
||||
this.$el.off('hide.bs.modal');
|
||||
this.$el.off('shown.bs.modal');
|
||||
}
|
||||
});
|
||||
return region;
|
||||
}).call(this);
|
||||
this.reset();
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = region;
|
||||
@@ -3,11 +3,16 @@ var NzbDroneCell = require('../../Cells/NzbDroneCell');
|
||||
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'file-browser-name-cell',
|
||||
render : function(){
|
||||
|
||||
render : function() {
|
||||
this.$el.empty();
|
||||
|
||||
var name = this.model.get(this.column.get('name'));
|
||||
|
||||
this.$el.html(name);
|
||||
|
||||
this.delegateEvents();
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -2,17 +2,22 @@ var _ = require('underscore');
|
||||
var Backgrid = require('backgrid');
|
||||
|
||||
module.exports = Backgrid.Row.extend({
|
||||
className : 'file-browser-row',
|
||||
events : {"click" : '_selectRow'},
|
||||
className : 'file-browser-row',
|
||||
|
||||
events : {
|
||||
'click' : '_selectRow'
|
||||
},
|
||||
|
||||
_originalInit : Backgrid.Row.prototype.initialize,
|
||||
initialize : function(){
|
||||
|
||||
initialize : function() {
|
||||
this._originalInit.apply(this, arguments);
|
||||
},
|
||||
_selectRow : function(){
|
||||
if(this.model.get('type') === 'file') {
|
||||
|
||||
_selectRow : function() {
|
||||
if (this.model.get('type') === 'file') {
|
||||
this.model.collection.trigger('filebrowser:fileselected', this.model);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.model.collection.trigger('filebrowser:folderselected', this.model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,24 +3,26 @@ var NzbDroneCell = require('../../Cells/NzbDroneCell');
|
||||
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'file-browser-type-cell',
|
||||
render : function(){
|
||||
|
||||
render : function() {
|
||||
this.$el.empty();
|
||||
|
||||
var type = this.model.get(this.column.get('name'));
|
||||
var icon = 'icon-hdd';
|
||||
if(type === 'computer') {
|
||||
|
||||
if (type === 'computer') {
|
||||
icon = 'icon-desktop';
|
||||
}
|
||||
else if(type === 'parent') {
|
||||
} else if (type === 'parent') {
|
||||
icon = 'icon-level-up';
|
||||
}
|
||||
else if(type === 'folder') {
|
||||
} else if (type === 'folder') {
|
||||
icon = 'icon-folder-close-alt';
|
||||
}
|
||||
else if(type === 'file') {
|
||||
} else if (type === 'file') {
|
||||
icon = 'icon-file-alt';
|
||||
}
|
||||
|
||||
this.$el.html('<i class="{0}"></i>'.format(icon));
|
||||
this.delegateEvents();
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user