2020-01-20 01:50:45 +01:00
|
|
|
import { Component, Prop, Watch } from 'vue-property-decorator'
|
|
|
|
|
import { INotData } from '../../model/index'
|
|
|
|
|
import { tools } from '../../store/Modules/tools'
|
|
|
|
|
import { NotevoleStore } from '@store'
|
|
|
|
|
import MixinBase from '@src/mixins/mixin-base'
|
|
|
|
|
import { validationMixin } from 'vuelidate'
|
|
|
|
|
import { validations } from '../CSignUpNotevole/CSignUp-validate'
|
|
|
|
|
import { CTitleBanner } from '@components'
|
|
|
|
|
import { CCardState } from '../CCardState'
|
|
|
|
|
import { UserStore } from '../../store/Modules'
|
2020-01-27 15:09:11 +01:00
|
|
|
import { CCardStat } from '../CCardStat'
|
|
|
|
|
import { CLineChart } from '../CLineChart'
|
|
|
|
|
import { CGeoChart } from '../CGeoChart'
|
|
|
|
|
import { CListNationality } from '../CListNationality'
|
2020-01-20 01:50:45 +01:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
name: 'CStatusReg',
|
2020-01-27 15:09:11 +01:00
|
|
|
components: { CTitleBanner, CCardState, CCardStat, CLineChart, CGeoChart, CListNationality }
|
2020-01-20 01:50:45 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export default class CStatusReg extends MixinBase {
|
|
|
|
|
public NUMSEC_TO_POLLING: number = 60
|
|
|
|
|
public MAXNUM_POLLING: number = 10
|
|
|
|
|
|
|
|
|
|
public myloadingload: boolean = false
|
|
|
|
|
public eseguipolling: boolean = false
|
|
|
|
|
public polling = null
|
|
|
|
|
public numpolled: number = 0
|
|
|
|
|
public datastat: INotData = {
|
|
|
|
|
num_reg: 0,
|
2020-05-10 21:06:42 +02:00
|
|
|
num_passeggeri: 0,
|
|
|
|
|
num_imbarcati: 0,
|
2020-01-27 15:09:11 +01:00
|
|
|
num_teleg_attivo: 0,
|
|
|
|
|
email_non_verif: 0,
|
|
|
|
|
num_teleg_pending: 0,
|
2020-01-20 01:50:45 +01:00
|
|
|
lastsreg: [],
|
|
|
|
|
checkuser: { verified_email: false }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async checkifpolling() {
|
|
|
|
|
if (UserStore.state.my.profile) {
|
2020-05-10 21:06:42 +02:00
|
|
|
if (!UserStore.state.my.verified_email || (UserStore.state.my.profile.teleg_id <= 0 && (tools.appid() === tools.IDAPP_AYNI)))
|
2020-01-20 01:50:45 +01:00
|
|
|
this.NUMSEC_TO_POLLING = 10
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.eseguipolling) {
|
|
|
|
|
clearInterval(this.polling)
|
|
|
|
|
this.polling = null
|
|
|
|
|
if (this.numpolled > 100) {
|
|
|
|
|
this.NUMSEC_TO_POLLING = 60 * 5
|
|
|
|
|
}
|
|
|
|
|
if (this.numpolled < this.MAXNUM_POLLING) {
|
|
|
|
|
if (!this.polling) {
|
|
|
|
|
this.polling = setInterval(() => {
|
|
|
|
|
this.load()
|
|
|
|
|
this.numpolled++
|
|
|
|
|
}, this.NUMSEC_TO_POLLING * 1000)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public beforeDestroy() {
|
|
|
|
|
clearInterval(this.polling)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public created() {
|
|
|
|
|
if (tools.isManager()) {
|
2020-02-19 16:10:05 +01:00
|
|
|
this.MAXNUM_POLLING = 100
|
2020-01-20 01:50:45 +01:00
|
|
|
}
|
|
|
|
|
this.load()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get lastsreg() {
|
|
|
|
|
return this.datastat.lastsreg
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async load() {
|
|
|
|
|
// console.log('load')
|
|
|
|
|
this.myloadingload = true
|
|
|
|
|
const datastat = await NotevoleStore.actions.notevoleload()
|
|
|
|
|
if (datastat) {
|
|
|
|
|
this.datastat = datastat
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// console.log('this.datastat.lastsreg')
|
|
|
|
|
// console.table(this.datastat.lastsreg)
|
|
|
|
|
|
|
|
|
|
// console.log('newsstate')
|
|
|
|
|
// console.table('GlobalStore.state.serv_settings', GlobalStore.state.serv_settings)
|
|
|
|
|
|
|
|
|
|
this.eseguipolling = true
|
|
|
|
|
|
|
|
|
|
// console.log('this.eseguipolling', this.eseguipolling)
|
|
|
|
|
this.myloadingload = false
|
|
|
|
|
|
|
|
|
|
if (UserStore.state.my) {
|
|
|
|
|
if (this.datastat.checkuser) {
|
|
|
|
|
if (this.datastat.checkuser.verified_email && !UserStore.state.my.verified_email) {
|
|
|
|
|
UserStore.state.my.verified_email = true
|
|
|
|
|
this.riaggiorna()
|
|
|
|
|
}
|
2020-03-10 21:42:30 +01:00
|
|
|
if (UserStore.state.my.profile && this.datastat.checkuser.profile) {
|
2020-01-20 01:50:45 +01:00
|
|
|
if ((UserStore.state.my.profile.teleg_id <= 0 && this.datastat.checkuser.profile.teleg_id > 0) ||
|
|
|
|
|
(UserStore.state.my.profile.teleg_id !== this.datastat.checkuser.profile.teleg_id > 0)) {
|
|
|
|
|
UserStore.state.my.profile.teleg_id = this.datastat.checkuser.profile.teleg_id
|
|
|
|
|
this.riaggiorna()
|
|
|
|
|
}
|
|
|
|
|
if ((UserStore.state.my.profile.teleg_checkcode <= 0 && this.datastat.checkuser.profile.teleg_checkcode > 0) ||
|
|
|
|
|
(UserStore.state.my.profile.teleg_checkcode !== this.datastat.checkuser.profile.teleg_checkcode)) {
|
|
|
|
|
UserStore.state.my.profile.teleg_checkcode = this.datastat.checkuser.profile.teleg_checkcode
|
|
|
|
|
this.riaggiorna()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.checkifpolling()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public riaggiorna() {
|
|
|
|
|
// clearInterval(this.polling)
|
|
|
|
|
// this.polling = null
|
|
|
|
|
this.checkifpolling()
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-19 16:10:05 +01:00
|
|
|
public calcperc(val1, valmax ) {
|
|
|
|
|
if (valmax > 0)
|
|
|
|
|
return (val1 / valmax * 100)
|
|
|
|
|
else
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-20 01:50:45 +01:00
|
|
|
get visustat() {
|
2020-05-10 21:06:42 +02:00
|
|
|
return this.datastat.num_reg > 0
|
2020-01-20 01:50:45 +01:00
|
|
|
}
|
|
|
|
|
|
2020-01-27 15:09:11 +01:00
|
|
|
get telegnonattivi() {
|
|
|
|
|
return this.datastat.num_reg - this.datastat.num_teleg_attivo
|
|
|
|
|
}
|
|
|
|
|
get emailnonverif() {
|
|
|
|
|
return this.datastat.email_non_verif
|
|
|
|
|
}
|
2020-01-20 01:50:45 +01:00
|
|
|
}
|