<div class="fullheight settings" data-ng-controller="SettingsCtrl as settings">

    <div class="fullheight col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1 col-sm-12">
        <div class="fullheight panel panel-default" role="tabpanel">


            <!-- Nav tabs -->
            <ul class="nav nav-tabs" role="tablist">
                <li role="presentation" class="active">
                    <a data-target="#tab-apps" aria-controls="tab-apps" role="tab" data-toggle="tab">{{'app.apps'|translate}}</a>
                </li>
                <li role="presentation">
                    <a data-target="#tab-user" aria-controls="tab-user" role="tab" data-toggle="tab">{{'user.user'|translate}}</a>
                </li>
                <li role="presentation" data-ng-repeat="key in settings.settingkeys" data-ng-init="settinglist = settings.settings[key]">
                    <a data-target="#tab-{{$index}}" aria-controls="tab-{{$index}}" role="tab" data-toggle="tab">{{key|translate}}</a>
                </li>
            </ul>

            <div class="panel-under-tabs scroll-y panel-body">
                <!-- Tab panes -->
                <div class="tab-content">
                    <div role="tabpanel" class="tab-pane active" id="tab-apps">
                        <h3>{{'app.apps'|translate}}</h3>

                        <div class="tile tile-autoheight">
                            <div class="tile-inner">
                                <p data-ng-bind-html="settings.apps.message|translate"></p>
                                <div class="row">
                                    <div class="col-sm-4 col-sm-offset-8">
                                        <div class="ffapp varcheck" data-ng-if="settings.apps.displaylink == 'firefoxapp'" data-ng-class="{true: 'var-is-true', false: 'var-is-false'}[ffappinstalled]">
                                            <a class="varcheck-if-false btn btn-block btn-lg btn-success" data-ng-click="settings.installffapp($event)">
                                                <i class="md md-lg md-play-download"></i> {{'app.install'|translate}}
                                            </a>
                                            <a class="varcheck-if-true btn btn-block btn-lg btn-success disabled" data-ng-click="settings.installffapp($event)">
                                                <i class="md md-lg md-play-install"></i> {{'app.installed'|translate}}
                                            </a>
                                        </div>
                                        <div class="chromeapp" data-ng-if="settings.apps.displaylink == 'chromeapp'">
                                            <a class="btn btn-block btn-lg btn-success" href="{{settings.apps.chromeapp}}" download="amanu.crx" target="_self">
                                                <i class="md md-lg md-play-download"></i> {{'app.download'|translate}}
                                            </a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </div>
                    <div role="tabpanel" class="tab-pane" id="tab-user">

                        <h3>{{'user.user'|translate}}</h3>

                        <div class="row">
                            <div class="col-sm-8">
                                <div class="listinfo-row" data-ng-repeat="user in settings.users">
                                    <div class="row">
                                        <div class="col-xs-6">
                                            <span class="username" data-in-place-edit
                                                  data-ipe-key="'username'"
                                                  data-ipe-value="user.username"
                                                  data-api-name="'userdata'"
                                                  data-api-id="user.id"
                                                  data-ipe-name="'user.username'|translate"
                                                  data-ipe-deletable="false"
                                                    ></span>
                                            <br/>
                                            <span class="secondary email" data-in-place-edit
                                                  data-ipe-key="'email'"
                                                  data-ipe-value="user.email"
                                                  data-api-name="'userdata'"
                                                  data-api-id="user.id"
                                                  data-ipe-name="'user.email'|translate"
                                                  data-ipe-type="email"
                                                  data-ipe-deletable="false"
                                                    ></span>
                                        </div>
                                        <div class="col-xs-6">
                                            <a class="listinfo-action listinfo-action-icon listinfo-action-success" href="mailto:{{user.email}}" title="{{'user.sendmail'|translate}}">
                                                <i class="md md-mail"></i>
                                            </a>
                                            <a class="listinfo-action listinfo-action-icon listinfo-action-danger" data-ng-click="settings.deleteUser($event, user.id)"  title="{{'user.delete'|translate}}">
                                                <i class="md md-delete"></i>
                                            </a>
                                            <a class="listinfo-action listinfo-action-icon listinfo-action-warning" data-ng-click="settings.changeUserPass(user)"  title="{{'user.changepass'|translate}}">
                                                <i class="md md-lock"></i>
                                            </a>
                                        </div>
                                    </div>

                                </div>
                            </div>
                            <div class="col-sm-4">
                                <div class="tile tile-autoheight">
                                    <div class="tile-inner">
                                        <h3>{{'user.new'|translate}}</h3>
                                        <form data-ng-submit="settings.addNewUser()">
                                            <div data-material-input
                                                 data-ng-model="settings.newUser.username"
                                                 data-input-id="new-username"
                                                 data-input-label="{{'user.username'|translate}}"
                                                 data-input-type="text"
                                                 data-input-required="true"></div>
                                            <div data-material-input
                                                 data-ng-model="settings.newUser.email"
                                                 data-input-id="new-email"
                                                 data-input-label="{{'user.email'|translate}}"
                                                 data-input-type="email"
                                                 data-input-required="true"></div>
                                            <div data-material-input
                                                 data-ng-model="settings.newUser.password1"
                                                 data-input-id="new-password1"
                                                 data-input-label="{{'user.password'|translate}}"
                                                 data-input-type="password"
                                                 data-input-required="true"></div>
                                            <div data-material-input
                                                 data-ng-model="settings.newUser.password2"
                                                 data-input-id="new-password2"
                                                 data-input-label="{{'user.password2'|translate}}"
                                                 data-input-type="password"
                                                 data-input-required="true"></div>
                                            <div class="row">
                                                <div class="col-xs-3">
                                                    <button type="button" class="btn btn-primary btn-block" title="{{'global.cancel'|translate}}" data-ng-click="settings.reset('newUser')">
                                                        <i class="md md-close md-lg"></i>
                                                    </button>
                                                </div>
                                                <div class="col-xs-9">
                                                    <button type="submit" class="btn btn-success btn-block" title="{{'user.new'|translate}}">
                                                        <i class="md md-group-add md-lg"></i>
                                                    </button>
                                                </div>
                                            </div>
                                        </form>

                                    </div>
                                </div>

                            </div>
                        </div>

                    </div>
                    <div data-ng-repeat="key in settings.settingkeys" data-ng-init="settinglist = settings.settings[key]"
                         role="tabpanel" class="tab-pane" id="tab-{{$index}}">

                        <div class="row" data-ng-repeat="settingkey in settings.objectKeys(settinglist)" data-ng-init="settingvalue = settinglist[settingkey]">

                            <div class="col-xs-12" data-ng-if="settingvalue == '%spacer%'">
                                <hr/>
                            </div>

                            <div data-ng-if="settings.isSettingSet(settingvalue)">
                                <div class="col-xs-12">
                                    <h3>{{'settings.sub.'+settingkey|translate}}</h3>
                                    <div class="row" data-ng-repeat="settingkey3 in settings.objectKeys(settingvalue)" data-ng-init="settingvalue3 = settingvalue[settingkey3]">
                                        <div class="col-sm-4">
                                            <p>{{'config.'+settingkey+'.'+settingkey3|translate}}</p>
                                        </div>
                                        <div class="col-sm-8">
                                            <div data-in-place-edit
                                                 data-ipe-value="settingvalue3"
                                                 data-ipe-key="settingkey+'.'+settingkey3"
                                                 data-ipe-name="'config.'+settingkey+'.'+settingkey3|translate"
                                                 data-ipe-deletable="false"
                                                 data-ipe-type="settings.settingtypes[settingkey+'.'+settingkey3]"
                                                 data-api-name="'settings'"></div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div data-ng-if="settings.isSetting(settingvalue)">
                                <div class="col-sm-4">
                                    <p>{{'config.'+settingkey|translate}}</p>
                                </div>
                                <div class="col-sm-8">
                                    <div data-in-place-edit
                                         data-ipe-value="settingvalue"
                                         data-ipe-key="settingkey"
                                         data-ipe-name="'config.'+settingkey|translate"
                                         data-ipe-deletable="false"
                                         data-ipe-type="settings.settingtypes[settingkey]"
                                         data-api-name="'settings'"></div>
                                </div>
                            </div>

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