mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-03 07:55:36 +00:00
update
This commit is contained in:
54
static/scripts/sysadmin-app/models/dirent.js
Normal file
54
static/scripts/sysadmin-app/models/dirent.js
Normal file
@@ -0,0 +1,54 @@
|
||||
define([
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common',
|
||||
], function(_, Backbone, Common) {
|
||||
'use strict';
|
||||
|
||||
var DirentModel = Backbone.Model.extend({
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return DirentModel;
|
||||
});
|
Reference in New Issue
Block a user