Skip to content

Commit

Permalink
Move SIP settings to the conversation settings dialog
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Petry <vincent@nextcloud.com>
  • Loading branch information
PVince81 committed Nov 12, 2020
1 parent 6d890b8 commit ac36fe3
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
class="app-settings-section">
<ModerationSettings />
</AppSettingsSection>
<AppSettingsSection
:title="t('spreed', 'SIP support')"
class="app-settings-section">
<SipSettings />
</AppSettingsSection>
</AppSettingsDialog>
</template>

Expand All @@ -41,6 +46,7 @@ import AppSettingsDialog from '@nextcloud/vue/dist/Components/AppSettingsDialog'
import AppSettingsSection from '@nextcloud/vue/dist/Components/AppSettingsSection'
import LinkShareSettings from './LinkShareSettings'
import ModerationSettings from './ModerationSettings'
import SipSettings from './SipSettings'
export default {
name: 'ConversationSettingsDialog',
Expand All @@ -50,6 +56,7 @@ export default {
AppSettingsSection,
LinkShareSettings,
ModerationSettings,
SipSettings,
},
data() {
Expand Down
90 changes: 90 additions & 0 deletions src/components/ConversationSettings/SipSettings.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<!--
- @copyright Copyright (c) 2020 Vincent Petry <vincent@nextcloud.com>
-
- @author Vincent Petry <vincent@nextcloud.com>
-
- @license GNU AGPL version 3 or any later version
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-->

<template>
<ul>
<ActionCheckbox
:checked="hasSIPEnabled"
:disabled="isSipLoading"
@change="toggleSIPEnabled">
{{ t('spreed', 'Enable SIP dial-in') }}
</ActionCheckbox>
</ul>
</template>

<script>
import { showError, showSuccess } from '@nextcloud/dialogs'
import { WEBINAR } from '../../constants'
import ActionCheckbox from '@nextcloud/vue/dist/Components/ActionCheckbox'
export default {
name: 'SipSettings',
components: {
ActionCheckbox,
},
data() {
return {
isSipLoading: false,
}
},
computed: {
token() {
return this.$store.getters.getToken()
},
conversation() {
return this.$store.getters.conversation(this.token) || this.$store.getters.dummyConversation
},
hasSIPEnabled() {
return this.conversation.sipEnabled === WEBINAR.SIP.ENABLED
},
},
methods: {
async toggleSIPEnabled(checked) {
try {
await this.$store.dispatch('setSIPEnabled', {
token: this.token,
state: checked ? WEBINAR.SIP.ENABLED : WEBINAR.SIP.DISABLED,
})
if (checked) {
showSuccess(t('spreed', 'SIP dial-in is now enabled'))
} else {
showSuccess(t('spreed', 'SIP dial-in is now disabled'))
}
} catch (e) {
// TODO check "precondition failed"
if (checked) {
console.error('Error occurred when enabling SIP dial-in', e)
showError(t('spreed', 'Error occurred when enabling SIP dial-in'))
} else {
console.error('Error occurred when disabling SIP dial-in', e)
showError(t('spreed', 'Error occurred when disabling SIP dial-in'))
}
}
},
},
}
</script>
28 changes: 1 addition & 27 deletions src/components/TopBar/TopBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,6 @@
@click="handleCopyLink">
{{ t('spreed', 'Copy link') }}
</ActionButton>
<template
v-if="showModerationOptions">
<ActionCheckbox
:checked="hasSIPEnabled"
@change="toggleSIPEnabled">
{{ t('spreed', 'Enable SIP dial-in') }}
</ActionCheckbox>
</template>
<template
v-if="showModerationOptions && canFullModerate && isInCall">
<ActionSeparator />
Expand Down Expand Up @@ -134,10 +126,9 @@ import Actions from '@nextcloud/vue/dist/Components/Actions'
import CallButton from './CallButton'
import { EventBus } from '../../services/EventBus'
import BrowserStorage from '../../services/BrowserStorage'
import ActionCheckbox from '@nextcloud/vue/dist/Components/ActionCheckbox'
import ActionLink from '@nextcloud/vue/dist/Components/ActionLink'
import ActionSeparator from '@nextcloud/vue/dist/Components/ActionSeparator'
import { CONVERSATION, WEBINAR, PARTICIPANT } from '../../constants'
import { CONVERSATION, PARTICIPANT } from '../../constants'
import { generateUrl } from '@nextcloud/router'
import { callParticipantCollection } from '../../utils/webrtc/index'
import { emit } from '@nextcloud/event-bus'
Expand All @@ -148,7 +139,6 @@ export default {
components: {
ActionButton,
Actions,
ActionCheckbox,
ActionLink,
CallButton,
Popover,
Expand Down Expand Up @@ -263,9 +253,6 @@ export default {
|| this.conversation.type === CONVERSATION.TYPE.PUBLIC
},
hasSIPEnabled() {
return this.conversation.sipEnabled === WEBINAR.SIP.ENABLED
},
isGrid() {
return this.$store.getters.isGrid
},
Expand Down Expand Up @@ -348,19 +335,6 @@ export default {
this.showLayoutHint = false
},
async toggleSIPEnabled(checked) {
try {
await this.$store.dispatch('setSIPEnabled', {
token: this.token,
state: checked ? WEBINAR.SIP.ENABLED : WEBINAR.SIP.DISABLED,
})
} catch (e) {
// TODO check "precondition failed"
// TODO showError()
console.error(e)
}
},
async handleCopyLink() {
try {
await this.$copyText(this.linkToConversation)
Expand Down

0 comments on commit ac36fe3

Please sign in to comment.