Skip to content

Commit 5601253

Browse files
authored
#449 - Remove generic form from details and sensors form (#496)
* #449 - Remove the generic form from details and sensors form
1 parent 4f8e5d9 commit 5601253

27 files changed

+819
-147
lines changed

ui/src/app/app.module.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ import { DurationPartComponent } from './components/workflows/workflow-form/dyna
8787
import { NotificationRuleComponent } from './components/admin/notification-rules/notification-rule/notification-rule.component';
8888
import { NotificationRuleComparisonComponent } from './components/admin/notification-rules/notification-rule-history/notification-rule-comparison/notification-rule-comparison.component';
8989
import { NotificationRuleHistoryComponent } from './components/admin/notification-rules/notification-rule-history/notification-rule-history.component';
90+
import { RecurringComponent } from './components/workflows/workflow-form/sensor/sensor-types/recurring/recurring.component';
91+
import { TimeComponent } from './components/workflows/workflow-form/sensor/sensor-types/time/time.component';
92+
import { KafkaComponent } from './components/workflows/workflow-form/sensor/sensor-types/kafka/kafka.component';
93+
import { AbsaKafkaComponent } from './components/workflows/workflow-form/sensor/sensor-types/absa-kafka/absa-kafka.component';
9094

9195
@NgModule({
9296
declarations: [
@@ -103,6 +107,10 @@ import { NotificationRuleHistoryComponent } from './components/admin/notificatio
103107
WorkflowComponent,
104108
WorkflowDetailsComponent,
105109
SensorComponent,
110+
RecurringComponent,
111+
TimeComponent,
112+
KafkaComponent,
113+
AbsaKafkaComponent,
106114
JobsComponent,
107115
JobComponent,
108116
StringPartComponent,
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!--
2+
~ Copyright 2018 ABSA Group Limited
3+
~
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~ http://www.apache.org/licenses/LICENSE-2.0
8+
~
9+
~ Unless required by applicable law or agreed to in writing, software
10+
~ distributed under the License is distributed on an "AS IS" BASIS,
11+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
~ See the License for the specific language governing permissions and
13+
~ limitations under the License.
14+
-->
15+
16+
<app-string-part
17+
[isShow]="isShow"
18+
[name]="'Topic'"
19+
[valueChanges]="sensorChanges"
20+
[value]="WorkflowEntryUtil.getValue('properties.topic', sensorData)"
21+
[property]="'properties.topic'"
22+
[partValidation]="PartValidationFactory.create(true, undefined, 1)">
23+
</app-string-part>
24+
<app-string-sequence-part
25+
[isShow]="isShow"
26+
[name]="'Kafka servers'"
27+
[valueChanges]="sensorChanges"
28+
[value]="WorkflowEntryUtil.getValue('properties.servers', sensorData)"
29+
[property]="'properties.servers'"
30+
[partValidation]="PartValidationFactory.create(true, undefined, 1)">
31+
</app-string-sequence-part>
32+
<app-guid-part
33+
[isShow]="isShow"
34+
[name]="'Ingestion token'"
35+
[valueChanges]="sensorChanges"
36+
[value]="WorkflowEntryUtil.getValue('properties.ingestionToken', sensorData)"
37+
[property]="'properties.ingestionToken'">
38+
</app-guid-part>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*!
2+
* Copyright 2018 ABSA Group Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright 2018 ABSA Group Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
17+
18+
import { Subject } from 'rxjs';
19+
import { Action } from '@ngrx/store';
20+
import { AbsaKafkaComponent } from './absa-kafka.component';
21+
import { WorkflowEntryModelFactory } from '../../../../../../models/workflowEntry.model';
22+
import { WorkflowSensorChanged } from '../../../../../../stores/workflows/workflows.actions';
23+
24+
describe('AbsaKafkaComponent', () => {
25+
let fixture: ComponentFixture<AbsaKafkaComponent>;
26+
let underTest: AbsaKafkaComponent;
27+
28+
const sensorData = [
29+
{ property: 'propertyOne', value: 'valueOne' },
30+
{ property: 'propertyTwo', value: 'valueTwo' },
31+
{ property: 'switchPartProp', value: 'optionTwo' },
32+
];
33+
34+
beforeEach(
35+
waitForAsync(() => {
36+
TestBed.configureTestingModule({
37+
declarations: [AbsaKafkaComponent],
38+
}).compileComponents();
39+
}),
40+
);
41+
42+
beforeEach(() => {
43+
fixture = TestBed.createComponent(AbsaKafkaComponent);
44+
underTest = fixture.componentInstance;
45+
46+
//set test data
47+
underTest.sensorData = sensorData;
48+
underTest.changes = new Subject<Action>();
49+
});
50+
51+
it('should create', () => {
52+
expect(underTest).toBeTruthy();
53+
});
54+
55+
it(
56+
'should dispatch workflow sensor change when value is received',
57+
waitForAsync(() => {
58+
const usedWorkflowEntry = WorkflowEntryModelFactory.create('property', 'value');
59+
fixture.detectChanges();
60+
fixture.whenStable().then(() => {
61+
const storeSpy = spyOn(underTest.changes, 'next');
62+
underTest.sensorChanges.next(usedWorkflowEntry);
63+
fixture.detectChanges();
64+
65+
fixture.whenStable().then(() => {
66+
expect(storeSpy).toHaveBeenCalledTimes(1);
67+
expect(storeSpy).toHaveBeenCalledWith(new WorkflowSensorChanged(usedWorkflowEntry));
68+
});
69+
});
70+
}),
71+
);
72+
});
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright 2018 ABSA Group Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
17+
import { Subject, Subscription } from 'rxjs';
18+
import { Action } from '@ngrx/store';
19+
import { PartValidationFactory } from '../../../../../../models/workflowFormParts.model';
20+
import { WorkflowEntryModel, WorkflowEntryModelFactory } from '../../../../../../models/workflowEntry.model';
21+
import { WorkflowSensorChanged } from '../../../../../../stores/workflows/workflows.actions';
22+
import { WorkflowEntryUtil } from 'src/app/utils/workflowEntry/workflowEntry.util';
23+
24+
@Component({
25+
selector: 'app-absa-kafka',
26+
templateUrl: './absa-kafka.component.html',
27+
styleUrls: ['./absa-kafka.component.scss'],
28+
})
29+
export class AbsaKafkaComponent implements OnInit, OnDestroy {
30+
@Input() isShow: boolean;
31+
@Input() sensorData: WorkflowEntryModel[];
32+
@Input() changes: Subject<Action>;
33+
34+
WorkflowEntryUtil = WorkflowEntryUtil;
35+
PartValidationFactory = PartValidationFactory;
36+
37+
sensorChanges: Subject<WorkflowEntryModel> = new Subject<WorkflowEntryModel>();
38+
sensorChangesSubscription: Subscription;
39+
40+
constructor() {
41+
// do nothing
42+
}
43+
44+
ngOnInit(): void {
45+
this.sensorChangesSubscription = this.sensorChanges.subscribe((sensorChange) => {
46+
this.changes.next(new WorkflowSensorChanged(WorkflowEntryModelFactory.create(sensorChange.property, sensorChange.value)));
47+
});
48+
}
49+
50+
ngOnDestroy(): void {
51+
!!this.sensorChangesSubscription && this.sensorChangesSubscription.unsubscribe();
52+
}
53+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!--
2+
~ Copyright 2018 ABSA Group Limited
3+
~
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~ http://www.apache.org/licenses/LICENSE-2.0
8+
~
9+
~ Unless required by applicable law or agreed to in writing, software
10+
~ distributed under the License is distributed on an "AS IS" BASIS,
11+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
~ See the License for the specific language governing permissions and
13+
~ limitations under the License.
14+
-->
15+
16+
<app-string-part
17+
[isShow]="isShow"
18+
[name]="'Topic'"
19+
[valueChanges]="sensorChanges"
20+
[value]="WorkflowEntryUtil.getValue('properties.topic', sensorData)"
21+
[property]="'properties.topic'"
22+
[partValidation]="PartValidationFactory.create(true, undefined, 1)">
23+
</app-string-part>
24+
<app-string-sequence-part
25+
[isShow]="isShow"
26+
[name]="'Kafka servers'"
27+
[valueChanges]="sensorChanges"
28+
[value]="WorkflowEntryUtil.getValue('properties.servers', sensorData)"
29+
[property]="'properties.servers'"
30+
[partValidation]="PartValidationFactory.create(true, undefined, 1)">
31+
</app-string-sequence-part>
32+
<app-key-string-value-part
33+
[isShow]="isShow"
34+
[name]="'Match properties'"
35+
[valueChanges]="sensorChanges"
36+
[value]="WorkflowEntryUtil.getValue('properties.matchProperties', sensorData)"
37+
[property]="'properties.matchProperties'"
38+
[partValidation]="PartValidationFactory.create(false, undefined, 1)">
39+
</app-key-string-value-part>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*!
2+
* Copyright 2018 ABSA Group Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright 2018 ABSA Group Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
17+
18+
import { Subject } from 'rxjs';
19+
import { Action } from '@ngrx/store';
20+
import { KafkaComponent } from './kafka.component';
21+
import { WorkflowEntryModelFactory } from '../../../../../../models/workflowEntry.model';
22+
import { WorkflowSensorChanged } from '../../../../../../stores/workflows/workflows.actions';
23+
24+
describe('KafkaComponent', () => {
25+
let fixture: ComponentFixture<KafkaComponent>;
26+
let underTest: KafkaComponent;
27+
28+
const sensorData = [
29+
{ property: 'propertyOne', value: 'valueOne' },
30+
{ property: 'propertyTwo', value: 'valueTwo' },
31+
{ property: 'switchPartProp', value: 'optionTwo' },
32+
];
33+
34+
beforeEach(
35+
waitForAsync(() => {
36+
TestBed.configureTestingModule({
37+
declarations: [KafkaComponent],
38+
}).compileComponents();
39+
}),
40+
);
41+
42+
beforeEach(() => {
43+
fixture = TestBed.createComponent(KafkaComponent);
44+
underTest = fixture.componentInstance;
45+
46+
//set test data
47+
underTest.sensorData = sensorData;
48+
underTest.changes = new Subject<Action>();
49+
});
50+
51+
it('should create', () => {
52+
expect(underTest).toBeTruthy();
53+
});
54+
55+
it(
56+
'should dispatch workflow sensor change when value is received',
57+
waitForAsync(() => {
58+
const usedWorkflowEntry = WorkflowEntryModelFactory.create('property', 'value');
59+
fixture.detectChanges();
60+
fixture.whenStable().then(() => {
61+
const storeSpy = spyOn(underTest.changes, 'next');
62+
underTest.sensorChanges.next(usedWorkflowEntry);
63+
fixture.detectChanges();
64+
65+
fixture.whenStable().then(() => {
66+
expect(storeSpy).toHaveBeenCalledTimes(1);
67+
expect(storeSpy).toHaveBeenCalledWith(new WorkflowSensorChanged(usedWorkflowEntry));
68+
});
69+
});
70+
}),
71+
);
72+
});
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright 2018 ABSA Group Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
17+
import { Subject, Subscription } from 'rxjs';
18+
import { Action } from '@ngrx/store';
19+
import { PartValidationFactory } from '../../../../../../models/workflowFormParts.model';
20+
import { WorkflowEntryModel, WorkflowEntryModelFactory } from '../../../../../../models/workflowEntry.model';
21+
import { WorkflowSensorChanged } from '../../../../../../stores/workflows/workflows.actions';
22+
import { WorkflowEntryUtil } from 'src/app/utils/workflowEntry/workflowEntry.util';
23+
24+
@Component({
25+
selector: 'app-kafka',
26+
templateUrl: './kafka.component.html',
27+
styleUrls: ['./kafka.component.scss'],
28+
})
29+
export class KafkaComponent implements OnInit, OnDestroy {
30+
@Input() isShow: boolean;
31+
@Input() sensorData: WorkflowEntryModel[];
32+
@Input() changes: Subject<Action>;
33+
34+
WorkflowEntryUtil = WorkflowEntryUtil;
35+
PartValidationFactory = PartValidationFactory;
36+
37+
sensorChanges: Subject<WorkflowEntryModel> = new Subject<WorkflowEntryModel>();
38+
sensorChangesSubscription: Subscription;
39+
40+
constructor() {
41+
// do nothing
42+
}
43+
44+
ngOnInit(): void {
45+
this.sensorChangesSubscription = this.sensorChanges.subscribe((sensorChange) => {
46+
this.changes.next(new WorkflowSensorChanged(WorkflowEntryModelFactory.create(sensorChange.property, sensorChange.value)));
47+
});
48+
}
49+
50+
ngOnDestroy(): void {
51+
!!this.sensorChangesSubscription && this.sensorChangesSubscription.unsubscribe();
52+
}
53+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!--
2+
~ Copyright 2018 ABSA Group Limited
3+
~
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~ http://www.apache.org/licenses/LICENSE-2.0
8+
~
9+
~ Unless required by applicable law or agreed to in writing, software
10+
~ distributed under the License is distributed on an "AS IS" BASIS,
11+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
~ See the License for the specific language governing permissions and
13+
~ limitations under the License.
14+
-->

0 commit comments

Comments
 (0)