2013-09-02 02:55:45 +00:00
|
|
|
|
'use strict';
|
|
|
|
|
define(
|
|
|
|
|
[
|
|
|
|
|
'backbone',
|
|
|
|
|
'ProgressMessaging/ProgressMessageModel',
|
|
|
|
|
'Shared/Messenger',
|
|
|
|
|
'Mixins/backbone.signalr.mixin'
|
|
|
|
|
], function (Backbone, ProgressMessageModel, Messenger) {
|
|
|
|
|
|
|
|
|
|
var ProgressMessageCollection = Backbone.Collection.extend({
|
|
|
|
|
url : window.ApiRoot + '/progressmessage',
|
|
|
|
|
model: ProgressMessageModel
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var collection = new ProgressMessageCollection().bindSignalR();
|
|
|
|
|
|
|
|
|
|
collection.signalRconnection.received(function (message) {
|
|
|
|
|
|
|
|
|
|
var type = getMessengerType(message.status);
|
2013-09-04 05:01:28 +00:00
|
|
|
|
var hideAfter = type === 'info' ? 60 : 5;
|
2013-09-02 02:55:45 +00:00
|
|
|
|
|
|
|
|
|
Messenger.show({
|
2013-09-04 05:01:28 +00:00
|
|
|
|
id : message.commandId,
|
|
|
|
|
message : message.message,
|
|
|
|
|
type : type,
|
|
|
|
|
hideAfter: hideAfter
|
2013-09-02 02:55:45 +00:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var getMessengerType = function (status) {
|
|
|
|
|
switch (status) {
|
|
|
|
|
case 'completed':
|
|
|
|
|
return 'success';
|
|
|
|
|
case 'failed':
|
|
|
|
|
return 'error';
|
|
|
|
|
default:
|
|
|
|
|
return 'info';
|
|
|
|
|
}
|
2013-09-02 03:46:43 +00:00
|
|
|
|
};
|
2013-09-02 02:55:45 +00:00
|
|
|
|
|
|
|
|
|
return collection;
|
|
|
|
|
});
|