Use toastr notifications instead of statusBarSet()

This commit is contained in:
Pablo Vazquez 2017-10-02 19:31:52 +02:00
parent 9870979c54
commit d3cd6a884e
6 changed files with 29 additions and 34 deletions

View File

@ -53,7 +53,7 @@ function setup_file_uploader(index, upload_element) {
beforeSend: function (xhr, data) { beforeSend: function (xhr, data) {
var token = this.fileInput.attr('data-token'); var token = this.fileInput.attr('data-token');
xhr.setRequestHeader('Authorization', 'basic ' + btoa(token + ':')); xhr.setRequestHeader('Authorization', 'basic ' + btoa(token + ':'));
statusBarSet('info', 'Uploading File...', 'pi-upload-cloud'); toastr.info('Uploading file...');
// console.log('Uploading from', upload_element, upload_element.value); // console.log('Uploading from', upload_element, upload_element.value);
@ -114,7 +114,7 @@ function setup_file_uploader(index, upload_element) {
$('.node-edit-title').html(filename); $('.node-edit-title').html(filename);
} }
statusBarSet('success', 'File Uploaded Successfully', 'pi-check'); toastr.success('File uploaded!');
set_progress_bar(100); set_progress_bar(100);
$('body').trigger('file-upload:finished'); $('body').trigger('file-upload:finished');
@ -131,9 +131,7 @@ function setup_file_uploader(index, upload_element) {
uploadErrors.push(fileupload.messages[key]); uploadErrors.push(fileupload.messages[key]);
} }
statusBarSet('error', toastr.error(uploadErrors.join("; "), 'Upload error');
'Upload error: ' + uploadErrors.join("; "),
'pi-attention', 16000);
set_progress_bar(100, 'progress-error'); set_progress_bar(100, 'progress-error');
@ -166,9 +164,9 @@ $(function () {
if (slug) { if (slug) {
document.getElementById('description').value += widget; document.getElementById('description').value += widget;
statusBarSet('success', 'Attachment appended to description', 'pi-check'); toastr.success('Attachment appended to description');
} else { } else {
statusBarSet('error', 'Slug is empty, upload something first', 'pi-warning'); toastr.error('Slug is empty, upload something first');
} }
}) })
; ;

View File

