Merge pull request #14585 from danielpetri1/pads-shared-notes-upload
feat: Automatic upload of the shared notes as presentation
This commit is contained in:
commit
23ee038387
@ -4,6 +4,7 @@ import { defineMessages, injectIntl } from 'react-intl';
|
||||
import injectWbResizeEvent from '/imports/ui/components/presentation/resize-wrapper/component';
|
||||
import Service from '/imports/ui/components/notes/service';
|
||||
import PadContainer from '/imports/ui/components/pads/container';
|
||||
import ConverterButtonContainer from './converter-button/container';
|
||||
import Styled from './styles';
|
||||
import { PANELS, ACTIONS } from '../layout/enums';
|
||||
import browserInfo from '/imports/utils/browserInfo';
|
||||
@ -60,6 +61,7 @@ const Notes = ({
|
||||
icon={isRTL ? 'right_arrow' : 'left_arrow'}
|
||||
/>
|
||||
</Styled.Title>
|
||||
<ConverterButtonContainer />
|
||||
</Styled.Header>
|
||||
<PadContainer
|
||||
externalId={Service.ID}
|
||||
|
@ -0,0 +1,43 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import _ from 'lodash';
|
||||
import { defineMessages, injectIntl } from 'react-intl';
|
||||
import Service from './service';
|
||||
import Styled from './styles';
|
||||
|
||||
const DEBOUNCE_TIMEOUT = 15000;
|
||||
const DEBOUNCE_OPTIONS = {
|
||||
leading: true,
|
||||
trailing: false,
|
||||
};
|
||||
|
||||
const intlMessages = defineMessages({
|
||||
convertAndUploadLabel: {
|
||||
id: 'app.note.converter-button.convertAndUpload',
|
||||
description: 'Export shared notes as a PDF and upload to the main room',
|
||||
},
|
||||
});
|
||||
|
||||
const propTypes = {
|
||||
intl: PropTypes.shape({
|
||||
formatMessage: PropTypes.func.isRequired,
|
||||
}).isRequired,
|
||||
amIPresenter: PropTypes.bool.isRequired,
|
||||
};
|
||||
|
||||
const ConverterButtonComponent = ({
|
||||
intl,
|
||||
amIPresenter,
|
||||
}) => (amIPresenter
|
||||
? (
|
||||
<Styled.ConvertAndUpload
|
||||
onClick={_.debounce(() => Service.convertAndUpload(), DEBOUNCE_TIMEOUT, DEBOUNCE_OPTIONS)}
|
||||
label={intl.formatMessage(intlMessages.convertAndUploadLabel)}
|
||||
icon="upload"
|
||||
/>
|
||||
)
|
||||
: null);
|
||||
|
||||
ConverterButtonComponent.propTypes = propTypes;
|
||||
|
||||
export default injectIntl(ConverterButtonComponent);
|
@ -0,0 +1,14 @@
|
||||
import React, { useContext } from 'react';
|
||||
import ConverterButton from './component';
|
||||
import { UsersContext } from '/imports/ui/components/components-data/users-context/context';
|
||||
import Auth from '/imports/ui/services/auth';
|
||||
|
||||
const ConverterButtonContainer = ({ ...props }) => {
|
||||
const usingUsersContext = useContext(UsersContext);
|
||||
const { users } = usingUsersContext;
|
||||
const amIPresenter = users[Auth.meetingID][Auth.userID].presenter;
|
||||
|
||||
return <ConverterButton {...{ amIPresenter, ...props }} />;
|
||||
};
|
||||
|
||||
export default ConverterButtonContainer;
|
@ -0,0 +1,47 @@
|
||||
import Auth from '/imports/ui/services/auth';
|
||||
import PresentationUploaderService from '/imports/ui/components/presentation/presentation-uploader/service';
|
||||
import PadsService from '/imports/ui/components/pads/service';
|
||||
import NotesService from '/imports/ui/components/notes/service';
|
||||
import { makeCall } from '/imports/ui/services/api';
|
||||
|
||||
const PADS_CONFIG = Meteor.settings.public.pads;
|
||||
const PRESENTATION_CONFIG = Meteor.settings.public.presentation;
|
||||
|
||||
async function convertAndUpload() {
|
||||
const params = PadsService.getParams();
|
||||
|
||||
const padId = await PadsService.getPadId(NotesService.ID);
|
||||
|
||||
const exportUrl = Auth.authenticateURL(`${PADS_CONFIG.url}/p/${padId}/export/pdf?${params}`);
|
||||
const sharedNotesAsPdf = await fetch(exportUrl, { credentials: 'include' });
|
||||
const data = await sharedNotesAsPdf.blob();
|
||||
|
||||
const sharedNotesData = new File([data], 'SharedNotes.pdf', {
|
||||
type: data.type,
|
||||
});
|
||||
|
||||
const formData = new FormData();
|
||||
|
||||
formData.append('presentation_name', 'SharedNotes.pdf');
|
||||
formData.append('Filename', 'SharedNotes.pdf');
|
||||
formData.append('conference', Auth.meetingID);
|
||||
formData.append('room', Auth.meetingID);
|
||||
formData.append('pod_id', 'DEFAULT_PRESENTATION_POD');
|
||||
formData.append('is_downloadable', false);
|
||||
formData.append('current', true);
|
||||
formData.append('fileUpload', sharedNotesData);
|
||||
|
||||
const presentationUploadToken = await PresentationUploaderService.requestPresentationUploadToken('DEFAULT_PRESENTATION_POD', Auth.meetingID, 'SharedNotes.pdf');
|
||||
|
||||
fetch(PRESENTATION_CONFIG.uploadEndpoint.replace('upload', `${presentationUploadToken}/upload`), {
|
||||
body: formData,
|
||||
method: 'post',
|
||||
});
|
||||
|
||||
makeCall('setUsedToken', presentationUploadToken);
|
||||
return null;
|
||||
}
|
||||
|
||||
export default {
|
||||
convertAndUpload,
|
||||
};
|
@ -0,0 +1,42 @@
|
||||
import styled from 'styled-components';
|
||||
import {
|
||||
borderSizeLarge,
|
||||
borderSize,
|
||||
} from '/imports/ui/stylesheets/styled-components/general';
|
||||
import {
|
||||
colorWhite,
|
||||
colorGrayDark,
|
||||
} from '/imports/ui/stylesheets/styled-components/palette';
|
||||
import Button from '/imports/ui/components/common/button/component';
|
||||
|
||||
const ConvertAndUpload = styled(Button)`
|
||||
position: relative;
|
||||
background-color: ${colorWhite};
|
||||
display: block;
|
||||
margin: ${borderSizeLarge};
|
||||
margin-bottom: ${borderSize};
|
||||
padding-left: 0;
|
||||
padding-right: inherit;
|
||||
[dir="rtl"] & {
|
||||
padding-left: inherit;
|
||||
padding-right: 0;
|
||||
}
|
||||
& > i {
|
||||
color: ${colorGrayDark};
|
||||
font-size: smaller;
|
||||
[dir="rtl"] & {
|
||||
-webkit-transform: scale(-1, 1);
|
||||
-moz-transform: scale(-1, 1);
|
||||
-ms-transform: scale(-1, 1);
|
||||
-o-transform: scale(-1, 1);
|
||||
transform: scale(-1, 1);
|
||||
}
|
||||
}
|
||||
&:hover {
|
||||
background-color: ${colorWhite};
|
||||
}
|
||||
`;
|
||||
|
||||
export default {
|
||||
ConvertAndUpload,
|
||||
};
|
@ -94,4 +94,5 @@ export default {
|
||||
getRev,
|
||||
getPadTail,
|
||||
getPadContent,
|
||||
getParams,
|
||||
};
|
||||
|
@ -270,4 +270,5 @@ export default {
|
||||
persistPresentationChanges,
|
||||
dispatchTogglePresentationDownloadable,
|
||||
setPresentation,
|
||||
requestPresentationUploadToken,
|
||||
};
|
||||
|
@ -60,6 +60,7 @@
|
||||
"app.notes.hide": "Notizen verbergen",
|
||||
"app.notes.locked": "Gesperrt",
|
||||
"app.pads.hint": "Drücken Sie Esc, um die Symbolleiste des Pads auszuwählen",
|
||||
"app.note.converter-button.convertAndUpload": "Geteilte Notizen im Präsentations-Bereich laden",
|
||||
"app.user.activityCheck": "Teilnehmeraktivitätsprüfung",
|
||||
"app.user.activityCheck.label": "Prüfen, ob der Teilnehmer noch in der Konferenz ist ({0})",
|
||||
"app.user.activityCheck.check": "Prüfen",
|
||||
|
@ -59,6 +59,7 @@
|
||||
"app.notes.title": "Shared Notes",
|
||||
"app.notes.label": "Notes",
|
||||
"app.notes.hide": "Hide notes",
|
||||
"app.note.converter-button.convertAndUpload": "Move notes to whiteboard",
|
||||
"app.notes.locked": "Locked",
|
||||
"app.pads.hint": "Press Esc to focus the pad's toolbar",
|
||||
"app.user.activityCheck": "User activity check",
|
||||
|
@ -43,6 +43,12 @@
|
||||
"app.captions.menu.cancelLabel": "Cancelar",
|
||||
"app.textInput.sendLabel": "Enviar",
|
||||
"app.title.defaultViewLabel": "Visualização da apresentação padrão",
|
||||
"app.note.title": "Notas compartilhadas",
|
||||
"app.note.label": "Notas",
|
||||
"app.note.hideNoteLabel": "Ocultar notas",
|
||||
"app.note.converter-button.convertAndUpload": "Adicionar notas compartilhadas como apresentação",
|
||||
"app.note.tipLabel": "Pressione Esc para focar na barra de ferramentas do editor",
|
||||
"app.note.locked": "Bloqueado",
|
||||
"app.user.activityCheck": "Verificação de atividade do usuário",
|
||||
"app.user.activityCheck.label": "Verifica se o usuário ainda está na sala ({0})",
|
||||
"app.user.activityCheck.check": "Verificar",
|
||||
|
@ -47,6 +47,12 @@
|
||||
"app.captions.ownership": "接管",
|
||||
"app.textInput.sendLabel": "发送",
|
||||
"app.title.defaultViewLabel": "默认演讲视图",
|
||||
"app.note.title": "分享笔记",
|
||||
"app.note.label": "笔记",
|
||||
"app.note.hideNoteLabel": "隐藏笔记面板",
|
||||
"app.note.converter-button.convertAndUpload": "上传共享笔记",
|
||||
"app.note.tipLabel": "按Esc键定位到编辑器工具栏",
|
||||
"app.note.locked": "已锁定",
|
||||
"app.user.activityCheck": "用户活动检查",
|
||||
"app.user.activityCheck.label": "确认用户是否仍然会议中({0})",
|
||||
"app.user.activityCheck.check": "检查",
|
||||
|
@ -55,6 +55,12 @@
|
||||
"app.captions.speech.error": "由於瀏覽器不相容或一段時間的靜音,語音辨識停止",
|
||||
"app.textInput.sendLabel": "送出",
|
||||
"app.title.defaultViewLabel": "預設簡報版面",
|
||||
"app.note.title": "共享筆記",
|
||||
"app.note.label": "筆記",
|
||||
"app.note.hideNoteLabel": "隱藏筆記",
|
||||
"app.note.converter-button.convertAndUpload": "上傳共享筆記",
|
||||
"app.note.tipLabel": "按下 Esc 鍵以聚焦到編輯器工具列",
|
||||
"app.note.locked": "已鎖定",
|
||||
"app.notes.title": "共享筆記",
|
||||
"app.notes.label": "筆記",
|
||||
"app.notes.hide": "隱藏筆記",
|
||||
|
Loading…
Reference in New Issue
Block a user