feat: add functionality to toggle inbox document source between personal and public scopes
Build and Push Multi-Platform Images / build-and-push (push) Successful in 34s
Build and Push Multi-Platform Images / build-and-push (push) Successful in 34s
This commit is contained in:
@@ -142,4 +142,15 @@ export class InboxController {
|
|||||||
res.setHeader('Cache-Control', 'private, max-age=3600');
|
res.setHeader('Cache-Control', 'private, max-age=3600');
|
||||||
return new StreamableFile(createReadStream(filePath));
|
return new StreamableFile(createReadStream(filePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Post(':id/source')
|
||||||
|
@HttpCode(204)
|
||||||
|
async updateSource(
|
||||||
|
@Param('id') id: string,
|
||||||
|
@Body() body: { source: any },
|
||||||
|
@Request() req: any,
|
||||||
|
): Promise<void> {
|
||||||
|
const preferredUsername: string | null = req.user?.preferredUsername ?? null;
|
||||||
|
await this.inboxService.updateSource(id, body.source, preferredUsername);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
|
BadRequestException,
|
||||||
ConflictException,
|
ConflictException,
|
||||||
Injectable,
|
Injectable,
|
||||||
Logger,
|
Logger,
|
||||||
@@ -190,4 +191,25 @@ export class InboxService {
|
|||||||
}
|
}
|
||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async updateSource(
|
||||||
|
id: string,
|
||||||
|
source: InboxSource,
|
||||||
|
preferredUsername: string | null,
|
||||||
|
): Promise<void> {
|
||||||
|
const { doc } = await this.resolveDocument(id, preferredUsername);
|
||||||
|
|
||||||
|
if (source === 'all') {
|
||||||
|
doc.Source = 'all';
|
||||||
|
doc.OwnerUsername = null;
|
||||||
|
} else {
|
||||||
|
if (!preferredUsername) {
|
||||||
|
throw new BadRequestException('Benutzername erforderlich für persönlichen Scan');
|
||||||
|
}
|
||||||
|
doc.Source = 'user';
|
||||||
|
doc.OwnerUsername = preferredUsername;
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.documentRepo.save(doc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,6 +89,10 @@ export const inboxApi = {
|
|||||||
opts ?? {},
|
opts ?? {},
|
||||||
)
|
)
|
||||||
.then((r) => r.data),
|
.then((r) => r.data),
|
||||||
|
updateSource: (id: string, source: InboxSource) =>
|
||||||
|
api
|
||||||
|
.post(`/api/inbox/${encodeURIComponent(id)}/source`, { source })
|
||||||
|
.then((r) => r.data),
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface PostprocessActionResult {
|
export interface PostprocessActionResult {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import {
|
|||||||
ReloadOutlined,
|
ReloadOutlined,
|
||||||
ScanOutlined,
|
ScanOutlined,
|
||||||
SearchOutlined,
|
SearchOutlined,
|
||||||
|
TeamOutlined,
|
||||||
UserOutlined,
|
UserOutlined,
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import type { ColumnsType } from 'antd/es/table';
|
import type { ColumnsType } from 'antd/es/table';
|
||||||
@@ -168,6 +169,19 @@ export default function InboxPage() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleUpdateSource = async (id: string, current: InboxFile['source']) => {
|
||||||
|
const next = current === 'all' ? 'user' : 'all';
|
||||||
|
try {
|
||||||
|
await inboxApi.updateSource(id, next);
|
||||||
|
message.success(
|
||||||
|
next === 'all' ? 'Zu Öffentlich verschoben' : 'Zu Persönlich verschoben',
|
||||||
|
);
|
||||||
|
await load();
|
||||||
|
} catch {
|
||||||
|
message.error('Verschieben fehlgeschlagen');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const filtered = files.filter((f) =>
|
const filtered = files.filter((f) =>
|
||||||
search ? f.name.toLowerCase().includes(search.toLowerCase()) : true,
|
search ? f.name.toLowerCase().includes(search.toLowerCase()) : true,
|
||||||
);
|
);
|
||||||
@@ -255,6 +269,21 @@ export default function InboxPage() {
|
|||||||
Löschen
|
Löschen
|
||||||
</Button>
|
</Button>
|
||||||
</Popconfirm>
|
</Popconfirm>
|
||||||
|
<Tooltip
|
||||||
|
title={
|
||||||
|
record.source === 'all'
|
||||||
|
? 'In meinen persönlichen Scan-Ordner verschieben'
|
||||||
|
: 'In den gemeinsamen Ordner (Öffentlich) verschieben'
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
type="link"
|
||||||
|
icon={record.source === 'all' ? <UserOutlined /> : <TeamOutlined />}
|
||||||
|
onClick={() => handleUpdateSource(record.id, record.source)}
|
||||||
|
>
|
||||||
|
{record.source === 'all' ? 'Zu Persönlich' : 'Zu Öffentlich'}
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user