assets.js.views.history.js Maven / Gradle / Ivy
The newest version!
/*
* #%L
* Backups
* %%
* Copyright (C) 2013 - 2014 Microsoft Corporation
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
B.View.HistoryView = Backbone.View.extend({
initialize: function(options) {
this.verifications = options.verifications;
this.listenTo(this.model, "b:indexed", this.render);
this.listenTo(this.verifications, "v:indexed", function() {
B.ViewUtil.updateVerificationStatuses(this.$(".i-backup-status"), this.verifications);
});
},
render: function() {
var that = this;
_.forEach(this.model.getByService(), function(backups, service){
var viewBackupRows = [];
backups.sortBy(function(b) { return b.get('startedDate') }).reverse().forEach(function(backup) {
var viewRowData = backup.attributes;
viewRowData['niceStartedDate'] = B.ViewUtil.niceifyDate(viewRowData['startedDate']);
viewRowData['niceCompletedDate'] = B.ViewUtil.niceifyDate(viewRowData['completedDate']);
viewRowData['niceOriginalSize'] = B.ViewUtil.niceifySize(viewRowData['originalSize']);
viewRowData['niceSize'] = B.ViewUtil.niceifySize(viewRowData['size']);
viewRowData['niceDuration'] = B.ViewUtil.niceifyDuration(viewRowData['duration']);
viewRowData['stateSymbol'] = B.ViewUtil.getGlyphForBackupState(viewRowData['state']);
viewBackupRows.push(viewRowData);
});
var m = Mustache.render(that.panelTemplate(), { service: service, backups: viewBackupRows });
that.$el.append(m);
});
},
panelTemplate: function() {
var t = "";
t += "";
t += "{{service}}
";
t += "";
t += "";
t += "";
t += " id start size duration source node ";
t += "{{#backups}}";
t += " ";
t += "{{id}} {{{niceStartedDate}}} ";
t += "{{& niceSize}} {{niceDuration}} {{sourceAddress}} {{nodeName}} ";
t += "{{/backups}}";
t += "
";
t += "";
t += "";
return t
}
});