Skip to content

Commit

Permalink
refactor: convert to promisse
Browse files Browse the repository at this point in the history
Signed-off-by: Vitor Mattos <[email protected]>
  • Loading branch information
vitormattos authored and backportbot-libresign[bot] committed Jan 28, 2025
1 parent dc50351 commit 9402369
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions src/views/Settings/IdentificationDocuments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadi
import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js'
import NcSettingsSection from '@nextcloud/vue/dist/Components/NcSettingsSection.js'
import logger from '../../logger.js'
export default {
name: 'IdentificationDocuments',
components: {
Expand Down Expand Up @@ -61,12 +63,19 @@ export default {
const responseIdentificationDocuments = await axios.get(generateOcsUrl('/apps/provisioning_api/api/v1/config/apps/libresign/identification_documents'))
this.identificationDocumentsFlowEnabled = !!responseIdentificationDocuments.data.ocs.data.data
const responseApprovalGroups = await axios.get(
await axios.get(
generateOcsUrl('/apps/provisioning_api/api/v1/config/apps/libresign/approval_group'),
)
if (responseApprovalGroups.data.ocs.data.data !== '') {
this.approvalGroups = JSON.parse(responseApprovalGroups.data.ocs.data.data)
}
.then(({ data }) => {
const approvalGroups = JSON.parse(data.ocs.data.data)
if (!approvalGroups) {
return
}
this.approvalGroups = this.groups.filter(group => {
return approvalGroups.indexOf(group.id) !== -1
})
})
.catch((error) => logger.debug('Could not fetch groups_request_sign', { error }))
},
saveIdentificationDocumentsStatus() {
OCP.AppConfig.setValue('libresign', 'identification_documents', this.identificationDocumentsFlowEnabled ? 1 : 0)
Expand All @@ -84,20 +93,18 @@ export default {
},
async searchGroup(query) {
this.loadingGroups = true
try {
const response = await axios.get(generateOcsUrl('cloud/groups/details'), {
search: query,
limit: 20,
offset: 0,
})
this.groups = response.data.ocs.data.groups.sort(function(a, b) {
return a.displayname.localeCompare(b.displayname)
await axios.get(generateOcsUrl('cloud/groups/details'), {
search: query,
limit: 20,
offset: 0,
})
.then(({ data }) => {
this.groups = data.ocs.data.groups.sort(function(a, b) {
return a.displayname.localeCompare(b.displayname)
})
})
} catch (err) {
console.error('Could not fetch groups', err)
} finally {
this.loadingGroups = false
}
.catch((error) => logger.debug('Could not search by groups', { error }))
this.loadingGroups = false
},
},
}
Expand Down

0 comments on commit 9402369

Please sign in to comment.