aboutsummaryrefslogtreecommitdiff
path: root/templates/config.html
blob: 2d644442b8f9412d70a01dc2e5d462658eb5b07a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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}}