mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-28 11:00:39 +00:00
CreatePersonaTokenPopup implementation
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
<template>
|
||||
<PopupWrapper name="create-personal-token">
|
||||
|
||||
<PopupHeader :title="$t('Create Personal Token')" icon="key" />
|
||||
|
||||
<PopupContent>
|
||||
<ValidationObserver v-if="! token" @submit.prevent="createTokenForm" ref="createToken" v-slot="{ invalid }" tag="form" class="form-wrapper">
|
||||
<ValidationProvider tag="div" mode="passive" class="input-wrapper password" name="Token Name" rules="required" v-slot="{ errors }">
|
||||
<label class="input-label"> {{ $t('Token Name') }}:</label>
|
||||
<input v-model="name" :class="{'is-error': errors[0]}" type="text" ref="input" class="focus-border-theme" :placeholder="$t('Type token name...')">
|
||||
<span class="error-message" v-if="errors[0]">{{ errors[0] }}</span>
|
||||
</ValidationProvider>
|
||||
</ValidationObserver>
|
||||
|
||||
<div v-if="token" class="form-wrapper">
|
||||
<div v-if="token">
|
||||
<div class="input-wrapper">
|
||||
<label class="input-label">{{ $t('Your Personal Access Token') }}:</label>
|
||||
<CopyInput size="small" :str="token['plainTextToken']" />
|
||||
</div>
|
||||
</div>
|
||||
<InfoBox style="margin-bottom: 0; margin-top: 20px">
|
||||
<p v-html="$t('Make sure to <b class=\'text-theme\'>copy your personal access token now</b>. You won’t be able to see it again!')"></p>
|
||||
</InfoBox>
|
||||
</div>
|
||||
</PopupContent>
|
||||
|
||||
<PopupActions v-if="! token">
|
||||
<ButtonBase
|
||||
class="popup-button"
|
||||
@click.native="$closePopup()"
|
||||
button-style="secondary"
|
||||
>
|
||||
{{ $t('global.cancel') }}
|
||||
</ButtonBase>
|
||||
<ButtonBase
|
||||
class="popup-button"
|
||||
@click.native="createTokenForm"
|
||||
button-style="theme"
|
||||
:loading="isLoading"
|
||||
:disabled="isLoading"
|
||||
>
|
||||
{{ $t('Create Token') }}
|
||||
</ButtonBase>
|
||||
</PopupActions>
|
||||
|
||||
<PopupActions v-if="token">
|
||||
<ButtonBase
|
||||
class="popup-button"
|
||||
@click.native="closePopup"
|
||||
button-style="theme"
|
||||
>
|
||||
{{ $t('shared_form.button_done') }}
|
||||
</ButtonBase>
|
||||
</PopupActions>
|
||||
</PopupWrapper>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {ValidationProvider, ValidationObserver} from 'vee-validate/dist/vee-validate.full'
|
||||
import PopupWrapper from '@/components/Others/Popup/PopupWrapper'
|
||||
import PopupActions from '@/components/Others/Popup/PopupActions'
|
||||
import PopupContent from '@/components/Others/Popup/PopupContent'
|
||||
import PopupHeader from '@/components/Others/Popup/PopupHeader'
|
||||
import CopyInput from '@/components/Others/Forms/CopyInput'
|
||||
import ButtonBase from '@/components/FilesView/ButtonBase'
|
||||
import InfoBox from '@/components/Others/Forms/InfoBox'
|
||||
import {required} from 'vee-validate/dist/rules'
|
||||
import axios from 'axios'
|
||||
|
||||
export default {
|
||||
name: "CreatePersonaTokenPopup",
|
||||
components: {
|
||||
ValidationProvider,
|
||||
ValidationObserver,
|
||||
PopupWrapper,
|
||||
PopupActions,
|
||||
PopupContent,
|
||||
PopupHeader,
|
||||
ButtonBase,
|
||||
CopyInput,
|
||||
required,
|
||||
InfoBox,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isLoading: false,
|
||||
name: undefined,
|
||||
token: undefined
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async createTokenForm() {
|
||||
|
||||
const isValid = await this.$refs.createToken.validate()
|
||||
|
||||
if (!isValid) return
|
||||
|
||||
this.isLoading = true
|
||||
|
||||
axios
|
||||
.post('/api/user/token/create', {
|
||||
name: this.name
|
||||
})
|
||||
.then(response => {
|
||||
this.token = response.data
|
||||
})
|
||||
.catch(() => this.$isSomethingWrong())
|
||||
.finally(() => {
|
||||
this.isLoading = false
|
||||
this.name = undefined
|
||||
})
|
||||
},
|
||||
closePopup() {
|
||||
this.$closePopup()
|
||||
this.token = undefined
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import "@assets/vuefilemanager/_inapp-forms.scss";
|
||||
@import '@assets/vuefilemanager/_forms';
|
||||
</style>
|
||||
@@ -1,28 +1,27 @@
|
||||
<template>
|
||||
<div class="inline-wrapper icon-append copy-input" :class="size" @click="copyUrl">
|
||||
<input ref="sel" :value="item.shared.link" id="link-input" type="text" class="input-text" readonly>
|
||||
<input ref="sel" :value="str" id="link-input" type="text" class="input-text" readonly>
|
||||
<div class="multi-icon">
|
||||
<div class="icon-item group hover-bg-theme-100">
|
||||
<link-icon v-if="! isCopiedLink" size="14" class="group-hover-text-theme hover-text-theme"/>
|
||||
<copy-icon v-if="! isCopiedLink" size="14" class="group-hover-text-theme hover-text-theme"/>
|
||||
<check-icon v-if="isCopiedLink" size="14" class="group-hover-text-theme hover-text-theme"/>
|
||||
</div>
|
||||
<div class="icon-item group hover-bg-theme-100" @click.stop.prevent="menuForEmail">
|
||||
<send-icon size="14" class="group-hover-text-theme hover-text-theme" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { LinkIcon, CheckIcon, SendIcon } from 'vue-feather-icons'
|
||||
import { events } from '@/bus'
|
||||
import { CopyIcon, CheckIcon, SendIcon } from 'vue-feather-icons'
|
||||
|
||||
export default {
|
||||
name: 'CopyInput',
|
||||
props: ['size', 'item'],
|
||||
props: [
|
||||
'size',
|
||||
'str'
|
||||
],
|
||||
components: {
|
||||
CheckIcon,
|
||||
LinkIcon,
|
||||
CopyIcon,
|
||||
SendIcon
|
||||
},
|
||||
data() {
|
||||
@@ -31,13 +30,6 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
menuForEmail() {
|
||||
events.$emit('popup:open', {
|
||||
name: 'share-edit',
|
||||
item: this.item,
|
||||
sentToEmail: true,
|
||||
})
|
||||
},
|
||||
copyUrl() {
|
||||
|
||||
// Get input value
|
||||
@@ -76,6 +68,7 @@ export default {
|
||||
border-top-right-radius: 8px;
|
||||
|
||||
line,
|
||||
rect,
|
||||
path,
|
||||
polygon {
|
||||
color: $text;
|
||||
@@ -93,6 +86,7 @@ export default {
|
||||
line,
|
||||
polyline,
|
||||
path,
|
||||
rect,
|
||||
polygon {
|
||||
color: inherit;
|
||||
}
|
||||
@@ -158,6 +152,7 @@ export default {
|
||||
|
||||
line,
|
||||
path,
|
||||
rect,
|
||||
polygon {
|
||||
color: inherit !important;
|
||||
}
|
||||
@@ -165,8 +160,6 @@ export default {
|
||||
.icon-item {
|
||||
border-color: #333333;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
.copy-input {
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
<template>
|
||||
<div class="inline-wrapper icon-append copy-input" :class="size" @click="copyUrl">
|
||||
<input ref="sel" :value="item.shared.link" id="link-input" type="text" class="input-text" readonly>
|
||||
<div class="multi-icon">
|
||||
<div class="icon-item group hover-bg-theme-100">
|
||||
<link-icon v-if="! isCopiedLink" size="14" class="group-hover-text-theme hover-text-theme"/>
|
||||
<check-icon v-if="isCopiedLink" size="14" class="group-hover-text-theme hover-text-theme"/>
|
||||
</div>
|
||||
<div class="icon-item group hover-bg-theme-100" @click.stop.prevent="menuForEmail">
|
||||
<send-icon size="14" class="group-hover-text-theme hover-text-theme" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { LinkIcon, CheckIcon, SendIcon } from 'vue-feather-icons'
|
||||
import { events } from '@/bus'
|
||||
|
||||
export default {
|
||||
name: 'CopyShareLink',
|
||||
props: ['size', 'item'],
|
||||
components: {
|
||||
CheckIcon,
|
||||
LinkIcon,
|
||||
SendIcon
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isCopiedLink: false
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
menuForEmail() {
|
||||
events.$emit('popup:open', {
|
||||
name: 'share-edit',
|
||||
item: this.item,
|
||||
sentToEmail: true,
|
||||
})
|
||||
},
|
||||
copyUrl() {
|
||||
|
||||
// Get input value
|
||||
var copyText = document.getElementById('link-input')
|
||||
|
||||
// select link
|
||||
copyText.select()
|
||||
copyText.setSelectionRange(0, 99999)
|
||||
|
||||
// Copy
|
||||
document.execCommand('copy')
|
||||
|
||||
// Mark button as copied
|
||||
this.isCopiedLink = true
|
||||
|
||||
// Reset copy button
|
||||
setTimeout(() => {
|
||||
this.isCopiedLink = false
|
||||
}, 1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import '@assets/vuefilemanager/_variables';
|
||||
@import '@assets/vuefilemanager/_mixins';
|
||||
@import "@assets/vuefilemanager/_inapp-forms.scss";
|
||||
@import "@assets/vuefilemanager/_forms.scss";
|
||||
|
||||
.multi-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: $light_background;
|
||||
border-bottom-right-radius: 8px;
|
||||
border-top-right-radius: 8px;
|
||||
|
||||
line,
|
||||
path,
|
||||
polygon {
|
||||
color: $text;
|
||||
}
|
||||
|
||||
.icon-item {
|
||||
padding: 9px 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-left: 1px solid $light_mode_border_darken;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
|
||||
line,
|
||||
polyline,
|
||||
path,
|
||||
polygon {
|
||||
color: inherit;
|
||||
}
|
||||
}
|
||||
|
||||
&:first-child {
|
||||
border-left: none;
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
border-bottom-right-radius: 8px;
|
||||
border-top-right-radius: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Single page
|
||||
.copy-input {
|
||||
border: 1px solid $light_mode_border_darken;
|
||||
border-radius: 8px;
|
||||
|
||||
&.small {
|
||||
|
||||
&.icon-append {
|
||||
|
||||
.icon {
|
||||
padding: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
input {
|
||||
padding: 6px 10px;
|
||||
@include font-size(13);
|
||||
}
|
||||
}
|
||||
|
||||
.icon {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
input {
|
||||
text-overflow: ellipsis;
|
||||
box-shadow: none;
|
||||
|
||||
&:disabled {
|
||||
color: $text;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
|
||||
.copy-input {
|
||||
border-color: #333333;
|
||||
}
|
||||
|
||||
.multi-icon {
|
||||
background: $dark_mode_foreground;
|
||||
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.12);
|
||||
|
||||
line,
|
||||
path,
|
||||
polygon {
|
||||
color: inherit !important;
|
||||
}
|
||||
|
||||
.icon-item {
|
||||
border-color: #333333;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
.copy-input {
|
||||
input {
|
||||
color: $dark_mode_text_primary;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -71,7 +71,7 @@
|
||||
<div v-if="isGeneratedShared" class="form-wrapper">
|
||||
<div class="input-wrapper">
|
||||
<label class="input-label">{{ this.sharedViaEmail ? $t('shared_form.label_share_vie_email') : $t('shared_form.label_shared_url') }}:</label>
|
||||
<CopyInput size="small" :item="pickedItem" />
|
||||
<CopyShareLink size="small" :item="pickedItem" />
|
||||
</div>
|
||||
</div>
|
||||
</PopupContent>
|
||||
@@ -100,7 +100,7 @@ import SwitchInput from '@/components/Others/Forms/SwitchInput'
|
||||
import SelectInput from '@/components/Others/Forms/SelectInput'
|
||||
import ThumbnailItem from '@/components/Others/ThumbnailItem'
|
||||
import ActionButton from '@/components/Others/ActionButton'
|
||||
import CopyInput from '@/components/Others/Forms/CopyInput'
|
||||
import CopyShareLink from '@/components/Others/Forms/CopyShareLink'
|
||||
import TabWrapper from '@/components/Others/TabWrapper'
|
||||
import TabOption from '@/components/Others/TabOption'
|
||||
import ButtonBase from '@/components/FilesView/ButtonBase'
|
||||
@@ -129,7 +129,7 @@ export default {
|
||||
SelectInput,
|
||||
SwitchInput,
|
||||
ButtonBase,
|
||||
CopyInput,
|
||||
CopyShareLink,
|
||||
MailIcon,
|
||||
required,
|
||||
LinkIcon,
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
<div v-if="! sendToRecipientsMenu || (sendToRecipientsMenu && isEmailSended)" class="input-wrapper copy-input">
|
||||
<label class="input-label">{{ $t('shared_form.label_share_vie_email') }}:</label>
|
||||
<CopyInput size="small" :item="pickedItem" />
|
||||
<CopyShareLink size="small" :item="pickedItem" />
|
||||
</div>
|
||||
|
||||
<ValidationObserver @submit.prevent v-if="sendToRecipientsMenu && !isEmailSended" v-slot="{ invalid }" ref="shareEmail" tag="form" class="form-wrapper">
|
||||
@@ -106,7 +106,7 @@
|
||||
import MultiEmailInput from '@/components/Others/Forms/MultiEmailInput'
|
||||
import ThumbnailItem from '@/components/Others/ThumbnailItem'
|
||||
import ActionButton from '@/components/Others/ActionButton'
|
||||
import CopyInput from '@/components/Others/Forms/CopyInput'
|
||||
import CopyShareLink from '@/components/Others/Forms/CopyShareLink'
|
||||
import ButtonBase from '@/components/FilesView/ButtonBase'
|
||||
import InfoBox from '@/components/Others/Forms/InfoBox'
|
||||
import {required} from 'vee-validate/dist/rules'
|
||||
@@ -130,7 +130,7 @@
|
||||
MultiEmailInput,
|
||||
SwitchInput,
|
||||
ButtonBase,
|
||||
CopyInput,
|
||||
CopyShareLink,
|
||||
required,
|
||||
InfoBox,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user