forked from geolba/tethys.frontend
- file download inside search detail page
This commit is contained in:
parent
6cb6f178a9
commit
3e73b91cf0
|
@ -141,13 +141,13 @@ export class DbDataset {
|
||||||
}
|
}
|
||||||
|
|
||||||
public hasEmbargoPassed(): boolean {
|
public hasEmbargoPassed(): boolean {
|
||||||
const embargoDate = moment(this.embargo_date);
|
if (this.embargo_date === null) {
|
||||||
if (embargoDate == null) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
const embargoDate = moment(this.embargo_date);
|
||||||
const todayDate = moment.now();
|
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)) {
|
if (embargoDate.isBefore(todayDate)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -53,6 +53,21 @@ export default class DatasetDetailComponent extends Vue {
|
||||||
this.$router.go(-1);
|
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 {
|
public getHumanDate(date: string): string {
|
||||||
return moment(date).format("DD.MM.YYYY HH:mm");
|
return moment(date).format("DD.MM.YYYY HH:mm");
|
||||||
// return moment(date).format("MMM Do YYYY");
|
// return moment(date).format("MMM Do YYYY");
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div class="column is-3-desktop is-4-tablet">Downloads/<br />downloads:</div>
|
<div class="column is-3-desktop is-4-tablet">Downloads/<br />downloads:</div>
|
||||||
<div class="column is-9-desktop is-8-tablet" v-if="dataset.files.length > 0">
|
<div class="column is-9-desktop is-8-tablet" v-if="dataset.files.length > 0">
|
||||||
<table id="items" v-if="dataset.hasEmbargoPassed()" class="pure-table pure-table-horizontal">
|
<table id="items" v-if="dataset.hasEmbargoPassed()" class="table is-bordered is-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Path Name</th>
|
<th>Path Name</th>
|
||||||
|
@ -66,18 +66,13 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="file in dataset.files" :key="file.id">
|
<tr v-for="file in dataset.files" :key="file.id">
|
||||||
<td>
|
<td>
|
||||||
{{ file.path_name }}
|
<a target="_blank" v-bind:href="'portal/file/download/' + file.id"> {{ file.label }} </a>
|
||||||
<!-- @if($file->exists() === true)
|
|
||||||
<a target="_blank" href="{{ route('file.download', ['id' => $file->id]) }}"> {{ $file->label }} </a>
|
|
||||||
@else
|
|
||||||
<span class="alert">missing file: {{ $file->path_name }}</span>
|
|
||||||
@endif -->
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<!-- <span>{{ pathinfo($file->path_name, PATHINFO_EXTENSION) }}</span> -->
|
<span>{{ getExtension(file.path_name) }}</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<!-- <span>{{ $file->formatSize(2) }}</span> -->
|
<span>{{ formatSize(file.file_size, 2) }}</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user