Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Web IDE blob image + default fallback
- Loading branch information
Showing
12 changed files
with
246 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
app/assets/javascripts/vue_shared/components/content_viewer/viewers/download_viewer.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<script> | ||
import Icon from '../../icon.vue'; | ||
import { numberToHumanSize } from '../../../../lib/utils/number_utils'; | ||
export default { | ||
components: { | ||
Icon, | ||
}, | ||
props: { | ||
path: { | ||
type: String, | ||
required: true, | ||
}, | ||
fileSize: { | ||
type: Number, | ||
required: false, | ||
default: 0, | ||
}, | ||
}, | ||
computed: { | ||
fileSizeReadable() { | ||
return numberToHumanSize(this.fileSize); | ||
}, | ||
fileName() { | ||
return this.path.split('/').pop(); | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<template> | ||
<div class="file-container"> | ||
<div class="file-content"> | ||
<p class="prepend-top-10 file-info"> | ||
{{ fileName }} ({{ fileSizeReadable }}) | ||
</p> | ||
<a | ||
:href="path" | ||
class="btn btn-default" | ||
rel="nofollow" | ||
download | ||
target="_blank"> | ||
<icon | ||
name="download" | ||
css-classes="pull-left append-right-8" | ||
:size="16" | ||
/> | ||
{{ __('Download') }} | ||
</a> | ||
</div> | ||
</div> | ||
</template> |
68 changes: 68 additions & 0 deletions
68
app/assets/javascripts/vue_shared/components/content_viewer/viewers/image_viewer.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<script> | ||
import { numberToHumanSize } from '../../../../lib/utils/number_utils'; | ||
export default { | ||
props: { | ||
path: { | ||
type: String, | ||
required: true, | ||
}, | ||
fileSize: { | ||
type: Number, | ||
required: false, | ||
default: 0, | ||
}, | ||
}, | ||
data() { | ||
return { | ||
width: 0, | ||
height: 0, | ||
isZoomable: false, | ||
isZoomed: false, | ||
}; | ||
}, | ||
computed: { | ||
fileSizeReadable() { | ||
return numberToHumanSize(this.fileSize); | ||
}, | ||
}, | ||
methods: { | ||
onImgLoad() { | ||
const contentImg = this.$refs.contentImg; | ||
this.isZoomable = | ||
contentImg.naturalWidth > contentImg.width || contentImg.naturalHeight > contentImg.height; | ||
this.width = contentImg.naturalWidth; | ||
this.height = contentImg.naturalHeight; | ||
}, | ||
onImgClick() { | ||
if (this.isZoomable) this.isZoomed = !this.isZoomed; | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<template> | ||
<div class="file-container"> | ||
<div class="file-content image_file"> | ||
<img | ||
ref="contentImg" | ||
:class="{ 'isZoomable': isZoomable, 'isZoomed': isZoomed }" | ||
:src="path" | ||
:alt="path" | ||
@load="onImgLoad" | ||
@click="onImgClick"/> | ||
<p class="file-info prepend-top-10"> | ||
<template v-if="fileSize>0"> | ||
{{ fileSizeReadable }} | ||
</template> | ||
<template v-if="fileSize>0 && width && height"> | ||
- | ||
</template> | ||
<template v-if="width && height"> | ||
{{ width }} x {{ height }} | ||
</template> | ||
</p> | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters