Skip to content

Commit 10bddeb

Browse files
committed
chore: fetch settings from API
Signed-off-by: Vitor Mattos <vitor@php.rio>
1 parent 19904d0 commit 10bddeb

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/views/Settings/CollectMetadata.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
</template>
1414
<script>
1515
import axios from '@nextcloud/axios'
16+
import { emit } from '@nextcloud/event-bus'
1617
import { translate as t } from '@nextcloud/l10n'
1718
import { generateOcsUrl } from '@nextcloud/router'
1819
@@ -42,7 +43,11 @@ export default {
4243
this.collectMetadataEnabled = ['true', true, '1', 1].includes(value)
4344
},
4445
saveCollectMetadata() {
45-
OCP.AppConfig.setValue('libresign', 'collect_metadata', this.collectMetadataEnabled ? 1 : 0)
46+
OCP.AppConfig.setValue('libresign', 'collect_metadata', this.collectMetadataEnabled ? 1 : 0, {
47+
success: () => {
48+
emit('collect-metadata:changed')
49+
}
50+
})
4651
},
4752
},
4853
}

src/views/Settings/SignatureStamp.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ import Upload from 'vue-material-design-icons/Upload.vue'
306306
307307
import { getCurrentUser } from '@nextcloud/auth'
308308
import axios from '@nextcloud/axios'
309+
import { subscribe, unsubscribe } from '@nextcloud/event-bus'
309310
import { loadState } from '@nextcloud/initial-state'
310311
import { translate as t, isRTL } from '@nextcloud/l10n'
311312
import { generateOcsUrl } from '@nextcloud/router'
@@ -461,13 +462,24 @@ export default {
461462
},
462463
mounted() {
463464
this.resizeHeight()
465+
subscribe('collect-metadata:changed', this.refreshAfterChangeCollectMetadata)
466+
},
467+
beforeUnmount() {
468+
unsubscribe('collect-metadata:changed')
464469
},
465470
methods: {
466471
reset() {
467472
this.dislaySuccessTemplate = false
468473
this.errorMessageBackground = ''
469474
this.errorMessageTemplate = []
470475
},
476+
async refreshAfterChangeCollectMetadata() {
477+
await axios.get(generateOcsUrl('/apps/libresign/api/v1/admin/signature-settings'))
478+
.then(({ data }) => {
479+
this.availableVariables = data.ocs.data.signature_available_variables
480+
this.defaultSignatureTextTemplate = data.ocs.data.default_signature_text_template
481+
})
482+
},
471483
activateLocalFilePicker() {
472484
this.reset()
473485
// Set to null so that selecting the same file will trigger the change event

0 commit comments

Comments
 (0)