Add link to re-show the popup, and add some colour and other visual improvements

This commit is contained in:
Justin Hawkins 2021-10-26 22:48:16 +10:30
parent 3964c6fa72
commit 4b433304f6
5 changed files with 43 additions and 19 deletions

View File

@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
## [Unreleased] ## [Unreleased]
## [v0.5.2] - 2021-10-26
- Provide link to re-display the popup window from the index
- Visual improvements
## [v0.5.1] - 2021-10-25 ## [v0.5.1] - 2021-10-25
- Add note about adblockers potentially blocking the popup - Add note about adblockers potentially blocking the popup

View File

@ -15,6 +15,7 @@ import (
type Download struct { type Download struct {
Id int `json:"id"` Id int `json:"id"`
Url string `json:"url"` Url string `json:"url"`
PopupUrl string `json:"popup_url"`
Pid int `json:"pid"` Pid int `json:"pid"`
ExitCode int `json:"exit_code"` ExitCode int `json:"exit_code"`
State string `json:"state"` State string `json:"state"`

View File

@ -23,7 +23,7 @@ var downloads []*download.Download
var downloadId = 0 var downloadId = 0
var conf *config.Config var conf *config.Config
var versionInfo = version.Info{CurrentVersion: "v0.5.1"} var versionInfo = version.Info{CurrentVersion: "v0.5.2"}
//go:embed web //go:embed web
var webFS embed.FS var webFS embed.FS
@ -111,11 +111,13 @@ func homeHandler(w http.ResponseWriter, r *http.Request) {
type Info struct { type Info struct {
Downloads []*download.Download Downloads []*download.Download
BookmarkletURL template.URL BookmarkletURL template.URL
Config *config.Config
} }
info := Info{ info := Info{
Downloads: downloads, Downloads: downloads,
BookmarkletURL: template.URL(bookmarkletURL), BookmarkletURL: template.URL(bookmarkletURL),
Config: conf,
} }
err = t.ExecuteTemplate(w, "layout", info) err = t.ExecuteTemplate(w, "layout", info)
@ -292,6 +294,7 @@ func fetchHandler(w http.ResponseWriter, r *http.Request) {
Id: downloadId, Id: downloadId,
Url: url[0], Url: url[0],
PopupUrl: fmt.Sprintf("/fetch/%d", downloadId),
State: "choose profile", State: "choose profile",
Finished: false, Finished: false,
Eta: "?", Eta: "?",

View File

@ -2,7 +2,6 @@
{{ template "menu.tmpl" . }} {{ template "menu.tmpl" . }}
<div x-data="index()" x-init="fetch_data(); fetch_version()"> <div x-data="index()" x-init="fetch_data(); fetch_version()">
<p x-cloak x-show="version && version.upgrade_available"> <p x-cloak x-show="version && version.upgrade_available">
@ -25,7 +24,7 @@
<table class="pure-table"> <table class="pure-table">
<thead> <thead>
<tr> <tr>
<th>id</th><th>filename</th><th>url</th><th>state</th><th>percent</th><th>eta</th><th>finished</th> <th>id</th><th>filename</th><th>url</th><th>show</th><th>state</th><th>percent</th><th>eta</th><th>finished</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -33,11 +32,12 @@
<tr> <tr>
<td x-text="item.id"></td> <td x-text="item.id"></td>
<td x-text="item.files"></td> <td x-text="item.files"></td>
<td><a x-bind:href="item.url">link</a></td> <td><a class="int-link" x-bind:href="item.url">&#x2197;</a></td>
<td x-text="item.state"></td> <td><a class="int-link" @click="show_popup(item)" href="#">&#x1F4C4;</a></td>
<td :class="'state-'+item.state" x-text="item.state"></td>
<td x-text="item.percent"></td> <td x-text="item.percent"></td>
<td x-text="item.eta"></td> <td x-text="item.eta"></td>
<td x-text="item.finished"></td> <td x-text="item.finished ? '&#x2714;' : '-'"></td>
</tr> </tr>
</template> </template>
@ -78,6 +78,9 @@
setTimeout(() => { this.fetch_data() }, 1000); setTimeout(() => { this.fetch_data() }, 1000);
}) })
}, },
show_popup(item) {
window.open(item.popup_url, item.id, "width={{ .Config.UI.PopupWidth }},height={{ .Config.UI.PopupHeight }}");
},
} }
} }
</script> </script>

View File

@ -14,36 +14,48 @@
overflow:auto; overflow:auto;
} }
footer { footer {
padding-top: 50px; padding-top: 50px;
font-size: 30%; font-size: 30%;
}
.int-link {
text-decoration: none;
hover { color: red; }
}
.state-failed {
color: red;
}
.state-downloading {
color: blue;
}
.state-complete {
color: green;
} }
.gropple-config { .gropple-config {
font-size: 80%; font-size: 80%;
} }
.gropple-config input.input-long { .gropple-config input.input-long {
width: 27em; width: 27em;
} }
.gropple-config button { .gropple-config button {
border-radius: 12px; border-radius: 12px;
} }
.gropple-config button.button-del { .gropple-config button.button-del {
background: rgb(202, 60, 60); background: rgb(202, 60, 60);
} }
.gropple-config button.button-add { .gropple-config button.button-add {
background: rgb(60, 200, 60); background: rgb(60, 200, 60);
} }
.gropple-config .pure-form-message { .gropple-config .pure-form-message {
padding-top: .5em; padding-top: .5em;
padding-bottom: 1.5em; padding-bottom: 1.5em;
} }
.error { .error {
color: red; color: red;
} }
.success { .success {
color: green; color: green;
} }
[x-cloak] { display: none !important; } [x-cloak] { display: none !important; }
</style> </style>
@ -57,4 +69,4 @@
</body> </body>
{{ template "js" . }} {{ template "js" . }}
</html> </html>
{{ end }} {{ end }}