[web-src] Turn "Update library" into an action

This commit is contained in:
chme 2020-10-18 08:25:47 +02:00
parent 1aa401f024
commit bd099dc4be
2 changed files with 44 additions and 6 deletions

View File

@ -13,7 +13,7 @@
</div> </div>
<footer class="card-footer"> <footer class="card-footer">
<a class="card-footer-item has-text-dark" @click="$emit('close')"> <a class="card-footer-item has-text-dark" @click="$emit('close')">
<span class="icon"><i class="mdi mdi-cancel"></i></span> <span class="is-size-7">Cancel</span> <span class="icon"><i class="mdi mdi-cancel"></i></span> <span class="is-size-7">{{ close_action ? close_action : 'Cancel' }}</span>
</a> </a>
<a v-if="delete_action" class="card-footer-item has-background-danger has-text-white has-text-weight-bold" @click="$emit('delete')"> <a v-if="delete_action" class="card-footer-item has-background-danger has-text-white has-text-weight-bold" @click="$emit('delete')">
<span class="icon"><i class="mdi mdi-delete"></i></span> <span class="is-size-7">{{ delete_action }}</span> <span class="icon"><i class="mdi mdi-delete"></i></span> <span class="is-size-7">{{ delete_action }}</span>
@ -33,7 +33,7 @@
<script> <script>
export default { export default {
name: 'ModalDialog', name: 'ModalDialog',
props: ['show', 'title', 'ok_action', 'delete_action'] props: ['show', 'title', 'ok_action', 'delete_action', 'close_action']
} }
</script> </script>

View File

@ -36,7 +36,7 @@
<div class="navbar-end"> <div class="navbar-end">
<!-- Settings drop down --> <!-- Burger menu entries -->
<div class="navbar-item has-dropdown is-hoverable" <div class="navbar-item has-dropdown is-hoverable"
:class="{ 'is-active': show_settings_menu }" :class="{ 'is-active': show_settings_menu }"
@click="on_click_outside_settings"> @click="on_click_outside_settings">
@ -61,7 +61,10 @@
<hr class="fd-navbar-divider"> <hr class="fd-navbar-divider">
<navbar-item-link to="/settings/webinterface">Settings</navbar-item-link> <navbar-item-link to="/settings/webinterface">Settings</navbar-item-link>
<navbar-item-link to="/about">Update Library</navbar-item-link> <a class="navbar-item" @click.stop.prevent="show_update_library = true">
Update Library
</a>
<navbar-item-link to="/about">About</navbar-item-link>
<div class="navbar-item is-hidden-desktop" style="margin-bottom: 2.5rem;"></div> <div class="navbar-item is-hidden-desktop" style="margin-bottom: 2.5rem;"></div>
</div> </div>
@ -69,6 +72,29 @@
</div> </div>
</div> </div>
<modal-dialog
:show="show_update_library"
title="Update library"
:ok_action="library.updating ? '' : 'Rescan'"
close_action="Close"
@ok="update_library"
@close="show_update_library = false">
<template slot="modal-content">
<div v-if="!library.updating">
<p class="mb-3">Scan for new, deleted and modified files</p>
<div class="field">
<label class="checkbox is-size-7 is-small">
<input type="checkbox" v-model="rescan_metadata">
Rescan metadata for unmodified files
</label>
</div>
</div>
<div v-else>
<p class="mb-3">Library update in progress ...</p>
</div>
</template>
</modal-dialog>
<div class="is-overlay" v-show="show_settings_menu" <div class="is-overlay" v-show="show_settings_menu"
style="z-index:10; width: 100vw; height:100vh;" style="z-index:10; width: 100vw; height:100vh;"
@click="show_settings_menu = false"></div> @click="show_settings_menu = false"></div>
@ -77,15 +103,19 @@
<script> <script>
import NavbarItemLink from './NavbarItemLink' import NavbarItemLink from './NavbarItemLink'
import ModalDialog from '@/components/ModalDialog'
import * as types from '@/store/mutation_types' import * as types from '@/store/mutation_types'
import webapi from '@/webapi'
export default { export default {
name: 'NavbarTop', name: 'NavbarTop',
components: { NavbarItemLink }, components: { NavbarItemLink, ModalDialog },
data () { data () {
return { return {
show_settings_menu: false show_settings_menu: false,
show_update_library: false,
rescan_metadata: false
} }
}, },
@ -160,6 +190,14 @@ export default {
methods: { methods: {
on_click_outside_settings () { on_click_outside_settings () {
this.show_settings_menu = !this.show_settings_menu this.show_settings_menu = !this.show_settings_menu
},
update_library () {
if (this.rescan_metadata) {
webapi.library_rescan()
} else {
webapi.library_update()
}
} }
}, },