{{!
  Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.

  WSO2 Inc. licenses this file to you 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.
}}
{{#zone "topCss"}}
  {{css "css/main.css"}}
{{/zone}}
{{unit "cdmf.unit.lib.editable"}}
{{#zone "content"}}
    {{#if deviceFound}}
        {{#if isAuthorized}}
            <div class="row">
              <div class="col-lg-4">
                  <div class="device-info-container">
                      <div class="row">
                          <div class="col-lg-3">
                            {{#defineZone "device-thumbnail"}}
                              <i class="fw fw-mobile device-type fw-2x"></i>
                            {{/defineZone}}
                          </div>
                          <div class="col-lg-9">
                              <div class="device-info">
                                {{#defineZone "device-details-header"}}
                                  <h1 class="device-id" data-deviceid="{{device.deviceIdentifier}}"
                                  data-type="{{device.type}}"
                                  data-ownership="{{device.ownership}}"
                                  data-owner="{{device.owner}}">
                                        {{#if device.model}}
                                          <h4>{{device.vendor}} {{device.model}}</h4>
                                        {{/if}}
                                        <h4>Ownership - <strong>{{device.ownership}}</strong></h4>
                                        <h4>Device is
                                          <strong>
                                            {{#equal device.status "ACTIVE"}}Active{{/equal}}
                                            {{#equal device.status "INACTIVE"}}Inactive{{/equal}}
                                            {{#equal device.status "BLOCKED"}}Blocked{{/equal}}
                                            {{#equal device.status "REMOVED"}}Removed{{/equal}}
                                            {{#equal device.status "UNREACHABLE"}}Unreachable{{/equal}}
                                          </strong>
                                        </h4>
                                {{/defineZone}}
                            </div>
                          </div>
                      </div>
                  </div>
                  {{#defineZone "device-details"}}
                  {{/defineZone}}
                  {{#defineZone "device-opetations"}}
                    <div class="operation-container">
                      <div class="operation-title">
                          <h4>Device Operations</h4>
                      </div>
                      {{unit "cdmf.unit.device.operation-bar" device=device}}
                  </div>
                  {{/defineZone}}
                  <div class="clearfix"></div>
              </div>
              <!-- /col-lg-4 -->
              <div class="col-lg-8">
                  <ul class="nav nav-tabs">
                    {{#defineZone "device-view-tabs"}}
                      <li class="active"><a data-toggle="tab" href="#event_log">Operations Log</a></li>
                      {{#defineZone "device-details-tab-injected"}}
                      {{/defineZone}}
                    {{/defineZone}}
                  </ul>
                  <div class="tab-content">
                    {{#defineZone "device-view-tab-contents"}}
                        <div id="event_log" class="tab-pane fade in active">
                          <div class="tab-actions">
                            <div class="action-btn-container">
                                <div class="action-btn show filter">
                                    <a href="javascript:void(0);" id="refresh-operations">
                                        <i class="fw fw-refresh"></i> Refresh Log
                                    </a>
                                </div>
                            </div>
                          </div>
                          <div id="operations-spinner" class="wr-advance-operations-init hidden">
                              <i class="fw fw-wso2-logo fw-pulse fw-2x"></i> Loading Operations Log...
                          </div>
                          <div class="clearfix"></div>
                            <div class="operation-log-container">
                                <table class="table table-striped table-hover table-responsive list-table display responsive nowrap data-table"
                                id="operation-log">
                                    <thead class="block">
                                        <tr class="sort-row">
                                            <!-- <th class="content-fill no-sort"></th> -->
                                            <th>Name</th>
                                            <th>Position</th>
                                            <th>Office</th>
                                            <!-- <th>Age</th>
                                            <th>Start date</th>
                                            <th>Salary</th>
                                            <th class="no-sort"></th> -->
                                        </tr>
                                    </thead>
                                    <tbody>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                      {{#defineZone "device-view-tab-injected-conents"}}
                      {{/defineZone}}
                    {{/defineZone}}
                  </div>
              </div>
              <!-- /col-lg-08 -->
            </div>
            <!-- /row -->
        {{else}}
            <h1 class="page-sub-title">
                Permission Denied
            </h1>
            <br>
            You are not authorized to view specified device in the system.
        {{/if}}
    {{else}}
        <h1 class="page-sub-title">
            Device not found
        </h1>
        </h1>
        <br>
        You have tried to access either a removed or non-existing device.
    {{/if}}
{{/zone}}
{{#zone "bottomJs"}}
    {{js "js/device-view.js"}}
    <script id="policy-view" src="{{@unit.publicUri}}/templates/policy-compliance.hbs"
            data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}"
            type="text/x-handlebars-template"></script>
    <script id="policy-list" src="{{@unit.publicUri}}/templates/policy-list.hbs"
            data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}"
            type="text/x-handlebars-template"></script>
    <script id="applications-list" src="{{@unit.publicUri}}/templates/applications-list.hbs"
            data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}"
            type="text/x-handlebars-template"></script>
{{/zone}}
