Skip to content

Commit

Permalink
Merge pull request #83 from Kanaries/v3-research
Browse files Browse the repository at this point in the history
V3 research backup demo
  • Loading branch information
ObservedObserver committed Mar 24, 2022
2 parents acc0ec8 + a7bfac6 commit 293a903
Show file tree
Hide file tree
Showing 103 changed files with 3,976 additions and 759 deletions.
91 changes: 91 additions & 0 deletions apps/testServer/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
var express = require("express");
var fs = require("fs");
var app = express();
var bodyParser = require("body-parser");
var cookieParser = require("cookie-parser");
app.use(express.json({ limit: Infinity }));

app.use(bodyParser.json());
app.use(cookieParser());
app.use(bodyParser.urlencoded({ extended: false }));

app.all("*", function (req, res, next) {
// res.header("Access-Control-Allow-Origin", ["http://kanaries-app.s3.ap-northeast-1.amazonaws.com", "http://localhost:8000"]);
res.header("Access-Control-Allow-Origin", '*');
// res.header("Access-Control-Allow-Credentials", true);
res.header(
"Access-Control-Allow-Headers",
"Content-Type, Content-Length, Authorization, Accept, X-Requested-With , yourHeaderFeild"
);
res.header("Access-Control-Allow-Methods", "PUT, POST, GET, DELETE, OPTIONS");

if (req.method == "OPTIONS") {
res.send(200);
/让options请求快速返回/;
} else {
next();
}
});
app.post("/associate", function (req, res) {
// console.log("[/assocaite]", req);
const fields = req.body.fields;
const returns = JSON.parse(fs.readFileSync('/Users/chenhao/Downloads/result(3).json').toString())
const result1 = returns.data.t1;
for (let i = 0; i < result1.length; i++) {
result1[i].dimensions = result1[i].dimensions.map(d => {
const target = fields.find(f => f.fid.split('_')[1] === d.split('_')[1]);
return target.fid;
}).filter(f => Boolean(f));
result1[i].measures = result1[i].measures.map(d => {
const target = fields.find(f => f.fid.split('_')[1] === d.split('_')[1]);
return target.fid;
}).filter(f => Boolean(f));
}
const result2 = returns.data.t2;
for (let i = 0; i < result2.length; i++) {
result2[i].dimensions = result2[i].dimensions.map(d => {
const target = fields.find(f => f.fid.split('_')[1] === d.split('_')[1]);
return target.fid;
}).filter(f => Boolean(f));
result2[i].measures = result2[i].measures.map(d => {
const target = fields.find(f => f.fid.split('_')[1] === d.split('_')[1]);
return target.fid;
}).filter(f => Boolean(f));
}
res.json(returns);
});

app.post("/start", function (req, res) {
console.log("[/start]", req);
const fields = req.body.fields;
res.json({
success: true,
data: {
fields: req.body.fields,
dataSource: req.body.dataSource,
insightSpaces: [
{
dimensions: fields.filter((f) => f.analyticType === "dimension").slice(0, 2).map(f => f.fid),
measures: fields.filter((f) => f.analyticType === "measure").slice(0, 2).map(f => f.fid),
// significance: 1,
score: 1,
// impurity: 1
},
{
dimensions: fields.filter((f) => f.analyticType === "dimension").slice(1, 3).map(f => f.fid),
measures: fields.filter((f) => f.analyticType === "measure").slice(1, 2).map(f => f.fid),
// significance: 1,
score: 1,
// impurity: 1
}
]
},
});
});

