Build failure fixes
All checks were successful
Automated Container Build / build-and-push (push) Successful in 1m21s
All checks were successful
Automated Container Build / build-and-push (push) Successful in 1m21s
This commit is contained in:
parent
d80e31e7f5
commit
6a754808b5
3 changed files with 16 additions and 6 deletions
|
|
@ -26,8 +26,9 @@ export default function OfficeHome({ type, onFileSelect, onCreateBlank }: Office
|
|||
useEffect(() => {
|
||||
// Fetch all files from root directory (as a simple way to find recent files of this type)
|
||||
// Or we could use a search endpoint. For now we will fetch the root directory and filter.
|
||||
api.listFiles('.')
|
||||
.then(files => {
|
||||
api.listDirectory('.')
|
||||
.then(data => {
|
||||
const files: FileItem[] = data.files || [];
|
||||
const ext = type === 'docs' ? '.docx' : '.pptx';
|
||||
const filtered = files
|
||||
.filter(f => !f.is_dir && f.name.endsWith(ext) && !f.is_trashed)
|
||||
|
|
@ -44,8 +45,8 @@ export default function OfficeHome({ type, onFileSelect, onCreateBlank }: Office
|
|||
|
||||
const handleCreateBlank = async () => {
|
||||
try {
|
||||
const res = await api.client.post('/onlyoffice/create', { type: type === 'docs' ? 'word' : 'slide' });
|
||||
const { path, name } = res.data;
|
||||
const res = await api.createOnlyOfficeFile(type === 'docs' ? 'word' : 'slide');
|
||||
const { path, name } = res;
|
||||
|
||||
const newFile: FileItem = {
|
||||
name,
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ export default function OnlyOfficeEditor({ file, type, onClose }: OnlyOfficeEdit
|
|||
|
||||
useEffect(() => {
|
||||
// We need a short-lived download token to pass to the Document Server
|
||||
api.client.get('/auth/download-token')
|
||||
.then(res => setDownloadToken(res.data.token))
|
||||
api.createDownloadToken()
|
||||
.then((token: string) => setDownloadToken(token))
|
||||
.catch(console.error);
|
||||
}, [file.path]);
|
||||
|
||||
|
|
|
|||
|
|
@ -468,6 +468,15 @@ class ApiClient {
|
|||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
// --- OnlyOffice ---
|
||||
async createOnlyOfficeFile(type: 'word' | 'slide') {
|
||||
const res = await this.request('/api/onlyoffice/create', {
|
||||
method: 'POST',
|
||||
body: { type },
|
||||
});
|
||||
return res.json();
|
||||
}
|
||||
}
|
||||
|
||||
export const api = new ApiClient();
|
||||
|
|
|
|||
Reference in a new issue