diff options
author | flo-mic <florianmichel@hotmail.de> | 2021-02-22 15:31:54 +0300 |
---|---|---|
committer | flo-mic <florianmichel@hotmail.de> | 2021-02-22 15:31:54 +0300 |
commit | c64354217c7422ac2a91175170d1234f9009e540 (patch) | |
tree | f287c1a8c86e3454f79dca1a03e7a4139153ec5b /src/vue | |
parent | 8bb7fbf679af7a68b4b738633deed27117cb1bf3 (diff) |
introduce clear passwords from clipboard feature
Diffstat (limited to 'src/vue')
-rw-r--r-- | src/vue/Components/List/Item/Password.vue | 8 | ||||
-rw-r--r-- | src/vue/Components/Options/Settings.vue | 39 | ||||
-rw-r--r-- | src/vue/Components/Tools/Generate.vue | 2 |
3 files changed, 42 insertions, 7 deletions
diff --git a/src/vue/Components/List/Item/Password.vue b/src/vue/Components/List/Item/Password.vue index 28d59ea..7e99be1 100644 --- a/src/vue/Components/List/Item/Password.vue +++ b/src/vue/Components/List/Item/Password.vue @@ -5,8 +5,8 @@ {{ password.getLabel() }} </div> <div class="options"> - <icon icon="user" hover-icon="clipboard" @click="copy('username')" draggable="true" @dragstart="drag($event, 'username')"/> - <icon icon="key" font="solid" hover-icon="clipboard" hover-font="regular" @click="copy('password')" draggable="true" @dragstart="drag($event, 'password')"/> + <icon icon="user" hover-icon="clipboard" @click="copy('username', 'text')" draggable="true" @dragstart="drag($event, 'username')"/> + <icon icon="key" font="solid" hover-icon="clipboard" hover-font="regular" @click="copy('password', 'password')" draggable="true" @dragstart="drag($event, 'password')"/> </div> <icon :class="securityClass" icon="shield-alt" font="solid"/> </li> @@ -92,9 +92,9 @@ ErrorManager.logError(e); } }, - copy(property) { + copy(property, type) { let data = this.password.getProperty(property); - navigator.clipboard.writeText(data); + MessageService.send({type: 'clipboard.write', payload: {type: type, value: data}}).catch(ErrorManager.catch); let label = property.capitalize(); if(['password', 'username', 'url'].indexOf(property) === -1) { diff --git a/src/vue/Components/Options/Settings.vue b/src/vue/Components/Options/Settings.vue index f6824a5..22bd788 100644 --- a/src/vue/Components/Options/Settings.vue +++ b/src/vue/Components/Options/Settings.vue @@ -23,6 +23,15 @@ <translate tag="label" for="paste-basic-auth" say="SettingsPasteBasicAuth"/> <help-text type="warning" text="HelpPasteBasicAuth"/> </div> + <div class="setting"> + <slider-field id="clipboard-clear-passwords" v-model="clearClipboard"/> + <translate tag="label" for="clipboard-clear-passwords" say="SettingsClearClipboardPasswords"/> + <help-text type="warning" text="HelpClearClipboardPasswords"/> + </div> + <div class="setting"> + <translate tag="label" for="clipboard-clear-delay" say="SettingsClearClipboardDelay"/> + <select-field id="clipboard-clear-delay" :options="clearClipboardDelayOptions" v-model="clearClipboardDelay"/> + </div> <translate tag="h3" say="NotificationSettings"/> <div class="setting"> @@ -48,10 +57,11 @@ import SettingsService from '@js/Services/SettingsService'; import ToastService from '@js/Services/ToastService'; import SliderField from "@vue/Components/Form/SliderField"; + import SelectField from "@vue/Components/Form/SelectField"; import HelpText from "@vue/Components/Options/Setting/HelpText"; export default { - components: {HelpText, SliderField, Translate}, + components: {HelpText, SliderField, SelectField, Translate}, data() { return { autoclose : false, @@ -61,7 +71,9 @@ compromised : false, notifyPwNew : false, relatedSearch : false, - notifyPwUpdate: false + notifyPwUpdate: false, + clearClipboard: true, + clearClipboardDelay: 60 }; }, @@ -69,6 +81,17 @@ this.loadData(); }, + computed: { + clearClipboardDelayOptions() { + var i = 1; + var result = []; + for(let i of [15, 30, 45, 60, 90]) { + result.push({id: i, label: ['SettingsClipboardClearDelayOptions', i]}); + } + return result; + } + }, + methods: { loadData() { this.getSetting('paste.popup.close', 'autoclose'); @@ -79,6 +102,8 @@ this.getSetting('popup.related.search', 'relatedSearch'); this.getSetting('notification.password.new', 'notifyPwNew'); this.getSetting('notification.password.update', 'notifyPwUpdate'); + this.getSetting('clipboard.clear.passwords', 'clearClipboard'); + this.getSetting('clipboard.clear.delay', 'clearClipboardDelay'); }, async getSetting(name, variable) { try { @@ -124,6 +149,16 @@ this.setSetting('paste.basic-auth', value); } }, + clearClipboard(value, oldValue) { + if(oldValue !== null && value !== oldValue) { + this.setSetting('clipboard.clear.passwords', value); + } + }, + clearClipboardDelay(value, oldValue) { + if(oldValue !== null && value !== oldValue) { + this.setSetting('clipboard.clear.delay', value); + } + }, relatedSearch(value, oldValue) { if(oldValue !== null && value !== oldValue) { this.setSetting('popup.related.search', value); diff --git a/src/vue/Components/Tools/Generate.vue b/src/vue/Components/Tools/Generate.vue index ba1c55a..61e6aef 100644 --- a/src/vue/Components/Tools/Generate.vue +++ b/src/vue/Components/Tools/Generate.vue @@ -101,7 +101,7 @@ copy() { let data = this.password, label = LocalisationService.translate('PropertyPassword'); - navigator.clipboard.writeText(data); + MessageService.send({type: 'clipboard.write', payload: {type: 'password', value: data}}).catch(ErrorManager.catch); ToastService .success(['PasswordPropertyCopied', label]) |