Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge from edp963/davinci dev-0.3 #3

Merged
merged 16 commits into from
Dec 5, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix:(drill) fix linkage lose drill filters and groups
  • Loading branch information
ruanhan committed Nov 29, 2019
commit 01131a6026f4e8efd94fb701e92d1f0e23b9f793
5 changes: 0 additions & 5 deletions webapp/app/components/Linkages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,11 @@ export function getMappingLinkage (itemId: number, linkages: ILinkage[]) {
}

export function processLinkage (itemId: number, triggerData, mappingLinkage: IMappingLinkage, interactingLinkage) {
console.log(arguments)
Object.keys(mappingLinkage).forEach((linkagerItemId) => {
const linkage = mappingLinkage[+linkagerItemId]

const linkageFilters: IFilters[] = []
const linkageVariables: QueryVariable = []
console.log(linkage)
linkage.forEach((l) => {
const { triggerKey, triggerSqlType, triggerType, linkagerKey, linkagerSqlType, linkagerType, relation } = l
const actuallyData = Array.isArray(triggerData) ? triggerData[0][triggerKey] : triggerData[triggerKey]
Expand All @@ -84,10 +82,8 @@ export function processLinkage (itemId: number, triggerData, mappingLinkage: IMa
sqlType: linkagerSqlType,
operator: relation
}
console.log(filterJson)
linkageFilters.push(filterJson)
// linkageFilters.push(`${validLinkagerKey} ${relation} ${interactValue}`) // 联动filter生成在此处
console.log(linkageFilters)
} else if (linkagerType === 'variable') {
linkageVariables.push({ name: linkagerKey, value: interactValue })
}
Expand All @@ -106,7 +102,6 @@ export function processLinkage (itemId: number, triggerData, mappingLinkage: IMa
}
}
})
console.log(interactingLinkage)
return interactingLinkage
}

Expand Down
37 changes: 25 additions & 12 deletions webapp/app/containers/Dashboard/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ export interface IDataRequestParams {
}
nativeQuery?: boolean
customOrders?: IFieldSortDescriptor[]
drillStatus?: {
filter: {
sqls: []
}
groups: Array<string>
}
}

export interface IDataDownloadParams extends IDataRequestParams {
Expand Down Expand Up @@ -676,6 +682,9 @@ export class Grid extends React.Component<IGridProps & RouteComponentWithParams,
let drillStatus
let pagination
let nativeQuery
const prevDrillHistory = cachedQueryConditions.drillHistory
? cachedQueryConditions.drillHistory[cachedQueryConditions.drillHistory.length - 1]
: {}

if (queryConditions) {
tempFilters = queryConditions.tempFilters !== void 0 ? queryConditions.tempFilters : cachedQueryConditions.tempFilters
Expand All @@ -685,7 +694,7 @@ export class Grid extends React.Component<IGridProps & RouteComponentWithParams,
variables = queryConditions.variables || cachedQueryConditions.variables
linkageVariables = queryConditions.linkageVariables || cachedQueryConditions.linkageVariables
globalVariables = queryConditions.globalVariables || cachedQueryConditions.globalVariables
drillStatus = queryConditions.drillStatus || void 0
drillStatus = queryConditions.drillStatus || prevDrillHistory
pagination = queryConditions.pagination || cachedQueryConditions.pagination
nativeQuery = queryConditions.nativeQuery !== void 0 ? queryConditions.nativeQuery : cachedQueryConditions.nativeQuery
} else {
Expand All @@ -698,6 +707,7 @@ export class Grid extends React.Component<IGridProps & RouteComponentWithParams,
globalVariables = cachedQueryConditions.globalVariables
pagination = cachedQueryConditions.pagination
nativeQuery = cachedQueryConditions.nativeQuery
drillStatus = prevDrillHistory
}

let groups = cols.concat(rows).filter((g) => g.name !== '指标名称').map((g) => g.name)
Expand Down Expand Up @@ -753,9 +763,9 @@ export class Grid extends React.Component<IGridProps & RouteComponentWithParams,
return a.concat(b.config.sqlModel)
}, [])
const requestParams = {
groups: drillStatus && drillStatus.groups ? drillStatus.groups : groups,
groups,
aggregators,
filters: drillStatus && drillStatus.filter ? drillStatus.filter.sqls : requestParamsFilters,
filters: requestParamsFilters,
tempFilters,
linkageFilters,
globalFilters,
Expand All @@ -768,7 +778,8 @@ export class Grid extends React.Component<IGridProps & RouteComponentWithParams,
flush: renderType === 'flush',
pagination,
nativeQuery,
customOrders
customOrders,
drillStatus
}

if (tempOrders) {
Expand Down Expand Up @@ -1487,14 +1498,16 @@ export class Grid extends React.Component<IGridProps & RouteComponentWithParams,
})
}
private selectDrillHistory = (history, item, itemId, widgetId) => {
const { currentItemsInfo, onDeleteDrillHistory } = this.props
if (history) {
this.getChartData('rerender', itemId, widgetId, {
drillStatus: history
})
} else {
this.getChartData('rerender', itemId, widgetId)
}
const { onDeleteDrillHistory } = this.props
setTimeout(() => {
if (history) {
this.getChartData('rerender', itemId, widgetId, {
drillStatus: history
})
} else {
this.getChartData('rerender', itemId, widgetId)
}
}, 50)
onDeleteDrillHistory(itemId, item)
}

