<commit_before><!--
 - @copyright Copyright (c) 2019 <NAME> <<EMAIL>>
 -
 - @author <NAME> <<EMAIL>>
 -
 - @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>
	<div id="signaling_server" class="videocalls section signaling-server">
		<h2>
			{{ t('spreed', 'High-performance backend') }}

			<NcButton v-if="!loading && showAddServerButton"
				class="signaling-server__add-icon"
				type="tertiary-no-background"
				:aria-label="t('spreed', 'Add a new high-performance backend server')"
				@click="newServer">
				<template #icon>
					<Plus :size="20" />
				</template>
			</NcButton>
		</h2>

		<p class="settings-hint">
			{{ t('spreed', 'An external signaling server should optionally be used for larger installations. Leave empty to use the internal signaling server.') }}
			<span v-if="!servers.length">{{ t('spreed', 'Please note that calls with more than 4 participants without external signaling server, participants can experience connectivity issues and cause high load on participating devices.') }}</span>
		</p>

		<p v-if="!isCacheConfigured"
			class="settings-hint warning">
			{{ t('spreed', 'It is highly recommended to set up a distributed cache when using Nextcloud Talk together with a High Performance Back-end.') }}
		</p>

		<div v-if="!servers.length" class="signaling-warning">
			<input id="hide_warning"
				v-model="hideWarning"
				type="checkbox"
				name="hide_warning"
				class="checkbox"
				:disabled="loading"
				@change="updateHideWarning">
			<label for="hide_warning">{{ t('spreed', 'Don\'t warn about connectivity issues in calls with more than 4 participants') }}</label>
		</div>

		<ul class="turn-servers">
			<transition-group name="fade" tag="li">
				<SignalingServer v-for="(server, index) in servers"
					:key="`server${index}`"
					:server.sync="servers[index].server"
					:verify.sync="servers[index].verify"
					:index="index"
					:loading="loading"
					@remove-server="removeServer"
					@update:server="debounceUpdateServers"
					@update:verify="debounceUpdateServers" />
			</transition-group>
		</ul>

		<div class="signaling-secret">
			<h4>{{ t('spreed', 'Shared secret') }}</h4>
			<input v-model="secret"
				type="text"
				name="signaling_secret"
				:disabled="loading"
				:placeholder="t('spreed', 'Shared secret')"
				:aria-label="t('spreed', 'Shared secret')"
				@input="debounceUpdateServers">
		</div>
	</div>
</template>

<script>
import SignalingServer from '../../components/AdminSettings/SignalingServer.vue'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import Plus from 'vue-material-design-icons/Plus.vue'
import { showSuccess } from '@nextcloud/dialogs'
import { loadState } from '@nextcloud/initial-state'
import debounce from 'debounce'
import { SIGNALING } from '../../constants.js'

export default {
	name: 'SignalingServers',

	components: {
		NcButton,
		SignalingServer,
		Plus,
	},

	data() {
		return {
			servers: [],
			secret: '',
			hideWarning: false,
			loading: false,
			saved: false,<commit_msg>Migrate warning toggle to NcCheckboxRadioSwitch<commit_after><!--
 - @copyright Copyright (c) 2019 <NAME> <<EMAIL>>
 -
 - @author <NAME> <<EMAIL>>
 -
 - @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>
	<div id="signaling_server" class="videocalls section signaling-server">
		<h2>
			{{ t('spreed', 'High-performance backend') }}

			<NcButton v-if="!loading && showAddServerButton"
				class="signaling-server__add-icon"
				type="tertiary-no-background"
				:aria-label="t('spreed', 'Add a new high-performance backend server')"
				@click="newServer">
				<template #icon>
					<Plus :size="20" />
				</template>
			</NcButton>
		</h2>

		<p class="settings-hint">
			{{ t('spreed', 'An external signaling server should optionally be used for larger installations. Leave empty to use the internal signaling server.') }}
			<span v-if="!servers.length">{{ t('spreed', 'Please note that calls with more than 4 participants without external signaling server, participants can experience connectivity issues and cause high load on participating devices.') }}</span>
		</p>

		<p v-if="!isCacheConfigured"
			class="settings-hint warning">
			{{ t('spreed', 'It is highly recommended to set up a distributed cache when using Nextcloud Talk together with a High Performance Back-end.') }}
		</p>

		<div v-if="!servers.length" class="signaling-warning">
			<NcCheckboxRadioSwitch :checked.sync="hideWarning"
				name="hide_warning"
				:disabled="loading"
				type="switch"
				@update:checked="updateHideWarning">
				{{ t('spreed', 'Don\'t warn about connectivity issues in calls with more than 4 participants') }}
			</NcCheckboxRadioSwitch>
		</div>

		<ul class="turn-servers">
			<transition-group name="fade" tag="li">
				<SignalingServer v-for="(server, index) in servers"
					:key="`server${index}`"
					:server.sync="servers[index].server"
					:verify.sync="servers[index].verify"
					:index="index"
					:loading="loading"
					@remove-server="removeServer"
					@update:server="debounceUpdateServers"
					@update:verify="debounceUpdateServers" />
			</transition-group>
		</ul>

		<div class="signaling-secret">
			<h4>{{ t('spreed', 'Shared secret') }}</h4>
			<input v-model="secret"
				type="text"
				name="signaling_secret"
				:disabled="loading"
				:placeholder="t('spreed', 'Shared secret')"
				:aria-label="t('spreed', 'Shared secret')"
				@input="debounceUpdateServers">
		</div>
	</div>
</template>

<script>
import SignalingServer from '../../components/AdminSettings/SignalingServer.vue'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js'
import Plus from 'vue-material-design-icons/Plus.vue'
import { showSuccess } from '@nextcloud/dialogs'
import { loadState } from '@nextcloud/initial-state'
import debounce from 'debounce'
import { SIGNALING } from '../../constants.js'

export default {
	name: 'SignalingServers',

	components: {
		NcButton,
		NcCheckboxRadioSwitch,
		SignalingServer,
		Plus,
	},

	data() {
		return {
			servers: [],
			secret: '',
			hideWarning: false,
			loading: false,
			saved: false,
{'fraction_non_alphanumeric': 0.13815005954743945, 'fraction_numerical': 0.003705174010850867, 'mean_word_length': 4.015262110152621, 'pattern_counts': {'":': 0, '<': 84, '<?xml version=': 0, '>': 84, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7143933', 'n_tokens_mistral': 2600, 'n_tokens_neox': 2259, 'n_words': 696}