diff --git a/.eslintrc.js b/.eslintrc.js index 87d9e7e..712bbc2 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -28,5 +28,6 @@ module.exports = { 'comma-dangle': ['error', 'always-multiline'], 'array-bracket-newline': ['error', 'consistent'], 'quote-props': ['error', 'as-needed'], + 'indent': ['warn', 'tab'], }, } \ No newline at end of file diff --git a/ts/Manager/App.tsx b/ts/Manager/App.tsx index 9e7fac0..ef60dd7 100644 --- a/ts/Manager/App.tsx +++ b/ts/Manager/App.tsx @@ -12,20 +12,20 @@ enum SortOrder { DESC = -1, ASC = 1 }; function sortRooms(key: SortKey, orderBy: SortOrder) { return (a: Room, b: Room) => { switch (key) { - case 'name': - case 'welcome': - return a[key].localeCompare(b[key]) * orderBy; - case 'maxParticipants': - return (a.maxParticipants - b.maxParticipants) * orderBy; - case 'record': - if (a.record && !b.record) { - return 1 * orderBy; - } - if (!a.record && b.record) { - return -1 * orderBy; - } + case 'name': + case 'welcome': + return a[key].localeCompare(b[key]) * orderBy; + case 'maxParticipants': + return (a.maxParticipants - b.maxParticipants) * orderBy; + case 'record': + if (a.record && !b.record) { + return 1 * orderBy; + } + if (!a.record && b.record) { + return -1 * orderBy; + } - return 0; + return 0; } } } diff --git a/ts/Manager/NewRoomForm.tsx b/ts/Manager/NewRoomForm.tsx index 7fd64af..2dd1ec5 100644 --- a/ts/Manager/NewRoomForm.tsx +++ b/ts/Manager/NewRoomForm.tsx @@ -5,27 +5,27 @@ type Props = { } const NewRoomForm: React.FC = (props) => { - const [name, setName] = useState(''); + const [name, setName] = useState(''); - function addRoom(ev: React.FormEvent) { - ev.preventDefault(); + function addRoom(ev: React.FormEvent) { + ev.preventDefault(); - props.addRoom(name); + props.addRoom(name); - setName(''); + setName(''); } - return ( -
- {setName(event.target.value)}} /> + return ( + + {setName(event.target.value)}} /> - -
- ) + + + ) } export default NewRoomForm; \ No newline at end of file diff --git a/ts/Manager/RoomRow.tsx b/ts/Manager/RoomRow.tsx index bef810e..198ab8b 100644 --- a/ts/Manager/RoomRow.tsx +++ b/ts/Manager/RoomRow.tsx @@ -19,87 +19,87 @@ type EditableValueProps = { } const EditableValue: React.FC = ({ setValue, setActive, active, field, value, type }) => { - if (active === field) { - return setValue(field, type === 'number' ? parseInt(value):value)} - onClick={event => event.stopPropagation()} - initialValue={value} - type={type} - /> - } + if (active === field) { + return setValue(field, type === 'number' ? parseInt(value):value)} + onClick={event => event.stopPropagation()} + initialValue={value} + type={type} + /> + } - function onClick(ev) { - ev.stopPropagation(); + function onClick(ev) { + ev.stopPropagation(); - setActive(field); - } + setActive(field); + } - return {value}; + return {value}; } const RoomRow: React.FC = (props) => { - const [activeEdit, setActiveEdit] = useState(''); - const room = props.room; + const [activeEdit, setActiveEdit] = useState(''); + const room = props.room; - function updateRoom(key: string, value: string|boolean|number) { - props.updateRoom({ - ...props.room, - [key]: value, - }); + function updateRoom(key: string, value: string|boolean|number) { + props.updateRoom({ + ...props.room, + [key]: value, + }); - setActiveEdit(''); - } + setActiveEdit(''); + } - function deleteRow(ev: MouseEvent) { - ev.preventDefault(); + function deleteRow(ev: MouseEvent) { + ev.preventDefault(); - OC.dialogs.confirm( - t('bbb', 'Are you sure you want to delete "{name}"? This operation can not be undone', { name: room.name }), - t('bbb', 'Delete "{name}"?', { name: room.name }), - confirmed => { - if (confirmed) { - props.deleteRoom(room.id); - } - }, - true - ); - } + OC.dialogs.confirm( + t('bbb', 'Are you sure you want to delete "{name}"? This operation can not be undone', { name: room.name }), + t('bbb', 'Delete "{name}"?', { name: room.name }), + confirmed => { + if (confirmed) { + props.deleteRoom(room.id); + } + }, + true + ); + } - function edit(field: string, type: 'text' | 'number' = 'text'){ - return - } + function edit(field: string, type: 'text' | 'number' = 'text'){ + return + } - return ( - - - - - - - - - - - {edit('name')} - - - {edit('welcome')} - - - {edit('maxParticipants', 'number')} - - - updateRoom('record', event.target.checked)} /> - - - - - - - ) + return ( + + + + + + + + + + + {edit('name')} + + + {edit('welcome')} + + + {edit('maxParticipants', 'number')} + + + updateRoom('record', event.target.checked)} /> + + + + + + + ) } export default RoomRow; \ No newline at end of file diff --git a/ts/Manager/SortArrow.tsx b/ts/Manager/SortArrow.tsx index 2865fbe..2a2c4f5 100644 --- a/ts/Manager/SortArrow.tsx +++ b/ts/Manager/SortArrow.tsx @@ -7,11 +7,11 @@ export interface SortArrowProps { } export function SortArrow({name, value, direction}: SortArrowProps) { - if (name === value) { - return ( - {direction < 0 ? '▼' : '▲'} - ); - } else { - return ; - } + if (name === value) { + return ( + {direction < 0 ? '▼' : '▲'} + ); + } else { + return ; + } } \ No newline at end of file diff --git a/ts/admin.ts b/ts/admin.ts index 144bdb5..0418e87 100644 --- a/ts/admin.ts +++ b/ts/admin.ts @@ -1,10 +1,10 @@ declare const OCP: any; $(() => { - $('#bbb-settings form').submit(function (ev) { - ev.preventDefault(); + $('#bbb-settings form').submit(function (ev) { + ev.preventDefault(); - OCP.AppConfig.setValue('bbb', 'api.url', this['api.url'].value); - OCP.AppConfig.setValue('bbb', 'api.secret', this['api.secret'].value); - }) + OCP.AppConfig.setValue('bbb', 'api.url', this['api.url'].value); + OCP.AppConfig.setValue('bbb', 'api.secret', this['api.secret'].value); + }) }); \ No newline at end of file diff --git a/ts/filelist.ts b/ts/filelist.ts index 19bf4f1..d3e4889 100644 --- a/ts/filelist.ts +++ b/ts/filelist.ts @@ -5,97 +5,97 @@ import { Room } from './Manager/Api'; declare const OCA: any; class BigBlueButton { - public async getRooms(): Promise { - const response = await axios.get(OC.generateUrl('/apps/bbb/rooms')) + public async getRooms(): Promise { + const response = await axios.get(OC.generateUrl('/apps/bbb/rooms')) - return response.data - } + return response.data + } } $(() => { - if (!OCA?.Files?.fileActions) { - return; - } + if (!OCA?.Files?.fileActions) { + return; + } - const mimeTypes = [ - 'application/pdf', - 'application/vnd.oasis.opendocument.presentation', - 'application/vnd.oasis.opendocument.text', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - 'application/vnd.openxmlformats-officedocument.presentationml.presentation', - 'application/msword', - 'application/vnd.ms-powerpoint', - ]; - const bbb = new BigBlueButton(); + const mimeTypes = [ + 'application/pdf', + 'application/vnd.oasis.opendocument.presentation', + 'application/vnd.oasis.opendocument.text', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'application/msword', + 'application/vnd.ms-powerpoint', + ]; + const bbb = new BigBlueButton() - bbb.getRooms().then(rooms => { - rooms.forEach(room => { - mimeTypes.forEach(mime => registerFileAction(mime, room.id, room.uid, room.name)); - }) - }); + bbb.getRooms().then(rooms => { + rooms.forEach(room => { + mimeTypes.forEach(mime => registerFileAction(mime, room.id, room.uid, room.name)); + }) + }); - function registerFileAction(mime, id, uid, name) { - OCA.Files.fileActions.registerAction({ - name: 'bbb-' + id, - displayName: name, - mime, - permissions: OC.PERMISSION_SHARE, - icon: OC.imagePath('bbb', 'app-dark.svg'), - actionHandler: (fileName, context) => { - share(context.fileInfoModel.getFullPath(), fileName, uid); - }, - }); - } + function registerFileAction(mime, id, uid, name) { + OCA.Files.fileActions.registerAction({ + name: 'bbb-' + id, + displayName: name, + mime, + permissions: OC.PERMISSION_SHARE, + icon: OC.imagePath('bbb', 'app-dark.svg'), + actionHandler: (fileName, context) => { + share(context.fileInfoModel.getFullPath(), fileName, uid); + }, + }); + } - async function share(path: string, filename: string, roomUid) { - const id = await createShare(path); - const shareUrl = await configureShare(id); - const joinUrl = generateUrl('/apps/bbb/b/{uid}?u={url}&filename={filename}', { - uid: roomUid, - url: shareUrl + '/download', - filename, - }); + async function share(path: string, filename: string, roomUid) { + const id = await createShare(path); + const shareUrl = await configureShare(id); + const joinUrl = generateUrl('/apps/bbb/b/{uid}?u={url}&filename={filename}', { + uid: roomUid, + url: shareUrl + '/download', + filename, + }); - window.open(joinUrl, '_blank', 'noopener,noreferrer'); - } + window.open(joinUrl, '_blank', 'noopener,noreferrer'); + } - async function createShare(path: string): Promise { - const url = generateOcsUrl('apps/files_sharing/api/v1', 2) + 'shares'; + async function createShare(path: string): Promise { + const url = generateOcsUrl('apps/files_sharing/api/v1', 2) + 'shares'; - const createResponse = await axios.post(url, { - path, - shareType: OC.Share.SHARE_TYPE_LINK, - note: 'foobar foobar foobar', - expireDate: '2020-07-01', - }); + const createResponse = await axios.post(url, { + path, + shareType: OC.Share.SHARE_TYPE_LINK, + note: 'foobar foobar foobar', + expireDate: '2020-07-01', + }); - const { meta, data } = createResponse.data.ocs; + const { meta, data } = createResponse.data.ocs; - if (meta.statuscode !== 200) { - throw new Error('Failed to create share'); - } + if (meta.statuscode !== 200) { + throw new Error('Failed to create share'); + } - return data.id; - } + return data.id; + } - async function configureShare(id: number): Promise { - const url = generateOcsUrl('apps/files_sharing/api/v1', 2) + 'shares/' + id; + async function configureShare(id: number): Promise { + const url = generateOcsUrl('apps/files_sharing/api/v1', 2) + 'shares/' + id; - const tomorrow = new Date(); - tomorrow.setDate(new Date().getDate() + 1); + const tomorrow = new Date(); + tomorrow.setDate(new Date().getDate() + 1); - const updateResponse = await axios.put(url, { - expireDate: tomorrow.toISOString().split('T')[0], - note: 'BigBlueButton', - }); + const updateResponse = await axios.put(url, { + expireDate: tomorrow.toISOString().split('T')[0], + note: 'BigBlueButton', + }); - const { meta, data } = updateResponse.data.ocs; + const { meta, data } = updateResponse.data.ocs; - if (meta.statuscode !== 200) { - throw new Error('Failed to configure share'); - } + if (meta.statuscode !== 200) { + throw new Error('Failed to configure share'); + } - return data.url; - } + return data.url; + } }); \ No newline at end of file