feat: delete zoom accounts from settings
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
:options="{
|
:options="{
|
||||||
title:
|
title:
|
||||||
accountID === 'new' ? __('New Zoom Account') : __('Edit Zoom Account'),
|
accountID === 'new' ? __('New Zoom Account') : __('Edit Zoom Account'),
|
||||||
size: 'lg',
|
size: 'xl',
|
||||||
actions: [
|
actions: [
|
||||||
{
|
{
|
||||||
label: __('Save'),
|
label: __('Save'),
|
||||||
@@ -17,17 +17,17 @@
|
|||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<template #body-content>
|
<template #body-content>
|
||||||
<div class="grid grid-cols-2 gap-5">
|
<div class="mb-4">
|
||||||
<Link
|
|
||||||
v-model="account.member"
|
|
||||||
:label="__('Member')"
|
|
||||||
doctype="User"
|
|
||||||
:onCreate="(value, close) => openSettings('Members', close)"
|
|
||||||
:required="true"
|
|
||||||
/>
|
|
||||||
<FormControl
|
<FormControl
|
||||||
v-model="account.account_id"
|
v-model="account.enabled"
|
||||||
:label="__('Account ID')"
|
:label="__('Enabled')"
|
||||||
|
type="checkbox"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="grid grid-cols-2 gap-5">
|
||||||
|
<FormControl
|
||||||
|
v-model="account.name"
|
||||||
|
:label="__('Account Name')"
|
||||||
type="text"
|
type="text"
|
||||||
:required="true"
|
:required="true"
|
||||||
/>
|
/>
|
||||||
@@ -37,25 +37,40 @@
|
|||||||
type="text"
|
type="text"
|
||||||
:required="true"
|
:required="true"
|
||||||
/>
|
/>
|
||||||
|
<Link
|
||||||
|
v-model="account.member"
|
||||||
|
:label="__('Member')"
|
||||||
|
doctype="Course Evaluator"
|
||||||
|
:onCreate="(value, close) => openSettings('Members', close)"
|
||||||
|
:required="true"
|
||||||
|
/>
|
||||||
<FormControl
|
<FormControl
|
||||||
v-model="account.client_secret"
|
v-model="account.client_secret"
|
||||||
:label="__('Client Secret')"
|
:label="__('Client Secret')"
|
||||||
type="password"
|
type="password"
|
||||||
:required="true"
|
:required="true"
|
||||||
/>
|
/>
|
||||||
|
<FormControl
|
||||||
|
v-model="account.account_id"
|
||||||
|
:label="__('Account ID')"
|
||||||
|
type="text"
|
||||||
|
:required="true"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Dialog, FormControl } from 'frappe-ui'
|
import { call, Dialog, FormControl, toast } from 'frappe-ui'
|
||||||
import { inject, reactive, watch } from 'vue'
|
import { inject, reactive, watch } from 'vue'
|
||||||
import { User } from '@/components/Settings/types'
|
import { User } from '@/components/Settings/types'
|
||||||
import { openSettings } from '@/utils'
|
import { openSettings, cleanError } from '@/utils'
|
||||||
import Link from '@/components/Controls/Link.vue'
|
import Link from '@/components/Controls/Link.vue'
|
||||||
|
|
||||||
interface ZoomAccount {
|
interface ZoomAccount {
|
||||||
name: string
|
name: string
|
||||||
|
account_name: string
|
||||||
|
enabled: boolean
|
||||||
member: string
|
member: string
|
||||||
account_id: string
|
account_id: string
|
||||||
client_id: string
|
client_id: string
|
||||||
@@ -64,6 +79,13 @@ interface ZoomAccount {
|
|||||||
|
|
||||||
interface ZoomAccounts {
|
interface ZoomAccounts {
|
||||||
data: ZoomAccount[]
|
data: ZoomAccount[]
|
||||||
|
reload: () => void
|
||||||
|
insert: {
|
||||||
|
submit: (
|
||||||
|
data: ZoomAccount,
|
||||||
|
options: { onSuccess: () => void; onError: (err: any) => void }
|
||||||
|
) => void
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const show = defineModel('show')
|
const show = defineModel('show')
|
||||||
@@ -71,6 +93,8 @@ const user = inject<User | null>('$user')
|
|||||||
const zoomAccounts = defineModel<ZoomAccounts>('zoomAccounts')
|
const zoomAccounts = defineModel<ZoomAccounts>('zoomAccounts')
|
||||||
|
|
||||||
const account = reactive({
|
const account = reactive({
|
||||||
|
name: '',
|
||||||
|
enabled: false,
|
||||||
member: user?.data?.name || '',
|
member: user?.data?.name || '',
|
||||||
account_id: '',
|
account_id: '',
|
||||||
client_id: '',
|
client_id: '',
|
||||||
@@ -87,10 +111,11 @@ const props = defineProps({
|
|||||||
watch(
|
watch(
|
||||||
() => props.accountID,
|
() => props.accountID,
|
||||||
(val) => {
|
(val) => {
|
||||||
console.log(val)
|
|
||||||
if (val != 'new') {
|
if (val != 'new') {
|
||||||
zoomAccounts.value?.data.forEach((acc) => {
|
zoomAccounts.value?.data.forEach((acc) => {
|
||||||
if (acc.name === val) {
|
if (acc.name === val) {
|
||||||
|
account.name = acc.name
|
||||||
|
account.enabled = acc.enabled || false
|
||||||
account.member = acc.member
|
account.member = acc.member
|
||||||
account.account_id = acc.account_id
|
account.account_id = acc.account_id
|
||||||
account.client_id = acc.client_id
|
account.client_id = acc.client_id
|
||||||
@@ -100,4 +125,82 @@ watch(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
watch(show, (val) => {
|
||||||
|
if (!val) {
|
||||||
|
account.name = ''
|
||||||
|
account.enabled = false
|
||||||
|
account.member = user?.data?.name || ''
|
||||||
|
account.account_id = ''
|
||||||
|
account.client_id = ''
|
||||||
|
account.client_secret = ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const saveAccount = (close) => {
|
||||||
|
if (props.accountID == 'new') {
|
||||||
|
createAccount(close)
|
||||||
|
} else {
|
||||||
|
updateAccount(close)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const createAccount = (close) => {
|
||||||
|
zoomAccounts.value?.insert.submit(
|
||||||
|
{
|
||||||
|
account_name: account.name,
|
||||||
|
...account,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
onSuccess() {
|
||||||
|
zoomAccounts.value?.reload()
|
||||||
|
close()
|
||||||
|
toast.success(__('Zoom Account created successfully'))
|
||||||
|
},
|
||||||
|
onError(err) {
|
||||||
|
close()
|
||||||
|
toast.error(
|
||||||
|
cleanError(err.messages[0]) || __('Error creating Zoom Account')
|
||||||
|
)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateAccount = async (close) => {
|
||||||
|
if (props.accountID != account.name) {
|
||||||
|
await renameDoc()
|
||||||
|
}
|
||||||
|
setValue(close)
|
||||||
|
}
|
||||||
|
|
||||||
|
const renameDoc = async () => {
|
||||||
|
await call('frappe.client.rename_doc', {
|
||||||
|
doctype: 'LMS Zoom Settings',
|
||||||
|
old_name: props.accountID,
|
||||||
|
new_name: account.name,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const setValue = (close) => {
|
||||||
|
zoomAccounts.value?.setValue.submit(
|
||||||
|
{
|
||||||
|
...account,
|
||||||
|
name: account.name,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
onSuccess() {
|
||||||
|
zoomAccounts.value?.reload()
|
||||||
|
close()
|
||||||
|
toast.success(__('Zoom Account updated successfully'))
|
||||||
|
},
|
||||||
|
onError(err) {
|
||||||
|
close()
|
||||||
|
toast.error(
|
||||||
|
cleanError(err.messages[0]) || __('Error updating Zoom Account')
|
||||||
|
)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
<div class="text-xl font-semibold text-ink-gray-9">
|
<div class="text-xl font-semibold text-ink-gray-9">
|
||||||
{{ label }}
|
{{ label }}
|
||||||
</div>
|
</div>
|
||||||
<div class="text-xs text-ink-gray-5">
|
<!-- <div class="text-xs text-ink-gray-5">
|
||||||
{{ __(description) }}
|
{{ __(description) }}
|
||||||
</div>
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center space-x-5">
|
<div class="flex items-center space-x-5">
|
||||||
<Button @click="openTemplateForm('new')">
|
<Button @click="openTemplateForm('new')">
|
||||||
|
|||||||
@@ -155,13 +155,13 @@ const tabsStructure = computed(() => {
|
|||||||
type: 'Column Break',
|
type: 'Column Break',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Batch Confirmation Template',
|
label: 'Batch Confirmation Email Template',
|
||||||
name: 'batch_confirmation_template',
|
name: 'batch_confirmation_template',
|
||||||
doctype: 'Email Template',
|
doctype: 'Email Template',
|
||||||
type: 'Link',
|
type: 'Link',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Certification Template',
|
label: 'Certification Email Template',
|
||||||
name: 'certification_template',
|
name: 'certification_template',
|
||||||
doctype: 'Email Template',
|
doctype: 'Email Template',
|
||||||
type: 'Link',
|
type: 'Link',
|
||||||
|
|||||||
@@ -48,7 +48,15 @@
|
|||||||
<ListRow :row="row" v-for="row in zoomAccounts.data">
|
<ListRow :row="row" v-for="row in zoomAccounts.data">
|
||||||
<template #default="{ column, item }">
|
<template #default="{ column, item }">
|
||||||
<ListRowItem :item="row[column.key]" :align="column.align">
|
<ListRowItem :item="row[column.key]" :align="column.align">
|
||||||
<div class="leading-5 text-sm">
|
<div v-if="column.key == 'enabled'">
|
||||||
|
<Badge v-if="row[column.key]" theme="blue">
|
||||||
|
{{ __('Enabled') }}
|
||||||
|
</Badge>
|
||||||
|
<Badge v-else theme="gray">
|
||||||
|
{{ __('Disabled') }}
|
||||||
|
</Badge>
|
||||||
|
</div>
|
||||||
|
<div v-else class="leading-5 text-sm">
|
||||||
{{ row[column.key] }}
|
{{ row[column.key] }}
|
||||||
</div>
|
</div>
|
||||||
</ListRowItem>
|
</ListRowItem>
|
||||||
@@ -61,7 +69,7 @@
|
|||||||
<div class="flex gap-2">
|
<div class="flex gap-2">
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
@click="removeTemplate(selections, unselectAll)"
|
@click="removeAccount(selections, unselectAll)"
|
||||||
>
|
>
|
||||||
<Trash2 class="h-4 w-4 stroke-1.5" />
|
<Trash2 class="h-4 w-4 stroke-1.5" />
|
||||||
</Button>
|
</Button>
|
||||||
@@ -71,12 +79,18 @@
|
|||||||
</ListView>
|
</ListView>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ZoomAccountModal v-model="showForm" v-model:zoomAccounts="zoomAccounts" />
|
<ZoomAccountModal
|
||||||
|
v-model="showForm"
|
||||||
|
v-model:zoomAccounts="zoomAccounts"
|
||||||
|
:accountID="currentAccount"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {
|
import {
|
||||||
createListResource,
|
|
||||||
Button,
|
Button,
|
||||||
|
Badge,
|
||||||
|
call,
|
||||||
|
createListResource,
|
||||||
ListView,
|
ListView,
|
||||||
ListHeader,
|
ListHeader,
|
||||||
ListHeaderItem,
|
ListHeaderItem,
|
||||||
@@ -84,9 +98,11 @@ import {
|
|||||||
ListRow,
|
ListRow,
|
||||||
ListRowItem,
|
ListRowItem,
|
||||||
ListSelectBanner,
|
ListSelectBanner,
|
||||||
|
toast,
|
||||||
} from 'frappe-ui'
|
} from 'frappe-ui'
|
||||||
import { computed, inject, onMounted, ref } from 'vue'
|
import { computed, inject, onMounted, ref } from 'vue'
|
||||||
import { Plus, Trash2 } from 'lucide-vue-next'
|
import { Plus, Trash2 } from 'lucide-vue-next'
|
||||||
|
import { cleanError } from '@/utils'
|
||||||
import { User } from '@/components/Settings/types'
|
import { User } from '@/components/Settings/types'
|
||||||
import ZoomAccountModal from '@/components/Modals/ZoomAccountModal.vue'
|
import ZoomAccountModal from '@/components/Modals/ZoomAccountModal.vue'
|
||||||
|
|
||||||
@@ -103,6 +119,7 @@ const zoomAccounts = createListResource({
|
|||||||
doctype: 'LMS Zoom Settings',
|
doctype: 'LMS Zoom Settings',
|
||||||
fields: [
|
fields: [
|
||||||
'name',
|
'name',
|
||||||
|
'enabled',
|
||||||
'member',
|
'member',
|
||||||
'member_name',
|
'member_name',
|
||||||
'account_id',
|
'account_id',
|
||||||
@@ -119,7 +136,7 @@ onMounted(() => {
|
|||||||
const fetchZoomAccounts = () => {
|
const fetchZoomAccounts = () => {
|
||||||
if (!user?.data?.is_moderator && !user?.data?.is_evaluator) return
|
if (!user?.data?.is_moderator && !user?.data?.is_evaluator) return
|
||||||
|
|
||||||
if (user?.data?.is_evaluator) {
|
if (!user?.data?.is_moderator) {
|
||||||
zoomAccounts.update({
|
zoomAccounts.update({
|
||||||
filters: {
|
filters: {
|
||||||
member: user.data.name,
|
member: user.data.name,
|
||||||
@@ -134,6 +151,23 @@ const openForm = (accountID: string) => {
|
|||||||
showForm.value = true
|
showForm.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const removeAccount = (selections, unselectAll) => {
|
||||||
|
call('lms.lms.api.delete_documents', {
|
||||||
|
doctype: 'LMS Zoom Settings',
|
||||||
|
documents: Array.from(selections),
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
zoomAccounts.reload()
|
||||||
|
toast.success(__('Email Templates deleted successfully'))
|
||||||
|
unselectAll()
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
toast.error(
|
||||||
|
cleanError(err.messages[0]) || __('Error deleting email templates')
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const columns = computed(() => {
|
const columns = computed(() => {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@@ -144,6 +178,11 @@ const columns = computed(() => {
|
|||||||
label: __('Member'),
|
label: __('Member'),
|
||||||
key: 'member_name',
|
key: 'member_name',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: __('Enabled'),
|
||||||
|
key: 'enabled',
|
||||||
|
align: 'center',
|
||||||
|
},
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -163,6 +163,11 @@
|
|||||||
doctype="LMS Zoom Settings"
|
doctype="LMS Zoom Settings"
|
||||||
:label="__('Zoom Account')"
|
:label="__('Zoom Account')"
|
||||||
v-model="batch.zoom_account"
|
v-model="batch.zoom_account"
|
||||||
|
:onCreate="
|
||||||
|
(value, close) => {
|
||||||
|
openSettings('Zoom Accounts', close)
|
||||||
|
}
|
||||||
|
"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="space-y-5">
|
<div class="space-y-5">
|
||||||
|
|||||||
Reference in New Issue
Block a user