Commit a8d91dba authored by Janis Streib's avatar Janis Streib 🦉
Browse files

UPD: make token create transactional and did some cleanup

parent 7900f9bf
Pipeline #117217 passed with stages
in 4 minutes and 57 seconds
...@@ -222,52 +222,6 @@ ...@@ -222,52 +222,6 @@
</b-button> </b-button>
</template> </template>
</b-modal> </b-modal>
<b-modal id="modal-edit-token" size=lg title="Token bearbeiten">
<b-form>
<b-form-group label="Beschreibung:" label-for="input-token-edit-description">
<b-form-textarea
id="input-token-edit-description"
v-model.trim="new_token.description"
required
placeholder="Beschreibung"
/>
</b-form-group>
</b-form>
<div v-if="new_token.expiration_date != null">
<DateTimePicker label="Ablaufdatum:" :model="new_token.expiration_date"/>
<b-button block variant="outline-secondary" @click="new_token.expiration_date = null">
Ablaufdatum entfernen
</b-button>
</div>
<b-button block variant="outline-secondary" v-else
@click="new_token.expiration_date = formatDate(getDate30DaysAhead())">
Ablaufdatum hinzufügen
</b-button>
<template v-slot:modal-footer="{cancel}">
<b-alert id="alert-edit-token" v-model="show_modal_alert"
variant="danger" dismissible fade class="mb-0 flex-grow">
{{ modal_alert_content }}
</b-alert>
<b-button variant="outline-secondary" @click="cancel">
Abbrechen
</b-button>
<b-button id="button-delete-token" variant="danger">
Löschen
</b-button>
<b-popover ref="popoverTokenDelete" target="button-delete-token" triggers="click" placement="bottom">
<template v-slot:title>Token wirklich löschen?</template>
<b-button variant="danger" @click="deleteToken">
Löschen
</b-button>
<b-button variant="outline-secondary" @click="$refs.popoverTokenDelete.$emit('close')">
Abbrechen
</b-button>
</b-popover>
<b-button type="submit" variant="primary" :disabled="waiting" @click="editToken">
Änderungen übernehmen
</b-button>
</template>
</b-modal>
<Loading :data="[filtered_accounts]"> <Loading :data="[filtered_accounts]">
<template v-for="account in filtered_accounts"> <template v-for="account in filtered_accounts">
<b-card no-body :key="'card-account-' + account.login_name" class="mb-4 shadow"> <b-card no-body :key="'card-account-' + account.login_name" class="mb-4 shadow">
...@@ -390,10 +344,10 @@ ...@@ -390,10 +344,10 @@
</b-collapse> </b-collapse>
</b-card> </b-card>
</template> </template>
<DBEditor object_fq_name="cntl.wapi_auth" modal_id="edit_token" object_function="update" <DBEditor object_fq_name="cntl.wapi_auth" modal_id="token_editor" :object_function="db_editor_function"
:old_data="db_editor_old_data" :old_data="db_editor_old_data"
:presets="db_editor_presets" :presets="db_editor_presets"
:non_optionals_order="['description', 'expiration_date', 'do_refresh_token']" :non_optionals_order="['login_name', 'description', 'expiration_date', 'do_refresh_token']"
></DBEditor> ></DBEditor>
</Loading> </Loading>
</div> </div>
...@@ -419,6 +373,7 @@ export default { ...@@ -419,6 +373,7 @@ export default {
return { return {
db_editor_old_data: null, db_editor_old_data: null,
db_editor_presets: null, db_editor_presets: null,
db_editor_function: 'update',
tokens_by_account: null, tokens_by_account: null,
roles_by_account: null, roles_by_account: null,
assignable_roles: null, assignable_roles: null,
...@@ -563,14 +518,14 @@ export default { ...@@ -563,14 +518,14 @@ export default {
}, },
showModalEditToken(token) { showModalEditToken(token) {
this.db_editor_old_data = this.db_editor_presets = token this.db_editor_old_data = this.db_editor_presets = token
this.$bvModal.show('edit_token') this.db_editor_function = 'update'
this.$bvModal.show('token_editor')
}, },
showModalCreateToken(login_name) { showModalCreateToken(login_name) {
this.new_token.description = '' this.db_editor_old_data = {}
this.new_token.expiration_date = null this.db_editor_presets = { login_name: login_name }
this.new_token.login_name = login_name this.db_editor_function = 'create'
this.show_modal_alert = false this.$bvModal.show('token_editor')
this.$bvModal.show('modal-create-token')
}, },
resetAccountData() { resetAccountData() {
this.new_account = { this.new_account = {
...@@ -685,23 +640,6 @@ export default { ...@@ -685,23 +640,6 @@ export default {
this.waiting = false this.waiting = false
}) })
}, },
editToken() {
this.waiting = true
TokenService.update(this.$store.state.netdb_axios_config, {
description_new: this.new_token.description,
pk_old: this.new_token.pk,
do_refresh_token_new: true,
expiration_date_new: this.new_token.expiration_date
}).then(() => {
this.$bvModal.hide('modal-edit-token')
this.fetchData()
this.waiting = false
}).catch(error => {
this.modal_alert_content = error.response.data.error.type.text_descr
this.show_modal_alert = true
this.waiting = false
})
},
deleteToken() { deleteToken() {
this.waiting = true this.waiting = true
TokenService.delete(this.$store.state.netdb_axios_config, { TokenService.delete(this.$store.state.netdb_axios_config, {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment