actions.ts 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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 { IUserInfo, ISchedule, JobStatus, JobType } from './components/types'
  23. export const ScheduleActions = {
  24. loadSchedules(projectId: number) {
  25. return {
  26. type: ActionTypes.LOAD_SCHEDULES,
  27. payload: {
  28. projectId
  29. }
  30. }
  31. },
  32. schedulesLoaded(schedules: ISchedule[]) {
  33. return {
  34. type: ActionTypes.LOAD_SCHEDULES_SUCCESS,
  35. payload: {
  36. schedules
  37. }
  38. }
  39. },
  40. loadSchedulesFail() {
  41. return {
  42. type: ActionTypes.LOAD_SCHEDULES_FAILURE,
  43. payload: {}
  44. }
  45. },
  46. loadScheduleDetail(scheduleId: number) {
  47. return {
  48. type: ActionTypes.LOAD_SCHEDULE_DETAIL,
  49. payload: {
  50. scheduleId
  51. }
  52. }
  53. },
  54. scheduleDetailLoaded(schedule: ISchedule) {
  55. return {
  56. type: ActionTypes.LOAD_SCHEDULE_DETAIL_SUCCESS,
  57. payload: {
  58. schedule
  59. }
  60. }
  61. },
  62. loadScheduleDetailFail() {
  63. return {
  64. type: ActionTypes.LOAD_SCHEDULE_DETAIL_FAILURE,
  65. payload: {}
  66. }
  67. },
  68. addSchedule(schedule: ISchedule, resolve: () => void) {
  69. return {
  70. type: ActionTypes.ADD_SCHEDULE,
  71. payload: {
  72. schedule,
  73. resolve
  74. }
  75. }
  76. },
  77. scheduleAdded(result: ISchedule) {
  78. return {
  79. type: ActionTypes.ADD_SCHEDULE_SUCCESS,
  80. payload: {
  81. result
  82. }
  83. }
  84. },
  85. addScheduleFail() {
  86. return {
  87. type: ActionTypes.ADD_SCHEDULE_FAILURE,
  88. payload: {}
  89. }
  90. },
  91. editSchedule(schedule: ISchedule, resolve: () => void) {
  92. return {
  93. type: ActionTypes.EDIT_SCHEDULE,
  94. payload: {
  95. schedule,
  96. resolve
  97. }
  98. }
  99. },
  100. scheduleEdited(result: ISchedule) {
  101. return {
  102. type: ActionTypes.EDIT_SCHEDULE_SUCCESS,
  103. payload: {
  104. result
  105. }
  106. }
  107. },
  108. editScheduleFail() {
  109. return {
  110. type: ActionTypes.EDIT_SCHEDULE_FAILURE,
  111. payload: {}
  112. }
  113. },
  114. deleteSchedule(id: number) {
  115. return {
  116. type: ActionTypes.DELETE_SCHEDULE,
  117. payload: {
  118. id
  119. }
  120. }
  121. },
  122. scheduleDeleted(id: number) {
  123. return {
  124. type: ActionTypes.DELETE_SCHEDULE_SUCCESS,
  125. payload: {
  126. id
  127. }
  128. }
  129. },
  130. deleteScheduleFail() {
  131. return {
  132. type: ActionTypes.DELETE_SCHEDULE_FAILURE,
  133. payload: {}
  134. }
  135. },
  136. changeSchedulesStatus(id: number, currentStatus: JobStatus) {
  137. return {
  138. type: ActionTypes.CHANGE_SCHEDULE_STATUS,
  139. payload: {
  140. id,
  141. currentStatus
  142. }
  143. }
  144. },
  145. scheduleStatusChanged(schedule: ISchedule) {
  146. return {
  147. type: ActionTypes.CHANGE_SCHEDULE_STATUS_SUCCESS,
  148. payload: {
  149. schedule
  150. }
  151. }
  152. },
  153. changeScheduleJobType(jobType: JobType) {
  154. return {
  155. type: ActionTypes.CHANGE_SCHEDULE_JOB_TYPE,
  156. payload: {
  157. jobType
  158. }
  159. }
  160. },
  161. changeSchedulesStatusFail() {
  162. return {
  163. type: ActionTypes.CHANGE_SCHEDULE_STATUS_FAILURE,
  164. payload: {}
  165. }
  166. },
  167. executeScheduleImmediately (id: number, resolve: () => void) {
  168. return {
  169. type: ActionTypes.EXECUTE_SCHEDULE_IMMEDIATELY,
  170. payload: {
  171. id,
  172. resolve
  173. }
  174. }
  175. },
  176. resetScheduleState () {
  177. return {
  178. type: ActionTypes.RESET_SCHEDULE_STATE,
  179. payload: {}
  180. }
  181. },
  182. loadSuggestMails(keyword: string) {
  183. return {
  184. type: ActionTypes.LOAD_SUGGEST_MAILS,
  185. payload: {
  186. keyword
  187. }
  188. }
  189. },
  190. suggestMailsLoaded(mails: IUserInfo[]) {
  191. return {
  192. type: ActionTypes.LOAD_SUGGEST_MAILS_SUCCESS,
  193. payload: {
  194. mails
  195. }
  196. }
  197. },
  198. loadSuggestMailsFail() {
  199. return {
  200. type: ActionTypes.LOAD_SUGGEST_MAILS_FAILURE,
  201. payload: {}
  202. }
  203. },
  204. portalDashboardsLoaded(portalId: number, dashboards: any[]) {
  205. return {
  206. type: ActionTypes.LOAD_PORTAL_DASHBOARDS_SUCCESS,
  207. payload: {
  208. portalId,
  209. dashboards
  210. }
  211. }
  212. },
  213. loadVizs(projectId) {
  214. return {
  215. type: ActionTypes.LOAD_VIZS,
  216. payload: {
  217. projectId
  218. }
  219. }
  220. },
  221. vizsLoaded(result) {
  222. return {
  223. type: ActionTypes.LOAD_VIZS_SUCCESS,
  224. payload: {
  225. result
  226. }
  227. }
  228. },
  229. loadVizsFail() {
  230. return {
  231. type: ActionTypes.LOAD_VIZS_FAILUER
  232. }
  233. }
  234. }
  235. const mockAction = returnType(ScheduleActions)
  236. export type ScheduleActionType = typeof mockAction
  237. export default ScheduleActions