This commit is contained in:
Luke Pulverenti 2016-06-05 00:49:37 -04:00
commit 3f6ad34388
6 changed files with 25 additions and 38 deletions

View File

@ -43,7 +43,7 @@
reloadItems(page); reloadItems(page);
}, onApiFailure); }, Dashboard.processErrorResponse);
}); });
}); });
} }
@ -101,7 +101,7 @@
reloadItems(page); reloadItems(page);
}, onApiFailure); }, Dashboard.processErrorResponse);
}); });
}); });
} }
@ -116,7 +116,7 @@
renderResults(page, result); renderResults(page, result);
Dashboard.hideLoadingMsg(); Dashboard.hideLoadingMsg();
}, onApiFailure); }, Dashboard.processErrorResponse);
} }
function getStatusText(item, enhance) { function getStatusText(item, enhance) {
@ -273,26 +273,6 @@
} }
} }
function onApiFailure(e) {
Dashboard.hideLoadingMsg();
if (e.status == 0) {
Dashboard.alert({
title: 'Auto-Organize',
message: 'The operation is going to take a little longer. The view will be updated on completion.'
});
}
else {
Dashboard.alert({
title: Globalize.translate('AutoOrganizeError'),
message: Globalize.translate('ErrorOrganizingFileWithErrorCode', e.headers.get('X-Application-Error-Code'))
});
}
}
function getTabs() { function getTabs() {
return [ return [
{ {
@ -317,7 +297,7 @@
ApiClient.clearOrganizationLog().then(function () { ApiClient.clearOrganizationLog().then(function () {
reloadItems(page); reloadItems(page);
}, onApiFailure); }, Dashboard.processErrorResponse);
}); });
}).on('pageshow', '#libraryFileOrganizerLogPage', function () { }).on('pageshow', '#libraryFileOrganizerLogPage', function () {

View File

@ -96,15 +96,6 @@
$('.divMatchInfos', page).html(html); $('.divMatchInfos', page).html(html);
} }
function onApiFailure(e) {
Dashboard.hideLoadingMsg();
Dashboard.alert({
message: Globalize.translate('DefaultErrorMessage')
});
}
function getTabs() { function getTabs() {
return [ return [
{ {
@ -142,7 +133,7 @@
reloadList(page); reloadList(page);
}, onApiFailure); }, Dashboard.processErrorResponse);
}); });

View File

@ -103,7 +103,7 @@
tvOptions.CopyOriginalFile = $('#copyOrMoveFile', form).val(); tvOptions.CopyOriginalFile = $('#copyOrMoveFile', form).val();
ApiClient.updateNamedConfiguration('autoorganize', config).then(Dashboard.processServerConfigurationUpdateResult); ApiClient.updateNamedConfiguration('autoorganize', config).then(Dashboard.processServerConfigurationUpdateResult, Dashboard.processErrorResponse);
}); });
return false; return false;

View File

@ -16,7 +16,7 @@
config.WanDdns = $('#txtDdns', form).val(); config.WanDdns = $('#txtDdns', form).val();
config.CertificatePath = $('#txtCertificatePath', form).val(); config.CertificatePath = $('#txtCertificatePath', form).val();
ApiClient.updateServerConfiguration(config).then(Dashboard.processServerConfigurationUpdateResult); ApiClient.updateServerConfiguration(config).then(Dashboard.processServerConfigurationUpdateResult, Dashboard.processErrorResponse);
}); });
// Disable default form submission // Disable default form submission

View File

@ -869,7 +869,7 @@
require(['toast'], function (toast) { require(['toast'], function (toast) {
toast('Settings saved.'); toast('Settings saved.');
}); });
}); }, Dashboard.processErrorResponse);
} else { } else {
@ -882,7 +882,7 @@
Dashboard.navigate('dlnaprofiles.html'); Dashboard.navigate('dlnaprofiles.html');
}); }, Dashboard.processErrorResponse);
} }

View File

@ -455,6 +455,22 @@ var Dashboard = {
}); });
}, },
processErrorResponse: function (response) {
Dashboard.hideLoadingMsg();
var status = '' + response.status;
if (response.statusText) {
status = response.statusText;
}
Dashboard.alert({
title: status,
message: response.headers ? response.headers.get('X-Application-Error-Code') : null
});
},
alert: function (options) { alert: function (options) {
if (typeof options == "string") { if (typeof options == "string") {