Add icon management capabilities (error icon)

This commit is contained in:
Jesús Macias 2015-11-13 12:57:33 +01:00
parent 394d3eb0cd
commit a413f8eccc
2 changed files with 18 additions and 17 deletions

View File

@ -88,14 +88,14 @@ OCA.External.StatusManager = {
if (response && response.status === 0) { if (response && response.status === 0) {
self.mountStatus[mountData.mount_point] = response; self.mountStatus[mountData.mount_point] = response;
} else { } else {
if (response && response.data) { if (response && response.statusMessage) {
// failure response with error message // failure response with error message
self.mountStatus[mountData.mount_point] = {code: 'GE', self.mountStatus[mountData.mount_point] = {code: 'GE',
status: 'fail', status: 1,
error: response.data.message}; error: response.statusMessage};
} else { } else {
self.mountStatus[mountData.mount_point] = {code: 'GE', self.mountStatus[mountData.mount_point] = {code: 'GE',
status: 'fail', status: 1,
error: t('files_external', 'Empty response from the server')}; 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}); 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] = {code: 'GE',
status: 'fail', status: 1,
location: mountData.location, location: mountData.location,
error: message}; error: message};
afterCallback(mountData.mount_point, self.mountStatus[mountData.mount_point]); afterCallback(mountData.mount_point, self.mountStatus[mountData.mount_point]);
@ -171,7 +171,7 @@ OCA.External.StatusManager = {
manageMountPointError : function(name) { manageMountPointError : function(name) {
var self = this; var self = this;
this.getMountStatus($.proxy(function(allMountStatus) { 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]; var mountData = allMountStatus[name];
if ((mountData.code === 'CNP' || mountData.code === 'AD') && mountData.type === 'global' && mountData.location === 1) { 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 // 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')); OC.dialogs.message(mountData.error, t('files_external', 'Login credentials error'));
} else { } else {
OC.dialogs.message(mountData.error, t('files_external', 'Unknown error')); OC.dialogs.message(mountData.error, t('files_external', 'External mount error'));
} }
} }
}, this)); }, this));
@ -222,7 +222,7 @@ OCA.External.StatusManager = {
$.get(OC.filePath('files_external', 'ajax', 'dialog.php'), $.get(OC.filePath('files_external', 'ajax', 'dialog.php'),
sendParams, sendParams,
function(data) { function(data) {
if (typeof data.status !== 'undefined' && data.status === 'success') { if (typeof data.status !== 'undefined' && data.status === 0) {
$('body').append(data.form); $('body').append(data.form);
var wnd_send_button_click_func = function () { var wnd_send_button_click_func = function () {
$('.oc-dialog-close').hide(); $('.oc-dialog-close').hide();
@ -240,7 +240,7 @@ OCA.External.StatusManager = {
data: dataToSend, data: dataToSend,
success: function (data) { success: function (data) {
var dialog = $('#wnd_div_form'); var dialog = $('#wnd_div_form');
if (typeof(data.status) !== 'undefined' && data.status === 'success') { if (typeof(data.status) !== 'undefined' && data.status === 0) {
dialog.ocdialog('close'); dialog.ocdialog('close');
if (successCallback && $.isFunction(successCallback)) { if (successCallback && $.isFunction(successCallback)) {
@ -284,23 +284,24 @@ OCA.External.StatusManager = {
if (!this.notificationHasShown) { if (!this.notificationHasShown) {
this.notificationHasShown = true; this.notificationHasShown = true;
if (hasErrors) { 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) { processMountStatusIndividual : function(mountPoint, mountData) {
if (mountData.status === 'fail') { if (mountData.status === 1) {
var errorImage = 'folder-windows'; var errorImage = 'folder-windows-error';
/*
if (mountData.code === 'AD' || mountData.code === 'CNP') { if (mountData.code === 'AD' || mountData.code === 'CNP') {
errorImage += '-credentials'; errorImage += '-credentials';
} else if (mountData.code === 'IH' || mountData.code === 'CE') { } else if (mountData.code === 'IH' || mountData.code === 'CE') {
errorImage += '-timeout'; errorImage += '-timeout';
} else { } else {
errorImage += '-error'; errorImage += '-error';
} }*/
if (OCA.External.StatusManager.Utils.isCorrectViewAndRootFolder()) { 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; return false;
} else { } else {
@ -398,13 +399,13 @@ OCA.External.StatusManager = {
if (!self.notificationHasShown) { if (!self.notificationHasShown) {
var showNotification = false; var showNotification = false;
$.each(self.mountStatus, function(key, value){ $.each(self.mountStatus, function(key, value){
if (value.status === 'fail') { if (value.status === 1) {
self.notificationHasShown = true; self.notificationHasShown = true;
showNotification = true; showNotification = true;
} }
}); });
if (showNotification) { 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'));
} }
} }
}); });

View File

@ -100,7 +100,7 @@ OCA.External.StatusManager.Utils = {
} else { } else {
file = $("#fileList tr[data-file=\"" + this.jqSelEscape(filename) + "\"] > td:first-child div.thumbnail"); 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 // previous line is required in Chrome to force the css update so the image url
// is stored correctly later // is stored correctly later
//file.css('background-image', route).height(); //file.css('background-image', route).height();