actions.ts 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * <<
  3. * Davinci
  4. * ==
  5. * Copyright (C) 2016 - 2017 EDP
  6. * ==
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. * >>
  19. */
  20. import { ActionTypes } from './constants'
  21. import { returnType } from 'utils/redux'
  22. import { IDisplayFormed } from 'app/containers/Viz/types'
  23. export const ShareDisplayActions = {
  24. loadDisplay(token: string, resolve, reject) {
  25. return {
  26. type: ActionTypes.LOAD_SHARE_DISPLAY,
  27. payload: {
  28. token,
  29. resolve,
  30. reject
  31. }
  32. }
  33. },
  34. displayLoaded(display: IDisplayFormed, slides, widgets, formedViews) {
  35. return {
  36. type: ActionTypes.LOAD_SHARE_DISPLAY_SUCCESS,
  37. payload: {
  38. display,
  39. slides,
  40. widgets,
  41. formedViews
  42. }
  43. }
  44. },
  45. loadDisplayFail(error) {
  46. return {
  47. type: ActionTypes.LOAD_SHARE_DISPLAY_FAILURE,
  48. payload: {
  49. error
  50. }
  51. }
  52. },
  53. loadLayerData(renderType, slideNumber, layerId, dataToken, requestParams) {
  54. return {
  55. type: ActionTypes.LOAD_LAYER_DATA,
  56. payload: {
  57. renderType,
  58. slideNumber,
  59. layerId,
  60. dataToken,
  61. requestParams
  62. }
  63. }
  64. },
  65. layerDataLoaded(renderType, slideNumber, layerId, data, requestParams) {
  66. return {
  67. type: ActionTypes.LOAD_LAYER_DATA_SUCCESS,
  68. payload: {
  69. renderType,
  70. slideNumber,
  71. layerId,
  72. data,
  73. requestParams
  74. }
  75. }
  76. },
  77. loadLayerDataFail(slideNumber, layerId, error) {
  78. return {
  79. type: ActionTypes.LOAD_LAYER_DATA_FAILURE,
  80. payload: {
  81. slideNumber,
  82. layerId,
  83. error
  84. }
  85. }
  86. }
  87. }
  88. const mockAction = returnType(ShareDisplayActions)
  89. export type ShareDisplayActionType = typeof mockAction
  90. export default ShareDisplayActions