<!--
  #%L
  thinkbig-ui-operations-manager
  %%
  Copyright (C) 2017 ThinkBig Analytics
  %%
  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%
  -->
    <div flex layout="row" layout-sm="column" layout-xs="column">
            <card-layout flex="100" flex-gt-sm="80" flex-order="1" flex-order-xs="2" flex-order-sm="2" >
                <header-section style="white-space:nowrap" transclude-to="head" class="card-title">Scheduled Jobs</header-section>

                <body-section>
                <md-list flex layout-fill transclude-to="body" class="list-item-table">
                    <md-list-item  ng-repeat="job in vm.jobs | orderBy:'jobName'" layout="row">

                            <div flex="25" layout="column" class="item-column md-list-item-text ">
                                     <span class="item-title">
                                       {{job.jobName}}
                                     </span>
                                      <span ng-class="{'healthy': job.state == 'RUNNING' || job.state == 'SCHEDULED', 'warn':job.state == 'PAUSED', 'error':job.state == 'UNKNOWN'}" class="column-title-bottom">
                                         <ng-md-icon icon="{{job.stateIcon}}" size="20" options='{"rotation": "clock"}' >
                                         </ng-md-icon>   {{job.state}}
                                    </span>


                            </div>
                            <div flex="10" layout="column" class="item-column md-list-item-text ">
                                   <span  class="item-title" >
                                     {{job.jobGroup}}</span>
                                     <span class="column-title column-title-bottom">
                                     Group
                                   </span>
                            </div>
                            <div flex="20" layout="column" class="item-column md-list-item-text ">
                                   <span  class="item-title" >
                                     {{job.nextFireTimeString}}
                                   </span>
                                     <span class="column-title column-title-bottom">
                                     Next Fire
                                   </span>
                            </div>
                            <div flex="15" layout="column" class="item-column md-list-item-text " hide show-gt-md>
                                   <span  class="item-title" >
                                     {{job.cronExpression}}</span>
                                     <span class="column-title column-title-bottom">
                                     Cron Expression
                                   </span>
                            </div>
                            <div flex="30" flex-md="45" flex-sm="45" flex-xs="45" layout="row" class="item-column md-list-item-text " ng-if="vm.allowAdmin">
                                <md-button class="border-btn" ng-if="job.state=='RUNNING' || job.state =='SCHEDULED'" ng-disabled="job.state =='PAUSED' || job.state == 'RUNNING' || vm.schedulerDetails.status == 'PAUSED' " ng-click="vm.pauseJob(job)">PAUSE</md-button>
                                <md-button class="border-btn" ng-if="job.state=='PAUSED'" ng-disabled="job.state =='RUNNING' || vm.schedulerDetails.status == 'PAUSED'" ng-click="vm.resumeJob(job)">RESUME</md-button>
                                <md-button class="border-btn" ng-disabled="job.state !='SCHEDULED' || vm.schedulerDetails.status == 'PAUSED'" ng-click="vm.triggerJob(job)">FIRE NOW </md-button>
                            </div>

                        <md-divider ng-if="!$last"></md-divider>
                    </md-list-item>
                </md-list>
                </body-section>
            </card-layout>

            <card-layout flex="100" flex-gt-sm="20" flex-order="2" flex-order-xs="1" flex-order-sm="1" >
                <header-section style="white-space:nowrap" transclude-to="head" class="card-title">Scheduler Details</header-section>
                <body-section transclude-to="body" flex layout="column">
                    <div layout-align="center center" style="width:100%" ng-if="vm.allowAdmin">
                    <md-button class="border-btn" style="width:150px;max-width:150px;" ng-show="vm.schedulerDetails.status == 'RUNNING'" ng-click="vm.pauseScheduler()">
                        PAUSE SCHEDULER
                    </md-button>
                    <md-button class="border-btn"  style="width:150px;max-width:150px;" ng-show="vm.schedulerDetails.status == 'PAUSED'" ng-click="vm.resumeScheduler()">
                        RESUME SCHEDULER
                    </md-button>
                    </div>


                    <md-list flex  class="list-item-table" layout="column">
                        <md-list-item >
                            <div class="item-column md-list-item-text " layout-align="space-between start" layout="column">
                                    <span ng-class="{'healthy': vm.schedulerDetails.status == 'RUNNING', 'warn':vm.schedulerDetails.status == 'PAUSED'}">
                                         <ng-md-icon icon="{{vm.schedulerDetails.statusIcon}}" size="20" options='{"rotation": "clock"}'>
                                         </ng-md-icon>   {{vm.schedulerDetails.status}}
                                    </span>
                                    <span class="column-title column-title-bottom">
                                     Status
                                    </span>
                            </div>
                        </md-list-item>
                        <md-divider></md-divider>
                        <md-list-item >
                            <div class="item-column md-list-item-text " layout-align="space-between start" layout="column">
                                    <span class="item-title">
                                        {{vm.schedulerDetails.upTime}}
                                    </span>
                                    <span class="column-title column-title-bottom">
                                     Up Time
                                    </span>
                            </div>
                        </md-list-item>
                        <md-divider></md-divider>
                        <md-list-item>
                            <div class="item-column md-list-item-text " layout-align="space-between start" layout="column">
                                    <span class="item-title">
                                        {{vm.schedulerDetails.startTime}}
                                    </span>
                                    <span class="column-title column-title-bottom">
                                     Start Time
                                    </span>
                                </div>
                        </md-list-item>
                        <md-divider></md-divider>
                        <md-list-item >
                            <div class="item-column md-list-item-text " layout-align="space-between start" layout="column">
                                    <span class="item-title">
                                        {{vm.schedulerDetails.jobsExecuted}}
                                    </span>
                                    <span class="column-title column-title-bottom">
                                     Jobs Executed
                                    </span>
                            </div>
                        </md-list-item>
                    </md-list>
                </body-section>
                </card-layout>
    </div>
