2021-09-28 22:09:12 +09:30
{{ define "content" }}
2021-09-30 17:46:01 +09:30
{{ template "menu.tmpl" . }}
2021-09-28 22:09:12 +09:30
< div x-data = "config()" x-init = "fetch_config();" >
2021-09-30 17:12:03 +09:30
< p class = "error" x-show = "error_message" x-transition . duration . 500ms x-text = "error_message" > < / p >
< p class = "success" x-show = "success_message" x-transition . duration . 500ms x-text = "success_message" > < / p >
2021-09-28 22:09:12 +09:30
2021-09-30 17:46:16 +09:30
< p > Note: changes are not saved until the "Save Config" button is pressed at the bottom of the page.< / p >
2021-09-28 22:09:12 +09:30
< div class = "pure-g" >
2021-09-30 17:04:12 +09:30
2021-09-30 13:00:31 +09:30
< div class = "pure-u-md-1-2 pure-u-1" >
2021-09-28 22:09:12 +09:30
2021-09-30 13:00:31 +09:30
< form class = "pure-form pure-form-stacked gropple-config" >
2021-09-28 22:09:12 +09:30
< fieldset >
< legend > Server< / legend >
< label for = "config-server-port" > Listen Port< / label >
2021-09-29 23:15:44 +09:30
< input type = "text" id = "config-server-port" placeholder = "port number" x-model . number = "config.server.port" / >
2021-09-28 22:09:12 +09:30
< span class = "pure-form-message" > The port the web server will listen on.< / span >
< label for = "config-server-address" > Server address (URL)< / label >
2021-09-30 13:00:31 +09:30
< input type = "text" id = "config-server-address" class = "input-long" placeholder = "server address" x-model = "config.server.address" / >
2021-09-28 22:09:12 +09:30
< span class = "pure-form-message" >
The address the service will be available on. Generally it will be http://hostname:port where
hostname is the host the server is running on, and port is the port you set above.
< / span >
< label for = "config-server-downloadpath" > Download path< / label >
2021-09-30 13:00:31 +09:30
< input type = "text" id = "config-server-downloadpath" placeholder = "path" class = "input-long" x-model = "config.server.download_path" / >
2021-09-28 22:09:12 +09:30
< span class = "pure-form-message" > The path on the server to download files to.< / span >
2022-01-05 23:56:12 +10:30
< label for = "config-server-max-downloads" > Maximum active downloads per domain< / label >
2021-11-21 13:25:55 +10:30
< input type = "text" id = "config-server-max-downloads" placeholder = "2" class = "input-long" x-model . number = "config.server.maximum_active_downloads_per_domain" / >
2022-01-05 23:56:12 +10:30
< span class = "pure-form-message" > How many downloads can be simultaneously active. Use '0' for no limit. This limit is applied per domain that you download from.< / span >
2021-11-21 13:25:55 +10:30
2021-09-28 22:09:12 +09:30
< legend > UI< / legend >
2021-09-30 17:46:16 +09:30
< p > Note that changes to the popup dimensions will require you to recreate your bookmarklet.< / p >
2021-09-28 22:09:12 +09:30
< label for = "config-ui-popupwidth" > Popup Width< / label >
2021-09-29 23:15:44 +09:30
< input type = "text" id = "config-ui-popupwidth" placeholder = "width in pixels" x-model . number = "config.ui.popup_width" / >
2021-09-28 22:09:12 +09:30
< span class = "pure-form-message" > The width of popup windows in pixels.< / span >
< label for = "config-ui-popupheight" > Popup Height< / label >
2021-09-29 23:15:44 +09:30
< input type = "text" id = "config-ui-popupheight" placeholder = "height in pixels" x-model . number = "config.ui.popup_height" / >
2021-09-28 22:09:12 +09:30
< span class = "pure-form-message" > The height of popup windows in pixels.< / span >
< / fieldset >
< / form >
< / div >
2021-09-30 13:00:31 +09:30
< div class = "pure-u-md-1-2 pure-u-1" >
< form class = "pure-form gropple-config" >
2021-09-28 22:09:12 +09:30
< fieldset >
< legend > Download Profiles< / legend >
2021-09-30 13:00:31 +09:30
< p > Gropple supports multiple download profiles. Each profile specifies a different youtube-dl
compatible command, and arguments. When starting a download, you may choose which profile
to use. The URL will be appended to the argument list at the end.
< / p >
2021-09-30 17:46:16 +09:30
< hr >
2021-09-29 23:15:44 +09:30
< template x-for = "(profile, i) in config.profiles" >
< div >
2021-09-30 17:04:12 +09:30
< label x-bind:for = "'config-profiles-'+i+'-name'" > Name of profile < span x-text = "i+1" > < / span >
< / label >
2021-09-30 13:00:31 +09:30
< input type = "text" x-bind:id = "'config-profiles-'+i+'-name'" class = "input-long" placeholder = "name" x-model = "profile.name" / >
2021-09-30 17:04:12 +09:30
< button class = "pure-button button-del" href = "#" @ click . prevent = "config.profiles.splice(i, 1);;" > delete profile< / button >
2021-09-29 23:15:44 +09:30
< span class = "pure-form-message" > The name of this profile. For your information only.< / span >
< label x-bind:for = "'config-profiles-'+i+'-command'" > Command to run< / label >
2021-09-30 13:00:31 +09:30
< input type = "text" x-bind:id = "'config-profiles-'+i+'-command'" class = "input-long" placeholder = "name" x-model = "profile.command" / >
< span class = "pure-form-message" > Which command to run. Your path will be searched, or you can specify the full path here.< / span >
2021-09-29 23:15:44 +09:30
2021-09-30 13:00:31 +09:30
< label > Arguments< / label >
2021-09-29 23:15:44 +09:30
< template x-for = "(arg, j) in profile.args" >
< div >
< input type = "text" x-bind:id = "'config-profiles-'+i+'-arg-'+j" placeholder = "arg" x-model = "profile.args[j]" / >
2021-09-30 17:04:12 +09:30
< button class = "pure-button button-del" href = "#" @ click . prevent = "profile.args.splice(j, 1);;" > delete arg< / button >
2021-09-29 23:15:44 +09:30
< / div >
< / template >
2021-09-30 13:00:31 +09:30
< button class = "pure-button button-add" href = "#" @ click . prevent = "profile.args.push('');" > add arg< / button >
2021-09-29 23:15:44 +09:30
< hr >
< / div >
< / template >
2021-09-28 22:09:12 +09:30
2021-09-30 17:04:12 +09:30
< button class = "pure-button button-add" href = "#" @ click . prevent = "config.profiles.push({name: 'new profile', command: 'youtube-dl', args: []});" > add profile< / button >
2021-09-28 22:09:12 +09:30
< / fieldset >
< / form >
< / div >
< / div >
2021-09-29 23:15:44 +09:30
< div class = "pure-g" >
< div class = "pure-u-1" >
2021-09-30 13:00:31 +09:30
< button class = "pure-button pure-button-primary" @ click = "save_config();" href = "#" > Save Config< / button >
2021-09-29 23:15:44 +09:30
< / div >
< / div >
2021-09-28 22:09:12 +09:30
< / div >
{{ end }}
{{ define "js" }}
< script >
function config() {
return {
2021-09-29 23:15:44 +09:30
config: { server : {}, ui : {}, profiles: [] },
error_message: '',
2021-09-30 17:04:12 +09:30
success_message: '',
2021-09-29 23:15:44 +09:30
2021-09-28 22:09:12 +09:30
fetch_config() {
fetch('/rest/config')
.then(response => response.json())
.then(config => {
this.config = config;
})
.catch(error => {
2021-09-29 23:15:44 +09:30
console.log('failed to fetch config', error);
2021-09-28 22:09:12 +09:30
});
},
2021-09-29 23:15:44 +09:30
save_config() {
let op = {
method: 'POST',
2021-09-30 23:48:56 +09:30
body: JSON.stringify(this.config),
headers: { 'Content-Type': 'application/json' }
};
2021-09-29 23:15:44 +09:30
fetch('/rest/config', op)
.then(response => {
2021-09-30 17:04:12 +09:30
return response.json();
})
.then(response => {
if (response.error) {
this.error_message = response.error;
this.success_message = '';
document.body.scrollTop = document.documentElement.scrollTop = 0;
} else {
this.error_message = '';
this.success_message = 'configuration saved';
document.body.scrollTop = document.documentElement.scrollTop = 0;
this.config = response;
}
2021-09-29 23:15:44 +09:30
})
.catch(error => {
2021-09-30 17:04:12 +09:30
console.log('exception' ,error);
2021-09-29 23:15:44 +09:30
});
}
2021-09-28 22:09:12 +09:30
}
}
< / script >
{{ end }}