From 394d3eb0cd7448be3c7efc42c4012ecfdf99e654 Mon Sep 17 00:00:00 2001 From: Jesús Macias Date: Thu, 12 Nov 2015 13:40:28 +0100 Subject: First working approach to show mount status --- apps/files_external/js/app.js | 132 +++++--- apps/files_external/js/rollingqueue.js | 137 ++++++++ apps/files_external/js/statusmanager.js | 486 +++++++++++++++++++++++++++ apps/files_external/js/statusmanagerutils.js | 158 +++++++++ apps/files_external/lib/api.php | 6 +- apps/files_external/list.php | 5 + 6 files changed, 874 insertions(+), 50 deletions(-) create mode 100644 apps/files_external/js/rollingqueue.js create mode 100644 apps/files_external/js/statusmanager.js create mode 100644 apps/files_external/js/statusmanagerutils.js (limited to 'apps/files_external') diff --git a/apps/files_external/js/app.js b/apps/files_external/js/app.js index bf853f926dc..411d5fc3433 100644 --- a/apps/files_external/js/app.js +++ b/apps/files_external/js/app.js @@ -9,69 +9,105 @@ */ if (!OCA.External) { - /** - * @namespace - */ - OCA.External = {}; + /** + * @namespace + */ + OCA.External = {}; } /** * @namespace */ OCA.External.App = { - fileList: null, + fileList: null, - initList: function($el) { - if (this.fileList) { - return this.fileList; - } + initList: function($el) { + if (this.fileList) { + return this.fileList; + } - this.fileList = new OCA.External.FileList( - $el, - { - scrollContainer: $('#app-content'), - fileActions: this._createFileActions() - } - ); + this.fileList = new OCA.External.FileList( + $el, + { + scrollContainer: $('#app-content'), + fileActions: this._createFileActions() + } + ); - this._extendFileList(this.fileList); - this.fileList.appName = t('files_external', 'External storage'); - return this.fileList; - }, + this._extendFileList(this.fileList); + this.fileList.appName = t('files_external', 'External storage'); + return this.fileList; + }, - removeList: function() { - if (this.fileList) { - this.fileList.$fileList.empty(); - } - }, + removeList: function() { + if (this.fileList) { + this.fileList.$fileList.empty(); + } + }, - _createFileActions: function() { - // inherit file actions from the files app - var fileActions = new OCA.Files.FileActions(); - fileActions.registerDefaultActions(); + _createFileActions: function() { + // inherit file actions from the files app + var fileActions = new OCA.Files.FileActions(); + fileActions.registerDefaultActions(); - // when the user clicks on a folder, redirect to the corresponding - // folder in the files app instead of opening it directly - fileActions.register('dir', 'Open', OC.PERMISSION_READ, '', function (filename, context) { - OCA.Files.App.setActiveView('files', {silent: true}); - OCA.Files.App.fileList.changeDirectory(context.$file.attr('data-path') + '/' + filename, true, true); - }); - fileActions.setDefault('dir', 'Open'); - return fileActions; - }, + // when the user clicks on a folder, redirect to the corresponding + // folder in the files app instead of opening it directly + fileActions.register('dir', 'Open', OC.PERMISSION_READ, '', function (filename, context) { + OCA.Files.App.setActiveView('files', {silent: true}); + OCA.Files.App.fileList.changeDirectory(context.$file.attr('data-path') + '/' + filename, true, true); + }); + fileActions.setDefault('dir', 'Open'); + return fileActions; + }, - _extendFileList: function(fileList) { - // remove size column from summary - fileList.fileSummary.$el.find('.filesize').remove(); - } + _extendFileList: function(fileList) { + // remove size column from summary + fileList.fileSummary.$el.find('.filesize').remove(); + } }; $(document).ready(function() { - $('#app-content-extstoragemounts').on('show', function(e) { - OCA.External.App.initList($(e.target)); - }); - $('#app-content-extstoragemounts').on('hide', function() { - OCA.External.App.removeList(); - }); + $('#app-content-extstoragemounts').on('show', function(e) { + OCA.External.App.initList($(e.target)); + }); + $('#app-content-extstoragemounts').on('hide', function() { + OCA.External.App.removeList(); + }); + + /* Status Manager */ + if ($('#filesApp').val()) { + + $('#app-content-files') + .add('#app-content-extstoragemounts') + .on('changeDirectory', function(e){ + if (e.dir === '/') { + var mount_point = e.previousDir.split('/', 2)[1]; + // make sure we have a mount point list + OCA.External.StatusManager.getMountPointList(function() { + OCA.External.StatusManager.recheckConnectivityForMount([mount_point], true, true); + }); + } + }) + .on('fileActionsReady', function(e){ + if ($.isArray(e.$files)) { + if (OCA.External.StatusManager.mountStatus === null || + OCA.External.StatusManager.mountPointList === null || + _.size(OCA.External.StatusManager.mountStatus) !== _.size(OCA.External.StatusManager.mountPointList)) { + // we don't have the data cached, so we'll get it one by one + OCA.External.StatusManager.launchFullConnectivityCheckOneByOne(); + } else { + // make sure we have a mount point list + OCA.External.StatusManager.getMountPointList(function(){ + var fileNames = []; + $.each(e.$files, function(key, value){ + fileNames.push(value.attr('data-file')); + }); + OCA.External.StatusManager.recheckConnectivityForMount(fileNames, false, false); + }); + } + } + }); + } + /* End Status Manager */ }); diff --git a/apps/files_external/js/rollingqueue.js b/apps/files_external/js/rollingqueue.js new file mode 100644 index 00000000000..7e6570a2a7c --- /dev/null +++ b/apps/files_external/js/rollingqueue.js @@ -0,0 +1,137 @@ +/** + * ownCloud + * + * @author Juan Pablo Villafañez Ramos + * @author Jesus Macias Portela + * @copyright (C) 2014 ownCloud, Inc. + * + * This code is covered by the ownCloud Commercial License. + * + * You should have received a copy of the ownCloud Commercial License + * along with this program. If not, see . + * + */ + +(function(){ +/** + * Launch several functions at thee same time. The number of functions + * running at the same time is controlled by the queueWindow param + * + * The function list come in the following format: + * + * var flist = [ + * { + * funcName: function () { + * var d = $.Deferred(); + * setTimeout(function(){d.resolve();}, 1000); + * return d; + * } + * }, + * { + * funcName: $.get, + * funcArgs: [ + * OC.filePath('files_external', 'ajax', 'connectivityCheck.php'), + * {}, + * function () { + * console.log('titoooo'); + * } + * ] + * }, + * { + * funcName: $.get, + * funcArgs: [ + * OC.filePath('files_external', 'ajax', 'connectivityCheck.php') + * ], + * done: function () { + * console.log('yuupi'); + * }, + * always: function () { + * console.log('always done'); + * } + * } + *]; + * + * functions MUST implement the deferred interface + * + * @param functionList list of functions that the queue will run + * (check example above for the expected format) + * @param queueWindow specify the number of functions that will + * be executed at the same time + */ +var RollingQueue = function (functionList, queueWindow, callback) { + this.queueWindow = queueWindow || 1; + this.functionList = functionList; + this.callback = callback; + this.counter = 0; + this.runQueue = function() { + this.callbackCalled = false; + this.deferredsList = []; + if (!$.isArray(this.functionList)) { + throw "functionList must be an array"; + } + + for (i = 0; i < this.queueWindow; i++) { + this.launchNext(); + } + }; + + this.hasNext = function() { + return (this.counter in this.functionList); + }; + + this.launchNext = function() { + var currentCounter = this.counter++; + if (currentCounter in this.functionList) { + var funcData = this.functionList[currentCounter]; + if ($.isFunction(funcData.funcName)) { + var defObj = funcData.funcName.apply(funcData.funcName, funcData.funcArgs); + this.deferredsList.push(defObj); + if ($.isFunction(funcData.done)) { + defObj.done(funcData.done); + } + + if ($.isFunction(funcData.fail)) { + defObj.fail(funcData.fail); + } + + if ($.isFunction(funcData.always)) { + defObj.always(funcData.always); + } + + if (this.hasNext()) { + var self = this; + defObj.always(function(){ + _.defer($.proxy(function(){ + self.launchNext(); + }, self)); + }); + } else { + if (!this.callbackCalled) { + this.callbackCalled = true; + if ($.isFunction(this.callback)) { + $.when.apply($, this.deferredsList) + .always($.proxy(function(){ + this.callback(); + }, this) + ); + } + } + } + return defObj; + } + } + return false; + }; +}; + +if (!OCA.External) { + OCA.External = {}; +} + +if (!OCA.External.StatusManager) { + OCA.External.StatusManager = {}; +} + +OCA.External.StatusManager.RollingQueue = RollingQueue; + +})(); \ No newline at end of file diff --git a/apps/files_external/js/statusmanager.js b/apps/files_external/js/statusmanager.js new file mode 100644 index 00000000000..f3e0832ad6a --- /dev/null +++ b/apps/files_external/js/statusmanager.js @@ -0,0 +1,486 @@ +/** + * ownCloud + * + * @author Juan Pablo Villafañez Ramos + * @author Jesus Macias Portela + * @copyright (C) 2014 ownCloud, Inc. + * + * This code is covered by the ownCloud Commercial License. + * + * You should have received a copy of the ownCloud Commercial License + * along with this program. If not, see . + * + */ + +if (!OCA.External) { + OCA.External = {}; +} + +OCA.External.StatusManager = { + mountStatus : null, + mountPointList : null, + + getMountStatus : function(afterCallback) { + var self = this; + if (typeof afterCallback !== 'function' || self.isGetMountStatusRunning) { + return; + } + + if (self.mountStatus) { + afterCallback(self.mountStatus); + } else { + self.isGetMountStatusRunning = true; + $.ajax({ + type : 'GET', + url : OC.filePath('files_external', 'ajax', 'connectivityCheck.php'), + success : function(response) { + self.mountStatus = response.data; + afterCallback(self.mountStatus); + }, + error : function(jqxhr, state, error) { + OCA.External.StatusManager.Utils.showAlert(t('files_external', 'Couldn\'t get the status of the external mounts: {type}', {type : error})); + if (!self.mountStatus) { + self.mountStatus = {}; + } + $.each(self.mountPointList, function(name, value){ + if (!self.mountStatus[value.mount_point]) { + self.mountStatus[value.mount_point] = {}; + } + self.mountStatus[value.mount_point].status = 'ok'; + OCA.External.StatusManager.Utils.restoreFolder(value); + OCA.External.StatusManager.Utils.toggleLink(value.mount_point, true, true); + }); + }, + complete : function() { + self.isGetMountStatusRunning = false; + } + }); + } + }, + + getMountPointListElement : function(mount_point) { + var element; + $.each(this.mountPointList, function(key, value){ + if (value.mount_point === mount_point) { + element = value; + return false; + } + }); + return element; + }, + + getMountStatusForMount : function(mountData, afterCallback) { + var self = this; + if (typeof afterCallback !== 'function' || self.isGetMountStatusRunning) { + return $.Deferred().resolve(); + } + + var defObj; + if (self.mountStatus[mountData.mount_point]) { + defObj = $.Deferred(); + afterCallback(mountData.mount_point, self.mountStatus[mountData.mount_point]); + defObj.resolve(); // not really useful, but it'll keep the same behaviour + } else { + defObj = $.ajax({ + type : 'GET', + url: OC.webroot + '/index.php/apps/files_external/globalstorages/' + mountData.id, + success : function(response) { + if (response && response.status === 0) { + self.mountStatus[mountData.mount_point] = response; + } else { + if (response && response.data) { + // failure response with error message + self.mountStatus[mountData.mount_point] = {code: 'GE', + status: 'fail', + error: response.data.message}; + } else { + self.mountStatus[mountData.mount_point] = {code: 'GE', + status: 'fail', + error: t('files_external', 'Empty response from the server')}; + } + } + afterCallback(mountData.mount_point, self.mountStatus[mountData.mount_point]); + }, + error : function(jqxhr, state, error) { + var message; + if(mountData.location === 3){ + // In this case the error is because mount point use Login credentials and don't exist in the session + message = t('files_external', 'Couldn\'t access. Please logout and login to activate this mount point'); + } else { + message = t('files_external', 'Couldn\'t get the information from the ownCloud server: {code} {type}', {code: jqxhr.status, type: error}); + } + self.mountStatus[mountData.mount_point] = {code: 'GE', + status: 'fail', + location: mountData.location, + error: message}; + afterCallback(mountData.mount_point, self.mountStatus[mountData.mount_point]); + } + }); + } + return defObj; + }, + + getMountPointList : function(afterCallback) { + var self = this; + if (typeof afterCallback !== 'function' || self.isGetMountPointListRunning) { + return; + } + + + if (self.mountPointList) { + afterCallback(self.mountPointList); + } else { + self.isGetMountPointListRunning = true; + $.ajax({ + type : 'GET', + url : OC.linkToOCS('apps/files_external/api/v1') + 'mounts?format=json', + success : function(response) { + self.mountPointList = []; + _.each(response.ocs.data, function(mount){ + var element = {}; + element.mount_point = mount.name; + element.type = mount.scope; + element.location = ""; + element.id = mount.id; + element.backend = mount.backend; + element.class = mount.class; + + self.mountPointList.push(element); + }); + afterCallback(self.mountPointList); + }, + error : function(jqxhr, state, error) { + self.mountPointList = []; + OCA.External.StatusManager.Utils.showAlert(t('files_external', 'Couldn\'t get the list of external mount points: {type}', {type : error})); + }, + complete : function() { + self.isGetMountPointListRunning = false; + } + }); + } + }, + + setMountPointAsGood : function(mountPoint) { + OCA.External.StatusManager.Utils.restoreFolder(mountPoint); + OCA.External.StatusManager.Utils.toggleLink(mountPoint, true, true); + delete this.mountStatus[mountPoint].code; + delete this.mountStatus[mountPoint].error; + this.mountStatus[mountPoint].status = 'ok'; + }, + + manageMountPointError : function(name) { + var self = this; + this.getMountStatus($.proxy(function(allMountStatus) { + if (typeof allMountStatus[name] !== 'undefined' || allMountStatus[name].status === 'fail') { + var mountData = allMountStatus[name]; + if ((mountData.code === 'CNP' || mountData.code === 'AD') && mountData.type === 'global' && mountData.location === 1) { + // admin set up mount point and let users use their credentials. Credentials + // aren't stored yet or are wrong (handled by the same ajax request) + this.showCredentialsDialog(name, mountData, null, 'saveCredential.php', + null, this.setMountPointAsGood, this); + + } else if (mountData.code === 'AD' && mountData.type === 'personal' && mountData.location === 0) { + // personal set up mount point and let users use their credentials. + // Credentials are wrong so they need to be updated + // the "type 0" is a required parameter in the target ajax call + this.showCredentialsDialog(name, mountData, {type: 0}, 'updatePersonalMountPoint.php', + null, this.setMountPointAsGood, this); + + } else if (mountData.code === 'AD' && mountData.type === 'personal' && mountData.location === 2) { + this.showCredentialsDialog(name, mountData, null, 'saveGlobalCredentials.php', + t('files_external', 'WARNING: This mount point uses global credentials.\n\nChanging the credentials might affect to other mount points'), + function() { + this.recheckConnectivityForMount([name], true, true); + }, + this); + + } else if (mountData.code === 'AD' && mountData.type === 'global' && (mountData.location === 0 || mountData.location === 2)) { + OC.dialogs.message(t('files_external', 'The credentials for this mount point are wrong. This mount point was set by the administrator, please contact him / her to provide suitable credentials'), t('files_external', 'Credentials error')); + + } else if ((mountData.code === 'CE' || mountData.code === 'IH')) { + OC.dialogs.message(mountData.error, t('files_external', 'Connectivity error')); + + } else if ((mountData.code === 'GE' && mountData.location === 3)) { + OC.dialogs.message(mountData.error, t('files_external', 'Login credentials error')); + + } else { + OC.dialogs.message(mountData.error, t('files_external', 'Unknown error')); + } + } + }, this)); + }, + + showCredentialsDialog : function(mountPoint, mountData, extraParams, target, extraInfo, successCallback, callbackCtx) { + var self = this; + var baseParams = {target: target, + m: mountData.mid, + name: mountPoint, + url: mountData.url, + share: mountData.share, + extra: extraInfo}; + var sendParams = ($.isPlainObject(extraParams)) ? $.extend(baseParams, extraParams) : baseParams; + $.get(OC.filePath('files_external', 'ajax', 'dialog.php'), + sendParams, + function(data) { + if (typeof data.status !== 'undefined' && data.status === 'success') { + $('body').append(data.form); + var wnd_send_button_click_func = function () { + $('.oc-dialog-close').hide(); + var dataToSend = {}; + $('#wnd_div_form').find('input').each(function(){ + var thisElement = $(this); + if (thisElement.is('[type="checkbox"]')) { + dataToSend[thisElement.attr('name')] = thisElement.prop('checked'); + } else { + dataToSend[thisElement.attr('name')] = thisElement.val(); + } + }); + $.ajax({type: 'POST', + url: $('#wnd_div_form form').attr('action'), + data: dataToSend, + success: function (data) { + var dialog = $('#wnd_div_form'); + if (typeof(data.status) !== 'undefined' && data.status === 'success') { + dialog.ocdialog('close'); + + if (successCallback && $.isFunction(successCallback)) { + successCallback.call(callbackCtx || this, mountPoint); + } + } else { + $('.oc-dialog-close').show(); + dialog.ocdialog('option', 'title', 'Windows Network Drive credentials validation failed'); + var title = $('.oc-dialog-title'); + var color = title.css('background-color'); + title.css('background-color', 'red'); + title.animate({backgroundColor: color}, 5000); + } + }, + error: function (){ + $('.oc-dialog-close').show(); + }}); + }; + + var buttonList = [{text : t('files_external', 'Save'), + click : wnd_send_button_click_func, + closeOnEscape : true}]; + + var ocdialogParams = {modal: true, buttons : buttonList, + closeOnExcape : true}; + $('#wnd_div_form').ocdialog(ocdialogParams) + .bind('ocdialogclose', function(){ + $('#wnd_div_form').ocdialog('destroy').remove(); + }); + } + }); + }, + + processMountStatus : function(mounts) { + var hasErrors = false; + var self = this; + $.each(mounts, function(mountPoint, values){ + hasErrors = !self.processMountStatusIndividual(mountPoint, values) || hasErrors; + }); + + if (!this.notificationHasShown) { + this.notificationHasShown = true; + if (hasErrors) { + OCA.External.StatusManager.Utils.showAlert(t('files_external', 'Some of the configured Windows network drive(s) are not connected. Please click on the red row(s) for more information')); + } + } + }, + + processMountStatusIndividual : function(mountPoint, mountData) { + if (mountData.status === 'fail') { + var errorImage = 'folder-windows'; + if (mountData.code === 'AD' || mountData.code === 'CNP') { + errorImage += '-credentials'; + } else if (mountData.code === 'IH' || mountData.code === 'CE') { + errorImage += '-timeout'; + } else { + errorImage += '-error'; + } + if (OCA.External.StatusManager.Utils.isCorrectViewAndRootFolder()) { + OCA.External.StatusManager.Utils.showIconError(mountPoint, $.proxy(OCA.External.StatusManager.manageMountPointError, OCA.External.StatusManager), OC.imagePath('files_external', errorImage)); + } + return false; + } else { + if (OCA.External.StatusManager.Utils.isCorrectViewAndRootFolder()) { + OCA.External.StatusManager.Utils.restoreFolder(mountPoint); + OCA.External.StatusManager.Utils.toggleLink(mountPoint, true, true); + } + return true; + } + }, + + processMountList : function(mountList) { + var elementList = null; + $.each(mountList, function(name, value){ + var trElement = $('#fileList tr[data-file=\"' + OCA.External.StatusManager.Utils.jqSelEscape(value.mount_point) + '\"]'); + if (elementList) { + elementList = elementList.add(trElement); + } else { + elementList = trElement; + } + }); + + if (elementList instanceof $) { + if (OCA.External.StatusManager.Utils.isCorrectViewAndRootFolder()) { + // Put their custom icon + // OCA.External.StatusManager.Utils.changeFolderIcon(elementList.find('td:first-child div.thumbnail'), "url(" + OC.imagePath('windows_network_drive', 'folder-windows') + ")"); + // Save default view + OCA.External.StatusManager.Utils.storeDefaultFolderIconAndBgcolor(elementList); + // Disable row until check status + elementList.css('background-color', '#CCC'); + OCA.External.StatusManager.Utils.toggleLink(elementList.find('a.name'), false, false); + } + } + }, + + launchFullConnectivityCheck : function() { + var self = this; + this.getMountPointList(function(list){ + // check if we have a list first + if (list === undefined && !self.emptyWarningShown) { + self.emptyWarningShown = true; + OCA.External.StatusManager.Utils.showAlert(t('files_external', 'Couldn\'t get the list of Windows network drive mount points: empty response from the server')); + return; + } + if (list && list.length > 0) { + self.processMountList(list); + self.getMountStatus(function(mountStatus){ + if (mountStatus === undefined && !self.notificationNoProcessListDone) { + self.notificationNoProcessListDone = true; + OCA.External.StatusManager.Utils.showAlert(t('files_external', 'Couldn\'t get the status of the Windows network drive mounts: empty response from the server')); + if (!self.mountStatus) { + self.mountStatus = {}; + } + $.each(list, function(name, value){ + if (!self.mountStatus[value.mount_point]) { + self.mountStatus[value.mount_point] = {}; + } + self.mountStatus[value.mount_point].status = 'ok'; + OCA.External.StatusManager.Utils.restoreFolder(value.mount_point); + OCA.External.StatusManager.Utils.toggleLink(value.mount_point, true, true); + }); + return; + } + self.processMountStatus(mountStatus); + }); + } + }); + }, + + launchFullConnectivityCheckOneByOne : function() { + var self = this; + this.getMountPointList(function(list){ + // check if we have a list first + if (list === undefined && !self.emptyWarningShown) { + self.emptyWarningShown = true; + OCA.External.StatusManager.Utils.showAlert(t('files_external', 'Couldn\'t get the list of Windows network drive mount points: empty response from the server')); + return; + } + if (list && list.length > 0) { + self.processMountList(list); + + if (!self.mountStatus) { + self.mountStatus = {}; + } + + var ajaxQueue = []; + $.each(list, function(key, value){ + var queueElement = {funcName: $.proxy(self.getMountStatusForMount, self), + funcArgs: [value, + $.proxy(self.processMountStatusIndividual, self)]}; + ajaxQueue.push(queueElement); + }); + + var rolQueue = new OCA.External.StatusManager.RollingQueue(ajaxQueue, 4, function(){ + if (!self.notificationHasShown) { + var showNotification = false; + $.each(self.mountStatus, function(key, value){ + if (value.status === 'fail') { + self.notificationHasShown = true; + showNotification = true; + } + }); + if (showNotification) { + OCA.External.StatusManager.Utils.showAlert(t('files_external', 'Some of the configured Windows network drive(s) are not connected. Please click on the red row(s) for more information')); + } + } + }); + rolQueue.runQueue(); + } + }); + }, + + launchPartialConnectivityCheck : function(mountListData, recheck) { + if (mountListData.length === 0) { + return; + } + + var self = this; + var ajaxQueue = []; + $.each(mountListData, function(key, value){ + if (recheck && value.mount_point in self.mountStatus) { + delete self.mountStatus[value.mount_point]; + } + var queueElement = {funcName: $.proxy(self.getMountStatusForMount, self), + funcArgs: [value, + $.proxy(self.processMountStatusIndividual, self)]}; + ajaxQueue.push(queueElement); + }); + new OCA.External.StatusManager.RollingQueue(ajaxQueue, 4).runQueue(); + }, + + recheckConnectivityForMount : function(mountListNames, recheck, checkGlobal) { + if (mountListNames.length === 0) { + return; + } + + var self = this; + var mountListData = []; + var recheckPersonalGlobal = false; + var recheckAdminGlobal = false; + + if (!self.mountStatus) { + self.mountStatus = {}; + } + + $.each(mountListNames, function(key, value){ + var mountData = self.getMountPointListElement(value); + if (mountData) { + if (mountData.type === 'personal' && mountData.location === 2) { + recheckPersonalGlobal = true; + } + if (mountData.type === 'admin' && mountData.location === 2) { + recheckAdminGlobal = true; + } + mountListData.push(mountData); + } + }); + + // we might need to check more mounts if a personal mount with global credentials is affected + if (checkGlobal && (recheckPersonalGlobal || recheckAdminGlobal)) { + $.each(self.mountPointList, function(key, value){ + if (((recheckPersonalGlobal && value.type === 'personal') || (recheckAdminGlobal && value.type === 'admin')) && + value.location === 2 && + $.inArray(value, mountListData) === -1) { + // personal mount using global credentials, not present in the mountListData + mountListData.push(value); + } + }); + } + + // for all mounts in the list, delete the cached status values + if (recheck) { + $.each(mountListData, function(key, value){ + if (value.mount_point in self.mountStatus) { + delete self.mountStatus[value.mount_point]; + } + }); + } + + self.processMountList(mountListData); + self.launchPartialConnectivityCheck(mountListData, recheck); + } +}; diff --git a/apps/files_external/js/statusmanagerutils.js b/apps/files_external/js/statusmanagerutils.js new file mode 100644 index 00000000000..e8e8265f9ef --- /dev/null +++ b/apps/files_external/js/statusmanagerutils.js @@ -0,0 +1,158 @@ +/** + * ownCloud + * + * @author Juan Pablo Villafañez Ramos + * @author Jesus Macias Portela + * @copyright (C) 2014 ownCloud, Inc. + * + * This code is covered by the ownCloud Commercial License. + * + * You should have received a copy of the ownCloud Commercial License + * along with this program. If not, see . + * + */ + +if (!OCA.External) { + OCA.External = {}; +} + +if (!OCA.External.StatusManager) { + OCA.External.StatusManager = {}; +} + +OCA.External.StatusManager.Utils = { + + showAlert: function(message){ + if (!OC.Notification.isHidden()) { + OC.Notification.hide(); + OC.Notification.showHtml(message); + } else { + OC.Notification.showHtml(message); + } + setTimeout(function() { + if ($("#notification").text() === message) { + OC.Notification.hide(); + } + }, 10000); + }, + + showIconError: function(folder, clickAction, errorImageUrl) { + var bgColor = '#F2DEDE'; + var imageUrl = "url(" + errorImageUrl + ")"; + var trFolder = $('#fileList tr[data-file=\"' + this.jqSelEscape(folder) + '\"]'); + this.changeFolderIcon(folder, imageUrl); + this.toggleLink(folder, false, clickAction); + trFolder.css('background-color', bgColor); + }, + + /** + * @param folder string with the folder or jQuery element pointing to the tr element + */ + storeDefaultFolderIconAndBgcolor: function(folder) { + var trFolder; + if (folder instanceof $) { + trFolder = folder; + } else { + trFolder = $('#fileList tr[data-file=\"' + this.jqSelEscape(folder) + '\"]'); + } + trFolder.each(function(){ + var thisElement = $(this); + if (thisElement.data('oldbgcolor') === undefined) { + thisElement.data('oldbgcolor', thisElement.css('background-color')); + } + }); + + var icon = trFolder.find('td:first-child div.thumbnail'); + icon.each(function(){ + var thisElement = $(this); + if (thisElement.data('oldImage') === undefined) { + thisElement.data('oldImage', thisElement.css('background-image')); + } + }); + }, + + /** + * @param folder string with the folder or jQuery element pointing to the tr element + */ + restoreFolder: function(folder) { + var trFolder; + if (folder instanceof $) { + trFolder = folder; + } else { + trFolder = $('#fileList tr[data-file=\"' + this.jqSelEscape(folder) + '\"]'); + } + trFolder.css('background-color', ''); + tdChilds = trFolder.find("td:first-child div.thumbnail"); + tdChilds.each(function(){ + var thisElement = $(this); + thisElement.css('background-image', thisElement.data('oldImage')); + }); + }, + + /** + * @param folder string with the folder or jQuery element pointing to the first td element + * of the tr matching the folder name + */ + changeFolderIcon: function(filename, route) { + var file; + if (filename instanceof $) { + file = filename; + } else { + file = $("#fileList tr[data-file=\"" + this.jqSelEscape(filename) + "\"] > td:first-child div.thumbnail"); + } + file.css('background-image', route).hide().show(0); + // previous line is required in Chrome to force the css update so the image url + // is stored correctly later + //file.css('background-image', route).height(); + }, + + toggleLink: function(filename, active, action) { + var link; + if (filename instanceof $) { + link = filename; + } else { + link = $("#fileList tr[data-file=\"" + this.jqSelEscape(filename) + "\"] > td:first-child a.name"); + } + if (active) { + link.off('click.connectivity'); + OCA.Files.App.fileList.fileActions.display(link.parent(), true, OCA.Files.App.fileList); + } else { + link.find('.fileactions, .nametext .action').remove(); // from files/js/fileactions (display) + link.off('click.connectivity'); + link.on('click.connectivity', function(e){ + if (action && $.isFunction(action)) { + action(filename); + } + e.preventDefault(); + return false; + }); + } + }, + + isCorrectViewAndRootFolder: function() { + // correct views = files & extstoragemounts + if (OCA.Files.App.getActiveView() === 'files' || OCA.Files.App.getActiveView() === 'extstoragemounts') { + return OCA.Files.App.getCurrentAppContainer().find('#dir').val() === '/'; + } + return false; + }, + + /* escape a selector expression for jQuery */ + jqSelEscape: function(expression) { + return expression.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]^`{|}~]/g, '\\$&'); + }, + + /* Copied from http://stackoverflow.com/questions/2631001/javascript-test-for-existence-of-nested-object-key */ + checkNested: function(cobj /*, level1, level2, ... levelN*/) { + var args = Array.prototype.slice.call(arguments), + obj = args.shift(); + + for (var i = 0; i < args.length; i++) { + if (!obj || !obj.hasOwnProperty(args[i])) { + return false; + } + obj = obj[args[i]]; + } + return true; + } +}; diff --git a/apps/files_external/lib/api.php b/apps/files_external/lib/api.php index af9b802e522..f0c9e568c9e 100644 --- a/apps/files_external/lib/api.php +++ b/apps/files_external/lib/api.php @@ -28,7 +28,7 @@ class Api { /** * Formats the given mount config to a mount entry. - * + * * @param string $mountPoint mount point name, relative to the data dir * @param array $mountConfig mount config to format * @@ -59,7 +59,9 @@ class Api { 'type' => 'dir', 'backend' => $mountConfig['backend'], 'scope' => ( $isSystemMount ? 'system' : 'personal' ), - 'permissions' => $permissions + 'permissions' => $permissions, + 'id' => $mountConfig['id'], + 'class' => $mountConfig['class'] ); return $entry; } diff --git a/apps/files_external/list.php b/apps/files_external/list.php index b98db79de89..831107c9c3f 100644 --- a/apps/files_external/list.php +++ b/apps/files_external/list.php @@ -23,6 +23,11 @@ OCP\User::checkLoggedIn(); $tmpl = new OCP\Template('files_external', 'list', ''); +/* Load Status Manager */ +\OCP\Util::addScript('files_external', 'statusmanager'); +\OCP\Util::addScript('files_external', 'statusmanagerutils'); +\OCP\Util::addScript('files_external', 'rollingqueue'); + OCP\Util::addScript('files_external', 'app'); OCP\Util::addScript('files_external', 'mountsfilelist'); -- cgit v1.2.3 From a413f8eccccfdd0bdc9bf970801568a8f27743d7 Mon Sep 17 00:00:00 2001 From: Jesús Macias Date: Fri, 13 Nov 2015 12:57:33 +0100 Subject: Add icon management capabilities (error icon) --- apps/files_external/js/statusmanager.js | 33 ++++++++++++++-------------- apps/files_external/js/statusmanagerutils.js | 2 +- 2 files changed, 18 insertions(+), 17 deletions(-) (limited to 'apps/files_external') diff --git a/apps/files_external/js/statusmanager.js b/apps/files_external/js/statusmanager.js index f3e0832ad6a..266a11b0deb 100644 --- a/apps/files_external/js/statusmanager.js +++ b/apps/files_external/js/statusmanager.js @@ -88,14 +88,14 @@ OCA.External.StatusManager = { if (response && response.status === 0) { self.mountStatus[mountData.mount_point] = response; } else { - if (response && response.data) { + if (response && response.statusMessage) { // failure response with error message self.mountStatus[mountData.mount_point] = {code: 'GE', - status: 'fail', - error: response.data.message}; + status: 1, + error: response.statusMessage}; } else { self.mountStatus[mountData.mount_point] = {code: 'GE', - status: 'fail', + status: 1, error: t('files_external', 'Empty response from the server')}; } } @@ -110,7 +110,7 @@ OCA.External.StatusManager = { message = t('files_external', 'Couldn\'t get the information from the ownCloud server: {code} {type}', {code: jqxhr.status, type: error}); } self.mountStatus[mountData.mount_point] = {code: 'GE', - status: 'fail', + status: 1, location: mountData.location, error: message}; afterCallback(mountData.mount_point, self.mountStatus[mountData.mount_point]); @@ -171,7 +171,7 @@ OCA.External.StatusManager = { manageMountPointError : function(name) { var self = this; this.getMountStatus($.proxy(function(allMountStatus) { - if (typeof allMountStatus[name] !== 'undefined' || allMountStatus[name].status === 'fail') { + if (typeof allMountStatus[name] !== 'undefined' || allMountStatus[name].status === 1) { var mountData = allMountStatus[name]; if ((mountData.code === 'CNP' || mountData.code === 'AD') && mountData.type === 'global' && mountData.location === 1) { // admin set up mount point and let users use their credentials. Credentials @@ -204,7 +204,7 @@ OCA.External.StatusManager = { OC.dialogs.message(mountData.error, t('files_external', 'Login credentials error')); } else { - OC.dialogs.message(mountData.error, t('files_external', 'Unknown error')); + OC.dialogs.message(mountData.error, t('files_external', 'External mount error')); } } }, this)); @@ -222,7 +222,7 @@ OCA.External.StatusManager = { $.get(OC.filePath('files_external', 'ajax', 'dialog.php'), sendParams, function(data) { - if (typeof data.status !== 'undefined' && data.status === 'success') { + if (typeof data.status !== 'undefined' && data.status === 0) { $('body').append(data.form); var wnd_send_button_click_func = function () { $('.oc-dialog-close').hide(); @@ -240,7 +240,7 @@ OCA.External.StatusManager = { data: dataToSend, success: function (data) { var dialog = $('#wnd_div_form'); - if (typeof(data.status) !== 'undefined' && data.status === 'success') { + if (typeof(data.status) !== 'undefined' && data.status === 0) { dialog.ocdialog('close'); if (successCallback && $.isFunction(successCallback)) { @@ -284,23 +284,24 @@ OCA.External.StatusManager = { if (!this.notificationHasShown) { this.notificationHasShown = true; if (hasErrors) { - OCA.External.StatusManager.Utils.showAlert(t('files_external', 'Some of the configured Windows network drive(s) are not connected. Please click on the red row(s) for more information')); + OCA.External.StatusManager.Utils.showAlert(t('files_external', 'Some of the configured external mount points are not connected. Please click on the red row(s) for more information')); } } }, processMountStatusIndividual : function(mountPoint, mountData) { - if (mountData.status === 'fail') { - var errorImage = 'folder-windows'; + if (mountData.status === 1) { + var errorImage = 'folder-windows-error'; + /* if (mountData.code === 'AD' || mountData.code === 'CNP') { errorImage += '-credentials'; } else if (mountData.code === 'IH' || mountData.code === 'CE') { errorImage += '-timeout'; } else { errorImage += '-error'; - } + }*/ if (OCA.External.StatusManager.Utils.isCorrectViewAndRootFolder()) { - OCA.External.StatusManager.Utils.showIconError(mountPoint, $.proxy(OCA.External.StatusManager.manageMountPointError, OCA.External.StatusManager), OC.imagePath('files_external', errorImage)); + OCA.External.StatusManager.Utils.showIconError(mountPoint, $.proxy(OCA.External.StatusManager.manageMountPointError, OCA.External.StatusManager), OC.imagePath('core', 'filetypes/' + errorImage)); } return false; } else { @@ -398,13 +399,13 @@ OCA.External.StatusManager = { if (!self.notificationHasShown) { var showNotification = false; $.each(self.mountStatus, function(key, value){ - if (value.status === 'fail') { + if (value.status === 1) { self.notificationHasShown = true; showNotification = true; } }); if (showNotification) { - OCA.External.StatusManager.Utils.showAlert(t('files_external', 'Some of the configured Windows network drive(s) are not connected. Please click on the red row(s) for more information')); + OCA.External.StatusManager.Utils.showAlert(t('files_external', 'Some of the configured external mount points are not connected. Please click on the red row(s) for more information')); } } }); diff --git a/apps/files_external/js/statusmanagerutils.js b/apps/files_external/js/statusmanagerutils.js index e8e8265f9ef..0ee6bc2a17e 100644 --- a/apps/files_external/js/statusmanagerutils.js +++ b/apps/files_external/js/statusmanagerutils.js @@ -100,7 +100,7 @@ OCA.External.StatusManager.Utils = { } else { file = $("#fileList tr[data-file=\"" + this.jqSelEscape(filename) + "\"] > td:first-child div.thumbnail"); } - file.css('background-image', route).hide().show(0); + // file.css('background-image', route).hide().show(0); // previous line is required in Chrome to force the css update so the image url // is stored correctly later //file.css('background-image', route).height(); -- cgit v1.2.3 From fab13b7ca55c02b15c237bd57d5a9de23f0d014e Mon Sep 17 00:00:00 2001 From: Jesús Macias Date: Wed, 18 Nov 2015 12:12:32 +0100 Subject: Add method to show custom icon and icon-error for each storage backend --- apps/files_external/js/statusmanager.js | 252 +++++++++++++++++++++------ apps/files_external/js/statusmanagerutils.js | 158 ----------------- apps/files_external/list.php | 1 - 3 files changed, 200 insertions(+), 211 deletions(-) delete mode 100644 apps/files_external/js/statusmanagerutils.js (limited to 'apps/files_external') diff --git a/apps/files_external/js/statusmanager.js b/apps/files_external/js/statusmanager.js index 266a11b0deb..244f5b6bd55 100644 --- a/apps/files_external/js/statusmanager.js +++ b/apps/files_external/js/statusmanager.js @@ -16,6 +16,10 @@ if (!OCA.External) { OCA.External = {}; } +if (!OCA.External.StatusManager) { + OCA.External.StatusManager = {}; +} + OCA.External.StatusManager = { mountStatus : null, mountPointList : null, @@ -90,16 +94,16 @@ OCA.External.StatusManager = { } else { if (response && response.statusMessage) { // failure response with error message - self.mountStatus[mountData.mount_point] = {code: 'GE', + self.mountStatus[mountData.mount_point] = { type: mountData.type, status: 1, error: response.statusMessage}; } else { - self.mountStatus[mountData.mount_point] = {code: 'GE', + self.mountStatus[mountData.mount_point] = { type: mountData.type, status: 1, error: t('files_external', 'Empty response from the server')}; } } - afterCallback(mountData.mount_point, self.mountStatus[mountData.mount_point]); + afterCallback(mountData, self.mountStatus[mountData.mount_point]); }, error : function(jqxhr, state, error) { var message; @@ -109,7 +113,7 @@ OCA.External.StatusManager = { } else { message = t('files_external', 'Couldn\'t get the information from the ownCloud server: {code} {type}', {code: jqxhr.status, type: error}); } - self.mountStatus[mountData.mount_point] = {code: 'GE', + self.mountStatus[mountData.mount_point] = { type: mountData.type, status: 1, location: mountData.location, error: message}; @@ -142,8 +146,8 @@ OCA.External.StatusManager = { element.type = mount.scope; element.location = ""; element.id = mount.id; - element.backend = mount.backend; - element.class = mount.class; + element.backendText = mount.backend; + element.backend = mount.class; self.mountPointList.push(element); }); @@ -173,38 +177,18 @@ OCA.External.StatusManager = { this.getMountStatus($.proxy(function(allMountStatus) { if (typeof allMountStatus[name] !== 'undefined' || allMountStatus[name].status === 1) { var mountData = allMountStatus[name]; - if ((mountData.code === 'CNP' || mountData.code === 'AD') && mountData.type === 'global' && mountData.location === 1) { - // admin set up mount point and let users use their credentials. Credentials - // aren't stored yet or are wrong (handled by the same ajax request) - this.showCredentialsDialog(name, mountData, null, 'saveCredential.php', - null, this.setMountPointAsGood, this); - - } else if (mountData.code === 'AD' && mountData.type === 'personal' && mountData.location === 0) { - // personal set up mount point and let users use their credentials. - // Credentials are wrong so they need to be updated - // the "type 0" is a required parameter in the target ajax call - this.showCredentialsDialog(name, mountData, {type: 0}, 'updatePersonalMountPoint.php', - null, this.setMountPointAsGood, this); - - } else if (mountData.code === 'AD' && mountData.type === 'personal' && mountData.location === 2) { - this.showCredentialsDialog(name, mountData, null, 'saveGlobalCredentials.php', - t('files_external', 'WARNING: This mount point uses global credentials.\n\nChanging the credentials might affect to other mount points'), - function() { - this.recheckConnectivityForMount([name], true, true); - }, - this); - - } else if (mountData.code === 'AD' && mountData.type === 'global' && (mountData.location === 0 || mountData.location === 2)) { - OC.dialogs.message(t('files_external', 'The credentials for this mount point are wrong. This mount point was set by the administrator, please contact him / her to provide suitable credentials'), t('files_external', 'Credentials error')); - - } else if ((mountData.code === 'CE' || mountData.code === 'IH')) { - OC.dialogs.message(mountData.error, t('files_external', 'Connectivity error')); - - } else if ((mountData.code === 'GE' && mountData.location === 3)) { - OC.dialogs.message(mountData.error, t('files_external', 'Login credentials error')); - + if (mountData.type === "system") { + OC.dialogs.confirm(t('files_external', 'There was an error with message: ') + mountData.error + '. Do you want to review mount point config in admin settings page?', t('files_external', 'External mount error'), function(e){ + if(e === true) { + window.location.href = OC.generateUrl('/settings/admin#files_external'); + } + }); } else { - OC.dialogs.message(mountData.error, t('files_external', 'External mount error')); + OC.dialogs.confirm(t('files_external', 'There was an error with message: ') + mountData.error + '. Do you want to review mount point config in personal settings page?', t('files_external', 'External mount error'), function(e){ + if(e === true) { + window.location.href = OC.generateUrl('/settings/personal#' + t('files_external', 'goto-external-storage')); + } + }); } } }, this)); @@ -289,19 +273,15 @@ OCA.External.StatusManager = { } }, - processMountStatusIndividual : function(mountPoint, mountData) { - if (mountData.status === 1) { - var errorImage = 'folder-windows-error'; - /* - if (mountData.code === 'AD' || mountData.code === 'CNP') { - errorImage += '-credentials'; - } else if (mountData.code === 'IH' || mountData.code === 'CE') { - errorImage += '-timeout'; - } else { - errorImage += '-error'; - }*/ + processMountStatusIndividual : function(mountData, mountStatus) { + var mountPoint = mountData.mount_point; + if (mountStatus.status === 1) { + var trElement = $('#fileList tr[data-file=\"' + OCA.External.StatusManager.Utils.jqSelEscape(mountPoint) + '\"]'); + + route = OCA.External.StatusManager.Utils.getIconRoute(trElement) + '-error'; + if (OCA.External.StatusManager.Utils.isCorrectViewAndRootFolder()) { - OCA.External.StatusManager.Utils.showIconError(mountPoint, $.proxy(OCA.External.StatusManager.manageMountPointError, OCA.External.StatusManager), OC.imagePath('core', 'filetypes/' + errorImage)); + OCA.External.StatusManager.Utils.showIconError(mountPoint, $.proxy(OCA.External.StatusManager.manageMountPointError, OCA.External.StatusManager), route); } return false; } else { @@ -317,6 +297,7 @@ OCA.External.StatusManager = { var elementList = null; $.each(mountList, function(name, value){ var trElement = $('#fileList tr[data-file=\"' + OCA.External.StatusManager.Utils.jqSelEscape(value.mount_point) + '\"]'); + trElement.attr('data-external-backend', value.backend); if (elementList) { elementList = elementList.add(trElement); } else { @@ -327,7 +308,7 @@ OCA.External.StatusManager = { if (elementList instanceof $) { if (OCA.External.StatusManager.Utils.isCorrectViewAndRootFolder()) { // Put their custom icon - // OCA.External.StatusManager.Utils.changeFolderIcon(elementList.find('td:first-child div.thumbnail'), "url(" + OC.imagePath('windows_network_drive', 'folder-windows') + ")"); + OCA.External.StatusManager.Utils.changeFolderIcon(elementList); // Save default view OCA.External.StatusManager.Utils.storeDefaultFolderIconAndBgcolor(elementList); // Disable row until check status @@ -343,7 +324,7 @@ OCA.External.StatusManager = { // check if we have a list first if (list === undefined && !self.emptyWarningShown) { self.emptyWarningShown = true; - OCA.External.StatusManager.Utils.showAlert(t('files_external', 'Couldn\'t get the list of Windows network drive mount points: empty response from the server')); + OCA.External.StatusManager.Utils.showAlert(t('files_external', 'Couldn\'t get the list of external mount points: empty response from the server')); return; } if (list && list.length > 0) { @@ -351,7 +332,7 @@ OCA.External.StatusManager = { self.getMountStatus(function(mountStatus){ if (mountStatus === undefined && !self.notificationNoProcessListDone) { self.notificationNoProcessListDone = true; - OCA.External.StatusManager.Utils.showAlert(t('files_external', 'Couldn\'t get the status of the Windows network drive mounts: empty response from the server')); + OCA.External.StatusManager.Utils.showAlert(t('files_external', 'Couldn\'t get the status of the external mounts: empty response from the server')); if (!self.mountStatus) { self.mountStatus = {}; } @@ -485,3 +466,170 @@ OCA.External.StatusManager = { self.launchPartialConnectivityCheck(mountListData, recheck); } }; + +OCA.External.StatusManager.Utils = { + + showAlert: function(message){ + if (!OC.Notification.isHidden()) { + OC.Notification.hide(); + OC.Notification.showHtml(message); + } else { + OC.Notification.showHtml(message); + } + setTimeout(function() { + if ($("#notification").text() === message) { + OC.Notification.hide(); + } + }, 10000); + }, + + showIconError: function(folder, clickAction, errorImageUrl) { + var bgColor = '#F2DEDE'; + var imageUrl = "url(" + errorImageUrl + ")"; + var trFolder = $('#fileList tr[data-file=\"' + this.jqSelEscape(folder) + '\"]'); + this.changeFolderIcon(folder, imageUrl); + this.toggleLink(folder, false, clickAction); + trFolder.css('background-color', bgColor); + }, + + /** + * @param folder string with the folder or jQuery element pointing to the tr element + */ + storeDefaultFolderIconAndBgcolor: function(folder) { + var trFolder; + if (folder instanceof $) { + trFolder = folder; + } else { + trFolder = $('#fileList tr[data-file=\"' + this.jqSelEscape(folder) + '\"]'); + } + trFolder.each(function(){ + var thisElement = $(this); + if (thisElement.data('oldbgcolor') === undefined) { + thisElement.data('oldbgcolor', thisElement.css('background-color')); + } + }); + + var icon = trFolder.find('td:first-child div.thumbnail'); + icon.each(function(){ + var thisElement = $(this); + if (thisElement.data('oldImage') === undefined) { + thisElement.data('oldImage', thisElement.css('background-image')); + } + }); + }, + + /** + * @param folder string with the folder or jQuery element pointing to the tr element + */ + restoreFolder: function(folder) { + var trFolder; + if (folder instanceof $) { + trFolder = folder; + } else { + trFolder = $('#fileList tr[data-file=\"' + this.jqSelEscape(folder) + '\"]'); + } + trFolder.css('background-color', ''); + tdChilds = trFolder.find("td:first-child div.thumbnail"); + tdChilds.each(function(){ + var thisElement = $(this); + thisElement.css('background-image', thisElement.data('oldImage')); + }); + }, + + /** + * @param folder string with the folder or jQuery element pointing to the first td element + * of the tr matching the folder name + */ + changeFolderIcon: function(filename) { + var file; + var route; + if (filename instanceof $) { + //trElementList + $.each(filename, function(index){ + route = OCA.External.StatusManager.Utils.getIconRoute($(this)); + $(this).attr("data-icon", route); + $(this).find('td:first-child div.thumbnail').css('background-image', "url(" + route + ")").css('display', 'none').css('display', 'inline'); + }); + } else { + file = $("#fileList tr[data-file=\"" + this.jqSelEscape(filename) + "\"] > td:first-child div.thumbnail"); + parentTr = file.parents('tr:first'); + route = OCA.External.StatusManager.Utils.getIconRoute(parentTr); + parentTr.attr("data-icon", route); + file.css('background-image', "url(" + route + ")").css('display', 'none').css('display', 'inline'); + } + }, + + /** + * @param backend string with the name of the external storage backend + * of the tr matching the folder name + */ + getIconRoute: function(tr) { + var icon = OC.imagePath('core', 'filetypes/folder-external'); + var backend = null; + + if (tr instanceof $) { + backend = tr.attr('data-external-backend'); + } + + switch (backend) { + case 'smb': + icon = OC.imagePath('windows_network_drive', 'folder-windows'); + break; + case 'sharepoint': + icon = OC.imagePath('sharepoint', 'folder-sharepoint'); + break; + } + + return icon; + }, + + toggleLink: function(filename, active, action) { + var link; + if (filename instanceof $) { + link = filename; + } else { + link = $("#fileList tr[data-file=\"" + this.jqSelEscape(filename) + "\"] > td:first-child a.name"); + } + if (active) { + link.off('click.connectivity'); + OCA.Files.App.fileList.fileActions.display(link.parent(), true, OCA.Files.App.fileList); + } else { + link.find('.fileactions, .nametext .action').remove(); // from files/js/fileactions (display) + link.off('click.connectivity'); + link.on('click.connectivity', function(e){ + if (action && $.isFunction(action)) { + action(filename); + } + e.preventDefault(); + return false; + }); + } + }, + + isCorrectViewAndRootFolder: function() { + // correct views = files & extstoragemounts + if (OCA.Files.App.getActiveView() === 'files' || OCA.Files.App.getActiveView() === 'extstoragemounts') { + return OCA.Files.App.getCurrentAppContainer().find('#dir').val() === '/'; + } + return false; + }, + + /* escape a selector expression for jQuery */ + jqSelEscape: function(expression) { + return expression.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]^`{|}~]/g, '\\$&'); + }, + + /* Copied from http://stackoverflow.com/questions/2631001/javascript-test-for-existence-of-nested-object-key */ + checkNested: function(cobj /*, level1, level2, ... levelN*/) { + var args = Array.prototype.slice.call(arguments), + obj = args.shift(); + + for (var i = 0; i < args.length; i++) { + if (!obj || !obj.hasOwnProperty(args[i])) { + return false; + } + obj = obj[args[i]]; + } + return true; + } +}; diff --git a/apps/files_external/js/statusmanagerutils.js b/apps/files_external/js/statusmanagerutils.js deleted file mode 100644 index 0ee6bc2a17e..00000000000 --- a/apps/files_external/js/statusmanagerutils.js +++ /dev/null @@ -1,158 +0,0 @@ -/** - * ownCloud - * - * @author Juan Pablo Villafañez Ramos - * @author Jesus Macias Portela - * @copyright (C) 2014 ownCloud, Inc. - * - * This code is covered by the ownCloud Commercial License. - * - * You should have received a copy of the ownCloud Commercial License - * along with this program. If not, see . - * - */ - -if (!OCA.External) { - OCA.External = {}; -} - -if (!OCA.External.StatusManager) { - OCA.External.StatusManager = {}; -} - -OCA.External.StatusManager.Utils = { - - showAlert: function(message){ - if (!OC.Notification.isHidden()) { - OC.Notification.hide(); - OC.Notification.showHtml(message); - } else { - OC.Notification.showHtml(message); - } - setTimeout(function() { - if ($("#notification").text() === message) { - OC.Notification.hide(); - } - }, 10000); - }, - - showIconError: function(folder, clickAction, errorImageUrl) { - var bgColor = '#F2DEDE'; - var imageUrl = "url(" + errorImageUrl + ")"; - var trFolder = $('#fileList tr[data-file=\"' + this.jqSelEscape(folder) + '\"]'); - this.changeFolderIcon(folder, imageUrl); - this.toggleLink(folder, false, clickAction); - trFolder.css('background-color', bgColor); - }, - - /** - * @param folder string with the folder or jQuery element pointing to the tr element - */ - storeDefaultFolderIconAndBgcolor: function(folder) { - var trFolder; - if (folder instanceof $) { - trFolder = folder; - } else { - trFolder = $('#fileList tr[data-file=\"' + this.jqSelEscape(folder) + '\"]'); - } - trFolder.each(function(){ - var thisElement = $(this); - if (thisElement.data('oldbgcolor') === undefined) { - thisElement.data('oldbgcolor', thisElement.css('background-color')); - } - }); - - var icon = trFolder.find('td:first-child div.thumbnail'); - icon.each(function(){ - var thisElement = $(this); - if (thisElement.data('oldImage') === undefined) { - thisElement.data('oldImage', thisElement.css('background-image')); - } - }); - }, - - /** - * @param folder string with the folder or jQuery element pointing to the tr element - */ - restoreFolder: function(folder) { - var trFolder; - if (folder instanceof $) { - trFolder = folder; - } else { - trFolder = $('#fileList tr[data-file=\"' + this.jqSelEscape(folder) + '\"]'); - } - trFolder.css('background-color', ''); - tdChilds = trFolder.find("td:first-child div.thumbnail"); - tdChilds.each(function(){ - var thisElement = $(this); - thisElement.css('background-image', thisElement.data('oldImage')); - }); - }, - - /** - * @param folder string with the folder or jQuery element pointing to the first td element - * of the tr matching the folder name - */ - changeFolderIcon: function(filename, route) { - var file; - if (filename instanceof $) { - file = filename; - } else { - file = $("#fileList tr[data-file=\"" + this.jqSelEscape(filename) + "\"] > td:first-child div.thumbnail"); - } - // file.css('background-image', route).hide().show(0); - // previous line is required in Chrome to force the css update so the image url - // is stored correctly later - //file.css('background-image', route).height(); - }, - - toggleLink: function(filename, active, action) { - var link; - if (filename instanceof $) { - link = filename; - } else { - link = $("#fileList tr[data-file=\"" + this.jqSelEscape(filename) + "\"] > td:first-child a.name"); - } - if (active) { - link.off('click.connectivity'); - OCA.Files.App.fileList.fileActions.display(link.parent(), true, OCA.Files.App.fileList); - } else { - link.find('.fileactions, .nametext .action').remove(); // from files/js/fileactions (display) - link.off('click.connectivity'); - link.on('click.connectivity', function(e){ - if (action && $.isFunction(action)) { - action(filename); - } - e.preventDefault(); - return false; - }); - } - }, - - isCorrectViewAndRootFolder: function() { - // correct views = files & extstoragemounts - if (OCA.Files.App.getActiveView() === 'files' || OCA.Files.App.getActiveView() === 'extstoragemounts') { - return OCA.Files.App.getCurrentAppContainer().find('#dir').val() === '/'; - } - return false; - }, - - /* escape a selector expression for jQuery */ - jqSelEscape: function(expression) { - return expression.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]^`{|}~]/g, '\\$&'); - }, - - /* Copied from http://stackoverflow.com/questions/2631001/javascript-test-for-existence-of-nested-object-key */ - checkNested: function(cobj /*, level1, level2, ... levelN*/) { - var args = Array.prototype.slice.call(arguments), - obj = args.shift(); - - for (var i = 0; i < args.length; i++) { - if (!obj || !obj.hasOwnProperty(args[i])) { - return false; - } - obj = obj[args[i]]; - } - return true; - } -}; diff --git a/apps/files_external/list.php b/apps/files_external/list.php index 831107c9c3f..0a994e147f5 100644 --- a/apps/files_external/list.php +++ b/apps/files_external/list.php @@ -25,7 +25,6 @@ $tmpl = new OCP\Template('files_external', 'list', ''); /* Load Status Manager */ \OCP\Util::addScript('files_external', 'statusmanager'); -\OCP\Util::addScript('files_external', 'statusmanagerutils'); \OCP\Util::addScript('files_external', 'rollingqueue'); OCP\Util::addScript('files_external', 'app'); -- cgit v1.2.3 From ae061bcbed3bdaaa8526e0d442b6c77f6909a1ab Mon Sep 17 00:00:00 2001 From: Jesús Macias Date: Wed, 18 Nov 2015 18:34:26 +0100 Subject: Fix code from PR comments --- apps/files_external/js/rollingqueue.js | 6 +- apps/files_external/js/statusmanager.js | 1134 ++++++++++++++----------------- 2 files changed, 525 insertions(+), 615 deletions(-) (limited to 'apps/files_external') diff --git a/apps/files_external/js/rollingqueue.js b/apps/files_external/js/rollingqueue.js index 7e6570a2a7c..0bff974414f 100644 --- a/apps/files_external/js/rollingqueue.js +++ b/apps/files_external/js/rollingqueue.js @@ -5,10 +5,10 @@ * @author Jesus Macias Portela * @copyright (C) 2014 ownCloud, Inc. * - * This code is covered by the ownCloud Commercial License. + * This file is licensed under the Affero General Public License version 3 + * or later. * - * You should have received a copy of the ownCloud Commercial License - * along with this program. If not, see . + * See the COPYING-README file. * */ diff --git a/apps/files_external/js/statusmanager.js b/apps/files_external/js/statusmanager.js index 244f5b6bd55..5f881532614 100644 --- a/apps/files_external/js/statusmanager.js +++ b/apps/files_external/js/statusmanager.js @@ -5,631 +5,541 @@ * @author Jesus Macias Portela * @copyright (C) 2014 ownCloud, Inc. * - * This code is covered by the ownCloud Commercial License. + * This file is licensed under the Affero General Public License version 3 + * or later. * - * You should have received a copy of the ownCloud Commercial License - * along with this program. If not, see . + * See the COPYING-README file. * */ if (!OCA.External) { - OCA.External = {}; + OCA.External = {}; } if (!OCA.External.StatusManager) { - OCA.External.StatusManager = {}; + OCA.External.StatusManager = {}; } OCA.External.StatusManager = { - mountStatus : null, - mountPointList : null, - - getMountStatus : function(afterCallback) { - var self = this; - if (typeof afterCallback !== 'function' || self.isGetMountStatusRunning) { - return; - } - - if (self.mountStatus) { - afterCallback(self.mountStatus); - } else { - self.isGetMountStatusRunning = true; - $.ajax({ - type : 'GET', - url : OC.filePath('files_external', 'ajax', 'connectivityCheck.php'), - success : function(response) { - self.mountStatus = response.data; - afterCallback(self.mountStatus); - }, - error : function(jqxhr, state, error) { - OCA.External.StatusManager.Utils.showAlert(t('files_external', 'Couldn\'t get the status of the external mounts: {type}', {type : error})); - if (!self.mountStatus) { - self.mountStatus = {}; - } - $.each(self.mountPointList, function(name, value){ - if (!self.mountStatus[value.mount_point]) { - self.mountStatus[value.mount_point] = {}; - } - self.mountStatus[value.mount_point].status = 'ok'; - OCA.External.StatusManager.Utils.restoreFolder(value); - OCA.External.StatusManager.Utils.toggleLink(value.mount_point, true, true); - }); - }, - complete : function() { - self.isGetMountStatusRunning = false; - } - }); - } - }, - - getMountPointListElement : function(mount_point) { - var element; - $.each(this.mountPointList, function(key, value){ - if (value.mount_point === mount_point) { - element = value; - return false; - } - }); - return element; - }, - - getMountStatusForMount : function(mountData, afterCallback) { - var self = this; - if (typeof afterCallback !== 'function' || self.isGetMountStatusRunning) { - return $.Deferred().resolve(); - } - - var defObj; - if (self.mountStatus[mountData.mount_point]) { - defObj = $.Deferred(); - afterCallback(mountData.mount_point, self.mountStatus[mountData.mount_point]); - defObj.resolve(); // not really useful, but it'll keep the same behaviour - } else { - defObj = $.ajax({ - type : 'GET', - url: OC.webroot + '/index.php/apps/files_external/globalstorages/' + mountData.id, - success : function(response) { - if (response && response.status === 0) { - self.mountStatus[mountData.mount_point] = response; - } else { - if (response && response.statusMessage) { - // failure response with error message - self.mountStatus[mountData.mount_point] = { type: mountData.type, - status: 1, - error: response.statusMessage}; - } else { - self.mountStatus[mountData.mount_point] = { type: mountData.type, - status: 1, - error: t('files_external', 'Empty response from the server')}; - } - } - afterCallback(mountData, self.mountStatus[mountData.mount_point]); - }, - error : function(jqxhr, state, error) { - var message; - if(mountData.location === 3){ - // In this case the error is because mount point use Login credentials and don't exist in the session - message = t('files_external', 'Couldn\'t access. Please logout and login to activate this mount point'); - } else { - message = t('files_external', 'Couldn\'t get the information from the ownCloud server: {code} {type}', {code: jqxhr.status, type: error}); - } - self.mountStatus[mountData.mount_point] = { type: mountData.type, - status: 1, - location: mountData.location, - error: message}; - afterCallback(mountData.mount_point, self.mountStatus[mountData.mount_point]); - } - }); - } - return defObj; - }, - - getMountPointList : function(afterCallback) { - var self = this; - if (typeof afterCallback !== 'function' || self.isGetMountPointListRunning) { - return; - } - - - if (self.mountPointList) { - afterCallback(self.mountPointList); - } else { - self.isGetMountPointListRunning = true; - $.ajax({ - type : 'GET', - url : OC.linkToOCS('apps/files_external/api/v1') + 'mounts?format=json', - success : function(response) { - self.mountPointList = []; - _.each(response.ocs.data, function(mount){ - var element = {}; - element.mount_point = mount.name; - element.type = mount.scope; - element.location = ""; - element.id = mount.id; - element.backendText = mount.backend; - element.backend = mount.class; - - self.mountPointList.push(element); - }); - afterCallback(self.mountPointList); - }, - error : function(jqxhr, state, error) { - self.mountPointList = []; - OCA.External.StatusManager.Utils.showAlert(t('files_external', 'Couldn\'t get the list of external mount points: {type}', {type : error})); - }, - complete : function() { - self.isGetMountPointListRunning = false; - } - }); - } - }, - - setMountPointAsGood : function(mountPoint) { - OCA.External.StatusManager.Utils.restoreFolder(mountPoint); - OCA.External.StatusManager.Utils.toggleLink(mountPoint, true, true); - delete this.mountStatus[mountPoint].code; - delete this.mountStatus[mountPoint].error; - this.mountStatus[mountPoint].status = 'ok'; - }, - - manageMountPointError : function(name) { - var self = this; - this.getMountStatus($.proxy(function(allMountStatus) { - if (typeof allMountStatus[name] !== 'undefined' || allMountStatus[name].status === 1) { - var mountData = allMountStatus[name]; - if (mountData.type === "system") { - OC.dialogs.confirm(t('files_external', 'There was an error with message: ') + mountData.error + '. Do you want to review mount point config in admin settings page?', t('files_external', 'External mount error'), function(e){ - if(e === true) { - window.location.href = OC.generateUrl('/settings/admin#files_external'); - } - }); - } else { - OC.dialogs.confirm(t('files_external', 'There was an error with message: ') + mountData.error + '. Do you want to review mount point config in personal settings page?', t('files_external', 'External mount error'), function(e){ - if(e === true) { - window.location.href = OC.generateUrl('/settings/personal#' + t('files_external', 'goto-external-storage')); - } - }); - } - } - }, this)); - }, - - showCredentialsDialog : function(mountPoint, mountData, extraParams, target, extraInfo, successCallback, callbackCtx) { - var self = this; - var baseParams = {target: target, - m: mountData.mid, - name: mountPoint, - url: mountData.url, - share: mountData.share, - extra: extraInfo}; - var sendParams = ($.isPlainObject(extraParams)) ? $.extend(baseParams, extraParams) : baseParams; - $.get(OC.filePath('files_external', 'ajax', 'dialog.php'), - sendParams, - function(data) { - if (typeof data.status !== 'undefined' && data.status === 0) { - $('body').append(data.form); - var wnd_send_button_click_func = function () { - $('.oc-dialog-close').hide(); - var dataToSend = {}; - $('#wnd_div_form').find('input').each(function(){ - var thisElement = $(this); - if (thisElement.is('[type="checkbox"]')) { - dataToSend[thisElement.attr('name')] = thisElement.prop('checked'); - } else { - dataToSend[thisElement.attr('name')] = thisElement.val(); - } - }); - $.ajax({type: 'POST', - url: $('#wnd_div_form form').attr('action'), - data: dataToSend, - success: function (data) { - var dialog = $('#wnd_div_form'); - if (typeof(data.status) !== 'undefined' && data.status === 0) { - dialog.ocdialog('close'); - - if (successCallback && $.isFunction(successCallback)) { - successCallback.call(callbackCtx || this, mountPoint); - } - } else { - $('.oc-dialog-close').show(); - dialog.ocdialog('option', 'title', 'Windows Network Drive credentials validation failed'); - var title = $('.oc-dialog-title'); - var color = title.css('background-color'); - title.css('background-color', 'red'); - title.animate({backgroundColor: color}, 5000); - } - }, - error: function (){ - $('.oc-dialog-close').show(); - }}); - }; - - var buttonList = [{text : t('files_external', 'Save'), - click : wnd_send_button_click_func, - closeOnEscape : true}]; - - var ocdialogParams = {modal: true, buttons : buttonList, - closeOnExcape : true}; - $('#wnd_div_form').ocdialog(ocdialogParams) - .bind('ocdialogclose', function(){ - $('#wnd_div_form').ocdialog('destroy').remove(); - }); - } - }); - }, - - processMountStatus : function(mounts) { - var hasErrors = false; - var self = this; - $.each(mounts, function(mountPoint, values){ - hasErrors = !self.processMountStatusIndividual(mountPoint, values) || hasErrors; - }); - - if (!this.notificationHasShown) { - this.notificationHasShown = true; - if (hasErrors) { - OCA.External.StatusManager.Utils.showAlert(t('files_external', 'Some of the configured external mount points are not connected. Please click on the red row(s) for more information')); - } - } - }, - - processMountStatusIndividual : function(mountData, mountStatus) { - var mountPoint = mountData.mount_point; - if (mountStatus.status === 1) { - var trElement = $('#fileList tr[data-file=\"' + OCA.External.StatusManager.Utils.jqSelEscape(mountPoint) + '\"]'); - - route = OCA.External.StatusManager.Utils.getIconRoute(trElement) + '-error'; - - if (OCA.External.StatusManager.Utils.isCorrectViewAndRootFolder()) { - OCA.External.StatusManager.Utils.showIconError(mountPoint, $.proxy(OCA.External.StatusManager.manageMountPointError, OCA.External.StatusManager), route); - } - return false; - } else { - if (OCA.External.StatusManager.Utils.isCorrectViewAndRootFolder()) { - OCA.External.StatusManager.Utils.restoreFolder(mountPoint); - OCA.External.StatusManager.Utils.toggleLink(mountPoint, true, true); - } - return true; - } - }, - - processMountList : function(mountList) { - var elementList = null; - $.each(mountList, function(name, value){ - var trElement = $('#fileList tr[data-file=\"' + OCA.External.StatusManager.Utils.jqSelEscape(value.mount_point) + '\"]'); - trElement.attr('data-external-backend', value.backend); - if (elementList) { - elementList = elementList.add(trElement); - } else { - elementList = trElement; - } - }); - - if (elementList instanceof $) { - if (OCA.External.StatusManager.Utils.isCorrectViewAndRootFolder()) { - // Put their custom icon - OCA.External.StatusManager.Utils.changeFolderIcon(elementList); - // Save default view - OCA.External.StatusManager.Utils.storeDefaultFolderIconAndBgcolor(elementList); - // Disable row until check status - elementList.css('background-color', '#CCC'); - OCA.External.StatusManager.Utils.toggleLink(elementList.find('a.name'), false, false); - } - } - }, - - launchFullConnectivityCheck : function() { - var self = this; - this.getMountPointList(function(list){ - // check if we have a list first - if (list === undefined && !self.emptyWarningShown) { - self.emptyWarningShown = true; - OCA.External.StatusManager.Utils.showAlert(t('files_external', 'Couldn\'t get the list of external mount points: empty response from the server')); - return; - } - if (list && list.length > 0) { - self.processMountList(list); - self.getMountStatus(function(mountStatus){ - if (mountStatus === undefined && !self.notificationNoProcessListDone) { - self.notificationNoProcessListDone = true; - OCA.External.StatusManager.Utils.showAlert(t('files_external', 'Couldn\'t get the status of the external mounts: empty response from the server')); - if (!self.mountStatus) { - self.mountStatus = {}; - } - $.each(list, function(name, value){ - if (!self.mountStatus[value.mount_point]) { - self.mountStatus[value.mount_point] = {}; - } - self.mountStatus[value.mount_point].status = 'ok'; - OCA.External.StatusManager.Utils.restoreFolder(value.mount_point); - OCA.External.StatusManager.Utils.toggleLink(value.mount_point, true, true); - }); - return; - } - self.processMountStatus(mountStatus); - }); - } - }); - }, - - launchFullConnectivityCheckOneByOne : function() { - var self = this; - this.getMountPointList(function(list){ - // check if we have a list first - if (list === undefined && !self.emptyWarningShown) { - self.emptyWarningShown = true; - OCA.External.StatusManager.Utils.showAlert(t('files_external', 'Couldn\'t get the list of Windows network drive mount points: empty response from the server')); - return; - } - if (list && list.length > 0) { - self.processMountList(list); - - if (!self.mountStatus) { - self.mountStatus = {}; - } - - var ajaxQueue = []; - $.each(list, function(key, value){ - var queueElement = {funcName: $.proxy(self.getMountStatusForMount, self), - funcArgs: [value, - $.proxy(self.processMountStatusIndividual, self)]}; - ajaxQueue.push(queueElement); - }); - - var rolQueue = new OCA.External.StatusManager.RollingQueue(ajaxQueue, 4, function(){ - if (!self.notificationHasShown) { - var showNotification = false; - $.each(self.mountStatus, function(key, value){ - if (value.status === 1) { - self.notificationHasShown = true; - showNotification = true; - } - }); - if (showNotification) { - OCA.External.StatusManager.Utils.showAlert(t('files_external', 'Some of the configured external mount points are not connected. Please click on the red row(s) for more information')); - } - } - }); - rolQueue.runQueue(); - } - }); - }, - - launchPartialConnectivityCheck : function(mountListData, recheck) { - if (mountListData.length === 0) { - return; - } - - var self = this; - var ajaxQueue = []; - $.each(mountListData, function(key, value){ - if (recheck && value.mount_point in self.mountStatus) { - delete self.mountStatus[value.mount_point]; - } - var queueElement = {funcName: $.proxy(self.getMountStatusForMount, self), - funcArgs: [value, - $.proxy(self.processMountStatusIndividual, self)]}; - ajaxQueue.push(queueElement); - }); - new OCA.External.StatusManager.RollingQueue(ajaxQueue, 4).runQueue(); - }, - - recheckConnectivityForMount : function(mountListNames, recheck, checkGlobal) { - if (mountListNames.length === 0) { - return; - } - - var self = this; - var mountListData = []; - var recheckPersonalGlobal = false; - var recheckAdminGlobal = false; - - if (!self.mountStatus) { - self.mountStatus = {}; - } - - $.each(mountListNames, function(key, value){ - var mountData = self.getMountPointListElement(value); - if (mountData) { - if (mountData.type === 'personal' && mountData.location === 2) { - recheckPersonalGlobal = true; - } - if (mountData.type === 'admin' && mountData.location === 2) { - recheckAdminGlobal = true; - } - mountListData.push(mountData); - } - }); - - // we might need to check more mounts if a personal mount with global credentials is affected - if (checkGlobal && (recheckPersonalGlobal || recheckAdminGlobal)) { - $.each(self.mountPointList, function(key, value){ - if (((recheckPersonalGlobal && value.type === 'personal') || (recheckAdminGlobal && value.type === 'admin')) && - value.location === 2 && - $.inArray(value, mountListData) === -1) { - // personal mount using global credentials, not present in the mountListData - mountListData.push(value); - } - }); - } - - // for all mounts in the list, delete the cached status values - if (recheck) { - $.each(mountListData, function(key, value){ - if (value.mount_point in self.mountStatus) { - delete self.mountStatus[value.mount_point]; - } - }); - } - - self.processMountList(mountListData); - self.launchPartialConnectivityCheck(mountListData, recheck); - } + mountStatus : null, + mountPointList : null, + + getMountStatus : function(afterCallback) { + var self = this; + if (typeof afterCallback !== 'function' || self.isGetMountStatusRunning) { + return; + } + + if (self.mountStatus) { + afterCallback(self.mountStatus); + } else { + self.isGetMountStatusRunning = true; + $.ajax({ + type : 'GET', + url : OC.filePath('files_external', 'ajax', 'connectivityCheck.php'), + success : function(response) { + self.mountStatus = response.data; + afterCallback(self.mountStatus); + }, + error : function(jqxhr, state, error) { + OC.Notification.showTemporary(t('files_external', 'Couldn\'t get the status of the external mounts: {type}', {type : error})); + if (!self.mountStatus) { + self.mountStatus = {}; + } + $.each(self.mountPointList, function(name, value){ + if (!self.mountStatus[value.mount_point]) { + self.mountStatus[value.mount_point] = {}; + } + self.mountStatus[value.mount_point].status = 'ok'; + OCA.External.StatusManager.Utils.restoreFolder(value); + OCA.External.StatusManager.Utils.toggleLink(value.mount_point, true, true); + }); + }, + complete : function() { + self.isGetMountStatusRunning = false; + } + }); + } + }, + + getMountPointListElement : function(mount_point) { + var element; + $.each(this.mountPointList, function(key, value){ + if (value.mount_point === mount_point) { + element = value; + return false; + } + }); + return element; + }, + + getMountStatusForMount : function(mountData, afterCallback) { + var self = this; + if (typeof afterCallback !== 'function' || self.isGetMountStatusRunning) { + return $.Deferred().resolve(); + } + + var defObj; + if (self.mountStatus[mountData.mount_point]) { + defObj = $.Deferred(); + afterCallback(mountData, self.mountStatus[mountData.mount_point]); + defObj.resolve(); // not really useful, but it'll keep the same behaviour + } else { + defObj = $.ajax({ + type : 'GET', + url: OC.webroot + '/index.php/apps/files_external/globalstorages/' + mountData.id, + success : function(response) { + if (response && response.status === 0) { + self.mountStatus[mountData.mount_point] = response; + } else { + if (response && response.statusMessage) { + // failure response with error message + self.mountStatus[mountData.mount_point] = { type: mountData.type, + status: 1, + error: response.statusMessage}; + } else { + self.mountStatus[mountData.mount_point] = { type: mountData.type, + status: 1, + error: t('files_external', 'Empty response from the server')}; + } + } + afterCallback(mountData, self.mountStatus[mountData.mount_point]); + }, + error : function(jqxhr, state, error) { + var message; + if(mountData.location === 3){ + // In this case the error is because mount point use Login credentials and don't exist in the session + message = t('files_external', 'Couldn\'t access. Please logout and login to activate this mount point'); + } else { + message = t('files_external', 'Couldn\'t get the information from the ownCloud server: {code} {type}', {code: jqxhr.status, type: error}); + } + self.mountStatus[mountData.mount_point] = { type: mountData.type, + status: 1, + location: mountData.location, + error: message}; + afterCallback(mountData, self.mountStatus[mountData.mount_point]); + } + }); + } + return defObj; + }, + + getMountPointList : function(afterCallback) { + var self = this; + if (typeof afterCallback !== 'function' || self.isGetMountPointListRunning) { + return; + } + + + if (self.mountPointList) { + afterCallback(self.mountPointList); + } else { + self.isGetMountPointListRunning = true; + $.ajax({ + type : 'GET', + url : OC.linkToOCS('apps/files_external/api/v1') + 'mounts?format=json', + success : function(response) { + self.mountPointList = []; + _.each(response.ocs.data, function(mount){ + var element = {}; + element.mount_point = mount.name; + element.type = mount.scope; + element.location = ""; + element.id = mount.id; + element.backendText = mount.backend; + element.backend = mount.class; + + self.mountPointList.push(element); + }); + afterCallback(self.mountPointList); + }, + error : function(jqxhr, state, error) { + self.mountPointList = []; + OC.Notification.showTemporary(t('files_external', 'Couldn\'t get the list of external mount points: {type}', {type : error})); + }, + complete : function() { + self.isGetMountPointListRunning = false; + } + }); + } + }, + + setMountPointAsGood : function(mountPoint) { + OCA.External.StatusManager.Utils.restoreFolder(mountPoint); + OCA.External.StatusManager.Utils.toggleLink(mountPoint, true, true); + delete this.mountStatus[mountPoint].code; + delete this.mountStatus[mountPoint].error; + this.mountStatus[mountPoint].status = 'ok'; + }, + + manageMountPointError : function(name) { + var self = this; + this.getMountStatus($.proxy(function(allMountStatus) { + if (typeof allMountStatus[name] !== 'undefined' || allMountStatus[name].status === 1) { + var mountData = allMountStatus[name]; + if (mountData.type === "system") { + OC.dialogs.confirm(t('files_external', 'There was an error with message: ') + mountData.error + '. Do you want to review mount point config in admin settings page?', t('files_external', 'External mount error'), function(e){ + if(e === true) { + window.location.href = OC.generateUrl('/settings/admin#files_external'); + } + }); + } else { + OC.dialogs.confirm(t('files_external', 'There was an error with message: ') + mountData.error + '. Do you want to review mount point config in personal settings page?', t('files_external', 'External mount error'), function(e){ + if(e === true) { + window.location.href = OC.generateUrl('/settings/personal#' + t('files_external', 'goto-external-storage')); + } + }); + } + } + }, this)); + }, + + + processMountStatus : function(mounts) { + var hasErrors = false; + var self = this; + $.each(mounts, function(mountPoint, values){ + hasErrors = !self.processMountStatusIndividual(mountPoint, values) || hasErrors; + }); + + if (!this.notificationHasShown) { + this.notificationHasShown = true; + if (hasErrors) { + OC.Notification.showTemporary(t('files_external', 'Some of the configured external mount points are not connected. Please click on the red row(s) for more information')); + } + } + }, + + processMountStatusIndividual : function(mountData, mountStatus) { + + var mountPoint = mountData.mount_point; + if (mountStatus.status === 1) { + var trElement = FileList.findFileEl(OCA.External.StatusManager.Utils.jqSelEscape(mountPoint)); //$('#fileList tr[data-file=\"' + OCA.External.StatusManager.Utils.jqSelEscape(mountPoint) + '\"]'); + + route = OCA.External.StatusManager.Utils.getIconRoute(trElement) + '-error'; + + if (OCA.External.StatusManager.Utils.isCorrectViewAndRootFolder()) { + OCA.External.StatusManager.Utils.showIconError(mountPoint, $.proxy(OCA.External.StatusManager.manageMountPointError, OCA.External.StatusManager), route); + } + return false; + } else { + if (OCA.External.StatusManager.Utils.isCorrectViewAndRootFolder()) { + OCA.External.StatusManager.Utils.restoreFolder(mountPoint); + OCA.External.StatusManager.Utils.toggleLink(mountPoint, true, true); + } + return true; + } + }, + + processMountList : function(mountList) { + var elementList = null; + $.each(mountList, function(name, value){ + var trElement = $('#fileList tr[data-file=\"' + OCA.External.StatusManager.Utils.jqSelEscape(value.mount_point) + '\"]'); //FileList.findFileEl(OCA.External.StatusManager.Utils.jqSelEscape(value.mount_point)); + trElement.attr('data-external-backend', value.backend); + if (elementList) { + elementList = elementList.add(trElement); + } else { + elementList = trElement; + } + }); + + if (elementList instanceof $) { + if (OCA.External.StatusManager.Utils.isCorrectViewAndRootFolder()) { + // Put their custom icon + OCA.External.StatusManager.Utils.changeFolderIcon(elementList); + // Save default view + OCA.External.StatusManager.Utils.storeDefaultFolderIconAndBgcolor(elementList); + // Disable row until check status + elementList.css('background-color', '#CCC'); + OCA.External.StatusManager.Utils.toggleLink(elementList.find('a.name'), false, false); + } + } + }, + + launchFullConnectivityCheck : function() { + var self = this; + this.getMountPointList(function(list){ + // check if we have a list first + if (list === undefined && !self.emptyWarningShown) { + self.emptyWarningShown = true; + OC.Notification.showTemporary(t('files_external', 'Couldn\'t get the list of external mount points: empty response from the server')); + return; + } + if (list && list.length > 0) { + self.processMountList(list); + self.getMountStatus(function(mountStatus){ + if (mountStatus === undefined && !self.notificationNoProcessListDone) { + self.notificationNoProcessListDone = true; + OC.Notification.showTemporary(t('files_external', 'Couldn\'t get the status of the external mounts: empty response from the server')); + if (!self.mountStatus) { + self.mountStatus = {}; + } + $.each(list, function(name, value){ + if (!self.mountStatus[value.mount_point]) { + self.mountStatus[value.mount_point] = {}; + } + self.mountStatus[value.mount_point].status = 'ok'; + OCA.External.StatusManager.Utils.restoreFolder(value.mount_point); + OCA.External.StatusManager.Utils.toggleLink(value.mount_point, true, true); + }); + return; + } + self.processMountStatus(mountStatus); + }); + } + }); + }, + + launchFullConnectivityCheckOneByOne : function() { + var self = this; + this.getMountPointList(function(list){ + // check if we have a list first + if (list === undefined && !self.emptyWarningShown) { + self.emptyWarningShown = true; + OC.Notification.showTemporary(t('files_external', 'Couldn\'t get the list of Windows network drive mount points: empty response from the server')); + return; + } + if (list && list.length > 0) { + self.processMountList(list); + + if (!self.mountStatus) { + self.mountStatus = {}; + } + + var ajaxQueue = []; + $.each(list, function(key, value){ + var queueElement = {funcName: $.proxy(self.getMountStatusForMount, self), + funcArgs: [value, + $.proxy(self.processMountStatusIndividual, self)]}; + ajaxQueue.push(queueElement); + }); + + var rolQueue = new OCA.External.StatusManager.RollingQueue(ajaxQueue, 4, function(){ + if (!self.notificationHasShown) { + var showNotification = false; + $.each(self.mountStatus, function(key, value){ + if (value.status === 1) { + self.notificationHasShown = true; + showNotification = true; + } + }); + if (showNotification) { + OC.Notification.showTemporary(t('files_external', 'Some of the configured external mount points are not connected. Please click on the red row(s) for more information')); + } + } + }); + rolQueue.runQueue(); + } + }); + }, + + launchPartialConnectivityCheck : function(mountListData, recheck) { + if (mountListData.length === 0) { + return; + } + + var self = this; + var ajaxQueue = []; + $.each(mountListData, function(key, value){ + if (recheck && value.mount_point in self.mountStatus) { + delete self.mountStatus[value.mount_point]; + } + var queueElement = {funcName: $.proxy(self.getMountStatusForMount, self), + funcArgs: [value, + $.proxy(self.processMountStatusIndividual, self)]}; + ajaxQueue.push(queueElement); + }); + new OCA.External.StatusManager.RollingQueue(ajaxQueue, 4).runQueue(); + }, + + recheckConnectivityForMount : function(mountListNames, recheck, checkGlobal) { + if (mountListNames.length === 0) { + return; + } + + var self = this; + var mountListData = []; + var recheckPersonalGlobal = false; + var recheckAdminGlobal = false; + + if (!self.mountStatus) { + self.mountStatus = {}; + } + + $.each(mountListNames, function(key, value){ + var mountData = self.getMountPointListElement(value); + if (mountData) { + mountListData.push(mountData); + } + }); + + // for all mounts in the list, delete the cached status values + if (recheck) { + $.each(mountListData, function(key, value){ + if (value.mount_point in self.mountStatus) { + delete self.mountStatus[value.mount_point]; + } + }); + } + + self.processMountList(mountListData); + self.launchPartialConnectivityCheck(mountListData, recheck); + } }; OCA.External.StatusManager.Utils = { - showAlert: function(message){ - if (!OC.Notification.isHidden()) { - OC.Notification.hide(); - OC.Notification.showHtml(message); - } else { - OC.Notification.showHtml(message); - } - setTimeout(function() { - if ($("#notification").text() === message) { - OC.Notification.hide(); - } - }, 10000); - }, - - showIconError: function(folder, clickAction, errorImageUrl) { - var bgColor = '#F2DEDE'; - var imageUrl = "url(" + errorImageUrl + ")"; - var trFolder = $('#fileList tr[data-file=\"' + this.jqSelEscape(folder) + '\"]'); - this.changeFolderIcon(folder, imageUrl); - this.toggleLink(folder, false, clickAction); - trFolder.css('background-color', bgColor); - }, - - /** - * @param folder string with the folder or jQuery element pointing to the tr element - */ - storeDefaultFolderIconAndBgcolor: function(folder) { - var trFolder; - if (folder instanceof $) { - trFolder = folder; - } else { - trFolder = $('#fileList tr[data-file=\"' + this.jqSelEscape(folder) + '\"]'); - } - trFolder.each(function(){ - var thisElement = $(this); - if (thisElement.data('oldbgcolor') === undefined) { - thisElement.data('oldbgcolor', thisElement.css('background-color')); - } - }); - - var icon = trFolder.find('td:first-child div.thumbnail'); - icon.each(function(){ - var thisElement = $(this); - if (thisElement.data('oldImage') === undefined) { - thisElement.data('oldImage', thisElement.css('background-image')); - } - }); - }, - - /** - * @param folder string with the folder or jQuery element pointing to the tr element - */ - restoreFolder: function(folder) { - var trFolder; - if (folder instanceof $) { - trFolder = folder; - } else { - trFolder = $('#fileList tr[data-file=\"' + this.jqSelEscape(folder) + '\"]'); - } - trFolder.css('background-color', ''); - tdChilds = trFolder.find("td:first-child div.thumbnail"); - tdChilds.each(function(){ - var thisElement = $(this); - thisElement.css('background-image', thisElement.data('oldImage')); - }); - }, - - /** - * @param folder string with the folder or jQuery element pointing to the first td element - * of the tr matching the folder name - */ - changeFolderIcon: function(filename) { - var file; - var route; - if (filename instanceof $) { - //trElementList - $.each(filename, function(index){ - route = OCA.External.StatusManager.Utils.getIconRoute($(this)); - $(this).attr("data-icon", route); - $(this).find('td:first-child div.thumbnail').css('background-image', "url(" + route + ")").css('display', 'none').css('display', 'inline'); - }); - } else { - file = $("#fileList tr[data-file=\"" + this.jqSelEscape(filename) + "\"] > td:first-child div.thumbnail"); - parentTr = file.parents('tr:first'); - route = OCA.External.StatusManager.Utils.getIconRoute(parentTr); - parentTr.attr("data-icon", route); - file.css('background-image', "url(" + route + ")").css('display', 'none').css('display', 'inline'); - } - }, - - /** - * @param backend string with the name of the external storage backend - * of the tr matching the folder name - */ - getIconRoute: function(tr) { - var icon = OC.imagePath('core', 'filetypes/folder-external'); - var backend = null; - - if (tr instanceof $) { - backend = tr.attr('data-external-backend'); - } - - switch (backend) { - case 'smb': - icon = OC.imagePath('windows_network_drive', 'folder-windows'); - break; - case 'sharepoint': - icon = OC.imagePath('sharepoint', 'folder-sharepoint'); - break; - } - - return icon; - }, - - toggleLink: function(filename, active, action) { - var link; - if (filename instanceof $) { - link = filename; - } else { - link = $("#fileList tr[data-file=\"" + this.jqSelEscape(filename) + "\"] > td:first-child a.name"); - } - if (active) { - link.off('click.connectivity'); - OCA.Files.App.fileList.fileActions.display(link.parent(), true, OCA.Files.App.fileList); - } else { - link.find('.fileactions, .nametext .action').remove(); // from files/js/fileactions (display) - link.off('click.connectivity'); - link.on('click.connectivity', function(e){ - if (action && $.isFunction(action)) { - action(filename); - } - e.preventDefault(); - return false; - }); - } - }, - - isCorrectViewAndRootFolder: function() { - // correct views = files & extstoragemounts - if (OCA.Files.App.getActiveView() === 'files' || OCA.Files.App.getActiveView() === 'extstoragemounts') { - return OCA.Files.App.getCurrentAppContainer().find('#dir').val() === '/'; - } - return false; - }, - - /* escape a selector expression for jQuery */ - jqSelEscape: function(expression) { - return expression.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]^`{|}~]/g, '\\$&'); - }, - - /* Copied from http://stackoverflow.com/questions/2631001/javascript-test-for-existence-of-nested-object-key */ - checkNested: function(cobj /*, level1, level2, ... levelN*/) { - var args = Array.prototype.slice.call(arguments), - obj = args.shift(); - - for (var i = 0; i < args.length; i++) { - if (!obj || !obj.hasOwnProperty(args[i])) { - return false; - } - obj = obj[args[i]]; - } - return true; - } + showIconError: function(folder, clickAction, errorImageUrl) { + var bgColor = '#F2DEDE'; + var imageUrl = "url(" + errorImageUrl + ")"; + var trFolder = $('#fileList tr[data-file=\"' + OCA.External.StatusManager.Utils.jqSelEscape(folder) + '\"]'); //FileList.findFileEl(OCA.External.StatusManager.Utils.jqSelEscape(folder)); + this.changeFolderIcon(folder, imageUrl); + this.toggleLink(folder, false, clickAction); + trFolder.css('background-color', bgColor); + }, + + /** + * @param folder string with the folder or jQuery element pointing to the tr element + */ + storeDefaultFolderIconAndBgcolor: function(folder) { + var trFolder; + if (folder instanceof $) { + trFolder = folder; + } else { + trFolder = $('#fileList tr[data-file=\"' + OCA.External.StatusManager.Utils.jqSelEscape(folder) + '\"]'); //FileList.findFileEl(OCA.External.StatusManager.Utils.jqSelEscape(folder)); //$('#fileList tr[data-file=\"' + OCA.External.StatusManager.Utils.jqSelEscape(folder) + '\"]'); + } + trFolder.each(function(){ + var thisElement = $(this); + if (thisElement.data('oldbgcolor') === undefined) { + thisElement.data('oldbgcolor', thisElement.css('background-color')); + } + }); + + var icon = trFolder.find('td:first-child div.thumbnail'); + icon.each(function(){ + var thisElement = $(this); + if (thisElement.data('oldImage') === undefined) { + thisElement.data('oldImage', thisElement.css('background-image')); + } + }); + }, + + /** + * @param folder string with the folder or jQuery element pointing to the tr element + */ + restoreFolder: function(folder) { + var trFolder; + if (folder instanceof $) { + trFolder = folder; + } else { + // cant use here FileList.findFileEl(OCA.External.StatusManager.Utils.jqSelEscape(folder)); return incorrect instance of filelist + trFolder = $('#fileList tr[data-file=\"' + OCA.External.StatusManager.Utils.jqSelEscape(folder) + '\"]'); + } + trFolder.css('background-color', ''); + tdChilds = trFolder.find("td:first-child div.thumbnail"); + tdChilds.each(function(){ + var thisElement = $(this); + thisElement.css('background-image', thisElement.data('oldImage')); + }); + }, + + /** + * @param folder string with the folder or jQuery element pointing to the first td element + * of the tr matching the folder name + */ + changeFolderIcon: function(filename) { + var file; + var route; + if (filename instanceof $) { + //trElementList + $.each(filename, function(index){ + route = OCA.External.StatusManager.Utils.getIconRoute($(this)); + $(this).attr("data-icon", route); + $(this).find('td:first-child div.thumbnail').css('background-image', "url(" + route + ")").css('display', 'none').css('display', 'inline'); + }); + } else { + file = $("#fileList tr[data-file=\"" + this.jqSelEscape(filename) + "\"] > td:first-child div.thumbnail"); + parentTr = file.parents('tr:first'); + route = OCA.External.StatusManager.Utils.getIconRoute(parentTr); + parentTr.attr("data-icon", route); + file.css('background-image', "url(" + route + ")").css('display', 'none').css('display', 'inline'); + } + }, + + /** + * @param backend string with the name of the external storage backend + * of the tr matching the folder name + */ + getIconRoute: function(tr) { + var icon = OC.imagePath('core', 'filetypes/folder-external'); + var backend = null; + + if (tr instanceof $) { + backend = tr.attr('data-external-backend'); + } + + switch (backend) { + case 'smb': + icon = OC.imagePath('windows_network_drive', 'folder-windows'); + break; + case 'sharepoint': + icon = OC.imagePath('sharepoint', 'folder-sharepoint'); + break; + } + + return icon; + }, + + toggleLink: function(filename, active, action) { + var link; + if (filename instanceof $) { + link = filename; + } else { + link = $("#fileList tr[data-file=\"" + this.jqSelEscape(filename) + "\"] > td:first-child a.name"); + } + if (active) { + link.off('click.connectivity'); + OCA.Files.App.fileList.fileActions.display(link.parent(), true, OCA.Files.App.fileList); + } else { + link.find('.fileactions, .nametext .action').remove(); // from files/js/fileactions (display) + link.off('click.connectivity'); + link.on('click.connectivity', function(e){ + if (action && $.isFunction(action)) { + action(filename); + } + e.preventDefault(); + return false; + }); + } + }, + + isCorrectViewAndRootFolder: function() { + // correct views = files & extstoragemounts + if (OCA.Files.App.getActiveView() === 'files' || OCA.Files.App.getActiveView() === 'extstoragemounts') { + return OCA.Files.App.getCurrentAppContainer().find('#dir').val() === '/'; + } + return false; + }, + + /* escape a selector expression for jQuery */ + jqSelEscape: function(expression) { + if(expression){ + return expression.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]^`{|}~]/g, '\\$&'); + } + return null; + }, + + /* Copied from http://stackoverflow.com/questions/2631001/javascript-test-for-existence-of-nested-object-key */ + checkNested: function(cobj /*, level1, level2, ... levelN*/) { + var args = Array.prototype.slice.call(arguments), + obj = args.shift(); + + for (var i = 0; i < args.length; i++) { + if (!obj || !obj.hasOwnProperty(args[i])) { + return false; + } + obj = obj[args[i]]; + } + return true; + } }; -- cgit v1.2.3 From 31cfd43e8ad95bec0086409597c35294b7d19df6 Mon Sep 17 00:00:00 2001 From: Jesús Macias Date: Fri, 20 Nov 2015 08:42:31 +0100 Subject: Adding logic to show custom icon for current backends, waiting for icon files --- apps/files_external/js/statusmanager.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'apps/files_external') diff --git a/apps/files_external/js/statusmanager.js b/apps/files_external/js/statusmanager.js index 5f881532614..5c60c935e9d 100644 --- a/apps/files_external/js/statusmanager.js +++ b/apps/files_external/js/statusmanager.js @@ -485,6 +485,30 @@ OCA.External.StatusManager.Utils = { case 'sharepoint': icon = OC.imagePath('sharepoint', 'folder-sharepoint'); break; + case 'amazons3': + icon = OC.imagePath('core', 'filesystem/folder-external'); + break; + case 'dav': + icon = OC.imagePath('core', 'filesystem/folder-external'); + break; + case 'dropbox': + icon = OC.imagePath('core', 'filesystem/folder-external'); + break; + case 'ftp': + icon = OC.imagePath('core', 'filesystem/folder-external'); + break; + case 'google': + icon = OC.imagePath('core', 'filesystem/folder-external'); + break; + case 'owncloud': + icon = OC.imagePath('core', 'filesystem/folder-external'); + break; + case 'sftp': + icon = OC.imagePath('core', 'filesystem/folder-external'); + break; + case 'swift': + icon = OC.imagePath('core', 'filesystem/folder-external'); + break; } return icon; -- cgit v1.2.3 From 5b9a693fbc73b5bed59197af0f9961605cea11ec Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Fri, 20 Nov 2015 16:00:16 +0100 Subject: Added some unit tests for the status manager --- apps/files_external/tests/js/statusmanagerSpec.js | 205 ++++++++++++++++++++++ tests/karma.config.js | 3 +- 2 files changed, 207 insertions(+), 1 deletion(-) create mode 100644 apps/files_external/tests/js/statusmanagerSpec.js (limited to 'apps/files_external') diff --git a/apps/files_external/tests/js/statusmanagerSpec.js b/apps/files_external/tests/js/statusmanagerSpec.js new file mode 100644 index 00000000000..975d71627bf --- /dev/null +++ b/apps/files_external/tests/js/statusmanagerSpec.js @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2015 Vincent Petry + * + * This file is licensed under the Affero General Public License version 3 + * or later. + * + * See the COPYING-README file. + * + */ + +describe('OCA.External.StatusManager tests', function() { + var notificationStub; + var fileList; + var statusManager; + var oldAppWebRoots; + + beforeEach(function() { + notificationStub = sinon.stub(OC.Notification, 'showTemporary'); + var $content = $('
'); + $('#testArea').append($content); + // dummy file list + var $div = $( + '
' + + '' + + '' + + '' + + '' + + '
' + + '
'); + $('#content').append($div); + + var fileActions = new OCA.Files.FileActions(); + fileList = new OCA.Files.FileList( + $div, { + fileActions : fileActions + } + ); + + fileList.add({ + id: 1, + type: 'folder', + name: 'testmount', + mountType: 'external-root', + path: '/', + mimetype: 'httpd/unix-directory', + size: 12, + permissions: OC.PERMISSION_ALL, + etag: 'abc' + }); + + statusManager = OCA.External.StatusManager; + + oldAppWebRoots = _.extend({}, OC.appswebroots); + OC.appswebroots['files_external'] = OC.webroot + '/apps/files_external'; + }); + afterEach(function() { + statusManager.mountStatus = null; + statusManager.mountPointList = null; + + notificationStub.restore(); + OC.appswebroots = oldAppWebRoots; + }); + + describe('getMountStatusForMount', function() { + beforeEach(function() { + statusManager.mountStatus = []; + }); + + it('retrieves mount status and passes it to callback', function() { + var mountData = { + id: 123, + type: 'smb', + mount_point: 'testmount', + location: 3 + }; + + var callbackStub = sinon.stub(); + statusManager.getMountStatusForMount(mountData, callbackStub); + + expect(fakeServer.requests.length).toEqual(1); + + var mountStatus = { + type: 'smb', + status: 0 + }; + + var jsonData = JSON.stringify(mountStatus); + var request = fakeServer.requests[0]; + + expect(request.url).toEqual(OC.webroot + '/index.php/apps/files_external/globalstorages/123'); + + fakeServer.requests[0].respond( + 200, + {'Content-Type': 'application/json'}, + jsonData + ); + + + expect(callbackStub.calledOnce).toEqual(true); + expect(callbackStub.getCall(0).args[0]).toEqual(mountData); + expect(callbackStub.getCall(0).args[1]).toEqual(mountStatus); + + // second call does not send request but returns known data + statusManager.getMountStatusForMount(mountData, callbackStub); + + expect(fakeServer.requests.length).toEqual(1); + + expect(callbackStub.calledTwice).toEqual(true); + expect(callbackStub.getCall(1).args[0]).toEqual(mountData); + expect(callbackStub.getCall(1).args[1]).toEqual(mountStatus); + }); + // TODO: case where status is not 0 + // TODO: error case + }); + describe('getMountPointList', function() { + // TODO + }); + describe('processMountList', function() { + var getActiveViewStub; + var getCurrentAppContainerStub; + + beforeEach(function() { + getActiveViewStub = sinon.stub(OCA.Files.App, 'getActiveView'); + getActiveViewStub.returns('files'); + getCurrentAppContainerStub = sinon.stub(OCA.Files.App, 'getCurrentAppContainer'); + getCurrentAppContainerStub.returns($('#testArea')); + }); + afterEach(function() { + getActiveViewStub.restore(); + getCurrentAppContainerStub.restore(); + }); + + it('updates file list element with status', function() { + var mountList = [{ + id: 123, + mount_point: 'testmount', + backend: 'smb', + backendText: 'SMB', + type: 'system', + status: 0, + location: '' + }]; + statusManager.processMountList(mountList); + + var $tr = fileList.findFileEl('testmount'); + expect($tr.attr('data-external-backend')).toEqual('smb'); + expect($tr.attr('data-icon')).toEqual( + OC.imagePath('windows_network_drive', 'folder-windows') + ); + // TODO: thumbnail URL + /* + expect(OC.TestUtil.getImageUrl($tr.find('.thumbnail'))).toEqual( + OC.imagePath('windows_network_drive', 'folder-windows') + ); + */ + // TODO: check CSS class + + }); + }); + describe('processMountStatus', function() { + // TODO + }); + describe('launchFullConnectivityCheckOneByOne', function() { + var getMountPointListStub; + var getMountStatusStub; + var processMountStatusStub; + var processMountListStub; + + beforeEach(function() { + getMountPointListStub = sinon.stub(statusManager, 'getMountPointList'); + getMountStatusStub = sinon.stub(statusManager, 'getMountStatus'); + processMountStatusStub = sinon.stub(statusManager, 'processMountStatus'); + processMountListStub = sinon.stub(statusManager, 'processMountList'); + }); + afterEach(function() { + getMountPointListStub.restore(); + getMountStatusStub.restore(); + processMountStatusStub.restore(); + processMountListStub.restore(); + }); + it('retrieves mount points then processes them', function() { + statusManager.launchFullConnectivityCheck(); + + expect(getMountPointListStub.calledOnce).toEqual(true); + var mountList = [{ + id: 123, + mount_point: 'testmount', + backend: 'smb', + backendText: 'SMB', + type: 'system', + status: 0, + location: '' + }]; + getMountPointListStub.yield(mountList); + + expect(processMountListStub.calledOnce).toEqual(true); + expect(processMountListStub.calledWith(mountList)).toEqual(true); + + // TODO: continue checking getMountStatus, etc + }); + }); + describe('recheckConnectivityForOne', function() { + // TODO + }); +}); diff --git a/tests/karma.config.js b/tests/karma.config.js index 64a94ef230b..10c5fa3344e 100644 --- a/tests/karma.config.js +++ b/tests/karma.config.js @@ -67,7 +67,8 @@ module.exports = function(config) { // up with the global namespace/classes/state 'apps/files_external/js/app.js', 'apps/files_external/js/mountsfilelist.js', - 'apps/files_external/js/settings.js' + 'apps/files_external/js/settings.js', + 'apps/files_external/js/statusmanager.js' ], testFiles: ['apps/files_external/tests/js/*.js'] }, -- cgit v1.2.3 From 5580b562a36c682c4baea89c7026af5596f714bc Mon Sep 17 00:00:00 2001 From: Jesús Macias Date: Tue, 24 Nov 2015 08:16:14 +0100 Subject: Fix code from PR comments --- apps/files_external/js/app.js | 165 ++++++++++++++++---------------- apps/files_external/js/rollingqueue.js | 118 +++++++++++------------ apps/files_external/js/settings.js | 4 +- apps/files_external/js/statusmanager.js | 157 +++++++++++++----------------- 4 files changed, 208 insertions(+), 236 deletions(-) (limited to 'apps/files_external') diff --git a/apps/files_external/js/app.js b/apps/files_external/js/app.js index 411d5fc3433..87507f93be3 100644 --- a/apps/files_external/js/app.js +++ b/apps/files_external/js/app.js @@ -9,105 +9,106 @@ */ if (!OCA.External) { - /** - * @namespace - */ - OCA.External = {}; + /** + * @namespace + */ + OCA.External = {}; } /** * @namespace */ OCA.External.App = { - fileList: null, + fileList: null, - initList: function($el) { - if (this.fileList) { - return this.fileList; - } + initList: function($el) { + if (this.fileList) { + return this.fileList; + } - this.fileList = new OCA.External.FileList( - $el, - { - scrollContainer: $('#app-content'), - fileActions: this._createFileActions() - } - ); + this.fileList = new OCA.External.FileList( + $el, + { + scrollContainer: $('#app-content'), + fileActions: this._createFileActions() + } + ); - this._extendFileList(this.fileList); - this.fileList.appName = t('files_external', 'External storage'); - return this.fileList; - }, + this._extendFileList(this.fileList); + this.fileList.appName = t('files_external', 'External storage'); + return this.fileList; + }, - removeList: function() { - if (this.fileList) { - this.fileList.$fileList.empty(); - } - }, + removeList: function() { + if (this.fileList) { + this.fileList.$fileList.empty(); + } + }, - _createFileActions: function() { - // inherit file actions from the files app - var fileActions = new OCA.Files.FileActions(); - fileActions.registerDefaultActions(); + _createFileActions: function() { + // inherit file actions from the files app + var fileActions = new OCA.Files.FileActions(); + fileActions.registerDefaultActions(); - // when the user clicks on a folder, redirect to the corresponding - // folder in the files app instead of opening it directly - fileActions.register('dir', 'Open', OC.PERMISSION_READ, '', function (filename, context) { - OCA.Files.App.setActiveView('files', {silent: true}); - OCA.Files.App.fileList.changeDirectory(context.$file.attr('data-path') + '/' + filename, true, true); - }); - fileActions.setDefault('dir', 'Open'); - return fileActions; - }, + // when the user clicks on a folder, redirect to the corresponding + // folder in the files app instead of opening it directly + fileActions.register('dir', 'Open', OC.PERMISSION_READ, '', function (filename, context) { + OCA.Files.App.setActiveView('files', {silent: true}); + OCA.Files.App.fileList.changeDirectory(context.$file.attr('data-path') + '/' + filename, true, true); + }); + fileActions.setDefault('dir', 'Open'); + return fileActions; + }, - _extendFileList: function(fileList) { - // remove size column from summary - fileList.fileSummary.$el.find('.filesize').remove(); - } + _extendFileList: function(fileList) { + // remove size column from summary + fileList.fileSummary.$el.find('.filesize').remove(); + } }; $(document).ready(function() { - $('#app-content-extstoragemounts').on('show', function(e) { - OCA.External.App.initList($(e.target)); - }); - $('#app-content-extstoragemounts').on('hide', function() { - OCA.External.App.removeList(); - }); + $('#app-content-extstoragemounts').on('show', function(e) { + OCA.External.App.initList($(e.target)); + }); + $('#app-content-extstoragemounts').on('hide', function() { + OCA.External.App.removeList(); + }); - /* Status Manager */ - if ($('#filesApp').val()) { + /* Status Manager */ + if ($('#filesApp').val()) { - $('#app-content-files') - .add('#app-content-extstoragemounts') - .on('changeDirectory', function(e){ - if (e.dir === '/') { - var mount_point = e.previousDir.split('/', 2)[1]; - // make sure we have a mount point list - OCA.External.StatusManager.getMountPointList(function() { - OCA.External.StatusManager.recheckConnectivityForMount([mount_point], true, true); - }); - } - }) - .on('fileActionsReady', function(e){ - if ($.isArray(e.$files)) { - if (OCA.External.StatusManager.mountStatus === null || - OCA.External.StatusManager.mountPointList === null || - _.size(OCA.External.StatusManager.mountStatus) !== _.size(OCA.External.StatusManager.mountPointList)) { - // we don't have the data cached, so we'll get it one by one - OCA.External.StatusManager.launchFullConnectivityCheckOneByOne(); - } else { - // make sure we have a mount point list - OCA.External.StatusManager.getMountPointList(function(){ - var fileNames = []; - $.each(e.$files, function(key, value){ - fileNames.push(value.attr('data-file')); - }); - OCA.External.StatusManager.recheckConnectivityForMount(fileNames, false, false); - }); - } - } - }); - } - /* End Status Manager */ + $('#app-content-files') + .add('#app-content-extstoragemounts') + .on('changeDirectory', function(e){ + if (e.dir === '/') { + var mount_point = e.previousDir.split('/', 2)[1]; + // Every time that we return to / root folder from a mountpoint, mount_point status is rechecked + OCA.External.StatusManager.getMountPointList(function() { + OCA.External.StatusManager.recheckConnectivityForMount([mount_point], true); + }); + } + }) + .on('fileActionsReady', function(e){ + if ($.isArray(e.$files)) { + if (OCA.External.StatusManager.mountStatus === null || + OCA.External.StatusManager.mountPointList === null || + _.size(OCA.External.StatusManager.mountStatus) !== _.size(OCA.External.StatusManager.mountPointList)) { + // Will be the very first check when the files view will be loaded + OCA.External.StatusManager.launchFullConnectivityCheckOneByOne(); + } else { + // When we change between general files view and external files view + OCA.External.StatusManager.getMountPointList(function(){ + var fileNames = []; + $.each(e.$files, function(key, value){ + fileNames.push(value.attr('data-file')); + }); + // Recheck if launched but work from cache + OCA.External.StatusManager.recheckConnectivityForMount(fileNames, false); + }); + } + } + }); + } + /* End Status Manager */ }); diff --git a/apps/files_external/js/rollingqueue.js b/apps/files_external/js/rollingqueue.js index 0bff974414f..58cb0fb22f0 100644 --- a/apps/files_external/js/rollingqueue.js +++ b/apps/files_external/js/rollingqueue.js @@ -59,77 +59,77 @@ * be executed at the same time */ var RollingQueue = function (functionList, queueWindow, callback) { - this.queueWindow = queueWindow || 1; - this.functionList = functionList; - this.callback = callback; - this.counter = 0; - this.runQueue = function() { - this.callbackCalled = false; - this.deferredsList = []; - if (!$.isArray(this.functionList)) { - throw "functionList must be an array"; - } + this.queueWindow = queueWindow || 1; + this.functionList = functionList; + this.callback = callback; + this.counter = 0; + this.runQueue = function() { + this.callbackCalled = false; + this.deferredsList = []; + if (!$.isArray(this.functionList)) { + throw "functionList must be an array"; + } - for (i = 0; i < this.queueWindow; i++) { - this.launchNext(); - } - }; + for (i = 0; i < this.queueWindow; i++) { + this.launchNext(); + } + }; - this.hasNext = function() { - return (this.counter in this.functionList); - }; + this.hasNext = function() { + return (this.counter in this.functionList); + }; - this.launchNext = function() { - var currentCounter = this.counter++; - if (currentCounter in this.functionList) { - var funcData = this.functionList[currentCounter]; - if ($.isFunction(funcData.funcName)) { - var defObj = funcData.funcName.apply(funcData.funcName, funcData.funcArgs); - this.deferredsList.push(defObj); - if ($.isFunction(funcData.done)) { - defObj.done(funcData.done); - } + this.launchNext = function() { + var currentCounter = this.counter++; + if (currentCounter in this.functionList) { + var funcData = this.functionList[currentCounter]; + if ($.isFunction(funcData.funcName)) { + var defObj = funcData.funcName.apply(funcData.funcName, funcData.funcArgs); + this.deferredsList.push(defObj); + if ($.isFunction(funcData.done)) { + defObj.done(funcData.done); + } - if ($.isFunction(funcData.fail)) { - defObj.fail(funcData.fail); - } + if ($.isFunction(funcData.fail)) { + defObj.fail(funcData.fail); + } - if ($.isFunction(funcData.always)) { - defObj.always(funcData.always); - } + if ($.isFunction(funcData.always)) { + defObj.always(funcData.always); + } - if (this.hasNext()) { - var self = this; - defObj.always(function(){ - _.defer($.proxy(function(){ - self.launchNext(); - }, self)); - }); - } else { - if (!this.callbackCalled) { - this.callbackCalled = true; - if ($.isFunction(this.callback)) { - $.when.apply($, this.deferredsList) - .always($.proxy(function(){ - this.callback(); - }, this) - ); - } - } - } - return defObj; - } - } - return false; - }; + if (this.hasNext()) { + var self = this; + defObj.always(function(){ + _.defer($.proxy(function(){ + self.launchNext(); + }, self)); + }); + } else { + if (!this.callbackCalled) { + this.callbackCalled = true; + if ($.isFunction(this.callback)) { + $.when.apply($, this.deferredsList) + .always($.proxy(function(){ + this.callback(); + }, this) + ); + } + } + } + return defObj; + } + } + return false; + }; }; if (!OCA.External) { - OCA.External = {}; + OCA.External = {}; } if (!OCA.External.StatusManager) { - OCA.External.StatusManager = {}; + OCA.External.StatusManager = {}; } OCA.External.StatusManager.RollingQueue = RollingQueue; diff --git a/apps/files_external/js/settings.js b/apps/files_external/js/settings.js index a839f396b9b..22f18fc29e3 100644 --- a/apps/files_external/js/settings.js +++ b/apps/files_external/js/settings.js @@ -1054,12 +1054,12 @@ MountConfigListView.prototype = _.extend({ } return defaultMountPoint + append; }, - + /** * Toggles the mount options dropdown * * @param {Object} $tr configuration row - */ + */ _showMountOptionsDropdown: function($tr) { if (this._preventNextDropdown) { // prevented because the click was on the toggle diff --git a/apps/files_external/js/statusmanager.js b/apps/files_external/js/statusmanager.js index 5c60c935e9d..0aedeb99226 100644 --- a/apps/files_external/js/statusmanager.js +++ b/apps/files_external/js/statusmanager.js @@ -21,9 +21,15 @@ if (!OCA.External.StatusManager) { } OCA.External.StatusManager = { + mountStatus : null, mountPointList : null, + /** + * Function + * @param {callback} afterCallback + */ + getMountStatus : function(afterCallback) { var self = this; if (typeof afterCallback !== 'function' || self.isGetMountStatusRunning) { @@ -32,36 +38,14 @@ OCA.External.StatusManager = { if (self.mountStatus) { afterCallback(self.mountStatus); - } else { - self.isGetMountStatusRunning = true; - $.ajax({ - type : 'GET', - url : OC.filePath('files_external', 'ajax', 'connectivityCheck.php'), - success : function(response) { - self.mountStatus = response.data; - afterCallback(self.mountStatus); - }, - error : function(jqxhr, state, error) { - OC.Notification.showTemporary(t('files_external', 'Couldn\'t get the status of the external mounts: {type}', {type : error})); - if (!self.mountStatus) { - self.mountStatus = {}; - } - $.each(self.mountPointList, function(name, value){ - if (!self.mountStatus[value.mount_point]) { - self.mountStatus[value.mount_point] = {}; - } - self.mountStatus[value.mount_point].status = 'ok'; - OCA.External.StatusManager.Utils.restoreFolder(value); - OCA.External.StatusManager.Utils.toggleLink(value.mount_point, true, true); - }); - }, - complete : function() { - self.isGetMountStatusRunning = false; - } - }); } }, + /** + * Function Check mount point status from cache + * @param {string} mount_point + */ + getMountPointListElement : function(mount_point) { var element; $.each(this.mountPointList, function(key, value){ @@ -73,6 +57,12 @@ OCA.External.StatusManager = { return element; }, + /** + * Function Check mount point status from cache + * @param {string} mount_point + * @param {string} mount_point + */ + getMountStatusForMount : function(mountData, afterCallback) { var self = this; if (typeof afterCallback !== 'function' || self.isGetMountStatusRunning) { @@ -124,13 +114,17 @@ OCA.External.StatusManager = { return defObj; }, + /** + * Function to get external mount point list from the files_external API + * @param {function} afterCallback function to be executed + */ + getMountPointList : function(afterCallback) { var self = this; if (typeof afterCallback !== 'function' || self.isGetMountPointListRunning) { return; } - if (self.mountPointList) { afterCallback(self.mountPointList); } else { @@ -164,13 +158,10 @@ OCA.External.StatusManager = { } }, - setMountPointAsGood : function(mountPoint) { - OCA.External.StatusManager.Utils.restoreFolder(mountPoint); - OCA.External.StatusManager.Utils.toggleLink(mountPoint, true, true); - delete this.mountStatus[mountPoint].code; - delete this.mountStatus[mountPoint].error; - this.mountStatus[mountPoint].status = 'ok'; - }, + /** + * Function to manage action when a mountpoint status = 1 (Errored). Show a dialog to be redirected to settings page. + * @param {string} name MountPoint Name + */ manageMountPointError : function(name) { var self = this; @@ -194,27 +185,17 @@ OCA.External.StatusManager = { }, this)); }, - - processMountStatus : function(mounts) { - var hasErrors = false; - var self = this; - $.each(mounts, function(mountPoint, values){ - hasErrors = !self.processMountStatusIndividual(mountPoint, values) || hasErrors; - }); - - if (!this.notificationHasShown) { - this.notificationHasShown = true; - if (hasErrors) { - OC.Notification.showTemporary(t('files_external', 'Some of the configured external mount points are not connected. Please click on the red row(s) for more information')); - } - } - }, + /** + * Function to process a mount point in relation with their status, Called from Async Queue. + * @param {object} mountData + * @param {object} mountStatus + */ processMountStatusIndividual : function(mountData, mountStatus) { var mountPoint = mountData.mount_point; if (mountStatus.status === 1) { - var trElement = FileList.findFileEl(OCA.External.StatusManager.Utils.jqSelEscape(mountPoint)); //$('#fileList tr[data-file=\"' + OCA.External.StatusManager.Utils.jqSelEscape(mountPoint) + '\"]'); + var trElement = FileList.findFileEl(OCA.External.StatusManager.Utils.jqSelEscape(mountPoint)); route = OCA.External.StatusManager.Utils.getIconRoute(trElement) + '-error'; @@ -231,6 +212,12 @@ OCA.External.StatusManager = { } }, + /** + * Function to process a mount point in relation with their status + * @param {object} mountData + * @param {object} mountStatus + */ + processMountList : function(mountList) { var elementList = null; $.each(mountList, function(name, value){ @@ -256,39 +243,9 @@ OCA.External.StatusManager = { } }, - launchFullConnectivityCheck : function() { - var self = this; - this.getMountPointList(function(list){ - // check if we have a list first - if (list === undefined && !self.emptyWarningShown) { - self.emptyWarningShown = true; - OC.Notification.showTemporary(t('files_external', 'Couldn\'t get the list of external mount points: empty response from the server')); - return; - } - if (list && list.length > 0) { - self.processMountList(list); - self.getMountStatus(function(mountStatus){ - if (mountStatus === undefined && !self.notificationNoProcessListDone) { - self.notificationNoProcessListDone = true; - OC.Notification.showTemporary(t('files_external', 'Couldn\'t get the status of the external mounts: empty response from the server')); - if (!self.mountStatus) { - self.mountStatus = {}; - } - $.each(list, function(name, value){ - if (!self.mountStatus[value.mount_point]) { - self.mountStatus[value.mount_point] = {}; - } - self.mountStatus[value.mount_point].status = 'ok'; - OCA.External.StatusManager.Utils.restoreFolder(value.mount_point); - OCA.External.StatusManager.Utils.toggleLink(value.mount_point, true, true); - }); - return; - } - self.processMountStatus(mountStatus); - }); - } - }); - }, + /** + * Function to process the whole mount point list in relation with their status (Async queue) + */ launchFullConnectivityCheckOneByOne : function() { var self = this; @@ -333,6 +290,13 @@ OCA.External.StatusManager = { }); }, + + /** + * Function to process a mount point list in relation with their status (Async queue) + * @param {object} mountListData + * @param {boolean} recheck delete cached info and force api call to check mount point status + */ + launchPartialConnectivityCheck : function(mountListData, recheck) { if (mountListData.length === 0) { return; @@ -352,7 +316,14 @@ OCA.External.StatusManager = { new OCA.External.StatusManager.RollingQueue(ajaxQueue, 4).runQueue(); }, - recheckConnectivityForMount : function(mountListNames, recheck, checkGlobal) { + + /** + * Function to relaunch some mount point status check + * @param {string} mountListNames + * @param {boolean} recheck delete cached info and force api call to check mount point status + */ + + recheckConnectivityForMount : function(mountListNames, recheck) { if (mountListNames.length === 0) { return; } @@ -486,28 +457,28 @@ OCA.External.StatusManager.Utils = { icon = OC.imagePath('sharepoint', 'folder-sharepoint'); break; case 'amazons3': - icon = OC.imagePath('core', 'filesystem/folder-external'); + icon = OC.imagePath('core', 'filetypes/folder-external'); break; case 'dav': - icon = OC.imagePath('core', 'filesystem/folder-external'); + icon = OC.imagePath('core', 'filetypes/folder-external'); break; case 'dropbox': - icon = OC.imagePath('core', 'filesystem/folder-external'); + icon = OC.imagePath('core', 'filetypes/folder-external'); break; case 'ftp': - icon = OC.imagePath('core', 'filesystem/folder-external'); + icon = OC.imagePath('core', 'filetypes/folder-external'); break; case 'google': - icon = OC.imagePath('core', 'filesystem/folder-external'); + icon = OC.imagePath('core', 'filetypes/folder-external'); break; case 'owncloud': - icon = OC.imagePath('core', 'filesystem/folder-external'); + icon = OC.imagePath('core', 'filetypes/folder-external'); break; case 'sftp': - icon = OC.imagePath('core', 'filesystem/folder-external'); + icon = OC.imagePath('core', 'filetypes/folder-external'); break; case 'swift': - icon = OC.imagePath('core', 'filesystem/folder-external'); + icon = OC.imagePath('core', 'filetypes/folder-external'); break; } -- cgit v1.2.3 From 674bc8e9cb340b2be1b27d4c8e3a539f550acb14 Mon Sep 17 00:00:00 2001 From: Jesús Macias Date: Tue, 24 Nov 2015 08:52:02 +0100 Subject: Add css to manage row status color --- apps/files_external/css/external.css | 8 ++++++++ apps/files_external/js/statusmanager.js | 7 +++---- apps/files_external/list.php | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 apps/files_external/css/external.css (limited to 'apps/files_external') diff --git a/apps/files_external/css/external.css b/apps/files_external/css/external.css new file mode 100644 index 00000000000..b0b0634fc58 --- /dev/null +++ b/apps/files_external/css/external.css @@ -0,0 +1,8 @@ +.externalDisabledRow { + background-color: #CCC ! important;; +} + + +.externalErroredRow { + background-color: #F2DEDE ! important;; +} diff --git a/apps/files_external/js/statusmanager.js b/apps/files_external/js/statusmanager.js index 0aedeb99226..5e7cb4e109e 100644 --- a/apps/files_external/js/statusmanager.js +++ b/apps/files_external/js/statusmanager.js @@ -237,7 +237,7 @@ OCA.External.StatusManager = { // Save default view OCA.External.StatusManager.Utils.storeDefaultFolderIconAndBgcolor(elementList); // Disable row until check status - elementList.css('background-color', '#CCC'); + elementList.addClass('externalDisabledRow'); OCA.External.StatusManager.Utils.toggleLink(elementList.find('a.name'), false, false); } } @@ -361,12 +361,11 @@ OCA.External.StatusManager = { OCA.External.StatusManager.Utils = { showIconError: function(folder, clickAction, errorImageUrl) { - var bgColor = '#F2DEDE'; var imageUrl = "url(" + errorImageUrl + ")"; var trFolder = $('#fileList tr[data-file=\"' + OCA.External.StatusManager.Utils.jqSelEscape(folder) + '\"]'); //FileList.findFileEl(OCA.External.StatusManager.Utils.jqSelEscape(folder)); this.changeFolderIcon(folder, imageUrl); this.toggleLink(folder, false, clickAction); - trFolder.css('background-color', bgColor); + trFolder.addClass('externalErroredRow'); }, /** @@ -406,7 +405,7 @@ OCA.External.StatusManager.Utils = { // cant use here FileList.findFileEl(OCA.External.StatusManager.Utils.jqSelEscape(folder)); return incorrect instance of filelist trFolder = $('#fileList tr[data-file=\"' + OCA.External.StatusManager.Utils.jqSelEscape(folder) + '\"]'); } - trFolder.css('background-color', ''); + trFolder.removeClass('externalErroredRow').removeClass('externalDisabledRow'); tdChilds = trFolder.find("td:first-child div.thumbnail"); tdChilds.each(function(){ var thisElement = $(this); diff --git a/apps/files_external/list.php b/apps/files_external/list.php index 0a994e147f5..4bbe5588c26 100644 --- a/apps/files_external/list.php +++ b/apps/files_external/list.php @@ -24,6 +24,7 @@ OCP\User::checkLoggedIn(); $tmpl = new OCP\Template('files_external', 'list', ''); /* Load Status Manager */ +\OCP\Util::addStyle('files_external', 'external'); \OCP\Util::addScript('files_external', 'statusmanager'); \OCP\Util::addScript('files_external', 'rollingqueue'); -- cgit v1.2.3 From 70071c8865eb18b739e9e681244497da310512d9 Mon Sep 17 00:00:00 2001 From: Jesús Macias Date: Tue, 24 Nov 2015 11:55:33 +0100 Subject: Fix css selector and bug checking personal mounts status --- apps/files_external/css/external.css | 8 ++++---- apps/files_external/js/statusmanager.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'apps/files_external') diff --git a/apps/files_external/css/external.css b/apps/files_external/css/external.css index b0b0634fc58..bf57ec88053 100644 --- a/apps/files_external/css/external.css +++ b/apps/files_external/css/external.css @@ -1,8 +1,8 @@ -.externalDisabledRow { - background-color: #CCC ! important;; +#filestable tbody tr.externalDisabledRow { + background-color: #CCC; } -.externalErroredRow { - background-color: #F2DEDE ! important;; +#filestable tbody tr.externalErroredRow { + background-color: #F2DEDE; } diff --git a/apps/files_external/js/statusmanager.js b/apps/files_external/js/statusmanager.js index 5e7cb4e109e..4048bfc31bc 100644 --- a/apps/files_external/js/statusmanager.js +++ b/apps/files_external/js/statusmanager.js @@ -77,7 +77,7 @@ OCA.External.StatusManager = { } else { defObj = $.ajax({ type : 'GET', - url: OC.webroot + '/index.php/apps/files_external/globalstorages/' + mountData.id, + url: OC.webroot + '/index.php/apps/files_external/' + ((mountData.type === 'personal') ? 'userstorages' : 'globalstorages') + '/' + mountData.id, success : function(response) { if (response && response.status === 0) { self.mountStatus[mountData.mount_point] = response; -- cgit v1.2.3 From a79ae4ae086c08c75a6d974966458251e2167347 Mon Sep 17 00:00:00 2001 From: Jesús Macias Date: Tue, 1 Dec 2015 12:58:01 +0100 Subject: Delete js unit test. Another issue has been created to create js test --- apps/files_external/tests/js/statusmanagerSpec.js | 205 ---------------------- 1 file changed, 205 deletions(-) delete mode 100644 apps/files_external/tests/js/statusmanagerSpec.js (limited to 'apps/files_external') diff --git a/apps/files_external/tests/js/statusmanagerSpec.js b/apps/files_external/tests/js/statusmanagerSpec.js deleted file mode 100644 index 975d71627bf..00000000000 --- a/apps/files_external/tests/js/statusmanagerSpec.js +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (c) 2015 Vincent Petry - * - * This file is licensed under the Affero General Public License version 3 - * or later. - * - * See the COPYING-README file. - * - */ - -describe('OCA.External.StatusManager tests', function() { - var notificationStub; - var fileList; - var statusManager; - var oldAppWebRoots; - - beforeEach(function() { - notificationStub = sinon.stub(OC.Notification, 'showTemporary'); - var $content = $('
'); - $('#testArea').append($content); - // dummy file list - var $div = $( - '
' + - '' + - '' + - '' + - '' + - '
' + - '
'); - $('#content').append($div); - - var fileActions = new OCA.Files.FileActions(); - fileList = new OCA.Files.FileList( - $div, { - fileActions : fileActions - } - ); - - fileList.add({ - id: 1, - type: 'folder', - name: 'testmount', - mountType: 'external-root', - path: '/', - mimetype: 'httpd/unix-directory', - size: 12, - permissions: OC.PERMISSION_ALL, - etag: 'abc' - }); - - statusManager = OCA.External.StatusManager; - - oldAppWebRoots = _.extend({}, OC.appswebroots); - OC.appswebroots['files_external'] = OC.webroot + '/apps/files_external'; - }); - afterEach(function() { - statusManager.mountStatus = null; - statusManager.mountPointList = null; - - notificationStub.restore(); - OC.appswebroots = oldAppWebRoots; - }); - - describe('getMountStatusForMount', function() { - beforeEach(function() { - statusManager.mountStatus = []; - }); - - it('retrieves mount status and passes it to callback', function() { - var mountData = { - id: 123, - type: 'smb', - mount_point: 'testmount', - location: 3 - }; - - var callbackStub = sinon.stub(); - statusManager.getMountStatusForMount(mountData, callbackStub); - - expect(fakeServer.requests.length).toEqual(1); - - var mountStatus = { - type: 'smb', - status: 0 - }; - - var jsonData = JSON.stringify(mountStatus); - var request = fakeServer.requests[0]; - - expect(request.url).toEqual(OC.webroot + '/index.php/apps/files_external/globalstorages/123'); - - fakeServer.requests[0].respond( - 200, - {'Content-Type': 'application/json'}, - jsonData - ); - - - expect(callbackStub.calledOnce).toEqual(true); - expect(callbackStub.getCall(0).args[0]).toEqual(mountData); - expect(callbackStub.getCall(0).args[1]).toEqual(mountStatus); - - // second call does not send request but returns known data - statusManager.getMountStatusForMount(mountData, callbackStub); - - expect(fakeServer.requests.length).toEqual(1); - - expect(callbackStub.calledTwice).toEqual(true); - expect(callbackStub.getCall(1).args[0]).toEqual(mountData); - expect(callbackStub.getCall(1).args[1]).toEqual(mountStatus); - }); - // TODO: case where status is not 0 - // TODO: error case - }); - describe('getMountPointList', function() { - // TODO - }); - describe('processMountList', function() { - var getActiveViewStub; - var getCurrentAppContainerStub; - - beforeEach(function() { - getActiveViewStub = sinon.stub(OCA.Files.App, 'getActiveView'); - getActiveViewStub.returns('files'); - getCurrentAppContainerStub = sinon.stub(OCA.Files.App, 'getCurrentAppContainer'); - getCurrentAppContainerStub.returns($('#testArea')); - }); - afterEach(function() { - getActiveViewStub.restore(); - getCurrentAppContainerStub.restore(); - }); - - it('updates file list element with status', function() { - var mountList = [{ - id: 123, - mount_point: 'testmount', - backend: 'smb', - backendText: 'SMB', - type: 'system', - status: 0, - location: '' - }]; - statusManager.processMountList(mountList); - - var $tr = fileList.findFileEl('testmount'); - expect($tr.attr('data-external-backend')).toEqual('smb'); - expect($tr.attr('data-icon')).toEqual( - OC.imagePath('windows_network_drive', 'folder-windows') - ); - // TODO: thumbnail URL - /* - expect(OC.TestUtil.getImageUrl($tr.find('.thumbnail'))).toEqual( - OC.imagePath('windows_network_drive', 'folder-windows') - ); - */ - // TODO: check CSS class - - }); - }); - describe('processMountStatus', function() { - // TODO - }); - describe('launchFullConnectivityCheckOneByOne', function() { - var getMountPointListStub; - var getMountStatusStub; - var processMountStatusStub; - var processMountListStub; - - beforeEach(function() { - getMountPointListStub = sinon.stub(statusManager, 'getMountPointList'); - getMountStatusStub = sinon.stub(statusManager, 'getMountStatus'); - processMountStatusStub = sinon.stub(statusManager, 'processMountStatus'); - processMountListStub = sinon.stub(statusManager, 'processMountList'); - }); - afterEach(function() { - getMountPointListStub.restore(); - getMountStatusStub.restore(); - processMountStatusStub.restore(); - processMountListStub.restore(); - }); - it('retrieves mount points then processes them', function() { - statusManager.launchFullConnectivityCheck(); - - expect(getMountPointListStub.calledOnce).toEqual(true); - var mountList = [{ - id: 123, - mount_point: 'testmount', - backend: 'smb', - backendText: 'SMB', - type: 'system', - status: 0, - location: '' - }]; - getMountPointListStub.yield(mountList); - - expect(processMountListStub.calledOnce).toEqual(true); - expect(processMountListStub.calledWith(mountList)).toEqual(true); - - // TODO: continue checking getMountStatus, etc - }); - }); - describe('recheckConnectivityForOne', function() { - // TODO - }); -}); -- cgit v1.2.3 From d14f1283290552f10b58f28ac46a8e74ab8c615d Mon Sep 17 00:00:00 2001 From: Jenkins for ownCloud Date: Sun, 6 Dec 2015 01:54:33 -0500 Subject: [tx-robot] updated from transifex --- apps/files_external/l10n/lt_LT.js | 1 + apps/files_external/l10n/lt_LT.json | 1 + apps/user_ldap/l10n/lt_LT.js | 2 ++ apps/user_ldap/l10n/lt_LT.json | 2 ++ lib/l10n/lt_LT.js | 2 ++ lib/l10n/lt_LT.json | 2 ++ lib/l10n/pt_BR.js | 6 +++++- lib/l10n/pt_BR.json | 6 +++++- 8 files changed, 20 insertions(+), 2 deletions(-) (limited to 'apps/files_external') diff --git a/apps/files_external/l10n/lt_LT.js b/apps/files_external/l10n/lt_LT.js index dabdeb8bd32..3a871070f45 100644 --- a/apps/files_external/l10n/lt_LT.js +++ b/apps/files_external/l10n/lt_LT.js @@ -3,6 +3,7 @@ OC.L10N.register( { "Fetching request tokens failed. Verify that your app key and secret are correct." : "Nepavyko atsiųsti užklausos žymės. Patikrinkite savo programos raktą ir paslaptį.", "Step 1 failed. Exception: %s" : "1 žingsnio klaida: %s", + "Step 2 failed. Exception: %s" : "2 žingsnio klaida: %s", "External storage" : "Išorinė saugykla", "Personal" : "Asmeniniai", "Grant access" : "Suteikti priėjimą", diff --git a/apps/files_external/l10n/lt_LT.json b/apps/files_external/l10n/lt_LT.json index 2b05c277ee6..854f753acaf 100644 --- a/apps/files_external/l10n/lt_LT.json +++ b/apps/files_external/l10n/lt_LT.json @@ -1,6 +1,7 @@ { "translations": { "Fetching request tokens failed. Verify that your app key and secret are correct." : "Nepavyko atsiųsti užklausos žymės. Patikrinkite savo programos raktą ir paslaptį.", "Step 1 failed. Exception: %s" : "1 žingsnio klaida: %s", + "Step 2 failed. Exception: %s" : "2 žingsnio klaida: %s", "External storage" : "Išorinė saugykla", "Personal" : "Asmeniniai", "Grant access" : "Suteikti priėjimą", diff --git a/apps/user_ldap/l10n/lt_LT.js b/apps/user_ldap/l10n/lt_LT.js index e27dcc3e8de..c263e952206 100644 --- a/apps/user_ldap/l10n/lt_LT.js +++ b/apps/user_ldap/l10n/lt_LT.js @@ -4,7 +4,9 @@ OC.L10N.register( "Failed to clear the mappings." : "Nepavyko išvalyti sąsajų.", "Failed to delete the server configuration" : "Nepavyko pašalinti serverio konfigūracijos", "The configuration is valid and the connection could be established!" : "Konfigūracija yra tinkama bei prisijungta sėkmingai!", + "The configuration is invalid. Please have a look at the logs for further details." : "Neteisinga konfigūracija. Daugiau informacijos rasite žurnaluose.", "No action specified" : "Nepasirinktas veiksmas", + "No data specified" : "Nepateikta duomenų", "Select groups" : "Pasirinkti grupes", "Do you really want to delete the current Server Configuration?" : "Ar tikrai norite ištrinti dabartinę serverio konfigūraciją?", "Confirm Deletion" : "Patvirtinkite trynimą", diff --git a/apps/user_ldap/l10n/lt_LT.json b/apps/user_ldap/l10n/lt_LT.json index fa1526c0632..64e2bae4670 100644 --- a/apps/user_ldap/l10n/lt_LT.json +++ b/apps/user_ldap/l10n/lt_LT.json @@ -2,7 +2,9 @@ "Failed to clear the mappings." : "Nepavyko išvalyti sąsajų.", "Failed to delete the server configuration" : "Nepavyko pašalinti serverio konfigūracijos", "The configuration is valid and the connection could be established!" : "Konfigūracija yra tinkama bei prisijungta sėkmingai!", + "The configuration is invalid. Please have a look at the logs for further details." : "Neteisinga konfigūracija. Daugiau informacijos rasite žurnaluose.", "No action specified" : "Nepasirinktas veiksmas", + "No data specified" : "Nepateikta duomenų", "Select groups" : "Pasirinkti grupes", "Do you really want to delete the current Server Configuration?" : "Ar tikrai norite ištrinti dabartinę serverio konfigūraciją?", "Confirm Deletion" : "Patvirtinkite trynimą", diff --git a/lib/l10n/lt_LT.js b/lib/l10n/lt_LT.js index f73b1fdc871..402167cb3c6 100644 --- a/lib/l10n/lt_LT.js +++ b/lib/l10n/lt_LT.js @@ -4,7 +4,9 @@ OC.L10N.register( "Cannot write into \"config\" directory!" : "Negalima rašyti į \"config\" aplanką!", "This can usually be fixed by giving the webserver write access to the config directory" : "Tai gali būti ištaisyta suteikiant web serveriui rašymo teises į config aplanką", "See %s" : "Žiūrėk %s", + "Sample configuration detected" : "Aptiktas konfigūracijos pavyzdys", "PHP %s or higher is required." : "Reikalinga PHP %s arba aukštesnė.", + "Following databases are supported: %s" : "Palaikomos duomenų bazės: %s", "Help" : "Pagalba", "Personal" : "Asmeniniai", "Users" : "Vartotojai", diff --git a/lib/l10n/lt_LT.json b/lib/l10n/lt_LT.json index e9acd6f2950..c4efe386655 100644 --- a/lib/l10n/lt_LT.json +++ b/lib/l10n/lt_LT.json @@ -2,7 +2,9 @@ "Cannot write into \"config\" directory!" : "Negalima rašyti į \"config\" aplanką!", "This can usually be fixed by giving the webserver write access to the config directory" : "Tai gali būti ištaisyta suteikiant web serveriui rašymo teises į config aplanką", "See %s" : "Žiūrėk %s", + "Sample configuration detected" : "Aptiktas konfigūracijos pavyzdys", "PHP %s or higher is required." : "Reikalinga PHP %s arba aukštesnė.", + "Following databases are supported: %s" : "Palaikomos duomenų bazės: %s", "Help" : "Pagalba", "Personal" : "Asmeniniai", "Users" : "Vartotojai", diff --git a/lib/l10n/pt_BR.js b/lib/l10n/pt_BR.js index 8078d369b76..2595d5dfd38 100644 --- a/lib/l10n/pt_BR.js +++ b/lib/l10n/pt_BR.js @@ -147,6 +147,10 @@ OC.L10N.register( "Data directory (%s) is invalid" : "Diretório de dados (%s) é inválido", "Please check that the data directory contains a file \".ocdata\" in its root." : "Por favor, verifique se o diretório de dados contém um arquivo \".ocdata\" em sua raiz.", "Could not obtain lock type %d on \"%s\"." : "Não foi possível obter tipo de bloqueio %d em \"%s\".", - "Storage not available" : "Armazanamento não disponível" + "Storage unauthorized. %s" : "Armazenamento não autorizado. %s", + "Storage incomplete configuration. %s" : "Incompleta configuração de armazenamento. %s", + "Storage connection error. %s" : "Erro na conexão de armazenamento. %s", + "Storage not available" : "Armazanamento não disponível", + "Storage connection timeout. %s" : "Tempo limite de conexão de armazenamento. %s" }, "nplurals=2; plural=(n > 1);"); diff --git a/lib/l10n/pt_BR.json b/lib/l10n/pt_BR.json index 5987c1e2ac7..0da54181b3f 100644 --- a/lib/l10n/pt_BR.json +++ b/lib/l10n/pt_BR.json @@ -145,6 +145,10 @@ "Data directory (%s) is invalid" : "Diretório de dados (%s) é inválido", "Please check that the data directory contains a file \".ocdata\" in its root." : "Por favor, verifique se o diretório de dados contém um arquivo \".ocdata\" em sua raiz.", "Could not obtain lock type %d on \"%s\"." : "Não foi possível obter tipo de bloqueio %d em \"%s\".", - "Storage not available" : "Armazanamento não disponível" + "Storage unauthorized. %s" : "Armazenamento não autorizado. %s", + "Storage incomplete configuration. %s" : "Incompleta configuração de armazenamento. %s", + "Storage connection error. %s" : "Erro na conexão de armazenamento. %s", + "Storage not available" : "Armazanamento não disponível", + "Storage connection timeout. %s" : "Tempo limite de conexão de armazenamento. %s" },"pluralForm" :"nplurals=2; plural=(n > 1);" } \ No newline at end of file -- cgit v1.2.3 From 35ab7f0e64316eba1966bde406f31885b61f15a8 Mon Sep 17 00:00:00 2001 From: Tim Dettrick Date: Mon, 10 Aug 2015 11:06:45 +1000 Subject: Improving fopen behaviour for Swift backend --- apps/files_external/lib/swift.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'apps/files_external') diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php index e946e7feb77..a64a02a4ed9 100644 --- a/apps/files_external/lib/swift.php +++ b/apps/files_external/lib/swift.php @@ -354,9 +354,18 @@ class Swift extends \OC\Files\Storage\Common { } $tmpFile = \OCP\Files::tmpFile($ext); \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack')); - if ($this->file_exists($path)) { + // Fetch existing file if required + if ($mode[0] !== 'w' && $this->file_exists($path)) { + if ($mode[0] === 'x') { + // File cannot already exist + return false; + } $source = $this->fopen($path, 'r'); file_put_contents($tmpFile, $source); + // Seek to end if required + if ($mode[0] === 'a') { + fseek($tmpFile, 0, SEEK_END); + } } self::$tmpFiles[$tmpFile] = $path; -- cgit v1.2.3 From 97f9213da95187a9992f700597fb012429b60469 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Mon, 7 Dec 2015 12:05:27 +0000 Subject: Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- apps/files_external/lib/smb.php | 1 - apps/files_external/tests/amazons3migration.php | 3 +++ apps/files_external/tests/controller/storagescontrollertest.php | 6 ++++++ apps/files_external/tests/service/backendservicetest.php | 5 +++++ apps/files_sharing/appinfo/application.php | 1 - apps/files_sharing/lib/cache.php | 2 +- apps/files_sharing/lib/controllers/externalsharescontroller.php | 3 +-- apps/files_sharing/lib/controllers/sharecontroller.php | 2 +- apps/files_sharing/lib/middleware/sharingcheckmiddleware.php | 1 - apps/files_sharing/lib/sharedstorage.php | 2 -- 10 files changed, 17 insertions(+), 9 deletions(-) (limited to 'apps/files_external') diff --git a/apps/files_external/lib/smb.php b/apps/files_external/lib/smb.php index f58cd9849f2..a94840ead59 100644 --- a/apps/files_external/lib/smb.php +++ b/apps/files_external/lib/smb.php @@ -33,7 +33,6 @@ use Icewind\SMB\Exception\Exception; use Icewind\SMB\Exception\NotFoundException; use Icewind\SMB\NativeServer; use Icewind\SMB\Server; -use Icewind\Streams\CallbackWrapper; use Icewind\Streams\IteratorDirectory; use OC\Files\Filesystem; diff --git a/apps/files_external/tests/amazons3migration.php b/apps/files_external/tests/amazons3migration.php index 33fb6119a92..cc47107c7fe 100644 --- a/apps/files_external/tests/amazons3migration.php +++ b/apps/files_external/tests/amazons3migration.php @@ -130,6 +130,9 @@ class AmazonS3Migration extends \Test\TestCase { return $storages; } + /** + * @param string $id + */ public function deleteStorage($id) { $stmt = \OC::$server->getDatabaseConnection()->prepare( 'DELETE FROM `*PREFIX*storages` WHERE `id` = ?' diff --git a/apps/files_external/tests/controller/storagescontrollertest.php b/apps/files_external/tests/controller/storagescontrollertest.php index 8a7acf81009..747bcd46e17 100644 --- a/apps/files_external/tests/controller/storagescontrollertest.php +++ b/apps/files_external/tests/controller/storagescontrollertest.php @@ -48,6 +48,9 @@ abstract class StoragesControllerTest extends \Test\TestCase { \OC_Mount_Config::$skipTest = false; } + /** + * @return \OCA\Files_External\Lib\Backend\Backend + */ protected function getBackendMock($class = '\OCA\Files_External\Lib\Backend\SMB', $storageClass = '\OC\Files\Storage\SMB') { $backend = $this->getMockBuilder('\OCA\Files_External\Lib\Backend\Backend') ->disableOriginalConstructor() @@ -59,6 +62,9 @@ abstract class StoragesControllerTest extends \Test\TestCase { return $backend; } + /** + * @return \OCA\Files_External\Lib\Auth\AuthMechanism + */ protected function getAuthMechMock($scheme = 'null', $class = '\OCA\Files_External\Lib\Auth\NullMechanism') { $authMech = $this->getMockBuilder('\OCA\Files_External\Lib\Auth\AuthMechanism') ->disableOriginalConstructor() diff --git a/apps/files_external/tests/service/backendservicetest.php b/apps/files_external/tests/service/backendservicetest.php index 5097b479a5f..e9cb0e2c368 100644 --- a/apps/files_external/tests/service/backendservicetest.php +++ b/apps/files_external/tests/service/backendservicetest.php @@ -35,6 +35,11 @@ class BackendServiceTest extends \Test\TestCase { $this->l10n = $this->getMock('\OCP\IL10N'); } + /** + * @param string $class + * + * @return \OCA\Files_External\Lib\Backend\Backend + */ protected function getBackendMock($class) { $backend = $this->getMockBuilder('\OCA\Files_External\Lib\Backend\Backend') ->disableOriginalConstructor() diff --git a/apps/files_sharing/appinfo/application.php b/apps/files_sharing/appinfo/application.php index ffe3a6a513f..6af450405a3 100644 --- a/apps/files_sharing/appinfo/application.php +++ b/apps/files_sharing/appinfo/application.php @@ -25,7 +25,6 @@ namespace OCA\Files_Sharing\AppInfo; -use OCA\Files_Sharing\Helper; use OCA\Files_Sharing\MountProvider; use OCP\AppFramework\App; use OC\AppFramework\Utility\SimpleContainer; diff --git a/apps/files_sharing/lib/cache.php b/apps/files_sharing/lib/cache.php index 2e615e231f1..c9032413783 100644 --- a/apps/files_sharing/lib/cache.php +++ b/apps/files_sharing/lib/cache.php @@ -98,7 +98,7 @@ class Shared_Cache extends Cache { /** * get the stored metadata of a file or folder * - * @param string|int $file + * @param string $file * @return array|false */ public function get($file) { diff --git a/apps/files_sharing/lib/controllers/externalsharescontroller.php b/apps/files_sharing/lib/controllers/externalsharescontroller.php index edf065ab476..ec576065669 100644 --- a/apps/files_sharing/lib/controllers/externalsharescontroller.php +++ b/apps/files_sharing/lib/controllers/externalsharescontroller.php @@ -45,7 +45,6 @@ class ExternalSharesController extends Controller { /** * @param string $appName * @param IRequest $request - * @param bool $incomingShareEnabled * @param \OCA\Files_Sharing\External\Manager $externalManager * @param IClientService $clientService */ @@ -84,7 +83,7 @@ class ExternalSharesController extends Controller { * @NoAdminRequired * @NoOutgoingFederatedSharingRequired * - * @param $id + * @param integer $id * @return JSONResponse */ public function destroy($id) { diff --git a/apps/files_sharing/lib/controllers/sharecontroller.php b/apps/files_sharing/lib/controllers/sharecontroller.php index 4b446d79ada..fe7b159449c 100644 --- a/apps/files_sharing/lib/controllers/sharecontroller.php +++ b/apps/files_sharing/lib/controllers/sharecontroller.php @@ -124,7 +124,7 @@ class ShareController extends Controller { * @UseSession * * Authenticates against password-protected shares - * @param $token + * @param string $token * @param string $password * @return RedirectResponse|TemplateResponse */ diff --git a/apps/files_sharing/lib/middleware/sharingcheckmiddleware.php b/apps/files_sharing/lib/middleware/sharingcheckmiddleware.php index 22b9d32a275..04dd28574d6 100644 --- a/apps/files_sharing/lib/middleware/sharingcheckmiddleware.php +++ b/apps/files_sharing/lib/middleware/sharingcheckmiddleware.php @@ -27,7 +27,6 @@ namespace OCA\Files_Sharing\Middleware; use OCP\App\IAppManager; use OCP\AppFramework\Http\NotFoundResponse; use OCP\AppFramework\Middleware; -use OCP\AppFramework\Http\TemplateResponse; use OCP\Files\NotFoundException; use OCP\IConfig; use OCP\AppFramework\Utility\IControllerMethodReflector; diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php index 4807b5ee738..cda3f564d5f 100644 --- a/apps/files_sharing/lib/sharedstorage.php +++ b/apps/files_sharing/lib/sharedstorage.php @@ -32,8 +32,6 @@ namespace OC\Files\Storage; use OC\Files\Filesystem; use OCA\Files_Sharing\ISharedStorage; -use OCA\Files_Sharing\Propagator; -use OCA\Files_Sharing\SharedMount; use OCP\Lock\ILockingProvider; /** -- cgit v1.2.3 From 453e1bf66e7edb6e2b3d25a093bf2c7662f209a7 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Mon, 7 Dec 2015 15:43:36 +0000 Subject: Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- apps/files_external/command/listcommand.php | 1 - apps/files_sharing/tests/locking.php | 1 - lib/private/appframework/utility/simplecontainer.php | 2 -- lib/private/files/filesystem.php | 1 - lib/private/session/cryptowrapper.php | 1 - settings/controller/userscontroller.php | 1 - tests/core/avatar/avatarcontrollertest.php | 3 --- tests/lib/appframework/http/RequestTest.php | 1 - 8 files changed, 11 deletions(-) (limited to 'apps/files_external') diff --git a/apps/files_external/command/listcommand.php b/apps/files_external/command/listcommand.php index 4c027ffcb8e..baba9be59f5 100644 --- a/apps/files_external/command/listcommand.php +++ b/apps/files_external/command/listcommand.php @@ -29,7 +29,6 @@ use OCP\IUserManager; use OCP\IUserSession; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\Table; -use Symfony\Component\Console\Helper\TableHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; diff --git a/apps/files_sharing/tests/locking.php b/apps/files_sharing/tests/locking.php index 3b8900f2061..ad7b6b3e8a3 100644 --- a/apps/files_sharing/tests/locking.php +++ b/apps/files_sharing/tests/locking.php @@ -24,7 +24,6 @@ namespace OCA\Files_sharing\Tests; use OC\Files\Filesystem; use OC\Files\View; -use OC\Lock\MemcacheLockingProvider; use OCP\Lock\ILockingProvider; /** diff --git a/lib/private/appframework/utility/simplecontainer.php b/lib/private/appframework/utility/simplecontainer.php index bcae351e023..e55d4e20a81 100644 --- a/lib/private/appframework/utility/simplecontainer.php +++ b/lib/private/appframework/utility/simplecontainer.php @@ -29,9 +29,7 @@ namespace OC\AppFramework\Utility; use ReflectionClass; use ReflectionException; use Closure; - use Pimple\Container; - use OCP\AppFramework\QueryException; use OCP\IContainer; diff --git a/lib/private/files/filesystem.php b/lib/private/files/filesystem.php index 9f243c15a4c..9d1b7150687 100644 --- a/lib/private/files/filesystem.php +++ b/lib/private/files/filesystem.php @@ -58,7 +58,6 @@ namespace OC\Files; -use OC\Cache\File; use OC\Files\Config\MountProviderCollection; use OC\Files\Storage\StorageFactory; use OCP\Files\Config\IMountProvider; diff --git a/lib/private/session/cryptowrapper.php b/lib/private/session/cryptowrapper.php index c79778587e0..177f11ffb70 100644 --- a/lib/private/session/cryptowrapper.php +++ b/lib/private/session/cryptowrapper.php @@ -23,7 +23,6 @@ namespace OC\Session; -use OCP\AppFramework\Utility\ITimeFactory; use OCP\IConfig; use OCP\IRequest; use OCP\ISession; diff --git a/settings/controller/userscontroller.php b/settings/controller/userscontroller.php index 0164d3bcee7..8ad975fd664 100644 --- a/settings/controller/userscontroller.php +++ b/settings/controller/userscontroller.php @@ -27,7 +27,6 @@ namespace OC\Settings\Controller; use OC\AppFramework\Http; -use OC\Settings\Factory\SubAdminFactory; use OC\User\User; use OCP\App\IAppManager; use OCP\AppFramework\Controller; diff --git a/tests/core/avatar/avatarcontrollertest.php b/tests/core/avatar/avatarcontrollertest.php index efe41763ff7..a113add72b9 100644 --- a/tests/core/avatar/avatarcontrollertest.php +++ b/tests/core/avatar/avatarcontrollertest.php @@ -23,14 +23,11 @@ namespace OC\Core\Avatar; use OC; use OC\Core\Application; use OCP\AppFramework\IAppContainer; -use OC\Files\Filesystem; use OCP\AppFramework\Http; -use OCP\Image; use OCP\Files\Folder; use OCP\Files\File; use OCP\IUser; use OCP\IAvatar; - use Test\Traits\UserTrait; /** diff --git a/tests/lib/appframework/http/RequestTest.php b/tests/lib/appframework/http/RequestTest.php index 92a2cc01dd2..32603d0da59 100644 --- a/tests/lib/appframework/http/RequestTest.php +++ b/tests/lib/appframework/http/RequestTest.php @@ -10,7 +10,6 @@ namespace OC\AppFramework\Http; -use OC\Security\Crypto; use OCP\Security\ISecureRandom; use OCP\IConfig; -- cgit v1.2.3 From 736e133c047a22b587294a1231b61ac2575f3f83 Mon Sep 17 00:00:00 2001 From: Jenkins for ownCloud Date: Tue, 8 Dec 2015 01:56:19 -0500 Subject: [tx-robot] updated from transifex --- apps/files_external/l10n/es.js | 14 ++++++++++++-- apps/files_external/l10n/es.json | 14 ++++++++++++-- apps/files_external/l10n/fr.js | 1 + apps/files_external/l10n/fr.json | 1 + apps/files_external/l10n/nl.js | 1 + apps/files_external/l10n/nl.json | 1 + apps/files_external/l10n/th_TH.js | 1 + apps/files_external/l10n/th_TH.json | 1 + core/l10n/nl.js | 5 +++++ core/l10n/nl.json | 5 +++++ lib/l10n/fr.js | 3 ++- lib/l10n/fr.json | 3 ++- lib/l10n/nl.js | 6 +++++- lib/l10n/nl.json | 6 +++++- 14 files changed, 54 insertions(+), 8 deletions(-) (limited to 'apps/files_external') diff --git a/apps/files_external/l10n/es.js b/apps/files_external/l10n/es.js index 1d49d7b13b8..6d8bf0d3139 100644 --- a/apps/files_external/l10n/es.js +++ b/apps/files_external/l10n/es.js @@ -1,13 +1,23 @@ OC.L10N.register( "files_external", { + "Fetching request tokens failed. Verify that your app key and secret are correct." : "Fallo al acceder a los tokens solicitados. Verfique que su clave de app y la clave secreta son correctas.", + "Fetching access tokens failed. Verify that your app key and secret are correct." : "Fallo al acceder a los tokens solicitados. Verfique que su clave de app y la clave secreta son correctas.", + "Please provide a valid app key and secret." : "Por favor facilite una clave de app y una clave secreta válidas.", "Step 1 failed. Exception: %s" : "El paso 1 falló. Excepción: %s", "Step 2 failed. Exception: %s" : "El paso 2 falló. Excepción: %s", "External storage" : "Almacenamiento externo", "Storage with id \"%i\" not found" : "No se ha encontrado almacenamiento con id \"%i\"", + "Invalid backend or authentication mechanism class" : "Sistema o mecanismo de autentificación inválido", "Invalid mount point" : "Punto de montaje no válido", + "Objectstore forbidden" : "Objeto de almacenaje prohibido", "Invalid storage backend \"%s\"" : "Motor de almacenamiento no válido «%s»", - "Not permitted to use authentication mechanism \"%s\"" : "No está permitido usar el mecanismo de autenticación \"%s\"", + "Not permitted to use backend \"%s\"" : "No se permite usar el mecanismo \"%s\"", + "Not permitted to use authentication mechanism \"%s\"" : "No está permitido usar el mecanismo de autentificación \"%s\"", + "Unsatisfied backend parameters" : "Los parámetros del sistema no son válidos", + "Unsatisfied authentication mechanism parameters" : "Los parámetros del mecanismo de autentificación no son válidos", + "Insufficient data: %s" : "Datos insuficientes: %s", + "%s" : "%s", "Personal" : "Personal", "System" : "Sistema", "Grant access" : "Conceder acceso", @@ -84,7 +94,7 @@ OC.L10N.register( "Scope" : "Ámbito", "External Storage" : "Almacenamiento externo", "Folder name" : "Nombre de la carpeta", - "Authentication" : "Autenticación", + "Authentication" : "Autentificación", "Configuration" : "Configuración", "Available for" : "Disponible para", "Add storage" : "Añadir almacenamiento", diff --git a/apps/files_external/l10n/es.json b/apps/files_external/l10n/es.json index 1c60cd5fdea..bf0624e96db 100644 --- a/apps/files_external/l10n/es.json +++ b/apps/files_external/l10n/es.json @@ -1,11 +1,21 @@ { "translations": { + "Fetching request tokens failed. Verify that your app key and secret are correct." : "Fallo al acceder a los tokens solicitados. Verfique que su clave de app y la clave secreta son correctas.", + "Fetching access tokens failed. Verify that your app key and secret are correct." : "Fallo al acceder a los tokens solicitados. Verfique que su clave de app y la clave secreta son correctas.", + "Please provide a valid app key and secret." : "Por favor facilite una clave de app y una clave secreta válidas.", "Step 1 failed. Exception: %s" : "El paso 1 falló. Excepción: %s", "Step 2 failed. Exception: %s" : "El paso 2 falló. Excepción: %s", "External storage" : "Almacenamiento externo", "Storage with id \"%i\" not found" : "No se ha encontrado almacenamiento con id \"%i\"", + "Invalid backend or authentication mechanism class" : "Sistema o mecanismo de autentificación inválido", "Invalid mount point" : "Punto de montaje no válido", + "Objectstore forbidden" : "Objeto de almacenaje prohibido", "Invalid storage backend \"%s\"" : "Motor de almacenamiento no válido «%s»", - "Not permitted to use authentication mechanism \"%s\"" : "No está permitido usar el mecanismo de autenticación \"%s\"", + "Not permitted to use backend \"%s\"" : "No se permite usar el mecanismo \"%s\"", + "Not permitted to use authentication mechanism \"%s\"" : "No está permitido usar el mecanismo de autentificación \"%s\"", + "Unsatisfied backend parameters" : "Los parámetros del sistema no son válidos", + "Unsatisfied authentication mechanism parameters" : "Los parámetros del mecanismo de autentificación no son válidos", + "Insufficient data: %s" : "Datos insuficientes: %s", + "%s" : "%s", "Personal" : "Personal", "System" : "Sistema", "Grant access" : "Conceder acceso", @@ -82,7 +92,7 @@ "Scope" : "Ámbito", "External Storage" : "Almacenamiento externo", "Folder name" : "Nombre de la carpeta", - "Authentication" : "Autenticación", + "Authentication" : "Autentificación", "Configuration" : "Configuración", "Available for" : "Disponible para", "Add storage" : "Añadir almacenamiento", diff --git a/apps/files_external/l10n/fr.js b/apps/files_external/l10n/fr.js index 8ff4fcdfdd9..8d5f7e911b7 100644 --- a/apps/files_external/l10n/fr.js +++ b/apps/files_external/l10n/fr.js @@ -17,6 +17,7 @@ OC.L10N.register( "Unsatisfied backend parameters" : "Paramètres manquants pour le service", "Unsatisfied authentication mechanism parameters" : "Paramètres manquants pour la méthode d'authentification", "Insufficient data: %s" : "Données insuffisantes : %s", + "%s" : "%s", "Personal" : "Personnel", "System" : "Système", "Grant access" : "Autoriser l'accès", diff --git a/apps/files_external/l10n/fr.json b/apps/files_external/l10n/fr.json index 9a610bd964b..cae66119a4f 100644 --- a/apps/files_external/l10n/fr.json +++ b/apps/files_external/l10n/fr.json @@ -15,6 +15,7 @@ "Unsatisfied backend parameters" : "Paramètres manquants pour le service", "Unsatisfied authentication mechanism parameters" : "Paramètres manquants pour la méthode d'authentification", "Insufficient data: %s" : "Données insuffisantes : %s", + "%s" : "%s", "Personal" : "Personnel", "System" : "Système", "Grant access" : "Autoriser l'accès", diff --git a/apps/files_external/l10n/nl.js b/apps/files_external/l10n/nl.js index 05d1a3f6de5..5051689216f 100644 --- a/apps/files_external/l10n/nl.js +++ b/apps/files_external/l10n/nl.js @@ -17,6 +17,7 @@ OC.L10N.register( "Unsatisfied backend parameters" : "Onvoldoende backend parameters", "Unsatisfied authentication mechanism parameters" : "Onvoldoende authenticatiemechanisme parameters", "Insufficient data: %s" : "Onvoldoende gegevens: %s", + "%s" : "%s", "Personal" : "Persoonlijk", "System" : "Systeem", "Grant access" : "Sta toegang toe", diff --git a/apps/files_external/l10n/nl.json b/apps/files_external/l10n/nl.json index e30870e4ae1..d8a254bad1b 100644 --- a/apps/files_external/l10n/nl.json +++ b/apps/files_external/l10n/nl.json @@ -15,6 +15,7 @@ "Unsatisfied backend parameters" : "Onvoldoende backend parameters", "Unsatisfied authentication mechanism parameters" : "Onvoldoende authenticatiemechanisme parameters", "Insufficient data: %s" : "Onvoldoende gegevens: %s", + "%s" : "%s", "Personal" : "Persoonlijk", "System" : "Systeem", "Grant access" : "Sta toegang toe", diff --git a/apps/files_external/l10n/th_TH.js b/apps/files_external/l10n/th_TH.js index 6c1efa5aacd..bb9c2dc909d 100644 --- a/apps/files_external/l10n/th_TH.js +++ b/apps/files_external/l10n/th_TH.js @@ -17,6 +17,7 @@ OC.L10N.register( "Unsatisfied backend parameters" : "พารามิเตอร์แบ็กเอนด์ไม่ได้รับอนุญาต", "Unsatisfied authentication mechanism parameters" : "การรับรองความถูกต้องไม่เพียงพอ", "Insufficient data: %s" : "ข้อมูลไม่เพียงพอ: %s", + "%s" : "%s", "Personal" : "ส่วนตัว", "System" : "ระบบ", "Grant access" : "อนุญาตให้เข้าถึงได้", diff --git a/apps/files_external/l10n/th_TH.json b/apps/files_external/l10n/th_TH.json index 3de48d733d3..f38d99ae88b 100644 --- a/apps/files_external/l10n/th_TH.json +++ b/apps/files_external/l10n/th_TH.json @@ -15,6 +15,7 @@ "Unsatisfied backend parameters" : "พารามิเตอร์แบ็กเอนด์ไม่ได้รับอนุญาต", "Unsatisfied authentication mechanism parameters" : "การรับรองความถูกต้องไม่เพียงพอ", "Insufficient data: %s" : "ข้อมูลไม่เพียงพอ: %s", + "%s" : "%s", "Personal" : "ส่วนตัว", "System" : "ระบบ", "Grant access" : "อนุญาตให้เข้าถึงได้", diff --git a/core/l10n/nl.js b/core/l10n/nl.js index ffff693e95c..9e2bc2d345e 100644 --- a/core/l10n/nl.js +++ b/core/l10n/nl.js @@ -18,6 +18,8 @@ OC.L10N.register( "Repair error: " : "Reparatiefout:", "Set log level to debug - current level: \"%s\"" : "Instellen logniveau op debug - huidige niveau: \"%s\"", "Reset log level to \"%s\"" : "Terugzetten logniveau op \"#%s\"", + "Starting code integrity check" : "Starten code betrouwbaarheidscontrole", + "Finished code integrity check" : "Gereed met code betrouwbaarheidscontrole", "%s (3rdparty)" : "%s (3rdparty)", "%s (incompatible)" : "%s (incompatibel)", "Following apps have been disabled: %s" : "De volgende apps zijn gedeactiveerd: %s", @@ -77,6 +79,7 @@ OC.L10N.register( "Oct." : "Okt.", "Nov." : "Nov.", "Dec." : "Dec.", + "There were problems with the code integrity check. More information…" : "Er traden problemen op tijdens de code betrouwbaarheidscontrole. Meer informatie…", "Settings" : "Instellingen", "Saving..." : "Opslaan", "seconds ago" : "seconden geleden", @@ -116,6 +119,7 @@ OC.L10N.register( "Your PHP version ({version}) is no longer supported by PHP. We encourage you to upgrade your PHP version to take advantage of performance and security updates provided by PHP." : "UwPHP versie ({version}) wordt niet langer ondersteund door PHP. We adviseren u om uw PHP versie te upgraden voor betere prestaties en security updates geleverd door PHP.", "The reverse proxy headers configuration is incorrect, or you are accessing ownCloud from a trusted proxy. If you are not accessing ownCloud from a trusted proxy, this is a security issue and can allow an attacker to spoof their IP address as visible to ownCloud. Further information can be found in our documentation." : "De reverse proxy headerconfiguratie is onjuist, of u hebt toegang tot ownCloud via een vertrouwde proxy. Als u ownCloud niet via een vertrouwde proxy benadert, dan levert dan een beveiligingsrisico op, waardoor een aanvaller het IP-adres dat ownCloud ziet kan spoofen. Meer informatie is te vinden in onze documentatie.", "Memcached is configured as distributed cache, but the wrong PHP module \"memcache\" is installed. \\OC\\Memcache\\Memcached only supports \"memcached\" and not \"memcache\". See the memcached wiki about both modules." : "Memcached is geconfigureerd als gedistribueerde cache, maar de verkeerde PHP module \"memcache\" is geïnstalleerd. \\OC\\Memcache\\Memcached ondersteunt alleen \"memcached\" en niet \"memcache\". Zie de memcached wiki over beide modules.", + "Some files have not passed the integrity check. Further information on how to resolve this issue can be found in our documentation. (List of invalid files… / Rescan…)" : "Sommige bestanden kwamen niet door de code betrouwbaarheidscontrole. Meer informatie over het oplossen van dit probleem kan worden gevonden in onze documentatie. (Lijst met ongeldige bestanden… / Opnieuw…)", "Error occurred while checking server setup" : "Een fout trad op bij checken serverconfiguratie", "The \"{header}\" HTTP header is not configured to equal to \"{expected}\". This is a potential security or privacy risk and we recommend adjusting this setting." : "De \"{header}\" HTTP header is niet overeenkomstig met \"{expected}\" geconfigureerd. Dit is een potentieel security of privacy risico en we adviseren om deze instelling te wijzigen.", "The \"Strict-Transport-Security\" HTTP header is not configured to least \"{seconds}\" seconds. For enhanced security we recommend enabling HSTS as described in our security tips." : "De \"Strict-Transport-Security\" HTTP header is niet geconfigureerd als minimaal \"{seconds}\" seconden. Voor verbeterde beveiliging adviseren we HSTS in te schakelen zoals beschreven in onze security tips.", @@ -187,6 +191,7 @@ OC.L10N.register( "Couldn't reset password because the token is invalid" : "Kon het wachtwoord niet herstellen, omdat het token ongeldig is", "Couldn't reset password because the token is expired" : "Kon het wachtwoord niet herstellen, omdat het token verlopen is", "Couldn't send reset email. Please make sure your username is correct." : "Kon e-mail niet versturen. Verifieer of uw gebruikersnaam correct is.", + "Could not send reset email because there is no email address for this username. Please contact your administrator." : "Kon geen herstel e-mail versturen, omdat er geen e-mailadres bekend is bij deze gebruikersnaam. Neem contact op met uw beheerder.", "%s password reset" : "%s wachtwoord reset", "Use the following link to reset your password: {link}" : "Gebruik de volgende link om uw wachtwoord te resetten: {link}", "New password" : "Nieuw wachtwoord", diff --git a/core/l10n/nl.json b/core/l10n/nl.json index a387d496092..d565545ce38 100644 --- a/core/l10n/nl.json +++ b/core/l10n/nl.json @@ -16,6 +16,8 @@ "Repair error: " : "Reparatiefout:", "Set log level to debug - current level: \"%s\"" : "Instellen logniveau op debug - huidige niveau: \"%s\"", "Reset log level to \"%s\"" : "Terugzetten logniveau op \"#%s\"", + "Starting code integrity check" : "Starten code betrouwbaarheidscontrole", + "Finished code integrity check" : "Gereed met code betrouwbaarheidscontrole", "%s (3rdparty)" : "%s (3rdparty)", "%s (incompatible)" : "%s (incompatibel)", "Following apps have been disabled: %s" : "De volgende apps zijn gedeactiveerd: %s", @@ -75,6 +77,7 @@ "Oct." : "Okt.", "Nov." : "Nov.", "Dec." : "Dec.", + "There were problems with the code integrity check. More information…" : "Er traden problemen op tijdens de code betrouwbaarheidscontrole. Meer informatie…", "Settings" : "Instellingen", "Saving..." : "Opslaan", "seconds ago" : "seconden geleden", @@ -114,6 +117,7 @@ "Your PHP version ({version}) is no longer supported by PHP. We encourage you to upgrade your PHP version to take advantage of performance and security updates provided by PHP." : "UwPHP versie ({version}) wordt niet langer ondersteund door PHP. We adviseren u om uw PHP versie te upgraden voor betere prestaties en security updates geleverd door PHP.", "The reverse proxy headers configuration is incorrect, or you are accessing ownCloud from a trusted proxy. If you are not accessing ownCloud from a trusted proxy, this is a security issue and can allow an attacker to spoof their IP address as visible to ownCloud. Further information can be found in our documentation." : "De reverse proxy headerconfiguratie is onjuist, of u hebt toegang tot ownCloud via een vertrouwde proxy. Als u ownCloud niet via een vertrouwde proxy benadert, dan levert dan een beveiligingsrisico op, waardoor een aanvaller het IP-adres dat ownCloud ziet kan spoofen. Meer informatie is te vinden in onze documentatie.", "Memcached is configured as distributed cache, but the wrong PHP module \"memcache\" is installed. \\OC\\Memcache\\Memcached only supports \"memcached\" and not \"memcache\". See the memcached wiki about both modules." : "Memcached is geconfigureerd als gedistribueerde cache, maar de verkeerde PHP module \"memcache\" is geïnstalleerd. \\OC\\Memcache\\Memcached ondersteunt alleen \"memcached\" en niet \"memcache\". Zie de memcached wiki over beide modules.", + "Some files have not passed the integrity check. Further information on how to resolve this issue can be found in our documentation. (List of invalid files… / Rescan…)" : "Sommige bestanden kwamen niet door de code betrouwbaarheidscontrole. Meer informatie over het oplossen van dit probleem kan worden gevonden in onze documentatie. (Lijst met ongeldige bestanden… / Opnieuw…)", "Error occurred while checking server setup" : "Een fout trad op bij checken serverconfiguratie", "The \"{header}\" HTTP header is not configured to equal to \"{expected}\". This is a potential security or privacy risk and we recommend adjusting this setting." : "De \"{header}\" HTTP header is niet overeenkomstig met \"{expected}\" geconfigureerd. Dit is een potentieel security of privacy risico en we adviseren om deze instelling te wijzigen.", "The \"Strict-Transport-Security\" HTTP header is not configured to least \"{seconds}\" seconds. For enhanced security we recommend enabling HSTS as described in our security tips." : "De \"Strict-Transport-Security\" HTTP header is niet geconfigureerd als minimaal \"{seconds}\" seconden. Voor verbeterde beveiliging adviseren we HSTS in te schakelen zoals beschreven in onze security tips.", @@ -185,6 +189,7 @@ "Couldn't reset password because the token is invalid" : "Kon het wachtwoord niet herstellen, omdat het token ongeldig is", "Couldn't reset password because the token is expired" : "Kon het wachtwoord niet herstellen, omdat het token verlopen is", "Couldn't send reset email. Please make sure your username is correct." : "Kon e-mail niet versturen. Verifieer of uw gebruikersnaam correct is.", + "Could not send reset email because there is no email address for this username. Please contact your administrator." : "Kon geen herstel e-mail versturen, omdat er geen e-mailadres bekend is bij deze gebruikersnaam. Neem contact op met uw beheerder.", "%s password reset" : "%s wachtwoord reset", "Use the following link to reset your password: {link}" : "Gebruik de volgende link om uw wachtwoord te resetten: {link}", "New password" : "Nieuw wachtwoord", diff --git a/lib/l10n/fr.js b/lib/l10n/fr.js index e9b4b52f51f..014b6c24e59 100644 --- a/lib/l10n/fr.js +++ b/lib/l10n/fr.js @@ -149,6 +149,7 @@ OC.L10N.register( "Storage unauthorized. %s" : "Espace de stockage non autorisé. %s", "Storage incomplete configuration. %s" : "Configuration de l'espace de stockage incomplète. %s", "Storage connection error. %s" : "Erreur de connexion à l'espace stockage. %s", - "Storage not available" : "Support de stockage non disponible" + "Storage not available" : "Support de stockage non disponible", + "Storage connection timeout. %s" : "Le délai d'attente pour la connexion à l'espace de stockage a été dépassé. %s" }, "nplurals=2; plural=(n > 1);"); diff --git a/lib/l10n/fr.json b/lib/l10n/fr.json index 7da5eaedd75..feaae43bf41 100644 --- a/lib/l10n/fr.json +++ b/lib/l10n/fr.json @@ -147,6 +147,7 @@ "Storage unauthorized. %s" : "Espace de stockage non autorisé. %s", "Storage incomplete configuration. %s" : "Configuration de l'espace de stockage incomplète. %s", "Storage connection error. %s" : "Erreur de connexion à l'espace stockage. %s", - "Storage not available" : "Support de stockage non disponible" + "Storage not available" : "Support de stockage non disponible", + "Storage connection timeout. %s" : "Le délai d'attente pour la connexion à l'espace de stockage a été dépassé. %s" },"pluralForm" :"nplurals=2; plural=(n > 1);" } \ No newline at end of file diff --git a/lib/l10n/nl.js b/lib/l10n/nl.js index 24e087a50f5..f4201778f7e 100644 --- a/lib/l10n/nl.js +++ b/lib/l10n/nl.js @@ -147,6 +147,10 @@ OC.L10N.register( "Data directory (%s) is invalid" : "Data directory (%s) is ongeldig", "Please check that the data directory contains a file \".ocdata\" in its root." : "Verifieer dat de data directory een bestand \".ocdata\" in de hoofdmap heeft.", "Could not obtain lock type %d on \"%s\"." : "Kon geen lock type %d krijgen op \"%s\".", - "Storage not available" : "Opslag niet beschikbaar" + "Storage unauthorized. %s" : "Opslag niet toegestaan. %s", + "Storage incomplete configuration. %s" : "Incomplete opslagconfiguratie. %s", + "Storage connection error. %s" : "Opslagverbindingsfout. %s", + "Storage not available" : "Opslag niet beschikbaar", + "Storage connection timeout. %s" : "Opslagverbinding time-out. %s" }, "nplurals=2; plural=(n != 1);"); diff --git a/lib/l10n/nl.json b/lib/l10n/nl.json index 691f3e08240..c8981f8fd4c 100644 --- a/lib/l10n/nl.json +++ b/lib/l10n/nl.json @@ -145,6 +145,10 @@ "Data directory (%s) is invalid" : "Data directory (%s) is ongeldig", "Please check that the data directory contains a file \".ocdata\" in its root." : "Verifieer dat de data directory een bestand \".ocdata\" in de hoofdmap heeft.", "Could not obtain lock type %d on \"%s\"." : "Kon geen lock type %d krijgen op \"%s\".", - "Storage not available" : "Opslag niet beschikbaar" + "Storage unauthorized. %s" : "Opslag niet toegestaan. %s", + "Storage incomplete configuration. %s" : "Incomplete opslagconfiguratie. %s", + "Storage connection error. %s" : "Opslagverbindingsfout. %s", + "Storage not available" : "Opslag niet beschikbaar", + "Storage connection timeout. %s" : "Opslagverbinding time-out. %s" },"pluralForm" :"nplurals=2; plural=(n != 1);" } \ No newline at end of file -- cgit v1.2.3 From f55a56ff6cea0f411b864549693e4783bcac69bb Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Tue, 8 Dec 2015 09:45:20 +0100 Subject: Use proper PHPDoc reference --- apps/files_external/lib/storageconfig.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'apps/files_external') diff --git a/apps/files_external/lib/storageconfig.php b/apps/files_external/lib/storageconfig.php index 97e0386be73..49a40a9a5d7 100644 --- a/apps/files_external/lib/storageconfig.php +++ b/apps/files_external/lib/storageconfig.php @@ -163,7 +163,7 @@ class StorageConfig implements \JsonSerializable { } /** - * @param Backend + * @param Backend $backend */ public function setBackend(Backend $backend) { $this->backend= $backend; @@ -177,7 +177,7 @@ class StorageConfig implements \JsonSerializable { } /** - * @param AuthMechanism + * @param AuthMechanism $authMechanism */ public function setAuthMechanism(AuthMechanism $authMechanism) { $this->authMechanism = $authMechanism; -- cgit v1.2.3