Skip to content

Commit

Permalink
gd-ui-boilerplate - Older version renamed to gd-ui-boilerplate-v7, la…
Browse files Browse the repository at this point in the history
…test version is now simply gd-ui-boilerplate
  • Loading branch information
BugsBunny338 committed Mar 13, 2021
1 parent a551a4c commit 4ec3e88
Show file tree
Hide file tree
Showing 60 changed files with 11,721 additions and 11,720 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage
Expand Down
50 changes: 50 additions & 0 deletions gd-ui-boilerplate-v7/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# GoodData.UI@v7 Boilerplate App

This app follows steps from https://sdk.gooddata.com/gooddata-ui/docs/ht_create_your_first_visualization.html:

* It initializes create-react-app
* It configures GoodData proxy
* It adds [@gooddata/react-components](https://www.npmjs.com/package/@gooddata/react-components) package

This app also shows:

* Use of `<AttributeFilter>` component
* Use of `<Kpi>` component

And finally this app demonstrates 3 approaches how to render visualizations:

* By referencing `<Visualization>` created in Analytical Designer
* By specifying buckets (measures, viewBy, stackBy) with `<ColumnChart>` component
* By creating custom column chart using `<Execute>` component and [Highcharts](https://www.highcharts.com/) library

## Live demo

This app is deployed at https://gooddata-demo.s3.amazonaws.com/gd-ui-boilerplate-v7/index.html. For access, you can register at https://gooddata-examples.herokuapp.com/.

## How to run locally

* `git clone --depth 1 https://github.com/gooddata/ui-sdk-examples.git`
* `cd ui-sdk-examples/gd-ui-boilerplate-v7/`
* `yarn install --pure-lockfile` (or `npm install`)
* `yarn start` (or `GD_URL=developer.na.gooddata.com yarn start`)

## How to build for deployment

* `yarn build` when deploying to root folder
* `PUBLIC_URL=/gd-ui-boilerplate-v7 yarn build` when deploying to `/gd-ui-boilerplate-v7` folder

## Backend/proxy info

This app is configured to run against https://developer.na.gooddata.com/. For access, you can register at https://gooddata-examples.herokuapp.com/.

## Compatibility

An ES6 [@babel/polyfill](https://babeljs.io/docs/en/babel-polyfill) was added to support Internet Explorer.

## Screnshots

![homepage](https://raw.githubusercontent.com/gooddata/ui-sdk-examples/master/gd-ui-boilerplate-v7/public/screen1.png "Homepage")

---

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
34 changes: 34 additions & 0 deletions gd-ui-boilerplate-v7/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "gd-ui-boilerplate-v7",
"version": "0.1.0",
"private": true,
"dependencies": {
"@gooddata/react-components": "^7.1.1",
"node-sass": "^4.9.4",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-highcharts": "^16.0.2",
"react-scripts": "2.0.5",
"react-select": "^3.1.0"
},
"scripts": {
"start": "cross-env HTTPS=true react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"buildgd": "cross-env PUBLIC_URL=/gd-ui-boilerplate-v7 yarn build",
"syncgd": "s3cmd --config .s3cfg sync --delete-removed ./build/ s3://gooddata-demo/gd-ui-boilerplate-v7/"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"devDependencies": {
"cross-env": "^5.2.0"
}
}
Binary file added gd-ui-boilerplate-v7/public/favicon.ico
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<meta charset="utf-8">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Expand All @@ -25,9 +20,12 @@
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>GoodData.UI Boilerplate</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.0.0/polyfill.min.js"></script>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
Expand Down
Binary file added gd-ui-boilerplate-v7/public/screen1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions gd-ui-boilerplate-v7/src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.App {
text-align: center;
}

.App-logo {
animation: App-logo-spin infinite 20s linear;
height: 40vmin;
}

.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}

.App-link {
color: #61dafb;
}

@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
89 changes: 89 additions & 0 deletions gd-ui-boilerplate-v7/src/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import React, { useState, useEffect } from 'react';
import { Headline, ColumnChart, Execute, Visualization, Model } from '@gooddata/react-components';
import C from './catalog';
import config from './config';
import AttributeDropdown from './components/AttributeDropdown';
import CustomBarChart from './components/CustomBarChart';
import { loginMachinery } from './utils';

import '@gooddata/react-components/styles/css/main.css';
import './App.css';

function App() {
const [isLogged, setIsLogged] = useState(false);
const [filters, setFilters] = useState([]);

useEffect(() => {
loginMachinery({ ...config }, () => setIsLogged(true));
});

if (!isLogged) {
return <span>Checking your credentials, please wait…</span>;
}

return (
<div className="App">
<div style={{ width: 400, margin: 'auto', marginBottom: 20, marginTop: 20 }}>
<AttributeDropdown
{...config}
placeholder="Filter cities"
attribute={C.attributeDisplayForm('Location City')}
filters={filters}
updateFilters={setFilters}
/>
</div>
<div>
# of Location City: <Headline
{...config}
filters={filters}
primaryMeasure={Model.measure(C.measure('# Location City'))}
/>
<br />
<br />
</div>
<div style={{ height: 400 }}>
<Visualization
{...config}
filters={filters}
identifier="aby6oS6DbpFX"
/>
</div>
<div style={{ height: 400 }}>
<ColumnChart
{...config}
filters={filters}
measures={[Model.measure(C.measure('# Checks'))]}
viewBy={Model.attribute(C.attributeDisplayForm('Location City'))}
stackBy={Model.attribute(C.attributeDisplayForm('Location Name'))}
/>
</div>
<div style={{ height: 400 }}>
<Execute
{...config}
afm={{
measures: [{
localIdentifier: 'm1',
definition: {
measure: {
item: {
identifier: C.measure('# Checks')
}
}
}
}],
attributes: [{
localIdentifier: 'a1',
displayForm: {
identifier: C.attributeDisplayForm('Location City')
}
}],
filters
}}
children={CustomBarChart}
/>
</div>
</div>
);
}

export default App;
9 changes: 9 additions & 0 deletions gd-ui-boilerplate-v7/src/App.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';

it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<App />, div);
ReactDOM.unmountComponentAtNode(div);
});
File renamed without changes.
File renamed without changes.
32 changes: 32 additions & 0 deletions gd-ui-boilerplate-v7/src/components/CustomBarChart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (C) 2007-2018, GoodData(R) Corporation. All rights reserved.
import React from 'react';
import ReactHighcharts from 'react-highcharts';

const CustomBarChart = ({error, isLoading, result}) => {
if (isLoading) {
return <span>Loading…</span>;
}

if (error) {
return <span>Something went wrong :-(</span>;
}

const config = {
chart: {
type: 'column',
},
title: {
text: '🎉🍾🙌 My First Custom Chart 🙌🍾🎉'
},
series: result.executionResult.data.map((row, i) =>
({ data: [parseFloat(row[0])] }))
};

if (result) {
return (
<ReactHighcharts config={config} />
);
}
};

export default CustomBarChart;
File renamed without changes.
14 changes: 14 additions & 0 deletions gd-ui-boilerplate-v7/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
body {
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
monospace;
}
18 changes: 18 additions & 0 deletions gd-ui-boilerplate-v7/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (C) 2007-2018, GoodData(R) Corporation. All rights reserved.
import React from 'react';
import ReactDOM from 'react-dom';

import App from './App';
import * as serviceWorker from './serviceWorker';

import './index.css';

ReactDOM.render(
<App />,
document.getElementById('root')
);

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: http://bit.ly/CRA-PWA
serviceWorker.unregister();
Loading

0 comments on commit 4ec3e88

Please sign in to comment.