<!--
  ~ Copyright 2024 Apollo Authors
  ~
  ~ 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.
  ~
-->
<!doctype html>
<html ng-app="config_export">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="icon" href="img/config.png">
    <!-- styles -->
    <link rel="stylesheet" type="text/css" href="vendor/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="vendor/angular/angular-toastr-1.4.1.min.css">
    <link rel="stylesheet" type="text/css" href="vendor/select2/select2.min.css">
    <link rel="stylesheet" type="text/css" media='all' href="vendor/angular/loading-bar.min.css">
    <link rel="stylesheet" type="text/css" href="styles/common-style.css">
    <title>{{'ConfigExport.Title' | translate }}</title>
</head>

<body>
<apollonav></apollonav>
<div class="container-fluid" ng-controller="ConfigExportController">
    <div class="col-md-10 col-md-offset-1 panel">
        <ul class="nav nav-tabs">
            <li role="presentation" ng-class="{false:'disabled'}[allowSwitchingTabs]" class="active" ng-if="hasRootPermission">
                <a ng-disabled="!allowSwitchingTabs" style="border-left-style:none" href="#env_config" data-toggle="tab">{{'ConfigExport.Env.Tab' | translate}}</a>
            </li>
            <li role="presentation" ng-class="{false:'disabled'}[allowSwitchingTabs]">
                <a ng-disabled="!allowSwitchingTabs" href="#app_config"  data-toggle="tab">{{'ConfigExport.App.Tab' | translate}}</a>
            </li>
        </ul>

        <div class="tab-content">
            <div class="tab-pane fade in active" id="env_config" style="background-color:#fff" ng-if="hasRootPermission">
                <section class="panel-body">
                    <header class="panel-heading">
                        {{'ConfigExport.Title' | translate }}
                        <small>{{'ConfigExport.Env.TitleTips' | translate }}</small>
                    </header>
                    <form class="form-horizontal" style="padding-top: 15px;">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">{{'ConfigExport.SelectExportEnv' | translate }}</label>
                            <div class="col-sm-2">
                                <table class="table table-hover">
                                    <tbody>
                                    <tr style="cursor: pointer" ng-repeat="env in exportEnvs"
                                        ng-click="toggleEnvCheckedStatus(env)">
                                        <td width="10%"><input type="checkbox" ng-checked="env.checked"
                                                               ng-click="switchChecked(env, $event)"></td>
                                        <td width="30%" ng-bind="env.name"></td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"></label>
                            <div class="col-sm-9">
                                <a type="button" class="btn btn-primary" ng-click="export()">{{'ConfigExport.Export' | translate }}</a>
                                <p class="help-block">（{{'ConfigExport.ExportTips' | translate }}）</p>
                            </div>
                        </div>
                    </form>

                    <hr>

                    <form class="form-horizontal">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">{{'ConfigExport.SelectImportEnv' | translate }}</label>
                            <div class="col-sm-2">
                                <table class="table table-hover">
                                    <tbody>
                                    <tr style="cursor: pointer" ng-repeat="env in importEnvs"
                                        ng-click="toggleEnvCheckedStatus(env)">
                                        <td width="10%"><input type="checkbox" ng-checked="env.checked"
                                                               ng-click="switchChecked(env, $event)"></td>
                                        <td width="30%" ng-bind="env.name"></td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">{{'ConfigExport.ImportConflictLabel' | translate }}</label>
                            <div class="col-sm-9">
                                <div class="radio">
                                    <input type="radio" name="conflictAction" value="ignore" checked ng-model="conflictAction">
                                    {{'ConfigExport.IgnoreExistedNamespace' | translate }}
                                </div>
                                <div class="radio">
                                    <input type="radio" name="conflictAction" value="cover" ng-model="conflictAction">
                                    {{'ConfigExport.OverwriteExistedNamespace' | translate }}
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">{{'ConfigExport.UploadFile' | translate }}</label>
                            <div class="col-sm-9">
                                <input type="file" id="envFileUpload">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"></label>
                            <div class=" col-sm-9">
                                <a type="button" class="btn btn-primary" ng-click="import()">{{'ConfigExport.Import' | translate }}</a>
                                <br>
                                <p class="help-block">（{{'ConfigExport.ImportTips' | translate }}）</p>
                            </div>
                        </div>
                    </form>
                </section>
            </div>

            <div class="tab-pane fade" ng-class="{'in active': !hasRootPermission}" id="app_config" style="background-color:#fff">
                <section class="panel-body">
                    <header class="panel-heading">
                        {{'ConfigExport.Title' | translate }}
                        <small>{{'ConfigExport.App.TitleTips' | translate }}</small>
                    </header>
                    <form class="form-horizontal" style="padding-top: 15px;">
                        <div class="form-group" valdr-form-group>
                            <label class="col-sm-2 control-label">
                                <apollorequiredfield></apollorequiredfield>
                                {{'Common.AppId' | translate }}
                            </label>
                            <div class="col-sm-5">
                                <input type="text" class="form-control" ng-model="cluster.appId">
                            </div>
                        </div>
                        <div class="form-group" valdr-form-group>
                            <label class="col-sm-2 control-label">
                                <apollorequiredfield></apollorequiredfield>
                                {{'ConfigExport.EnvName' | translate }}
                            </label>
                            <div class="col-sm-5">
                                <input type="text" class="form-control" ng-model="cluster.env">
                            </div>
                        </div>
                        <div class="form-group" valdr-form-group>
                            <label class="col-sm-2 control-label">
                                <apollorequiredfield></apollorequiredfield>
                                {{'Common.ClusterName' | translate }}
                            </label>
                            <div class="col-sm-5">
                                <input type="text" class="form-control" ng-model="cluster.name">
                                <small>{{'ConfigExport.ClusterNameTips' | translate }}</small>
                            </div>
                            <div class="col-sm-1">
                                <button class="btn btn-info"
                                        ng-click="getClusterInfo()">{{'Common.Search' | translate }}</button>
                            </div>
                        </div>
                        <div class="form-group" valdr-form-group>
                            <label class="col-sm-2 control-label">
                                {{'ConfigExport.ClusterInfo' | translate }}</label>
                            <div class="col-sm-5">
                                <h5 style="color: red" ng-show="cluster.info" ng-bind="cluster.info"></h5>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label"></label>
                            <div class="col-sm-9">
                                <a type="button" class="btn btn-primary" ng-click="exportAppConfig()" ng-disabled="appConfigBtnDisabled">{{'ConfigExport.Export' | translate }}</a>
                            </div>
                        </div>
                    </form>

                    <hr>

                    <form class="form-horizontal">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">{{'ConfigExport.ImportConflictLabel' | translate }}</label>
                            <div class="col-sm-9">
                                <div class="radio">
                                    <input type="radio" name="conflictAction" value="ignore" checked ng-model="conflictAction">
                                    {{'ConfigExport.IgnoreExistedNamespace' | translate }}
                                </div>
                                <div class="radio">
                                    <input type="radio" name="conflictAction" value="cover" ng-model="conflictAction">
                                    {{'ConfigExport.OverwriteExistedNamespace' | translate }}
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">{{'ConfigExport.UploadFile' | translate }}</label>
                            <div class="col-sm-9">
                                <input type="file" id="appFileUpload">
                            </div>
                        </div>
                        <div class="form-group" valdr-form-group>
                            <label class="col-sm-2 control-label">
                                {{'ConfigExport.ClusterInfo' | translate }}</label>
                            <div class="col-sm-5">
                                <h5 style="color: red" ng-show="cluster.info" ng-bind="cluster.info"></h5>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"></label>
                            <div class=" col-sm-9">
                                <a type="button" class="btn btn-primary" ng-click="importAppConfig()" ng-disabled="appConfigBtnDisabled">{{'ConfigExport.Import' | translate }}</a>
                                <br>
                                <p class="help-block">（{{'ConfigExport.ImportTips' | translate }}）</p>
                            </div>
                        </div>
                    </form>
                </section>
            </div>
        </div>
    </div>
