Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Encryption.vue « src - github.com/nextcloud/privacy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 98c62cad9aa4bebbb12799bfd4f070fe8e10cdfb (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<template>
	<div class="who-has-access">
		<!-- eslint-disable-next-line vue/no-v-html -->
		<p v-show="!isEditing" v-html="label" />
		<span v-show="isAdmin && !isEditing" class="icon icon-rename" @click="openEditFullDiskEncryptionForm" />
		<div v-if="isEditing" v-click-outside="cancelEditFullDiskEncryptionForm">
			<form>
				<input id="fullDiskEncryptionEnabledCheckbox" v-model="fullDiskEncryptionEnabled"
					:disabled="isSavingChanges" type="checkbox" name="fullDiskEncryptionEnabledCheckbox"
					class="checkbox" @change="saveFullDiskEncryptionForm"
				>
				<label for="fullDiskEncryptionEnabledCheckbox">
					{{ checkboxLabel }}
				</label>
			</form>
		</div>
	</div>
</template>

<script>
import { generateUrl } from 'nextcloud-server/dist/router'
import HttpClient from 'nextcloud-axios'
import ClickOutside from 'vue-click-outside'

export default {
	name: 'Encryption',
	directives: {
		ClickOutside
	},
	data: () => ({
		fullDiskEncryptionEnabled: false,
		serverSideEncryptionEnabled: false,
		isAdmin: true,
		isEditing: false,
		isSavingChanges: false
	}),
	computed: {
		label() {
			if (!this.serverSideEncryptionEnabled && !this.fullDiskEncryptionEnabled) {
				return t('privacy', 'Your files are not protected by encryption.')
			} else if (this.serverSideEncryptionEnabled && !this.fullDiskEncryptionEnabled) {
				return t('privacy', 'Your files are encrypted with {linkopen}server-side-encryption ↗{linkclose}.')
					.replace('{linkopen}', '<a href="https://nextcloud.com/blog/encryption-in-nextcloud/" target="_blank" title="" rel="noreferrer noopener">')
					.replace('{linkclose}', '</a>')
			} else if (!this.serverSideEncryptionEnabled && this.fullDiskEncryptionEnabled) {
				return t('privacy', 'This server is protected with full-disk-encryption.')
			} else {
				return t('privacy', 'Your files are encrypted with {linkopen}server-side-encryption ↗{linkclose}. Additionally, this server is protected with full-disk-encryption.')
					.replace('{linkopen}', '<a href="https://nextcloud.com/blog/encryption-in-nextcloud/" target="_blank" title="" rel="noreferrer noopener">')
					.replace('{linkclose}', '</a>')
			}
		},
		checkboxLabel() {
			return t('privacy', 'This server is using full-disk-encryption.')
		}
	},
	created() {
		this.fullDiskEncryptionEnabled = (this.$parent.$el.getAttribute('data-full-disk-encryption') === '1')
		this.serverSideEncryptionEnabled = (this.$parent.$el.getAttribute('data-server-side-encryption') === '1')
		this.isAdmin = OC.isUserAdmin()
	},
	methods: {
		openEditFullDiskEncryptionForm() {
			setTimeout(() => {
				this.isEditing = true
			}, 0)
		},
		cancelEditFullDiskEncryptionForm() {
			this.isEditing = false
		},
		saveFullDiskEncryptionForm() {
			const url = generateUrl('/apps/privacy/api/fullDiskEncryption')
			this.isSavingChanges = true

			HttpClient.post(url, { enabled: this.fullDiskEncryptionEnabled ? '1' : '0' }).then(resp => {
				this.isSavingChanges = false
				this.isEditing = false
			})
		}
	}
}
</script>