-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from Kanaries/beta
feat: temporal info extension
- Loading branch information
Showing
18 changed files
with
644 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,7 +166,7 @@ | |
"title": "下载数据" | ||
}, | ||
"extend": { | ||
"title": "扩展维度" | ||
"title": "扩展信息" | ||
} | ||
}, | ||
"meta": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { IRow } from "visual-insights"; | ||
import { IRawField } from "rath-client/src/interfaces"; | ||
import { workerService } from "rath-client/src/service"; | ||
/* eslint import/no-webpack-loader-syntax:0 */ | ||
// @ts-ignore | ||
// eslint-disable-next-line | ||
import ExpandDateTimeWorker from './workers/dateTimeExpand.worker.js?worker'; | ||
import { dateTimeExpand, doTest } from './workers/engine/dateTimeExpand' | ||
import { checkExpandEnv } from './workers/engine/checkExpandEnv' | ||
|
||
interface ExpandDateTimeProps { | ||
dataSource: IRow[]; | ||
fields: IRawField[]; | ||
} | ||
const ExpandEnv = checkExpandEnv(); | ||
|
||
export async function expandDateTimeService (props: ExpandDateTimeProps): Promise<ExpandDateTimeProps> { | ||
if (ExpandEnv === 'debug') { | ||
doTest() | ||
let res = dateTimeExpand(props) as ExpandDateTimeProps | ||
return res | ||
} | ||
else { | ||
try { | ||
const worker = new ExpandDateTimeWorker() | ||
const result = await workerService<ExpandDateTimeProps, ExpandDateTimeProps>(worker, props) | ||
worker.terminate(); | ||
if (result.success) { | ||
return result.data | ||
} | ||
else { | ||
throw new Error(`[ExpandDateTimeWorker]: ${result.message}`) | ||
} | ||
} catch (error) { | ||
console.error(`[ExpandDateTimeWorker]: ${error}`) | ||
throw error; | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
packages/rath-client/src/dev/workers/dateTimeExpand.worker.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* eslint no-restricted-globals: 0 */ | ||
import { dateTimeExpand } from "./engine/dateTimeExpand"; | ||
import { timer } from '../../workers/timer'; | ||
|
||
const expandService = e => { | ||
try { | ||
const { fields, dataSource } = e.data; | ||
const res = dateTimeExpand({ fields, dataSource }) | ||
self.postMessage({ | ||
success: true, | ||
data: res | ||
}) | ||
} catch (error) { | ||
self.postMessage({ | ||
success: false, | ||
message: `[expandService]${error}\n${error.stack}` | ||
}) | ||
} | ||
} | ||
|
||
self.addEventListener('message', timer(expandService), false) |
12 changes: 12 additions & 0 deletions
12
packages/rath-client/src/dev/workers/engine/checkExpandEnv.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export function checkExpandEnv(): string { | ||
if (typeof window === 'object') { | ||
const url = new URL(window.location.href).searchParams.get('expand'); | ||
if(url) { | ||
(window as any).ExpandEnv = url | ||
return url | ||
} | ||
else return '' | ||
} | ||
if (process.env.EXPAND_ENV) return process.env.EXPAND_ENV | ||
else return '' | ||
} |
Oops, something went wrong.