parent
b94ff97a77
commit
2e3114cc28
@ -0,0 +1,105 @@ |
|||||||
|
/* |
||||||
|
* Copyright (c) 2014 Vincent Petry <pvince81@owncloud.com> |
||||||
|
* |
||||||
|
* This file is licensed under the Affero General Public License version 3 |
||||||
|
* or later. |
||||||
|
* |
||||||
|
* See the COPYING-README file. |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
// HACK: this piece needs to be loaded AFTER the files app (for unit tests)
|
||||||
|
$(document).ready(function () { |
||||||
|
(function (OCA) { |
||||||
|
/** |
||||||
|
* @class OCA.Files.RecentFileList |
||||||
|
* @augments OCA.Files.RecentFileList |
||||||
|
* |
||||||
|
* @classdesc Recent file list. |
||||||
|
* Displays the list of recently modified files |
||||||
|
* |
||||||
|
* @param $el container element with existing markup for the #controls |
||||||
|
* and a table |
||||||
|
* @param [options] map of options, see other parameters |
||||||
|
*/ |
||||||
|
var RecentFileList = function ($el, options) { |
||||||
|
options.sorting = { |
||||||
|
mode: 'mtime', |
||||||
|
direction: 'desc' |
||||||
|
}; |
||||||
|
this.initialize($el, options); |
||||||
|
}; |
||||||
|
RecentFileList.prototype = _.extend({}, OCA.Files.FileList.prototype, |
||||||
|
/** @lends OCA.Files.RecentFileList.prototype */ { |
||||||
|
id: 'recent', |
||||||
|
appName: t('files', 'Recent'), |
||||||
|
|
||||||
|
_clientSideSort: true, |
||||||
|
_allowSelection: false, |
||||||
|
|
||||||
|
/** |
||||||
|
* @private |
||||||
|
*/ |
||||||
|
initialize: function () { |
||||||
|
OCA.Files.FileList.prototype.initialize.apply(this, arguments); |
||||||
|
if (this.initialized) { |
||||||
|
return; |
||||||
|
} |
||||||
|
OC.Plugins.attach('OCA.Files.RecentFileList', this); |
||||||
|
}, |
||||||
|
|
||||||
|
updateEmptyContent: function () { |
||||||
|
var dir = this.getCurrentDirectory(); |
||||||
|
if (dir === '/') { |
||||||
|
// root has special permissions
|
||||||
|
this.$el.find('#emptycontent').toggleClass('hidden', !this.isEmpty); |
||||||
|
this.$el.find('#filestable thead th').toggleClass('hidden', this.isEmpty); |
||||||
|
} |
||||||
|
else { |
||||||
|
OCA.Files.FileList.prototype.updateEmptyContent.apply(this, arguments); |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
|
getDirectoryPermissions: function () { |
||||||
|
return OC.PERMISSION_READ | OC.PERMISSION_DELETE; |
||||||
|
}, |
||||||
|
|
||||||
|
updateStorageStatistics: function () { |
||||||
|
// no op because it doesn't have
|
||||||
|
// storage info like free space / used space
|
||||||
|
}, |
||||||
|
|
||||||
|
reload: function () { |
||||||
|
this.showMask(); |
||||||
|
if (this._reloadCall) { |
||||||
|
this._reloadCall.abort(); |
||||||
|
} |
||||||
|
|
||||||
|
// there is only root
|
||||||
|
this._setCurrentDir('/', false); |
||||||
|
|
||||||
|
this._reloadCall = $.ajax({ |
||||||
|
url: OC.generateUrl('/apps/files/api/v1/recent'), |
||||||
|
type: 'GET', |
||||||
|
dataType: 'json' |
||||||
|
}); |
||||||
|
var callBack = this.reloadCallback.bind(this); |
||||||
|
return this._reloadCall.then(callBack, callBack); |
||||||
|
}, |
||||||
|
|
||||||
|
reloadCallback: function (result) { |
||||||
|
delete this._reloadCall; |
||||||
|
this.hideMask(); |
||||||
|
|
||||||
|
if (result.files) { |
||||||
|
this.setFiles(result.files.sort(this._sortComparator)); |
||||||
|
return true; |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
OCA.Files.RecentFileList = RecentFileList; |
||||||
|
})(OCA); |
||||||
|
}); |
||||||
|
|
@ -0,0 +1,117 @@ |
|||||||
|
/* |
||||||
|
* Copyright (c) 2014 Vincent Petry <pvince81@owncloud.com> |
||||||
|
* |
||||||
|
* This file is licensed under the Affero General Public License version 3 |
||||||
|
* or later. |
||||||
|
* |
||||||
|
* See the COPYING-README file. |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
(function (OCA) { |
||||||
|
/** |
||||||
|
* @namespace OCA.Files.RecentPlugin |
||||||
|
* |
||||||
|
* Registers the recent file list from the files app sidebar. |
||||||
|
*/ |
||||||
|
OCA.Files.RecentPlugin = { |
||||||
|
name: 'Recent', |
||||||
|
|
||||||
|
/** |
||||||
|
* @type OCA.Files.RecentFileList |
||||||
|
*/ |
||||||
|
recentFileList: null, |
||||||
|
|
||||||
|
attach: function () { |
||||||
|
var self = this; |
||||||
|
$('#app-content-recent').on('show.plugin-recent', function (e) { |
||||||
|
self.showFileList($(e.target)); |
||||||
|
}); |
||||||
|
$('#app-content-recent').on('hide.plugin-recent', function () { |
||||||
|
self.hideFileList(); |
||||||
|
}); |
||||||
|
}, |
||||||
|
|
||||||
|
detach: function () { |
||||||
|
if (this.recentFileList) { |
||||||
|
this.recentFileList.destroy(); |
||||||
|
OCA.Files.fileActions.off('setDefault.plugin-recent', this._onActionsUpdated); |
||||||
|
OCA.Files.fileActions.off('registerAction.plugin-recent', this._onActionsUpdated); |
||||||
|
$('#app-content-recent').off('.plugin-recent'); |
||||||
|
this.recentFileList = null; |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
|
showFileList: function ($el) { |
||||||
|
if (!this.recentFileList) { |
||||||
|
this.recentFileList = this._createRecentFileList($el); |
||||||
|
} |
||||||
|
return this.recentFileList; |
||||||
|
}, |
||||||
|
|
||||||
|
hideFileList: function () { |
||||||
|
if (this.recentFileList) { |
||||||
|
this.recentFileList.$fileList.empty(); |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
|
/** |
||||||
|
* Creates the recent file list. |
||||||
|
* |
||||||
|
* @param $el container for the file list |
||||||
|
* @return {OCA.Files.RecentFileList} file list |
||||||
|
*/ |
||||||
|
_createRecentFileList: function ($el) { |
||||||
|
var fileActions = this._createFileActions(); |
||||||
|
// register recent list for sidebar section
|
||||||
|
return new OCA.Files.RecentFileList( |
||||||
|
$el, { |
||||||
|
fileActions: fileActions, |
||||||
|
scrollContainer: $('#app-content') |
||||||
|
} |
||||||
|
); |
||||||
|
}, |
||||||
|
|
||||||
|
_createFileActions: function () { |
||||||
|
// inherit file actions from the files app
|
||||||
|
var fileActions = new OCA.Files.FileActions(); |
||||||
|
// note: not merging the legacy actions because legacy apps are not
|
||||||
|
// compatible with the sharing overview and need to be adapted first
|
||||||
|
fileActions.registerDefaultActions(); |
||||||
|
fileActions.merge(OCA.Files.fileActions); |
||||||
|
|
||||||
|
if (!this._globalActionsInitialized) { |
||||||
|
// in case actions are registered later
|
||||||
|
this._onActionsUpdated = _.bind(this._onActionsUpdated, this); |
||||||
|
OCA.Files.fileActions.on('setDefault.plugin-recent', this._onActionsUpdated); |
||||||
|
OCA.Files.fileActions.on('registerAction.plugin-recent', this._onActionsUpdated); |
||||||
|
this._globalActionsInitialized = true; |
||||||
|
} |
||||||
|
|
||||||
|
// when the user clicks on a folder, redirect to the corresponding
|
||||||
|
// folder in the files app instead of opening it directly
|
||||||
|
fileActions.register('dir', 'Open', OC.PERMISSION_READ, '', function (filename, context) { |
||||||
|
OCA.Files.App.setActiveView('files', {silent: true}); |
||||||
|
var path = OC.joinPaths(context.$file.attr('data-path'), filename); |
||||||
|
OCA.Files.App.fileList.changeDirectory(path, true, true); |
||||||
|
}); |
||||||
|
fileActions.setDefault('dir', 'Open'); |
||||||
|
return fileActions; |
||||||
|
}, |
||||||
|
|
||||||
|
_onActionsUpdated: function (ev) { |
||||||
|
if (ev.action) { |
||||||
|
this.recentFileList.fileActions.registerAction(ev.action); |
||||||
|
} else if (ev.defaultAction) { |
||||||
|
this.recentFileList.fileActions.setDefault( |
||||||
|
ev.defaultAction.mime, |
||||||
|
ev.defaultAction.name |
||||||
|
); |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
})(OCA); |
||||||
|
|
||||||
|
OC.Plugins.register('OCA.Files.App', OCA.Files.RecentPlugin); |
||||||
|
|
@ -0,0 +1,7 @@ |
|||||||
|
<?php |
||||||
|
// Check if we are a user |
||||||
|
OCP\User::checkLoggedIn(); |
||||||
|
|
||||||
|
$tmpl = new OCP\Template('files', 'recentlist', ''); |
||||||
|
|
||||||
|
$tmpl->printPage(); |
@ -0,0 +1,42 @@ |
|||||||
|
<?php /** @var $l OC_L10N */ ?> |
||||||
|
<div id='notification'></div> |
||||||
|
|
||||||
|
<div id="emptycontent" class="hidden"></div> |
||||||
|
|
||||||
|
<input type="hidden" name="dir" value="" id="dir"> |
||||||
|
|
||||||
|
<div class="nofilterresults hidden"> |
||||||
|
<div class="icon-search"></div> |
||||||
|
<h2><?php p($l->t('No entries found in this folder')); ?></h2>
|
||||||
|
<p></p> |
||||||
|
</div> |
||||||
|
|
||||||
|
<table id="filestable"> |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
<th id='headerName' class="hidden column-name"> |
||||||
|
<div id="headerName-container"> |
||||||
|
<a class="name sort columntitle" |
||||||
|
data-sort="name"><span><?php p($l->t('Name')); ?></span></a>
|
||||||
|
</div> |
||||||
|
</th> |
||||||
|
<th id="headerSize" class="hidden column-size"> |
||||||
|
<a class="size sort columntitle" |
||||||
|
data-sort="size"><span><?php p($l->t('Size')); ?></span></a>
|
||||||
|
</th> |
||||||
|
<th id="headerDate" class="hidden column-mtime"> |
||||||
|
<a id="modified" class="columntitle" |
||||||
|
data-sort="mtime"><span><?php p($l->t('Modified')); ?></span><span
|
||||||
|
class="sort-indicator"></span></a> |
||||||
|
<span class="selectedActions"><a href="" class="delete-selected"> |
||||||
|
<span><?php p($l->t('Delete')) ?></span>
|
||||||
|
<span class="icon icon-delete"></span> |
||||||
|
</a></span> |
||||||
|
</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody id="fileList"> |
||||||
|
</tbody> |
||||||
|
<tfoot> |
||||||
|
</tfoot> |
||||||
|
</table> |
Loading…
Reference in new issue