Skip to content

Commit

Permalink
add ability to revalidate User Condition when changing
Browse files Browse the repository at this point in the history
  • Loading branch information
disk91 committed Aug 12, 2023
1 parent 33e1583 commit 532fb40
Show file tree
Hide file tree
Showing 13 changed files with 392 additions and 23 deletions.
119 changes: 119 additions & 0 deletions nuxt/console/components/UserConditionSetup.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<template>
<div>
<h5><b-badge variant="secondary" class="m-2">{{ $t('uc_version_title') }}</b-badge></h5>

<b-form-group
:label="$t('uc_version')"
label-for="conditionVersion"
label-cols="3"
label-align="right"
label-class="w-25"
label-size="sm"
class="mb-1 mr-1"
>
<b-form-input
v-model="versionRead.message"
id="conditionVersion"
type="text" size="sm"
></b-form-input>
<b-form-text style="font-size:0.5rem;">{{ $t('uc_version_desc') }}</b-form-text>
</b-form-group>
<b-form-group
label-cols="3"
label-align="right"
label-class="w-25"
label-size="sm"
class="mb-1"
>
<b-button
variant="primary"
size="sm"
@click="updateCondition()"
>
{{ $t('inv_upt_but') }}
</b-button>
<b-card-text class="small mb-2 text-danger" v-show="errorMessage!=''">
<b-icon icon="exclamation-circle-fill" variant="danger"></b-icon>
{{ $t(errorMessage) }}
</b-card-text>
<b-card-text class="mb-2 text-success" v-show="successMessage!=''">
<b-icon icon="check-square" variant="success"></b-icon>
{{ $t(successMessage) }}
</b-card-text>
</b-form-group>

</div>
</template>

<script lang="ts">
import Vue from 'vue'
import { UserConditionVersionGetReqItf, UserConditionVersionUpdateReqItf } from 'vue/types/conditions';
interface data {
isBusy : boolean,
versionRead : UserConditionVersionGetReqItf,
errorMessage : string,
successMessage : string,
}
export default Vue.extend({
name: "ConditionSetup",
components: {
},
data() : data {
return {
isBusy : false,
versionRead : {} as UserConditionVersionGetReqItf,
errorMessage : '',
successMessage : '',
};
},
async fetch() {
let config = {
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer '+this.$store.state.consoleBearer,
}
};
this.isBusy = true;
this.$axios.get<UserConditionVersionGetReqItf>(this.$config.conditionGet,config)
.then((response) =>{
if (response.status == 200 ) {
this.versionRead = response.data;
this.isBusy = false;
}
}).catch((err) =>{
this.errorMessage = 'uc_error_load_condition';
this.versionRead = {} as UserConditionVersionGetReqItf;
})
},
methods : {
updateCondition() {
this.errorMessage='';
this.successMessage='';
let config = {
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer '+this.$store.state.consoleBearer,
}
};
let newCondition = {
conditionVersion : this.versionRead.message
} as UserConditionVersionUpdateReqItf;
this.$axios.put(this.$config.conditionPut, newCondition, config)
.then((response) =>{
if (response.status == 200 ) {
this.successMessage = "uc_update_success";
}
}).catch((err) =>{
if ( err.response.status == 403 ) {
this.errorMessage = "uc_update_error";
}
})
}
},
mounted() {
},
})
</script>
11 changes: 11 additions & 0 deletions nuxt/console/front_locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -417,5 +417,16 @@
"mig_setup_auth_data_tx" : "By entering your API key, you accept to transfer device meta-data, credentials and other needed information to this service.",
"mig_processing_devices" : "Preparing devices",

"uc_version_title" : "User condition version",
"uc_version" : "Current version",
"uc_version_desc" : "Free text field for naming the current user condition version",
"uc_error_load_condition" : "Failed to load user condition version",
"uc_update_success" : "Condition Version has been updated",
"uc_update_error" : "Impossible to update condition version",
"uc_condition_message" : "The end user licence agreement has been updated, before being able to access the service, you need to renew your agreement for these new conditions.",
"uc_condition_visit" : "Please read the end-user license agreement",
"uc_condition_valid" : "I accept the new end-user license agreement",
"uc_condition_submit" : "Next",

"end" : "end"
}
11 changes: 11 additions & 0 deletions nuxt/console/front_locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -418,5 +418,16 @@
"mig_setup_auth_data_tx" : "En saisissant votre clef API, vous acceptez de transférer les meta-données de vos objets, leurs clefs, et autres données vers ce service.",
"mig_processing_devices" : "Prepartion des devices",

"uc_version_title" : "Version des conditions utilisateur",
"uc_version" : "Version actuelle",
"uc_version_desc" : "Version des conditions, champ texte libre",
"uc_error_load_condition" : "Impossible de charger la version de condition",
"uc_update_success" : "La version des conditions a été mise à jour",
"uc_update_error" : "Impossible de mettre à jour la version",
"uc_condition_message" : "Les conditions d'utilisation du service ont évoluées, vous devez valider les nouvelles conditions pour accéder au service.",
"uc_condition_visit" : "Merci de lire les nouvelles conditions d'utilisation",
"uc_condition_valid" : "J'accepte les conditions d'utilisation",
"uc_condition_submit" : "Continuer",

