feat: rename js files to ts
This commit is contained in:

committed by
kolaente

parent
4cff3ebee1
commit
15b67136fe
37
src/models/file.ts
Normal file
37
src/models/file.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import AbstractModel from './abstractModel'
|
||||
|
||||
export default class FileModel extends AbstractModel {
|
||||
constructor(data) {
|
||||
super(data)
|
||||
this.created = new Date(this.created)
|
||||
}
|
||||
|
||||
defaults() {
|
||||
return {
|
||||
id: 0,
|
||||
mime: '',
|
||||
name: '',
|
||||
size: 0,
|
||||
created: null,
|
||||
}
|
||||
}
|
||||
|
||||
getHumanSize() {
|
||||
const sizes = {
|
||||
0: 'B',
|
||||
1: 'KB',
|
||||
2: 'MB',
|
||||
3: 'GB',
|
||||
4: 'TB',
|
||||
}
|
||||
|
||||
let it = 0
|
||||
let size = this.size
|
||||
while (size > 1024) {
|
||||
size /= 1024
|
||||
it++
|
||||
}
|
||||
|
||||
return Number(Math.round(size + 'e2') + 'e-2') + ' ' + sizes[it]
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user