{{!
  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/analytics.css"}}
{{/zone}}

{{unit "cdmf.unit.ui.title" pageTitle="Analytics"}}
{{unit "cdmf.unit.ui.content.title" pageHeader=title}}
{{unit "cdmf.unit.lib.service-invoker-utility"}}
{{unit "cdmf.unit.lib.handlebars"}}
{{unit "cdmf.unit.lib.rickshaw-graph"}}

{{#zone "breadcrumbs"}}
    <li>
        <a href="{{@app.context}}/">
            <i class="icon fw fw-home"></i>
        </a>
    </li>
    <li>
        <a href="{{@app.context}}/groups">
            Groups
        </a>
    </li>
    <li>
        <a href="{{@app.context}}/devices?groupId={{groupId}}&groupName={{groupName}}">
            {{groupName}}
        </a>
    </li>
    <li>
        <a href="#">
            Analytics
        </a>
    </li>
{{/zone}}

{{#zone "content"}}
    <div class="container container-bg  white-bg">
        <div class=" margin-top-double">
            {{#if deviceTypes}}
                <div class="row padding-top-double padding-bottom-double margin-bottom-double">
                    {{unit "cdmf.unit.analytics.date-range-picker" deviceTypes=deviceTypes}}
                </div>
                <hr>
                <div class="clear"></div>
                <div id="div-chart">
                    {{#each deviceTypes}}
                        {{unit deviceAnalyticsViewUnitName devices=devices}}
                    {{/each}}
                </div>
            {{else}}
                <div id="ast-container" class="ast-container list-view">
                    <div class="ctrl-info-panel col-centered text-center wr-login">
                        <h2>You don't have any device assigned to this group to view analytics. Let's add a new device group!</h2>
                        <br/>
                        <p class="text-center">
                            <a href="{{@app.context}}/devices" class="wr-btn">
                                <span class="fw-stack">
                                    <i class="fw fw-circle-outline fw-stack-2x"></i>
                                    <i class="fw fw-add fw-stack-1x"></i>
                                </span>
                                Assign from My Devices
                            </a>
                        </p>
                    </div>
                </div>
            {{/if}}
        </div>
    </div>
{{/zone}}