"end" : "fin"
}
8 changes: 8 additions & 0 deletions nuxt/console/interfaces/conditions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
declare module "vue/types/conditions" {
interface UserConditionVersionGetReqItf {
message : string,
}
interface UserConditionVersionUpdateReqItf {
conditionVersion : string,
}
}
3 changes: 3 additions & 0 deletions nuxt/console/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ export default {
proxyGet:(process.env.API_HOST || '')+'/console/1.0/proxy/getter',
proxyDeact:(process.env.API_HOST || '')+'/console/1.0/proxy/deactivate',
ouiGet:(process.env.API_HOST || '')+'/console/1.0/misc/oui',
conditionGet:(process.env.API_HOST || '')+'/console/1.0/misc/condition',
conditionPut:(process.env.API_HOST || '')+'/console/1.0/misc/condition',
userConditionPut:(process.env.API_HOST || '')+'/console/1.0/user/condition',
termAndUse:process.env.CONSOLE_TERMS || '/',
maxDevices:process.env.MAX_DEVICES || 500,
disablePurchase:process.env.DIS_DC_PURCHASE || 'false',
Expand Down
93 changes: 93 additions & 0 deletions nuxt/console/pages/front/conditions.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<template>
<div style="height: 100vh; width: 100%;
z-index: 1; overflow: hidden; position: relative;
display: flex;
background: url('/static/front/background.svg') center center / cover rgb(240, 242, 245);
box-sizing: border-box;
justify-content: center;">
<div style="max-width: 500px; position: absolute;
top: 47%; left: 50%; transform: translate(-50%, -50%);
height: auto;">
<b-card align="center" style="border-radius: 1.5rem;padding: 2rem;">
<b-card-img src="/static/front/logo.svg"
alt="logo"
style="width: 25%; margin: 20px 0px 20px 0px;"
top></b-card-img>
<b-card-text>
<h1 class="mb-2">{{ $config.consoleName }}</h1>
</b-card-text>
<b-card-text class="small">
<span style="color: rgb(148, 24, 51);">
{{ $t('uc_condition_message') }}
</span><br/>
<b-link :href="$config.termAndUse">{{ $t('uc_condition_visit') }}</b-link>
<br/>
<b-form-group style="text-align:center;" class="mb-1 small mt-2">
<b-form-checkbox v-model="conditionAccepted"
id="signup-conditions"
value='true'
unchecked-value='false'
class="mb-1"
style="text-align:center;"
:state="conditionState"
>
{{ $t('uc_condition_valid') }}
</b-form-checkbox>
</b-form-group>
<b-button block @click="conditionValidated"
:disabled="acceptSubmit"
variant="primary"
class="mb-2">
{{ $t('uc_condition_submit') }}</b-button>
</b-form>

</b-card-text>
</b-card>
</div>

</div>
</template>


<script lang="ts">
import Vue from 'vue'
export default Vue.extend({
name: "UserConditionPage",
auth: false,
data() {
return {
polling : null,
conditionAccepted : 'false',
conditionState : true,
errorMessage : '',
}
},
computed: {
acceptSubmit() {
return ! (this.$data.conditionAccepted == 'true');
}
},
methods: {
async conditionValidated() {
this.errorMessage='';
let config = {
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer '+this.$store.state.consoleBearer,
}
};
this.$axios.put(this.$config.userConditionPut, {}, config)
.then((response) =>{
if (response.status == 200 ) {
this.$router.push('/front/');
}
}).catch((err) =>{
})
}
},
mounted() {
},
})
</script>
9 changes: 8 additions & 1 deletion nuxt/console/pages/front/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,15 @@ export default Vue.extend({
let conBearer = resp.data.consoleBearer;
this.$store.commit('setConsoleBearer', conBearer);
this.$store.commit('setUserAdmin',resp.data.admin);
if ( resp.data.userConditionChanged ) {
this.$router.push('/front/conditions/');
} else {
this.$router.push('/front/');
}
} else {
// @TODO should be an error page ?
this.$router.push('/front/');
}
this.$router.push('/front/');
});
} catch (err) {
this.errorMessage=this.$t('login_error') as string;
Expand Down
5 changes: 4 additions & 1 deletion nuxt/console/pages/front/profiles.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<b-col cols="6">
<ManageTenant/>
</b-col>
<b-col cols="6">
<b-col cols="6">
<UserConditionVersion/>
<InvoiceSetup/>
</b-col>
</b-row>
Expand All @@ -19,6 +20,7 @@
import ManageTenantTemplate from '~/components/ManageTenantTemplate.vue';
import ManageTenant from '~/components/ManageTenant.vue';
import InvoiceSetup from '~/components/InvoiceSetup.vue';
import UserConditionVersion from '~/components/UserConditionSetup.vue';
export default Vue.extend({
name: "ManageTenantProfiles",
Expand All @@ -27,6 +29,7 @@
'ManageTenantTemplate' : ManageTenantTemplate,
'ManageTenant' : ManageTenant,
'InvoiceSetup' : InvoiceSetup,
'UserConditionVersion' : UserConditionVersion,
},
})
</script>
Expand Down
Loading

0 comments on commit 532fb40

Please sign in to comment.