123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329 |
- /*
- * <<
- * 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 { ActionTypes } from './constants'
- import { returnType } from 'utils/redux'
- import {
- ISourceBase,
- ISource,
- SourceResetConnectionProperties,
- ITableColumns,
- ISourceDatabases,
- ICSVMetaInfo,
- IDatabaseTables,
- IDatasourceInfo
- } from './types'
- export const SourceActions = {
- loadSources(projectId: number) {
- return {
- type: ActionTypes.LOAD_SOURCES,
- payload: {
- projectId
- }
- }
- },
- sourcesLoaded(sources: ISourceBase[]) {
- return {
- type: ActionTypes.LOAD_SOURCES_SUCCESS,
- payload: {
- sources
- }
- }
- },
- loadSourcesFail() {
- return {
- type: ActionTypes.LOAD_SOURCES_FAILURE
- }
- },
- loadSourceDetail(sourceId: number, resolve?: (source: ISource) => void) {
- return {
- type: ActionTypes.LOAD_SOURCE_DETAIL,
- payload: {
- sourceId,
- resolve
- }
- }
- },
- sourceDetailLoaded(source: ISource) {
- return {
- type: ActionTypes.LOAD_SOURCE_DETAIL_SUCCESS,
- payload: {
- source
- }
- }
- },
- loadSourceDetailFail() {
- return {
- type: ActionTypes.LOAD_SOURCE_DETAIL_FAIL,
- payload: {}
- }
- },
- addSource(source: ISource, resolve: () => void) {
- return {
- type: ActionTypes.ADD_SOURCE,
- payload: {
- source,
- resolve
- }
- }
- },
- sourceAdded(result: ISourceBase) {
- return {
- type: ActionTypes.ADD_SOURCE_SUCCESS,
- payload: {
- result
- }
- }
- },
- addSourceFail() {
- return {
- type: ActionTypes.ADD_SOURCE_FAILURE,
- payload: {}
- }
- },
- deleteSource(id: number) {
- return {
- type: ActionTypes.DELETE_SOURCE,
- payload: {
- id
- }
- }
- },
- sourceDeleted(id: number) {
- return {
- type: ActionTypes.DELETE_SOURCE_SUCCESS,
- payload: {
- id
- }
- }
- },
- deleteSourceFail() {
- return {
- type: ActionTypes.DELETE_SOURCE_FAILURE,
- payload: {}
- }
- },
- editSource(source: ISource, resolve: () => void) {
- return {
- type: ActionTypes.EDIT_SOURCE,
- payload: {
- source,
- resolve
- }
- }
- },
- sourceEdited(result: ISourceBase) {
- return {
- type: ActionTypes.EDIT_SOURCE_SUCCESS,
- payload: {
- result
- }
- }
- },
- editSourceFail() {
- return {
- type: ActionTypes.EDIT_SOURCE_FAILURE,
- payload: {}
- }
- },
- testSourceConnection(testSource) {
- return {
- type: ActionTypes.TEST_SOURCE_CONNECTION,
- payload: {
- testSource
- }
- }
- },
- sourceConnected() {
- return {
- type: ActionTypes.TEST_SOURCE_CONNECTION_SUCCESS,
- payload: {}
- }
- },
- testSourceConnectionFail() {
- return {
- type: ActionTypes.TEST_SOURCE_CONNECTION_FAILURE,
- payload: {}
- }
- },
- resetSourceConnection(
- properties: SourceResetConnectionProperties,
- resolve: () => void
- ) {
- return {
- type: ActionTypes.RESET_SOURCE_CONNECTION,
- payload: {
- properties,
- resolve
- }
- }
- },
- sourceReset() {
- return {
- type: ActionTypes.RESET_SOURCE_CONNECTION_SUCCESS,
- payload: {}
- }
- },
- resetSourceConnectionFail() {
- return {
- type: ActionTypes.RESET_SOURCE_CONNECTION_FAILURE,
- payload: {}
- }
- },
- validateCsvTableName(
- csvMeta: Pick<ICSVMetaInfo, 'sourceId' | 'tableName' | 'mode'>,
- callback: (errMsg?: string) => void
- ) {
- return {
- type: ActionTypes.VALIDATE_CSV_TABLE_NAME,
- payload: {
- csvMeta,
- callback
- }
- }
- },
- uploadCsvFile(csvMeta: ICSVMetaInfo, resolve: () => void, reject: () => void) {
- return {
- type: ActionTypes.UPLOAD_CSV_FILE,
- payload: {
- csvMeta,
- resolve,
- reject
- }
- }
- },
- loadSourceDatabases(sourceId: number) {
- return {
- type: ActionTypes.LOAD_SOURCE_DATABASES,
- payload: {
- sourceId
- }
- }
- },
- sourceDatabasesLoaded(sourceDatabases: ISourceDatabases) {
- return {
- type: ActionTypes.LOAD_SOURCE_DATABASES_SUCCESS,
- payload: {
- sourceDatabases
- }
- }
- },
- loadSourceDatabasesFail(err) {
- return {
- type: ActionTypes.LOAD_SOURCE_DATABASES_FAILURE,
- payload: {
- err
- }
- }
- },
- loadDatabaseTables(sourceId: number, databaseName: string, resolve?) {
- return {
- type: ActionTypes.LOAD_SOURCE_DATABASE_TABLES,
- payload: {
- sourceId,
- databaseName,
- resolve
- }
- }
- },
- databaseTablesLoaded(databaseTables: IDatabaseTables) {
- return {
- type: ActionTypes.LOAD_SOURCE_DATABASE_TABLES_SUCCESS,
- payload: {
- databaseTables
- }
- }
- },
- loadDatabaseTablesFail(err) {
- return {
- type: ActionTypes.LOAD_SOURCE_DATABASE_TABLES_FAILURE,
- payload: {
- err
- }
- }
- },
- loadTableColumns(
- sourceId: number,
- databaseName: string,
- tableName: string,
- resolve?
- ) {
- return {
- type: ActionTypes.LOAD_SOURCE_TABLE_COLUMNS,
- payload: {
- sourceId,
- databaseName,
- tableName,
- resolve
- }
- }
- },
- tableColumnsLoaded(databaseName: string, tableColumns: ITableColumns) {
- return {
- type: ActionTypes.LOAD_SOURCE_TABLE_COLUMNS_SUCCESS,
- payload: {
- databaseName,
- tableColumns
- }
- }
- },
- loadTableColumnsFail(err) {
- return {
- type: ActionTypes.LOAD_SOURCE_TABLE_COLUMNS_FAILURE,
- payload: {
- err
- }
- }
- },
- loadDatasourcesInfo() {
- return {
- type: ActionTypes.LOAD_DATASOURCES_INFO
- }
- },
- datasourcesInfoLoaded(info: IDatasourceInfo[]) {
- return {
- type: ActionTypes.LOAD_DATASOURCES_INFO_SUCCESS,
- payload: {
- info
- }
- }
- },
- loadDatasourcesInfoFail(err) {
- return {
- type: ActionTypes.LOAD_DATASOURCES_INFO_FAILURE,
- payload: {
- err
- }
- }
- }
- }
- const mockAction = returnType(SourceActions)
- export type SourceActionType = typeof mockAction
- export default SourceActions
|