This repository has been archived on 2019-06-27. You can view files and clone it, but cannot push or open issues/pull-requests.
am/tmpl_gen.go

596 lines
12 KiB
Go

package am
var tmpls = `
{{define "PageStart" -}}
<!doctype html>
<html lang="en">
<head>
<title>am</title>
<style>{{template "CSS"}}</style>
</head>
<body>
<ul class="top-menu">
<li><a href="/log/list">Log</a></li>
<li><a href="/source/list">Sources</a></li>
<li><a href="/user/list">Users</a></li>
<li style="float:right"><a>{{now}}</a></li>
</ul>
{{end}}
{{define "PageEnd" -}}
</body>
</html>
{{- end}}
{{define "Error" -}}
{{template "PageStart"}}
<h1>Error</h1>
<section>
<p>{{.}}</p>
</section>
{{template "PageEnd"}}
{{- end}}
-------------------------------------------------------------------------------
-- List
-------------------------------------------------------------------------------
{{define "LogList" -}}
{{template "PageStart"}}
<h1>Log</h1>
<section>
<form>
<select Name="Type">
<option value="all" {{if (eq .Args.Type "all")}}selected{{end}}>Type: All</option>
<option value="alert" {{if (eq .Args.Type "alert")}}selected{{end}}>Type: Alerts</option>
<option value="log" {{if (eq .Args.Type "log")}}selected{{end}}>Type: Non-alerts</option>
</select>
<select Name="SourceID">
<option value="">Source: All</option>
{{range .Sources}}
<option value="{{.SourceID}}" {{if (eq .SourceID $.Args.SourceID)}}selected{{end}}>
Source: {{.Name}}
</option>
{{end}}
</select>
<input type="submit" value="Submit">
</form>
{{if .Args.BeforeID}}
<p><a href="javascript:history.back()">Back</a></p>
{{end}}
<table>
<tr>
<th>Time</th>
<th> </th>
<th>Source</th>
<th>Text</th>
</tr>
{{range .Entries}}
<tr>
<td>{{.TS.Format "2006-01-02 15:04"}}
</td>
<td>{{if .Alert}}<b>!</b>{{end}}</td>
<td><a href="/source/view/{{.SourceID}}">{{.SourceName}}</a></td>
<td style="width:100%;">{{.Text}}</td>
</tr>
{{end}}
</table>
{{if .NextURL}}
<p><a href="{{.NextURL}}">More</a></p>{{end}}
</section>
{{template "PageEnd"}}
{{- end}}
-------------------------------------------------------------------------------
-- Insert
-------------------------------------------------------------------------------
{{define "SourceInsert" -}}
{{template "PageStart"}}
<h1 class="breadcrumbs">
<a href="/source/list">Sources</a> / Insert
</h1>
<section>
<form method="POST">
<input type="hidden" name="CSRF" value="{{.CSRF}}">
<ul class="form-list">
<li>
<label for="Name">Name:</label>
<input type="text" id="Name" name="Name" required>
</li>
<li>
<label for="Description">Description</label>
<textarea id="Description" name="Description" rows=8></textarea>
</li>
<li>
<label for="AlertTimeout">Alert Timeout:</label>
<input type="number" id="AlertTimeout" name="AlertTimeout">
</li>
<li>
<input type="submit" value="Insert">
</li>
</form>
</section>
{{template "PageEnd"}}
{{- end}}
-------------------------------------------------------------------------------
-- List
-------------------------------------------------------------------------------
{{define "SourceList" -}}
{{template "PageStart"}}
<h1 class="breadcrumbs">Sources</h1>
<ul class="section-menu">
<li><a href="/source/insert">Insert</a></li>
</ul>
<section>
<ul class="user-list">
{{range . -}}
<li>
<a href="/source/view/{{.SourceID}}">
{{.Name}} {{if .TimedOut}}&#x2716;{{end}}
</a>
</li>
{{- end}}
</ul>
</section>
{{template "PageEnd"}}
{{- end}}
-------------------------------------------------------------------------------
-- View
-------------------------------------------------------------------------------
{{define "SourceView" -}}
{{template "PageStart"}}
<h1 class="breadcrumbs">
<a href="/source/list">Sources</a> / {{.Name}}
</h1>
<ul class="section-menu">
<li><a href="/source/update/{{.SourceID}}">Update</a></li>
<li><a href="/source/delete/{{.SourceID}}">Delete</a></li>
</ul>
<section>
<dl>
<dt>API Key</dt>
<dd>{{.APIKey}}</dd>
<dt>Description</dt>
<dd class="multiline">{{.Description}}</dd>
<dt>Last Seen</dt>
<dd>{{.LastSeenAt.Format "2006-01-02 15:04"}}</dd>
<dt>Alert Timeout (sec)</dt>
<dd>{{.AlertTimeout}}</dd>
</dl>
</section>
{{template "PageEnd"}}
{{- end}}
-------------------------------------------------------------------------------
-- Update
-------------------------------------------------------------------------------
{{define "SourceUpdate" -}}
{{template "PageStart"}}
<h1 class="breadcrumbs">
<a href="/source/list">Sources</a> /
<a href="/source/view/{{.Source.SourceID}}">{{.Source.Name}}</a> /
Update
</h1>
<section>
<form method="POST">
<input type="hidden" name="CSRF" value="{{.CSRF}}">
<input type="hidden" name="SourceID" value="{{.Source.SourceID}}">
<ul class="form-list">
<li>
<label for="Description">Description</label>
<textarea id="Description" name="Description" rows=8>
{{- .Source.Description -}}
</textarea>
</li>
<li>
<label for="AlertTimeout">Alert Timeout (Sec):</label>
<input type="number" id="AlertTimeout" name="AlertTimeout" value="{{.Source.AlertTimeout}}">
</li>
<li>
<input type="submit" value="Update">
</li>
</form>
</section>
{{template "PageEnd"}}
{{- end}}
-------------------------------------------------------------------------------
-- Delete
-------------------------------------------------------------------------------
{{define "SourceDelete" -}}
{{template "PageStart"}}
<h1 class="breadcrumbs">
<a href="/source/list">Sources</a> /
<a href="/source/view/{{.Source.SourceID}}">{{.Source.Name}}</a> /
Delete
</h1>
<section>
<p>Really delete source {{.Source.Name}}?</p>
<form method="POST">
<input type="hidden" name="CSRF" value="{{.CSRF}}">
<ul class="form-list">
<li>
<input type="submit" value="Delete">
</li>
</ul>
</form>
</section>
{{template "PageEnd"}}
{{- end}}
{{define "CSS"}}
/*********
* Links *
*********/
a {
text-decoration: none;
color: #444;
}
/************
* Top Menu *
************/
.top-menu {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
border-bottom: 1px solid #999999;
}
.top-menu li {
float: left;
}
.top-menu li a {
display: block;
text-align: center;
padding: 14px 16px;
}
/****************
* Section Menu *
****************/
.section-menu {
list-style-type: none;
padding: 0;
overflow: hidden;
}
.section-menu li {
float: left;
border: 1px solid #999999;
margin-right: 8px;
}
.section-menu li a {
display: block;
text-align: center;
padding: 8px 12px;
}
/***********
* Section *
***********/
section {
padding-left: 40px;
}
/********************
* Definition Lists *
********************/
dt {
font-weight: bold;
margin: 8px 0;
max-width: 400px;
}
dd {
margin: 0 0 0 32px;
padding: 8px 0 8px 16px;
min-height: 20px;
max-width: 480px;
border-left: 1px solid #999999;
}
.multiline {
white-space: pre-wrap;
}
/*********
* Table *
*********/
table {
border-collapse: collapse;
width: 100%;
}
th, td {
padding: 8px;
text-align: left;
white-space: nowrap;
}
tr:nth-child(even){
background-color: #f8f8f8;
}
/*********
* Forms *
*********/
.form-list {
max-width: 400px;
padding: 0;
}
.form-list li {
display: block;
list-style: none;
margin: 10px 0 0 0;
}
.form-list label{
margin:0 0 4px 0;
padding:0px;
display:block;
}
.form-list input,.form-list textarea,.form-liat select{
padding: 8px;
margin: 0px;
width: 100%;
box-sizing: border-box;
}
.form-list input[type=checkbox] {
padding: 8px;
margin: 0px;
width: auto;
}
.form-list input + label {
display: inline;
}
.form-list input[type=submit] {
padding: 8px;
margin: 0px;
width: auto;
background: none;
border: 1px solid #999999;
color: #444;
padding: 8px 12px;
}
/*************
* User List *
*************/
.user-list {
list-style: none;
padding: 0;
}
.user-list li {
}
.user-list li a {
margin: 6px 0;
display: block;
}
{{end}}
-------------------------------------------------------------------------------
-- Insert
-------------------------------------------------------------------------------
{{define "UserInsert" -}}
{{template "PageStart"}}
<h1 class="breadcrumbs">
<a href="/user/list">Users</a> / Insert
</h1>
<section>
<form method="POST" autocomplete="off">
<input type="hidden" name="CSRF" value="{{.CSRF}}">
<ul class="form-list">
<li>
<label for="Username">Username:</label>
<input type="text" name="Username" autocomplete="off" required>
</li>
<li>
<label for="Password">Password:</label>
<input type="password" name="Password" autocomplete="off" required>
</li>
<li>
<input type="checkbox" name="Admin" id="Admin">
<label for="Admin">Admin</label>
</li>
<li>
<input type="submit" value="Insert">
</li>
</ul>
</form>
</section>
{{template "PageEnd"}}
{{- end}}
-------------------------------------------------------------------------------
-- List
-------------------------------------------------------------------------------
{{define "UserList" -}}
{{template "PageStart"}}
<h1 class="breadcrumbs">Users</h1>
<ul class="section-menu">
<li><a href="/user/insert">Insert</a></li>
</ul>
<section>
<ul class="user-list">
{{range . -}}
<li>
<a href="/user/view/{{.Username}}">
{{.Username}}{{if .Admin}} &#x272a;{{end}}
</a>
</li>
{{- end}}
</ul>
</section>
{{template "PageEnd"}}
{{- end}}
-------------------------------------------------------------------------------
-- View
-------------------------------------------------------------------------------
{{define "UserView" -}}
{{template "PageStart"}}
<h1 class="breadcrumbs">
<a href="/user/list">Users</a> / {{.Username}}
</h1>
<ul class="section-menu">
<li><a href="/user/update/{{.Username}}">Update</a></li>
<li><a href="/user/delete/{{.Username}}">Delete</a></li>
</ul>
<section>
<dl>
<dt>Admin</dt>
<dd>{{if .Admin}}True{{else}}False{{end}}</dd>
</dl>
</section>
{{template "PageEnd"}}
{{- end}}
-------------------------------------------------------------------------------
-- Update
-------------------------------------------------------------------------------
{{define "UserUpdate" -}}
{{template "PageStart"}}
<h1 class="breadcrumbs">
<a href="/user/list">Users</a> /
<a href="/user/view/{{.User.Username}}">{{.User.Username}}</a> /
Update
</h1>
<section>
<form method="POST">
<input type="hidden" name="CSRF" value="{{.CSRF}}">
<ul class="form-list">
<li>
<label for="NewPassword">Password:</label>
<input type="password" name="NewPassword" autocomplete="off">
</li>
<li>
<input type="checkbox" name="Admin" id="Admin" {{if .User.Admin}}Checked{{end}}>
<label for="Admin">Admin</label>
</li>
<li>
<input type="submit" value="Update">
</li>
</ul>
</form>
</section>
{{template "PageEnd"}}
{{- end}}
-------------------------------------------------------------------------------
-- Delete
-------------------------------------------------------------------------------
{{define "UserDelete" -}}
{{template "PageStart"}}
<h1 class="breadcrumbs">
<a href="/user/list">Users</a> /
<a href="/user/view/{{.User.Username}}">{{.User.Username}}</a> /
Delete
</h1>
<section>
<p>Really delete user {{.User.Username}}?</p>
<form method="POST">
<input type="hidden" name="CSRF" value="{{.CSRF}}">
<ul class="form-list">
<li>
<input type="submit" value="Delete">
</li>
</ul>
</form>
</section>
{{template "PageEnd"}}
{{- end}}
`