-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Dlp Jobs page and integration in fields
- Loading branch information
Showing
38 changed files
with
483 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { AnyAction } from 'redux'; | ||
|
||
import { Dispatch } from "react"; | ||
import { getDlpFindingsForField, getJobs, getResult } from 'gateways/dlp'; | ||
|
||
export const fetchDlpJobs = (dispatch: Dispatch<AnyAction>) => { | ||
dispatch({ type: "DLP_JOB_REQUEST" }); | ||
getJobs() | ||
.then(jobs => dispatch({ type: "DLP_JOB_SUCCESS", payload: jobs })) | ||
.catch(error => dispatch({ type: "DLP_JOB_FAILURE", payload: error })) | ||
} | ||
|
||
|
||
export const fetchDlpResults = (dispatch: Dispatch<AnyAction>, resultId: string) => { | ||
dispatch({ type: "DLP_RESULT_REQUEST" }); | ||
getResult(resultId) | ||
.then(result => dispatch({ type: "DLP_RESULT_SUCCESS", payload: result })) | ||
.catch(error => dispatch({ type: "DLP_RESULT_FAILURE", payload: error })) | ||
} | ||
|
||
export const fetchDlpFindingsByField = (dispatch: Dispatch<AnyAction>, fieldId: string) => { | ||
dispatch({ type: "DLP_FINDINGS_BY_FIELD_REQUEST" }); | ||
getDlpFindingsForField(fieldId) | ||
.then(findings => dispatch({ type: "DLP_FINDINGS_BY_FIELD_SUCCESS", payload: { id: fieldId, findings } })) | ||
.catch(error => dispatch({ type: "DLP_FINDINGS_BY_FIELD_FAILURE", payload: error })) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { URL_BASE } from "index"; | ||
import { DlpFinding, DlpJob, DlpJobResult } from "types/dlp"; | ||
|
||
export const getJobs = (): Promise<DlpJob[]> => fetch(`${URL_BASE}/api/dlp`).then(response => response.json()); | ||
|
||
export const getResult = (resultId: string): Promise<DlpJobResult> => fetch(`${URL_BASE}/api/dlp/results/${resultId}`).then(response => response.json()); | ||
|
||
export const getDlpFindingsForField= (fieldId: string): Promise<DlpFinding[]> => fetch(`${URL_BASE}/api/fields/${fieldId}/dlp`).then(response => response.json()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { FetchDlpFindingsByFieldActionTypes, FetchDlpJobResultActionTypes, FetchDlpJobsActionTypes } from "types/actions/Dlp"; | ||
import { DlpFinding, DlpJob, DlpJobResult } from "types/dlp"; | ||
|
||
|
||
export const dlpJobs = (state: DlpJob[] = [], action: FetchDlpJobsActionTypes) => { | ||
switch (action.type) { | ||
case "DLP_JOB_SUCCESS": | ||
return action.payload; | ||
default: | ||
return state; | ||
} | ||
} | ||
|
||
export const dlpResults = (state: {[k: string]: DlpJobResult} = {}, action: FetchDlpJobResultActionTypes) => { | ||
switch (action.type) { | ||
case "DLP_RESULT_SUCCESS": | ||
return {...state, [action.payload.id]: action.payload}; | ||
default: | ||
return state; | ||
} | ||
} | ||
|
||
|
||
export const dlpFindingsByField = (state: {[k: string]: DlpFinding[]} = {}, action: FetchDlpFindingsByFieldActionTypes) => { | ||
switch (action.type) { | ||
case "DLP_FINDINGS_BY_FIELD_SUCCESS": | ||
return {...state, [action.payload.id]: action.payload.findings}; | ||
default: | ||
return state; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { DlpFinding, DlpJob, DlpJobResult } from "types/dlp"; | ||
|
||
interface FetchDlpJobsRequestAction { | ||
type: "DLP_JOB_REQUEST"; | ||
} | ||
|
||
interface FetchDlpJobsSuccessAction { | ||
type: "DLP_JOB_SUCCESS"; | ||
payload: DlpJob[]; | ||
} | ||
|
||
interface FetchDlpJobsFailureAction { | ||
type: "DLP_JOB_FAILURE"; | ||
payload: string; | ||
} | ||
|
||
export type FetchDlpJobsActionTypes = FetchDlpJobsRequestAction | FetchDlpJobsSuccessAction | FetchDlpJobsFailureAction; | ||
|
||
|
||
interface FetchDlpJobResultRequestAction { | ||
type: "DLP_RESULT_REQUEST"; | ||
} | ||
|
||
interface FetchDlpJobResultSuccessAction { | ||
type: "DLP_RESULT_SUCCESS"; | ||
payload: DlpJobResult; | ||
} | ||
|
||
interface FetchDlpJobResultFailureAction { | ||
type: "DLP_RESULT_FAILURE"; | ||
payload: string; | ||
} | ||
|
||
export type FetchDlpJobResultActionTypes = FetchDlpJobResultRequestAction | FetchDlpJobResultSuccessAction | FetchDlpJobResultFailureAction; | ||
|
||
|
||
interface FetchDlpFindingsByFieldRequestAction { | ||
type: "DLP_FINDINGS_BY_FIELD_REQUEST"; | ||
} | ||
|
||
interface FetchDlpFindingsByFieldSuccessAction { | ||
type: "DLP_FINDINGS_BY_FIELD_SUCCESS"; | ||
payload: { | ||
id: string; | ||
findings: DlpFinding[]; | ||
}; | ||
} | ||
|
||
interface FetchDlpFindingsByFieldFailureAction { | ||
type: "DLP_FINDINGS_BY_FIELD_FAILURE"; | ||
payload: string; | ||
} | ||
|
||
export type FetchDlpFindingsByFieldActionTypes = FetchDlpFindingsByFieldRequestAction | FetchDlpFindingsByFieldSuccessAction | FetchDlpFindingsByFieldFailureAction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { Field } from '../../types'; | ||
import { Field } from '../types'; | ||
|
||
import * as types from './Types'; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.