{{template "base/head" .}}
<div id="body" class="container">
    <form action="/install" method="post" class="form-horizontal card" id="install-card">
        {{.CsrfTokenHtml}}
        <h3>Install Steps For First-time Run</h3>

        <div class="alert alert-danger form-error{{if .HasError}}{{else}} hidden{{end}}">{{.ErrorMsg}}</div>
        <p class="help-block text-center">Gogs requires MySQL or PostgreSQL based on your choice</p>
        <div class="form-group">
            <label class="col-md-3 control-label">Database Type: </label>
            <div class="col-md-8">
                <select name="database" id="install-database" class="form-control">
                    <option value="mysql">MySQL</option>
                    <option value="pgsql">PostgreSQL</option>
                    <option value="sqlite">SQLite3</option>
                </select>
            </div>
        </div>
        <div class="server-sql">
            <div class="form-group">
                <label class="col-md-3 control-label">Host: </label>

                <div class="col-md-8">
                    <input name="host" class="form-control" placeholder="Type database server host, leave blank to keep default" value="{{.DbCfg.Host}}" required="required">
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label">User: </label>

                <div class="col-md-8">
                    <input name="user" class="form-control" placeholder="Type database username" required="required" value="{{.DbCfg.User}}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label">Password: </label>

                <div class="col-md-8">
                    <input name="passwd" type="password" class="form-control" placeholder="Type database password" required="required" value="{{.DbCfg.Pwd}}">
                </div>
            </div>

            <div class="form-group">
                <label class="col-md-3 control-label">Database Name: </label>

                <div class="col-md-8">
                    <input name="database" type="text" class="form-control" placeholder="Type mysql database name" value="{{.DbCfg.Name}}" required="required">
                    <p class="help-block">Recommend use INNODB engine with utf8_general_ci charset.</p>
                </div>
            </div>

            <div class="form-group pgsql-setting hide">
                <label class="col-md-3 control-label">SSL Mode: </label>
                <div class="col-md-8">
                    <select name="ssl_mode" class="form-control">
                        <option value="disable">Disable</option>
                        <option value="require">Require</option>
                        <option value="verify-full">Verify Full</option>
                    </select>
                </div>
            </div>
        </div>
        <div class="sqlite-setting hide">
            <div class="form-group">
                <label class="col-md-3 control-label">Path: </label>

                <div class="col-md-8">
                    <input name="path" class="form-control" placeholder="Type sqlite3 file path" value="{{.DbCfg.Path}}">
                    <p class="help-block">The file path of SQLite3 database.</p>
                </div>
            </div>
        </div>

        <hr/>

        <p class="help-block text-center">General Settings of Gogs</p>

        <div class="form-group">
            <label class="col-md-3 control-label">Repository Path: </label>

            <div class="col-md-8">
                <input name="repo-path" type="text" class="form-control" placeholder="Type your repository directory" value="{{.RepoRootPath}}" required="required">

                <p class="help-block">The git copy of each repository is saved in this directory.</p>
            </div>
        </div>

        <div class="form-group">
            <label class="col-md-3 control-label">Run User: </label>

            <div class="col-md-8">
                <input name="system-user" type="text" class="form-control" placeholder="Type system user name" value="{{.RunUser}}" required="required">
                <p class="help-block">The user has access to visit and run Gogs.</p>
            </div>
        </div>
        
        <div class="form-group">
            <label class="col-md-3 control-label">App URL: </label>

            <div class="col-md-8">
                <input name="app_url" type="text" class="form-control" placeholder="Type app root URL " value="{{.AppUrl}}" required="required">
                <p class="help-block">This affects HTTP/HTTPS clone URL and somewhere in e-mail.</p>
            </div>
        </div>

        <hr/>

        <p class="help-block text-center">Admin Account Settings</p>

        <div class="form-group">
            <label class="col-md-3 control-label">Username: </label>

            <div class="col-md-8">
                <input name="admin_name" type="text" class="form-control" placeholder="Type admin user name" value="admin" required="required">
            </div>
        </div>

        <div class="form-group">
            <label class="col-md-3 control-label">Password: </label>

            <div class="col-md-8">
                <input name="admin_pwd" type="password" class="form-control" placeholder="Type admin user password" required="required">
            </div>
        </div>

        <div class="form-group">
            <label class="col-md-3 control-label">E-mail: </label>

            <div class="col-md-8">
                <input name="admin_email" type="text" class="form-control" placeholder="Type admin user e-mail" required="required">
            </div>
        </div>

        <hr/>

        <div class="form-group text-center">
            <!-- <button class="btn btn-primary btn-lg">Test Configuration</button> -->
            <button class="btn btn-danger btn-lg">Install Gogs</button>
            <button class="btn btn-default btn-sm" type="button" data-toggle="modal" data-target="#advance-options-modal">
                Advanced Options
            </button>
        </div>

        <div class="modal fade" id="advance-options-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header"><h4 class="modal-title">Advanced Options</h4></div>
                    <div class="modal-body">
                        <p class="help-block text-center">Email Service Settings</p>

                        <div class="form-group">
                            <label class="col-md-3 control-label">SMTP Host: </label>

                            <div class="col-md-8">
                                <input name="smtp_host" type="text" class="form-control" placeholder="Type SMTP host address">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-3 control-label">Email: </label>

                            <div class="col-md-8">
                                <input name="mailer_user" type="text" class="form-control" placeholder="Type SMTP user e-mail address">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-3 control-label">Password: </label>

                            <div class="col-md-8">
                                <input name="mailer_pwd" type="password" class="form-control" placeholder="Type SMTP user password">
                            </div>
                        </div>
                        <hr/>
                        <p class="text-center help-block">Notification Settings</p>

                        <div class="form-group">
                            <div class="col-md-offset-3 col-md-7">
                                <div class="checkbox">
                                    <label>
                                        <input name="register_confirm" type="checkbox">
                                        <strong>Enable Register Confirmation</strong>
                                    </label>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-md-offset-3 col-md-7">
                                <div class="checkbox">
                                    <label>
                                        <input name="mail_notify" type="checkbox">
                                        <strong>Enable Mail Notification</strong>
                                    </label>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="modal-footer">
                        <button type="button" class="btn btn-success" data-dismiss="modal">Confirm</button>
                    </div>
                </div>
            </div>
        </div>

    </form>
</div>
{{template "base/footer" .}}