mirror of https://github.com/sualko/cloud_bbb
feat: clone rooms
parent
9564fcd63c
commit
69b8d73687
|
@ -43,7 +43,7 @@ const App: React.FC<Props> = () => {
|
||||||
const [orderBy, setOrderBy] = useState<SortKey>('name');
|
const [orderBy, setOrderBy] = useState<SortKey>('name');
|
||||||
const [sortOrder, setSortOrder] = useState(SortOrder.ASC);
|
const [sortOrder, setSortOrder] = useState(SortOrder.ASC);
|
||||||
|
|
||||||
const rows = rooms.sort(sortRooms(orderBy, sortOrder)).map(room => <RoomRow room={room} restriction={restriction} key={room.id} updateRoom={updateRoom} deleteRoom={deleteRoom} />);
|
const rows = rooms.sort(sortRooms(orderBy, sortOrder)).map(room => <RoomRow room={room} restriction={restriction} key={room.id} updateRoom={updateRoom} deleteRoom={deleteRoom} cloneRoom={cloneRoom}/>);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
Promise.all([
|
Promise.all([
|
||||||
|
@ -121,6 +121,25 @@ const App: React.FC<Props> = () => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cloneRoom(room: Room) {
|
||||||
|
|
||||||
|
let access = Access.Public;
|
||||||
|
|
||||||
|
const disabledRoomTypes = restriction?.roomTypes || [];
|
||||||
|
if (disabledRoomTypes.length > 0 && disabledRoomTypes.indexOf(access) > -1) {
|
||||||
|
access = Object.values(Access).filter(a => disabledRoomTypes.indexOf(a) < 0)[0] as Access;
|
||||||
|
}
|
||||||
|
|
||||||
|
const maxParticipants = restriction?.maxParticipants || 0;
|
||||||
|
|
||||||
|
return api.createRoom(room.name, access, maxParticipants).then(newRoom => {
|
||||||
|
room.uid = newRoom.uid;
|
||||||
|
room.id = newRoom.id;
|
||||||
|
setRooms(rooms.concat([room]));
|
||||||
|
updateRoom(room);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const maxRooms = restriction?.maxRooms || 0;
|
const maxRooms = restriction?.maxRooms || 0;
|
||||||
const quota = maxRooms < 0 ? t('bbb', 'unlimited') : rooms.filter(room => room.userId === OC.currentUser).length + ' / ' + maxRooms;
|
const quota = maxRooms < 0 ? t('bbb', 'unlimited') : rooms.filter(room => room.userId === OC.currentUser).length + ' / ' + maxRooms;
|
||||||
|
|
||||||
|
@ -151,6 +170,7 @@ const App: React.FC<Props> = () => {
|
||||||
</th>
|
</th>
|
||||||
<th />
|
<th />
|
||||||
<th />
|
<th />
|
||||||
|
<th />
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
|
@ -11,6 +11,7 @@ type Props = {
|
||||||
restriction?: Restriction;
|
restriction?: Restriction;
|
||||||
updateRoom: (room: Room) => Promise<void>;
|
updateRoom: (room: Room) => Promise<void>;
|
||||||
deleteRoom: (id: number) => void;
|
deleteRoom: (id: number) => void;
|
||||||
|
cloneRoom: (room: Room) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
type RecordingsNumberProps = {
|
type RecordingsNumberProps = {
|
||||||
|
@ -175,6 +176,10 @@ const RoomRow: React.FC<Props> = (props) => {
|
||||||
return <EditableValue field={field} value={room[field]} setValue={updateRoom} type={type} options={options} />;
|
return <EditableValue field={field} value={room[field]} setValue={updateRoom} type={type} options={options} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cloneRow() {
|
||||||
|
props.cloneRoom({...props.room});
|
||||||
|
}
|
||||||
|
|
||||||
const avatarUrl = OC.generateUrl('/avatar/' + encodeURIComponent(room.userId) + '/' + 24, {
|
const avatarUrl = OC.generateUrl('/avatar/' + encodeURIComponent(room.userId) + '/' + 24, {
|
||||||
user: room.userId,
|
user: room.userId,
|
||||||
size: 24,
|
size: 24,
|
||||||
|
@ -225,6 +230,11 @@ const RoomRow: React.FC<Props> = (props) => {
|
||||||
<td className="edit icon-col">
|
<td className="edit icon-col">
|
||||||
<EditRoom room={props.room} restriction={props.restriction} updateProperty={updateRoom} />
|
<EditRoom room={props.room} restriction={props.restriction} updateProperty={updateRoom} />
|
||||||
</td>
|
</td>
|
||||||
|
<td className="clone icon-col">
|
||||||
|
<button className="action-item" onClick={cloneRow} title={t('bbb', 'Clone Room')}>
|
||||||
|
<span className="icon icon-template-add icon-visible"></span>
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
<td className="remove icon-col">
|
<td className="remove icon-col">
|
||||||
<button className="action-item" onClick={deleteRow as any} title={t('bbb', 'Delete')}>
|
<button className="action-item" onClick={deleteRow as any} title={t('bbb', 'Delete')}>
|
||||||
<span className="icon icon-delete icon-visible"></span>
|
<span className="icon icon-delete icon-visible"></span>
|
||||||
|
|
Loading…
Reference in New Issue