<!--
  ~ Copyright 2021 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="index">

<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" media='all' href="vendor/font-awesome.min.css">

    <link rel="stylesheet" type="text/css" href="styles/common-style.css">
    <title>{{'Common.Title' | translate }}</title>
</head>

<body>

    <apollonav></apollonav>

    <div id="app-list" class="hidden" ng-controller="IndexController">

        <section class="media create-app-list">
            <aside class="media-left text-center">
                <h5>{{'Index.MyProject' | translate }}</h5>
            </aside>
            <aside class="media-body">
                <div class="app-panel col-md-2 text-center" ng-click="goToCreateAppPage()"
                    ng-if="hasCreateApplicationPermission">
                    <div href="#" class="thumbnail create-btn hover cursor-pointer">
                        <img src="img/plus-white.png" />
                        <h5>{{'Index.CreateProject' | translate }}</h5>
                    </div>
                </div>
                <div class="app-panel col-md-2 text-center" ng-repeat="app in createdApps"
                    ng-click="goToAppHomePage(app.appId)">
                    <div href="#" class="thumbnail hover cursor-pointer">
                        <h4 ng-bind="app.appId"></h4>
                        <h5 ng-bind="app.name"></h5>
                    </div>
                </div>
                <div class="app-panel col-md-2 text-center" ng-show="hasMoreCreatedApps"
                    ng-click="getUserCreatedApps()">
                    <div href="#" class="thumbnail hover cursor-pointer">
                        <img class="more-img" src="img/more.png" />
                        <h5>{{'Index.LoadMore' | translate }}</h5>
                    </div>
                </div>
            </aside>
        </section>

        <section class="media favorites-app-list">
            <aside class="media-left text-center">
                <h5>{{'Index.FavoriteItems' | translate }}</h5>
            </aside>
            <aside class="media-body">
                <div class="app-panel col-md-2 text-center" ng-repeat="app in favorites"
                    ng-click="goToAppHomePage(app.appId)" ng-mouseover="toggleOperationBtn(app)"
                    ng-mouseout="toggleOperationBtn(app)">
                    <div class="thumbnail hover">
                        <h4 ng-bind="app.appId"></h4>
                        <h5 ng-bind="app.name"></h5>

                        <p class="operate-panel" ng-show="app.showOperationBtn">
                            <button class="btn btn-default btn-xs" title="{{'Index.Topping' | translate }}"
                                ng-click="toTop(app.favoriteId);$event.stopPropagation();">
                                <img src="img/top.png" class="i-15">
                            </button>
                            <button class="btn btn-default btn-xs" title="{{'Index.FavoriteCancel' | translate }}"
                                ng-click="deleteFavorite(app.favoriteId);$event.stopPropagation();">
                                <img src="img/like.png" class="i-15">
                            </button>
                        </p>
                    </div>
                </div>
                <div class="col-md-2 text-center" ng-show="hasMoreFavorites" ng-click="getUserFavorites()">
                    <div href="#" class="thumbnail hover cursor-pointer">
                        <img class="more-img" src="img/more.png" />
                        <h5>{{'Index.LoadMore' | translate }}</h5>
                    </div>
                </div>
                <div class="no-favorites text-center" ng-show="!favorites || favorites.length == 0">
                    <h4>{{'Index.FavoriteTip' | translate }}</h4>
                </div>

            </aside>
        </section>

        <section class="media visit-app-list" ng-show="visitedApps && visitedApps.length">
            <aside class="media-left text-center">
                <h5>{{'Index.RecentlyViewedItems' | translate }}</h5>
            </aside>
            <aside class="media-body">
                <div class="app-panel col-md-2 text-center" ng-repeat="app in visitedApps"
                    ng-click="goToAppHomePage(app.appId)">
                    <div class="thumbnail hover">
                        <h4 ng-bind="app.appId"></h4>
                        <h5 ng-bind="app.name"></h5>
                    </div>
                </div>
            </aside>
        </section>
    </div>


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

    <!--angular-->
    <script src="vendor/angular/angular.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>

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

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

    <script type="application/javascript">
        function getPrefixPath() {
            $.ajax({
                method: 'get',
                async: false,
                url: 'prefix-path',
                success: function (res) {
                    window.localStorage.setItem("prefixPath", res);
                }
            })
        }
        getPrefixPath();
    </script>

    <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/FavoriteService.js"></script>
    <script type="application/javascript" src="scripts/services/PermissionService.js"></script>
    <script type="application/javascript" src="scripts/AppUtils.js"></script>
    <script type="application/javascript" src="scripts/directive/directive.js"></script>

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

</body>

</html>