@ -41,7 +41,7 @@ function addNode(nodeTypeName, parentId) {
$('.button-add-group-icon').addClass('pi-collection-plus').removeClass('pi-spin spin'); $('.button-add-group-icon').addClass('pi-collection-plus').removeClass('pi-spin spin');
}) })
.fail(function(data){ .fail(function(data){
statusBarSet('error', 'Error creating node (' + data.status + ' - ' + data.statusText + ')', 'pi-warning', 5000); toastr.error(data.status + ' - ' + data.statusText, 'Error creating node');
}); });
} }
@ -122,13 +122,13 @@ $( document ).ready(function() {
$.post(urlNodeMove, moveNodeParams, $.post(urlNodeMove, moveNodeParams,
function(data){ function(data){
}).done(function() { }).done(function() {
statusBarSet('success', 'Moved just fine'); toastr.success('Moved!');
Cookies.remove('bcloud_moving_node'); Cookies.remove('bcloud_moving_node');
moveModeExit(); moveModeExit();
$('#project_tree').jstree("refresh"); $('#project_tree').jstree("refresh");
}) })
.fail(function(data){ .fail(function(data){
statusBarSet('error', 'Error moving node (' + data.status + ' - ' + data.statusText + ')', 'pi-warning', 6000); toastr.error(data.status + ' - ' + data.statusText, 'Error moving node');
$(this).html('<i class="pi-check"></i> Move Here'); $(this).html('<i class="pi-check"></i> Move Here');
}); });
}); });
@ -149,10 +149,10 @@ $( document ).ready(function() {
// Feedback logic // Feedback logic
}) })
.done(function(){ .done(function(){
statusBarSet('success', 'Featured status toggled successfully', 'pi-star-filled'); toastr.success('Featured status toggled');
}) })
.fail(function(data){ .fail(function(data){
statusBarSet('error', 'Error toggling feature (' + data.status + ' - ' + data.statusText + ')', 'pi-warning', 6000); toastr.error(data.status + ' - ' + data.statusText, 'Error toggling featured status');
}); });
}); });
@ -163,16 +163,16 @@ $( document ).ready(function() {
$.post(urlNodeToggleProjHeader, {node_id: ProjectUtils.nodeId()}) $.post(urlNodeToggleProjHeader, {node_id: ProjectUtils.nodeId()})
.done(function (data) { .done(function (data) {
statusBarSet('success', 'Project Header ' + data.action + ' successfully', 'pi-star-filled'); toastr.success('Project header ' + data.action + '!');
}) })
.fail(function (jsxhr) { .fail(function (jsxhr) {
var content_type = jsxhr.getResponseHeader('Content-Type'); var content_type = jsxhr.getResponseHeader('Content-Type');
if(content_type.startsWith('application/json')) { if(content_type.startsWith('application/json')) {
var data = jsxhr.responseJSON; var data = jsxhr.responseJSON;
statusBarSet('error', 'Error toggling (' + data.messsage + ')', 'pi-warning', 6000); toastr.error(data.message, 'Error toggling header');
} else { } else {
statusBarSet('error', 'Error toggling (' + jsxhr.responseText + ')', 'pi-warning', 6000); toastr.error(jsxhr.responseText, 'Error toggling header');
} }
}); });
}); });
@ -196,7 +196,7 @@ $( document ).ready(function() {
// Feedback logic // Feedback logic
}) })
.done(function () { .done(function () {
statusBarSet('success', 'Deleted successfully', 'pi-trash'); toastr.success('Deleted!');
if (ProjectUtils.parentNodeId() != '') { if (ProjectUtils.parentNodeId() != '') {
displayNode(ProjectUtils.parentNodeId()); displayNode(ProjectUtils.parentNodeId());
@ -211,7 +211,7 @@ $( document ).ready(function() {
}) })
.fail(function (data) { .fail(function (data) {
statusBarSet('error', 'Error deleting (' + data.status + ' - ' + data.statusText + ')', 'pi-warning', 6000); toastr.error(data.status + ' - ' + data.statusText, 'Error deleting');
}); });
} }
}); });
@ -226,11 +226,11 @@ $( document ).ready(function() {
// Feedback logic // Feedback logic
}) })
.done(function(data){ .done(function(data){
statusBarSet('success', data.data.message); toastr.success(data.data.message);
displayNode(currentNodeId); displayNode(currentNodeId);
}) })
.fail(function(data){ .fail(function(data){
statusBarSet('error', 'Error toggling status (' + data.status + ' - ' + data.statusText + ')', 'pi-warning', 6000); toastr.error(data.status + ' - ' + data.statusText, 'Error toggling status');
}); });
}); });

View File

