Skip to content

Commit

Permalink
Merge pull request #338 from Kanaries/common-ui-upgrade
Browse files Browse the repository at this point in the history
feat: upgrade parts of ui
  • Loading branch information
ObservedObserver authored Apr 23, 2023
2 parents dd7d58e + 95ce523 commit 6630718
Show file tree
Hide file tree
Showing 20 changed files with 1,275 additions and 549 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Get started with RATH now!

### Import data from online databases or CSV/JSON files.

[![](https://docs-us.oss-us-west-1.aliyuncs.com/images/readme/data-source-feature.png)](https://docs.kanaries.net/data-profiling#import-your-data)
[![](https://docs-us.oss-us-west-1.aliyuncs.com/images/readme/ds-create.png)](https://docs.kanaries.net/data-profiling#import-your-data)


### View statistics from your data source
Expand Down
4 changes: 3 additions & 1 deletion packages/rath-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
"@emotion/styled": "^11.10.4",
"@fluentui/font-icons-mdl2": "^8.5.4",
"@fluentui/react": "^8.94.4",
"@fluentui/react-components": "^9.19.0",
"@fluentui/react-file-type-icons": "^8.8.3",
"@fluentui/react-hooks": "^8.6.11",
"@fluentui/react-icons": "^2.0.200",
"@kanaries/graphic-walker": "^0.2.18",
"@kanaries/loa": "^0.0.16",
"@kanaries/web-data-loader": "0.1.7",
Expand Down Expand Up @@ -78,7 +80,7 @@
},
"scripts": {
"start": "react-app-rewired start",
"build": "GENERATE_SOURCEMAP=false react-app-rewired build",
"build": "GENERATE_SOURCEMAP=false react-app-rewired build --max_old_space_size=4096 build",
"build2": "GENERATE_SOURCEMAP=false react-app-rewired --max_old_space_size=4096 build",
"buildForAnalysis": "react-app-rewired build",
"test": "jest -c ./jest.config.js --passWithNoTests --no-cache",
Expand Down
55 changes: 45 additions & 10 deletions packages/rath-client/public/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@
"menu": {
"dataSource": "DataSource",
"eda": "Exploratory Data Analysis",
"editor": "Manual Exploration",
"editor": "Exploration",
"vizPipe": "interactive Pipeline",
"support": "Support",
"megaAuto": "Mega-auto Exploration",
"semiAuto": "Semi-auto Exploration",
"megaAuto": "Data Autopilot",
"semiAuto": "Data Copilot",
"devCollection": "Insiders(α)",
"dashBoardDesigner": "Dashboard Designer",
"painter": "Data Painter",
Expand Down Expand Up @@ -179,13 +179,13 @@
"sizeInfo": "{nCols} fields, {nRows} rows",
"demoDataset": {
"CARS": { "title": "Cars", "description": "Origin, product name and physical attributes of cars." },
"STUDENTS": { "title": "Students", "description": "" },
"BTC_GOLD": { "title": "BTC - Gold", "description": "" },
"CAR_SALES": { "title": "Car Sales", "description": "" },
"COLLAGE": { "title": "Collage", "description": "" },
"TITANIC": { "title": "Titanic", "description": "" },
"KEPLER": { "title": "Kepler", "description": "" },
"BIKE_SHARING_DC": { "title": "Bike Sharing", "description": "" }
"STUDENTS": { "title": "Students", "description": "What influence students' performance on exams?" },
"BTC_GOLD": { "title": "BTC - Gold", "description": "History data of bitcoin and gold price." },
"CAR_SALES": { "title": "Car Sales", "description": "Sales data of cars." },
"COLLAGE": { "title": "College", "description": "Public indicators of colleges." },
"TITANIC": { "title": "Titanic", "description": "Titanic shipwreck." },
"KEPLER": { "title": "Kepler", "description": "Kelper telescope data." },
"BIKE_SHARING_DC": { "title": "Bike Sharing", "description": "Bike renting data." }
},
"btn": {
"use_table": "Load this table (up to 100 rows)",
Expand Down Expand Up @@ -224,6 +224,41 @@
"database": "Database",
"kanaries_cloud": "Cloud"
},
"sources": {
"file": {
"name": "File",
"desc": "Upload a file to load data. Supported file formats: CSV, JSON and Excel."
},
"restful": {
"name": "From URL",
"desc": "Load data from a URL (JSON format)."
},
"database": {
"name": "Database",
"desc": "Connect to a database to load data. Supported databases: MySQL, PostgreSQL, Oracle, SQL Server, and SQLite."
},
"demo": {
"name": "Demo",
"desc": "Load a demo dataset to get started. It helps you to learn RATH's features and workflow."
},
"kanaries_cloud": {
"name": "Cloud",
"desc": "Load data from Kanaries Cloud."
},
"airtable": {
"name": "Airtable",
"desc": "Load tables from Airtable."
},
"local": {
"name": "History",
"desc": "Load data from your analysis history."
},
"olap": {
"name": "OLAP",
"desc": "Load data from OLAP."

}
},
"cloud": {
"notebook": "Notebook",
"dataset": "Dataset",
Expand Down
12 changes: 9 additions & 3 deletions packages/rath-client/src/components/appNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ const AppNav: React.FC<AppNavProps> = (props) => {
key: p,
name: `${navMode === 'text' ? intl.get(`menu.${p}`) : ''}${hotkeyAccess ? ` (${hotkeyAccess})` : ''}`,
forceAnchor: true,
iconProps: { iconName: getIcon(p) },
// iconProps: navMode === 'icon' ? {iconName: getIcon(p) } : undefined,
// iconProps: { iconName: getIcon(p) },
iconProps: navMode === 'icon' ? {iconName: getIcon(p) } : undefined,
onClick(e: any) {
e.preventDefault();
commonStore.setAppKey(p);
Expand Down Expand Up @@ -187,7 +187,13 @@ const AppNav: React.FC<AppNavProps> = (props) => {
PIVOT_KEYS.dashBoardDesigner,
]),
},
...getLinks([PIVOT_KEYS.support]),
// ...getLinks([PIVOT_KEYS.support]),
{
key: 'support',
name: intl.get('menu.support'),
url: 'https://docs.kanaries.net',
target: '_blank',
}
],
},
];
Expand Down
1 change: 0 additions & 1 deletion packages/rath-client/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ body {
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
background-color: rgb(250, 250, 250)
}

code {
Expand Down
9 changes: 6 additions & 3 deletions packages/rath-client/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ import ReactDOM from 'react-dom';
import { initializeIcons } from '@fluentui/font-icons-mdl2';
import { ThemeProvider } from '@fluentui/react';
import { inject } from '@vercel/analytics';

import 'office-ui-fabric-core/dist/css/fabric.css';
import './index.css';

import { FluentProvider } from '@fluentui/react-components';
// @ts-ignore
// eslint-disable-next-line import/first
import App from './App';
import { mainTheme } from './theme';
import { customLightTheme, mainTheme } from './theme';

inject();

Expand All @@ -27,7 +28,9 @@ initializeIcons();

ReactDOM.render(
<ThemeProvider theme={mainTheme}>
<App />
<FluentProvider theme={customLightTheme}>
<App />
</FluentProvider>
</ThemeProvider>,
document.getElementById('root')
);
4 changes: 2 additions & 2 deletions packages/rath-client/src/normalize.css
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ img, svg, video, canvas, audio, iframe, embed, object {
vertical-align: middle;
}

img, video {
/* img, video {
max-width: 100%;
height: auto;
}
} */

[hidden] {
display: none;
Expand Down
211 changes: 211 additions & 0 deletions packages/rath-client/src/pages/dataConnection/create.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
// Copyright (C) 2023 observedobserver
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import React, { useCallback, useState } from 'react';
import { Breadcrumb, IBreadcrumbItem, ProgressIndicator } from '@fluentui/react';
import { observer } from 'mobx-react-lite';
import intl from 'react-intl-universal';
import styled from 'styled-components';
import { Button, Card } from '@fluentui/react-components';
import { ArrowHookUpLeft24Filled } from '@fluentui/react-icons';
import { IDataSourceType } from '../../global';
import { IMuteFieldBase, IRow } from '../../interfaces';
import { DataSourceTag, IDBMeta, setDataStorage } from '../../utils/storage';
import DataLoadingStatus from '../dataSource/dataLoadingStatus';
import { useGlobalStore } from '../../store';
import { PIVOT_KEYS } from '../../constants';
import DatabaseConnector from '../dataSource/selection/database';
import { notify } from '../../components/error';
import FileData from './file';
import DemoData from './demo';
// import RestfulData from './restful';
import JSONAPI from './jsonAPI';
import OLAPData from './olap';
import HistoryPanel from './history';
import AirTableSource from './airtable';
import SupportedSources from './supportedSources';
import KanariesCloud from './cloud';

interface ConnectionCreationProps {
// show: boolean;
// loading: boolean;
// onClose: () => void;
// onStartLoading: () => void;
// onLoadingFailed: (err: any) => void;
// onDataLoaded: (fields: IMuteFieldBase[], dataSource: IRow[], name?: string, tag?: DataSourceTag | undefined, withHistory?: IDBMeta | undefined) => void;
// onDataLoading: (p: number) => void;
// toggleLoadingAnimation: (on: boolean) => void;
}

const Content = styled.div<{ open: boolean }>`
min-height: ${({ open }) => (open ? '60vh' : 'unset')};
`;

const ConnectionCreation: React.FC<ConnectionCreationProps> = (props) => {
const { dataSourceStore, commonStore, megaAutoStore, semiAutoStore } = useGlobalStore();
const { loading } = dataSourceStore;
// const { show, onClose, onDataLoaded, loading, onStartLoading, onLoadingFailed, onDataLoading, toggleLoadingAnimation } = props;

const [dataSourceType, setDataSourceType] = useState<IDataSourceType | null>(null);

const onSelectPannelClose = useCallback(() => {
// dataSourceStore.setShowDataImportSelection(false);
commonStore.setAppKey(PIVOT_KEYS.dataSource);
}, [commonStore]);

const onSelectDataLoaded = useCallback(
(fields: IMuteFieldBase[], dataSource: IRow[], name?: string, tag?: DataSourceTag | undefined, withHistory?: IDBMeta | undefined) => {
megaAutoStore.init();
semiAutoStore.init();
dataSourceStore.loadDataWithInferMetas(dataSource, fields);
if (name && tag !== undefined) {
dataSourceStore.setDatasetId(name);
setDataStorage(name, fields, dataSource, tag, withHistory);
}
},
[dataSourceStore, megaAutoStore, semiAutoStore]
);

const onSelectStartLoading = useCallback(() => {
dataSourceStore.setLoading(true);
}, [dataSourceStore]);

const onLoadingFailed = useCallback(
(err: any) => {
dataSourceStore.setLoading(false);
notify({
type: 'error',
title: '[Data Loading Error]',
content: `${err}`,
});
},
[dataSourceStore]
);

const toggleLoadingAnimation = useCallback(
(on: boolean) => {
dataSourceStore.setLoading(on);
},
[dataSourceStore]
);

const onDataLoading = useCallback(
(p: number) => {
dataSourceStore.setLoadingDataProgress(Math.floor(p * 100) / 100);
},
[dataSourceStore]
);

const formMap: Record<IDataSourceType, JSX.Element> = {
[IDataSourceType.CLOUD]: <KanariesCloud setLoadingAnimation={toggleLoadingAnimation} />,
[IDataSourceType.FILE]: (
<FileData
onDataLoading={onDataLoading}
onClose={onSelectPannelClose}
onDataLoaded={onSelectDataLoaded}
onLoadingFailed={onLoadingFailed}
toggleLoadingAnimation={toggleLoadingAnimation}
/>
),
[IDataSourceType.DEMO]: (
<DemoData
onClose={onSelectPannelClose}
onDataLoaded={onSelectDataLoaded}
onLoadingFailed={onLoadingFailed}
onStartLoading={onSelectStartLoading}
/>
),
[IDataSourceType.OLAP]: <OLAPData onClose={onSelectPannelClose} onDataLoaded={onSelectDataLoaded} />,
[IDataSourceType.RESTFUL]: (
<JSONAPI
onClose={onSelectPannelClose}
onDataLoaded={onSelectDataLoaded}
onLoadingFailed={onLoadingFailed}
onStartLoading={onSelectStartLoading}
/>
// <RestfulData onClose={onSelectPannelClose} onDataLoaded={onSelectDataLoaded} onLoadingFailed={onLoadingFailed} onStartLoading={onSelectStartLoading} />
),
[IDataSourceType.LOCAL]: <HistoryPanel onClose={onSelectPannelClose} onDataLoaded={onSelectDataLoaded} onLoadingFailed={onLoadingFailed} />,
[IDataSourceType.DATABASE]: <DatabaseConnector onClose={onSelectPannelClose} onDataLoaded={onSelectDataLoaded} />,
[IDataSourceType.AIRTABLE]: (
<AirTableSource
onClose={onSelectPannelClose}
onDataLoaded={onSelectDataLoaded}
onLoadingFailed={onLoadingFailed}
onStartLoading={onSelectStartLoading}
/>
),
};

const _onBreadcrumbItemClicked = useCallback((ev?: React.MouseEvent<HTMLElement>, item?: IBreadcrumbItem) => {
if (item && item.key === 'connection') {
setDataSourceType(null);
}
}, []);

const items: IBreadcrumbItem[] = [
{ text: intl.get('dataSource.dataSourceConnection.types'), key: 'connection', onClick: _onBreadcrumbItemClicked, role: 'text' },
];

if (dataSourceType !== null) {
items.push({ text: intl.get(`dataSource.importData.type.${dataSourceType}`), key: dataSourceType, onClick: _onBreadcrumbItemClicked });
}

return (
<div style={{ marginTop: '1em' }}>
{dataSourceType !== null && (
<Card>
<Breadcrumb
items={items}
maxDisplayedItems={10}
styles={{
itemLink: {
fontSize: '1em',
},
}}
/>
<hr style={{ marginTop: '1em' }} />
<div style={{ margin: '2px 0em' }}>
<Button
icon={<ArrowHookUpLeft24Filled />}
onClick={() => {
setDataSourceType(null);
}}
>
{intl.get('common.return')}
</Button>
</div>
<Content open={Boolean(dataSourceType)}>
{loading && dataSourceType !== IDataSourceType.FILE && <ProgressIndicator description="loading" />}
{loading && dataSourceType === IDataSourceType.FILE && <DataLoadingStatus />}
{dataSourceType && formMap[dataSourceType]}
</Content>
</Card>
)}

<div>
{dataSourceType === null && (
<SupportedSources
onSelected={(k) => {
setDataSourceType(k as IDataSourceType);
}}
/>
)}
</div>
</div>
);
};

export default observer(ConnectionCreation);
Loading

1 comment on commit 6630718

@vercel
Copy link

@vercel vercel bot commented on 6630718 Apr 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.