summaryrefslogtreecommitdiffstats
path: root/settings/src/store
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2018-05-30 10:40:50 +0200
committerJulius Härtl <jus@bitgrid.net>2018-06-06 11:40:09 +0200
commit52895cb41ef061900081e82f6232c417f2aa221b (patch)
treea8a07bf3c8871bc9f199031d1c25f9a64a2edbfe /settings/src/store
parent5ac8af27dcb1651a369838e82be8447ef6fa70d3 (diff)
downloadnextcloud-server-52895cb41ef061900081e82f6232c417f2aa221b.tar.gz
nextcloud-server-52895cb41ef061900081e82f6232c417f2aa221b.zip
Add loading indicator and disable buttons during actions
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'settings/src/store')
-rw-r--r--settings/src/store/apps.js63
1 files changed, 45 insertions, 18 deletions
diff --git a/settings/src/store/apps.js b/settings/src/store/apps.js
index 09bc00a3966..eb584443935 100644
--- a/settings/src/store/apps.js
+++ b/settings/src/store/apps.js
@@ -66,6 +66,16 @@ const mutations = {
state.allApps = apps;
},
+ setError(state, {appId, error}) {
+ let app = state.apps.find(app => app.id === appId);
+ app.error = error;
+ },
+
+ clearError(state, {appId, error}) {
+ let app = state.apps.find(app => app.id === appId);
+ app.error = null;
+ },
+
enableApp(state, {appId, groups}) {
let app = state.apps.find(app => app.id === appId);
app.active = true;
@@ -98,12 +108,22 @@ const mutations = {
state.updateCount = 0;
},
startLoading(state, id) {
- Vue.set(state.loading, id, true);
- console.log(state.loading);
+ if (Array.isArray(id)) {
+ id.forEach((_id) => {
+ Vue.set(state.loading, _id, true);
+ })
+ } else {
+ Vue.set(state.loading, id, true);
+ }
},
stopLoading(state, id) {
- Vue.set(state.loading, id, false);
- console.log(state.loading);
+ if (Array.isArray(id)) {
+ id.forEach((_id) => {
+ Vue.set(state.loading, _id, false);
+ })
+ } else {
+ Vue.set(state.loading, id, false);
+ }
},
};
@@ -145,14 +165,22 @@ const actions = {
apps = [appId];
}
return api.requireAdmin().then((response) => {
- return api.post(OC.generateUrl(`settings/apps/enable`), {appIds: apps, groups: groups})
+ context.commit('startLoading', apps);
+ context.commit('startLoading', 'install');
+ return api.post(OC.generateUrl(`settings/apps/enable`), {appIds: apps, groups: groups})
.then((response) => {
+ context.commit('stopLoading', apps);
+ context.commit('stopLoading', 'install');
apps.forEach(_appId => {
context.commit('enableApp', {appId: _appId, groups: groups});
});
return true;
})
- .catch((error) => context.commit('APPS_API_FAILURE', { appId, error }))
+ .catch((error) => {
+ context.commit('stopLoading', apps);
+ context.commit('stopLoading', 'install');
+ context.commit('APPS_API_FAILURE', { appId, error })
+ })
}).catch((error) => context.commit('API_FAILURE', { appId, error }));
},
disableApp(context, { appId }) {
@@ -163,35 +191,34 @@ const actions = {
apps = [appId];
}
return api.requireAdmin().then((response) => {
+ context.commit('startLoading', apps);
return api.post(OC.generateUrl(`settings/apps/disable`), {appIds: apps})
.then((response) => {
+ context.commit('stopLoading', apps);
apps.forEach(_appId => {
context.commit('disableApp', _appId);
});
return true;
})
- .catch((error) => context.commit('APPS_API_FAILURE', { appId, error }))
- }).catch((error) => context.commit('API_FAILURE', { appId, error }));
- },
- // TODO: use enable app
- installApp(context, { appId }) {
- return api.requireAdmin().then((response) => {
- return api.get(OC.generateUrl(`settings/apps/enable/${appId}`))
- .then((response) => {
- context.commit('enableApp', appId);
- return true;
+ .catch((error) => {
+ context.commit('stopLoading', apps);
+ context.commit('APPS_API_FAILURE', { appId, error })
})
- .catch((error) => context.commit('APPS_API_FAILURE', { appId, error }))
}).catch((error) => context.commit('API_FAILURE', { appId, error }));
},
uninstallApp(context, { appId }) {
return api.requireAdmin().then((response) => {
+ context.commit('startLoading', appId);
return api.get(OC.generateUrl(`settings/apps/uninstall/${appId}`))
.then((response) => {
+ context.commit('stopLoading', appId);
context.commit('uninstallApp', appId);
return true;
})
- .catch((error) => context.commit('APPS_API_FAILURE', { appId, error }))
+ .catch((error) => {
+ context.commit('stopLoading', appId);
+ context.commit('APPS_API_FAILURE', { appId, error })
+ })
}).catch((error) => context.commit('API_FAILURE', { appId, error }));
},