summaryrefslogtreecommitdiffstats
path: root/settings/js/apps.js
diff options
context:
space:
mode:
Diffstat (limited to 'settings/js/apps.js')
-rw-r--r--settings/js/apps.js108
1 files changed, 95 insertions, 13 deletions
diff --git a/settings/js/apps.js b/settings/js/apps.js
index a12131b0224..95e56485a6a 100644
--- a/settings/js/apps.js
+++ b/settings/js/apps.js
@@ -96,12 +96,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) {
@@ -116,14 +145,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);
@@ -140,6 +174,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() {
@@ -153,7 +202,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') {
@@ -204,7 +252,7 @@ OC.Settings.Apps = OC.Settings.Apps || {
if(response.status === 'success'){
var navIds=response.nav_ids;
for(var i=0; i< navIds.length; i++){
- $('#apps .wrapper').children('li[data-id="'+navIds[i]+'"]').remove();
+ $('#apps ul').children('li[data-id="'+navIds[i]+'"]').remove();
}
}
});
@@ -215,7 +263,7 @@ OC.Settings.Apps = OC.Settings.Apps || {
var navEntries=response.nav_entries;
for(var i=0; i< navEntries.length; i++){
var entry = navEntries[i];
- var container = $('#apps .wrapper');
+ var container = $('#apps ul');
if(container.children('li[data-id="'+entry.id+'"]').length === 0){
var li=$('<li></li>');
@@ -229,8 +277,9 @@ OC.Settings.Apps = OC.Settings.Apps || {
li.append(a);
// append the new app as last item in the list
- // (.push is from sticky footer)
- $('#apps .wrapper .push').before(li);
+ // which is the "add apps" entry with the id
+ // #apps-management
+ $('#apps-management').before(li);
// scroll the app navigation down
// so the newly added app is seen
@@ -240,11 +289,12 @@ OC.Settings.Apps = OC.Settings.Apps || {
// draw attention to the newly added app entry
// by flashing it twice
- container.children('li[data-id="' + entry.id + '"]')
- .animate({opacity: 0.3})
+ $('#header .menutoggle')
+ .animate({opacity: 0.5})
+ .animate({opacity: 1})
+ .animate({opacity: 0.5})
.animate({opacity: 1})
- .animate({opacity: 0.3})
- .animate({opacity: 1});
+ .animate({opacity: 0.75});
if (!SVGSupport() && entry.icon.match(/\.svg$/i)) {
$(img).addClass('svg');
@@ -258,12 +308,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();
});
@@ -308,6 +364,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) {
@@ -316,4 +386,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();
+ });
});