Skip to content

Commit b039813

Browse files
committed
Add fullscreen-view
1 parent f7db8dc commit b039813

File tree

4 files changed

+44
-2
lines changed

4 files changed

+44
-2
lines changed

xp-archive/client/contentView/ContentView.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import style from './ContentView.module.css';
1212
const getDisplayComponent = (viewVariant: ViewVariant, data?: ContentServiceResponse | null) => {
1313
if (!data) return null;
1414
const components: Record<ViewVariant, React.ReactElement> = {
15-
html: <HtmlView html={data.html} />,
15+
html: <HtmlView html={data.html} versionId={data.json._id} locale={data.json.language} />,
1616
filepreview: <FilePreviewWrapper content={data.json} />,
1717
pdf: <PdfExport versions={data.versions} />,
1818
json: <ContentJsonView json={data.json} />,

xp-archive/client/contentView/htmlView/HtmlView.module.css

+6
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@
99
width: 100%;
1010
border: none;
1111
}
12+
13+
.fullscreenButton {
14+
position: absolute;
15+
bottom: 0.25rem;
16+
right: 1.5rem;
17+
}
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,37 @@
11
import React from 'react';
22
import style from './HtmlView.module.css';
3+
import { ExpandIcon } from '@navikt/aksel-icons';
4+
import { xpArchiveConfig } from '@common/shared/siteConfigs';
5+
import { Button } from '@navikt/ds-react';
36

47
type Props = {
58
html: string | undefined;
9+
versionId: string;
10+
locale: string;
611
};
712

8-
export const HtmlView = ({ html }: Props) => {
13+
export const HtmlView = ({ html, versionId, locale }: Props) => {
914
if (!html) {
1015
return <div>Ingenting å forhåndsvise</div>;
1116
}
17+
18+
const fullscreenPath = `${xpArchiveConfig.basePath}/html/${versionId}/${locale || ''}`;
19+
1220
return (
1321
<div className={style.wrapper}>
1422
<iframe title={'HTML-visning'} srcDoc={html} className={style.iframe}></iframe>;
23+
<Button
24+
as={'a'}
25+
href={fullscreenPath}
26+
className={style.fullscreenButton}
27+
icon={<ExpandIcon />}
28+
onClick={(e) => {
29+
e.preventDefault();
30+
window.open(fullscreenPath, '_blank');
31+
}}
32+
>
33+
{'Åpne i nytt vindu'}
34+
</Button>
1535
</div>
1636
);
1737
};

xp-archive/server/src/routing/site.ts

+16
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,22 @@ export const setupSite = async (router: Router) => {
3131
const attachmentService = new AttachmentService();
3232
const pdfService = new PdfService({ browser, contentService });
3333

34+
router.get('/html/:versionKey/:locale?', async (req, res, next) => {
35+
const { versionKey, locale } = req.params;
36+
37+
const version = await contentService.fetchContent(versionKey, locale || 'no');
38+
if (!version) {
39+
return next();
40+
}
41+
42+
if (!version.html) {
43+
return res
44+
.status(406)
45+
.send(`Content with version key ${versionKey} does not have html content`);
46+
}
47+
48+
return res.send(version.html);
49+
});
3450
router.get('/api/content', contentService.getContentHandler);
3551
router.get('/api/contentTree', contentTreeService.getContentTreeHandler);
3652
router.get('/api/contentIcon', contentIconService.getContentIconHandler);

0 commit comments

Comments
 (0)