Skip to content

Commit

Permalink
MVP - add option in admin settings to enable recording consent
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
  • Loading branch information
Antreesy committed Oct 5, 2023
1 parent b8b3d6c commit 8a46f05
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
80 changes: 80 additions & 0 deletions src/components/AdminSettings/RecordingServers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,30 @@
:label="t('spreed', 'Shared secret')"
label-visible
@update:value="updateSecret" />

<template v-if="servers.length && recordingConsentCapability">
<h3>{{ t('spreed', 'Recording consent') }}</h3>

<label for="recording-consent_input" class="recording-consent__label">
{{ t('spreed', 'Require recording consent before joining call') }}
</label>
<NcSelect v-model="recordingConsentSelected"
input-id="recording-consent_input"
class="recording-consent__select"
name="recording-consent"
:options="recordingConsentOptions"
:clearable="false"
:placeholder="t('spreed', 'Recording consent')"
label="label"
track-by="value"
no-wrap
:disabled="loading"
@input="setRecordingConsent" />

<NcNoteCard v-if="recordingConsentSelected.value" type="warning">
{{ getRecordingConsentWarning(recordingConsentSelected.value) }}
</NcNoteCard>
</template>
</section>
</template>

Expand All @@ -73,36 +97,55 @@ import debounce from 'debounce'

import Plus from 'vue-material-design-icons/Plus.vue'

import { getCapabilities } from '@nextcloud/capabilities'
import { showSuccess } from '@nextcloud/dialogs'
import { formatFileSize } from '@nextcloud/files'
import { loadState } from '@nextcloud/initial-state'

import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcNoteCard from '@nextcloud/vue/dist/Components/NcNoteCard.js'
import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js'
import NcTextField from '@nextcloud/vue/dist/Components/NcTextField.js'

import RecordingServer from '../../components/AdminSettings/RecordingServer.vue'
import { CALL } from '../../constants.js'
import TransitionWrapper from '../TransitionWrapper.vue'

const recordingConsentCapability = getCapabilities()?.spreed?.features?.includes('recording-consent')
const recordingConsentOptions = [
{ value: CALL.RECORDING_CONSENT.OFF, label: t('spreed', 'Off') },
{ value: CALL.RECORDING_CONSENT.REQUIRED, label: t('spreed', 'Enabled') },
{ value: CALL.RECORDING_CONSENT.OPTIONAL, label: t('spreed', 'Optional') },
]

export default {
name: 'RecordingServers',

components: {
NcButton,
NcNoteCard,
NcSelect,
NcTextField,
Plus,
RecordingServer,
TransitionWrapper,
},

setup() {
return {
recordingConsentCapability,
recordingConsentOptions,
}
},

data() {
return {
servers: [],
secret: '',
uploadLimit: 0,
loading: false,
saved: false,
recordingConsentSelected: recordingConsentOptions.find(option => option.value === loadState('spreed', 'recording_consent')),
}
},

Expand Down Expand Up @@ -164,6 +207,27 @@ export default {
})
},

setRecordingConsent(checked) {
this.loading = true
OCP.AppConfig.setValue('spreed', 'recording_consent', checked.value.toString(), {
success: function() {
this.loading = false
}.bind(this),
})
},

getRecordingConsentWarning(value) {
switch (value) {
case CALL.RECORDING_CONSENT.OPTIONAL:
return t('spreed', 'Moderators will be allowed to enable consent on conversation level. The consent to be recorded will be required for each participant before joining every call in this conversation.')
case CALL.RECORDING_CONSENT.REQUIRED:
return t('spreed', 'The consent to be recorded will be required for each participant before joining every call.')
case CALL.RECORDING_CONSENT.OFF:
default:
return ''
}
},

toggleSave() {
this.saved = true
setTimeout(() => {
Expand All @@ -182,4 +246,20 @@ export default {
.additional-top-margin {
margin-top: 10px;
}

h3 {
margin-top: 24px;
font-weight: 600;
}

.recording-consent {
&__select {
width: 300px;
}

&__label {
display: block;
padding: 4px 0;
}
}
</style>
5 changes: 5 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ export const CALL = {
AUDIO_STARTING: 4,
FAILED: 5,
},
RECORDING_CONSENT: {
OFF: 0,
REQUIRED: 1,
OPTIONAL: 2,
},
}

export const CONVERSATION = {
Expand Down

0 comments on commit 8a46f05

Please sign in to comment.