diff options
author | Alex Auvolat <alex@adnab.me> | 2020-02-26 22:49:27 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-02-26 22:49:27 +0100 |
commit | 8a5ed3f507d37c52e2a68a23ced6942cc752221d (patch) | |
tree | 14e85d2f6031d6b38ad34bb7b360df3918c1c9e4 /templates | |
parent | 775fc7b2172a632587e82cd44b9d7400ca4f4f74 (diff) | |
download | easybridge-8a5ed3f507d37c52e2a68a23ced6942cc752221d.tar.gz easybridge-8a5ed3f507d37c52e2a68a23ced6942cc752221d.zip |
Initial ability to configure accounts from web interface
Diffstat (limited to 'templates')
-rw-r--r-- | templates/config.html | 71 | ||||
-rw-r--r-- | templates/home.html | 43 |
2 files changed, 98 insertions, 16 deletions
diff --git a/templates/config.html b/templates/config.html new file mode 100644 index 0000000..2d64444 --- /dev/null +++ b/templates/config.html @@ -0,0 +1,71 @@ +{{define "title"}}Account configuration |{{end}} + +{{define "body"}} +<div class="d-flex"> + <h4>Configure account</h4> + <a class="ml-auto btn btn-info" href="/">Go back</a> +</div> + +{{if .ErrorMessage}} + <div class="alert alert-danger mt-4">An error occurred. + <div style="font-size: 0.8em">{{ .ErrorMessage }}</div> + </div> +{{end}} + +<form method="POST" class="mt-4"> + <div class="form-group"> + <label for="name">Account name:</label> + <input type="text" {{if .NameEditable}}{{else}}disabled="disabled"{{end}} id="name" name="name" class="form-control" value="{{ .Name }}" /> + {{if .InvalidName}} + <div class="alert alert-warning">Invalid name (must not be empty)</div> + {{end}} + </div> + <div class="form-group"> + <label>Protocol:</label> + <input type="text" disabled="disabled" class="form-control" value="{{ .Protocol }}" /> + </div> + {{$config := .Config}} + {{$errors := .Errors}} + {{range $i, $schema := .Schema}} + <div class="form-group"> + <label for="{{$schema.Name}}">{{$schema.Description}}</label> + {{if $schema.FixedValue}} + <input type="text" + disabled="disabled" + class="form-control" + name="{{$schema.Name}}" + id="{{$schema.Name}}" + value="{{index $config $schema.Name}}" /> + {{else if $schema.IsBoolean}} + {{$value := index $config $schema.Name}} + <label for="{{$schema.Name}}-true"> + <input type="radio" name="{{$schema.Name}}" id="{{$schema.Name}}-true" value="true" {{if eq $value "true"}}checked="checked"{{end}} /> + Yes + </label> + <label for="{{$schema.Name}}-false"> + <input type="radio" name="{{$schema.Name}}" id="{{$schema.Name}}-false" value="false" {{if eq $value "false"}}checked="checked"{{end}} /> + No + </label> + {{else if $schema.IsPassword}} + <input type="password" + class="form-control" + name="{{$schema.Name}}" + id="{{$schema.Name}}" + value="{{index $config $schema.Name}}" /> + {{else}} + <input type="text" + class="form-control" + name="{{$schema.Name}}" + id="{{$schema.Name}}" + value="{{index $config $schema.Name}}" /> + {{end}} + {{$error := index $errors $schema.Name}} + {{if $error}} + <div class="alert alert-warning mt-2">{{$error}}</div> + {{end}} + </div> + {{end}} + <button type="submit" class="btn btn-primary">Save configuration</button> +</form> + +{{end}} diff --git a/templates/home.html b/templates/home.html index 40a0e5c..da3e478 100644 --- a/templates/home.html +++ b/templates/home.html @@ -8,23 +8,34 @@ <a class="ml-auto btn btn-sm btn-dark" href="/logout">Log out</a> </div> -<table class="table mt-4"> - <thead> - <tr> - <th>Account name</th> - <th>Protocol</th> - <th></th> - </tr> - </thead> - <tbody> - {{range $name, $acc := .Accounts}} +{{ if .Accounts }} + <table class="table mt-4"> + <thead> <tr> - <td>{{ $name }}</td> - <td>{{ $acc.Protocol }}</td> - <td>Modifier etc</td> + <th>Account name</th> + <th>Protocol</th> + <th></th> </tr> - {{end}} - </tbody> -</table> + </thead> + <tbody> + {{range $i, $acc := .Accounts}} + <tr> + <td>{{ $acc.AccountName }}</td> + <td>{{ $acc.Protocol }}</td> + <td> + <a class="btn btn-sm btn-primary" href="/edit/{{ $acc.AccountName }}">Modify</a> + <a class="btn btn-sm btn-danger ml-4" href="/delete/{{ $acc.AccountName }}">Delete</a> + </td> + </tr> + {{end}} + </tbody> + </table> +{{end}} + +<h5 class="mt-4">Add account</h5> + +<a class="btn btn-sm btn-dark" href="/add/irc">IRC</a> +<a class="btn btn-sm btn-warning ml-4" href="/add/xmpp">XMPP</a> +<a class="btn btn-sm btn-info ml-4" href="/add/mattermost">Mattermost</a> {{end}} |