Code coverage report for src/card/info-status/info-status-card.component.js

Statements: 90% (9 / 10)      Branches: 100% (2 / 2)      Functions: 66.67% (2 / 3)      Lines: 90% (9 / 10)      Ignored: none     

All files » src/card/info-status/ » info-status-card.component.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144                                                                                                                                                                                                                                        1                       11 11 11 11 11 11       11 1          
/**
 * @ngdoc directive
 * @name patternfly.card.component:pfInfoStatusCard
 * @restrict E
 *
 * @param {object} status Status configuration information<br/>
 * <ul style='list-style-type: none'>
 * <li>.title         - the main title of the info status card
 * <li>.href          - the href to navigate to if one clicks on the title or count
 * <li>.iconClass     - an icon to display to the left of the count
 * <li>.iconImage     - an image to display to the left of Infrastructure
 * <li>.info          - an array of strings to display, each element in the array is on a new line, accepts HTML content
 * </ul>
 * @param {boolean=} show-top-border Show/hide the top border, true shows top border, false (default) hides top border
 * @param {boolean} htmlContent Flag to allow HTML content within the info options
 * @param {boolean=} showSpinner Show/Hide the spinner for loading state. True shows the spinner, false (default) hides the spinner
 * @param {string=} spinnerText Text for the card spinner
 * @param {string=} spinnerCardHeight Height to set for the card when data is loading and spinner is shown
 *
 * @description
 * Component for easily displaying textual information
 *
 * @example
 <example module="patternfly.card">
 
 <file name="index.html">
   <div ng-controller="CardDemoCtrl" class="container-fluid">
     <div class="row">
       <div class="col-xs-12 col-sm-6 col-md-5 col-lg-4">
         <label>With Top Border, Icon Class, Href</label>
         <pf-info-status-card status="infoStatus" show-top-border="true"></pf-info-status-card>
       </div>
       <div class="col-xs-12 col-sm-6 col-md-5 col-lg-4">
         <label>No Top Border, Icon Image, No Title</label>
         <pf-info-status-card status="infoStatusTitless"></pf-info-status-card>
       </div>
     </div>
     <div class="row">
       <div class="col-xs-12 col-sm-6 col-md-5 col-lg-4">
         <label>With HTML</label>
         <pf-info-status-card status="infoStatusAlt" html-content="true" show-spinner="dataLoading" spinner-card-height="145" spinner-text="Loading"></pf-info-status-card>
       </div>
       <div class="col-xs-12 col-sm-6 col-md-5 col-lg-4">
         <label>Loading State</label>
         <pf-info-status-card status="infoStatus2" show-top-border="true" spinner-card-height="165" show-spinner="dataLoading" spinner-text="Loading"></pf-info-status-card>
       </div>
     </div>
   </div>
 </file>
 
 <file name="script.js">
 angular.module( 'patternfly.card' ).controller( 'CardDemoCtrl', function( $scope, $window, $timeout ) {
    var imagePath = $window.IMAGE_PATH || "img";
 
    $scope.dataLoading = true;
 
    $scope.infoStatus = {
      "title":"TinyCore-local",
      "href":"#",
      "iconClass": "fa fa-shield",
      "info":[
        "VM Name: aapdemo002",
        "Host Name: localhost.localdomian",
        "IP Address: 10.9.62.100",
        "Power status: on"
      ]
    };
 
    $scope.infoStatus2 = {
        "title":"TinyCore-local",
        "iconClass": "fa fa-shield"
    };
 
    $scope.infoStatusTitless = {
      "iconImage": imagePath + "/OpenShift-logo.svg",
      "info":[
        "Infastructure: VMware",
        "Vmware: 1 CPU (1 socket x 1 core), 1024 MB",
        "12 Snapshots",
        "Drift History: 1"
        ]
    };
 
    $scope.infoStatusAlt = {};
 
    $timeout(function () {
      $scope.dataLoading = false;
 
      $scope.infoStatus2 = {
        "title":"TinyCore-local",
        "href":"#",
        "iconClass": "fa fa-shield",
        "info":[
          "VM Name: aapdemo002",
          "Host Name: localhost.localdomian",
          "IP Address: 10.9.62.100",
          "Power status: on"
        ]
      };
 
      $scope.infoStatusAlt = {
        "title":"Favorite Things",
        "iconClass":"fa fa-heart",
        "info":[
          "<i class='fa fa-coffee'>",
          "<i class='fa fa-motorcycle'>",
          "<b>Tacos</b>"
        ]
      };
    }, 6000 );
   });
 </file>
 
 </example>
 */
 
angular.module( 'patternfly.card' ).component('pfInfoStatusCard', {
  bindings: {
    status: '=',
    showTopBorder: '@?',
    showSpinner: '<?',
    spinnerText: '@?',
    spinnerCardHeight: '@?',
    htmlContent: '@?'
  },
  templateUrl: 'card/info-status/info-status-card.html',
  controller: function ($sce) {
    'use strict';
    var ctrl = this;
    ctrl.$onInit = function () {
      ctrl.shouldShowTopBorder = (ctrl.showTopBorder === 'true');
      ctrl.shouldShowHtmlContent = (ctrl.htmlContent === 'true');
      ctrl.showSpinner = ctrl.showSpinner === true;
      ctrl.trustAsHtml = function (html) {
        return $sce.trustAsHtml(html);
      };
 
      if (ctrl.spinnerCardHeight) {
        ctrl.spinnerHeight = {'height': ctrl.spinnerCardHeight};
      }
    };
  }
});