summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-11-02 14:17:49 +0100
committerLukas Reschke <lukas@owncloud.com>2015-11-22 16:05:50 +0100
commitdc8ce87a26aaeeec655530e2960561498e61c94a (patch)
tree1672ef688aae9514841289c02c95d1a784126f0e /core
parentf20232d4bd3e78c4ea980aa03849c3f9bcf5b893 (diff)
downloadnextcloud-server-dc8ce87a26aaeeec655530e2960561498e61c94a.tar.gz
nextcloud-server-dc8ce87a26aaeeec655530e2960561498e61c94a.zip
Query tags/favorite through Webdav in file list
Diffstat (limited to 'core')
-rw-r--r--core/js/files/client.js63
-rw-r--r--core/js/files/fileinfo.js5
2 files changed, 58 insertions, 10 deletions
diff --git a/core/js/files/client.js b/core/js/files/client.js
index 9bb7bb999fd..5ee90d2d52e 100644
--- a/core/js/files/client.js
+++ b/core/js/files/client.js
@@ -125,11 +125,18 @@
/**
* Client from the library
*
- * @type nl.sara.webdav.Client
+ * @type dav.Client
*/
_client: null,
/**
+ * Array of file info parsing functions.
+ *
+ * @type Array<OC.Files.Client~parseFileInfo>
+ */
+ _fileInfoParsers: [],
+
+ /**
* Returns the configured XHR provider for davclient
* @return {XMLHttpRequest}
*/
@@ -273,8 +280,7 @@
id: this._parseFileId(props['{' + Client.NS_OWNCLOUD + '}id']),
path: OC.dirname(path) || '/',
name: OC.basename(path),
- mtime: new Date(props['{' + Client.NS_DAV + '}getlastmodified']),
- _props: props
+ mtime: new Date(props['{' + Client.NS_DAV + '}getlastmodified'])
};
var etagProp = props['{' + Client.NS_DAV + '}getetag'];
@@ -350,6 +356,11 @@
}
}
+ // extend the parsed data using the custom parsers
+ _.each(this._fileInfoParsers, function(parserFunction) {
+ _.extend(data, parserFunction(response) || {});
+ });
+
return new FileInfo(data);
},
@@ -381,7 +392,7 @@
*
* @return {Array.<Object>} array of properties
*/
- _getPropfindProperties: function() {
+ getPropfindProperties: function() {
if (!this._propfindProperties) {
this._propfindProperties = _.map(Client._PROPFIND_PROPERTIES, function(propDef) {
return '{' + propDef[0] + '}' + propDef[1];
@@ -397,6 +408,7 @@
* @param {Object} [options] options
* @param {boolean} [options.includeParent=false] set to true to keep
* the parent folder in the result list
+ * @param {Array} [options.properties] list of Webdav properties to retrieve
*
* @return {Promise} promise
*/
@@ -404,14 +416,21 @@
if (!path) {
path = '';
}
+ options = options || {};
var self = this;
var deferred = $.Deferred();
var promise = deferred.promise();
+ var properties;
+ if (_.isUndefined(options.properties)) {
+ properties = this.getPropfindProperties();
+ } else {
+ properties = options.properties;
+ }
// TODO: headers
this._client.propFind(
this._buildUrl(path),
- this._getPropfindProperties(),
+ properties,
1
).then(function(result) {
if (self._isSuccessStatus(result.status)) {
@@ -432,23 +451,29 @@
* Returns the file info of a given path.
*
* @param {String} path path
- * @param {Array} [properties] list of webdav properties to
- * retrieve
+ * @param {Array} [options.properties] list of Webdav properties to retrieve
*
* @return {Promise} promise
*/
- getFileInfo: function(path) {
+ getFileInfo: function(path, options) {
if (!path) {
path = '';
}
+ options = options || {};
var self = this;
var deferred = $.Deferred();
var promise = deferred.promise();
+ var properties;
+ if (_.isUndefined(options.properties)) {
+ properties = this.getPropfindProperties();
+ } else {
+ properties = options.properties;
+ }
// TODO: headers
this._client.propFind(
this._buildUrl(path),
- this._getPropfindProperties(),
+ properties,
0
).then(
function(result) {
@@ -633,10 +658,30 @@
}
);
return promise;
+ },
+
+ /**
+ * Add a file info parser function
+ *
+ * @param {OC.Files.Client~parseFileInfo>}
+ */
+ addFileInfoParser: function(parserFunction) {
+ this._fileInfoParsers.push(parserFunction);
}
};
+ /**
+ * File info parser function
+ *
+ * This function receives a list of Webdav properties as input and
+ * should return a hash array of parsed properties, if applicable.
+ *
+ * @callback OC.Files.Client~parseFileInfo
+ * @param {Object} XML Webdav properties
+ * @return {Array} array of parsed property values
+ */
+
if (!OC.Files) {
/**
* @namespace OC.Files
diff --git a/core/js/files/fileinfo.js b/core/js/files/fileinfo.js
index 95af07b7992..c4a9eeb3d7c 100644
--- a/core/js/files/fileinfo.js
+++ b/core/js/files/fileinfo.js
@@ -34,7 +34,6 @@
this.mimetype = data.mimetype || 'application/octet-stream';
this.mountType = data.mountType;
this.icon = data.icon;
- this._props = data._props;
if (data.type) {
this.type = data.type;
@@ -44,6 +43,10 @@
this.type = 'file';
}
+ if (data.tags) {
+ this.tags = data.tags;
+ }
+
if (!this.mimetype) {
if (this.type === 'dir') {
this.mimetype = 'httpd/unix-directory';