Expand Down
10 changes: 9 additions & 1 deletion webapp/app/containers/View/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,17 +268,25 @@ export function* getViewDataFromVizItem (action: ViewActionType) {
linkageVariables,
globalVariables,
pagination,
drillStatus,
groups,
...rest
} = requestParams
const { pageSize, pageNo } = pagination || { pageSize: 0, pageNo: 0 }

let searchFilters = filters.concat(tempFilters).concat(linkageFilters).concat(globalFilters)
if (drillStatus && drillStatus.filter) {
searchFilters = searchFilters.concat( drillStatus.filter.sqls)
}

try {
const asyncData = yield call(request, {
method: 'post',
url: `${api.view}/${viewId}/getdata`,
data: {
...omit(rest, 'customOrders'),
filters: filters.concat(tempFilters).concat(linkageFilters).concat(globalFilters),
groups: drillStatus && drillStatus.groups ? drillStatus.groups : groups,
filters: searchFilters,
params: variables.concat(linkageVariables).concat(globalVariables),
pageSize,
pageNo
Expand Down
31 changes: 19 additions & 12 deletions webapp/share/containers/Dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,9 @@ export class Share extends React.Component<IDashboardProps, IDashboardStates> {
let drillStatus
let pagination
let nativeQuery
const prevDrillHistory = cachedQueryConditions.drillHistory
? cachedQueryConditions.drillHistory[cachedQueryConditions.drillHistory.length - 1]
: {}

if (queryConditions) {
tempFilters = queryConditions.tempFilters !== void 0 ? queryConditions.tempFilters : cachedQueryConditions.tempFilters
Expand All @@ -420,9 +423,9 @@ export class Share extends React.Component<IDashboardProps, IDashboardStates> {
variables = queryConditions.variables || cachedQueryConditions.variables
linkageVariables = queryConditions.linkageVariables || cachedQueryConditions.linkageVariables
globalVariables = queryConditions.globalVariables || cachedQueryConditions.globalVariables
drillStatus = queryConditions.drillStatus || void 0
pagination = queryConditions.pagination || cachedQueryConditions.pagination
nativeQuery = queryConditions.nativeQuery || cachedQueryConditions.nativeQuery
drillStatus = queryConditions.drillStatus || prevDrillHistory
} else {
tempFilters = cachedQueryConditions.tempFilters
linkageFilters = cachedQueryConditions.linkageFilters
Expand All @@ -433,6 +436,7 @@ export class Share extends React.Component<IDashboardProps, IDashboardStates> {
globalVariables = cachedQueryConditions.globalVariables
pagination = cachedQueryConditions.pagination
nativeQuery = cachedQueryConditions.nativeQuery
drillStatus = prevDrillHistory
}

let groups = cols.concat(rows).filter((g) => g.name !== '指标名称').map((g) => g.name)
Expand Down Expand Up @@ -490,9 +494,9 @@ export class Share extends React.Component<IDashboardProps, IDashboardStates> {


const requestParams = {
groups: drillStatus && drillStatus.groups ? drillStatus.groups : groups,
groups,
aggregators,
filters: drillStatus && drillStatus.filter ? drillStatus.filter.sqls : requestParamsFilters,
filters: requestParamsFilters,
tempFilters,
linkageFilters,
globalFilters,
Expand All @@ -505,7 +509,8 @@ export class Share extends React.Component<IDashboardProps, IDashboardStates> {
flush: renderType === 'flush',
pagination,
nativeQuery,
customOrders
customOrders,
drillStatus
}

if (tempOrders) {
Expand Down Expand Up @@ -934,14 +939,16 @@ export class Share extends React.Component<IDashboardProps, IDashboardStates> {
}

private selectDrillHistory = (history, item, itemId, widgetId) => {
const { currentItemsInfo, onDeleteDrillHistory } = this.props
if (history) {
this.getChartData('rerender', itemId, widgetId, {
drillStatus: history
})
} else {
this.getChartData('rerender', itemId, widgetId)
}
const { onDeleteDrillHistory } = this.props
setTimeout(() => {
if (history) {
this.getChartData('rerender', itemId, widgetId, {
drillStatus: history
})
} else {
this.getChartData('rerender', itemId, widgetId)
}
}, 50)
onDeleteDrillHistory(itemId, item)
}

Expand Down
10 changes: 9 additions & 1 deletion webapp/share/containers/Dashboard/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,25 @@ export function* getResultset (action) {
linkageVariables,
globalVariables,
pagination,
drillStatus,
groups,
...rest
} = requestParams
const { pageSize, pageNo } = pagination || { pageSize: 0, pageNo: 0 }

let searchFilters = filters.concat(tempFilters).concat(linkageFilters).concat(globalFilters)
if (drillStatus && drillStatus.filter) {
searchFilters = searchFilters.concat( drillStatus.filter.sqls)
}

try {
const resultset = yield call(request, {
method: 'post',
url: `${api.share}/data/${dataToken}`,
data: {
...omit(rest, 'customOrders'),
filters: filters.concat(tempFilters).concat(linkageFilters).concat(globalFilters),
groups: drillStatus && drillStatus.groups ? drillStatus.groups : groups,
filters: searchFilters,
params: variables.concat(linkageVariables).concat(globalVariables),
pageSize,
pageNo
Expand Down