All Downloads are FREE. Search and download functionalities are using the official Maven repository.

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 += ""; t += "{{#backups}}"; t += ""; t += ""; t += ""; t += "{{/backups}}"; t += "
 idstartsizedurationsourcenode
{{id}}{{{niceStartedDate}}}{{& niceSize}}{{niceDuration}}{{sourceAddress}}{{nodeName}}
"; t += "
"; t += "
"; return t } });




© 2015 - 2024 Weber Informatics LLC | Privacy Policy