mirror of https://github.com/sualko/cloud_bbb
parent
9564fcd63c
commit
46806ebe1a
|
@ -43,7 +43,7 @@ const App: React.FC<Props> = () => {
|
|||
const [orderBy, setOrderBy] = useState<SortKey>('name');
|
||||
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(() => {
|
||||
Promise.all([
|
||||
|
@ -105,6 +105,10 @@ const App: React.FC<Props> = () => {
|
|||
|
||||
function updateRoom(room: Room) {
|
||||
return api.updateRoom(room).then(updatedRoom => {
|
||||
|
||||
if (!rooms.find(room => room.id === updatedRoom.id)) {
|
||||
setRooms(rooms.concat([updatedRoom]));
|
||||
} else {
|
||||
setRooms(rooms.map(room => {
|
||||
if (room.id === updatedRoom.id) {
|
||||
return updatedRoom;
|
||||
|
@ -112,6 +116,7 @@ const App: React.FC<Props> = () => {
|
|||
|
||||
return room;
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -121,6 +126,25 @@ const App: React.FC<Props> = () => {
|
|||
});
|
||||
}
|
||||
|
||||
function cloneRoom(room: Room) {
|
||||
|
||||
if (room.moderatorToken !== null) {
|
||||
room.moderatorToken = 'true';
|
||||
}
|
||||
|
||||
return api.createRoom(room.name, room.access, room.maxParticipants).then(newRoom => {
|
||||
api.getRoomShares(room.id).then(shares => shares.forEach(share => {
|
||||
api.createRoomShare(newRoom.id, share.shareType, share.shareWith, share.permission);
|
||||
}));
|
||||
|
||||
updateRoom({
|
||||
...room,
|
||||
uid: newRoom.uid,
|
||||
id: newRoom.id,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const maxRooms = restriction?.maxRooms || 0;
|
||||
const quota = maxRooms < 0 ? t('bbb', 'unlimited') : rooms.filter(room => room.userId === OC.currentUser).length + ' / ' + maxRooms;
|
||||
|
||||
|
@ -151,6 +175,7 @@ const App: React.FC<Props> = () => {
|
|||
</th>
|
||||
<th />
|
||||
<th />
|
||||
<th />
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
|
|
@ -11,6 +11,7 @@ type Props = {
|
|||
restriction?: Restriction;
|
||||
updateRoom: (room: Room) => Promise<void>;
|
||||
deleteRoom: (id: number) => void;
|
||||
cloneRoom: (room: Room) => void;
|
||||
}
|
||||
|
||||
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} />;
|
||||
}
|
||||
|
||||
function cloneRow() {
|
||||
props.cloneRoom({...props.room});
|
||||
}
|
||||
|
||||
const avatarUrl = OC.generateUrl('/avatar/' + encodeURIComponent(room.userId) + '/' + 24, {
|
||||
user: room.userId,
|
||||
size: 24,
|
||||
|
@ -225,6 +230,11 @@ const RoomRow: React.FC<Props> = (props) => {
|
|||
<td className="edit icon-col">
|
||||
<EditRoom room={props.room} restriction={props.restriction} updateProperty={updateRoom} />
|
||||
</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">
|
||||
<button className="action-item" onClick={deleteRow as any} title={t('bbb', 'Delete')}>
|
||||
<span className="icon icon-delete icon-visible"></span>
|
||||
|
|
Loading…
Reference in New Issue