<!--
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF 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.
-->

<script type="text/ng-template" id="jobRefresh.html">
    <div class="modal-header">
        <h4 tooltip="refresh">CUBE REFRESH CONFIRM</h4>
    </div>
    <div class="modal-body" style="background-color: white">
        <div ng-if="metaModel.model.partition_desc.partition_date_column" class="row">
            <div class="col-md-2"></div>
            <div class="col-md-8">
                <div ng-if="!!!(cube.segments) || cube.segments.length == 0">
                    <span class="text-info">No Segment to refresh.</span>
                </div>
                <div ng-if="cube.segments.length > 0" class="row">
                    <table class="table table-striped list" >
                        <tbody>
                        <tr>
                            <td>PARTITION DATE COLUMN</td>
                            <td>{{metaModel.model.partition_desc.partition_date_column}}</td>
                        </tr>
                        <tr>
                            <td>REFRESH SEGMENT</td>
                            <td>
                                <select ng-model="selectedSegment"
                                        ng-init="selectedSegment=cube.segments[0];segmentSelected(selectedSegment);"
                                        ng-options="segment as segment.name for segment in cube.segments"
                                        ng-change="segmentSelected(selectedSegment)">
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>SEGMENT DETAIL</td>
                            <td>
                                <table class="table table-condensed">
                                    <tr>
                                        <td>Start Date (Include)</td>
                                        <td>{{selectedSegment.date_range_start |  reverseToGMT0}}</td>
                                    </tr>
                                    <tr>
                                        <td>End Date (Exclude)</td>
                                        <td>{{selectedSegment.date_range_end |  reverseToGMT0}}</td>
                                    </tr>
                                    <tr>
                                        <td>Last build Time</td>
                                        <td>{{selectedSegment.last_build_time | utcToConfigTimeZone}}</td>
                                    </tr>
                                    <tr>
                                        <td>Last build ID</td>
                                        <td>{{selectedSegment.last_build_job_id}}</td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
                <div ng-if="message">
                    <span class="text-warning">{{message}}</span>
                </div>
            </div>
            <div class="col-md-2"></div>
        </div>

        <div ng-if="!metaModel.model.partition_desc.partition_date_column" class="row">
            <div class="col-md-2"></div>
            <div class="col-md-8">
                <span>No partition date column defined. If you want to rebuild the cube, please click "Build".</span>
            </div>
            <div class="col-md-2"></div>
        </div>
    </div>

    <div class="modal-footer">
        <button class="btn btn-primary" ng-click="cancel()">Close</button>
        <button class="btn btn-success" ng-click="rebuild()" ng-disabled="!(jobBuildRequest.startTime >= 0 && jobBuildRequest.endTime > 0 && jobBuildRequest.startTime < jobBuildRequest.endTime)">Submit
        </button>
    </div>
</script>
