-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhtml.tmpl
More file actions
118 lines (100 loc) · 3.6 KB
/
html.tmpl
File metadata and controls
118 lines (100 loc) · 3.6 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#? stdtmpl | standard
#
#template `%`(idx: untyped): untyped =
# row[idx]
#end template
#
#
#
#proc genBackupSettings*(c: var TData, db: DbConn, msg = ""): string =
# result = ""
<link rel="stylesheet" href="/css/backup_private.css">
<script src="/js/backup_private.js" defer></script>
<div id="backup">
# if msg != "":
<div style="color: red; text-align: center;">
$msg
</div>
# end if
<div id="backupFront">
<h1>Backup settings</h1>
# let (n, v, d, u) = pluginGetDetails("backup")
<div id="pluginDetails">
<hr>
<div> <b>Package:</b> ${n}</div>
<div> <b>Version:</b> ${v}</div>
<div> <b>Description:</b><br>${d}</div>
<div> <b>URL:</b> <a href="${u}">${u}</a></div>
<hr>
</div>
</div>
<hr>
<div class="backup buttons is-centered">
<a href="#!" class="button is-info is-small backupTime">Change settings</a>
<a href="/backup/backupnow" class="button is-info is-small backupNow">Make a backup now</a>
</div>
# let backuptime = getValue(db, sql"SELECT value FROM backup_settings WHERE element = ?", "backuptime")
# let keepbackup = getValue(db, sql"SELECT value FROM backup_settings WHERE element = ?", "keepbackup")
# var backupdir = getValue(db, sql"SELECT value FROM backup_settings WHERE element = ?", "backupdir")
# if backupdir == "":
# backupdir = "data/"
# end if
<form method="get" action="/backup/backupsettings" class="backup hidden">
<div>
<label>Backup time each x hour (0 or empty = disabled)</label>
<div>
<input name="backuptime" class="backuptime input is-small" value="${backuptime}" required type="number" pattern="[0-9]" />
</div>
</div>
<hr>
<div>
<label>Keep backups for x days (0 or empty = keep forever)</label>
<div>
<input name="keepbackup" class="keepbackup input is-small" value="${keepbackup}" required type="number" pattern="[0-9]" />
</div>
</div>
<hr>
<div>
<label>Backup directory (standard = backup/)</label>
<i>If you specify a custom path, the full path is required!</i>
<div>
<input name="backupdir" class="backupdir input is-small" value="${backupdir}" required type="text" placeholder="backup/"/>
</div>
</div>
<hr>
<button type="submit" class="button is-success is-small">Save settings</button>
</form>
<ul class="backup">
# var backupFiles: seq[string]
# for backup in walkDir(backupdir):
# let (pd, ppath) = backup
# discard pd
# let backupName = replace(ppath, backupdir, "")
#
# if backupName == "website.db":
# continue
# end if
#
# backupFiles.add(backupName)
# end for
#
# backupFiles.sort()
#
# for backupName in backupFiles:
<li class="backup">
# if backupName.contains(".tar.gz"):
<a href="/backup/download?backupname=${backupName}" class="download button is-link is-small" download="${backupName}">Download files</a>
<a href="#!" class="button is-warning is-small load" data-url="/backup/loadbackup?backupname=${backupName}">Import files</a>
# else:
<a href="/backup/download?backupname=${backupName}" class="download button is-link is-small" download="${backupName}">Download DB</a>
# when not defined(postgres):
<a href="#!" class="button is-warning is-small load" data-url="/backup/loadbackup?backupname=${backupName}">Load DB</a>
# end when
# end if
<a href="#!" class="delete is-pulled-right has-text-danger is-small" data-url="/backup/delete?backupname=${backupName}">Delete</a>
<div class="name">${backupName}</div>
</li>
# end for
</ul>
</div>
#end proc