<!doctype html>
<!--
  ~ Copyright 2016 Red Hat, Inc. and/or its affiliates
  ~ and other contributors as indicated by the @author tags.
  ~
  ~ 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.
  -->

<html lang="en">

<head>
    <meta charset="utf-8">
    <title>Angular Product Portal</title>

    <script src="lib/angular/angular.js"></script>
    <script src="lib/angular/angular-resource.js"></script>
    <script src="lib/angular/angular-route.js"></script>
    <script src="lib/angular/ui-bootstrap-tpls-0.4.0.js"></script>

    <script src="/auth/js/keycloak.js"></script>
    <script src="js/app.js" type="text/javascript"></script>
</head>

<body data-ng-controller="GlobalCtrl">

<div id="content-area" class="col-md-9" role="main">
    <div id="content">
        <h2><span>Products</span></h2>
        <a href="" ng-click="logout()">Sign Out</a>
        <button type="submit" data-ng-click="reloadData()">Reload</button>
        <table class="table" data-ng-show="products.length > 0">
            <thead>
            <tr>
                <th>Product Listing</th>
            </tr>
            </thead>
            <tbody>
            <tr data-ng-repeat="p in products">
                <td>{{p}}</a></td>
            </tr>
            </tbody>
        </table>
    </div>
    <hr />
    <div>
        <h2><span>Realm Roles</span></h2>
        <button type="submit" data-ng-click="loadRoles()">load Roles</button>
        <button type="submit" data-ng-click="addRole()">Add Role</button>
        <button type="submit" data-ng-click="deleteRole()">Delete Role</button>
        <table class="table" data-ng-show="roles.length > 0">
            <thead>
            <tr>
                <th>Role Listing</th>
            </tr>
            </thead>
            <tbody>
            <tr data-ng-repeat="r in roles">
                <td>{{r.name}}</a></td>
            </tr>
            </tbody>
        </table>
    </div>
    <hr />
    <div>
        <h2><span>Social providers</span></h2>
        <button type="submit" data-ng-click="loadServerInfo()">load available social providers</button>
        <table class="table" data-ng-show="serverInfo.socialProviders.length > 0">
            <thead>
            <tr>
                <th>Available social providers</th>
            </tr>
            </thead>
            <tbody>
            <tr data-ng-repeat="sp in serverInfo.socialProviders">
                <td>{{sp}}</a></td>
            </tr>
            </tbody>
        </table>
    </div>
    <hr />
    <div>
        <h2><span>Realm info</span></h2>
        <button type="submit" data-ng-click="loadPublicRealmInfo()">Load public realm info</button>

        <div data-ng-show="publicKeys">
            <b>Realm issuer</b>: {{realmOIDCInfo.issuer}} <br/>
            <table class="table" data-ng-show="publicKeys.keys.length > 0">
                <thead>
                <tr>
                    <th>Public Key KIDs</th>
                </tr>
                </thead>
                <tbody>
                <tr data-ng-repeat="pk in publicKeys.keys">
                    <td>{{pk.kid}}</td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
    <hr />
    <div>
        <h2><span>Server version</span></h2>
        <button type="submit" data-ng-click="loadVersion()">Load version</button>

        <div data-ng-show="version">
            Keycloak version: {{version.version}} <br/>
            Keycloak build time: {{version['build-time'] | date:'yyyy-MM-dd HH:mm:ss'}} <br/>
        </div>
    </div>
    <hr />
</div>
</body>
</html>
