Implement app bundle management
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
parent
5f8b935c8e
commit
127b21b493
|
@ -113,10 +113,40 @@ export default {
|
|||
},
|
||||
useBundleView() {
|
||||
return (this.category === 'app-bundles');
|
||||
},
|
||||
allBundlesEnabled() {
|
||||
return function(id) {
|
||||
console.log(this.bundleApps(id).filter(app => !app.active));
|
||||
return this.bundleApps(id).filter(app => !app.active).length === 0;
|
||||
}
|
||||
},
|
||||
bundleToggleText() {
|
||||
return function(id) {
|
||||
if (this.allBundlesEnabled(id)) {
|
||||
return t('settings', 'Disable all');
|
||||
}
|
||||
return t('settings', 'Enable all');
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
toggleBundle(id) {
|
||||
if (this.allBundlesEnabled) {
|
||||
return this.disableBundle(id);
|
||||
}
|
||||
return this.enableBundle(id);
|
||||
},
|
||||
enableBundle(id) {
|
||||
let apps = this.bundleApps(id).map(app => app.id);
|
||||
console.log(apps);
|
||||
this.$store.dispatch('enableApp', { appId: apps, groups: [] })
|
||||
.catch((error) => { console.log(error); OC.Notification.show(error)});
|
||||
},
|
||||
disableBundle(id) {
|
||||
let apps = this.bundleApps(id).map(app => app.id);
|
||||
this.$store.dispatch('disableApp', { appId: apps, groups: [] })
|
||||
.catch((error) => { OC.Notification.show(error)});
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -138,28 +138,42 @@ const getters = {
|
|||
const actions = {
|
||||
|
||||
enableApp(context, { appId, groups }) {
|
||||
let apps;
|
||||
if (Array.isArray(appId)) {
|
||||
apps = appId;
|
||||
} else {
|
||||
apps = [appId];
|
||||
}
|
||||
return api.requireAdmin().then((response) => {
|
||||
return api.post(OC.generateUrl(`settings/apps/enable/${appId}`), {
|
||||
groups: groups
|
||||
})
|
||||
return api.post(OC.generateUrl(`settings/apps/enable`), {appIds: apps, groups: groups})
|
||||
.then((response) => {
|
||||
context.commit('enableApp', {appId: appId, groups: groups});
|
||||
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('API_FAILURE', { appId, error }));
|
||||
|
||||
},
|
||||
disableApp(context, { appId }) {
|
||||
let apps;
|
||||
if (Array.isArray(appId)) {
|
||||
apps = appId;
|
||||
} else {
|
||||
apps = [appId];
|
||||
}
|
||||
return api.requireAdmin().then((response) => {
|
||||
return api.get(OC.generateUrl(`settings/apps/disable/${appId}`))
|
||||
return api.post(OC.generateUrl(`settings/apps/disable`), {appIds: apps})
|
||||
.then((response) => {
|
||||
context.commit('disableApp', appId);
|
||||
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}`))
|
||||
|
|
Loading…
Reference in New Issue