<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>
	<modal @close="close">
		<div id="modal-inner" :class="{ 'icon-loading': loading }">
			<div id="modal-content">
				<h1>{{ t('spreed', 'Select a room to link to the collection') }}</h1>
				<div id="room-list">
					<ul v-if="!loading">
						<li v-for="room in rooms" :key="room.token" :class="{'selected': (selectedRoom === room.id) }"
							@click="selectedRoom=room.token">
							<avatar v-if="room.type === types.ROOM_TYPE_ONE_TO_ONE" :user="room.name" />
							<div v-else-if="room.type === types.ROOM_TYPE_GROUP" class="avatar icon icon-contacts" />
							<div v-else-if="room.type === types.ROOM_TYPE_PUBLIC" class="avatar icon icon-public icon-white" />
							<span>{{ room.displayName }}</span>
						</li>
					</ul>
				</div>
				<div id="modal-buttons">
					<button v-if="!loading" class="primary" @click="select">
						{{ t('spreed', 'Select room') }}
					</button>
				</div>
			</div>
		</div>
	</modal>
</template>
<style scoped>
	#modal-inner {
		width: 90vw;
		max-width: 400px;
		height: 50vh;
		position: relative;
	}
	#modal-content {
		position: absolute;
		width: calc(100% - 40px);
		height: calc(100% - 40px);
		display: flex;
		flex-direction: column;
		padding: 20px;
	}
	#room-list {
		overflow: scroll;
		flex: 0 1 auto;
	}
	li {
		padding: 6px;
		border: 1px solid transparent;
		display: flex;
	}
	li:hover, li:focus {
		background-color: var(--color-background-dark);
	}
	li.selected {
		border: 1px solid var(--color-primary);
	}
	.avatar.icon {
		border-radius: 50%;
		width: 32px;
		height: 32px;
		background-color: var(--color-background-darker);
	}
	li > span {
		padding: 5px;
	}
	li > span,
	.avatar {
		vertical-align: middle;

	}
	#modal-buttons {
		overflow: hidden;
		height: 44px;
		flex-shrink: 0;
	}
	#modal-buttons .primary {
		float: right;
	}

</style>
<script>
/* global OC */
import { Modal } from 'nextcloud-vue/dist/Components/Modal'
import { Avatar } from 'nextcloud-vue/dist/Components/Avatar'
import axios from 'nextcloud-axios'

export default {
	name: 'CollaborationView',
	components: {
		Modal, Avatar
	},
	data() {
		return {
			rooms: [],
			selectedRoom: null,
			loading: true,
			// TODO: should be included once this is properly available
			types: {
				ROOM_TYPE_ONE_TO_ONE: 1,
				ROOM_TYPE_GROUP: 2,
				ROOM_TYPE_PUBLIC: 3
			}
		}
	},
	beforeMount() {
		this.fetchRooms()
	},
	methods: {
		fetchRooms() {
			axios.get(OC.linkToOCS('/apps/spreed/api/v1', 2) + 'room').then((response) => {
				this.rooms = response.data.ocs.data
				this.loading = false
			})
		},
		close() {
			this.$root.$emit('close')
		},
		select() {
			this.$root.$emit('select', this.selectedRoom)
		}
	}
}
</script><commit_msg>Fix scrollbar and hide current room<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>
	<modal @close="close">
		<div id="modal-inner" :class="{ 'icon-loading': loading }">
			<div id="modal-content">
				<h1>{{ t('spreed', 'Select a room to link to the collection') }}</h1>
				<div id="room-list">
					<ul v-if="!loading">
						<li v-for="room in availableRooms" :key="room.token" :class="{'selected': (selectedRoom === room.id) }"
							@click="selectedRoom=room.token">
							<avatar v-if="room.type === types.ROOM_TYPE_ONE_TO_ONE" :user="room.name" />
							<div v-else-if="room.type === types.ROOM_TYPE_GROUP" class="avatar icon icon-contacts" />
							<div v-else-if="room.type === types.ROOM_TYPE_PUBLIC" class="avatar icon icon-public icon-white" />
							<span>{{ room.displayName }}</span>
						</li>
					</ul>
				</div>
				<div id="modal-buttons">
					<button v-if="!loading" class="primary" @click="select">
						{{ t('spreed', 'Select room') }}
					</button>
				</div>
			</div>
		</div>
	</modal>
</template>
<style scoped>
	#modal-inner {
		width: 90vw;
		max-width: 400px;
		height: 50vh;
		position: relative;
	}
	#modal-content {
		position: absolute;
		width: calc(100% - 40px);
		height: calc(100% - 40px);
		display: flex;
		flex-direction: column;
		padding: 20px;
	}
	#room-list {
		overflow-y: scroll;
		flex: 0 1 auto;
	}
	li {
		padding: 6px;
		border: 1px solid transparent;
		display: flex;
	}
	li:hover, li:focus {
		background-color: var(--color-background-dark);
	}
	li.selected {
		border: 1px solid var(--color-primary);
	}
	.avatar.icon {
		border-radius: 50%;
		width: 32px;
		height: 32px;
		background-color: var(--color-background-darker);
	}
	li > span {
		padding: 5px;
	}
	li > span,
	.avatar {
		vertical-align: middle;

	}
	#modal-buttons {
		overflow: hidden;
		height: 44px;
		flex-shrink: 0;
	}
	#modal-buttons .primary {
		float: right;
	}

</style>
<script>
/* global OC */
import { Modal } from 'nextcloud-vue/dist/Components/Modal'
import { Avatar } from 'nextcloud-vue/dist/Components/Avatar'
import axios from 'nextcloud-axios'

export default {
	name: 'CollaborationView',
	components: {
		Modal, Avatar
	},
	data() {
		return {
			rooms: [],
			selectedRoom: null,
			loading: true,
			// TODO: should be included once this is properly available
			types: {
				ROOM_TYPE_ONE_TO_ONE: 1,
				ROOM_TYPE_GROUP: 2,
				ROOM_TYPE_PUBLIC: 3
			}
		}
	},
	beforeMount() {
		this.fetchRooms()
	},
	methods: {
		fetchRooms() {
			axios.get(OC.linkToOCS('/apps/spreed/api/v1', 2) + 'room').then((response) => {
				this.rooms = response.data.ocs.data
				this.loading = false
			})
		},
		close() {
			this.$root.$emit('close')
		},
		select() {
			this.$root.$emit('select', this.selectedRoom)
		}
	},
	computed: {
		currentRoom() {
			if (OCA.SpreedMe && OCA.SpreedMe.app.activeRoom) {
				return OCA.SpreedMe.app.activeRoom.get('token')
			}
			return null
		},
		availableRooms() {
			return this.rooms.filter((room) => room.token !== this.currentRoom)
		}
	}
}
</script>
{'fraction_non_alphanumeric': 0.15610217596972564, 'fraction_numerical': 0.012704419516150832, 'mean_word_length': 3.0838852097130243, 'pattern_counts': {'":': 0, '<': 77, '<?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': '1531656', 'n_tokens_mistral': 3045, 'n_tokens_neox': 2615, 'n_words': 690}