1
0
Fork 0
dri/src/components/TagSize.vue

39 lines
761 B
Vue
Raw Normal View History

2018-09-26 22:27:42 +08:00
<template>
2018-09-29 16:37:40 +08:00
<LoadableText :text="text" />
2018-09-26 22:27:42 +08:00
</template>
<script>
import filesize from 'filesize';
2018-09-29 15:39:45 +08:00
import { tag } from '@/api';
2018-09-26 22:27:42 +08:00
import LoadableText from '@/components/LoadableText.vue';
export default {
2018-09-27 13:41:08 +08:00
components: {
LoadableText,
},
props: {
repo: String,
tag: String,
2018-09-29 15:39:45 +08:00
size: Number,
2018-09-27 13:41:08 +08:00
},
data() {
return {
2018-09-29 15:39:45 +08:00
text: '',
2018-09-27 13:41:08 +08:00
};
},
async created() {
const r = await tag(this.repo, this.tag);
if (r.mediaType === 'application/vnd.docker.distribution.manifest.list.v2+json') {
console.error('V2 manifest lists not supported yet');
return;
}
if (r.schemaVersion === 1) {
2018-09-29 15:39:45 +08:00
console.error('V1 manifests not supported');
return;
2018-09-27 13:41:08 +08:00
}
2018-09-29 15:39:45 +08:00
const total = r.layers.reduce((a, b) => a + b.size, 0);
this.text = filesize(total);
2018-09-27 13:41:08 +08:00
},
2018-09-26 22:27:42 +08:00
};
</script>