<!--

    Copyright (C) 2015-2016 Jeeva Kandasamy (jkandasa@gmail.com)

    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.

-->
<div class="container-fluid">

  <!-- Loading icon disaplay -->
  <div ng-hide="resourceCount.$resolved">
    <div ng-include src="'partials/common-html/loading.html'"></div>
  </div>

  <div ng-show="resourceCount.$resolved"> <!-- Main Message -->

    <!-- Page Header -->
    <div ng-include src="'partials/common-html/header-list.html'"></div>

    <div class=" container-fluid row"><!-- row1 -->
      <div class="row-cards-pf ">

        <div class="col-xs-6 col-sm-6 col-lg-6">
          <div class="card-pf card-pf-utilization card-pf-accented">
            <div class="card-pf-heading">
              <h2 class="card-pf-title">{{ 'DETAILS' | translate }} <a class="btn btn-link pull-right" ui-sref="gatewaysAddEdit({ id: item.id })"><i class="fa fa-edit"></i> {{ 'EDIT' | translate }} </a></h2>
            </div>
            <div class="card-pf-body">
              <dl class="dl-horizontal">
                <dt>{{ 'NAME' | translate }}</dt> <dd>{{item.name}}</dd>
                <dt>{{ 'ENABLED' | translate }}</dt> <dd>{{item.enabled? 'ENABLED' : 'DISABLED' | translate }}</dd>
                <dt>{{ 'TRANSMIT_DELAY' | translate }}</dt><dd>{{item.txDelay}} {{ 'MILLISECONDS_SHORT' | translate }}</dd>
                <dt>{{ 'ACK_ENABLED' | translate }}</dt> <dd>{{item.ackEnabled? 'ENABLED' : 'DISABLED' | translate }}</dd>
                <span ng-if="item.ackEnabled">
                <dt>{{ 'STREAM_ACK_ENABLED' | translate }}</dt> <dd>{{item.streamAckEnabled? 'ENABLED' : 'DISABLED' | translate }}</dd>
                <dt>{{ 'FAILED_RETRY_COUNT' | translate }}</dt><dd>{{item.failedRetryCount}}</dd>
                <dt>{{ 'ACK_WAIT_TIME' | translate }}</dt><dd>{{item.ackWaitTime}} {{ 'MILLISECONDS_SHORT' | translate }}</dd>
                </span>
                <dt>{{ 'TYPE' | translate }}</dt> <dd>{{item.type}}</dd>
                <dt>{{ 'NETWORK_TYPE' | translate }}</dt> <dd>{{item.networkType}}</dd>
                <dt>{{ 'CONNECTION_DETAILS' | translate }}</dt> <dd>{{item.connectionDetails}}</dd>
                <dt>{{ 'STATUS' | translate }}</dt>
                <dd>
                  <span class="card-pf-aggregate-status-notification">
                    <span ng-show="item.state.toLowerCase() === 'up'">
                      {{ 'UP' | translate }} <i class="fa fa-arrow-circle-o-up text-color-green fa-lg"></i>
                    </span>
                    <span ng-show="item.state.toLowerCase() === 'down'">
                      {{ 'DOWN' | translate }} <i class="fa fa-arrow-circle-o-down text-color-red fa-lg"></i>
                    </span>
                     <span ng-show="item.state.toLowerCase() === 'unavailable'">
                      {{ 'UNAVAILABLE' | translate }} <i class="fa fa-question-circle text-color-gray fa-lg"></i>
                    </span>
                  </span>
                </dd>
                <dt>{{ 'STATUS_SINCE' | translate }}</dt> <dd><span uib-tooltip="{{item.statusSince | date:mchelper.cfg.dateFormat:mchelper.cfg.timezone}}" tooltip-placement="right" am-time-ago="item.statusSince"></span></dd>
                <dt>{{ 'STATUS_MESSAGE' | translate }}</dt> <dd>{{item.statusMessage}}</dd>
                <dt>{{ 'TOPOLOGY' | translate }}</dt> <dd><a class="mc-inline-editer-ab" ui-sref="dashboardTopology({ resourceType: 'Gateway', resourceId: item.id})"><span class="pficon pficon-topology mc-icon-lg"></span></a></dd>

                <legend><small>{{ 'RESOURCES' | translate }}</small></legend>
                <dt><span class="fa fa-sitemap mc-icon-md-3"></span>{{ 'NODES' | translate }}</dt>
                <dd>
                  <a class="mc-inline-editer-ab" ng-if="resourceCount.nodes > 0" ui-sref="nodesList({ gatewayId: item.id})">{{resourceCount.nodes}}</a>
                  <span ng-if="resourceCount.nodes == 0">{{resourceCount.nodes}}</span>
                </dd>
                <dt><span class="fa fa-eye mc-icon-md-3"></span>{{ 'SENSORS' | translate }}</dt>
                <dd>
                  <span>{{resourceCount.sensors}}</span>
                </dd>
                <dt><span class="pficon pficon-replicator mc-icon-md-3"></span>{{ 'RESOURCES_GROUPS' | translate }}</dt>
                <dd>
                  <a class="mc-inline-editer-ab" ng-if="resourceCount.resourcesGroups > 0" ui-sref="resourcesGroupList({ resourceType:resourceCount.resourceType, resourceId: resourceCount.resourceId})">{{resourceCount.resourcesGroups}}</a>
                  <span ng-if="resourceCount.resourcesGroups == 0">{{resourceCount.resourcesGroups}}</span>
                </dd>
              </dl>
            </div>
          </div>
        </div>

        <div class="col-xs-6 col-sm-6 col-lg-6">
          <div class="card-pf card-pf-utilization card-pf-accented">
            <div class="card-pf-heading">
              <h2 class="card-pf-title">{{ 'STATISTICS' | translate }}</h2>
            </div>
            <div class="card-pf-body">
              <dl class="dl-horizontal">
                <dt>{{ 'AVERAGE_TIME' | translate }}</dt> <dd>{{statistics.timeAverage | number: 2}}  {{ 'MILLISECONDS_SHORT' | translate }}</dd>
                <dt>{{ 'LAST_MINUTE_AVERAGE' | translate }}</dt> <dd>{{statistics.timeAverageLastMinute | number: 2}}  {{ 'MILLISECONDS_SHORT' | translate }}</dd>
                <dt>{{ 'LAST_MESSAGE' | translate }}</dt> <dd>{{statistics.timeLastMessage}}  {{ 'MILLISECONDS_SHORT' | translate }} <span ng-if="statistics.timestamp != 0">| </span><span uib-tooltip="{{item.statusSince | date:mchelper.cfg.dateFormat:mchelper.cfg.timezone}}" tooltip-placement="right" am-time-ago="statistics.timestamp"></span></dd>
                <dt>{{ 'LAST_MINUTE_RATE' | translate }}</dt> <dd>{{statistics.countLastMinute}}</dd>
                <dt>{{ 'COUNT' | translate }} ({{ 'TOTAL' | translate }} | Tx)</dt><dd>{{statistics.count}} | {{statistics.txCount}}</dd>
                <dt>{{ 'FAILURE_COUNT' | translate }}</dt><dd>{{statistics.countFailure}} | {{statistics.percentageFailure | number: 2}}%</dd>
                <dt>{{ 'MESSAGES_IN_QUEUE' | translate }}</dt> <dd>{{statistics.sizeQueue}}</dd>
              </dl>
            </div>
          </div>
        </div>

      </div>
    </div><!-- /row1 -->

  </div> <!-- Main Message -->

</div> <!-- Container-fluid -->