var server = app.listen(8000, function () {
var host = server.address().address;
var port = server.address().port;

console.log("应用实例,访问地址为 http://%s:%s", host, port);
});
11 changes: 11 additions & 0 deletions apps/testServer/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"dependencies": {
"body-parser": "^1.19.2",
"cookie-parser": "^1.4.6",
"express": "^4.17.3"
},
"prettier": {
"tabWidth": 4,
"printWidth": 120
}
}
5 changes: 2 additions & 3 deletions packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"@kanaries/graphic-walker": "0.1.0",
"@kanaries/web-data-loader": "0.1.0",
"@material-ui/core": "^5.0.0-beta.5",
"@tableau/tableau-ui": "^3.0.0",
"@uifabric/icons": "^7.5.17",
"@uifabric/react-hooks": "^7.13.9",
"ali-react-table": "^2.3.1",
Expand Down Expand Up @@ -45,7 +44,7 @@
"vega": "^5.19.1",
"vega-embed": "^6.15.1",
"vega-lite": "^4.17.0",
"visual-insights": "0.7.12",
"visual-insights": "0.7.15",
"web-vitals": "^0.2.4",
"worker-loader": "^3.0.7"
},
Expand All @@ -65,7 +64,7 @@
},
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"build": "GENERATE_SOURCEMAP=false react-app-rewired build",
"build2": "react-app-rewired --max_old_space_size=4096 build",
"test": "react-app-rewired test",
"eject": "react-app-rewired eject",
Expand Down
30 changes: 27 additions & 3 deletions packages/frontend/public/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"editor": "Visual Editor",
"support": "Support",
"lts": "Explore",
"pattern": "Build Knowledge(beta)",
"devCollection": "Debug"
},
"preference": {
Expand All @@ -36,7 +37,9 @@
"cancel": "Cancel",
"analysis": {
"start": "Insight Analysis",
"checkResult": "Check Existed Results"
"checkResult": "Check Existed Results",
"pattern": "Build Knowledge(beta)",
"manual": "Manual Explore"
},
"importStorage": {
"title": "Import History Storage",
Expand Down Expand Up @@ -69,6 +72,26 @@
"extractInsightOld": "Insight Analysis(Debug)",
"cleanMethod": "Clean Method",
"useField": "use field",
"viewMode": "View Mode",
"metaView": "Meta View",
"dataView": "Table View",
"advice": {
"lackData": "Lack of Data",
"lackDimension": "There should includes dimensions in the datasource.",
"lackMeasure": "There should includes measures in the datasource",
"smallSample": "The sample size is not big enough, which may influence the reliability of recommandation.",
"forceAnalysis": "Force Analysis"
},
"meta": {
"uniqueValue": "Unique Value",
"analyticType": "analytic type",
"semanticType": "semantic Type",
"disable": {
"title": "Disable Column",
"on": "able",
"off": "disable"
}
},
"importData": {
"buttonName": "Import Data",
"type": {
Expand Down Expand Up @@ -99,7 +122,7 @@
"simpleClean": "simple cleaning",
"none": "none(use original data)"
},
"tip": "Remember to adjust the fields' types and cleaning strategy before extracting insights.",
"tip": "Remember to adjust the fields' types and cleaning strategy before analysis.",
"recordCount": "Number of records {count}",
"upload": {
"title": "Upload Your own dataset",
Expand All @@ -113,7 +136,8 @@
"title": "Explore Mode",
"firstTime": "Meet the data first time",
"familiar": "Familiar with the data",
"comprehensive": "Comprehensive"
"comprehensive": "Comprehensive",
"manual": "Manual(with specific purpose)"
}
},
"meta": {
Expand Down
35 changes: 30 additions & 5 deletions packages/frontend/public/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
"dataSource": "数据源",
"noteBook": "交互式算法可视化",
"explore": "探索分析(旧)",
"dashBoard": "报表",
"dashBoard": "报表推荐",
"explainer": "数据解读",
"editor": "自助分析",
"support": "帮助",
"lts": "探索分析",
"pattern": "建立认知(beta)",
"devCollection": "调试模式"
},
"preference": {
Expand All @@ -36,7 +37,9 @@
"cancel": "取消",
"analysis": {
"start": "开始分析",
"checkResult": "查看已有结果"
"checkResult": "查看已有结果",
"pattern": "建立认知(beta)",
"manual": "自助分析"
},
"importStorage": {
"title": "导入历史分析",
Expand Down Expand Up @@ -69,8 +72,29 @@
"extractInsightOld": "开始分析(调试模式)",
"cleanMethod": "清洗方法",
"useField": "允许使用",
"viewMode": "视图模式",
"metaView": "元数据视图",
"dataView": "数据视图",
"advice": {
"lackData": "缺少有效数据",
"lackDimension": "数据集中缺少维度,无法进行完整的分析任务。",
"lackMeasure": "数据集中缺少度量,无法进行完整的分析任务。",
"smallSample": "数据集中样本数量低于预期,可能会对推荐结果的一般性造成影响。(小样本问题)",
"forceAnalysis": "强制分析"
},
"meta": {
"title": "元数据视图",
"uniqueValue": "唯一值数量",
"analyticType": "分析类型",
"semanticType": "数据类型",
"disable": {
"title": "是否使用该列",
"on": "使用",
"off": "禁用"
}
},
"importData": {
"buttonName": "导入数据",
"buttonName": "选择数据",
"type": {
"file": "文件",
"restful": "RESTFUL",
Expand Down Expand Up @@ -99,7 +123,7 @@
"simpleClean": "简单的替换",
"none": "无(使用原始数据)"
},
"tip": "记得在提取洞察前先调整数据的清洗策略并配置字段的属性",
"tip": "记得在开始分析前先调整数据的清洗策略并配置字段的属性",
"recordCount": "记录数 {count}",
"upload": {
"title": "上传你的数据集,根据需求调整以下配置",
Expand All @@ -113,7 +137,8 @@
"title": "探索模式",
"firstTime": "第一次接触该数据集",
"familiar": "基本熟悉该数据集",
"comprehensive": "综合模式"
"comprehensive": "综合模式",
"manual": "手动(有明确分析目的)"
}
},
"meta": {
Expand Down
29 changes: 6 additions & 23 deletions packages/frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { useEffect } from "react";
import intl from 'react-intl-universal';
import { useGlobalStore, StoreWrapper } from './store/index'
import { observer } from "mobx-react-lite";
import "./App.css";
Expand All @@ -9,6 +8,7 @@ import NoteBook from "./pages/notebook/index";
import VisualInterface from './pages/visualInterface';
import DataSourceBoard from "./pages/dataSource/index";
import DashBoardPage from './pages/dashBoard/index';
import PatternPage from './pages/pattern/index';
import DevPage from './pages/dev';
import SupportPage from './pages/support/index';
import LTSPage from './pages/lts';
Expand All @@ -17,6 +17,8 @@ import AppNav from "./components/appNav";
import { destroyRathWorker, initRathWorker } from "./service";
import { PIVOT_KEYS } from "./constants";
import CrInfo from "./components/crInfo";
// import { loadTheme } from "office-ui-fabric-react";
// import { RATH_DARK_PALETTE, RATH_DARK_THEME } from "./theme";


// FIXME: 这两代码好像没什么用
Expand All @@ -27,28 +29,6 @@ function App() {
const { langStore, commonStore } = useGlobalStore()
const { appKey } = commonStore;

let pivotKeys: string[] = [
PIVOT_KEYS.dataSource,
PIVOT_KEYS.lts,
PIVOT_KEYS.editor,
PIVOT_KEYS.dashBoard,
PIVOT_KEYS.noteBook,
PIVOT_KEYS.gallery,
PIVOT_KEYS.explainer,
PIVOT_KEYS.support
]

let pivotList = pivotKeys.map((page, index) => {
return { title: page, itemKey: page }
})

if (langStore.loaded && langStore.lang) {
pivotList = pivotKeys.map(p => intl.get(`menu.${p}`))
.map((page, index) => {
return { title: page, itemKey: pivotKeys[index] }
})
}

useEffect(() => {
initRathWorker(commonStore.computationEngine);
return () => {
Expand Down Expand Up @@ -125,6 +105,7 @@ function App() {
{appKey === PIVOT_KEYS.editor && <VisualInterface />}
{appKey === PIVOT_KEYS.support && <SupportPage />}
{appKey === PIVOT_KEYS.lts && <LTSPage />}
{appKey === PIVOT_KEYS.pattern && <PatternPage />}
<CrInfo />
</div>
</div>
Expand All @@ -134,6 +115,8 @@ function App() {

const OBApp = observer(App);

// loadTheme(RATH_DARK_THEME);

export default function WrappedApp() {
return (
<StoreWrapper>
Expand Down
26 changes: 3 additions & 23 deletions packages/frontend/src/components/appNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,10 @@ const LogoBar = styled.div`

interface AppNavProps {}
const AppNav: React.FC<AppNavProps> = props => {
const { langStore, commonStore } = useGlobalStore()
const { commonStore } = useGlobalStore()

const { appKey } = commonStore;

let pivotKeys: string[] = [
PIVOT_KEYS.dataSource,
PIVOT_KEYS.lts,
PIVOT_KEYS.editor,
PIVOT_KEYS.dashBoard,
PIVOT_KEYS.noteBook,
PIVOT_KEYS.gallery,
PIVOT_KEYS.explainer,
PIVOT_KEYS.support
]

const getLinks = useCallback((pivotKeys: string[]) => {
return pivotKeys.map(p => {
return {
Expand All @@ -62,29 +51,20 @@ const AppNav: React.FC<AppNavProps> = props => {
})
}, [commonStore])

let pivotList = pivotKeys.map((page, index) => {
return { title: page, itemKey: page }
})

if (langStore.loaded && langStore.lang) {
pivotList = pivotKeys.map(p => intl.get(`menu.${p}`))
.map((page, index) => {
return { title: page, itemKey: pivotKeys[index] }
})
}
const groups: INavLinkGroup[] = [
{
links: [
...getLinks([PIVOT_KEYS.dataSource,
PIVOT_KEYS.lts,
PIVOT_KEYS.editor,
PIVOT_KEYS.dashBoard,
PIVOT_KEYS.pattern
]),
{
url: '#dev-mode',
key: intl.get('menu.devCollection'),
name: intl.get('menu.devCollection'),
isExpanded: true,
isExpanded: false,
forceAnchor: true,
onClick (e: any) { e.preventDefault() },
links: getLinks([
Expand Down

0 comments on commit 293a903

Please sign in to comment.