Commit 0da95ae3 authored by gj4210's avatar gj4210 👁
Browse files

UPD: Turned transaction_error into transaction_result

+ hide transaction result (currently error only) when changes to transaction list are made
parent 336d60fe
Pipeline #92687 passed with stages
in 7 minutes and 40 seconds
......@@ -42,9 +42,9 @@
</li>
</ul>
<div class="error-warning"
v-if="$store.state.transaction_error && $store.state.transaction_error.uuid === element.uuid">
v-if="$store.state.transaction_result && $store.state.transaction_result.type === 'error' && $store.state.transaction_result.uuid === element.uuid">
<font-awesome-icon :icon="['fas','exclamation-triangle']"/>
{{$store.state.transaction_error.error.error.description}}
{{$store.state.transaction_result.error.error.description}}
</div>
<b-button-group class="d-flex">
<b-button :disabled="should_edit" variant="outline-primary"
......@@ -85,13 +85,14 @@
Anwenden
</b-button>
</b-button-group>
<template v-if="$store.state.transaction_error">
<template v-if="$store.state.transaction_result && $store.state.transaction_result.type === 'error'">
<hr/>
<p class="text-center text-danger">
<font-awesome-icon :icon="['fas','exclamation-triangle']"/>
Weitere Fehlerinformationen:
</p>
<CopyField variant="danger" :text="JSON.stringify($store.state.transaction_error.error, null, 1)" multiline/>
<CopyField variant="danger" :text="JSON.stringify($store.state.transaction_result.error, null, 1)"
multiline/>
</template>
<DBEditor modal_id="ta-edit"
:object_fq_name="edit_elem.object_fq_name"
......
......@@ -55,7 +55,7 @@ const store = new Vuex.Store({
done: JSON.parse(window.localStorage.getItem('done')) || [],
undone: JSON.parse(window.localStorage.getItem('undone')) || [],
undo_redo_new_mutaion: JSON.parse(window.localStorage.getItem('undo_redo_new_mutation')) || true,
transaction_error: JSON.parse(window.localStorage.getItem('transaction_error')) || null,
transaction_result: JSON.parse(window.localStorage.getItem('transaction_result')) || null,
show_sidebar: JSON.parse(window.localStorage.getItem('show_sidebar')) || false,
},
mutations: {
......@@ -114,14 +114,15 @@ const store = new Vuex.Store({
state.undo_redo_new_mutaion = true
state.undone = []
state.done = []
state.transaction_error = null
state.transaction_result = null
window.localStorage.removeItem('done')
window.localStorage.removeItem('undone')
window.localStorage.removeItem('undo_redo_new_mutation')
window.localStorage.removeItem('user')
window.localStorage.removeItem('token')
window.localStorage.removeItem('ta_list')
window.localStorage.removeItem('transaction_error')
window.localStorage.removeItem('transaction_result')
window.localStorage.removeItem('show_sidebar')
state.netdb_axios_config = {
headers: {
'Authorization': null,
......@@ -130,6 +131,9 @@ const store = new Vuex.Store({
}
},
removeTransactionElement(state, payload) {
state.transaction_result = null
window.localStorage.removeItem('transaction_result')
for (let i = 0; i < state.ta_list.length; i++) {
if (state.ta_list[i].uuid === payload.uuid) {
state.ta_list.splice(i, 1)
......@@ -139,6 +143,9 @@ const store = new Vuex.Store({
window.localStorage.setItem('ta_list', JSON.stringify(state.ta_list))
},
addTransactionElement(state, payload) {
state.transaction_result = null
window.localStorage.removeItem('transaction_result')
if (state.ta_list == null) {
state.ta_list = []
}
......@@ -156,26 +163,38 @@ const store = new Vuex.Store({
window.localStorage.setItem('ta_list', JSON.stringify(state.ta_list))
},
emptyTransactionList(state) {
state.transaction_result = null
window.localStorage.removeItem('transaction_result')
state.ta_list = []
window.localStorage.setItem('ta_list', JSON.stringify(state.ta_list))
},
async testTransaction(state) {
state.transaction_result = null
window.localStorage.removeItem('transaction_result')
let api_list = APIUtil.buildAPITaFromTaObjectArray(state.ta_list)
try {
let res = await WAPITransactionSerice.executeDry(state.netdb_axios_config, api_list)
window.console.debug(res)
state.transaction_error = null
window.localStorage.setItem('transaction_error', JSON.stringify(state.transaction_error))
state.transaction_result = {
'type': 'success'
}
window.localStorage.setItem('transaction_result', JSON.stringify(state.transaction_result))
} catch (e) {
window.console.debug(e.response)
state.transaction_error = {
state.transaction_result = {
'type': 'error',
'error': e.response.data.exception,
'uuid': state.ta_list[e.response.data.exception.traceback[0].param['wapi.transaction_stmt.index']].uuid
}
window.localStorage.setItem('transaction_error', JSON.stringify(state.transaction_error))
window.localStorage.setItem('transaction_result', JSON.stringify(state.transaction_result))
}
},
async executeTransaction(state) {
state.transaction_result = null
window.localStorage.removeItem('transaction_result')
let api_list = APIUtil.buildAPITaFromTaObjectArray(state.ta_list)
try {
let res = await WAPITransactionSerice.execute(state.netdb_axios_config, api_list)
......@@ -188,15 +207,18 @@ const store = new Vuex.Store({
window.localStorage.removeItem('undone')
window.localStorage.removeItem('undo_redo_new_mutation')
window.localStorage.removeItem('ta_list')
state.transaction_error = null
window.localStorage.setItem('transaction_error', JSON.stringify(state.transaction_error))
state.transaction_result = {
'type': 'success'
}
window.localStorage.setItem('transaction_result', JSON.stringify(state.transaction_result))
} catch (e) {
window.console.debug(e.response)
state.transaction_error = {
state.transaction_result = {
'type': 'error',
'error': e.response.data.exception,
'uuid': state.ta_list[e.response.data.exception.traceback[0].param['wapi.transaction_stmt.index']].uuid
}
window.localStorage.setItem('transaction_error', JSON.stringify(state.transaction_error))
window.localStorage.setItem('transaction_result', JSON.stringify(state.transaction_result))
}
},
showSidebar(state, show) {
......@@ -208,7 +230,7 @@ const store = new Vuex.Store({
sharedMutations(
{
predicate:
['pushUndoRedoUndone', 'popUndoRedoUndone', 'clearUndoRedoUndone', 'setUndoRedoNewMutation', 'clearUndoRedoDone', 'popUndoRedoDone', 'emptyState', 'login', 'logout', 'addTransactionElement', 'removeTransactionElement', 'emptyTransactionList']
['pushUndoRedoUndone', 'popUndoRedoUndone', 'clearUndoRedoUndone', 'setUndoRedoNewMutation', 'clearUndoRedoDone', 'popUndoRedoDone', 'emptyState', 'login', 'logout', 'addTransactionElement', 'removeTransactionElement', 'emptyTransactionList', 'removeTransactionResult']
}
)
],
......
Supports Markdown
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