Skip to content

Commit

Permalink
geochart - Proxy - no authentication needed
Browse files Browse the repository at this point in the history
  • Loading branch information
BugsBunny338 committed Oct 18, 2021
1 parent 2b612fd commit edf5b51
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 72 deletions.
4 changes: 1 addition & 3 deletions geochart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ This demonstrates how you can feed data from the [GoodData](https://www.gooddata

## Backend

This app is designed to connect to domain https://developer.na.gooddata.com/, workspace `xms7ga4tf3g3nzucd8380o2bev8oeknp`.

For access, you can register at https://gooddata-examples.herokuapp.com/.
This app is designed to connect to workspace `xms7ga4tf3g3nzucd8380o2bev8oeknp` on https://live-examples-proxy.herokuapp.com/ domain, and does not require authentication.

## Live demo

Expand Down
4 changes: 2 additions & 2 deletions geochart/src/components/Header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { AuthStatus } from "../../contexts/Auth/state";

import Logo from "./Logo";
import Links from "./Links";
import Aside from "./Aside";
// import Aside from "./Aside";

import styles from "./Header.module.scss";

Expand Down Expand Up @@ -91,7 +91,7 @@ const Header = () => {
</>
)}

<Aside />
{/* <Aside /> */}
</nav>
);
};
Expand Down
2 changes: 1 addition & 1 deletion geochart/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export const appName = "geochart";

// The URL of analytical GoodData backend with workspaces, insights, metrics, attributes, datasets, and users
// that will be available to the application.
export const backend = "https://developer.na.gooddata.com";
export const backend = "https://live-examples-proxy.herokuapp.com/";

// The ID of workspace that is selected by default in the optional workspace picker component (located in the web
// application header). It is also a default setting for script that refreshes MD data used by the application.
Expand Down
17 changes: 6 additions & 11 deletions geochart/src/contexts/Auth/backend.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import bearFactory, {
FixedLoginAndPasswordAuthProvider,
ContextDeferredAuthProvider,
AnonymousAuthProvider,
} from "@gooddata/sdk-backend-bear";
import { backend } from "../../constants";

import { backend as hostname } from "../../constants";
export const createBackend = () =>
bearFactory({ hostname: backend }).withAuthentication(new AnonymousAuthProvider());

const backendConfig = process.env.REACT_APP_SET_HOSTNAME ? { hostname } : {};

export const createBackend = () => {
return bearFactory(backendConfig).withAuthentication(new ContextDeferredAuthProvider());
};

export const backendWithCredentials = (backend, username, password) => {
return backend.withAuthentication(new FixedLoginAndPasswordAuthProvider(username, password));
};
export const backendWithCredentials = (backend, username, password) =>
backend.withAuthentication(new FixedLoginAndPasswordAuthProvider(username, password));
18 changes: 9 additions & 9 deletions geochart/src/routes/AppRouter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { HashRouter as Router, Route, Redirect } from "react-router-dom";
import { HashRouter as Router, Route } from "react-router-dom";

import { WorkspaceProvider } from "../contexts/Workspace";
import Page from "../components/Page";
Expand All @@ -12,13 +12,13 @@ import Home from "./Home";
import styles from "./AppRouter.module.scss";

// Uncomment these lines if you want to redirect unauthorized users to login form
import { useAuth } from "../contexts/Auth";
import { AuthStatus } from "../contexts/Auth/state";
const RedirectIfNotLoggedIn = () => {
const auth = useAuth();
const shouldRedirectToLogin = auth.authStatus === AuthStatus.UNAUTHORIZED;
return shouldRedirectToLogin ? <Route component={() => <Redirect to="/login" />} /> : null;
};
// import { useAuth } from "../contexts/Auth";
// import { AuthStatus } from "../contexts/Auth/state";
// const RedirectIfNotLoggedIn = () => {
// const auth = useAuth();
// const shouldRedirectToLogin = auth.authStatus === AuthStatus.UNAUTHORIZED;
// return shouldRedirectToLogin ? <Route component={() => <Redirect to="/login" />} /> : null;
// };

const AppRouter = () => {
return (
Expand All @@ -31,7 +31,7 @@ const AppRouter = () => {
<Route exact path="/dashboard" component={() => <Page>Dashboard</Page>} />
<Route exact path="/login" component={Login} />
<Route exact path="/logout" component={Logout} />
<RedirectIfNotLoggedIn />
{/* <RedirectIfNotLoggedIn /> */}
</WorkspaceProvider>
</Router>
</div>
Expand Down
3 changes: 1 addition & 2 deletions geochart/src/routes/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const Home = () => {
}

if (error) {
return <p>Execution failed; {error}</p>;
return <p>Execution failed; {error.toString()}</p>;
}

if (result) {
Expand All @@ -28,7 +28,6 @@ const Home = () => {
population: parseInt(slice.rawData()[0]),
density: parseInt(slice.rawData()[1]),
}));
console.log(data);
return <GeoChart height={600} data={data} />;
}

Expand Down
44 changes: 0 additions & 44 deletions geochart/src/setupProxy.js

This file was deleted.

0 comments on commit edf5b51

Please sign in to comment.