You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
742 B
38 lines
742 B
const moment = require("moment")
|
|
|
|
module.exports = class {
|
|
onCreate(input) {
|
|
this.state = {
|
|
modal: null,
|
|
deleted: false,
|
|
date: moment(input.data.time).format("MMM D, YYYY"),
|
|
}
|
|
}
|
|
|
|
onInput(input) {
|
|
if (input && input.data) {
|
|
this.state.date = moment(input.data.time).format("MMM D, YYYY")
|
|
}
|
|
}
|
|
|
|
open(modal) {
|
|
this.state.modal = modal
|
|
}
|
|
|
|
close() {
|
|
this.state.modal = null
|
|
}
|
|
|
|
removed() {
|
|
this.state.deleted = true
|
|
this.emit("removed")
|
|
}
|
|
|
|
sizeString(bytes) {
|
|
const order = Math.floor(Math.log2(bytes) / 10)
|
|
const unit = ["B", "KB", "MB", "GB", "TB", "PB"][order]
|
|
const number = bytes / Math.pow(2, (order)*10)
|
|
|
|
return `${number.toFixed(2)} ${unit}`
|
|
}
|
|
}
|