Skip to content

Commit

Permalink
fix(drill) edp963#1971
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanhan committed Oct 28, 2020
1 parent 9e8800c commit 6e31d92
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 40 deletions.
7 changes: 5 additions & 2 deletions webapp/app/components/DataDrill/abstract/widgetOperating.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default class OperatingWidget extends OperateObjectAbstract {
}

public initGroups() {
const widget = this.getWidgetById(this.currentWidgetId)
let widget = this.getWidgetById(this.currentWidgetId)
if (!widget.initGroups) {
const { rows, cols, color, label } = widget
const setDefaultEmptyArray = setDefaultReplaceNull((f) => f, [])
Expand All @@ -94,7 +94,10 @@ export default class OperatingWidget extends OperateObjectAbstract {
setDefaultEmptyArray
)(label)
]
widget.initGroups = groups
widget = {
...widget,
initGroups: groups
}
return groups
}
return widget.initGroups
Expand Down
79 changes: 45 additions & 34 deletions webapp/app/containers/Dashboard/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,14 @@ export function* getDashboardDetail(action: DashboardActionType) {

operationWidgetProps.widgetIntoPool(widgets)

const formedViews: IFormedViews = views.reduce(
(obj, view) => {
obj[view.id] = {
...view,
model: JSON.parse(view.model || '{}'),
variable: JSON.parse(view.variable || '[]')
}
return obj
},
{}
)
const formedViews: IFormedViews = views.reduce((obj, view) => {
obj[view.id] = {
...view,
model: JSON.parse(view.model || '{}'),
variable: JSON.parse(view.variable || '[]')
}
return obj
}, {})

yield put(dashboardDetailLoaded(dashboard, items, widgets, formedViews))
} catch (err) {
Expand Down Expand Up @@ -484,19 +481,26 @@ export function* getDashboardShareLink(action: DashboardActionType) {
loadDashboardShareLinkFail
} = DashboardActions

const {id, mode, permission, expired, roles, viewers} = action.payload.params
const {
id,
mode,
permission,
expired,
roles,
viewers
} = action.payload.params

let requestData = null
switch(mode) {
switch (mode) {
case 'AUTH':
requestData = { mode, expired, permission, roles, viewers }
break
case 'PASSWORD':
case 'NORMAL':
requestData = { mode, expired }
break
default:
break
requestData = { mode, expired, permission, roles, viewers }
break
case 'PASSWORD':
case 'NORMAL':
requestData = { mode, expired }
break
default:
break
}

try {
Expand All @@ -506,7 +510,7 @@ export function* getDashboardShareLink(action: DashboardActionType) {
data: requestData
})

const { token, password} = result.payload
const { token, password } = result.payload
switch (mode) {
case 'AUTH':
yield put(dashboardAuthorizedShareLinkLoaded(token))
Expand All @@ -520,14 +524,13 @@ export function* getDashboardShareLink(action: DashboardActionType) {
default:
break
}

} catch (err) {
yield put(loadDashboardShareLinkFail())
errorHandler(err)
}
}

export function* getWidgetShareLink (action: DashboardActionType) {
export function* getWidgetShareLink(action: DashboardActionType) {
if (action.type !== ActionTypes.LOAD_WIDGET_SHARE_LINK) {
return
}
Expand All @@ -537,19 +540,27 @@ export function* getWidgetShareLink (action: DashboardActionType) {
widgetShareLinkLoaded,
loadWidgetShareLinkFail
} = DashboardActions
const {id, itemId, mode, expired, permission, roles, viewers} = action.payload.params
const {
id,
itemId,
mode,
expired,
permission,
roles,
viewers
} = action.payload.params

let requestData = null
switch(mode) {
switch (mode) {
case 'AUTH':
requestData = { mode, expired, permission, roles, viewers }
break
case 'PASSWORD':
case 'NORMAL':
requestData = { mode, expired }
break
default:
break
requestData = { mode, expired, permission, roles, viewers }
break
case 'PASSWORD':
case 'NORMAL':
requestData = { mode, expired }
break
default:
break
}

try {
Expand Down
14 changes: 10 additions & 4 deletions webapp/share/containers/Dashboard/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@ import {
takeLatest,
takeEvery
} from 'redux-saga/effects'

import { IWidgetFormed } from 'app/containers/Widget/types'
import { ActionTypes } from './constants'
import { DashboardActions, DashboardActionType } from './actions'
import {
makeSelectDashboard,
makeSelectItemRelatedWidget,
makeSelectItemInfo,
makeSelectFormedViews
makeSelectFormedViews,
makeSelectWidgets
} from './selectors'
import { makeSelectShareType } from 'share/containers/App/selectors'
import {
Expand Down Expand Up @@ -64,7 +67,6 @@ import {
IDashboard,
IQueryConditions
} from 'app/containers/Dashboard/types'
import { IWidgetFormed } from 'app/containers/Widget/types'
import { IShareFormedViews } from 'app/containers/View/types'
import {
IGlobalControlConditions,
Expand All @@ -82,7 +84,7 @@ import api from 'utils/api'
import { message } from 'antd'
import { DownloadTypes } from 'app/containers/App/constants'
import { localStorageCRUD, getPasswordUrl } from '../../util'

import { operationWidgetProps } from 'app/components/DataDrill/abstract/widgetOperating'
export function* getDashboard(action: DashboardActionType) {
if (action.type !== ActionTypes.LOAD_SHARE_DASHBOARD) {
return
Expand Down Expand Up @@ -110,6 +112,7 @@ export function* getDashboard(action: DashboardActionType) {
...rest,
config: dashboardConfigMigrationRecorder(parsedConfig)
}

const formedWidgets = widgets.map((widget) => {
const { config, ...rest } = widget
const parsedConfig: IWidgetConfig = JSON.parse(config)
Expand All @@ -132,6 +135,8 @@ export function* getDashboard(action: DashboardActionType) {
{}
)
yield put(dashboardGetted(dashboard, relations, formedWidgets, formedViews))
const getWidgets: IWidgetFormed = yield select(makeSelectWidgets())
operationWidgetProps.widgetIntoPool(getWidgets)
} catch (err) {
yield put(loadDashboardFail())
errorHandler(err)
Expand Down Expand Up @@ -171,7 +176,8 @@ export function* getWidget(action: DashboardActionType) {
{}
)
yield put(widgetGetted(formedWidget, formedViews))

const getWidgets: IWidgetFormed = yield select(makeSelectWidgets())
operationWidgetProps.widgetIntoPool(getWidgets)
if (resolve) {
resolve(formedWidget, formedViews)
}
Expand Down

0 comments on commit 6e31d92

Please sign in to comment.