2020-06-30 11:47:21 -07:00
|
|
|
import "bootstrap/dist/css/bootstrap.css";
|
|
|
|
import { initializeIcons } from "office-ui-fabric-react/lib/Icons";
|
2020-05-25 21:30:55 -05:00
|
|
|
import React from "react";
|
|
|
|
import * as ReactDOM from "react-dom";
|
2020-06-30 11:47:21 -07:00
|
|
|
import { initializeConfiguration } from "../Config";
|
|
|
|
import {
|
|
|
|
NotebookViewerComponent,
|
|
|
|
NotebookViewerComponentProps
|
|
|
|
} from "../Explorer/Controls/NotebookViewer/NotebookViewerComponent";
|
|
|
|
import { IGalleryItem, JunoClient } from "../Juno/JunoClient";
|
|
|
|
import * as GalleryUtils from "../Utils/GalleryUtils";
|
2020-05-25 21:30:55 -05:00
|
|
|
|
|
|
|
const onInit = async () => {
|
2020-06-30 11:47:21 -07:00
|
|
|
initializeIcons();
|
|
|
|
await initializeConfiguration();
|
|
|
|
const galleryViewerProps = GalleryUtils.getGalleryViewerProps(window);
|
|
|
|
const notebookViewerProps = GalleryUtils.getNotebookViewerProps(window);
|
|
|
|
const backNavigationText = galleryViewerProps.selectedTab && GalleryUtils.getTabTitle(galleryViewerProps.selectedTab);
|
2020-05-25 21:30:55 -05:00
|
|
|
|
2020-06-30 11:47:21 -07:00
|
|
|
const notebookUrl = decodeURIComponent(notebookViewerProps.notebookUrl);
|
|
|
|
render(notebookUrl, backNavigationText);
|
|
|
|
|
|
|
|
const galleryItemId = notebookViewerProps.galleryItemId;
|
|
|
|
if (galleryItemId) {
|
|
|
|
const junoClient = new JunoClient();
|
|
|
|
const notebook = await junoClient.getNotebook(galleryItemId);
|
|
|
|
render(notebookUrl, backNavigationText, notebook.data);
|
2020-05-25 21:30:55 -05:00
|
|
|
}
|
2020-06-30 11:47:21 -07:00
|
|
|
};
|
2020-05-25 21:30:55 -05:00
|
|
|
|
2020-06-30 11:47:21 -07:00
|
|
|
const render = (notebookUrl: string, backNavigationText: string, galleryItem?: IGalleryItem) => {
|
|
|
|
const props: NotebookViewerComponentProps = {
|
|
|
|
junoClient: galleryItem ? new JunoClient() : undefined,
|
|
|
|
notebookUrl,
|
|
|
|
galleryItem,
|
|
|
|
backNavigationText,
|
|
|
|
onBackClick: undefined,
|
|
|
|
onTagClick: undefined
|
|
|
|
};
|
2020-06-05 04:04:15 +02:00
|
|
|
|
2020-06-30 11:47:21 -07:00
|
|
|
ReactDOM.render(<NotebookViewerComponent {...props} />, document.getElementById("notebookContent"));
|
2020-05-25 21:30:55 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
// Entry point
|
|
|
|
window.addEventListener("load", onInit);
|