2018-10-13 17:07:54 +08:00
|
|
|
import moment from 'moment';
|
|
|
|
import { Utils } from '../utils/utils';
|
2018-11-22 11:26:00 +08:00
|
|
|
import FileTag from './file-tag';
|
2018-10-13 17:07:54 +08:00
|
|
|
|
|
|
|
class Dirent {
|
|
|
|
constructor(json) {
|
|
|
|
this.id = json.id;
|
|
|
|
this.name = json.name;
|
|
|
|
this.type = json.type;
|
|
|
|
this.mtime = moment.unix(json.mtime).fromNow();
|
|
|
|
this.permission = json.permission;
|
2018-12-22 11:17:03 +08:00
|
|
|
this.isSelected = false; // is check or not
|
2018-10-13 17:07:54 +08:00
|
|
|
if (json.type === 'file') {
|
|
|
|
this.size = Utils.bytesToSize(json.size);
|
|
|
|
this.starred = json.starred;
|
|
|
|
this.is_locked = json.is_locked;
|
|
|
|
this.lock_time = moment.unix(json.lock_time).fromNow();
|
|
|
|
this.lock_owner= json.lock_owner;
|
|
|
|
this.locked_by_me = json.locked_by_me;
|
|
|
|
this.modifier_name = json.modifier_name;
|
|
|
|
this.modifier_email = json.modifier_email;
|
|
|
|
this.modifier_contact_email = json.modifier_contact_email;
|
2018-11-22 11:26:00 +08:00
|
|
|
let file_tags = [];
|
|
|
|
if (json.file_tags) {
|
|
|
|
file_tags = json.file_tags.map(item => {
|
|
|
|
return new FileTag(item);
|
2018-11-28 08:57:42 +08:00
|
|
|
});
|
2018-11-22 11:26:00 +08:00
|
|
|
}
|
|
|
|
this.file_tags = file_tags;
|
2018-10-13 17:07:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-22 11:26:00 +08:00
|
|
|
isDir() {
|
|
|
|
return this.type !== 'file';
|
|
|
|
}
|
|
|
|
|
2018-10-13 17:07:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export default Dirent;
|