debian-mirror-gitlab/app/assets/javascripts/blob/pdf/pdf_viewer.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

56 lines
1.1 KiB
Vue
Raw Normal View History

2020-04-08 14:13:33 +05:30
<script>
import { GlLoadingIcon } from '@gitlab/ui';
2022-06-21 17:19:12 +05:30
import PdfLab from '~/pdf/index.vue';
2020-04-08 14:13:33 +05:30
export default {
components: {
PdfLab,
GlLoadingIcon,
},
props: {
pdf: {
type: String,
required: true,
},
},
data() {
return {
error: false,
loadError: false,
loading: true,
};
},
methods: {
onLoad() {
this.loading = false;
},
onError(error) {
this.loading = false;
this.loadError = true;
this.error = error;
},
},
};
</script>
<template>
2020-07-28 23:09:34 +05:30
<div class="js-pdf-viewer container-fluid md gl-mt-3 gl-mb-3">
2020-04-08 14:13:33 +05:30
<div v-if="loading && !error" class="text-center loading">
<gl-loading-icon class="mt-5" size="lg" />
</div>
2022-01-26 12:08:38 +05:30
<pdf-lab
v-if="!loadError"
:pdf="pdf"
@pdflabload="onLoad"
@pdflaberror="onError"
v-on="$listeners"
/>
2020-04-08 14:13:33 +05:30
<p v-if="error" class="text-center">
<span v-if="loadError" ref="loadError">
{{ __('An error occurred while loading the file. Please try again later.') }}
</span>
<span v-else>{{ __('An error occurred while decoding the file.') }}</span>
</p>
</div>
</template>