2023-11-19 23:11:37 +10:30
|
|
|
{{ define "content" }}
|
2023-11-20 07:03:49 +10:30
|
|
|
<div id="layout" class="pure-g pure-u-1" x-data="popup_create()" >
|
|
|
|
|
2023-11-19 23:11:37 +10:30
|
|
|
<h2>Download create</h2>
|
|
|
|
<p>URL: <tt>{{ .url }}</tt></p>
|
2023-11-20 07:03:49 +10:30
|
|
|
|
|
|
|
<p class="error" x-show="error_message" x-transition.duration.500ms x-text="error_message"></p>
|
|
|
|
|
2023-11-19 23:11:37 +10:30
|
|
|
<table class="pure-table" >
|
|
|
|
<tr>
|
|
|
|
<th>profile</th>
|
|
|
|
<td>
|
2023-11-20 07:03:49 +10:30
|
|
|
<select class="pure-input-1-2" x-model="profile_chosen">
|
2023-11-19 23:11:37 +10:30
|
|
|
<option value="">choose a profile</option>
|
|
|
|
{{ range $i := .config.DownloadProfiles }}
|
|
|
|
<option>{{ $i.Name }}</option>
|
|
|
|
{{ end }}
|
|
|
|
</select>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th>destination</th>
|
|
|
|
<td>
|
2023-11-20 07:03:49 +10:30
|
|
|
<select class="pure-input-1-2" x-model="destination_chosen">
|
|
|
|
<option value="">leave in {{ .config.Server.DownloadPath }}</option>
|
2023-11-19 23:11:37 +10:30
|
|
|
{{ range $i := .config.Destinations }}
|
|
|
|
<option>{{ $i.Name }}</option>
|
|
|
|
{{ end }}
|
|
|
|
</select>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th> </th>
|
|
|
|
<td>
|
|
|
|
<button class="pure-button" @click="start()">start download</button>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
{{ end }}
|
|
|
|
{{ define "js" }}
|
|
|
|
<script>
|
|
|
|
function popup_create() {
|
|
|
|
return {
|
2023-11-20 07:03:49 +10:30
|
|
|
profile_chosen: "",
|
|
|
|
destination_chosen: "",
|
|
|
|
error_message: "",
|
2023-11-19 23:11:37 +10:30
|
|
|
start() {
|
|
|
|
let op = {
|
|
|
|
method: 'POST',
|
2023-11-20 07:03:49 +10:30
|
|
|
body: JSON.stringify({action: 'start', url: '{{ .url }}', profile: this.profile_chosen, destination: this.destination_chosen}),
|
2023-11-19 23:11:37 +10:30
|
|
|
headers: { 'Content-Type': 'application/json' }
|
|
|
|
};
|
2023-11-20 07:03:49 +10:30
|
|
|
fetch('/fetch', op)
|
2023-11-19 23:11:37 +10:30
|
|
|
.then(response => response.json())
|
2023-11-20 07:03:49 +10:30
|
|
|
.then(response => {
|
|
|
|
console.log(response)
|
|
|
|
if (response.error) {
|
|
|
|
this.error_message = response.error;
|
|
|
|
this.success_message = '';
|
|
|
|
document.body.scrollTop = document.documentElement.scrollTop = 0;
|
|
|
|
} else {
|
|
|
|
this.error_message = '';
|
|
|
|
console.log(response.location)
|
|
|
|
window.location = response.location
|
|
|
|
}
|
2023-11-19 23:11:37 +10:30
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
{{ end }}
|
|
|
|
|