1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-06-20 12:22:24 +00:00
seahub/static/scripts/sysadmin-app/models/dirent.js

55 lines
1.6 KiB
JavaScript
Raw Normal View History

2016-05-25 02:45:22 +00:00
define([
'underscore',
'backbone',
'common',
], function(_, Backbone, Common) {
'use strict';
2016-05-27 08:42:40 +00:00
var DirentModel = Backbone.Model.extend({
2016-05-25 02:45:22 +00:00
// get the absolute path within the library
getPath: function() {
return Common.pathJoin([this.collection.path, this.get('obj_name')]);
},
// return the URL to visit the folder or file
getWebUrl: function() {
var dir = this.collection;
var dirent_path = this.getPath();
if (this.get('is_file')) {
return '#';
} else {
return '#libraries/' + dir.repo_id + '/dirents' + Common.encodePath(dirent_path);
}
},
getDownloadUrl: function() {
var dir = this.collection;
var dirent_path = this.getPath();
return app.config.siteRoot + "api/v2.1/admin/libraries/" + dir.repo_id
+ "/dirent/?path=" + Common.encodePath(dirent_path) + "&dl=1";
},
getDeleteUrl: function() {
var dir = this.collection;
var dirent_path = this.getPath();
return app.config.siteRoot + "api/v2.1/admin/libraries/" + dir.repo_id
+ "/dirent/?path=" + Common.encodePath(dirent_path);
},
getIconUrl: function(size) {
if (this.get('is_file')) {
return Common.getFileIconUrl(this.get('obj_name'), size);
} else {
var is_readonly = this.get('perm') == 'r';
return Common.getDirIconUrl(is_readonly, size);
}
}
});
2016-05-27 08:42:40 +00:00
return DirentModel;
2016-05-25 02:45:22 +00:00
});