Fix displaying errors

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2018-07-04 13:36:16 +02:00
parent 96e65c677b
commit ebeb2da3d3
No known key found for this signature in database
GPG Key ID: 4C614C6ED2CDE6DF
2 changed files with 16 additions and 8 deletions

View File

@ -51,10 +51,10 @@
<div class="actions">
<div class="warning" v-if="app.error">{{ app.error }}</div>
<div class="icon icon-loading-small" v-if="loading(app.id)"></div>
<input v-if="app.update" class="update" type="button" :value="t('settings', 'Update to {update}', {update:app.update})" v-on:click="update(app.id)" :disabled="installing || loading(app.id)" />
<input v-if="app.canUnInstall" class="uninstall" type="button" :value="t('settings', 'Remove')" v-on:click="remove(app.id)" :disabled="installing || loading(app.id)" />
<input v-if="app.active" class="enable" type="button" :value="t('settings','Disable')" v-on:click="disable(app.id)" :disabled="installing || loading(app.id)" />
<input v-if="!app.active" class="enable" type="button" :value="enableButtonText" v-on:click="enable(app.id)" v-tooltip.auto="enableButtonTooltip" :disabled="!app.canInstall || installing || loading(app.id)" />
<input v-if="app.update" class="update" type="button" :value="t('settings', 'Update to {update}', {update:app.update})" v-on:click.stop="update(app.id)" :disabled="installing || loading(app.id)" />
<input v-if="app.canUnInstall" class="uninstall" type="button" :value="t('settings', 'Remove')" v-on:click.stop="remove(app.id)" :disabled="installing || loading(app.id)" />
<input v-if="app.active" class="enable" type="button" :value="t('settings','Disable')" v-on:click.stop="disable(app.id)" :disabled="installing || loading(app.id)" />
<input v-if="!app.active" class="enable" type="button" :value="enableButtonText" v-on:click.stop="enable(app.id)" v-tooltip.auto="enableButtonTooltip" :disabled="!app.canInstall || installing || loading(app.id)" />
</div>
</div>
</template>

View File

@ -62,8 +62,13 @@ const mutations = {
},
setError(state, {appId, error}) {
let app = state.apps.find(app => app.id === appId);
app.error = error;
if (!Array.isArray(appId)) {
appId = [appId];
}
appId.forEach((_id) => {
let app = state.apps.find(app => app.id === _id);
app.error = error;
});
},
clearError(state, {appId, error}) {
@ -199,10 +204,13 @@ const actions = {
});
})
.catch((error) => {
context.commit('setError', {appId: apps, error: t('settings', 'Error while enabling app')});
context.commit('stopLoading', apps);
context.commit('stopLoading', 'install');
context.commit('APPS_API_FAILURE', { appId, error })
context.commit('setError', {
appId: apps,
error: error.response.data.data.message
});
context.commit('APPS_API_FAILURE', { appId, error});
})
}).catch((error) => context.commit('API_FAILURE', { appId, error }));
},