<div class="container-fluid content-main">

    <!--Users Table -->
    <div class="row">
        <div class="col pt-4">
            <div class="card">
                <div class="card-body">

                    <h2>Users</h2>

                    <!--User Buttons -->
                    <div class="card">
                        <div class="card-body">
                            <div class="row">
                                <!--Add User-->
                                <div class="col pt-4">

                                    <ng-form name="$ctrl.newUserForm" ng-submit="$ctrl.submitUser()">
                                        <div class="input-group">
                                            <input type="text" placeholder="Username" ng-model="$ctrl.newUser.name"
                                                class="form-control" required name="username" />
                                            <div
                                                ng-show="$ctrl.newUserForm.$submitted && $ctrl.newUserForm.username.$invalid">
                                                <span class="alert-danger">This field is required</span>
                                            </div>
                                            <input type="text" placeholder="password" ng-model="$ctrl.newUser.hash"
                                                class="form-control" required name="password" />
                                            <div
                                                ng-show="$ctrl.newUserForm.$submitted && $ctrl.newUserForm.password.$invalid">
                                                <span class="alert-danger">This field is required</span>
                                            </div>
                                        </div>
                                        <div class="card">
                                            <button class="btn" ng-click="$ctrl.submitUser()">Create User</button>
                                        </div>
                                    </ng-form>

                                </div>

                                <!--Import Users File-->
                                <div class="col pt-4">


                                    <div class="card">
                                        <input type="file" size="10" file-reader="fileContent" accept=".csv" />
                                    </div>
                                    <div class="card">
                                        <button class="btn" type='button' value="Upload"
                                            ng-click="$ctrl.importUsers()">Import
                                            Users File</button>
                                    </div>
                                    <br>

                                </div>

                                <!--Download User Stories-->
                                <div class="col pt-4">


                                    <div class="card">
                                        <script src="https://cdn.jsdelivr.net/npm/alasql@0.4"></script>
                                        <script type="text/javascript"
                                            src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.7.12/xlsx.core.min.js"></script>
                                        <button class="btn" ng-click="$ctrl.downloadUserStories()">Download User
                                            Stories</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <br>

                    <!--User Information -->
                    <table class="table">
                        <tr>
                            <th scope="col">Active</th>
                            <th scope="col">Machine</th>
                            <th scope="col">User ID</th>
                            <th scope="col">Username</th>
                            <th scope="col">Password</th>
                            <th scope="col">Activities Completed</th>
                            <th scope="col">View Story</th>
                            <th scope="col"></th>
                        </tr>
                        <tr ng-repeat="u in $ctrl.users">
                            <td ng-if="u.active==1">&#10004;</td>
                            <td ng-if="!u.active==1"></td>
                            <td>{{u.host}}</td>
                            <td>{{u.id}}</td>
                            <td>{{u.name}}</td>
                            <td>{{u.hash}}</td>
                            <td>{{u.activity_status}}
                                <div
                                    style="height: 30px; width: 100px; background-color: #f4f4f4; margin: -25px 0 0 50px; border-radius: 4px; border: 1px solid #999999">
                                    <div
                                        style="height: 100%; width: {{u.widthContainer}}; background-color: #1a4a7a; border-radius: 4px">
                                    </div>
                                </div>
                            </td>
                            <td>
                                <button style="margin: 1px 0 0 0; border: none; border-radius: 4px;"
                                    ng-click="$ctrl.viewUserStory(u.id)">View</button>
                            </td>
                            <td>
                            </td>
                            <td ng-if="u.active==1">
                                <button ng-click="$ctrl.kickUser(u.id)">Kick</button>
                            </td>
                            <td ng-if="!u.active==1"></td>
                        </tr>
                    </table>

                </div>
            </div>
        </div>
    </div>
    <br>

    <!--Activities List-->
    <div class="row">

        <div class="col pt-4">

            <div class="card">
                <div class="card-body">

                    <h2>Activities</h2>

                    <table class="table">
                        <tr>
                            <th scope="col">Stopped</th>
                            <th scope="col">Disabled</th>
                            <th scope="col">Status</th>
                            <th scope="col">ID</th>
                            <th scope="col">Type</th>
                            <th scope="col">Name</th>
                        </tr>
                        <tr ng-repeat="a in $ctrl.activities track by a.id">
                            <td scope="row">
                                <input type="checkbox" ng-model="$ctrl.stoppedActivities[a.id]">
                                <!--{{$ctrl.stoppedActivities[a.id]}}-->
                            </td>
                            <td scope="row">
                                <input type="checkbox" ng-model="$ctrl.disabledActivities[a.id]">
                                <!--{{$ctrl.disabledActivities[a.id]}}-->
                            </td>
                            <td scope="row">{{a.status}}</td>
                            <td scope="row">{{a.id}}</td>
                            <td scope="row">{{a.type}}</td>
                            <td scope="row">{{a.name}}</td>
                        </tr>
                    </table>
                    <div class="card">
                        <button class="btn" ng-click="$ctrl.updateActivities()">Update Activities</button>
                    </div>
                    <div class="card">
                        <button class="btn" ng-click="$ctrl.resetActivities()">Reset Activities</button>
                    </div>
                </div>
            </div>
            <br></br>

        </div>

    </div>

</div>




</div>