</div>

<div ng-include="'views/common/footer.html'"></div>

<!-- jquery.js -->
<script src="vendor/jquery.min.js" type="text/javascript"></script>

<!--angular-->
<script src="vendor/angular/angular.min.js"></script>
<script src="vendor/angular/angular-route.min.js"></script>
<script src="vendor/angular/angular-resource.min.js"></script>
<script src="vendor/angular/angular-toastr-1.4.1.tpls.min.js"></script>
<script src="vendor/angular/loading-bar.min.js"></script>
<script src="vendor/angular/angular-cookies.min.js"></script>

<script src="vendor/angular/angular-translate.2.18.1/angular-translate.min.js"></script>
<script src="vendor/angular/angular-translate.2.18.1/angular-translate-loader-static-files.min.js"></script>
<script src="vendor/angular/angular-translate.2.18.1/angular-translate-storage-cookie.min.js"></script>

<!--valdr-->
<script src="vendor/valdr/valdr.min.js" type="text/javascript"></script>
<script src="vendor/valdr/valdr-message.min.js" type="text/javascript"></script>

<!-- bootstrap.js -->
<script src="vendor/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>

<script src="vendor/lodash.min.js"></script>

<script src="vendor/select2/select2.min.js" type="text/javascript"></script>
<!--biz-->
<!--must import-->
<script type="application/javascript" src="scripts/app.js"></script>
<script type="application/javascript" src="scripts/services/AppService.js"></script>
<script type="application/javascript" src="scripts/services/EnvService.js"></script>
<script type="application/javascript" src="scripts/services/UserService.js"></script>
<script type="application/javascript" src="scripts/services/CommonService.js"></script>
<script type="application/javascript" src="scripts/services/PermissionService.js"></script>
<script type="application/javascript" src="scripts/services/ClusterService.js"></script>
<script type="application/javascript" src="scripts/services/NamespaceService.js"></script>
<script type="application/javascript" src="scripts/services/SystemInfoService.js"></script>
<script type="application/javascript" src="scripts/services/ExportService.js"></script>

<script type="application/javascript" src="scripts/PageCommon.js"></script>
<script type="application/javascript" src="scripts/directive/directive.js"></script>
<script type="application/javascript" src="scripts/valdr.js"></script>

<script type="application/javascript" src="scripts/AppUtils.js"></script>
<script type="application/javascript" src="scripts/services/OrganizationService.js"></script>

<script type="application/javascript" src="scripts/controller/ConfigExportController.js"></script>
</body>

</html>
