1
0
Fork 0

prep for new notifications, cleanup

This commit is contained in:
Heiko Kernbach 2014-02-17 11:47:58 +01:00
parent c40d930fa6
commit 238396e3c4
10 changed files with 11 additions and 75 deletions

View File

@ -101,49 +101,12 @@
return returnVal;
},
removeNotifications: function () {
$.gritter.removeAll();
this.lastNotificationMessage = null;
arangoNotification: function (message) {
},
arangoNotification: function (message, time) {
var returnVal = false;
$.gritter.add({
title: "Notice:",
text: message,
time: time || 3000,
before_open: function(){
returnVal = true;
}
});
this.lastNotificationMessage = null;
return returnVal;
},
arangoError: function (message) {
var returnVal = false;
$.gritter.add({
title: "Error:",
text: message,
sticky: true,
before_open: function(){
if (this.lastNotificationMessage === message) {
// prevent display the same message over & over
return false;
}
if($('.gritter-item-wrapper').length === 3) {
// not more than 3 messages at once
return false;
}
this.lastNotificationMessage = message;
returnVal = true;
},
before_close: function(){
// reset last text when closing a specific message
this.lastNotificationMessage = null;
}
});
return returnVal;
},
getRandomToken: function () {
return Math.round(new Date().getTime());
},

View File

@ -70,12 +70,8 @@
this.footerView = new window.FooterView();
this.naviView = new window.NavigationView();
// this.statView = new window.StatisticBarView();
// this.userBarView = new window.UserBarView();
this.footerView.render();
this.naviView.render();
// this.statView.render();
// this.userBarView.render();
this.graphView = new window.GraphView({
graphs: this.graphs,
collection: window.arangoCollectionsStore

View File

@ -131,10 +131,6 @@
}
var changeResult = window.arangoCollectionsStore.changeCollection(collid, wfs, journalSize);
if (result === true) {
arangoHelper.arangoNotification("Collection renamed");
}
if (result !== true) {
if (result !== undefined) {
arangoHelper.arangoError("Collection error: " + result);
@ -168,14 +164,12 @@
}
});
this.hideModal();
arangoHelper.arangoNotification("Collection renamed");
}
else {
arangoHelper.arangoError("Collection error: " + result2);
}
}
else {
//arangoHelper.arangoNotification("No changes.");
this.hideModal();
}
}
@ -209,10 +203,7 @@
var self = this;
var collName = self.myCollection.name;
var returnval = window.arangoCollectionsStore.deleteCollection(collName);
if (returnval === true) {
arangoHelper.arangoNotification('Collection deleted successfully.');
}
else {
if (returnval === false) {
arangoHelper.arangoError('Could not delete collection.');
}
self.hideModal();

View File

@ -105,7 +105,6 @@
self.handleError(err.status, err.statusText, name);
},
success: function(data) {
arangoHelper.arangoNotification("Database " + name + " created.");
self.hideModal();
self.updateDatabases();
}

View File

@ -93,10 +93,7 @@
}
result = window.arangoDocumentStore.saveDocument(this.colid, this.docid, model);
if (result === true) {
arangoHelper.arangoNotification('Document saved');
}
else if (result === false) {
if (result === false) {
arangoHelper.arangoError('Document error');
}
}
@ -104,10 +101,7 @@
editor = ace.edit("sourceEditor");
model = editor.getValue();
result = window.arangoDocumentStore.saveEdge(this.colid, this.docid, model);
if (result === true) {
arangoHelper.arangoNotification('Edge saved');
}
else if (result === false) {
if (result === false) {
arangoHelper.arangoError('Edge error');
}
}

View File

@ -350,7 +350,6 @@
//Success
if (result !== false) {
window.location.hash = "collection/" + result;
arangoHelper.arangoNotification('Document created');
return;
}
//Error
@ -424,18 +423,15 @@
result = window.arangoDocumentStore.deleteDocument(this.colid, this.docid);
if (result === true) {
//on success
arangoHelper.arangoNotification('Document deleted');
deleted = true;
}
else if (result === false) {
arangoHelper.arangoError('Could not delete document');
}
}
else if (this.type === 'edge') {
result = window.arangoDocumentStore.deleteEdge(this.colid, this.docid);
if (result === true) {
//on success
arangoHelper.arangoNotification('Edge deleted');
deleted = true;
}
else if (result === false) {

View File

@ -34,7 +34,6 @@
success: function(data) {
if (self.isOffline === true) {
self.isOffline = false;
arangoHelper.removeNotifications();
if (!self.firstLogin) {
window.setTimeout(function(){
arangoHelper.arangoNotification("Server connected");

View File

@ -18,8 +18,8 @@
collection: window.arangoDatabase,
current: window.currentDB
});
// this.userBarView = new window.UserBarView({});
// this.statisticBarView = new window.StatisticBarView({});
this.userBarView = new window.UserBarView({});
this.statisticBarView = new window.StatisticBarView({});
},
handleSelectDatabase: function () {
@ -34,8 +34,8 @@
isSystem: window.currentDB.get("isSystem")
}));
this.dbSelectionView.render($("#dbSelect"));
// this.userBarView.render($("#userBar"));
// this.statisticBarView.render($("#statisticBar"));
this.userBarView.render($("#userBar"));
this.statisticBarView.render($("#statisticBar"));
return this;
},

View File

@ -85,7 +85,6 @@
if (returnobj.status === true) {
self.hidden();
$("#add-collection").modal('hide');
arangoHelper.arangoNotification("Collection created");
window.App.navigate("collection/" + collName + "/documents/1", {trigger: true});
}

View File

@ -54,9 +54,8 @@
}
},
render: function (el) {
console.log(el);
this.$el = el;
this.$el.html(this.template.render({
img : "https://s.gravatar.com/avatar/9c53a795affc3c3c03801ffae90e2e11?s=80",
@ -67,4 +66,4 @@
return this.$el;
}
});
}());
}());