summaryrefslogtreecommitdiffstats
path: root/settings/js
diff options
context:
space:
mode:
authoricewind1991 <robin@icewind.nl>2014-06-03 19:01:12 +0200
committericewind1991 <robin@icewind.nl>2014-06-03 19:01:12 +0200
commitcdf8a123e7133fdb59991ee1bc830e625727460f (patch)
tree90fb931f8f0adccd8687c154723e53d5fb3e7dec /settings/js
parente4c3ff03d60d5b541e483050174b1b7456e4babd (diff)
parenta3202f1f031b443433aefc74958b268ceae3e024 (diff)
downloadnextcloud-server-cdf8a123e7133fdb59991ee1bc830e625727460f.tar.gz
nextcloud-server-cdf8a123e7133fdb59991ee1bc830e625727460f.zip
Merge pull request #8264 from owncloud/app-enable-by-group
Add the option to enable apps only for specific groups
Diffstat (limited to 'settings/js')
-rw-r--r--settings/js/apps.js90
1 files changed, 85 insertions, 5 deletions
diff --git a/settings/js/apps.js b/settings/js/apps.js
index 05db4c9a048..b1c28498266 100644
--- a/settings/js/apps.js
+++ b/settings/js/apps.js
@@ -88,12 +88,41 @@ OC.Settings.Apps = OC.Settings.Apps || {
} else {
page.find(".warning").hide();
}
+
+ page.find("div.multiselect").parent().remove();
+ if(OC.Settings.Apps.isType(app, 'filesystem') || OC.Settings.Apps.isType(app, 'prelogin') ||
+ OC.Settings.Apps.isType(app, 'authentication') || OC.Settings.Apps.isType(app, 'logging')) {
+ page.find("#groups_enable").hide();
+ page.find("label[for='groups_enable']").hide();
+ page.find("#groups_enable").attr('checked', null);
+ } else {
+ $('#group_select > option').each(function (i, el) {
+ if (app.groups.length === 0 || app.groups.indexOf(el.value) >= 0) {
+ $(el).attr('selected', 'selected');
+ } else {
+ $(el).attr('selected', null);
+ }
+ });
+ if (app.active) {
+ if (app.groups.length) {
+ $('#group_select').multiSelect();
+ page.find("#groups_enable").attr('checked','checked');
+ } else {
+ page.find("#groups_enable").attr('checked', null);
+ }
+ page.find("#groups_enable").show();
+ page.find("label[for='groups_enable']").show();
+ } else {
+ page.find("#groups_enable").hide();
+ page.find("label[for='groups_enable']").hide();
+ }
+ }
},
- enableApp:function(appid, active, element) {
- console.log('enableApp:', appid, active, element);
+ enableApp:function(appid, active, element, groups) {
+ groups = groups || [];
var appitem=$('#app-navigation ul li[data-id="'+appid+'"]');
element.val(t('settings','Please wait....'));
- if(active) {
+ if(active && !groups.length) {
$.post(OC.filePath('settings','ajax','disableapp.php'),{appid:appid},function(result) {
if(!result || result.status !== 'success') {
if (result.data && result.data.message) {
@@ -108,14 +137,19 @@ OC.Settings.Apps = OC.Settings.Apps || {
}
else {
appitem.data('active',false);
+ appitem.data('groups', '');
element.data('active',false);
OC.Settings.Apps.removeNavigation(appid);
appitem.removeClass('active');
element.val(t('settings','Enable'));
+ element.parent().find("#groups_enable").hide();
+ element.parent().find("label[for='groups_enable']").hide();
+ var app = OC.get('appData_' + appid);
+ app.active = false;
}
},'json');
} else {
- $.post(OC.filePath('settings','ajax','enableapp.php'),{appid:appid},function(result) {
+ $.post(OC.filePath('settings','ajax','enableapp.php'),{appid: appid, groups: groups},function(result) {
if(!result || result.status !== 'success') {
if (result.data && result.data.message) {
OC.Settings.Apps.showErrorMessage(result.data.message);
@@ -132,6 +166,21 @@ OC.Settings.Apps = OC.Settings.Apps || {
element.data('active',true);
appitem.addClass('active');
element.val(t('settings','Disable'));
+ var app = OC.get('appData_' + appid);
+ app.active = true;
+ if (OC.Settings.Apps.isType(app, 'filesystem') || OC.Settings.Apps.isType(app, 'prelogin') ||
+ OC.Settings.Apps.isType(app, 'authentication') || OC.Settings.Apps.isType(app, 'logging')) {
+ element.parent().find("#groups_enable").hide();
+ element.parent().find("label[for='groups_enable']").hide();
+ } else {
+ element.parent().find("#groups_enable").show();
+ element.parent().find("label[for='groups_enable']").show();
+ if (groups) {
+ appitem.data('groups', JSON.stringify(groups));
+ } else {
+ appitem.data('groups', '');
+ }
+ }
}
},'json')
.fail(function() {
@@ -145,7 +194,6 @@ OC.Settings.Apps = OC.Settings.Apps || {
}
},
updateApp:function(appid, element) {
- console.log('updateApp:', appid, element);
element.val(t('settings','Updating....'));
$.post(OC.filePath('settings','ajax','updateapp.php'),{appid:appid},function(result) {
if(!result || result.status !== 'success') {
@@ -238,12 +286,18 @@ OC.Settings.Apps = OC.Settings.Apps || {
showErrorMessage: function(message) {
$('.appinfo .warning').show();
$('.appinfo .warning').text(message);
+ },
+ isType: function(app, type){
+ return app.types && app.types.indexOf(type) !== -1;
}
};
$(document).ready(function(){
$('#app-navigation ul li').each(function(index,li){
var app = OC.get('appData_'+$(li).data('id'));
+ if (app) {
+ app.groups= $(li).data('groups') || [];
+ }
$(li).data('app',app);
$(this).find('span.hidden').remove();
});
@@ -281,6 +335,20 @@ $(document).ready(function(){
}
});
+ $('#group_select').change(function() {
+ var element = $('#app-content input.enable');
+ var groups = $(this).val();
+ var appid = element.data('appid');
+ if (appid) {
+ OC.Settings.Apps.enableApp(appid, false, element, groups);
+ var li = $('[data-id="'+appid+'"]');
+ var app = OC.get('appData_' + $(li).data('id'));
+ app.groups = groups;
+ li.data('groups', groups);
+ li.attr('data-groups', JSON.stringify(groups));
+ }
+ });
+
if(appid) {
var item = $('#app-navigation ul li[data-id="'+appid+'"]');
if(item) {
@@ -289,4 +357,16 @@ $(document).ready(function(){
$('#app-navigation').animate({scrollTop: $(item).offset().top-70}, 'slow','swing');
}
}
+
+ $("#groups_enable").change(function() {
+ if (this.checked) {
+ $("div.multiselect").parent().remove();
+ $('#group_select').multiSelect();
+ } else {
+ $('#group_select').hide().val(null);
+ $("div.multiselect").parent().remove();
+ }
+
+ $('#group_select').change();
+ });
});