{{template "base/base.html" .}}
{{define "meta"}}
{{end}}
{{define "extrajs"}}
{{end}}
{{define "body"}}

    {{ $senss := .sensors }}
    {{ $notifs := .notifications }}
  <br/>

  <table class="table table-striped">
    <tr>
        <th>#</th>
        <th>Condition</th>
        <th>Value</th>
        <th>Sensor</th>
        <th>Enable</th>
        <th>Action</th>
    </tr>
    {{range $key, $val := $notifs}}
    <form method="POST" >
    <tr>
        <td>
            {{$val.Id}}
            <input type="hidden" name="id" value="{{$val.Id}}" />
        </td>
        <td>
            <select class="form-control" name="condition">
                <option value="<"
                {{if eq $val.Condition "<" }}
                selected
                {{end}}
                >lower</option>
                <option value="<="
                {{if eq $val.Condition "<=" }}
                selected
                {{end}}
                >lower or equals</option>
                <option value=">"
                {{if eq $val.Condition ">" }}
                selected
                {{end}}
                >greater</option>
                <option value=">="
                {{if eq $val.Condition ">=" }}
                selected
                {{end}}
                >greater or equals</option>
                <option value="!="
                {{if eq $val.Condition "!=" }}
                selected
                {{end}}
                >different</option>
                <option value="=="
                {{if eq $val.Condition "==" }}
                selected
                {{end}}
                >equals</option>
            </select>
        </td>
        <td><input type="number" class="form-control" placeholder="Value" name="value" value="{{$val.Value}}" /></td>
        <td>
            <select class="form-control" name="sensor-mac">
            {{range $kk, $sens := $senss}}
                <option value="{{$sens.MAC}}"
                {{ if eq $sens.Name $val.Sensor }}
                selected
                {{end}}
                >{{$sens.Name}}</option>
            {{end}}
            </select>
        </td>
        <td>
            <input type="checkbox" name="enable"
            {{if $val.Enable}}
                checked
            {{end}}
            />
        </td>
        <td>
            <button type="submit" name="action" value="modif" class="btn btn-info btn-xs btn-block">Udpate</button>
            <button type="submit" name="action" value="delete" class="btn btn-danger btn-xs btn-block">Delete</button>
        </td>
    </tr>
    </form>
    {{end}}
    <form method="POST" >
    <tr>
        <td></td>
        <td>
            <select class="form-control" name="condition">
                <option value="<">lower</option>
                <option value="<=">lower or equals</option>
                <option value=">">greater</option>
                <option value=">=">greater or equals</option>
                <option value="!=">different</option>
                <option value="==">equals</option>
            </select>
        </td>
        <td><input type="number" class="form-control" placeholder="Value" name="value" /></td>
        <td>
            <select class="form-control" name="sensor-mac">
            {{range $kk, $sens := $senss}}
                <option value="{{$sens.MAC}}">{{$sens.Name}}</option>
            {{end}}
            </select>
        </td>
        <td>
            <input type="checkbox" name="enable" checked />
        </td>
        <td><button type="submit" name="action" value="add" class="btn btn-success btn-xs btn-block">Add</button></td>
    </tr>
    </form>
  </table>

  <br/>

{{end}}