@ -155,7 +155,7 @@ script(type="text/javascript").
var $file = $('.form-group.file #file'); var $file = $('.form-group.file #file');
if ($file.val() == '') { if ($file.val() == '') {
$file.addClass('error'); $file.addClass('error');
statusBarSet('error', 'No File Selected', 'pi-warning', 5000); toastr.error('No file selected');
return jQuery.Deferred().reject("nofile"); return jQuery.Deferred().reject("nofile");
} }
@ -173,10 +173,9 @@ script(type="text/javascript").
.fail(function(data){ .fail(function(data){
/* Something went wrong, print it */ /* Something went wrong, print it */
if (data.status == 422) { if (data.status == 422) {
statusBarSet('error', 'The submitted data could not be validated.', 'pi-warning', 8000); toastr.error('The submitted data could not be validated');
} else { } else {
statusBarSet('error', "Error! We've been notified and are working on it - " toastr.error(data.status + ' ' + data.statusText, 'Error saving');
+ data.status + ' ' + data.statusText, 'pi-warning', 8000);
} }
$("li.button-save").addClass('field-error'); $("li.button-save").addClass('field-error');
@ -196,7 +195,7 @@ script(type="text/javascript").
{% if is_embedded_edit %} {% if is_embedded_edit %}
/* Load content*/ /* Load content*/
$('#project_context').html(dataHtml); $('#project_context').html(dataHtml);
statusBarSet('success', 'Saved Successfully', 'pi-check'); toastr.success('Saved!');
/* Style button */ /* Style button */
$("li.button-save").removeClass('saving field-error'); $("li.button-save").removeClass('saving field-error');

View File

@ -112,10 +112,8 @@ script.
.addClass('processing'); .addClass('processing');
var item_url = '/o/' + item_id; var item_url = '/o/' + item_id;
statusBarSet('default', 'Loading organization…');
$.get(item_url, function(item_data) { $.get(item_url, function(item_data) {
statusBarClear();
$('#item-details').html(item_data); $('#item-details').html(item_data);
current_item current_item
@ -129,7 +127,7 @@ script.
} }
current_item.removeClass(clean_classes); current_item.removeClass(clean_classes);
statusBarSet('error', 'Failed to open organization', 'pi-warning'); toastr.error('Failed to open organization');
if (xhr.status) { if (xhr.status) {
$('#item-details').html(xhr.responseText); $('#item-details').html(xhr.responseText);

View File

@ -245,7 +245,7 @@ script.
}) })
.done(function (data) { .done(function (data) {
setTimeout(function(){ $('.sharing-users-item').removeClass('added');}, 350); setTimeout(function(){ $('.sharing-users-item').removeClass('added');}, 350);
statusBarSet('success', 'Member added to this organization!', 'pi-grin'); toastr.success('Member added to this organization!');
// TODO fsiddi: avoid the reloading of the entire page? // TODO fsiddi: avoid the reloading of the entire page?
window.location.reload(); window.location.reload();

View File

@ -79,7 +79,7 @@ script.
if ($found.length) { if ($found.length) {
$found.addClass('active'); $found.addClass('active');
setTimeout(function(){ $('.sharing-users-item').removeClass('active');}, 350); setTimeout(function(){ $('.sharing-users-item').removeClass('active');}, 350);
statusBarSet('info', 'User is already part of the project', 'pi-info'); toastr.info('User is already part of the project');
return; return;
} }
@ -95,7 +95,7 @@ script.
}); });
function addUser(userId){ function addUser(userId){
if (!userId || userId.length == 0) { if (!userId || userId.length == 0) {
statusBarSet('error', 'Please select a user from the list', 'pi-warning'); toastr.warning('Please select a user from the list');
return; return;
} }
@ -137,11 +137,11 @@ script.
$('<i>').addClass('pi-trash').appendTo($button); $('<i>').addClass('pi-trash').appendTo($button);
setTimeout(function(){ $('.sharing-users-item').removeClass('added');}, 350); setTimeout(function(){ $('.sharing-users-item').removeClass('added');}, 350);
statusBarSet('success', 'User added to this project!', 'pi-grin'); toastr.success('User added to this project!');
}) })
.fail(function (jsxhr){ .fail(function (jsxhr){
data = jsxhr.responseJSON; data = jsxhr.responseJSON;
statusBarSet('error', 'Could not add user (' + data.message + ')', 'pi-warning'); toastr.error(data.message, 'Could not add user');
}); });
} }
@ -158,10 +158,10 @@ script.
{user_id: userId, action: 'remove'}) {user_id: userId, action: 'remove'})
.done(function (data) { .done(function (data) {
$("ul.sharing-users-list").find("[user-id='" + userId + "']").remove(); $("ul.sharing-users-list").find("[user-id='" + userId + "']").remove();
statusBarSet('success', 'User removed from this project', 'pi-trash'); toastr.success('User removed from this project');
}) })
.fail(function (data){ .fail(function (data){
statusBarSet('error', 'Could not remove user (' + data._status + ')', 'pi-warning'); toastr.error(data._status, 'Could not remove user');
}); });
} }
}); });