Skip to content

Commit dd822fc

Browse files
[CYB-164] Pipeline CRUD + Inter-cluster communication (#41)
1 parent 905a4b0 commit dd822fc

File tree

52 files changed

+14084
-232
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+14084
-232
lines changed

flink-cyber/metron-parser-chain/parser-chains-config-service/frontend/parser-chains-client/package-lock.json

Lines changed: 12344 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flink-cyber/metron-parser-chain/parser-chains-config-service/frontend/parser-chains-client/src/app/chain-add-parser-page/chain-add-parser-page.effects.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
* limitations governing your use of the file.
1111
*/
1212

13-
import { Injectable } from '@angular/core';
14-
import { Actions, Effect, ofType } from '@ngrx/effects';
15-
import { Action } from '@ngrx/store';
16-
import { NzMessageService } from 'ng-zorro-antd/message';
17-
import { Observable, of } from 'rxjs';
18-
import { catchError, map, switchMap } from 'rxjs/operators';
13+
import {Injectable} from '@angular/core';
14+
import {Actions, Effect, ofType} from '@ngrx/effects';
15+
import {Action} from '@ngrx/store';
16+
import {NzMessageService} from 'ng-zorro-antd/message';
17+
import {Observable, of} from 'rxjs';
18+
import {catchError, map, switchMap} from 'rxjs/operators';
1919

20-
import { AddParserPageService } from '../services/chain-add-parser-page.service';
20+
import {AddParserPageService} from '../services/chain-add-parser-page.service';
2121

2222
import * as fromActions from './chain-add-parser-page.actions';
2323

@@ -26,7 +26,7 @@ export class AddParserEffects {
2626
constructor(
2727
private actions$: Actions,
2828
private messageService: NzMessageService,
29-
private addParserService: AddParserPageService,
29+
private addParserService: AddParserPageService
3030
) { }
3131

3232
@Effect()

flink-cyber/metron-parser-chain/parser-chains-config-service/frontend/parser-chains-client/src/app/chain-list-page/chain-list-page.actions.ts

Lines changed: 108 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
* limitations governing your use of the file.
1111
*/
1212

13-
import { Action } from '@ngrx/store';
13+
import {Action} from '@ngrx/store';
1414

15-
import { ChainModel, ChainOperationalModel } from './chain.model';
15+
import {ChainModel, ChainOperationalModel} from './chain.model';
1616

1717
export const LOAD_CHAINS = '[Chain List] load all start';
1818
export const LOAD_CHAINS_SUCCESS = '[Chain List] load all success';
@@ -26,8 +26,23 @@ export const SHOW_CREATE_MODAL = '[Chain List] show create modal';
2626
export const HIDE_CREATE_MODAL = '[Chain List] hide create modal';
2727
export const SHOW_DELETE_MODAL = '[Chain List] show delete modal';
2828
export const HIDE_DELETE_MODAL = '[Chain List] hide delete modal';
29+
export const SHOW_RENAME_SELECTED_PIPELINE_MODAL = '[Chain List] show rename selected pipeline modal';
30+
export const HIDE_RENAME_PIPELINE_MODAL = '[Chain List] hide rename pipeline modal';
2931
export const CREATE_CHAIN_SUCCESS = '[Chain List] create item success';
3032
export const CREATE_CHAIN_FAIL = '[Chain List] create item fail';
33+
export const LOAD_PIPELINES = '[Chain List] load pipelines start';
34+
export const LOAD_PIPELINES_SUCCESS = '[Chain List] load pipelines success';
35+
export const LOAD_PIPELINES_FAIL = '[Chain List] load pipelines fail';
36+
export const CREATE_PIPELINE = '[Chain List] create pipeline start';
37+
export const CREATE_PIPELINE_SUCCESS = '[Chain List] create pipeline success';
38+
export const CREATE_PIPELINE_FAIL = '[Chain List] create pipeline fail';
39+
export const RENAME_SELECTED_PIPELINE = '[Chain List] rename selected pipeline start';
40+
export const RENAME_PIPELINE_SUCCESS = '[Chain List] rename pipeline success';
41+
export const RENAME_PIPELINE_FAIL = '[Chain List] rename pipeline fail';
42+
export const DELETE_SELECTED_PIPELINE = '[Chain List] delete selected pipeline start';
43+
export const DELETE_PIPELINE_SUCCESS = '[Chain List] delete pipeline success';
44+
export const DELETE_PIPELINE_FAIL = '[Chain List] delete pipeline fail';
45+
export const PIPELINE_CHANGED = '[Chain List] selected pipeline changed';
3146

3247
export class NoopChainAction implements Action {
3348
readonly type: '';
@@ -92,6 +107,16 @@ export class HideDeleteModalAction implements Action {
92107
constructor() {}
93108
}
94109

110+
export class ShowRenameSelectedPipelineModalAction implements Action {
111+
readonly type = SHOW_RENAME_SELECTED_PIPELINE_MODAL;
112+
constructor() {}
113+
}
114+
115+
export class HideRenamePipelineModalAction implements Action {
116+
readonly type = HIDE_RENAME_PIPELINE_MODAL;
117+
constructor() {}
118+
}
119+
95120
export class CreateChainSuccessAction implements Action {
96121
readonly type = CREATE_CHAIN_SUCCESS;
97122
constructor(public chain: ChainModel) {}
@@ -102,6 +127,71 @@ export class CreateChainFailAction implements Action {
102127
constructor(public error: { message: string }) {}
103128
}
104129

130+
export class LoadPipelinesAction implements Action {
131+
readonly type = LOAD_PIPELINES;
132+
constructor() {}
133+
}
134+
135+
export class LoadPipelinesSuccessAction implements Action {
136+
readonly type = LOAD_PIPELINES_SUCCESS;
137+
constructor(public pipelines: string[]) {}
138+
}
139+
140+
export class LoadPipelinesFailAction implements Action {
141+
readonly type = LOAD_PIPELINES_FAIL;
142+
constructor(public error: { message: string }) {}
143+
}
144+
145+
export class CreatePipelineAction implements Action {
146+
readonly type = CREATE_PIPELINE;
147+
constructor(public pipelineName: string) {}
148+
}
149+
150+
export class CreatePipelineSuccessAction implements Action {
151+
readonly type = CREATE_PIPELINE_SUCCESS;
152+
constructor(public newPipelineName, public pipelines: string[]) {}
153+
}
154+
155+
export class CreatePipelineFailAction implements Action {
156+
readonly type = CREATE_PIPELINE_FAIL;
157+
constructor(public error: { message: string }) {}
158+
}
159+
160+
export class RenameSelectedPipelineAction implements Action {
161+
readonly type = RENAME_SELECTED_PIPELINE;
162+
constructor(public newPipelineName: string) {}
163+
}
164+
165+
export class RenamePipelineSuccessAction implements Action {
166+
readonly type = RENAME_PIPELINE_SUCCESS;
167+
constructor(public newPipelineName, public pipelines: string[]) {}
168+
}
169+
170+
export class RenamePipelineFailAction implements Action {
171+
readonly type = RENAME_PIPELINE_FAIL;
172+
constructor(public error: { message: string }) {}
173+
}
174+
175+
export class DeleteSelectedPipelineAction implements Action {
176+
readonly type = DELETE_SELECTED_PIPELINE;
177+
constructor() {}
178+
}
179+
180+
export class DeletePipelineSuccessAction implements Action {
181+
readonly type = DELETE_PIPELINE_SUCCESS;
182+
constructor(public pipelines: string[]) {}
183+
}
184+
185+
export class DeletePipelineFailAction implements Action {
186+
readonly type = DELETE_PIPELINE_FAIL;
187+
constructor(public error: { message: string }) {}
188+
}
189+
190+
export class PipelineChangedAction implements Action {
191+
readonly type = PIPELINE_CHANGED;
192+
constructor(public newPipelineName: string) {}
193+
}
194+
105195
export type ChainListAction = LoadChainsAction
106196
| LoadChainsSuccessAction
107197
| LoadChainsFailAction
@@ -114,6 +204,21 @@ export type ChainListAction = LoadChainsAction
114204
| CreateChainAction
115205
| ShowCreateModalAction
116206
| HideCreateModalAction
207+
| ShowRenameSelectedPipelineModalAction
208+
| HideRenamePipelineModalAction
117209
| CreateChainSuccessAction
118210
| CreateChainFailAction
119-
| NoopChainAction;
211+
| NoopChainAction
212+
| LoadPipelinesAction
213+
| LoadPipelinesSuccessAction
214+
| LoadPipelinesFailAction
215+
| CreatePipelineAction
216+
| CreatePipelineSuccessAction
217+
| CreatePipelineFailAction
218+
| RenameSelectedPipelineAction
219+
| RenamePipelineSuccessAction
220+
| RenamePipelineFailAction
221+
| DeleteSelectedPipelineAction
222+
| DeletePipelineSuccessAction
223+
| DeletePipelineFailAction
224+
| PipelineChangedAction;

flink-cyber/metron-parser-chain/parser-chains-config-service/frontend/parser-chains-client/src/app/chain-list-page/chain-list-page.component.html

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,24 @@
4242
</nz-form-item>
4343
</form>
4444
</nz-modal>
45+
<nz-modal
46+
[nzVisible]="isPipelineRenameModalVisible$ | async"
47+
nzTitle="Rename Pipeline"
48+
(nzOnCancel)="handlePipelineRenameModalCancel()"
49+
(nzOnOk)="renamePipeline()"
50+
[nzOkDisabled]="!newPipelineName.valid"
51+
[nzOkLoading]="isOkLoading$ | async"
52+
>
53+
<form nz-form *nzModalContent [formGroup]="renamePipelineForm" (ngSubmit)='renamePipeline()' [nzLayout]="'vertical'">
54+
<nz-form-item>
55+
<nz-form-label>Pipeline name:</nz-form-label>
56+
<nz-form-control nzErrorTip="Pipeline Name is Required with at least 3 characters" nzSpan="14">
57+
<input nz-input data-qe-id="pipeline-name" formControlName="pipelineName" type="text" id="pipelineName"
58+
placeholder="{{selectedPipeline$ | async}}">
59+
</nz-form-control>
60+
</nz-form-item>
61+
</form>
62+
</nz-modal>
4563
<nz-modal
4664
*ngIf="deleteChainItem$ | async as deleteChainItem"
4765
[nzVisible]="isChainDeleteModalVisible$ | async"
@@ -59,6 +77,43 @@
5977
</ng-template>
6078
</nz-modal>
6179

80+
<div class="pipeline-select">
81+
<span>Select pipeline:</span>
82+
<nz-select
83+
nzShowSearch
84+
nzAllowClear
85+
[nzDropdownRender]="newPipelineRenderTemplate"
86+
nzPlaceHolder="Select a pipeline"
87+
class="pipeline-select-dropdown pipeline-element"
88+
[nzDisabled]="(pipelineList$ | async) && (pipelineList$ | async).length < 1"
89+
[ngModel]="selectedPipeline$ | async"
90+
(ngModelChange)="pipelineChanged($event)">
91+
<nz-option *ngFor="let item of (pipelineList$ | async)" [nzLabel]="item" [nzValue]="item"></nz-option>
92+
</nz-select>
93+
<ng-template #newPipelineRenderTemplate>
94+
<nz-divider class="add-pipeline-divider"></nz-divider>
95+
<div class="add-pipeline-container">
96+
<input type="text" nz-input #inputElement />
97+
<a class="add-pipeline-button" (click)="createPipeline(inputElement)">
98+
<span nz-icon nzType="plus"></span>
99+
Add pipeline
100+
</a>
101+
</div>
102+
</ng-template>
103+
<button *ngIf="selectedPipeline$ | async"
104+
class="pipeline-element"
105+
nz-tooltip="Delete selected pipeline"
106+
nz-button
107+
nzType="default"
108+
(click)="deletePipeline()">Delete</button>
109+
<button *ngIf="selectedPipeline$ | async"
110+
class="pipeline-element"
111+
nz-tooltip="Rename selected pipeline"
112+
nz-button
113+
nzType="default"
114+
(click)="showPipelineRenameModal()">Rename</button>
115+
</div>
116+
62117
<nz-card nzTitle="Parser Chains" [nzExtra]="AddButton">
63118
<nz-table #basicTable [nzData]="$any(chainDataSorted$ | async)" [nzShowPagination]="false">
64119
<thead>

flink-cyber/metron-parser-chain/parser-chains-config-service/frontend/parser-chains-client/src/app/chain-list-page/chain-list-page.component.scss

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,28 @@
5252
height: 30px;
5353
font-size: 20px;
5454
}
55+
56+
.pipeline-select {
57+
margin: 1rem;
58+
width: 40rem;
59+
display-model: inline-block;
60+
}
61+
62+
.pipeline-element {
63+
margin: 0 0.25rem;
64+
}
65+
66+
.pipeline-select-dropdown {
67+
width: 12rem;
68+
}
69+
.add-pipeline-divider {
70+
margin: 4px 0;
71+
}
72+
.add-pipeline-container {
73+
padding: 8px;
74+
}
75+
.add-pipeline-button {
76+
flex: 0 0 auto;
77+
padding: 8px;
78+
display: block;
79+
}

flink-cyber/metron-parser-chain/parser-chains-config-service/frontend/parser-chains-client/src/app/chain-list-page/chain-list-page.component.ts

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@ import {BehaviorSubject, combineLatest, Observable, of} from 'rxjs';
1818
import {switchMap, take} from 'rxjs/operators';
1919

2020
import * as fromActions from './chain-list-page.actions';
21-
import {LoadChainsAction} from './chain-list-page.actions';
21+
import {LoadPipelinesAction} from './chain-list-page.actions';
2222
import {
2323
ChainListPageState,
2424
getChains,
25-
getCreateModalVisible, getDeleteChain,
25+
getCreateModalVisible,
26+
getDeleteChain,
2627
getDeleteModalVisible,
2728
getLoading,
29+
getPipelineRenameModalVisible,
30+
getPipelines,
31+
getSelectedPipeline,
2832
} from './chain-list-page.reducers';
2933
import {ChainModel, ChainOperationalModel} from './chain.model';
3034
import {NzMessageService} from "ng-zorro-antd/message";
@@ -36,27 +40,35 @@ import {NzMessageService} from "ng-zorro-antd/message";
3640
})
3741
export class ChainListPageComponent implements OnInit {
3842
isChainCreateModalVisible$: Observable<boolean>;
43+
isPipelineRenameModalVisible$: Observable<boolean>;
3944
isOkLoading$: Observable<boolean>;
4045
chains$: Observable<ChainModel[]>;
4146
isChainDeleteModalVisible$: Observable<boolean>;
4247
deleteChainItem$: Observable<ChainModel>;
48+
pipelineList$: Observable<string[]>;
4349
totalRecords = 200;
4450
chainDataSorted$: Observable<ChainModel[]>;
4551
sortDescription$: BehaviorSubject<{ key: string, value: string }> = new BehaviorSubject({key: 'name', value: ''});
4652
newChainForm: UntypedFormGroup;
53+
renamePipelineForm: UntypedFormGroup;
54+
selectedPipeline$: Observable<string>;
55+
4756

4857
constructor(
4958
private store: Store<ChainListPageState>,
5059
private fb: UntypedFormBuilder,
5160
private route: ActivatedRoute,
5261
private messageService: NzMessageService,
5362
) {
54-
store.dispatch(new LoadChainsAction());
63+
store.dispatch(new LoadPipelinesAction());
5564
this.chains$ = store.pipe(select(getChains));
5665
this.isOkLoading$ = store.pipe(select(getLoading));
5766
this.isChainCreateModalVisible$ = store.pipe(select(getCreateModalVisible));
5867
this.isChainDeleteModalVisible$ = store.pipe(select(getDeleteModalVisible));
68+
this.isPipelineRenameModalVisible$ = store.pipe(select(getPipelineRenameModalVisible));
5969
this.deleteChainItem$ = this.store.pipe(select(getDeleteChain));
70+
this.pipelineList$ = this.store.pipe(select(getPipelines));
71+
this.selectedPipeline$ = this.store.pipe(select(getSelectedPipeline));
6072

6173
this.chainDataSorted$ = combineLatest([
6274
this.chains$,
@@ -66,10 +78,18 @@ export class ChainListPageComponent implements OnInit {
6678
);
6779
}
6880

81+
pipelineChanged($event: string) {
82+
this.store.dispatch(new fromActions.PipelineChangedAction($event))
83+
}
84+
6985
get chainName() {
7086
return this.newChainForm.get('chainName') as UntypedFormControl;
7187
}
7288

89+
get newPipelineName() {
90+
return this.renamePipelineForm.get('pipelineName') as UntypedFormControl;
91+
}
92+
7393
showAddChainModal(): void {
7494
this.store.dispatch(new fromActions.ShowCreateModalAction());
7595
}
@@ -126,5 +146,31 @@ export class ChainListPageComponent implements OnInit {
126146
this.newChainForm = this.fb.group({
127147
chainName: new UntypedFormControl('', [Validators.required, Validators.minLength(3)]),
128148
});
149+
this.renamePipelineForm = this.fb.group({
150+
pipelineName: new UntypedFormControl('', [Validators.required, Validators.minLength(3)]),
151+
});
152+
}
153+
154+
showPipelineRenameModal() {
155+
this.store.dispatch(new fromActions.ShowRenameSelectedPipelineModalAction());
156+
}
157+
158+
handlePipelineRenameModalCancel() {
159+
this.store.dispatch(new fromActions.HideRenamePipelineModalAction());
160+
}
161+
162+
createPipeline(inputElement: HTMLInputElement) {
163+
let pipelineName = inputElement.value;
164+
this.store.dispatch(new fromActions.CreatePipelineAction(pipelineName));
165+
}
166+
167+
deletePipeline() {
168+
this.store.dispatch(new fromActions.DeleteSelectedPipelineAction());
169+
}
170+
171+
renamePipeline() {
172+
let newPipelineName = this.newPipelineName.value;
173+
this.renamePipelineForm.reset();
174+
this.store.dispatch(new fromActions.RenameSelectedPipelineAction(newPipelineName));
129175
}
130176
}

0 commit comments

Comments
 (0)