mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-02 10:55:30 -04:00
57 lines
1.4 KiB
JavaScript
57 lines
1.4 KiB
JavaScript
const component = () => {
|
|
return {
|
|
progress: 1.0,
|
|
generating: false,
|
|
scanning: false,
|
|
scanTitles: 0,
|
|
scanMs: -1,
|
|
themeSetting: '',
|
|
|
|
init() {
|
|
this.getProgress();
|
|
setInterval(() => {
|
|
this.getProgress();
|
|
}, 5000);
|
|
|
|
const setting = loadThemeSetting();
|
|
this.themeSetting = setting.charAt(0).toUpperCase() + setting.slice(1);
|
|
},
|
|
themeChanged(event) {
|
|
const newSetting = $(event.currentTarget).val().toLowerCase();
|
|
saveThemeSetting(newSetting);
|
|
setTheme();
|
|
},
|
|
scan() {
|
|
if (this.scanning) return;
|
|
this.scanning = true;
|
|
this.scanMs = -1;
|
|
this.scanTitles = 0;
|
|
$.post(`${base_url}api/admin/scan`)
|
|
.then((data) => {
|
|
this.scanMs = data.milliseconds;
|
|
this.scanTitles = data.titles;
|
|
})
|
|
.catch((e) => {
|
|
alert('danger', `Failed to trigger a scan. Error: ${e}`);
|
|
})
|
|
.always(() => {
|
|
this.scanning = false;
|
|
});
|
|
},
|
|
generateThumbnails() {
|
|
if (this.generating) return;
|
|
this.generating = true;
|
|
this.progress = 0.0;
|
|
$.post(`${base_url}api/admin/generate_thumbnails`).then(() => {
|
|
this.getProgress();
|
|
});
|
|
},
|
|
getProgress() {
|
|
$.get(`${base_url}api/admin/thumbnail_progress`).then((data) => {
|
|
this.progress = data.progress;
|
|
this.generating = data.progress > 0;
|
|
});
|
|
},
|
|
};
|
|
};
|