You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
stashr_image_thumbnailer/templates/thumbnailer_settings.html

180 lines
7.3 KiB

{% extends "settings_page.html" %}
{% block header_script_files %}
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
{% endblock %}
{% block settings_pane %}
<div id="app">
<settings ref="settings" v-bind:settings="settings"></settings>
<modals ref="modal" v-bind:settings="settings"></modals>
</div>
{% endblock %}
{% block script %}
Vue.component('settings', {
props: ['settings'],
template: `
<div class="row r-10 m-2">
<div class="col col-12">
<div class="row">
<div class="col-sm-12 col-md-6 text-center text-md-start">
<h2>Thumbnailer</h2>
</div>
</div>
<hr />
<div class="row">
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="settings-tab" data-bs-toggle="tab" data-bs-target="#settings" type="button" role="tab" aria-controls="settings" aria-selected="true">Settings</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="actions-tab" data-bs-toggle="tab" data-bs-target="#actions" type="button" role="tab" aria-controls="actions" aria-selected="false">Actions</button>
</li>
</ul>
<div class="tab-content py-2" id="myTabContent">
<div class="tab-pane fade show active" id="settings" role="tabpanel" aria-labelledby="settings-tab">
<div class="row">
<table class="table table-striped">
<tbody>
<tr>
<th scope="row">{{ settings_form.max_width.label.text }}</th><td>[[ settings.THUMBNAILER.max_width ]]</td>
</tr>
<tr>
<th scope="row">{{ settings_form.quality.label.text }}</th><td>[[ settings.THUMBNAILER.quality ]]</td>
</tr>
<tr>
<th scope="row">{{ settings_form.save_original_file.label.text }}</th><td>[[ settings.THUMBNAILER.save_original_file ]]</td>
</tr>
</tbody>
</table>
</div>
<div class="row w-100">
<div class="col-12 text-end my-2">
<button type="button" class="btn btn-info" data-bs-toggle="modal" data-bs-target="#settingsModal">Modify Settings</button>
</div>
</div>
</div>
<div class="tab-pane fade" id="actions" role="tabpanel" aria-labelledby="actions-tab">
<table class="table table-striped">
<thead>
<tr>
<th scope="col">Actions</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Scan New Images</th><td><a onclick="scanImages()"><i class="fas fa-play"></i></a></td>
</tr>
<tr>
<th scope="row">Process All Images</th><td><a onclick="processImages()"><i class="fas fa-play"></i></a></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
`,
methods: {},
delimiters: ["[[","]]"]
})
Vue.component('modals',{
props: ['settings'],
template: `
<div>
<div class="modal" id="settingsModal" role="dialog" aria-labelledby="settingsModal" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="notesModalTitle">
Modify App Settings
</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form method="POST">
<div class="modal-body">
{{ settings_form.csrf_token }}
<div class="mb-3">
{{ settings_form.max_width.label }}
{{ settings_form.max_width(class_='form-control', placeholder=settings_form.max_width.label.text) }}
</div>
<div class="mb-3">
{{ settings_form.quality.label }}
{{ settings_form.quality(class_='form-control', placeholder=settings_form.quality.label.text) }}
</div>
<div class="mb-3">
{{ settings_form.save_original_file }}
{{ settings_form.save_original_file.label }}
</div>
</div>
<div class="modal-footer">
{{ settings_form.settings_button(class_='btn btn-success') }}
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
</div>
</form>
</div>
</div>
</div>
</div>
`,
methods: {},
delimiters: ["[[","]]"]
})
var app = new Vue({
el: '#app',
data: {
settings: []
},
created() {
this.getSettings()
},
methods: {
getSettings() {
axios.get('{{ url_for('thumbnailer.api_get_settings') }}')
.then(res => {
this.settings = res.data.results;
document.getElementById('max_width').value = res.data.results.THUMBNAILER.max_width;
document.getElementById('quality').value = res.data.results.THUMBNAILER.quality;
document.getElementById('quality').checked = res.data.results.THUMBNAILER.settings_button;
})
.catch(err => console.log(err))
}
},
delimiters: ["[[","]]"]
})
function scanImages() {
axios.post('{{ url_for('thumbnailer.api_post_scan_images') }}')
.then(res => {
if(res.data.status_code == 200) {
stashrToast('Scanning Images', 'success')
} else {
stashrToast('Error', 'error')
}
})
}
function processImages() {
axios.post('{{ url_for('thumbnailer.api_post_process_images') }}')
.then(res => {
if(res.data.status_code == 200) {
stashrToast('Processing Images', 'success')
} else {
stashrToast('Error', 'error')
}
})
}
{% endblock %}