Skip to content

Commit 829e860

Browse files
author
Ihar
committed
feat: next batton accross configurator for reader writer[5018]
1 parent 858864a commit 829e860

File tree

9 files changed

+369
-17
lines changed

9 files changed

+369
-17
lines changed

frontend/src/app/modules/policy-engine/policy-viewer/blocks/global-events-reader-block/global-events-reader-block.component.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,19 @@
150150
(add)="confirmAddTopicModal()"
151151
>
152152
</app-add-event-topic-modal>
153+
154+
<div class="progress-footer" id="block-progress-footer" *ngIf="showNextButton">
155+
<div></div>
156+
<div>
157+
<button
158+
type="button"
159+
pButton
160+
class="p-button"
161+
label="Next"
162+
(click)="onNext()"
163+
[disabled]="loading"
164+
form="roles-form"
165+
>
166+
</button>
167+
</div>
168+
</div>

frontend/src/app/modules/policy-engine/policy-viewer/blocks/global-events-reader-block/global-events-reader-block.component.scss

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,3 +296,72 @@
296296
border-color: var(--color-primary, #4169E2);
297297
box-shadow: 0 0 0 2px rgba(65, 105, 226, 0.18);
298298
}
299+
300+
.gew-card {
301+
margin-bottom: 72px;
302+
}
303+
304+
.progress-footer {
305+
padding: 12px 48px;
306+
display: flex;
307+
justify-content: space-between;
308+
position: fixed;
309+
right: 0;
310+
bottom: 0;
311+
width: 100%;
312+
border-top: 1px solid var(--color-grey-3, #E1E7EF);
313+
background: #FFF;
314+
padding-left: calc(var(--header-width-expand) + 48px);
315+
transition: padding-left 0.125s ease-in-out;
316+
z-index: 999;
317+
}
318+
319+
:host ::ng-deep {
320+
.progress-footer {
321+
.p-button {
322+
padding: 5px 12px;
323+
min-width: 120px;
324+
border-radius: 8px;
325+
background: var(--color-primary, #0031ff);
326+
327+
.p-button-label {
328+
font-family: Inter;
329+
font-size: 14px;
330+
font-style: normal;
331+
font-weight: 500;
332+
line-height: 30px;
333+
color: var(--color-grey-white, #FFF);
334+
}
335+
336+
&:disabled {
337+
border-radius: 8px;
338+
border: 1px solid var(--color-grey-3, #E1E7EF);
339+
background: var(--color-grey-1, #F9FAFC);
340+
341+
.p-button-label {
342+
font-family: Inter;
343+
font-size: 14px;
344+
font-style: normal;
345+
font-weight: 500;
346+
line-height: 30px;
347+
color: var(--color-grey-4, #AAB7C4);
348+
}
349+
}
350+
}
351+
352+
.p-button-outlined {
353+
border-radius: 8px;
354+
border: 1px solid var(--color-secondary, #CDDDFD);
355+
background: var(--color-grey-white, #FFF);
356+
357+
.p-button-label {
358+
font-family: Inter;
359+
font-size: 14px;
360+
font-style: normal;
361+
font-weight: 500;
362+
line-height: 30px;
363+
color: var(--color-primary, #0031ff);
364+
}
365+
}
366+
}
367+
}

frontend/src/app/modules/policy-engine/policy-viewer/blocks/global-events-reader-block/global-events-reader-block.component.ts

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,10 @@ export interface GlobalEventsReaderGetDataResponse {
6363
streams: GlobalEventsStreamRow[];
6464
defaultTopicIds?: string[];
6565

66+
showNextButton?: boolean;
6667
documentTypeOptions?: Array<{ label: string; value: DocumentType }>;
6768
}
6869

69-
export interface GlobalEventsStreamRow {
70-
filterFieldsByBranch?: Record<string, Record<string, string>>;
71-
branchDocumentTypeByBranch?: Record<string, DocumentType>;
72-
}
73-
7470
@Component({
7571
selector: 'global-events-reader-block',
7672
templateUrl: './global-events-reader-block.component.html',
@@ -99,19 +95,18 @@ export class GlobalEventsReaderBlockComponent implements OnInit, OnDestroy {
9995

10096
public defaultTopicIds: string[] = [];
10197

102-
// Modal: Add Topic
10398
public addTopicModalOpen: boolean = false;
10499
public addTopicModalTopicId: string = '';
105100
public addTopicModalError: string = '';
106101

107-
public createTopicModalOpen: boolean = false;
108-
109102
private socket: any;
110103
private filtersDialogRef: DynamicDialogRef | null = null;
111104
private filtersDialogCloseSub: Subscription | null = null;
112105

113106
public documentTypeOptions: Array<{ label: string; value: DocumentType }> = [];
114107

108+
public showNextButton: boolean = false;
109+
115110
private confirmDialogRef: DynamicDialogRef | null = null;
116111

117112
constructor(
@@ -187,6 +182,8 @@ export class GlobalEventsReaderBlockComponent implements OnInit, OnDestroy {
187182
}
188183

189184
private applyData(data: GlobalEventsReaderGetDataResponse | null): void {
185+
this.showNextButton = Boolean(data?.showNextButton);
186+
190187
if (!data) {
191188
this.rows = [];
192189
this.readonly = true;
@@ -594,4 +591,37 @@ export class GlobalEventsReaderBlockComponent implements OnInit, OnDestroy {
594591
},
595592
);
596593
}
594+
595+
public onNext(): void {
596+
if (this.static) {
597+
return;
598+
}
599+
if (!this.policyId || !this.id) {
600+
return;
601+
}
602+
if (this.loading) {
603+
return;
604+
}
605+
606+
this.loading = true;
607+
608+
const payload = {
609+
operation: 'Next',
610+
};
611+
612+
this.policyEngineService
613+
.setBlockData(this.id, this.policyId, payload)
614+
.pipe(
615+
finalize(() => {
616+
this.loading = false;
617+
this.changeDetector.detectChanges();
618+
}),
619+
)
620+
.subscribe(
621+
() => {},
622+
(e) => {
623+
console.error(e?.error || e);
624+
},
625+
);
626+
}
597627
}

frontend/src/app/modules/policy-engine/policy-viewer/blocks/global-events-writer-block/global-events-writer-block.component.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,19 @@
114114
(add)="confirmAddTopicModal($event)"
115115
>
116116
</app-add-event-topic-modal>
117+
118+
<div class="progress-footer" id="block-progress-footer" *ngIf="showNextButton">
119+
<div></div>
120+
<div>
121+
<button
122+
type="button"
123+
pButton
124+
class="p-button"
125+
label="Next"
126+
(click)="onNext()"
127+
[disabled]="loading"
128+
form="roles-form"
129+
>
130+
</button>
131+
</div>
132+
</div>

frontend/src/app/modules/policy-engine/policy-viewer/blocks/global-events-writer-block/global-events-writer-block.component.scss

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,72 @@
195195
white-space: nowrap;
196196
font-family: var(--font-family-inter, 'Inter', sans-serif);
197197
}
198+
199+
.gew-card {
200+
margin-bottom: 72px;
201+
}
202+
203+
.progress-footer {
204+
padding: 12px 48px;
205+
display: flex;
206+
justify-content: space-between;
207+
position: fixed;
208+
right: 0;
209+
bottom: 0;
210+
width: 100%;
211+
border-top: 1px solid var(--color-grey-3, #E1E7EF);
212+
background: #FFF;
213+
padding-left: calc(var(--header-width-expand) + 48px);
214+
transition: padding-left 0.125s ease-in-out;
215+
z-index: 999;
216+
}
217+
218+
:host ::ng-deep {
219+
.progress-footer {
220+
.p-button {
221+
padding: 5px 12px;
222+
min-width: 120px;
223+
border-radius: 8px;
224+
background: var(--color-primary, #0031ff);
225+
226+
.p-button-label {
227+
font-family: Inter;
228+
font-size: 14px;
229+
font-style: normal;
230+
font-weight: 500;
231+
line-height: 30px;
232+
color: var(--color-grey-white, #FFF);
233+
}
234+
235+
&:disabled {
236+
border-radius: 8px;
237+
border: 1px solid var(--color-grey-3, #E1E7EF);
238+
background: var(--color-grey-1, #F9FAFC);
239+
240+
.p-button-label {
241+
font-family: Inter;
242+
font-size: 14px;
243+
font-style: normal;
244+
font-weight: 500;
245+
line-height: 30px;
246+
color: var(--color-grey-4, #AAB7C4);
247+
}
248+
}
249+
}
250+
251+
.p-button-outlined {
252+
border-radius: 8px;
253+
border: 1px solid var(--color-secondary, #CDDDFD);
254+
background: var(--color-grey-white, #FFF);
255+
256+
.p-button-label {
257+
font-family: Inter;
258+
font-size: 14px;
259+
font-style: normal;
260+
font-weight: 500;
261+
line-height: 30px;
262+
color: var(--color-primary, #0031ff);
263+
}
264+
}
265+
}
266+
}

frontend/src/app/modules/policy-engine/policy-viewer/blocks/global-events-writer-block/global-events-writer-block.component.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export interface WriterGetDataResponse {
3030
active: boolean;
3131
}>;
3232

33+
showNextButton?: boolean;
3334
defaultTopicIds?: string[];
3435
documentTypeOptions?: Array<{ label: string; value: GlobalDocumentType }>;
3536
}
@@ -71,6 +72,8 @@ export class GlobalEventsWriterBlockComponent implements OnInit, OnDestroy {
7172

7273
public defaultTopicIds: string[] = [];
7374

75+
public showNextButton: boolean = false;
76+
7477
private confirmDialogRef: DynamicDialogRef | null = null;
7578

7679
constructor(
@@ -147,6 +150,7 @@ export class GlobalEventsWriterBlockComponent implements OnInit, OnDestroy {
147150
private applyData(data: WriterGetDataResponse | null): void {
148151
this.defaultTopicIds = (data?.defaultTopicIds || []).map((t) => String(t).trim());
149152

153+
this.showNextButton = Boolean(data?.showNextButton);
150154
this.documentTypeOptions = data?.documentTypeOptions || [];
151155

152156
this.streams = (data?.streams || []).map((s) => {
@@ -397,4 +401,38 @@ export class GlobalEventsWriterBlockComponent implements OnInit, OnDestroy {
397401
},
398402
);
399403
}
404+
405+
public onNext(): void {
406+
if (this.static) {
407+
return;
408+
}
409+
if (!this.policyId || !this.id) {
410+
return;
411+
}
412+
if (this.loading) {
413+
return;
414+
}
415+
416+
this.loading = true;
417+
418+
const payload = {
419+
operation: 'Next' as any,
420+
streams: [],
421+
};
422+
423+
this.policyEngineService
424+
.setBlockData(this.id, this.policyId, payload)
425+
.pipe(
426+
finalize(() => {
427+
this.loading = false;
428+
this.changeDetector.detectChanges();
429+
}),
430+
)
431+
.subscribe(
432+
() => {},
433+
(e) => {
434+
console.error(e?.error || e);
435+
},
436+
);
437+
}
400438
}

guardian-service/src/policy-engine/block-about.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,6 +1547,13 @@ export const BlockAbout = {
15471547
],
15481548
'defaultEvent': true,
15491549
'properties': [
1550+
{
1551+
'name': 'showNextButton',
1552+
'label': 'Show Next button',
1553+
'title': 'Show button to move to next block with cached payload',
1554+
'type': 'Checkbox',
1555+
'default': false,
1556+
},
15501557
{
15511558
'name': 'topicIds',
15521559
'label': 'Global topics',
@@ -1595,6 +1602,13 @@ export const BlockAbout = {
15951602
'output': null,
15961603
'defaultEvent': true,
15971604
'properties': [
1605+
{
1606+
'name': 'showNextButton',
1607+
'label': 'Show Next button',
1608+
'title': 'Show button to move to next block with cached payload',
1609+
'type': 'Checkbox',
1610+
'default': false,
1611+
},
15981612
{
15991613
'name': 'eventTopics',
16001614
'label': 'Event topics',

0 commit comments

Comments
 (0)