<div ng-controller="SqlResolverController">

    <h2 class="form-signin-heading"
        ng-show="resolvername"
            translate>Edit SQL Resolver {{ resolvername }}</h2>

    <h2 class="form-signin-heading"
        ng-hide="resolvername"
            translate>Create a new SQL Resolver</h2>

    <form name="formResolverAddSql" role="form" validate
          class="form-horizontal">


        <div class="form-group">
            <label for="resolvername" class="col-sm-3 control-label"
                    translate>Resolver name</label>

            <div class="col-sm-9">
                <input name="resolvername" id="resolvername"
                       class="form-control"
                       ng-model="resolvername" required placeholder="resolver1"
                       autofocus/>
            </div>
        </div>
        <div class="form-group">
            <label for="driver" class="col-sm-3 control-label"
                    translate>Driver</label>

            <div class="col-sm-9">
                <input name="driver" class="form-control"
                       ng-model="params.Driver" required
                       placeholder="mysql"/>
            </div>
        </div>

        <div class="form-group">
            <label for="server" class="col-sm-3 control-label"
                    translate>Server</label>

            <div class="col-sm-3">
                <input name="server" class="form-control"
                       ng-model="params.Server" required
                       placeholder="127.0.0.1"/>
            </div>
            <label for="port" class="col-sm-3 control-label"
                    translate>Port</label>

            <div class="col-sm-3">
                <input name="port" class="form-control"
                       ng-model="params.Port"
                       placeholder="3306"/>
            </div>
        </div>

        <div class="form-group">
            <label for="database"
                   class="col-sm-3 control-label"
                    translate>Database</label>

            <div class="col-sm-9">
                <input name="database" class="form-control"
                       ng-model="params.Database"
                       placeholder="YourDataBase"/>
            </div>
        </div>
        <div class="form-group">
            <label for="user" class="col-sm-3 control-label">User</label>

            <div class="col-sm-9">
                <input name="user" class="form-control"
                       ng-model="params.User"
                       placeholder="user"/>
            </div>
        </div>
        <div class="form-group">
            <label for="password" class="col-sm-3 control-label" translate>
                Password</label>

            <div class="col-sm-9">
                <input name="password" class="form-control"
                       type="password"
                       ng-model="params.Password"
                       placeholder="topsecret"/>
            </div>
        </div>
        <div class="form-group">
            <label for="editable"
                class="col-sm-3 control-label" translate>
                Edit user store
            </label>
            <div class="col-sm-9">
            <input name="editable" id="editable"
                   ng-model="params.Editable"
                   type="checkbox"/>
                <p class="help-block" translate>
                    The user data in this database can be modified from within
                    privacyIDEA.
                </p>
            </div>
        </div>
        <div class="well">
            <div class="form-group">
                <button class="btn btn-info" ng-click="presetWordpress()"
                        translate>Wordpress
                </button>
                <button class="btn btn-info" ng-click="presetOTRS()"
                        translate>OTRS
                </button>
                <button class="btn btn-info" ng-click="presetTine()"
                        translate>Tine 2.0
                </button>
                <button class="btn btn-info" ng-click="presetOwncloud()"
                        translate>Owncloud
                </button>
                <button class="btn btn-info" ng-click="presetTypo3()"
                        translate>Typo3
                </button>
            </div>
            <div class="form-group">
                <label for="table" class="col-sm-3 control-label"
                        translate>Table</label>

                <div class="col-sm-3">
                    <input name="table" class="form-control"
                           ng-model="params.Table" required
                           placeholder="Users"/>
                </div>

                <label for="limit" class="col-sm-3 control-label"
                        translate>Limit</label>

                <div class="col-sm-3">
                    <input name="limit" class="form-control"
                           ng-model="params.Limit" required
                           placeholder="500"/>
                </div>
            </div>

            <div class="form-group">
                <label for="mapping"
                       class="col-sm-3 control-label"
                        translate>Mapping</label>

                <div class="col-sm-9">
                    <input name="mapping" class="form-control"
                           ng-model="params.Map" required
                           placeholder='{ "userid" : "id", "username": "user", "phone" : "telephoneNumber", "mobile" : "mobile", "email" : "mail", "surname" : "sn", "givenname" : "givenName" ,"password" : "password"}'
                            />
                </div>
            </div>

            <div class="form-group">
                <label for="where"
                       class="col-sm-3 control-label"
                        translate>Where statement</label>

                <div class="col-sm-9">
                    <input name="where" class="form-control"
                           ng-model="params.Where"/>
                </div>
            </div>
            <div class="form-group">
                <label for="encoding"
                       class="col-sm-3 control-label"
                        translate>Database Encoding</label>

                <div class="col-sm-9">
                    <input name="encoding" class="form-control"
                           ng-model="params.Encoding" />
                </div>
            </div>
            <div class="form-group">
                <label for="conparams"
                       class="col-sm-3 control-label"
                        translate>Connection Parameters</label>

                <div class="col-sm-9">
                    <input name="conparams" class="form-control"
                           ng-model="params.conParams"/>
                </div>
            </div>
        </div>
        <div class="text-center" ng-show="showResult">
            <label class="label"
                   ng-class="{'label-success':result.result,
               'label-danger':!result.result}">
                {{ result.description }}<span class="glyphicon glyphicon-remove"
                                              ng-click="showResult=false"></span>
            </label>
        </div>

        <div class="text-center">
            <button ng-click="testSQL()"
                    ng-disabled="formResolverAddSql.$invalid"
                    class="btn btn-success" translate>Test SQL Resolver
            </button>
            <button ng-click="setSQLResolver()"
                    ng-disabled="formResolverAddSql.$invalid"
                    class="btn btn-primary" translate>Save Resolver
            </button>
        </div>

    </form>
</div>
