aboutsummaryrefslogtreecommitdiffstats
path: root/settings/js
diff options
context:
space:
mode:
Diffstat (limited to 'settings/js')
-rw-r--r--settings/js/admin.js226
-rw-r--r--settings/js/apps.js632
-rw-r--r--settings/js/certificates.js70
-rw-r--r--settings/js/log.js80
-rw-r--r--settings/js/personal.js383
-rw-r--r--settings/js/settings.js94
-rw-r--r--settings/js/users/deleteHandler.js210
-rw-r--r--settings/js/users/filter.js78
-rw-r--r--settings/js/users/groups.js359
-rw-r--r--settings/js/users/users.js943
10 files changed, 0 insertions, 3075 deletions
diff --git a/settings/js/admin.js b/settings/js/admin.js
deleted file mode 100644
index 1bbb20efa00..00000000000
--- a/settings/js/admin.js
+++ /dev/null
@@ -1,226 +0,0 @@
-$(document).ready(function(){
- var params = OC.Util.History.parseUrlQuery();
-
- // Hack to add a trusted domain
- if (params.trustDomain) {
- OC.dialogs.confirm(t('settings', 'Are you really sure you want add "{domain}" as trusted domain?',
- {domain: params.trustDomain}),
- t('settings', 'Add trusted domain'), function(answer) {
- if(answer) {
- $.ajax({
- type: 'POST',
- url: OC.generateUrl('settings/admin/security/trustedDomains'),
- data: { newTrustedDomain: params.trustDomain }
- }).done(function() {
- window.location.replace(OC.generateUrl('settings/admin'));
- });
- }
- });
- }
-
-
- $('#excludedGroups').each(function (index, element) {
- OC.Settings.setupGroupsSelect($(element));
- $(element).change(function(ev) {
- var groups = ev.val || [];
- groups = JSON.stringify(groups);
- OC.AppConfig.setValue('core', $(this).attr('name'), groups);
- });
- });
-
-
- $('#loglevel').change(function(){
- $.post(OC.generateUrl('/settings/admin/log/level'), {level: $(this).val()},function(){
- OC.Log.reload();
- } );
- });
-
- $('#backgroundjobs span.crondate').tipsy({gravity: 's', live: true});
-
- $('#backgroundjobs input').change(function(){
- if($(this).attr('checked')){
- var mode = $(this).val();
- if (mode === 'ajax' || mode === 'webcron' || mode === 'cron') {
- OC.AppConfig.setValue('core', 'backgroundjobs_mode', mode);
- // clear cron errors on background job mode change
- OC.AppConfig.deleteKey('core', 'cronErrors');
- }
- }
- });
-
- $('#shareAPIEnabled').change(function() {
- $('#shareAPI p:not(#enable)').toggleClass('hidden', !this.checked);
- });
-
- $('#enableEncryption').change(function() {
- $('#encryptionAPI div#EncryptionWarning').toggleClass('hidden');
- });
-
- $('#reallyEnableEncryption').click(function() {
- $('#encryptionAPI div#EncryptionWarning').toggleClass('hidden');
- $('#encryptionAPI div#EncryptionSettingsArea').toggleClass('hidden');
- OC.AppConfig.setValue('core', 'encryption_enabled', 'yes');
- $('#enableEncryption').attr('disabled', 'disabled');
- });
-
- $('#startmigration').click(function(event){
- $(window).on('beforeunload.encryption', function(e) {
- return t('settings', 'Migration in progress. Please wait until the migration is finished');
- });
- event.preventDefault();
- $('#startmigration').prop('disabled', true);
- OC.msg.startAction('#startmigration_msg', t('settings', 'Migration started …'));
- $.post(OC.generateUrl('/settings/admin/startmigration'), '', function(data){
- OC.msg.finishedAction('#startmigration_msg', data);
- if (data['status'] === 'success') {
- $('#encryptionAPI div#selectEncryptionModules').toggleClass('hidden');
- $('#encryptionAPI div#migrationWarning').toggleClass('hidden');
- } else {
- $('#startmigration').prop('disabled', false);
- }
- $(window).off('beforeunload.encryption');
-
- });
- });
-
- $('#shareapiExpireAfterNDays').change(function() {
- var value = $(this).val();
- if (value <= 0) {
- $(this).val("1");
- }
- });
-
- $('#shareAPI input:not(#excludedGroups)').change(function() {
- var value = $(this).val();
- if ($(this).attr('type') === 'checkbox') {
- if (this.checked) {
- value = 'yes';
- } else {
- value = 'no';
- }
- }
- OC.AppConfig.setValue('core', $(this).attr('name'), value);
- });
-
- $('#shareapiDefaultExpireDate').change(function() {
- $("#setDefaultExpireDate").toggleClass('hidden', !this.checked);
- });
-
- $('#allowLinks').change(function() {
- $("#publicLinkSettings").toggleClass('hidden', !this.checked);
- $('#setDefaultExpireDate').toggleClass('hidden', !(this.checked && $('#shareapiDefaultExpireDate')[0].checked));
- });
-
- $('#mail_smtpauth').change(function() {
- if (!this.checked) {
- $('#mail_credentials').addClass('hidden');
- } else {
- $('#mail_credentials').removeClass('hidden');
- }
- });
-
- $('#mail_smtpmode').change(function() {
- if ($(this).val() !== 'smtp') {
- $('#setting_smtpauth').addClass('hidden');
- $('#setting_smtphost').addClass('hidden');
- $('#mail_smtpsecure_label').addClass('hidden');
- $('#mail_smtpsecure').addClass('hidden');
- $('#mail_credentials').addClass('hidden');
- } else {
- $('#setting_smtpauth').removeClass('hidden');
- $('#setting_smtphost').removeClass('hidden');
- $('#mail_smtpsecure_label').removeClass('hidden');
- $('#mail_smtpsecure').removeClass('hidden');
- if ($('#mail_smtpauth').attr('checked')) {
- $('#mail_credentials').removeClass('hidden');
- }
- }
- });
-
- $('#mail_general_settings_form').change(function(){
- OC.msg.startSaving('#mail_settings_msg');
- var post = $( "#mail_general_settings_form" ).serialize();
- $.post(OC.generateUrl('/settings/admin/mailsettings'), post, function(data){
- OC.msg.finishedSaving('#mail_settings_msg', data);
- });
- });
-
- $('#mail_credentials_settings_submit').click(function(){
- OC.msg.startSaving('#mail_settings_msg');
- var post = $( "#mail_credentials_settings" ).serialize();
- $.post(OC.generateUrl('/settings/admin/mailsettings/credentials'), post, function(data){
- OC.msg.finishedSaving('#mail_settings_msg', data);
- });
- });
-
- $('#sendtestemail').click(function(event){
- event.preventDefault();
- OC.msg.startAction('#sendtestmail_msg', t('settings', 'Sending...'));
- $.post(OC.generateUrl('/settings/admin/mailtest'), '', function(data){
- OC.msg.finishedAction('#sendtestmail_msg', data);
- });
- });
-
- $('#allowGroupSharing').change(function() {
- $('#allowGroupSharing').toggleClass('hidden', !this.checked);
- });
-
- $('#shareapiExcludeGroups').change(function() {
- $("#selectExcludedGroups").toggleClass('hidden', !this.checked);
- });
-
- // run setup checks then gather error messages
- $.when(
- OC.SetupChecks.checkWebDAV(),
- OC.SetupChecks.checkWellKnownUrl('/.well-known/caldav/', oc_defaults.docPlaceholderUrl, $('#postsetupchecks').data('check-wellknown') === 'true'),
- OC.SetupChecks.checkWellKnownUrl('/.well-known/carddav/', oc_defaults.docPlaceholderUrl, $('#postsetupchecks').data('check-wellknown') === 'true'),
- OC.SetupChecks.checkSetup(),
- OC.SetupChecks.checkGeneric(),
- OC.SetupChecks.checkDataProtected()
- ).then(function(check1, check2, check3, check4, check5, check6) {
- var messages = [].concat(check1, check2, check3, check4, check5, check6);
- var $el = $('#postsetupchecks');
- $el.find('.loading').addClass('hidden');
-
- var hasMessages = false;
- var $errorsEl = $el.find('.errors');
- var $warningsEl = $el.find('.warnings');
- var $infoEl = $el.find('.info');
-
- for (var i = 0; i < messages.length; i++ ) {
- switch(messages[i].type) {
- case OC.SetupChecks.MESSAGE_TYPE_INFO:
- $infoEl.append('<li>' + messages[i].msg + '</li>');
- break;
- case OC.SetupChecks.MESSAGE_TYPE_WARNING:
- $warningsEl.append('<li>' + messages[i].msg + '</li>');
- break;
- case OC.SetupChecks.MESSAGE_TYPE_ERROR:
- default:
- $errorsEl.append('<li>' + messages[i].msg + '</li>');
- }
- }
-
- if ($errorsEl.find('li').length > 0) {
- $errorsEl.removeClass('hidden');
- hasMessages = true;
- }
- if ($warningsEl.find('li').length > 0) {
- $warningsEl.removeClass('hidden');
- hasMessages = true;
- }
- if ($infoEl.find('li').length > 0) {
- $infoEl.removeClass('hidden');
- hasMessages = true;
- }
-
- if (hasMessages) {
- $el.find('.hint').removeClass('hidden');
- } else {
- var securityWarning = $('#security-warning');
- if (securityWarning.children('ul').children().length === 0) {
- $('#security-warning-state').find('span').removeClass('hidden');
- }
- }
- });
-});
diff --git a/settings/js/apps.js b/settings/js/apps.js
deleted file mode 100644
index e052a9ee9d3..00000000000
--- a/settings/js/apps.js
+++ /dev/null
@@ -1,632 +0,0 @@
-/* global Handlebars */
-
-Handlebars.registerHelper('score', function() {
- if(this.score) {
- var score = Math.round( this.score / 10 );
- var imageName = 'rating/s' + score + '.svg';
-
- return new Handlebars.SafeString('<img src="' + OC.imagePath('core', imageName) + '">');
- }
- return new Handlebars.SafeString('');
-});
-Handlebars.registerHelper('level', function() {
- if(typeof this.level !== 'undefined') {
- if(this.level === 200) {
- return new Handlebars.SafeString('<span class="official icon-checkmark">' + t('settings', 'Official') + '</span>');
- } else if(this.level === 100) {
- return new Handlebars.SafeString('<span class="approved">' + t('settings', 'Approved') + '</span>');
- } else {
- return new Handlebars.SafeString('<span class="experimental">' + t('settings', 'Experimental') + '</span>');
- }
- }
-});
-
-OC.Settings = OC.Settings || {};
-OC.Settings.Apps = OC.Settings.Apps || {
- setupGroupsSelect: function($elements) {
- OC.Settings.setupGroupsSelect($elements, {
- placeholder: t('core', 'All')
- });
- },
-
- State: {
- currentCategory: null,
- apps: null
- },
-
- loadCategories: function() {
- if (this._loadCategoriesCall) {
- this._loadCategoriesCall.abort();
- }
-
- var categories = [
- {displayName: t('settings', 'Enabled'), ident: 'enabled', id: '0'},
- {displayName: t('settings', 'Not enabled'), ident: 'disabled', id: '1'}
- ];
-
- var source = $("#categories-template").html();
- var template = Handlebars.compile(source);
- var html = template(categories);
- $('#apps-categories').html(html);
-
- OC.Settings.Apps.loadCategory($('#app-navigation').attr('data-category'));
-
- this._loadCategoriesCall = $.ajax(OC.generateUrl('settings/apps/categories'), {
- data:{},
- type:'GET',
- success:function (jsondata) {
- var html = template(jsondata);
- $('#apps-categories').html(html);
- $('#app-category-' + OC.Settings.Apps.State.currentCategory).addClass('active');
- },
- complete: function() {
- $('#app-navigation').removeClass('icon-loading');
- }
- });
-
- },
-
- loadCategory: function(categoryId) {
- if (OC.Settings.Apps.State.currentCategory === categoryId) {
- return;
- }
- if (this._loadCategoryCall) {
- this._loadCategoryCall.abort();
- }
- $('#apps-list')
- .addClass('icon-loading')
- .removeClass('hidden')
- .html('');
- $('#apps-list-empty').addClass('hidden');
- $('#app-category-' + OC.Settings.Apps.State.currentCategory).removeClass('active');
- $('#app-category-' + categoryId).addClass('active');
- OC.Settings.Apps.State.currentCategory = categoryId;
-
- this._loadCategoryCall = $.ajax(OC.generateUrl('settings/apps/list?category={categoryId}&includeUpdateInfo=0', {
- categoryId: categoryId
- }), {
- type:'GET',
- success: function (apps) {
- var appListWithIndex = _.indexBy(apps.apps, 'id');
- OC.Settings.Apps.State.apps = appListWithIndex;
- var appList = _.map(appListWithIndex, function(app) {
- // default values for missing fields
- return _.extend({level: 0}, app);
- });
- var source = $("#app-template").html();
- var template = Handlebars.compile(source);
-
- if (appList.length) {
- appList.sort(function(a,b) {
- var levelDiff = b.level - a.level;
- if (levelDiff === 0) {
- return OC.Util.naturalSortCompare(a.name, b.name);
- }
- return levelDiff;
- });
-
- var firstExperimental = false;
- _.each(appList, function(app) {
- if(app.level === 0 && firstExperimental === false) {
- firstExperimental = true;
- OC.Settings.Apps.renderApp(app, template, null, true);
- } else {
- OC.Settings.Apps.renderApp(app, template, null, false);
- }
- });
- } else {
- $('#apps-list').addClass('hidden');
- $('#apps-list-empty').removeClass('hidden').find('h2').text(t('settings', 'No apps found for your version'));
- }
-
- $('.app-level .official').tipsy({fallback: t('settings', 'Official apps are developed by and within the ownCloud community. They offer functionality central to ownCloud and are ready for production use.')});
- $('.app-level .approved').tipsy({fallback: t('settings', 'Approved apps are developed by trusted developers and have passed a cursory security check. They are actively maintained in an open code repository and their maintainers deem them to be stable for casual to normal use.')});
- $('.app-level .experimental').tipsy({fallback: t('settings', 'This app is not checked for security issues and is new or known to be unstable. Install at your own risk.')});
- },
- complete: function() {
- var availableUpdates = 0;
- $('#apps-list').removeClass('icon-loading');
- $.ajax(OC.generateUrl('settings/apps/list?category={categoryId}&includeUpdateInfo=1', {
- categoryId: categoryId
- }), {
- type: 'GET',
- success: function (apps) {
- _.each(apps.apps, function(app) {
- if (app.update) {
- var $update = $('#app-' + app.id + ' .update');
- $update.removeClass('hidden');
- $update.val(t('settings', 'Update to %s').replace(/%s/g, app.update));
- availableUpdates++;
- OC.Settings.Apps.State.apps[app.id].update = true;
- }
- });
-
- if (availableUpdates > 0) {
- OC.Notification.show(n('settings', 'You have %n app update pending', 'You have %n app updates pending', availableUpdates));
- }
- }
- });
- }
- });
- },
-
- renderApp: function(app, template, selector, firstExperimental) {
- if (!template) {
- var source = $("#app-template").html();
- template = Handlebars.compile(source);
- }
- if (typeof app === 'string') {
- app = OC.Settings.Apps.State.apps[app];
- }
- app.firstExperimental = firstExperimental;
-
- if (!app.preview) {
- app.preview = OC.imagePath('core', 'default-app-icon');
- app.previewAsIcon = true;
- }
-
- var html = template(app);
- if (selector) {
- selector.html(html);
- } else {
- $('#apps-list').append(html);
- }
-
- var page = $('#app-' + app.id);
-
- // image loading kung-fu (IE doesn't properly scale SVGs, so disable app icons)
- if (app.preview && !OC.Util.isIE()) {
- var currentImage = new Image();
- currentImage.src = app.preview;
-
- currentImage.onload = function() {
- page.find('.app-image')
- .append(this)
- .fadeIn();
- };
- }
-
- // set group select properly
- 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') ||
- OC.Settings.Apps.isType(app, 'prevent_group_restriction')) {
- page.find(".groups-enable").hide();
- page.find(".groups-enable__checkbox").attr('checked', null);
- } else {
- page.find('#group_select').val((app.groups || []).join('|'));
- if (app.active) {
- if (app.groups.length) {
- OC.Settings.Apps.setupGroupsSelect(page.find('#group_select'));
- page.find(".groups-enable__checkbox").attr('checked','checked');
- } else {
- page.find(".groups-enable__checkbox").attr('checked', null);
- }
- page.find(".groups-enable").show();
- } else {
- page.find(".groups-enable").hide();
- }
- }
- },
-
- isType: function(app, type){
- return app.types && app.types.indexOf(type) !== -1;
- },
-
- /**
- * Checks the server health.
- *
- * If the promise fails, the server is broken.
- *
- * @return {Promise} promise
- */
- _checkServerHealth: function() {
- return $.get(OC.generateUrl('apps/files'));
- },
-
- enableApp:function(appId, active, element, groups) {
- var self = this;
- OC.Settings.Apps.hideErrorMessage(appId);
- groups = groups || [];
- var appItem = $('div#app-'+appId+'');
- element.val(t('settings','Please wait....'));
- 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) {
- OC.Settings.Apps.showErrorMessage(appId, result.data.message);
- appItem.data('errormsg', result.data.message);
- } else {
- OC.Settings.Apps.showErrorMessage(appId, t('settings', 'Error while disabling app'));
- appItem.data('errormsg', t('settings', 'Error while disabling app'));
- }
- element.val(t('settings','Disable'));
- appItem.addClass('appwarning');
- } else {
- OC.Settings.Apps.rebuildNavigation();
- appItem.data('active',false);
- appItem.data('groups', '');
- element.data('active',false);
- appItem.removeClass('active');
- element.val(t('settings','Enable'));
- element.parent().find(".groups-enable").hide();
- element.parent().find('#group_select').hide().val(null);
- OC.Settings.Apps.State.apps[appId].active = false;
- }
- },'json');
- } else {
- // TODO: display message to admin to not refresh the page!
- // TODO: lock UI to prevent further operations
- $.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(appId, result.data.message);
- appItem.data('errormsg', result.data.message);
- } else {
- OC.Settings.Apps.showErrorMessage(appId, t('settings', 'Error while enabling app'));
- appItem.data('errormsg', t('settings', 'Error while disabling app'));
- }
- element.val(t('settings','Enable'));
- appItem.addClass('appwarning');
- } else {
- self._checkServerHealth().done(function() {
- if (result.data.update_required) {
- OC.Settings.Apps.showReloadMessage();
-
- setTimeout(function() {
- location.reload();
- }, 5000);
- }
-
- OC.Settings.Apps.rebuildNavigation();
- appItem.data('active',true);
- element.data('active',true);
- appItem.addClass('active');
- element.val(t('settings','Disable'));
- var app = OC.Settings.Apps.State.apps[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").attr('checked', null);
- element.parent().find(".groups-enable").hide();
- element.parent().find('#group_select').hide().val(null);
- } else {
- element.parent().find("#groups-enable").show();
- if (groups) {
- appItem.data('groups', JSON.stringify(groups));
- } else {
- appItem.data('groups', '');
- }
- }
- }).fail(function() {
- // server borked, emergency disable app
- $.post(OC.webroot + '/index.php/disableapp', {appid: appId}, function() {
- OC.Settings.Apps.showErrorMessage(
- appId,
- t('settings', 'Error: this app cannot be enabled because it makes the server unstable')
- );
- appItem.data('errormsg', t('settings', 'Error while enabling app'));
- element.val(t('settings','Enable'));
- appItem.addClass('appwarning');
- }).fail(function() {
- OC.Settings.Apps.showErrorMessage(
- appId,
- t('settings', 'Error: could not disable broken app')
- );
- appItem.data('errormsg', t('settings', 'Error while disabling broken app'));
- element.val(t('settings','Enable'));
- });
- });
- }
- },'json')
- .fail(function() {
- OC.Settings.Apps.showErrorMessage(appId, t('settings', 'Error while enabling app'));
- appItem.data('errormsg', t('settings', 'Error while enabling app'));
- appItem.data('active',false);
- appItem.addClass('appwarning');
- element.val(t('settings','Enable'));
- });
- }
- },
-
- updateApp:function(appId, element) {
- var oldButtonText = element.val();
- element.val(t('settings','Updating....'));
- OC.Settings.Apps.hideErrorMessage(appId);
- $.post(OC.filePath('settings','ajax','updateapp.php'),{appid:appId},function(result) {
- if(!result || result.status !== 'success') {
- if (result.data && result.data.message) {
- OC.Settings.Apps.showErrorMessage(appId, result.data.message);
- } else {
- OC.Settings.Apps.showErrorMessage(appId, t('settings','Error while updating app'));
- }
- element.val(oldButtonText);
- }
- else {
- element.val(t('settings','Updated'));
- element.hide();
- }
- },'json');
- },
-
- uninstallApp:function(appId, element) {
- OC.Settings.Apps.hideErrorMessage(appId);
- element.val(t('settings','Uninstalling ....'));
- $.post(OC.filePath('settings','ajax','uninstallapp.php'),{appid:appId},function(result) {
- if(!result || result.status !== 'success') {
- OC.Settings.Apps.showErrorMessage(appId, t('settings','Error while uninstalling app'));
- element.val(t('settings','Uninstall'));
- } else {
- OC.Settings.Apps.rebuildNavigation();
- element.parent().fadeOut(function() {
- element.remove();
- });
- }
- },'json');
- },
-
- rebuildNavigation: function() {
- $.getJSON(OC.filePath('settings', 'ajax', 'navigationdetect.php')).done(function(response){
- if(response.status === 'success'){
- var idsToKeep = {};
- var navEntries=response.nav_entries;
- var container = $('#apps ul');
- for(var i=0; i< navEntries.length; i++){
- var entry = navEntries[i];
- idsToKeep[entry.id] = true;
-
- if(container.children('li[data-id="'+entry.id+'"]').length === 0){
- var li=$('<li></li>');
- li.attr('data-id', entry.id);
- var img= $('<img class="app-icon"/>').attr({ src: entry.icon});
- var a=$('<a></a>').attr('href', entry.href);
- var filename=$('<span></span>');
- var loading = $('<div class="icon-loading-dark"></div>').css('display', 'none');
- filename.text(entry.name);
- a.prepend(filename);
- a.prepend(loading);
- a.prepend(img);
- li.append(a);
-
- // append the new app as last item in the list
- // 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
- $('#navigation').animate({
- scrollTop: $('#navigation').height()
- }, 'slow');
-
- // draw attention to the newly added app entry
- // by flashing it twice
- $('#header .menutoggle')
- .animate({opacity: 0.5})
- .animate({opacity: 1})
- .animate({opacity: 0.5})
- .animate({opacity: 1})
- .animate({opacity: 0.75});
-
- if (!OC.Util.hasSVGSupport() && entry.icon.match(/\.svg$/i)) {
- $(img).addClass('svg');
- OC.Util.replaceSVG();
- }
- }
- }
-
- container.children('li[data-id]').each(function(index, el) {
- if (!idsToKeep[$(el).data('id')]) {
- $(el).remove();
- }
- });
- }
- });
- },
-
- showErrorMessage: function(appId, message) {
- $('div#app-'+appId+' .warning')
- .show()
- .text(message);
- },
-
- hideErrorMessage: function(appId) {
- $('div#app-'+appId+' .warning')
- .hide()
- .text('');
- },
-
- showReloadMessage: function() {
- OC.dialogs.info(
- t(
- 'settings',
- 'The app has been enabled but needs to be updated. You will be redirected to the update page in 5 seconds.'
- ),
- t('settings','App update'),
- function () {
- window.location.reload();
- },
- true
- );
- },
-
- filter: function(query) {
- var $appList = $('#apps-list'),
- $emptyList = $('#apps-list-empty');
- $appList.removeClass('hidden');
- $appList.find('.section').removeClass('hidden');
- $emptyList.addClass('hidden');
-
- if (query === '') {
- return;
- }
-
- query = query.toLowerCase();
- $appList.find('.section').addClass('hidden');
-
- // App Name
- var apps = _.filter(OC.Settings.Apps.State.apps, function (app) {
- return app.name.toLowerCase().indexOf(query) !== -1;
- });
-
- // App ID
- apps = apps.concat(_.filter(OC.Settings.Apps.State.apps, function (app) {
- return app.id.toLowerCase().indexOf(query) !== -1;
- }));
-
- // App Description
- apps = apps.concat(_.filter(OC.Settings.Apps.State.apps, function (app) {
- return app.description.toLowerCase().indexOf(query) !== -1;
- }));
-
- // Author Name
- apps = apps.concat(_.filter(OC.Settings.Apps.State.apps, function (app) {
- return app.author.toLowerCase().indexOf(query) !== -1;
- }));
-
- // App status
- if (t('settings', 'Official').toLowerCase().indexOf(query) !== -1) {
- apps = apps.concat(_.filter(OC.Settings.Apps.State.apps, function (app) {
- return app.level === 200;
- }));
- }
- if (t('settings', 'Approved').toLowerCase().indexOf(query) !== -1) {
- apps = apps.concat(_.filter(OC.Settings.Apps.State.apps, function (app) {
- return app.level === 100;
- }));
- }
- if (t('settings', 'Experimental').toLowerCase().indexOf(query) !== -1) {
- apps = apps.concat(_.filter(OC.Settings.Apps.State.apps, function (app) {
- return app.level !== 100 && app.level !== 200;
- }));
- }
-
- apps = _.uniq(apps, function(app){return app.id;});
-
- if (apps.length === 0) {
- $appList.addClass('hidden');
- $emptyList.removeClass('hidden');
- $emptyList.removeClass('hidden').find('h2').text(t('settings', 'No apps found for {query}', {
- query: query
- }));
- } else {
- _.each(apps, function (app) {
- $('#app-' + app.id).removeClass('hidden');
- });
-
- $('#searchresults').hide();
- }
- },
-
- _onPopState: function(params) {
- params = _.extend({
- category: 'enabled'
- }, params);
-
- OC.Settings.Apps.loadCategory(params.category);
- },
-
- /**
- * Initializes the apps list
- */
- initialize: function($el) {
- OC.Plugins.register('OCA.Search', OC.Settings.Apps.Search);
- OC.Settings.Apps.loadCategories();
- OC.Util.History.addOnPopStateHandler(_.bind(this._onPopState, this));
-
- $(document).on('click', 'ul#apps-categories li', function () {
- var categoryId = $(this).data('categoryId');
- OC.Settings.Apps.loadCategory(categoryId);
- OC.Util.History.pushState({
- category: categoryId
- });
- $('#searchbox').val('');
- });
-
- $(document).on('click', '.app-description-toggle-show', function () {
- $(this).addClass('hidden');
- $(this).siblings('.app-description-toggle-hide').removeClass('hidden');
- $(this).siblings('.app-description-container').slideDown();
- });
- $(document).on('click', '.app-description-toggle-hide', function () {
- $(this).addClass('hidden');
- $(this).siblings('.app-description-toggle-show').removeClass('hidden');
- $(this).siblings('.app-description-container').slideUp();
- });
-
- $(document).on('click', '#apps-list input.enable', function () {
- var appId = $(this).data('appid');
- var element = $(this);
- var active = $(this).data('active');
-
- OC.Settings.Apps.enableApp(appId, active, element);
- });
-
- $(document).on('click', '#apps-list input.uninstall', function () {
- var appId = $(this).data('appid');
- var element = $(this);
-
- OC.Settings.Apps.uninstallApp(appId, element);
- });
-
- $(document).on('click', '#apps-list input.update', function () {
- var appId = $(this).data('appid');
- var element = $(this);
-
- OC.Settings.Apps.updateApp(appId, element);
- });
-
- $(document).on('change', '#group_select', function() {
- var element = $(this).parent().find('input.enable');
- var groups = $(this).val();
- if (groups && groups !== '') {
- groups = groups.split('|');
- } else {
- groups = [];
- }
-
- var appId = element.data('appid');
- if (appId) {
- OC.Settings.Apps.enableApp(appId, false, element, groups);
- OC.Settings.Apps.State.apps[appId].groups = groups;
- }
- });
-
- $(document).on('change', ".groups-enable__checkbox", function() {
- var $select = $(this).closest('.section').find('#group_select');
- $select.val('');
-
- if (this.checked) {
- OC.Settings.Apps.setupGroupsSelect($select);
- } else {
- $select.select2('destroy');
- }
-
- $select.change();
- });
-
- $(document).on('click', '#enable-experimental-apps', function () {
- var state = $(this).prop('checked');
- $.ajax(OC.generateUrl('settings/apps/experimental'), {
- data: {state: state},
- type: 'POST',
- success:function () {
- location.reload();
- }
- });
- });
- }
-};
-
-OC.Settings.Apps.Search = {
- attach: function (search) {
- search.setFilter('settings', OC.Settings.Apps.filter);
- }
-};
-
-$(document).ready(function () {
- // HACK: FIXME: use plugin approach
- if (!window.TESTING) {
- OC.Settings.Apps.initialize($('#apps-list'));
- }
-});
diff --git a/settings/js/certificates.js b/settings/js/certificates.js
deleted file mode 100644
index f2a8e6b0afb..00000000000
--- a/settings/js/certificates.js
+++ /dev/null
@@ -1,70 +0,0 @@
-$(document).ready(function () {
- var type = $('#sslCertificate').data('type');
- $('#sslCertificate').on('click', 'td.remove', function () {
- var row = $(this).parent();
- $.ajax(OC.generateUrl('settings/' + type + '/certificate/{certificate}', {certificate: row.data('name')}), {
- type: 'DELETE'
- });
- row.remove();
-
- if ($('#sslCertificate > tbody > tr').length === 0) {
- $('#sslCertificate').hide();
- }
- return true;
- });
-
- $('#sslCertificate tr > td').tipsy({gravity: 'n', live: true});
-
- $('#rootcert_import').fileupload({
- pasteZone: null,
- submit: function (e, data) {
- data.formData = _.extend(data.formData || {}, {
- requesttoken: OC.requestToken
- });
- },
- success: function (data) {
- if (typeof data === 'string') {
- data = $.parseJSON(data);
- } else if (data && data.length) {
- // fetch response from iframe
- data = $.parseJSON(data[0].body.innerText);
- }
- if (!data || typeof(data) === 'string') {
- // IE8 iframe workaround comes here instead of fail()
- OC.Notification.showTemporary(
- t('settings', 'An error occurred. Please upload an ASCII-encoded PEM certificate.'));
- return;
- }
- var issueDate = new Date(data.validFrom * 1000);
- var expireDate = new Date(data.validTill * 1000);
- var now = new Date();
- var isExpired = !(issueDate <= now && now <= expireDate);
-
- var row = $('<tr/>');
- row.data('name', data.name);
- row.addClass(isExpired ? 'expired' : 'valid');
- row.append($('<td/>').attr('title', data.organization).text(data.commonName));
- row.append($('<td/>').attr('title', t('core,', 'Valid until {date}', {date: data.validTillString}))
- .text(data.validTillString));
- row.append($('<td/>').attr('title', data.issuerOrganization).text(data.issuer));
- row.append($('<td/>').addClass('remove').append(
- $('<img/>').attr({
- alt: t('core', 'Delete'),
- title: t('core', 'Delete'),
- src: OC.imagePath('core', 'actions/delete.svg')
- }).addClass('action')
- ));
-
- $('#sslCertificate tbody').append(row);
- $('#sslCertificate').show();
- },
- fail: function () {
- OC.Notification.showTemporary(
- t('settings', 'An error occurred. Please upload an ASCII-encoded PEM certificate.'));
- }
- });
-
- if ($('#sslCertificate > tbody > tr').length === 0) {
- $('#sslCertificate').hide();
- }
-});
diff --git a/settings/js/log.js b/settings/js/log.js
deleted file mode 100644
index 43ef561f7ee..00000000000
--- a/settings/js/log.js
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- * Copyright (c) 2012, Robin Appelman <icewind1991@gmail.com>
- * Copyright (c) 2013, Morris Jobke <morris.jobke@gmail.com>
- * This file is licensed under the Affero General Public License version 3 or later.
- * See the COPYING-README file.
- */
-
-/* global formatDate */
-
-OC.Log = {
- reload: function (count) {
- if (!count) {
- count = OC.Log.loaded;
- }
- OC.Log.loaded = 0;
- $('#log tbody').empty();
- OC.Log.getMore(count);
- },
- levels: ['Debug', 'Info', 'Warning', 'Error', 'Fatal'],
- loaded: 3,//are initially loaded
- getMore: function (count) {
- count = count || 10;
- $.get(OC.generateUrl('/settings/admin/log/entries'), {offset: OC.Log.loaded, count: count}, function (result) {
- OC.Log.addEntries(result.data);
- if (!result.remain) {
- $('#moreLog').hide();
- }
- $('#lessLog').show();
- });
- },
- showLess: function (count) {
- count = count || 10;
- //calculate remaining items - at least 3
- OC.Log.loaded = Math.max(3, OC.Log.loaded - count);
- $('#moreLog').show();
- // remove all non-remaining items
- $('#log tr').slice(OC.Log.loaded).remove();
- if (OC.Log.loaded <= 3) {
- $('#lessLog').hide();
- }
- },
- addEntries: function (entries) {
- for (var i = 0; i < entries.length; i++) {
- var entry = entries[i];
- var row = $('<tr/>');
- var levelTd = $('<td/>');
- levelTd.text(OC.Log.levels[entry.level]);
- row.append(levelTd);
-
- var appTd = $('<td/>');
- appTd.text(entry.app);
- row.append(appTd);
-
- var messageTd = $('<td/>');
- messageTd.addClass('log-message');
- messageTd.text(entry.message);
- row.append(messageTd);
-
- var timeTd = $('<td/>');
- timeTd.addClass('date');
- if (isNaN(entry.time)) {
- timeTd.text(entry.time);
- } else {
- timeTd.text(formatDate(entry.time * 1000));
- }
- row.append(timeTd);
- $('#log').append(row);
- }
- OC.Log.loaded += entries.length;
- }
-};
-
-$(document).ready(function () {
- $('#moreLog').click(function () {
- OC.Log.getMore();
- });
- $('#lessLog').click(function () {
- OC.Log.showLess();
- });
-});
diff --git a/settings/js/personal.js b/settings/js/personal.js
deleted file mode 100644
index bd13b7fd251..00000000000
--- a/settings/js/personal.js
+++ /dev/null
@@ -1,383 +0,0 @@
-/**
- * Copyright (c) 2011, Robin Appelman <icewind1991@gmail.com>
- * 2013, Morris Jobke <morris.jobke@gmail.com>
- * This file is licensed under the Affero General Public License version 3 or later.
- * See the COPYING-README file.
- */
-
-/**
- * The callback will be fired as soon as enter is pressed by the
- * user or 1 second after the last data entry
- *
- * @param callback
- * @param allowEmptyValue if this is set to true the callback is also called when the value is empty
- */
-jQuery.fn.keyUpDelayedOrEnter = function (callback, allowEmptyValue) {
- var cb = callback;
- var that = this;
- this.keyup(_.debounce(function (event) {
- // enter is already handled in keypress
- if (event.keyCode === 13) {
- return;
- }
- if (allowEmptyValue || that.val() !== '') {
- cb();
- }
- }, 1000));
-
- this.keypress(function (event) {
- if (event.keyCode === 13 && (allowEmptyValue || that.val() !== '')) {
- event.preventDefault();
- cb();
- }
- });
-
- this.bind('paste', null, function (e) {
- if(!e.keyCode){
- if (allowEmptyValue || that.val() !== '') {
- cb();
- }
- }
- });
-};
-
-
-/**
- * Post the email address change to the server.
- */
-function changeEmailAddress () {
- var emailInfo = $('#email');
- if (emailInfo.val() === emailInfo.defaultValue) {
- return;
- }
- emailInfo.defaultValue = emailInfo.val();
- OC.msg.startSaving('#lostpassword .msg');
- var post = $("#lostpassword").serializeArray();
- $.ajax({
- type: 'PUT',
- url: OC.generateUrl('/settings/users/{id}/mailAddress', {id: OC.currentUser}),
- data: {
- mailAddress: post[0].value
- }
- }).done(function(result){
- // I know the following 4 lines look weird, but that is how it works
- // in jQuery - for success the first parameter is the result
- // for failure the first parameter is the result object
- OC.msg.finishedSaving('#lostpassword .msg', result);
- }).fail(function(result){
- OC.msg.finishedSaving('#lostpassword .msg', result.responseJSON);
- });
-}
-
-/**
- * Post the display name change to the server.
- */
-function changeDisplayName () {
- if ($('#displayName').val() !== '') {
- OC.msg.startSaving('#displaynameform .msg');
- // Serialize the data
- var post = $("#displaynameform").serialize();
- // Ajax foo
- $.post(OC.generateUrl('/settings/users/{id}/displayName', {id: OC.currentUser}), post, function (data) {
- if (data.status === "success") {
- $('#oldDisplayName').val($('#displayName').val());
- // update displayName on the top right expand button
- $('#expandDisplayName').text($('#displayName').val());
- // update avatar if avatar is available
- if(!$('#removeavatar').hasClass('hidden')) {
- updateAvatar();
- }
- }
- else {
- $('#newdisplayname').val(data.data.displayName);
- }
- OC.msg.finishedSaving('#displaynameform .msg', data);
- });
- }
-}
-
-function updateAvatar (hidedefault) {
- var $headerdiv = $('#header .avatardiv');
- var $displaydiv = $('#displayavatar .avatardiv');
-
- if (hidedefault) {
- $headerdiv.hide();
- $('#header .avatardiv').removeClass('avatardiv-shown');
- } else {
- $headerdiv.css({'background-color': ''});
- $headerdiv.avatar(OC.currentUser, 32, true);
- $('#header .avatardiv').addClass('avatardiv-shown');
- }
- $displaydiv.css({'background-color': ''});
- $displaydiv.avatar(OC.currentUser, 145, true);
-
- $('#removeavatar').removeClass('hidden').addClass('inlineblock');
-}
-
-function showAvatarCropper () {
- var $cropper = $('#cropper');
- $cropper.prepend("<img>");
- var $cropperImage = $('#cropper img');
-
- $cropperImage.attr('src',
- OC.generateUrl('/avatar/tmp') + '?requesttoken=' + encodeURIComponent(oc_requesttoken) + '#' + Math.floor(Math.random() * 1000));
-
- // Looks weird, but on('load', ...) doesn't work in IE8
- $cropperImage.ready(function () {
- $('#displayavatar').hide();
- $cropper.show();
-
- $cropperImage.Jcrop({
- onChange: saveCoords,
- onSelect: saveCoords,
- aspectRatio: 1,
- boxHeight: 500,
- boxWidth: 500,
- setSelect: [0, 0, 300, 300]
- });
- });
-}
-
-function sendCropData () {
- cleanCropper();
-
- var cropperData = $('#cropper').data();
- var data = {
- x: cropperData.x,
- y: cropperData.y,
- w: cropperData.w,
- h: cropperData.h
- };
- $.post(OC.generateUrl('/avatar/cropped'), {crop: data}, avatarResponseHandler);
-}
-
-function saveCoords (c) {
- $('#cropper').data(c);
-}
-
-function cleanCropper () {
- var $cropper = $('#cropper');
- $('#displayavatar').show();
- $cropper.hide();
- $('.jcrop-holder').remove();
- $('#cropper img').removeData('Jcrop').removeAttr('style').removeAttr('src');
- $('#cropper img').remove();
-}
-
-function avatarResponseHandler (data) {
- if (typeof data === 'string') {
- data = $.parseJSON(data);
- }
- var $warning = $('#avatar .warning');
- $warning.hide();
- if (data.status === "success") {
- updateAvatar();
- } else if (data.data === "notsquare") {
- showAvatarCropper();
- } else {
- $warning.show();
- $warning.text(data.data.message);
- }
-}
-
-$(document).ready(function () {
- if($('#pass2').length) {
- $('#pass2').showPassword().keyup();
- }
- $("#passwordbutton").click(function () {
- var isIE8or9 = $('html').hasClass('lte9');
- // FIXME - TODO - once support for IE8 and IE9 is dropped
- // for IE8 and IE9 this will check additionally if the typed in password
- // is different from the placeholder, because in IE8/9 the placeholder
- // is simply set as the value to look like a placeholder
- if ($('#pass1').val() !== '' && $('#pass2').val() !== ''
- && !(isIE8or9 && $('#pass2').val() === $('#pass2').attr('placeholder'))) {
- // Serialize the data
- var post = $("#passwordform").serialize();
- $('#passwordchanged').hide();
- $('#passworderror').hide();
- // Ajax foo
- $.post(OC.generateUrl('/settings/personal/changepassword'), post, function (data) {
- if (data.status === "success") {
- $('#pass1').val('');
- $('#pass2').val('').change();
- // Hide a possible errormsg and show successmsg
- $('#password-changed').removeClass('hidden').addClass('inlineblock');
- $('#password-error').removeClass('inlineblock').addClass('hidden');
- } else {
- if (typeof(data.data) !== "undefined") {
- $('#password-error').text(data.data.message);
- } else {
- $('#password-error').text(t('Unable to change password'));
- }
- // Hide a possible successmsg and show errormsg
- $('#password-changed').removeClass('inlineblock').addClass('hidden');
- $('#password-error').removeClass('hidden').addClass('inlineblock');
- }
- });
- return false;
- } else {
- // Hide a possible successmsg and show errormsg
- $('#password-changed').removeClass('inlineblock').addClass('hidden');
- $('#password-error').removeClass('hidden').addClass('inlineblock');
- return false;
- }
-
- });
-
- $('#displayName').keyUpDelayedOrEnter(changeDisplayName);
- $('#email').keyUpDelayedOrEnter(changeEmailAddress, true);
-
- $("#languageinput").change(function () {
- // Serialize the data
- var post = $("#languageinput").serialize();
- // Ajax foo
- $.post('ajax/setlanguage.php', post, function (data) {
- if (data.status === "success") {
- location.reload();
- }
- else {
- $('#passworderror').text(data.data.message);
- }
- });
- return false;
- });
-
- var uploadparms = {
- pasteZone: null,
- done: function (e, data) {
- var response = data;
- if (typeof data.result === 'string') {
- response = $.parseJSON(data.result);
- } else if (data.result && data.result.length) {
- // fetch response from iframe
- response = $.parseJSON(data.result[0].body.innerText);
- } else {
- response = data.result;
- }
- avatarResponseHandler(response);
- },
- submit: function(e, data) {
- data.formData = _.extend(data.formData || {}, {
- requesttoken: OC.requestToken
- });
- },
- fail: function (e, data){
- var msg = data.jqXHR.statusText + ' (' + data.jqXHR.status + ')';
- if (!_.isUndefined(data.jqXHR.responseJSON) &&
- !_.isUndefined(data.jqXHR.responseJSON.data) &&
- !_.isUndefined(data.jqXHR.responseJSON.data.message)
- ) {
- msg = data.jqXHR.responseJSON.data.message;
- }
- avatarResponseHandler({
- data: {
- message: t('settings', 'An error occurred: {message}', { message: msg })
- }
- });
- }
- };
-
- $('#uploadavatar').fileupload(uploadparms);
-
- $('#selectavatar').click(function () {
- OC.dialogs.filepicker(
- t('settings', "Select a profile picture"),
- function (path) {
- $.ajax({
- type: "POST",
- url: OC.generateUrl('/avatar/'),
- data: { path: path }
- }).done(avatarResponseHandler)
- .fail(function(jqXHR, status){
- var msg = jqXHR.statusText + ' (' + jqXHR.status + ')';
- if (!_.isUndefined(jqXHR.responseJSON) &&
- !_.isUndefined(jqXHR.responseJSON.data) &&
- !_.isUndefined(jqXHR.responseJSON.data.message)
- ) {
- msg = jqXHR.responseJSON.data.message;
- }
- avatarResponseHandler({
- data: {
- message: t('settings', 'An error occurred: {message}', { message: msg })
- }
- });
- });
- },
- false,
- ["image/png", "image/jpeg"]
- );
- });
-
- $('#removeavatar').click(function () {
- $.ajax({
- type: 'DELETE',
- url: OC.generateUrl('/avatar/'),
- success: function () {
- updateAvatar(true);
- $('#removeavatar').addClass('hidden').removeClass('inlineblock');
- }
- });
- });
-
- $('#abortcropperbutton').click(function () {
- cleanCropper();
- });
-
- $('#sendcropperbutton').click(function () {
- sendCropData();
- });
-
- $('#pass2').strengthify({
- zxcvbn: OC.linkTo('core','vendor/zxcvbn/zxcvbn.js'),
- titles: [
- t('core', 'Very weak password'),
- t('core', 'Weak password'),
- t('core', 'So-so password'),
- t('core', 'Good password'),
- t('core', 'Strong password')
- ]
- });
-
- // does the user have a custom avatar? if he does show #removeavatar
- $.get(OC.generateUrl(
- '/avatar/{user}/{size}',
- {user: OC.currentUser, size: 1}
- ), function (result) {
- if (typeof(result) === 'string') {
- // Show the delete button when the avatar is custom
- $('#removeavatar').removeClass('hidden').addClass('inlineblock');
- }
- });
-
- // Load the big avatar
- if (oc_config.enable_avatars) {
- $('#avatar .avatardiv').avatar(OC.currentUser, 145);
- }
-});
-
-if (!OC.Encryption) {
- OC.Encryption = {};
-}
-
-OC.Encryption.msg = {
- start: function (selector, msg) {
- var spinner = '<img src="' + OC.imagePath('core', 'loading-small.gif') + '">';
- $(selector)
- .html(msg + ' ' + spinner)
- .removeClass('success')
- .removeClass('error')
- .stop(true, true)
- .show();
- },
- finished: function (selector, data) {
- if (data.status === "success") {
- $(selector).html(data.data.message)
- .addClass('success')
- .stop(true, true)
- .delay(3000);
- } else {
- $(selector).html(data.data.message).addClass('error');
- }
- }
-};
diff --git a/settings/js/settings.js b/settings/js/settings.js
deleted file mode 100644
index fcbe328b76f..00000000000
--- a/settings/js/settings.js
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * Copyright (c) 2014, Vincent Petry <pvince81@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or later.
- * See the COPYING-README file.
- */
-OC.Settings = OC.Settings || {};
-OC.Settings = _.extend(OC.Settings, {
-
- _cachedGroups: null,
-
- /**
- * Setup selection box for group selection.
- *
- * Values need to be separated by a pipe "|" character.
- * (mostly because a comma is more likely to be used
- * for groups)
- *
- * @param $elements jQuery element (hidden input) to setup select2 on
- * @param [extraOptions] extra options hash to pass to select2
- */
- setupGroupsSelect: function($elements, extraOptions) {
- var self = this;
- if ($elements.length > 0) {
- // note: settings are saved through a "change" event registered
- // on all input fields
- $elements.select2(_.extend({
- placeholder: t('core', 'Groups'),
- allowClear: true,
- multiple: true,
- separator: '|',
- query: _.debounce(function(query) {
- var queryData = {};
- if (self._cachedGroups && query.term === '') {
- query.callback({results: self._cachedGroups});
- return;
- }
- if (query.term !== '') {
- queryData = {
- pattern: query.term,
- filterGroups: 1
- };
- }
- $.ajax({
- url: OC.generateUrl('/settings/users/groups'),
- data: queryData,
- dataType: 'json',
- success: function(data) {
- var results = [];
-
- // add groups
- $.each(data.data.adminGroups, function(i, group) {
- results.push({id:group.id, displayname:group.name});
- });
- $.each(data.data.groups, function(i, group) {
- results.push({id:group.id, displayname:group.name});
- });
-
- if (query.term === '') {
- // cache full list
- self._cachedGroups = results;
- }
- query.callback({results: results});
- }
- });
- }, 100, true),
- id: function(element) {
- return element.id;
- },
- initSelection: function(element, callback) {
- var selection =
- _.map(($(element).val() || []).split('|').sort(),
- function(groupName) {
- return {
- id: groupName,
- displayname: groupName
- };
- });
- callback(selection);
- },
- formatResult: function (element) {
- return escapeHTML(element.displayname);
- },
- formatSelection: function (element) {
- return escapeHTML(element.displayname);
- },
- escapeMarkup: function(m) {
- // prevent double markup escape
- return m;
- }
- }, extraOptions || {}));
- }
- }
-});
-
diff --git a/settings/js/users/deleteHandler.js b/settings/js/users/deleteHandler.js
deleted file mode 100644
index b684aff1889..00000000000
--- a/settings/js/users/deleteHandler.js
+++ /dev/null
@@ -1,210 +0,0 @@
-/**
- * Copyright (c) 2014, Arthur Schiwon <blizzz@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or later.
- * See the COPYING-README file.
- */
-
-/**
- * takes care of deleting things represented by an ID
- *
- * @class
- * @param {string} endpoint the corresponding ajax PHP script. Currently limited
- * to settings - ajax path.
- * @param {string} paramID the by the script expected parameter name holding the
- * ID of the object to delete
- * @param {markCallback} markCallback function to be called after successfully
- * marking the object for deletion.
- * @param {removeCallback} removeCallback the function to be called after
- * successful delete.
- */
-function DeleteHandler(endpoint, paramID, markCallback, removeCallback) {
- this.oidToDelete = false;
- this.canceled = false;
-
- this.ajaxEndpoint = endpoint;
- this.ajaxParamID = paramID;
-
- this.markCallback = markCallback;
- this.removeCallback = removeCallback;
- this.undoCallback = false;
-
- this.notifier = false;
- this.notificationDataID = false;
- this.notificationMessage = false;
- this.notificationPlaceholder = '%oid';
-}
-
-/**
- * Number of milliseconds after which the operation is performed.
- */
-DeleteHandler.TIMEOUT_MS = 7000;
-
-/**
- * Timer after which the action will be performed anyway.
- */
-DeleteHandler.prototype._timeout = null;
-
-/**
- * The function to be called after successfully marking the object for deletion
- * @callback markCallback
- * @param {string} oid the ID of the specific user or group
- */
-
-/**
- * The function to be called after successful delete. The id of the object will
- * be passed as argument. Unsuccessful operations will display an error using
- * OC.dialogs, no callback is fired.
- * @callback removeCallback
- * @param {string} oid the ID of the specific user or group
- */
-
-/**
- * This callback is fired after "undo" was clicked so the consumer can update
- * the web interface
- * @callback undoCallback
- * @param {string} oid the ID of the specific user or group
- */
-
-/**
- * enabled the notification system. Required for undo UI.
- *
- * @param {object} notifier Usually OC.Notification
- * @param {string} dataID an identifier for the notifier, e.g. 'deleteuser'
- * @param {string} message the message that should be shown upon delete. %oid
- * will be replaced with the affected id of the item to be deleted
- * @param {undoCallback} undoCallback called after "undo" was clicked
- */
-DeleteHandler.prototype.setNotification = function(notifier, dataID, message, undoCallback) {
- this.notifier = notifier;
- this.notificationDataID = dataID;
- this.notificationMessage = message;
- this.undoCallback = undoCallback;
-
- var dh = this;
-
- $('#notification')
- .off('click.deleteHandler_' + dataID)
- .on('click.deleteHandler_' + dataID, '.undo', function () {
- if ($('#notification').data(dh.notificationDataID)) {
- var oid = dh.oidToDelete;
- dh.cancel();
- if(typeof dh.undoCallback !== 'undefined') {
- dh.undoCallback(oid);
- }
- }
- dh.notifier.hide();
- });
-};
-
-/**
- * shows the Undo Notification (if configured)
- */
-DeleteHandler.prototype.showNotification = function() {
- if(this.notifier !== false) {
- if(!this.notifier.isHidden()) {
- this.hideNotification();
- }
- $('#notification').data(this.notificationDataID, true);
- var msg = this.notificationMessage.replace(
- this.notificationPlaceholder, escapeHTML(this.oidToDelete));
- this.notifier.showHtml(msg);
- }
-};
-
-/**
- * hides the Undo Notification
- */
-DeleteHandler.prototype.hideNotification = function() {
- if(this.notifier !== false) {
- $('#notification').removeData(this.notificationDataID);
- this.notifier.hide();
- }
-};
-
-/**
- * initializes the delete operation for a given object id
- *
- * @param {string} oid the object id
- */
-DeleteHandler.prototype.mark = function(oid) {
- if(this.oidToDelete !== false) {
- // passing true to avoid hiding the notification
- // twice and causing the second notification
- // to disappear immediately
- this.deleteEntry(true);
- }
- this.oidToDelete = oid;
- this.canceled = false;
- this.markCallback(oid);
- this.showNotification();
- if (this._timeout) {
- clearTimeout(this._timeout);
- this._timeout = null;
- }
- if (DeleteHandler.TIMEOUT_MS > 0) {
- this._timeout = window.setTimeout(
- _.bind(this.deleteEntry, this),
- DeleteHandler.TIMEOUT_MS
- );
- }
-};
-
-/**
- * cancels a delete operation
- */
-DeleteHandler.prototype.cancel = function() {
- if (this._timeout) {
- clearTimeout(this._timeout);
- this._timeout = null;
- }
-
- this.canceled = true;
- this.oidToDelete = false;
-};
-
-/**
- * executes a delete operation. Requires that the operation has been
- * initialized by mark(). On error, it will show a message via
- * OC.dialogs.alert. On success, a callback is fired so that the client can
- * update the web interface accordingly.
- *
- * @param {boolean} [keepNotification] true to keep the notification, false to hide
- * it, defaults to false
- */
-DeleteHandler.prototype.deleteEntry = function(keepNotification) {
- var deferred = $.Deferred();
- if(this.canceled || this.oidToDelete === false) {
- return deferred.resolve().promise();
- }
-
- var dh = this;
- if(!keepNotification && $('#notification').data(this.notificationDataID) === true) {
- dh.hideNotification();
- }
-
- if (this._timeout) {
- clearTimeout(this._timeout);
- this._timeout = null;
- }
-
- var payload = {};
- payload[dh.ajaxParamID] = dh.oidToDelete;
- return $.ajax({
- type: 'DELETE',
- url: OC.generateUrl(dh.ajaxEndpoint+'/'+this.oidToDelete),
- // FIXME: do not use synchronous ajax calls as they block the browser !
- async: false,
- success: function (result) {
- // Remove undo option, & remove user from table
-
- //TODO: following line
- dh.removeCallback(dh.oidToDelete);
- dh.canceled = true;
- },
- error: function (jqXHR) {
- OC.dialogs.alert(jqXHR.responseJSON.data.message, t('settings', 'Unable to delete {objName}', {objName: dh.oidToDelete}));
- dh.undoCallback(dh.oidToDelete);
-
- }
- });
-};
diff --git a/settings/js/users/filter.js b/settings/js/users/filter.js
deleted file mode 100644
index 339d6ad5ec7..00000000000
--- a/settings/js/users/filter.js
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- * Copyright (c) 2014, Arthur Schiwon <blizzz@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or later.
- * See the COPYING-README file.
- */
-
-/**
- * @brief this object takes care of the filter functionality on the user
- * management page
- * @param {UserList} userList the UserList object
- * @param {GroupList} groupList the GroupList object
- */
-function UserManagementFilter (userList, groupList) {
- this.userList = userList;
- this.groupList = groupList;
- this.oldFilter = '';
-
- this.init();
-}
-
-/**
- * @brief sets up when the filter action shall be triggered
- */
-UserManagementFilter.prototype.init = function () {
- OC.Plugins.register('OCA.Search', this);
-};
-
-/**
- * @brief the filter action needs to be done, here the accurate steps are being
- * taken care of
- */
-UserManagementFilter.prototype.run = _.debounce(function (filter) {
- if (filter === this.oldFilter) {
- return;
- }
- this.oldFilter = filter;
- this.userList.filter = filter;
- this.userList.empty();
- this.userList.update(GroupList.getCurrentGID());
- if (this.groupList.filterGroups) {
- // user counts are being updated nevertheless
- this.groupList.empty();
- }
- this.groupList.update();
- },
- 300
-);
-
-/**
- * @brief returns the filter String
- * @returns string
- */
-UserManagementFilter.prototype.getPattern = function () {
- var input = this.filterInput.val(),
- html = $('html'),
- isIE8or9 = html.hasClass('lte9');
- // FIXME - TODO - once support for IE8 and IE9 is dropped
- if (isIE8or9 && input == this.filterInput.attr('placeholder')) {
- input = '';
- }
- return input;
-};
-
-/**
- * @brief adds reset functionality to an HTML element
- * @param jQuery the jQuery representation of that element
- */
-UserManagementFilter.prototype.addResetButton = function (button) {
- var umf = this;
- button.click(function () {
- umf.filterInput.val('');
- umf.run();
- });
-};
-
-UserManagementFilter.prototype.attach = function (search) {
- search.setFilter('settings', this.run.bind(this));
-};
diff --git a/settings/js/users/groups.js b/settings/js/users/groups.js
deleted file mode 100644
index 27c41884504..00000000000
--- a/settings/js/users/groups.js
+++ /dev/null
@@ -1,359 +0,0 @@
-/**
- * Copyright (c) 2014, Raghu Nayyar <beingminimal@gmail.com>
- * Copyright (c) 2014, Arthur Schiwon <blizzz@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or later.
- * See the COPYING-README file.
- */
-
-var $userGroupList,
- $sortGroupBy;
-
-var GroupList;
-GroupList = {
- activeGID: '',
- everyoneGID: '_everyone',
- filter: '',
- filterGroups: false,
-
- addGroup: function (gid, usercount) {
- var $li = $userGroupList.find('.isgroup:last-child').clone();
- $li
- .data('gid', gid)
- .find('.groupname').text(gid);
- GroupList.setUserCount($li, usercount);
-
- $li.appendTo($userGroupList);
-
- GroupList.sortGroups();
-
- return $li;
- },
-
- setUserCount: function (groupLiElement, usercount) {
- if ($sortGroupBy !== 1) {
- // If we don't sort by group count we dont display them either
- return;
- }
-
- var $groupLiElement = $(groupLiElement);
- if (usercount === undefined || usercount === 0 || usercount < 0) {
- usercount = '';
- $groupLiElement.data('usercount', 0);
- } else {
- $groupLiElement.data('usercount', usercount);
- }
- $groupLiElement.find('.usercount').text(usercount);
- },
-
- getUserCount: function ($groupLiElement) {
- return parseInt($groupLiElement.data('usercount'), 10);
- },
-
- modGroupCount: function(gid, diff) {
- var $li = GroupList.getGroupLI(gid);
- var count = GroupList.getUserCount($li) + diff;
- GroupList.setUserCount($li, count);
- },
-
- incEveryoneCount: function() {
- GroupList.modGroupCount(GroupList.everyoneGID, 1);
- },
-
- decEveryoneCount: function() {
- GroupList.modGroupCount(GroupList.everyoneGID, -1);
- },
-
- incGroupCount: function(gid) {
- GroupList.modGroupCount(gid, 1);
- },
-
- decGroupCount: function(gid) {
- GroupList.modGroupCount(gid, -1);
- },
-
- getCurrentGID: function () {
- return GroupList.activeGID;
- },
-
- sortGroups: function () {
- var lis = $userGroupList.find('.isgroup').get();
-
- lis.sort(function (a, b) {
- // "Everyone" always at the top
- if ($(a).data('gid') === '_everyone') {
- return -1;
- } else if ($(b).data('gid') === '_everyone') {
- return 1;
- }
-
- // "admin" always as second
- if ($(a).data('gid') === 'admin') {
- return -1;
- } else if ($(b).data('gid') === 'admin') {
- return 1;
- }
-
- if ($sortGroupBy === 1) {
- // Sort by user count first
- var $usersGroupA = $(a).data('usercount'),
- $usersGroupB = $(b).data('usercount');
- if ($usersGroupA > 0 && $usersGroupA > $usersGroupB) {
- return -1;
- }
- if ($usersGroupB > 0 && $usersGroupB > $usersGroupA) {
- return 1;
- }
- }
-
- // Fallback or sort by group name
- return UserList.alphanum(
- $(a).find('a span').text(),
- $(b).find('a span').text()
- );
- });
-
- var items = [];
- $.each(lis, function (index, li) {
- items.push(li);
- if (items.length === 100) {
- $userGroupList.append(items);
- items = [];
- }
- });
- if (items.length > 0) {
- $userGroupList.append(items);
- }
- },
-
- createGroup: function (groupname) {
- $.post(
- OC.generateUrl('/settings/users/groups'),
- {
- id: groupname
- },
- function (result) {
- if (result.groupname) {
- var addedGroup = result.groupname;
- UserList.availableGroups = $.unique($.merge(UserList.availableGroups, [addedGroup]));
- GroupList.addGroup(result.groupname);
-
- $('.groupsselect, .subadminsselect')
- .append($('<option>', { value: result.groupname })
- .text(result.groupname));
- }
- GroupList.toggleAddGroup();
- }).fail(function(result) {
- OC.Notification.showTemporary(t('settings', 'Error creating group: {message}', {message: result.responseJSON.message}));
- });
- },
-
- update: function () {
- if (GroupList.updating) {
- return;
- }
- GroupList.updating = true;
- $.get(
- OC.generateUrl('/settings/users/groups'),
- {
- pattern: this.filter,
- filterGroups: this.filterGroups ? 1 : 0,
- sortGroups: $sortGroupBy
- },
- function (result) {
-
- var lis = [];
- if (result.status === 'success') {
- $.each(result.data, function (i, subset) {
- $.each(subset, function (index, group) {
- if (GroupList.getGroupLI(group.name).length > 0) {
- GroupList.setUserCount(GroupList.getGroupLI(group.name).first(), group.usercount);
- }
- else {
- var $li = GroupList.addGroup(group.name, group.usercount);
-
- $li.addClass('appear transparent');
- lis.push($li);
- }
- });
- });
- if (result.data.length > 0) {
- GroupList.doSort();
- }
- else {
- GroupList.noMoreEntries = true;
- }
- _.defer(function () {
- $(lis).each(function () {
- this.removeClass('transparent');
- });
- });
- }
- GroupList.updating = false;
-
- }
- );
- },
-
- elementBelongsToAddGroup: function (el) {
- return !(el !== $('#newgroup-form').get(0) &&
- $('#newgroup-form').find($(el)).length === 0);
- },
-
- hasAddGroupNameText: function () {
- var name = $('#newgroupname').val();
- return $.trim(name) !== '';
-
- },
-
- showGroup: function (gid) {
- GroupList.activeGID = gid;
- UserList.empty();
- UserList.update(gid);
- $userGroupList.find('li').removeClass('active');
- if (gid !== undefined) {
- //TODO: treat Everyone properly
- GroupList.getGroupLI(gid).addClass('active');
- }
- },
-
- isAddGroupButtonVisible: function () {
- return $('#newgroup-init').is(":visible");
- },
-
- toggleAddGroup: function (event) {
- if (GroupList.isAddGroupButtonVisible()) {
- event.stopPropagation();
- $('#newgroup-form').show();
- $('#newgroup-init').hide();
- $('#newgroupname').focus();
- GroupList.handleAddGroupInput('');
- }
- else {
- $('#newgroup-form').hide();
- $('#newgroup-init').show();
- $('#newgroupname').val('');
- }
- },
-
- handleAddGroupInput: function (input) {
- if(input.length) {
- $('#newgroup-form input[type="submit"]').attr('disabled', null);
- } else {
- $('#newgroup-form input[type="submit"]').attr('disabled', 'disabled');
- }
- },
-
- isGroupNameValid: function (groupname) {
- if ($.trim(groupname) === '') {
- OC.Notification.showTemporary(t('settings', 'Error creating group: {message}', {
- message: t('settings', 'A valid group name must be provided')
- }));
- return false;
- }
- return true;
- },
-
- hide: function (gid) {
- GroupList.getGroupLI(gid).hide();
- },
- show: function (gid) {
- GroupList.getGroupLI(gid).show();
- },
- remove: function (gid) {
- GroupList.getGroupLI(gid).remove();
- },
- empty: function () {
- $userGroupList.find('.isgroup').filter(function(index, item){
- return $(item).data('gid') !== '';
- }).remove();
- },
- initDeleteHandling: function () {
- //set up handler
- GroupDeleteHandler = new DeleteHandler('/settings/users/groups', 'groupname',
- GroupList.hide, GroupList.remove);
-
- //configure undo
- OC.Notification.hide();
- var msg = escapeHTML(t('settings', 'deleted {groupName}', {groupName: '%oid'})) + '<span class="undo">' +
- escapeHTML(t('settings', 'undo')) + '</span>';
- GroupDeleteHandler.setNotification(OC.Notification, 'deletegroup', msg,
- GroupList.show);
-
- //when to mark user for delete
- $userGroupList.on('click', '.delete', function () {
- // Call function for handling delete/undo
- GroupDeleteHandler.mark(GroupList.getElementGID(this));
- });
-
- //delete a marked user when leaving the page
- $(window).on('beforeunload', function () {
- GroupDeleteHandler.deleteEntry();
- });
- },
-
- getGroupLI: function (gid) {
- return $userGroupList.find('li.isgroup').filter(function () {
- return GroupList.getElementGID(this) === gid;
- });
- },
-
- getElementGID: function (element) {
- return ($(element).closest('li').data('gid') || '').toString();
- },
- getEveryoneCount: function () {
- $.ajax({
- type: "GET",
- dataType: "json",
- url: OC.generateUrl('/settings/users/stats')
- }).success(function (data) {
- $('#everyonegroup').data('usercount', data.totalUsers);
- $('#everyonecount').text(data.totalUsers);
- });
- }
-};
-
-$(document).ready( function () {
- $userGroupList = $('#usergrouplist');
- GroupList.initDeleteHandling();
- $sortGroupBy = $userGroupList.data('sort-groups');
- if ($sortGroupBy === 1) {
- // Disabled due to performance issues, when we don't need it for sorting
- GroupList.getEveryoneCount();
- }
-
- // Display or hide of Create Group List Element
- $('#newgroup-form').hide();
- $('#newgroup-init').on('click', function (e) {
- GroupList.toggleAddGroup(e);
- });
-
- $(document).on('click keydown keyup', function(event) {
- if(!GroupList.isAddGroupButtonVisible() &&
- !GroupList.elementBelongsToAddGroup(event.target) &&
- !GroupList.hasAddGroupNameText()) {
- GroupList.toggleAddGroup();
- }
- // Escape
- if(!GroupList.isAddGroupButtonVisible() && event.keyCode && event.keyCode === 27) {
- GroupList.toggleAddGroup();
- }
- });
-
-
- // Responsible for Creating Groups.
- $('#newgroup-form form').submit(function (event) {
- event.preventDefault();
- if(GroupList.isGroupNameValid($('#newgroupname').val())) {
- GroupList.createGroup($('#newgroupname').val());
- }
- });
-
- // click on group name
- $userGroupList.on('click', '.isgroup', function () {
- GroupList.showGroup(GroupList.getElementGID(this));
- });
-
- $('#newgroupname').on('input', function(){
- GroupList.handleAddGroupInput(this.value);
- });
-});
diff --git a/settings/js/users/users.js b/settings/js/users/users.js
deleted file mode 100644
index 9706ac9fbcd..00000000000
--- a/settings/js/users/users.js
+++ /dev/null
@@ -1,943 +0,0 @@
-/**
- * Copyright (c) 2014, Arthur Schiwon <blizzz@owncloud.com>
- * Copyright (c) 2014, Raghu Nayyar <beingminimal@gmail.com>
- * Copyright (c) 2011, Robin Appelman <icewind1991@gmail.com>
- * This file is licensed under the Affero General Public License version 3 or later.
- * See the COPYING-README file.
- */
-
-var $userList;
-var $userListBody;
-
-var UserDeleteHandler;
-var UserList = {
- availableGroups: [],
- offset: 0,
- usersToLoad: 10, //So many users will be loaded when user scrolls down
- initialUsersToLoad: 250, //initial number of users to load
- currentGid: '',
- filter: '',
-
- /**
- * Initializes the user list
- * @param $el user list table element
- */
- initialize: function($el) {
- this.$el = $el;
-
- // initially the list might already contain user entries (not fully ajaxified yet)
- // initialize these entries
- this.$el.find('.quota-user').singleSelect().on('change', this.onQuotaSelect);
- },
-
- /**
- * Add a user row from user object
- *
- * @param user object containing following keys:
- * {
- * 'name': 'username',
- * 'displayname': 'Users display name',
- * 'groups': ['group1', 'group2'],
- * 'subadmin': ['group4', 'group5'],
- * 'quota': '10 GB',
- * 'storageLocation': '/srv/www/owncloud/data/username',
- * 'lastLogin': '1418632333'
- * 'backend': 'LDAP',
- * 'email': 'username@example.org'
- * 'isRestoreDisabled':false
- * }
- * @param sort
- * @returns table row created for this user
- */
- add: function (user, sort) {
- if (this.currentGid && this.currentGid !== '_everyone' && _.indexOf(user.groups, this.currentGid) < 0) {
- return;
- }
-
- var $tr = $userListBody.find('tr:first-child').clone();
- // this removes just the `display:none` of the template row
- $tr.removeAttr('style');
- var subAdminsEl;
- var subAdminSelect;
- var groupsSelect;
-
- /**
- * Avatar or placeholder
- */
- if ($tr.find('div.avatardiv').length) {
- if (user.isAvatarAvailable === true) {
- $('div.avatardiv', $tr).avatar(user.name, 32, undefined, undefined, undefined, user.displayname);
- } else {
- $('div.avatardiv', $tr).imageplaceholder(user.displayname, undefined, 32);
- }
- }
-
- /**
- * add username and displayname to row (in data and visible markup)
- */
- $tr.data('uid', user.name);
- $tr.data('displayname', user.displayname);
- $tr.data('mailAddress', user.email);
- $tr.data('restoreDisabled', user.isRestoreDisabled);
- $tr.find('.name').text(user.name);
- $tr.find('td.displayName > span').text(user.displayname);
- $tr.find('td.mailAddress > span').text(user.email);
- $tr.find('td.displayName > .action').tooltip({placement: 'top'});
- $tr.find('td.mailAddress > .action').tooltip({placement: 'top'});
- $tr.find('td.password > .action').tooltip({placement: 'top'});
-
- /**
- * groups and subadmins
- */
- // make them look like the multiselect buttons
- // until they get time to really get initialized
- groupsSelect = $('<select multiple="multiple" class="groupsselect multiselect button" data-placehoder="Groups" title="' + t('settings', 'no group') + '"></select>')
- .data('username', user.name)
- .data('user-groups', user.groups);
- if ($tr.find('td.subadmins').length > 0) {
- subAdminSelect = $('<select multiple="multiple" class="subadminsselect multiselect button" data-placehoder="subadmins" title="' + t('settings', 'no group') + '">')
- .data('username', user.name)
- .data('user-groups', user.groups)
- .data('subadmin', user.subadmin);
- $tr.find('td.subadmins').empty();
- }
- $.each(this.availableGroups, function (i, group) {
- groupsSelect.append($('<option value="' + escapeHTML(group) + '">' + escapeHTML(group) + '</option>'));
- if (typeof subAdminSelect !== 'undefined' && group !== 'admin') {
- subAdminSelect.append($('<option value="' + escapeHTML(group) + '">' + escapeHTML(group) + '</option>'));
- }
- });
- $tr.find('td.groups').empty().append(groupsSelect);
- subAdminsEl = $tr.find('td.subadmins');
- if (subAdminsEl.length > 0) {
- subAdminsEl.append(subAdminSelect);
- }
-
- /**
- * remove action
- */
- if ($tr.find('td.remove img').length === 0 && OC.currentUser !== user.name) {
- var deleteImage = $('<img class="svg action">').attr({
- src: OC.imagePath('core', 'actions/delete')
- });
- var deleteLink = $('<a class="action delete">')
- .attr({ href: '#', 'original-title': t('settings', 'Delete')})
- .append(deleteImage);
- $tr.find('td.remove').append(deleteLink);
- } else if (OC.currentUser === user.name) {
- $tr.find('td.remove a').remove();
- }
-
- /**
- * quota
- */
- var $quotaSelect = $tr.find('.quota-user');
- if (user.quota === 'default') {
- $quotaSelect
- .data('previous', 'default')
- .find('option').attr('selected', null)
- .first().attr('selected', 'selected');
- } else {
- if ($quotaSelect.find('option').filterAttr('value', user.quota).length > 0) {
- $quotaSelect.find('option').filterAttr('value', user.quota).attr('selected', 'selected');
- } else {
- $quotaSelect.append('<option value="' + escapeHTML(user.quota) + '" selected="selected">' + escapeHTML(user.quota) + '</option>');
- }
- }
-
- /**
- * storage location
- */
- $tr.find('td.storageLocation').text(user.storageLocation);
-
- /**
- * user backend
- */
- $tr.find('td.userBackend').text(user.backend);
-
- /**
- * last login
- */
- var lastLoginRel = t('settings', 'never');
- var lastLoginAbs = lastLoginRel;
- if(user.lastLogin !== 0) {
- lastLoginRel = OC.Util.relativeModifiedDate(user.lastLogin);
- lastLoginAbs = OC.Util.formatDate(user.lastLogin);
- }
- var $tdLastLogin = $tr.find('td.lastLogin');
- $tdLastLogin.text(lastLoginRel);
- $tdLastLogin.attr('title', lastLoginAbs);
- // setup tooltip with #app-content as container to prevent the td to resize on hover
- $tdLastLogin.tooltip({placement: 'top', container: '#app-content'});
-
- /**
- * append generated row to user list
- */
- $tr.appendTo($userList);
- if(UserList.isEmpty === true) {
- //when the list was emptied, one row was left, necessary to keep
- //add working and the layout unbroken. We need to remove this item
- $tr.show();
- $userListBody.find('tr:first').remove();
- UserList.isEmpty = false;
- UserList.checkUsersToLoad();
- }
-
- /**
- * sort list
- */
- if (sort) {
- UserList.doSort();
- }
-
- $quotaSelect.on('change', UserList.onQuotaSelect);
-
- // defer init so the user first sees the list appear more quickly
- window.setTimeout(function(){
- $quotaSelect.singleSelect();
- UserList.applyGroupSelect(groupsSelect);
- if (subAdminSelect) {
- UserList.applySubadminSelect(subAdminSelect);
- }
- }, 0);
- return $tr;
- },
- // From http://my.opera.com/GreyWyvern/blog/show.dml/1671288
- alphanum: function(a, b) {
- function chunkify(t) {
- var tz = [], x = 0, y = -1, n = 0, i, j;
-
- while (i = (j = t.charAt(x++)).charCodeAt(0)) {
- var m = (i === 46 || (i >=48 && i <= 57));
- if (m !== n) {
- tz[++y] = "";
- n = m;
- }
- tz[y] += j;
- }
- return tz;
- }
-
- var aa = chunkify(a.toLowerCase());
- var bb = chunkify(b.toLowerCase());
-
- for (var x = 0; aa[x] && bb[x]; x++) {
- if (aa[x] !== bb[x]) {
- var c = Number(aa[x]), d = Number(bb[x]);
- if (c === aa[x] && d === bb[x]) {
- return c - d;
- } else {
- return (aa[x] > bb[x]) ? 1 : -1;
- }
- }
- }
- return aa.length - bb.length;
- },
- preSortSearchString: function(a, b) {
- var pattern = this.filter;
- if(typeof pattern === 'undefined') {
- return undefined;
- }
- pattern = pattern.toLowerCase();
- var aMatches = false;
- var bMatches = false;
- if(typeof a === 'string' && a.toLowerCase().indexOf(pattern) === 0) {
- aMatches = true;
- }
- if(typeof b === 'string' && b.toLowerCase().indexOf(pattern) === 0) {
- bMatches = true;
- }
-
- if((aMatches && bMatches) || (!aMatches && !bMatches)) {
- return undefined;
- }
-
- if(aMatches) {
- return -1;
- } else {
- return 1;
- }
- },
- doSort: function() {
- // some browsers like Chrome lose the scrolling information
- // when messing with the list elements
- var lastScrollTop = this.scrollArea.scrollTop();
- var lastScrollLeft = this.scrollArea.scrollLeft();
- var rows = $userListBody.find('tr').get();
-
- rows.sort(function(a, b) {
- // FIXME: inefficient way of getting the names,
- // better use a data attribute
- a = $(a).find('.name').text();
- b = $(b).find('.name').text();
- var firstSort = UserList.preSortSearchString(a, b);
- if(typeof firstSort !== 'undefined') {
- return firstSort;
- }
- return OC.Util.naturalSortCompare(a, b);
- });
-
- var items = [];
- $.each(rows, function(index, row) {
- items.push(row);
- if(items.length === 100) {
- $userListBody.append(items);
- items = [];
- }
- });
- if(items.length > 0) {
- $userListBody.append(items);
- }
- this.scrollArea.scrollTop(lastScrollTop);
- this.scrollArea.scrollLeft(lastScrollLeft);
- },
- checkUsersToLoad: function() {
- //30 shall be loaded initially, from then on always 10 upon scrolling
- if(UserList.isEmpty === false) {
- UserList.usersToLoad = 10;
- } else {
- UserList.usersToLoad = UserList.initialUsersToLoad;
- }
- },
- empty: function() {
- //one row needs to be kept, because it is cloned to add new rows
- $userListBody.find('tr:not(:first)').remove();
- var $tr = $userListBody.find('tr:first');
- $tr.hide();
- //on an update a user may be missing when the username matches with that
- //of the hidden row. So change this to a random string.
- $tr.data('uid', Math.random().toString(36).substring(2));
- UserList.isEmpty = true;
- UserList.offset = 0;
- UserList.checkUsersToLoad();
- },
- hide: function(uid) {
- UserList.getRow(uid).hide();
- },
- show: function(uid) {
- UserList.getRow(uid).show();
- },
- markRemove: function(uid) {
- var $tr = UserList.getRow(uid);
- var groups = $tr.find('.groups .groupsselect').val();
- for(var i in groups) {
- var gid = groups[i];
- var $li = GroupList.getGroupLI(gid);
- var userCount = GroupList.getUserCount($li);
- GroupList.setUserCount($li, userCount - 1);
- }
- GroupList.decEveryoneCount();
- UserList.hide(uid);
- },
- remove: function(uid) {
- UserList.getRow(uid).remove();
- },
- undoRemove: function(uid) {
- var $tr = UserList.getRow(uid);
- var groups = $tr.find('.groups .groupsselect').val();
- for(var i in groups) {
- var gid = groups[i];
- var $li = GroupList.getGroupLI(gid);
- var userCount = GroupList.getUserCount($li);
- GroupList.setUserCount($li, userCount + 1);
- }
- GroupList.incEveryoneCount();
- UserList.getRow(uid).show();
- },
- has: function(uid) {
- return UserList.getRow(uid).length > 0;
- },
- getRow: function(uid) {
- return $userListBody.find('tr').filter(function(){
- return UserList.getUID(this) === uid;
- });
- },
- getUID: function(element) {
- return ($(element).closest('tr').data('uid') || '').toString();
- },
- getDisplayName: function(element) {
- return ($(element).closest('tr').data('displayname') || '').toString();
- },
- getMailAddress: function(element) {
- return ($(element).closest('tr').data('mailAddress') || '').toString();
- },
- getRestoreDisabled: function(element) {
- return ($(element).closest('tr').data('restoreDisabled') || '');
- },
- initDeleteHandling: function() {
- //set up handler
- UserDeleteHandler = new DeleteHandler('/settings/users/users', 'username',
- UserList.markRemove, UserList.remove);
-
- //configure undo
- OC.Notification.hide();
- var msg = escapeHTML(t('settings', 'deleted {userName}', {userName: '%oid'})) + '<span class="undo">' +
- escapeHTML(t('settings', 'undo')) + '</span>';
- UserDeleteHandler.setNotification(OC.Notification, 'deleteuser', msg,
- UserList.undoRemove);
-
- //when to mark user for delete
- $userListBody.on('click', '.delete', function () {
- // Call function for handling delete/undo
- var uid = UserList.getUID(this);
- UserDeleteHandler.mark(uid);
- });
-
- //delete a marked user when leaving the page
- $(window).on('beforeunload', function () {
- UserDeleteHandler.deleteEntry();
- });
- },
- update: function (gid, limit) {
- if (UserList.updating) {
- return;
- }
- if(!limit) {
- limit = UserList.usersToLoad;
- }
- $userList.siblings('.loading').css('visibility', 'visible');
- UserList.updating = true;
- if(gid === undefined) {
- gid = '';
- }
- UserList.currentGid = gid;
- var pattern = this.filter;
- $.get(
- OC.generateUrl('/settings/users/users'),
- { offset: UserList.offset, limit: limit, gid: gid, pattern: pattern },
- function (result) {
- var loadedUsers = 0;
- var trs = [];
- //The offset does not mirror the amount of users available,
- //because it is backend-dependent. For correct retrieval,
- //always the limit(requested amount of users) needs to be added.
- $.each(result, function (index, user) {
- if(UserList.has(user.name)) {
- return true;
- }
- var $tr = UserList.add(user, user.lastLogin, false, user.backend);
- trs.push($tr);
- loadedUsers++;
- });
- if (result.length > 0) {
- UserList.doSort();
- $userList.siblings('.loading').css('visibility', 'hidden');
- // reset state on load
- UserList.noMoreEntries = false;
- }
- else {
- UserList.noMoreEntries = true;
- $userList.siblings('.loading').remove();
- }
- UserList.offset += limit;
- }).always(function() {
- UserList.updating = false;
- });
- },
-
- applyGroupSelect: function (element) {
- var checked = [];
- var $element = $(element);
- var user = UserList.getUID($element);
-
- if ($element.data('user-groups')) {
- if (typeof $element.data('user-groups') === 'string') {
- checked = $element.data('user-groups').split(", ");
- }
- else {
- checked = $element.data('user-groups');
- }
- }
- var checkHandler = null;
- if(user) { // Only if in a user row, and not the #newusergroups select
- checkHandler = function (group) {
- if (user === OC.currentUser && group === 'admin') {
- return false;
- }
- if (!oc_isadmin && checked.length === 1 && checked[0] === group) {
- return false;
- }
- $.post(
- OC.filePath('settings', 'ajax', 'togglegroups.php'),
- {
- username: user,
- group: group
- },
- function (response) {
- if (response.status === 'success') {
- GroupList.update();
- var groupName = response.data.groupname;
- if (UserList.availableGroups.indexOf(groupName) === -1 &&
- response.data.action === 'add'
- ) {
- UserList.availableGroups.push(groupName);
- }
-
- if (response.data.action === 'add') {
- GroupList.incGroupCount(groupName);
- } else {
- GroupList.decGroupCount(groupName);
- }
- }
- if (response.data.message) {
- OC.Notification.show(response.data.message);
- }
- }
- );
- };
- }
- var addGroup = function (select, group) {
- $('select[multiple]').each(function (index, element) {
- $element = $(element);
- if ($element.find('option').filterAttr('value', group).length === 0 &&
- select.data('msid') !== $element.data('msid')) {
- $element.append('<option value="' + escapeHTML(group) + '">' + escapeHTML(group) + '</option>');
- }
- });
- GroupList.addGroup(escapeHTML(group));
- };
- var label;
- if (oc_isadmin) {
- label = t('settings', 'add group');
- }
- else {
- label = null;
- }
- $element.multiSelect({
- createCallback: addGroup,
- createText: label,
- selectedFirst: true,
- checked: checked,
- oncheck: checkHandler,
- onuncheck: checkHandler,
- minWidth: 100
- });
- },
-
- applySubadminSelect: function (element) {
- var checked = [];
- var $element = $(element);
- var user = UserList.getUID($element);
-
- if ($element.data('subadmin')) {
- if (typeof $element.data('subadmin') === 'string') {
- checked = $element.data('subadmin').split(", ");
- }
- else {
- checked = $element.data('subadmin');
- }
- }
- var checkHandler = function (group) {
- if (group === 'admin') {
- return false;
- }
- $.post(
- OC.filePath('settings', 'ajax', 'togglesubadmins.php'),
- {
- username: user,
- group: group
- },
- function () {
- }
- );
- };
-
- var addSubAdmin = function (group) {
- $('select[multiple]').each(function (index, element) {
- if ($(element).find('option').filterAttr('value', group).length === 0) {
- $(element).append('<option value="' + escapeHTML(group) + '">' + escapeHTML(group) + '</option>');
- }
- });
- };
- $element.multiSelect({
- createCallback: addSubAdmin,
- createText: null,
- checked: checked,
- oncheck: checkHandler,
- onuncheck: checkHandler,
- minWidth: 100
- });
- },
-
- _onScroll: function() {
- if (!!UserList.noMoreEntries) {
- return;
- }
- if (UserList.scrollArea.scrollTop() + UserList.scrollArea.height() > UserList.scrollArea.get(0).scrollHeight - 500) {
- UserList.update(UserList.currentGid);
- }
- },
-
- /**
- * Event handler for when a quota has been changed through a single select.
- * This will save the value.
- */
- onQuotaSelect: function(ev) {
- var $select = $(ev.target);
- var uid = UserList.getUID($select);
- var quota = $select.val();
- UserList._updateQuota(uid, quota, function(returnedQuota){
- if (quota !== returnedQuota) {
- $select.find(':selected').text(returnedQuota);
- }
- });
- },
-
- /**
- * Saves the quota for the given user
- * @param {String} [uid] optional user id, sets default quota if empty
- * @param {String} quota quota value
- * @param {Function} ready callback after save
- */
- _updateQuota: function(uid, quota, ready) {
- $.post(
- OC.filePath('settings', 'ajax', 'setquota.php'),
- {username: uid, quota: quota},
- function (result) {
- if (ready) {
- ready(result.data.quota);
- }
- }
- );
- }
-};
-
-$(document).ready(function () {
- $userList = $('#userlist');
- $userListBody = $userList.find('tbody');
-
- UserList.initDeleteHandling();
-
- // Implements User Search
- OCA.Search.users= new UserManagementFilter(UserList, GroupList);
-
- UserList.scrollArea = $('#app-content');
-
- UserList.doSort();
- UserList.availableGroups = $userList.data('groups');
-
- UserList.scrollArea.scroll(function(e) {UserList._onScroll(e);});
-
- $userList.after($('<div class="loading" style="height: 200px; visibility: hidden;"></div>'));
-
- // TODO: move other init calls inside of initialize
- UserList.initialize($('#userlist'));
-
- $('.groupsselect').each(function (index, element) {
- UserList.applyGroupSelect(element);
- });
- $('.subadminsselect').each(function (index, element) {
- UserList.applySubadminSelect(element);
- });
-
- $userListBody.on('click', '.password', function (event) {
- event.stopPropagation();
-
- var $td = $(this).closest('td');
- var $tr = $(this).closest('tr');
- var uid = UserList.getUID($td);
- var $input = $('<input type="password">');
- var isRestoreDisabled = UserList.getRestoreDisabled($td) === true;
- if(isRestoreDisabled) {
- $tr.addClass('row-warning');
- // add tipsy if the password change could cause data loss - no recovery enabled
- $input.tipsy({gravity:'s'});
- $input.attr('title', t('settings', 'Changing the password will result in data loss, because data recovery is not available for this user'));
- }
- $td.find('img').hide();
- $td.children('span').replaceWith($input);
- $input
- .focus()
- .keypress(function (event) {
- if (event.keyCode === 13) {
- if ($(this).val().length > 0) {
- var recoveryPasswordVal = $('input:password[id="recoveryPassword"]').val();
- $.post(
- OC.generateUrl('/settings/users/changepassword'),
- {username: uid, password: $(this).val(), recoveryPassword: recoveryPasswordVal},
- function (result) {
- if (result.status != 'success') {
- OC.Notification.showTemporary(t('admin', result.data.message));
- }
- }
- );
- $input.blur();
- } else {
- $input.blur();
- }
- }
- })
- .blur(function () {
- $(this).replaceWith($('<span>●●●●●●●</span>'));
- $td.find('img').show();
- // remove highlight class from users without recovery ability
- $tr.removeClass('row-warning');
- });
- });
- $('input:password[id="recoveryPassword"]').keyup(function() {
- OC.Notification.hide();
- });
-
- $userListBody.on('click', '.displayName', function (event) {
- event.stopPropagation();
- var $td = $(this).closest('td');
- var $tr = $td.closest('tr');
- var uid = UserList.getUID($td);
- var displayName = escapeHTML(UserList.getDisplayName($td));
- var $input = $('<input type="text" value="' + displayName + '">');
- $td.find('img').hide();
- $td.children('span').replaceWith($input);
- $input
- .focus()
- .keypress(function (event) {
- if (event.keyCode === 13) {
- if ($(this).val().length > 0) {
- var $div = $tr.find('div.avatardiv');
- if ($div.length) {
- $div.imageplaceholder(uid, displayName);
- }
- $.post(
- OC.generateUrl('/settings/users/{id}/displayName', {id: uid}),
- {username: uid, displayName: $(this).val()},
- function (result) {
- if (result && result.status==='success' && $div.length){
- $div.avatar(result.data.username, 32);
- }
- }
- );
- var displayName = $input.val();
- $tr.data('displayname', displayName);
- $input.blur();
- } else {
- $input.blur();
- }
- }
- })
- .blur(function () {
- var displayName = $tr.data('displayname');
- $input.replaceWith('<span>' + escapeHTML(displayName) + '</span>');
- $td.find('img').show();
- });
- });
-
- $userListBody.on('click', '.mailAddress', function (event) {
- event.stopPropagation();
- var $td = $(this).closest('td');
- var $tr = $td.closest('tr');
- var uid = UserList.getUID($td);
- var mailAddress = escapeHTML(UserList.getMailAddress($td));
- var $input = $('<input type="text">').val(mailAddress);
- $td.children('span').replaceWith($input);
- $td.find('img').hide();
- $input
- .focus()
- .keypress(function (event) {
- if (event.keyCode === 13) {
- // enter key
-
- var mailAddress = $input.val();
- $td.find('.loading-small').css('display', 'inline-block');
- $input.css('padding-right', '26px');
- $input.attr('disabled', 'disabled');
- $.ajax({
- type: 'PUT',
- url: OC.generateUrl('/settings/users/{id}/mailAddress', {id: uid}),
- data: {
- mailAddress: $(this).val()
- }
- }).success(function () {
- // set data attribute to new value
- // will in blur() be used to show the text instead of the input field
- $tr.data('mailAddress', mailAddress);
- $td.find('.loading-small').css('display', '');
- $input.removeAttr('disabled')
- .triggerHandler('blur'); // needed instead of $input.blur() for Firefox
- }).fail(function (result) {
- OC.Notification.showTemporary(result.responseJSON.data.message);
- $td.find('.loading-small').css('display', '');
- $input.removeAttr('disabled')
- .css('padding-right', '6px');
- });
- }
- })
- .blur(function () {
- if($td.find('.loading-small').css('display') === 'inline-block') {
- // in Chrome the blur event is fired too early by the browser - even if the request is still running
- return;
- }
- var $span = $('<span>').text($tr.data('mailAddress'));
- $input.replaceWith($span);
- $td.find('img').show();
- });
- });
-
- // init the quota field select box after it is shown the first time
- $('#app-settings').one('show', function() {
- $(this).find('#default_quota').singleSelect().on('change', UserList.onQuotaSelect);
- });
-
- $('#newuser').submit(function (event) {
- event.preventDefault();
- var username = $('#newusername').val();
- var password = $('#newuserpassword').val();
- var email = $('#newemail').val();
- if ($.trim(username) === '') {
- OC.Notification.showTemporary(t('settings', 'Error creating user: {message}', {
- message: t('settings', 'A valid username must be provided')
- }));
- return false;
- }
- if ($.trim(password) === '') {
- OC.Notification.showTemporary(t('settings', 'Error creating user: {message}', {
- message: t('settings', 'A valid password must be provided')
- }));
- return false;
- }
- if(!$('#CheckboxMailOnUserCreate').is(':checked')) {
- email = '';
- }
- if ($('#CheckboxMailOnUserCreate').is(':checked') && $.trim(email) === '') {
- OC.Notification.showTemporary( t('settings', 'Error creating user: {message}', {
- message: t('settings', 'A valid email must be provided')
- }));
- return false;
- }
-
- var promise;
- if (UserDeleteHandler) {
- promise = UserDeleteHandler.deleteEntry();
- } else {
- promise = $.Deferred().resolve().promise();
- }
-
- promise.then(function() {
- var groups = $('#newusergroups').val() || [];
- $.post(
- OC.generateUrl('/settings/users/users'),
- {
- username: username,
- password: password,
- groups: groups,
- email: email
- },
- function (result) {
- if (result.groups) {
- for (var i in result.groups) {
- var gid = result.groups[i];
- if(UserList.availableGroups.indexOf(gid) === -1) {
- UserList.availableGroups.push(gid);
- }
- $li = GroupList.getGroupLI(gid);
- userCount = GroupList.getUserCount($li);
- GroupList.setUserCount($li, userCount + 1);
- }
- }
- if(!UserList.has(username)) {
- UserList.add(result, true);
- }
- $('#newusername').focus();
- GroupList.incEveryoneCount();
- }).fail(function(result) {
- OC.Notification.showTemporary(t('settings', 'Error creating user: {message}', {
- message: result.responseJSON.message
- }));
- }).success(function(){
- $('#newuser').get(0).reset();
- });
- });
- });
-
- if ($('#CheckboxStorageLocation').is(':checked')) {
- $("#userlist .storageLocation").show();
- }
- // Option to display/hide the "Storage location" column
- $('#CheckboxStorageLocation').click(function() {
- if ($('#CheckboxStorageLocation').is(':checked')) {
- $("#userlist .storageLocation").show();
- OC.AppConfig.setValue('core', 'umgmt_show_storage_location', 'true');
- } else {
- $("#userlist .storageLocation").hide();
- OC.AppConfig.setValue('core', 'umgmt_show_storage_location', 'false');
- }
- });
-
- if ($('#CheckboxLastLogin').is(':checked')) {
- $("#userlist .lastLogin").show();
- }
- // Option to display/hide the "Last Login" column
- $('#CheckboxLastLogin').click(function() {
- if ($('#CheckboxLastLogin').is(':checked')) {
- $("#userlist .lastLogin").show();
- OC.AppConfig.setValue('core', 'umgmt_show_last_login', 'true');
- } else {
- $("#userlist .lastLogin").hide();
- OC.AppConfig.setValue('core', 'umgmt_show_last_login', 'false');
- }
- });
-
- if ($('#CheckboxEmailAddress').is(':checked')) {
- $("#userlist .mailAddress").show();
- }
- // Option to display/hide the "Mail Address" column
- $('#CheckboxEmailAddress').click(function() {
- if ($('#CheckboxEmailAddress').is(':checked')) {
- $("#userlist .mailAddress").show();
- OC.AppConfig.setValue('core', 'umgmt_show_email', 'true');
- } else {
- $("#userlist .mailAddress").hide();
- OC.AppConfig.setValue('core', 'umgmt_show_email', 'false');
- }
- });
-
- if ($('#CheckboxUserBackend').is(':checked')) {
- $("#userlist .userBackend").show();
- }
- // Option to display/hide the "User Backend" column
- $('#CheckboxUserBackend').click(function() {
- if ($('#CheckboxUserBackend').is(':checked')) {
- $("#userlist .userBackend").show();
- OC.AppConfig.setValue('core', 'umgmt_show_backend', 'true');
- } else {
- $("#userlist .userBackend").hide();
- OC.AppConfig.setValue('core', 'umgmt_show_backend', 'false');
- }
- });
-
- if ($('#CheckboxMailOnUserCreate').is(':checked')) {
- $("#newemail").show();
- }
- // Option to display/hide the "E-Mail" input field
- $('#CheckboxMailOnUserCreate').click(function() {
- if ($('#CheckboxMailOnUserCreate').is(':checked')) {
- $("#newemail").show();
- OC.AppConfig.setValue('core', 'umgmt_send_email', 'true');
- } else {
- $("#newemail").hide();
- OC.AppConfig.setValue('core', 'umgmt_send_email', 'false');
- }
- });
-
- // calculate initial limit of users to load
- var initialUserCountLimit = UserList.initialUsersToLoad,
- containerHeight = $('#app-content').height();
- if(containerHeight > 40) {
- initialUserCountLimit = Math.floor(containerHeight/40);
- if (initialUserCountLimit < UserList.initialUsersToLoad) {
- initialUserCountLimit = UserList.initialUsersToLoad;
- }
- }
- //realign initialUserCountLimit with usersToLoad as a safeguard
- while((initialUserCountLimit % UserList.usersToLoad) !== 0) {
- // must be a multiple of this, otherwise LDAP freaks out.
- // FIXME: solve this in LDAP backend in 8.1
- initialUserCountLimit = initialUserCountLimit + 1;
- }
-
- // trigger loading of users on startup
- UserList.update(UserList.currentGid, initialUserCountLimit);
-
- _.defer(function() {
- $('#app-content').trigger($.Event('apprendered'));
- });
-
-});