improve: Drag & Drop (work in progress)

fix: - Axios: login error msg
This commit is contained in:
Paolo Arena
2019-02-20 11:53:56 +01:00
parent 1eca13c27f
commit 6a99f22bf3
21 changed files with 263 additions and 133 deletions

View File

@@ -30,6 +30,7 @@ export default class Signin extends Vue {
public $q
loading: boolean
$t: any
public iswaitingforRes: boolean = false
public signin: ISigninOptions = {
username: process.env.TEST_USERNAME || '',
@@ -75,31 +76,46 @@ export default class Signin extends Vue {
}
checkErrors(riscode) {
// console.log("RIS = " + riscode);
if (riscode === rescodes.OK) {
this.showNotif({ type: 'positive', message: this.$t('login.completato') })
this.$router.push('/')
} else if (riscode === serv_constants.RIS_CODE_LOGIN_ERR) {
// console.log('checkErrors: ', riscode)
try {
if (riscode === rescodes.OK) {
this.showNotif({ type: 'positive', message: this.$t('login.completato') })
this.$router.push('/')
} else if (riscode === serv_constants.RIS_CODE_LOGIN_ERR) {
// Wait N seconds to avoid calling many times...
return new Promise(function (resolve, reject) {
setTimeout(function () {
resolve('anything')
}, 1000)
}).then(() => {
this.showNotif(this.$t('login.errato'))
this.$router.push('/signin')
})
// Wait N seconds to avoid calling many times...
return new Promise(function (resolve, reject) {
setTimeout(function () {
resolve('anything')
}, 3000)
}).then(() => {
setTimeout( () => {
this.$q.loading.hide()
}, 200)
this.showNotif(this.$t('login.errato'))
this.iswaitingforRes = false
this.$router.push('/signin')
})
} else if (riscode === rescodes.ERR_SERVERFETCH) {
this.showNotif(this.$t('fetch.errore_server'))
} else if (riscode === rescodes.ERR_GENERICO) {
let msg = this.$t('fetch.errore_generico') + UserStore.mutations.getMsgError(riscode)
this.showNotif(msg)
} else {
this.showNotif('Errore num ' + riscode)
}
if (riscode !== serv_constants.RIS_CODE_LOGIN_ERR) {
this.iswaitingforRes = false
setTimeout( () => {
this.$q.loading.hide()
}, 200)
}
} finally {
} else if (riscode === rescodes.ERR_SERVERFETCH) {
this.showNotif(this.$t('fetch.errore_server'))
} else if (riscode === rescodes.ERR_GENERICO) {
let msg = this.$t('fetch.errore_generico') + UserStore.mutations.getMsgError(riscode)
this.showNotif(msg)
} else {
this.showNotif('Errore num ' + riscode)
}
}
redirect(response) {
@@ -132,17 +148,24 @@ export default class Signin extends Vue {
}
this.$q.loading.show({ message: this.$t('login.incorso') })
// disable Button Login:
this.iswaitingforRes = true
console.log(this.signin)
UserStore.actions.signin(this.signin)
.then((riscode) => {
console.log('signin FINITO CALL: riscode=', riscode)
// console.log('signin FINITO CALL: riscode=', riscode)
if (riscode === rescodes.OK) {
router.push('/signin')
}
return riscode
}).then((riscode) => {
this.$i18n.locale = UserStore.state.lang // Set Lang
if (UserStore.state.lang !== '')
this.$i18n.locale = UserStore.state.lang // Set Lang
else
UserStore.mutations.setlang(this.$i18n.locale) // Set Lang
// console.log('LANG ORA=', UserStore.state.lang)
globalroutines(this, 'loadapp', '')
return riscode
@@ -150,22 +173,21 @@ export default class Signin extends Vue {
.then((riscode) => {
if (riscode === rescodes.OK) {
GlobalStore.actions.createPushSubscription()
.then(ris => {
.then(rissub => {
})
.catch(e => {
console.log('ERROR = ' + e)
})
.then(() => {
this.checkErrors(riscode)
this.$q.loading.hide()
console.log('ERROR Subscription = ' + e)
})
}
this.checkErrors(riscode)
})
.catch(error => {
console.log('ERROR SIGNIN = ' + error)
this.checkErrors(error)
this.$q.loading.hide()
})
}

View File

@@ -52,7 +52,7 @@
</q-card-main>
<div align="center">
<q-btn rounded size="lg" color="primary" @click="submit" :disable="$v.$error">{{$t('login.enter')}}
<q-btn rounded size="lg" color="primary" @click="submit" :disable="$v.$error || iswaitingforRes">{{$t('login.enter')}}
</q-btn>
</div>
</form>