123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395 |
- /*
- * <<
- * Davinci
- * ==
- * Copyright (C) 2016 - 2017 EDP
- * ==
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * >>
- */
- import { returnType } from 'utils/redux'
- import { ActionTypes } from './constants'
- import {
- IDashboard,
- IDashboardItem,
- IQueryConditions,
- IDataRequestParams
- } from 'app/containers/Dashboard/types'
- import { IWidgetFormed } from 'app/containers/Widget/types'
- import {
- IShareFormedViews,
- IViewQueryResponse
- } from 'app/containers/View/types'
- import { RenderType } from 'app/containers/Widget/components/Widget'
- import { ControlPanelTypes } from 'app/components/Control/constants'
- import { IDistinctValueReqeustParams } from 'app/components/Control/types'
- export const DashboardActions = {
- getDashboard(token, reject) {
- return {
- type: ActionTypes.LOAD_SHARE_DASHBOARD,
- payload: {
- token,
- reject
- }
- }
- },
- dashboardGetted(
- dashboard: IDashboard,
- items: IDashboardItem[],
- widgets: IWidgetFormed[],
- formedViews: IShareFormedViews
- ) {
- return {
- type: ActionTypes.LOAD_SHARE_DASHBOARD_SUCCESS,
- payload: {
- dashboard,
- items,
- widgets,
- formedViews
- }
- }
- },
- loadDashboardFail() {
- return {
- type: ActionTypes.LOAD_SHARE_DASHBOARD_FAILURE
- }
- },
- getWidget(token, resolve, reject) {
- return {
- type: ActionTypes.LOAD_SHARE_WIDGET,
- payload: {
- token,
- resolve,
- reject
- }
- }
- },
- widgetGetted(widget: IWidgetFormed, formedViews: IShareFormedViews) {
- return {
- type: ActionTypes.LOAD_SHARE_WIDGET_SUCCESS,
- payload: {
- widget,
- formedViews
- }
- }
- },
- getResultset(
- renderType: RenderType,
- itemId: number,
- queryConditions: Partial<IQueryConditions>
- ) {
- return {
- type: ActionTypes.LOAD_SHARE_RESULTSET,
- payload: {
- renderType,
- itemId,
- queryConditions
- }
- }
- },
- resultsetGetted(
- renderType: RenderType,
- itemId: number,
- requestParams: IDataRequestParams,
- result: IViewQueryResponse
- ) {
- return {
- type: ActionTypes.LOAD_SHARE_RESULTSET_SUCCESS,
- payload: {
- renderType,
- itemId,
- requestParams,
- result
- }
- }
- },
- getResultsetFail(itemId, errorMessage) {
- return {
- type: ActionTypes.LOAD_SHARE_RESULTSET_FAILURE,
- payload: {
- itemId,
- errorMessage
- }
- }
- },
- getBatchDataWithControlValues(
- type: ControlPanelTypes,
- relatedItems: number[],
- formValues?: object,
- itemId?: number
- ) {
- return {
- type: ActionTypes.LOAD_BATCH_DATA_WITH_CONTROL_VALUES,
- payload: {
- type,
- relatedItems,
- formValues,
- itemId
- }
- }
- },
- setIndividualDashboard(
- widget: IWidgetFormed,
- formedViews: IShareFormedViews,
- token: string
- ) {
- return {
- type: ActionTypes.SET_INDIVIDUAL_DASHBOARD,
- payload: {
- widget,
- formedViews,
- token
- }
- }
- },
- loadWidgetCsv(itemId, requestParams, token) {
- return {
- type: ActionTypes.LOAD_WIDGET_CSV,
- payload: {
- itemId,
- requestParams,
- token
- }
- }
- },
- widgetCsvLoaded(itemId) {
- return {
- type: ActionTypes.LOAD_WIDGET_CSV_SUCCESS,
- payload: {
- itemId
- }
- }
- },
- loadWidgetCsvFail(itemId) {
- return {
- type: ActionTypes.LOAD_WIDGET_CSV_FAILURE,
- payload: {
- itemId
- }
- }
- },
- loadSelectOptions(
- controlKey: string,
- requestParams: { [viewId: string]: IDistinctValueReqeustParams },
- itemId: number
- ) {
- return {
- type: ActionTypes.LOAD_SELECT_OPTIONS,
- payload: {
- controlKey,
- requestParams,
- itemId
- }
- }
- },
- selectOptionsLoaded(controlKey, values, itemId) {
- return {
- type: ActionTypes.LOAD_SELECT_OPTIONS_SUCCESS,
- payload: {
- controlKey,
- values,
- itemId
- }
- }
- },
- loadSelectOptionsFail(error) {
- return {
- type: ActionTypes.LOAD_SELECT_OPTIONS_FAILURE,
- payload: {
- error
- }
- }
- },
- resizeDashboardItem(itemId) {
- return {
- type: ActionTypes.RESIZE_DASHBOARDITEM,
- payload: {
- itemId
- }
- }
- },
- resizeAllDashboardItem() {
- return {
- type: ActionTypes.RESIZE_ALL_DASHBOARDITEM
- }
- },
- renderChartError(itemId: number, error: Error) {
- return {
- type: ActionTypes.RENDER_CHART_ERROR,
- payload: {
- itemId,
- error
- }
- }
- },
- drillDashboardItem(itemId, drillHistory) {
- return {
- type: ActionTypes.DRILL_DASHBOARDITEM,
- payload: {
- itemId,
- drillHistory
- }
- }
- },
- deleteDrillHistory(itemId, index) {
- return {
- type: ActionTypes.DELETE_DRILL_HISTORY,
- payload: {
- itemId,
- index
- }
- }
- },
- selectDashboardItemChart(itemId, renderType, selectedItems) {
- return {
- type: ActionTypes.SELECT_DASHBOARD_ITEM_CHART,
- payload: {
- itemId,
- renderType,
- selectedItems
- }
- }
- },
- loadDownloadList(shareClinetId, token) {
- return {
- type: ActionTypes.LOAD_DOWNLOAD_LIST,
- payload: {
- shareClinetId,
- token
- }
- }
- },
- downloadListLoaded(list) {
- return {
- type: ActionTypes.LOAD_DOWNLOAD_LIST_SUCCESS,
- payload: {
- list
- }
- }
- },
- loadDownloadListFail(error) {
- return {
- type: ActionTypes.LOAD_DOWNLOAD_LIST_FAILURE,
- payload: {
- error
- }
- }
- },
- downloadFile(id, shareClinetId, token) {
- return {
- type: ActionTypes.DOWNLOAD_FILE,
- payload: {
- id,
- shareClinetId,
- token
- }
- }
- },
- fileDownloaded(id) {
- return {
- type: ActionTypes.DOWNLOAD_FILE_SUCCESS,
- payload: {
- id
- }
- }
- },
- downloadFileFail(error) {
- return {
- type: ActionTypes.DOWNLOAD_FILE_FAILURE,
- payload: {
- error
- }
- }
- },
- initiateDownloadTask(shareClientId: string, itemId: number) {
- return {
- type: ActionTypes.INITIATE_DOWNLOAD_TASK,
- payload: {
- shareClientId,
- itemId
- }
- }
- },
- DownloadTaskInitiated(itemId: number) {
- return {
- type: ActionTypes.INITIATE_DOWNLOAD_TASK_SUCCESS,
- payload: {
- itemId
- }
- }
- },
- initiateDownloadTaskFail(error, itemId: number) {
- return {
- type: ActionTypes.INITIATE_DOWNLOAD_TASK_FAILURE,
- payload: {
- error,
- itemId
- }
- }
- },
- sendShareParams(params) {
- return {
- type: ActionTypes.SEND_SHARE_PARAMS,
- payload: {
- params
- }
- }
- },
- setFullScreenPanelItemId(itemId) {
- return {
- type: ActionTypes.SET_FULL_SCREEN_PANEL_ITEM_ID,
- payload: {
- itemId
- }
- }
- }
- }
- const mockAction = returnType(DashboardActions)
- export type DashboardActionType = typeof mockAction
- export default DashboardActions
|