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-07-08 12:40:47 -07:00
|
|
|
import { GalleryHeaderComponent } from "../Explorer/Controls/Header/GalleryHeaderComponent";
|
2020-07-10 14:23:53 -07:00
|
|
|
import { FileSystemUtil } from "../Explorer/Notebook/FileSystemUtil";
|
2020-05-25 21:30:55 -05:00
|
|
|
|
|
|
|
const onInit = async () => {
|
2020-06-30 11:47:21 -07:00
|
|
|
initializeIcons();
|
|
|
|
await initializeConfiguration();
|
2020-07-06 12:10:26 -07:00
|
|
|
const galleryViewerProps = GalleryUtils.getGalleryViewerProps(window.location.search);
|
|
|
|
const notebookViewerProps = GalleryUtils.getNotebookViewerProps(window.location.search);
|
2020-06-30 11:47:21 -07:00
|
|
|
const backNavigationText = galleryViewerProps.selectedTab && GalleryUtils.getTabTitle(galleryViewerProps.selectedTab);
|
2020-07-10 14:23:53 -07:00
|
|
|
const hideInputs = notebookViewerProps.hideInputs;
|
2020-05-25 21:30:55 -05:00
|
|
|
|
2020-06-30 11:47:21 -07:00
|
|
|
const notebookUrl = decodeURIComponent(notebookViewerProps.notebookUrl);
|
2020-07-10 14:23:53 -07:00
|
|
|
render(notebookUrl, backNavigationText, hideInputs);
|
2020-06-30 11:47:21 -07:00
|
|
|
|
|
|
|
const galleryItemId = notebookViewerProps.galleryItemId;
|
|
|
|
if (galleryItemId) {
|
|
|
|
const junoClient = new JunoClient();
|
|
|
|
const notebook = await junoClient.getNotebook(galleryItemId);
|
2020-07-10 14:23:53 -07:00
|
|
|
render(notebookUrl, backNavigationText, hideInputs, 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-07-10 14:23:53 -07:00
|
|
|
const render = (notebookUrl: string, backNavigationText: string, hideInputs: boolean, galleryItem?: IGalleryItem) => {
|
2020-06-30 11:47:21 -07:00
|
|
|
const props: NotebookViewerComponentProps = {
|
|
|
|
junoClient: galleryItem ? new JunoClient() : undefined,
|
|
|
|
notebookUrl,
|
|
|
|
galleryItem,
|
|
|
|
backNavigationText,
|
2020-07-10 14:23:53 -07:00
|
|
|
hideInputs,
|
2020-06-30 11:47:21 -07:00
|
|
|
onBackClick: undefined,
|
|
|
|
onTagClick: undefined
|
|
|
|
};
|
2020-06-05 04:04:15 +02:00
|
|
|
|
2020-07-10 14:23:53 -07:00
|
|
|
if (galleryItem) {
|
|
|
|
document.title = FileSystemUtil.stripExtension(galleryItem.name, "ipynb");
|
|
|
|
}
|
|
|
|
|
2020-07-08 12:40:47 -07:00
|
|
|
const element = (
|
|
|
|
<>
|
|
|
|
<header>
|
|
|
|
<GalleryHeaderComponent />
|
|
|
|
</header>
|
|
|
|
<div style={{ marginLeft: 120, marginRight: 120 }}>
|
|
|
|
<NotebookViewerComponent {...props} />
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
|
|
|
|
ReactDOM.render(element, document.getElementById("notebookContent"));
|
2020-05-25 21:30:55 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
// Entry point
|
|
|
|
window.addEventListener("load", onInit);
|