Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions apps/comments/js/commentmodel.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,20 @@
*/

(function(OC, OCA) {
var NS_OWNCLOUD = 'http://owncloud.org/ns';

_.extend(OC.Files.Client, {
PROPERTY_FILEID: '{' + OC.Files.Client.NS_OWNCLOUD + '}id',
PROPERTY_MESSAGE: '{' + OC.Files.Client.NS_OWNCLOUD + '}message',
PROPERTY_ACTORTYPE: '{' + OC.Files.Client.NS_OWNCLOUD + '}actorType',
PROPERTY_ACTORID: '{' + OC.Files.Client.NS_OWNCLOUD + '}actorId',
PROPERTY_ISUNREAD: '{' + OC.Files.Client.NS_OWNCLOUD + '}isUnread',
PROPERTY_OBJECTID: '{' + OC.Files.Client.NS_OWNCLOUD + '}objectId',
PROPERTY_OBJECTTYPE: '{' + OC.Files.Client.NS_OWNCLOUD + '}objectType',
PROPERTY_ACTORDISPLAYNAME: '{' + OC.Files.Client.NS_OWNCLOUD + '}actorDisplayName',
PROPERTY_CREATIONDATETIME: '{' + OC.Files.Client.NS_OWNCLOUD + '}creationDateTime',
PROPERTY_MENTIONS: '{' + OC.Files.Client.NS_OWNCLOUD + '}mentions'
});

/**
* @class OCA.Comments.CommentModel
* @classdesc
Expand All @@ -27,16 +40,16 @@
},

davProperties: {
'id': '{' + NS_OWNCLOUD + '}id',
'message': '{' + NS_OWNCLOUD + '}message',
'actorType': '{' + NS_OWNCLOUD + '}actorType',
'actorId': '{' + NS_OWNCLOUD + '}actorId',
'actorDisplayName': '{' + NS_OWNCLOUD + '}actorDisplayName',
'creationDateTime': '{' + NS_OWNCLOUD + '}creationDateTime',
'objectType': '{' + NS_OWNCLOUD + '}objectType',
'objectId': '{' + NS_OWNCLOUD + '}objectId',
'isUnread': '{' + NS_OWNCLOUD + '}isUnread',
'mentions': '{' + NS_OWNCLOUD + '}mentions'
'id': OC.Files.Client.PROPERTY_FILEID,
'message': OC.Files.Client.PROPERTY_MESSAGE,
'actorType': OC.Files.Client.PROPERTY_ACTORTYPE,
'actorId': OC.Files.Client.PROPERTY_ACTORID,
'actorDisplayName': OC.Files.Client.PROPERTY_ACTORDISPLAYNAME,
'creationDateTime': OC.Files.Client.PROPERTY_CREATIONDATETIME,
'objectType': OC.Files.Client.PROPERTY_OBJECTTYPE,
'objectId': OC.Files.Client.PROPERTY_OBJECTID,
'isUnread': OC.Files.Client.PROPERTY_ISUNREAD,
'mentions': OC.Files.Client.PROPERTY_MENTIONS
},

parse: function(data) {
Expand Down Expand Up @@ -78,4 +91,3 @@

OCA.Comments.CommentModel = CommentModel;
})(OC, OCA);

11 changes: 7 additions & 4 deletions apps/comments/js/commentsummarymodel.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
*/

(function(OC, OCA) {
var NS_OWNCLOUD = 'http://owncloud.org/ns';

_.extend(OC.Files.Client, {
PROPERTY_READMARKER: '{' + OC.Files.Client.NS_OWNCLOUD + '}readMarker'
});

/**
* @class OCA.Comments.CommentSummaryModel
* @classdesc
*
* Model containing summary information related to comments
* like the read marker.
* like the read marker.
*
*/
var CommentSummaryModel = OC.Backbone.Model.extend(
Expand All @@ -37,7 +41,7 @@
_objectId: null,

davProperties: {
'readMarker': '{' + NS_OWNCLOUD + '}readMarker'
'readMarker': OC.Files.Client.PROPERTY_READMARKER
},

/**
Expand All @@ -62,4 +66,3 @@

OCA.Comments.CommentSummaryModel = CommentSummaryModel;
})(OC, OCA);

11 changes: 7 additions & 4 deletions apps/comments/js/filesplugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
/* global Handlebars */

(function() {

_.extend(OC.Files.Client, {
PROPERTY_COMMENTS_UNREAD: '{' + OC.Files.Client.NS_OWNCLOUD + '}comments-unread'
});

var TEMPLATE_COMMENTS_UNREAD =
'<a class="action action-comment permanent" title="{{countMessage}}" href="#">' +
'<img class="svg" src="{{iconUrl}}"/>' +
Expand Down Expand Up @@ -52,19 +57,17 @@

fileList.registerTabView(new OCA.Comments.CommentsTabView('commentsTabView'));

var NS_OC = 'http://owncloud.org/ns';

var oldGetWebdavProperties = fileList._getWebdavProperties;
fileList._getWebdavProperties = function() {
var props = oldGetWebdavProperties.apply(this, arguments);
props.push('{' + NS_OC + '}comments-unread');
props.push(OC.Files.Client.PROPERTY_COMMENTS_UNREAD);
return props;
};

fileList.filesClient.addFileInfoParser(function(response) {
var data = {};
var props = response.propStat[0].properties;
var commentsUnread = props['{' + NS_OC + '}comments-unread'];
var commentsUnread = props[OC.Files.Client.PROPERTY_COMMENTS_UNREAD];
if (!_.isUndefined(commentsUnread) && commentsUnread !== '') {
data.commentsUnread = parseInt(commentsUnread, 10);
}
Expand Down
3 changes: 3 additions & 0 deletions apps/dav/lib/Connector/Sabre/FilesPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node)
$propFind->handle(self::HAS_PREVIEW_PROPERTYNAME, function () use ($node) {
return json_encode($this->previewManager->isAvailable($node->getFileInfo()));
});
$propFind->handle(self::SIZE_PROPERTYNAME, function() use ($node) {
return $node->getSize();
});
}

if ($node instanceof \OCA\DAV\Connector\Sabre\Node) {
Expand Down
2 changes: 0 additions & 2 deletions apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,6 @@ public function testGetPropertiesForFile() {
$node->expects($this->exactly(2))
->method('getOwner')
->will($this->returnValue($user));
$node->expects($this->never())
->method('getSize');

$this->plugin->handleGetProperties(
$propFind,
Expand Down
47 changes: 45 additions & 2 deletions apps/files/js/fileinfomodel.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,18 @@
path: ''
},

initialize: function(data) {
_filesClient: null,

initialize: function(data, options) {
if (!_.isUndefined(data.id)) {
data.id = parseInt(data.id, 10);
}

if( options ){
if (options.filesClient) {
this._filesClient = options.filesClient;
}
}
},

/**
Expand Down Expand Up @@ -73,6 +81,42 @@
*/
getFullPath: function() {
return OC.joinPaths(this.get('path'), this.get('name'));
},

/**
* Reloads missing properties from server and set them in the model.
* @param properties array of properties to be reloaded
* @return ajax call object
*/
reloadProperties: function(properties) {
if( !this._filesClient ){
return;
}

var self = this;
var deferred = $.Deferred();

var targetPath = OC.joinPaths(this.get('path') + '/', this.get('name'));

this._filesClient.getFileInfo(targetPath, {
properties: properties
})
.then(function(status, data) {
// the following lines should be extracted to a mapper

if( properties.indexOf(OC.Files.Client.PROPERTY_GETCONTENTLENGTH) !== -1
|| properties.indexOf(OC.Files.Client.PROPERTY_SIZE) !== -1 ) {
self.set('size', data.size);
}

deferred.resolve(status, data);
})
.fail(function(status) {
OC.Notification.showTemporary(t('files', 'Could not load info for file "{file}"', {file: self.get('name')}));
deferred.reject(status);
});

return deferred.promise();
}
});

Expand All @@ -82,4 +126,3 @@
OCA.Files.FileInfoModel = FileInfoModel;

})(OC, OCA);

12 changes: 8 additions & 4 deletions apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,9 @@
// In the future the FileList should work with Backbone.Collection
// and contain existing models that can be used.
// This method would in the future simply retrieve the matching model from the collection.
var model = new OCA.Files.FileInfoModel(this.elementToFile($tr));
var model = new OCA.Files.FileInfoModel(this.elementToFile($tr), {
filesClient: this.filesClient
});
if (!model.get('path')) {
model.set('path', this.getCurrentDirectory(), {silent: true});
}
Expand Down Expand Up @@ -891,11 +893,14 @@
mimetype: $el.attr('data-mime'),
mtime: parseInt($el.attr('data-mtime'), 10),
type: $el.attr('data-type'),
size: parseInt($el.attr('data-size'), 10),
etag: $el.attr('data-etag'),
permissions: parseInt($el.attr('data-permissions'), 10),
hasPreview: $el.attr('data-has-preview') === 'true'
};
var size = $el.attr('data-size');
if (size) {
data.size = parseInt(size, 10);
}
var icon = $el.attr('data-icon');
if (icon) {
data.icon = icon;
Expand Down Expand Up @@ -1029,7 +1034,7 @@
* Returns whether the given file info must be hidden
*
* @param {OC.Files.FileInfo} fileInfo file info
*
*
* @return {boolean} true if the file is a hidden file, false otherwise
*/
_isHiddenFile: function(file) {
Expand Down Expand Up @@ -2828,7 +2833,6 @@
});
uploader.on('fail', function(e, data) {
self._uploader.log('filelist handle fileuploadfail', e, data);

self._uploads = [];

//if user pressed cancel hide upload chrome
Expand Down
13 changes: 13 additions & 0 deletions apps/files/js/mainfileinfodetailview.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,19 @@
if (this.model) {
this.model.on('change', this._onModelChanged, this);
}

if (this.model) {
var properties = [];
if( !this.model.has('size') ) {
properties.push(OC.Files.Client.PROPERTY_SIZE);
properties.push(OC.Files.Client.PROPERTY_GETCONTENTLENGTH);
}

if( properties.length > 0){
this.model.reloadProperties(properties);
}
}

this.render();
},

Expand Down
17 changes: 10 additions & 7 deletions apps/files/js/tagsplugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@

(function(OCA) {

_.extend(OC.Files.Client, {
PROPERTY_TAGS: '{' + OC.Files.Client.NS_OWNCLOUD + '}tags',
PROPERTY_FAVORITE: '{' + OC.Files.Client.NS_OWNCLOUD + '}favorite'
});

var TEMPLATE_FAVORITE_ACTION =
'<a href="#" ' +
'class="action action-favorite {{#isFavorite}}permanent{{/isFavorite}}">' +
Expand Down Expand Up @@ -162,24 +167,22 @@
return fileInfo;
};

var NS_OC = 'http://owncloud.org/ns';

var oldGetWebdavProperties = fileList._getWebdavProperties;
fileList._getWebdavProperties = function() {
var props = oldGetWebdavProperties.apply(this, arguments);
props.push('{' + NS_OC + '}tags');
props.push('{' + NS_OC + '}favorite');
props.push(OC.Files.Client.PROPERTY_TAGS);
props.push(OC.Files.Client.PROPERTY_FAVORITE);
return props;
};

fileList.filesClient.addFileInfoParser(function(response) {
var data = {};
var props = response.propStat[0].properties;
var tags = props['{' + NS_OC + '}tags'];
var favorite = props['{' + NS_OC + '}favorite'];
var tags = props[OC.Files.Client.PROPERTY_TAGS];
var favorite = props[OC.Files.Client.PROPERTY_FAVORITE];
if (tags && tags.length) {
tags = _.chain(tags).filter(function(xmlvalue) {
return (xmlvalue.namespaceURI === NS_OC && xmlvalue.nodeName.split(':')[1] === 'tag');
return (xmlvalue.namespaceURI === OC.Files.Client.NS_OWNCLOUD && xmlvalue.nodeName.split(':')[1] === 'tag');
}).map(function(xmlvalue) {
return xmlvalue.textContent || xmlvalue.text;
}).value();
Expand Down
28 changes: 20 additions & 8 deletions apps/files_sharing/js/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
*/

(function() {

_.extend(OC.Files.Client, {
PROPERTY_SHARE_TYPES: '{' + OC.Files.Client.NS_OWNCLOUD + '}share-types',
PROPERTY_OWNER_DISPLAY_NAME: '{' + OC.Files.Client.NS_OWNCLOUD + '}owner-display-name'
});

if (!OCA.Sharing) {
OCA.Sharing = {};
}
Expand Down Expand Up @@ -65,32 +71,38 @@
fileInfo.shareTypes = shareTypes;
}

if( $el.attr('data-expiration')){
var expirationTimestamp = parseInt($el.attr('data-expiration'));
fileInfo.shares = [];
fileInfo.shares.push({expiration: expirationTimestamp});
}

fileInfo.recipientsDisplayName = $el.attr('data-share-recipients') || undefined;

return fileInfo;
};

var NS_OC = 'http://owncloud.org/ns';

var oldGetWebdavProperties = fileList._getWebdavProperties;
fileList._getWebdavProperties = function() {
var props = oldGetWebdavProperties.apply(this, arguments);
props.push('{' + NS_OC + '}owner-display-name');
props.push('{' + NS_OC + '}share-types');
props.push(OC.Files.Client.PROPERTY_OWNER_DISPLAY_NAME);
props.push(OC.Files.Client.PROPERTY_SHARE_TYPES);
return props;
};

fileList.filesClient.addFileInfoParser(function(response) {
var data = {};
var props = response.propStat[0].properties;
var permissionsProp = props['{' + NS_OC + '}permissions'];
var permissionsProp = props[OC.Files.Client.PROPERTY_PERMISSIONS];

if (permissionsProp && permissionsProp.indexOf('S') >= 0) {
data.shareOwner = props['{' + NS_OC + '}owner-display-name'];
data.shareOwner = props[OC.Files.Client.PROPERTY_OWNER_DISPLAY_NAME];
}

var shareTypesProp = props['{' + NS_OC + '}share-types'];
var shareTypesProp = props[OC.Files.Client.PROPERTY_SHARE_TYPES];
if (shareTypesProp) {
data.shareTypes = _.chain(shareTypesProp).filter(function(xmlvalue) {
return (xmlvalue.namespaceURI === NS_OC && xmlvalue.nodeName.split(':')[1] === 'share-type');
return (xmlvalue.namespaceURI === OC.Files.Client.NS_OWNCLOUD && xmlvalue.nodeName.split(':')[1] === 'share-type');
}).map(function(xmlvalue) {
return parseInt(xmlvalue.textContent || xmlvalue.text, 10);
}).value();
Expand Down
Loading