<?php include(__DIR__."/../layout/top.php"); ?>
    <div class="row">
        <div class="col-md-12">
            <ul class="nav nav-tabs" id="myTab" role="tablist">
                <li class="nav-item">
                    <a class="nav-link active" id="home-tab" data-toggle="tab" href="#overview" role="tab" aria-controls="overview" aria-selected="true">Overview</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" id="profile-tab" data-toggle="tab" href="#api" role="tab" aria-controls="api" aria-selected="false">API Access</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" id="profile-tab" data-toggle="tab" href="#settings" role="tab" aria-controls="settings" aria-selected="false">Settings</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link disabled" id="contact-tab" data-toggle="tab" href="#contact" role="tab" aria-controls="contact" aria-selected="false">Users</a>
                </li>
            </ul>
            <div class="tab-content" id="myTabContent">
                <div class="tab-pane fade show active" id="overview" role="tabpanel" aria-labelledby="overview-tab">
                    <div class="row">
                        <div class="col-md-9">
                            <h3>App <?php echo $app->name; ?></h3>
                            <p><?php echo $app->description; ?></p>
                            <a href="<?php echo $app->url; ?>"><?php echo $app->url; ?></a>
                        </div>
                        <div class="col-md-3">
                            <img src="/gui/apps/<?php echo $app->id; ?>/icon" style="max-width: 100%;">
                        </div>
                    </div>

                </div>
                <div class="tab-pane fade" id="api" role="tabpanel" aria-labelledby="api-tab">
                    <h3>API Access</h3>
                    <b>API-Key</b>
                    <input class="form-control" value="<?php echo $app->apiKey; ?>">
                    <b>API-Secret</b> <a href="/gui/apps/<?php echo $app->id; ?>/regenerateAPISecret" class="btn-danger btn-sm btn" style="height: 16px; font-size: 11px;padding-top:0px;margin-top:0px;">Regenerate API Secret</a>
                    <input class="form-control" value="<?php echo $app->apiSecret; ?>">
                </div>
                <div class="tab-pane fade" id="settings" role="tabpanel" aria-labelledby="settings-tab">
                    <h3>Settings</h3>
                    <div class="row">
                        <div class="col-md-8">
                            <form method="post">
                                <table class="table">
                                    <tr>
                                        <td>Name</td>
                                        <td><input name="name" class="form-control" value="<?php echo $app->name; ?>"> </td>
                                    </tr>
                                    <tr>
                                        <td>URL</td>
                                        <td><input name="url" class="form-control" value="<?php echo $app->url; ?>"> </td>
                                    </tr>
                                    <tr>
                                        <td>Description</td>
                                        <td><textarea class="form-control" name="description" placeholder="App Beschreibung"><?php echo $app->description; ?></textarea></td>
                                    </tr>
                                    <tr>
                                        <td>Direct Login URL</td>
                                        <td><input name="direct_url" class="form-control" value="<?php echo $app->direct_url; ?>"> </td>
                                    </tr>
                                    <tr>
                                        <td>Testing <i class="fas fa-question-circle" data-placement="top"  data-toggle="popover" title="Access" data-content="To change this setting contact the Site Administrator"></i></td>
                                        <td><input type="checkbox" disabled <?php if($app->testing_warning) { echo 'checked'; } ?>> </td>
                                    </tr>
                                    <tr>
                                        <td>Untrusted <i class="fas fa-question-circle" data-placement="top"  data-toggle="popover" title="Access" data-content="To change this setting contact the Site Administrator"></i></td>
                                        <td><input type="checkbox" disabled <?php if($app->untrusted_warning) { echo 'checked'; } ?>> </td>
                                    </tr>
                                    <tr>
                                        <td>Auto Accept <i class="fas fa-question-circle" data-placement="top"  data-toggle="popover" title="Access" data-content="To change this setting contact the Site Administrator"></i></td>
                                        <td><input type="checkbox" disabled <?php if($app->auto_accept) { echo 'checked'; } ?>> </td>
                                    </tr>
                                    <tr>
                                        <td>Show on Webpage <i class="fas fa-question-circle" data-placement="top"  data-toggle="popover" title="Access" data-content="To change this setting contact the Site Administrator"></i></td>
                                        <td><input type="checkbox" disabled <?php if($app->show_on_webpage) { echo 'checked'; } ?>> </td>
                                    </tr>
                                </table>
                                <input type="submit" class="btn btn-success" value="Save">
                            </form>
                        </div>
                        <div class="col-md-4">
                            <b>Icon</b><br>
                            You can change the Icon of the App by uploading a square Pic.
                            <form action="/gui/apps/<?php echo $app->id; ?>/changeIcon" method="post" enctype="multipart/form-data">
                                <input type="file" name="icon" class="form-control" ><br>
                                <input type="submit" class="btn btn-success" value="Upload">
                            </form>
                        </div>
                    </div>
                </div>
                <div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">...</div>
            </div>
        </div>
    </div>
<script>
    $(function () {
        $('[data-toggle="popover"]').popover()
    })


</script>

<?php include(__DIR__."/../layout/bottom.php"); ?>