mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-06-20 19:57:44 +02:00
Replace custom notifications with vue-notification package
This commit is contained in:
parent
eafff6c17e
commit
06c8dd0a10
5
package-lock.json
generated
5
package-lock.json
generated
@ -9315,6 +9315,11 @@
|
|||||||
"vue-style-loader": "^4.1.0"
|
"vue-style-loader": "^4.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"vue-notification": {
|
||||||
|
"version": "1.3.20",
|
||||||
|
"resolved": "https://registry.npmjs.org/vue-notification/-/vue-notification-1.3.20.tgz",
|
||||||
|
"integrity": "sha512-vPj67Ah72p8xvtyVE8emfadqVWguOScAjt6OJDEUdcW5hW189NsqvfkOrctxHUUO9UYl9cTbIkzAEcPnHu+zBQ=="
|
||||||
|
},
|
||||||
"vue-pull-refresh": {
|
"vue-pull-refresh": {
|
||||||
"version": "0.2.7",
|
"version": "0.2.7",
|
||||||
"resolved": "https://registry.npmjs.org/vue-pull-refresh/-/vue-pull-refresh-0.2.7.tgz",
|
"resolved": "https://registry.npmjs.org/vue-pull-refresh/-/vue-pull-refresh-0.2.7.tgz",
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
"vue": "^2.6.12",
|
"vue": "^2.6.12",
|
||||||
"vue-axios": "^2.1.5",
|
"vue-axios": "^2.1.5",
|
||||||
"vue-i18n": "^8.21.1",
|
"vue-i18n": "^8.21.1",
|
||||||
|
"vue-notification": "^1.3.20",
|
||||||
"vue-pull-refresh": "^0.2.7",
|
"vue-pull-refresh": "^0.2.7",
|
||||||
"vue-qrcode-reader": "^2.3.13",
|
"vue-qrcode-reader": "^2.3.13",
|
||||||
"vue-router": "^3.4.3",
|
"vue-router": "^3.4.3",
|
||||||
|
19
resources/js/app.js
vendored
19
resources/js/app.js
vendored
@ -1,14 +1,17 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import router from './routes'
|
import router from './routes'
|
||||||
import api from './api'
|
import api from './api'
|
||||||
import i18n from './langs/i18n'
|
import i18n from './langs/i18n'
|
||||||
import FontAwesome from './packages/fontawesome'
|
import FontAwesome from './packages/fontawesome'
|
||||||
import Clipboard from './packages/clipboard'
|
import Clipboard from './packages/clipboard'
|
||||||
import QrcodeReader from './packages/qrcodeReader'
|
import QrcodeReader from './packages/qrcodeReader'
|
||||||
import App from './components/App'
|
import Notifications from 'vue-notification'
|
||||||
|
import App from './components/App'
|
||||||
|
|
||||||
import './components'
|
import './components'
|
||||||
|
|
||||||
|
Vue.use(Notifications)
|
||||||
|
|
||||||
const app = new Vue({
|
const app = new Vue({
|
||||||
el: '#app',
|
el: '#app',
|
||||||
data: {
|
data: {
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
<div v-if="$root.appSettings.isDemoApp" class="demo has-background-warning has-text-centered is-size-7-mobile">
|
<div v-if="$root.appSettings.isDemoApp" class="demo has-background-warning has-text-centered is-size-7-mobile">
|
||||||
{{ $t('commons.demo_do_not_post_sensitive_data') }}
|
{{ $t('commons.demo_do_not_post_sensitive_data') }}
|
||||||
</div>
|
</div>
|
||||||
|
<notifications width="100%" position="top" :duration="4000" :speed="0" :max="1" classes="notification" />
|
||||||
<main class="main-section">
|
<main class="main-section">
|
||||||
<router-view></router-view>
|
<router-view></router-view>
|
||||||
</main>
|
</main>
|
||||||
|
@ -3,10 +3,6 @@
|
|||||||
<div class="form-column column is-two-thirds-tablet is-half-desktop is-one-third-widescreen is-one-quarter-fullhd">
|
<div class="form-column column is-two-thirds-tablet is-half-desktop is-one-third-widescreen is-one-quarter-fullhd">
|
||||||
<h1 class="title" v-html="title" v-if="title"></h1>
|
<h1 class="title" v-html="title" v-if="title"></h1>
|
||||||
<slot />
|
<slot />
|
||||||
<p v-if="showTag">
|
|
||||||
<notification :message="fail" type="is-danger" :isFixed="hasFixedNotification" v-if="fail" />
|
|
||||||
<notification :message="success" type="is-success" :isFixed="hasFixedNotification" v-if="success" />
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -21,32 +17,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
|
||||||
showTag: function() {
|
|
||||||
return (this.fail || this.success) ? true : false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
title: {
|
title: {
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: ''
|
||||||
},
|
},
|
||||||
|
|
||||||
fail: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
},
|
|
||||||
|
|
||||||
success: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
},
|
|
||||||
|
|
||||||
hasFixedNotification: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
@ -24,9 +24,11 @@
|
|||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'Modal',
|
name: 'Modal',
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
value: Boolean,
|
value: Boolean,
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
isActive: {
|
isActive: {
|
||||||
get () {
|
get () {
|
||||||
@ -37,10 +39,12 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
closeModal: function(event) {
|
closeModal: function(event) {
|
||||||
if (event) {
|
if (event) {
|
||||||
this.isActive = false
|
this.isActive = false
|
||||||
|
this.$notify({ clean: true })
|
||||||
this.$parent.$emit('modalClose')
|
this.$parent.$emit('modalClose')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,50 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="notification" :class="[type, isFixed ? 'is-fixed' : '']" v-if="show">
|
|
||||||
<button class="delete" v-if="isDeletable" @click="close"></button>
|
|
||||||
{{ message }}
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
name: 'Notification',
|
|
||||||
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
show: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
props: {
|
|
||||||
type: {
|
|
||||||
type: String,
|
|
||||||
default: 'is-primary'
|
|
||||||
},
|
|
||||||
|
|
||||||
message: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
|
|
||||||
isDeletable: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
|
|
||||||
isFixed: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
|
|
||||||
close (event) {
|
|
||||||
if (event) {
|
|
||||||
this.show = false
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
@ -31,9 +31,6 @@
|
|||||||
<div class="column is-full quick-uploader-footer">
|
<div class="column is-full quick-uploader-footer">
|
||||||
<router-link :to="{ name: 'create' }" class="is-link">{{ $t('twofaccounts.use_full_form') }}</router-link>
|
<router-link :to="{ name: 'create' }" class="is-link">{{ $t('twofaccounts.use_full_form') }}</router-link>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="showError" class="column is-full quick-uploader-footer">
|
|
||||||
<notification :message="errorText" :isDeletable="false" type="is-danger" />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- camera stream fullscreen scanner -->
|
<!-- camera stream fullscreen scanner -->
|
||||||
@ -77,17 +74,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
|
||||||
|
|
||||||
debugMode: function() {
|
|
||||||
return process.env.NODE_ENV
|
|
||||||
},
|
|
||||||
|
|
||||||
showError: function() {
|
|
||||||
return this.debugMode == 'development' && this.errorName == 'NotAllowedError'
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
showTrailer: {
|
showTrailer: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@ -180,6 +166,10 @@
|
|||||||
this.$parent.$emit('cannotStream')
|
this.$parent.$emit('cannotStream')
|
||||||
|
|
||||||
console.log('fail to stream : ' + this.errorText)
|
console.log('fail to stream : ' + this.errorText)
|
||||||
|
|
||||||
|
if (this.errorName === 'NotAllowedError') {
|
||||||
|
this.$notify({ type: 'is-danger', text: this.errorText })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !this.errorName && !this.showStream ) {
|
if( !this.errorName && !this.showStream ) {
|
||||||
|
2
resources/js/components/index.js
vendored
2
resources/js/components/index.js
vendored
@ -6,7 +6,6 @@ import FormField from './FormField'
|
|||||||
import FormSelect from './FormSelect'
|
import FormSelect from './FormSelect'
|
||||||
import FormSwitch from './FormSwitch'
|
import FormSwitch from './FormSwitch'
|
||||||
import FormButtons from './FormButtons'
|
import FormButtons from './FormButtons'
|
||||||
import Notification from './Notification'
|
|
||||||
import VueFooter from './Footer'
|
import VueFooter from './Footer'
|
||||||
|
|
||||||
// Components that are registered globaly.
|
// Components that are registered globaly.
|
||||||
@ -18,7 +17,6 @@ import VueFooter from './Footer'
|
|||||||
FormSelect,
|
FormSelect,
|
||||||
FormSwitch,
|
FormSwitch,
|
||||||
FormButtons,
|
FormButtons,
|
||||||
Notification,
|
|
||||||
VueFooter,
|
VueFooter,
|
||||||
].forEach(Component => {
|
].forEach(Component => {
|
||||||
Vue.component(Component.name, Component)
|
Vue.component(Component.name, Component)
|
||||||
|
2
resources/js/routes.js
vendored
2
resources/js/routes.js
vendored
@ -10,7 +10,7 @@ import Login from './views/auth/Login'
|
|||||||
import Register from './views/auth/Register'
|
import Register from './views/auth/Register'
|
||||||
import PasswordRequest from './views/auth/password/Request'
|
import PasswordRequest from './views/auth/password/Request'
|
||||||
import PasswordReset from './views/auth/password/Reset'
|
import PasswordReset from './views/auth/password/Reset'
|
||||||
import Settings from './views/settings/Index'
|
import Settings from './views/settings/Index'
|
||||||
import Errors from './views/Error'
|
import Errors from './views/Error'
|
||||||
|
|
||||||
const router = new Router({
|
const router = new Router({
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<form-wrapper :fail="fail" :success="success">
|
<form-wrapper>
|
||||||
<form @submit.prevent="handleSubmit" @keydown="form.onKeydown($event)">
|
<form @submit.prevent="handleSubmit" @keydown="form.onKeydown($event)">
|
||||||
<form-field :form="form" fieldName="name" :label="$t('auth.forms.name')" autofocus />
|
<form-field :form="form" fieldName="name" :label="$t('auth.forms.name')" autofocus />
|
||||||
<form-field :form="form" fieldName="email" inputType="email" :label="$t('auth.forms.email')" />
|
<form-field :form="form" fieldName="email" inputType="email" :label="$t('auth.forms.email')" />
|
||||||
@ -16,8 +16,6 @@
|
|||||||
export default {
|
export default {
|
||||||
data(){
|
data(){
|
||||||
return {
|
return {
|
||||||
success: '',
|
|
||||||
fail: '',
|
|
||||||
form: new Form({
|
form: new Form({
|
||||||
name : '',
|
name : '',
|
||||||
email : '',
|
email : '',
|
||||||
@ -36,18 +34,15 @@
|
|||||||
handleSubmit(e) {
|
handleSubmit(e) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
this.fail = ''
|
|
||||||
this.success = ''
|
|
||||||
|
|
||||||
this.form.patch('/api/settings/account', {returnError: true})
|
this.form.patch('/api/settings/account', {returnError: true})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
|
|
||||||
this.success = response.data.message
|
this.$notify({ type: 'is-success', text: response.data.message })
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
if( error.response.status === 400 ) {
|
if( error.response.status === 400 ) {
|
||||||
|
|
||||||
this.fail = error.response.data.message
|
this.$notify({ type: 'is-danger', text: error.response.data.message })
|
||||||
}
|
}
|
||||||
else if( error.response.status !== 422 ) {
|
else if( error.response.status !== 422 ) {
|
||||||
this.$router.push({ name: 'genericError', params: { err: error.response } });
|
this.$router.push({ name: 'genericError', params: { err: error.response } });
|
||||||
|
@ -17,7 +17,9 @@
|
|||||||
<vue-footer :showButtons="true">
|
<vue-footer :showButtons="true">
|
||||||
<!-- Cancel button -->
|
<!-- Cancel button -->
|
||||||
<p class="control">
|
<p class="control">
|
||||||
<router-link :to="{ name: 'accounts' }" class="button is-dark is-rounded">{{ $t('commons.close') }}</router-link>
|
<a class="button is-dark is-rounded" @click.stop="exitSettings">
|
||||||
|
{{ $t('commons.close') }}
|
||||||
|
</a>
|
||||||
</p>
|
</p>
|
||||||
</vue-footer>
|
</vue-footer>
|
||||||
</div>
|
</div>
|
||||||
@ -64,6 +66,13 @@
|
|||||||
this.activeTab = selectedTab.name
|
this.activeTab = selectedTab.name
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
exitSettings: function(event) {
|
||||||
|
if (event) {
|
||||||
|
this.$notify({ clean: true })
|
||||||
|
this.$router.push({ name: 'accounts' })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<form-wrapper :fail="fail" :success="success" :hasFixedNotification="true">
|
<form-wrapper>
|
||||||
<div class="tags has-addons">
|
<div class="tags has-addons">
|
||||||
<span class="tag is-dark">2FAuth</span>
|
<span class="tag is-dark">2FAuth</span>
|
||||||
<span class="tag is-info">v{{ $root.appVersion }}</span>
|
<span class="tag is-info">v{{ $root.appVersion }}</span>
|
||||||
@ -21,8 +21,8 @@
|
|||||||
export default {
|
export default {
|
||||||
data(){
|
data(){
|
||||||
return {
|
return {
|
||||||
success: '',
|
// success: '',
|
||||||
fail: '',
|
// fail: '',
|
||||||
form: new Form({
|
form: new Form({
|
||||||
lang: this.$root.$i18n.locale,
|
lang: this.$root.$i18n.locale,
|
||||||
showTokenAsDot: this.$root.appSettings.showTokenAsDot,
|
showTokenAsDot: this.$root.appSettings.showTokenAsDot,
|
||||||
@ -45,13 +45,10 @@
|
|||||||
handleSubmit(e) {
|
handleSubmit(e) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
this.fail = ''
|
|
||||||
this.success = ''
|
|
||||||
|
|
||||||
this.form.post('/api/settings/options', {returnError: true})
|
this.form.post('/api/settings/options', {returnError: true})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
|
|
||||||
this.success = response.data.message
|
this.$notify({ type: 'is-success', text: response.data.message })
|
||||||
|
|
||||||
if(response.data.settings.lang !== this.$root.$i18n.locale) {
|
if(response.data.settings.lang !== this.$root.$i18n.locale) {
|
||||||
this.$router.go()
|
this.$router.go()
|
||||||
@ -62,7 +59,7 @@
|
|||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
|
||||||
this.fail = error.response.data.message
|
this.$notify({ type: 'is-danger', text: error.response.data.message })
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<form-wrapper :fail="fail" :success="success">
|
<form-wrapper>
|
||||||
<form @submit.prevent="handleSubmit" @keydown="form.onKeydown($event)">
|
<form @submit.prevent="handleSubmit" @keydown="form.onKeydown($event)">
|
||||||
<form-field :form="form" fieldName="password" inputType="password" :label="$t('auth.forms.new_password')" />
|
<form-field :form="form" fieldName="password" inputType="password" :label="$t('auth.forms.new_password')" />
|
||||||
<form-field :form="form" fieldName="password_confirmation" inputType="password" :label="$t('auth.forms.confirm_new_password')" />
|
<form-field :form="form" fieldName="password_confirmation" inputType="password" :label="$t('auth.forms.confirm_new_password')" />
|
||||||
@ -16,8 +16,6 @@
|
|||||||
export default {
|
export default {
|
||||||
data(){
|
data(){
|
||||||
return {
|
return {
|
||||||
success: '',
|
|
||||||
fail: '',
|
|
||||||
form: new Form({
|
form: new Form({
|
||||||
currentPassword : '',
|
currentPassword : '',
|
||||||
password : '',
|
password : '',
|
||||||
@ -30,19 +28,18 @@
|
|||||||
handleSubmit(e) {
|
handleSubmit(e) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
this.fail = ''
|
|
||||||
this.success = ''
|
|
||||||
|
|
||||||
this.form.patch('/api/settings/password', {returnError: true})
|
this.form.patch('/api/settings/password', {returnError: true})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
|
|
||||||
this.success = response.data.message
|
this.$notify({ type: 'is-success', text: response.data.message })
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
if( error.response.status === 400 ) {
|
if( error.response.status === 400 ) {
|
||||||
this.fail = error.response.data.message
|
|
||||||
|
this.$notify({ type: 'is-danger', text: error.response.data.message })
|
||||||
}
|
}
|
||||||
else if( error.response.status !== 422 ) {
|
else if( error.response.status !== 422 ) {
|
||||||
|
|
||||||
this.$router.push({ name: 'genericError', params: { err: error.response } });
|
this.$router.push({ name: 'genericError', params: { err: error.response } });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
15
resources/sass/app.scss
vendored
15
resources/sass/app.scss
vendored
@ -314,13 +314,16 @@ footer .field.is-grouped {
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.notification.is-fixed {
|
.notification {
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
padding: 0.5rem 2.5rem 0.5rem 1.5rem;
|
padding: 0.75rem 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification .notification-title {
|
||||||
|
// Style for title line
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification .notification-content {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user