Skip to content

Commit

Permalink
IFrame examples
Browse files Browse the repository at this point in the history
  • Loading branch information
tariqksoliman committed Nov 16, 2022
1 parent 6fd57ec commit 1370cb0
Show file tree
Hide file tree
Showing 15 changed files with 30,166 additions and 124 deletions.
7 changes: 6 additions & 1 deletion API/templates/config_template.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ module.exports = {
look: {
pagename: "MMGIS",
minimalist: false,
topbar: true,
toolbar: true,
scalebar: true,
coordinates: true,
zoomcontrol: false,
graticule: false,
miscellaneous: true,
bodycolor: "",
topbarcolor: "",
toolbarcolor: "",
Expand All @@ -39,7 +44,7 @@ module.exports = {
helpurl: "",
},
panels: ["viewer", "map", "globe"],
time:["enabled"],
time: ["enabled"],
tools: [
{
name: "Layers",
Expand Down
28 changes: 25 additions & 3 deletions config/js/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -499,15 +499,30 @@ function initialize() {
$("#tab_look #look_pagename").val(cData.look.pagename);
}
$("#tab_look input").prop("checked", false);
if (cData.look && cData.look.minimalist == true) {
if (cData.look && cData.look.minimalist != true) {
$("#tab_look #look_minimalist").prop("checked", true);
}
if (cData.look && cData.look.zoomcontrol == true) {
if (cData.look && cData.look.topbar != true) {
$("#tab_look #look_topbar").prop("checked", true);
}
if (cData.look && cData.look.toolbar != true) {
$("#tab_look #look_toolbar").prop("checked", true);
}
if (cData.look && cData.look.scalebar != true) {
$("#tab_look #look_scalebar").prop("checked", true);
}
if (cData.look && cData.look.coordinates != true) {
$("#tab_look #look_coordinates").prop("checked", true);
}
if (cData.look && cData.look.zoomcontrol != true) {
$("#tab_look #look_zoomcontrol").prop("checked", true);
}
if (cData.look && cData.look.graticule == true) {
if (cData.look && cData.look.graticule != true) {
$("#tab_look #look_graticule").prop("checked", true);
}
if (cData.look && cData.look.miscellaneous != true) {
$("#tab_look #look_miscellaneous").prop("checked", true);
}

//look colors
$("#tab_look #look_primarycolor").val(
Expand Down Expand Up @@ -1987,8 +2002,15 @@ function save() {
//Look
json.look["pagename"] = $("#tab_look #look_pagename").val();
json.look["minimalist"] = $("#tab_look #look_minimalist").prop("checked");
json.look["topbar"] = $("#tab_look #look_topbar").prop("checked");
json.look["toolbar"] = $("#tab_look #look_toolbar").prop("checked");
json.look["scalebar"] = $("#tab_look #look_scalebar").prop("checked");
json.look["coordinates"] = $("#tab_look #look_coordinates").prop("checked");
json.look["zoomcontrol"] = $("#tab_look #look_zoomcontrol").prop("checked");
json.look["graticule"] = $("#tab_look #look_graticule").prop("checked");
json.look["miscellaneous"] = $("#tab_look #look_miscellaneous").prop(
"checked"
);
//look colors
json.look["primarycolor"] = $("#tab_look #look_primarycolor").val();
json.look["secondarycolor"] = $("#tab_look #look_secondarycolor").val();
Expand Down
30 changes: 26 additions & 4 deletions docs/pages/Configure/Tabs/Look/Look_Tab.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,40 @@ grand_parent: Configure

Configure the look of MMGIS's UI for the mission

### Rebranding

#### Page Name

Sets the browser tab title and, if the UI is not minimalist, sets the title in the top bar. Defaults to `MMGIS`

#### Minimalist UI
### User Interface

Toggles user interface elements on or off.

#### Minimalist UI (DISABLED)

If checked, hides the top bar. The top bar contains descriptive elements and interactions as well as a search bar. Checking this may cause other setups to be irrelevant.

#### Zoom Control
#### Tob Bar

#### Tool Bar

#### Scale Bar

#### Coordinates

#### Map Zoom Control

If checked, adds `+` and `-` zoom buttons to the top right of the Map.

#### Graticule
#### Map Graticule

Displays a grid of longitudinal and latitudinal lines over the Map.

#### Miscellaneous

### Colors

#### Body Color

Sets the background color of MMGIS to a [CSS color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value). Might have little impact.
Expand All @@ -46,7 +64,9 @@ Sets the background of the Map to a [CSS color](https://developer.mozilla.org/en

Sets the highlight of active vector features to a [CSS color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value).

#### Swap
### Secondary Tools

#### Swap (DISABLED)

If checked, adds a button in the tool bar that enables users to switch seamlessly between missions. This functionality may be buggy and break things depending on the missions switched to and from. It's recommended to return to the landing page to switch between missions or to extensively test swapping between your missions before enabling Swap.

Expand All @@ -62,6 +82,8 @@ If checked, adds a button in the tool bar that enables users to screenshot the c

If checked, adds a button in the tool bar that enables users to quickly enter and exit fullscreen mode.

### User Help

#### Help

If checked, adds a button in the tool bar that links to help documentation. That link can be specified below in Help URL.
Expand Down
6 changes: 5 additions & 1 deletion docs/pages/Setup/ENVs/ENVs.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ Potentially logs a bunch of extra stuff for development purposes | bool | defaul

#### `FRAME_ANCESTORS=`

Sets the `Content-Security-Policy: frame-ancestors` header to allow the embedding of MMGIS in the specified external sites | string[] | default `null`
Sets the `Content-Security-Policy: frame-ancestors` header to allow the embedding of MMGIS in the specified external sites | string[] | default `null` | ex. FRAME_ANCESTORS='["http://localhost:8888"]'

#### `FRAME_SRC=`

Sets the `Content-Security-Policy: frame-src` header to allow the embedding iframes from external origins into MMGIS | string[] | default `null` | ex. FRAME_SRC='["http://localhost:8888"]'

#### `PUBLIC_URL=`

Expand Down
217 changes: 217 additions & 0 deletions examples/ReactWrappedIframe/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>React Wrapped iframe</title>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width,user-scalable=no,minimum-scale=1,maximum-scale=1"
/>
<meta name="theme-color" content="#1d1f20" />
<meta
name="description"
content="A web-based mapping and localization solution for science operation on planetary missions."
/>
<script src="../lib/react.development.js"></script>
<script src="../lib/react-dom.development.js"></script>
<script src="../lib/babel.min.js"></script>
<style>
body,
html {
background: #1d1f20;
overflow: hidden;
margin: 0;
padding: 0;
width: 100%;
height: 100%;
box-sizing: border-box;
font-family: sans-serif;
}
iframe {
width: 100%;
height: 100%;
border: none;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
}
ul li {
width: 40px;
text-align: center;
padding: 10px 0px;
}
p {
font-size: 14px;
}
#root {
width: 100%;
height: 100%;
}
.App {
width: 100%;
height: 100%;
display: flex;
flex-flow: column;
}
.TopBar {
width: 100%;
height: 40px;
background: white;
font-weight: bold;
padding: 10px;
box-sizing: border-box;
border-bottom: 1px solid #ddd;
}
.main {
display: flex;
height: calc(100vh - 40px);
width: 100%;
}
.Toolbar {
height: 100%;
width: 40px;
background: white;
box-sizing: border-box;
border-right: 1px solid #ddd;
}
.Panel {
height: 100%;
background: #f5f5f5;
padding: 10px;
box-sizing: border-box;
overflow-y: auto;
}
.MMGIS {
flex: 1;
}
.layer {
height: 10px;
margin: 2px 0px;
padding-left: 6px;
line-height: 12px;
cursor: pointer;
width: 220px;
text-align: left;
}
.layer.on {
border-left: 12px solid green;
}
.layer.off {
border-left: 12px solid red;
}
</style>
</head>
<body>
<div id="root"></div>

<!--
<div id="main">
<div id="top"></div>
<div id="middle">
<div id="left"></div>
<div id="center">
<iframe src="http://localhost:8888" title="MMGIS"></iframe>
</div>
<div id="right"></div>
</div>
<div id="bottom"></div>
</div>
-->
</body>
<footer>
<script type="text/babel">
function TopBar() {
return <div className="TopBar">React Wrapped Iframe</div>;
}

function Toolbar() {
return (
<div className="Toolbar">
<ul>
<li>A</li>
<li>B</li>
<li>C</li>
<li>D</li>
</ul>
</div>
);
}
function Panel(props) {
const { width } = props;
return (
<div className="Panel" style={{ width: `${width || 250}px` }}>
{props.children}
</div>
);
}
function MMGIS() {
React.useEffect(() => {
const MMGISIframe = document.getElementById("MMGISIframe");
MMGISIframe.addEventListener("load", function () {
window.mmgisAPI = this.contentWindow.mmgisAPI;
});
MMGISIframe.src = "http://localhost:8888?mission=MSL";
}, []);
return (
<div className="MMGIS">
<iframe id="MMGISIframe"></iframe>
</div>
);
}

function App() {
const [availableLayers, setAvailableLayers] = React.useState(null);
return (
<div className="App">
<TopBar />
<div className="main">
<Toolbar />
<Panel width={300}>
{availableLayers == null && (
<button
onClick={() => {
setAvailableLayers(mmgisAPI.getVisibleLayers());
}}
>
Show Layers
</button>
)}
<ul>
{availableLayers &&
Object.keys(availableLayers).map((layerName, i) => (
<li
key={i}
className={`layer ${
availableLayers[layerName] ? "on" : "off"
}`}
onClick={async () => {
await mmgisAPI.toggleLayer(layerName);
setAvailableLayers(mmgisAPI.getVisibleLayers());
}}
>
{layerName}
</li>
))}
</ul>
</Panel>
<MMGIS />
<Panel width={400}>
<h3>How to run this example:</h3>
<p>Add .env: FRAME_ANCESTORS='["http://localhost:8888"]'</p>
<p>Add .env: FRAME_SRC='["http://localhost:8888"]'</p>
<p>`npm run build`</p>
<p>`npm run start:prod:with_examples`</p>
<p>
Go to: localhost:8888/examples/ReactWrappedIframe/index.html
</p>
</Panel>
</div>
</div>
);
}
ReactDOM.render(<App />, document.getElementById("root"));
</script>
</footer>
</html>
Loading

0 comments on commit 1370cb0

Please sign in to comment.