Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added homepage to appstats to prevent confusion when running multiple… #171

Merged
merged 1 commit into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "opengis",
"homepage": "/public",
"homepage": "public",
"version": "1.1.4",
"private": true,
"dependencies": {
Expand Down
117 changes: 59 additions & 58 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,73 +16,74 @@ import packageJson from "../package.json";

const enableAnalytics = helpers.getURLParameter("ANALYTICS") !== "off";
if (mainConfig.googleAnalyticsID !== undefined && mainConfig.googleAnalyticsID !== "" && enableAnalytics) {
ReactGA.initialize(mainConfig.googleAnalyticsID);
ReactGA.pageview(window.location.pathname + window.location.search);
ReactGA.initialize(mainConfig.googleAnalyticsID);
ReactGA.pageview(window.location.pathname + window.location.search);
}

class App extends Component {
setControlPreferences() {
const localMapControls = helpers.getItemsFromStorage("Map Control Settings");
setControlPreferences() {
const localMapControls = helpers.getItemsFromStorage("Map Control Settings");

if (localMapControls !== undefined) window.mapControls = localMapControls;
else window.mapControls = mainConfig.controls;
}
componentWillMount() {
window.app = packageJson.name;
window.version = packageJson.version;
this.setControlPreferences();
}
if (localMapControls !== undefined) window.mapControls = localMapControls;
else window.mapControls = mainConfig.controls;
}
componentWillMount() {
window.app = packageJson.name;
window.homepage = packageJson.homepage;
window.version = packageJson.version;
this.setControlPreferences();
}

render() {
return (
<Router>
<Switch>
<Route path="/legend">
<LegendApp />
</Route>
<Route path="/layerInfo">
<LayerInfoApp />
</Route>
<Route path="/public">
<MapApp />
</Route>
<Route path="/">
<MapApp />
</Route>
</Switch>
</Router>
);
}
render() {
return (
<Router>
<Switch>
<Route path="/legend">
<LegendApp />
</Route>
<Route path="/layerInfo">
<LayerInfoApp />
</Route>
<Route path="/public">
<MapApp />
</Route>
<Route path="/">
<MapApp />
</Route>
</Switch>
</Router>
);
}
}

function MapApp() {
const [mapLoading, setMapLoading] = useState(true);
const [sidebarLoading, setSidebarLoading] = useState(true);
const [headerLoading, setHeaderLoading] = useState(true);
// LISTEN FOR MAP TO MOUNT
window.emitter.addListener("mapLoaded", () => setMapLoading(false));
// LISTEN FOR SIDEBAR TO MOUNT
window.emitter.addListener("sidebarLoaded", () => setSidebarLoading(false));
// LISTEN FOR HEADER TO MOUNT
window.emitter.addListener("headerLoaded", () => setHeaderLoading(false));
const [mapLoading, setMapLoading] = useState(true);
const [sidebarLoading, setSidebarLoading] = useState(true);
const [headerLoading, setHeaderLoading] = useState(true);
// LISTEN FOR MAP TO MOUNT
window.emitter.addListener("mapLoaded", () => setMapLoading(false));
// LISTEN FOR SIDEBAR TO MOUNT
window.emitter.addListener("sidebarLoaded", () => setSidebarLoading(false));
// LISTEN FOR HEADER TO MOUNT
window.emitter.addListener("headerLoaded", () => setHeaderLoading(false));

useEffect(() => {
helpers.loadConfig(() => {
document.title = window.config.title;
helpers.addIsLoaded("settings");
if (window.config.default_theme !== undefined) window.emitter.emit("activateSidebarItem", window.config.default_theme, "themes");
if (window.config.default_tool !== undefined) window.emitter.emit("activateSidebarItem", window.config.default_tool, "tools");
});
}, []);
useEffect(() => {
helpers.loadConfig(() => {
document.title = window.config.title;
helpers.addIsLoaded("settings");
if (window.config.default_theme !== undefined) window.emitter.emit("activateSidebarItem", window.config.default_theme, "themes");
if (window.config.default_tool !== undefined) window.emitter.emit("activateSidebarItem", window.config.default_tool, "tools");
});
}, []);

return (
<div>
<div id="portal-root" />
<LoadingScreen visible={mapLoading || sidebarLoading || headerLoading} backgroundColor={"#3498db"} />
<Header mapLoading={mapLoading} sidebarLoading={sidebarLoading} />
<Sidebar mapLoading={mapLoading} headerLoading={headerLoading} />
<SCMap sidebarLoading={sidebarLoading} headerLoading={headerLoading} />
</div>
);
return (
<div>
<div id="portal-root" />
<LoadingScreen visible={mapLoading || sidebarLoading || headerLoading} backgroundColor={"#3498db"} />
<Header mapLoading={mapLoading} sidebarLoading={sidebarLoading} />
<Sidebar mapLoading={mapLoading} headerLoading={headerLoading} />
<SCMap sidebarLoading={sidebarLoading} headerLoading={headerLoading} />
</div>
);
}
export default App;
15 changes: 5 additions & 10 deletions src/helpers/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,12 @@ export function addAppStat(type, description) {
if (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1") return;
const build = (appName, version) => `${appName}-${version}`;
const appStatsTemplate = (build, type, description) => `${window.config.appStatsUrl}${build}/${type}/${description}`;
let buildname = window.location.pathname.split("/").join("");
if (window.version !== undefined && window.version !== null) {
if (window.app !== undefined && window.app !== null) {
buildname += build(window.app, window.version);
} else {
buildname = build(buildname, window.version);
}
let buildname = "";
if (window.homepage) buildname += window.homepage;
if (window.version) {
buildname = build(window.app ? window.app : window.location.pathname.split("/").join(""), window.version);
}
if (window.homepage) buildname += "-" + window.homepage;
if (buildname === "") buildname = "Unknown";
httpGetText(appStatsTemplate(buildname, type, description));
});
Expand Down Expand Up @@ -390,7 +388,6 @@ export const messageColors = {
orange: "orange",
};
export function getHash(input) {

return input.split("").reduce((a, b) => {
a = (a << 5) - a + b.charCodeAt(0);
return a & a;
Expand Down Expand Up @@ -1473,9 +1470,7 @@ export function addIsLoaded(item) {
if (!window.loaded.includes(item.toLowerCase())) window.loaded.push(item.toLowerCase());
}
export function removeIsLoaded(item) {

if (window.loaded.includes(item.toLowerCase())) window.loaded.splice(window.loaded.indexOf(item.toLowerCase()), 1);

}

export function loadConfig(callback) {
Expand Down