summaryrefslogtreecommitdiff
path: root/src/client/app/desktop/views/components/drive-window.vue
blob: 1318762cbe7f91d96b8bb3505f0969e151e97eab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<template>
<mk-window ref="window" @closed="destroyDom" width="800px" height="500px" :popout-url="popout">
	<template slot="header">
		<p v-if="usage" :class="$style.info"><b>{{ usage.toFixed(1) }}%</b> {{ $t('used') }}</p>
		<span :class="$style.title"><fa icon="cloud"/>{{ $t('@.drive') }}</span>
	</template>
	<mk-drive :class="$style.browser" multiple :init-folder="folder" ref="browser"/>
</mk-window>
</template>

<script lang="ts">
import Vue from 'vue';
import i18n from '../../../i18n';
import { url } from '../../../config';

export default Vue.extend({
	i18n: i18n('desktop/views/components/drive-window.vue'),
	props: ['folder'],
	data() {
		return {
			usage: null
		};
	},
	mounted() {
		this.$root.api('drive').then(info => {
			this.usage = info.usage / info.capacity * 100;
		});
	},
	methods: {
		popout() {
			const folder = (this.$refs.browser as any) ? (this.$refs.browser as any).folder : null;
			if (folder) {
				return `${url}/i/drive/folder/${folder.id}`;
			} else {
				return `${url}/i/drive`;
			}
		}
	}
});
</script>

<style lang="stylus" module>
.title
	> [data-icon]
		margin-right 4px

.info
	position absolute
	top 0
	left 16px
	margin 0
	font-size 80%

.browser
	height 100%

</style>