diff --git a/src/models/dataset.ts b/src/models/dataset.ts index 4d8d5d3..1bee033 100644 --- a/src/models/dataset.ts +++ b/src/models/dataset.ts @@ -141,13 +141,13 @@ export class DbDataset { } public hasEmbargoPassed(): boolean { - const embargoDate = moment(this.embargo_date); - if (embargoDate == null) { + if (this.embargo_date === null) { return true; } + const embargoDate = moment(this.embargo_date); const todayDate = moment.now(); - // Embargo has passed on the day after the specified date + // Embargo has passed on the day after the specified date if (embargoDate.isBefore(todayDate)) { return true; } else { diff --git a/src/views/dataset-detail.component.ts/dataset-detail.component.ts b/src/views/dataset-detail.component.ts/dataset-detail.component.ts index e56f0a3..e8dace7 100644 --- a/src/views/dataset-detail.component.ts/dataset-detail.component.ts +++ b/src/views/dataset-detail.component.ts/dataset-detail.component.ts @@ -53,6 +53,21 @@ export default class DatasetDetailComponent extends Vue { this.$router.go(-1); } + public getExtension(filename: string): string { + return filename.substring(filename.lastIndexOf(".") + 1, filename.length) || filename; + } + + public formatSize(file_size: number, precision = 1) { + let size = file_size; + const unit = ["Byte", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"]; + let i; + for (i = 0; size >= 1024 && i < unit.length - 1; i++) { + size = size / 1024; + } + // return Math.round((size * precision) / precision) + " " + unit[i]; + return Math.round((size + Number.EPSILON) * 100) / 100 + " " + unit[i]; + } + public getHumanDate(date: string): string { return moment(date).format("DD.MM.YYYY HH:mm"); // return moment(date).format("MMM Do YYYY"); diff --git a/src/views/dataset-detail.component.ts/dataset-detail.component.vue b/src/views/dataset-detail.component.ts/dataset-detail.component.vue index df18bea..ec9a71a 100644 --- a/src/views/dataset-detail.component.ts/dataset-detail.component.vue +++ b/src/views/dataset-detail.component.ts/dataset-detail.component.vue @@ -55,7 +55,7 @@
Downloads/
downloads:
- +
@@ -66,18 +66,13 @@
Path Name
- {{ file.path_name }} - + {{ file.label }} - + {{ getExtension(file.path_name) }} - + {{ formatSize(file.file_size, 2) }}