Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fixes topic structure was deleted #280

Merged
merged 6 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions dynamic-mapping-ui/cumulocity.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ export default {
{
from: '../resources/image/Test.svg',
to: 'image/Test.svg'
},
{
from: '../LICENSE',
to: 'LICENSE.txt'
}
],
federation: [
Expand Down
3,902 changes: 1,649 additions & 2,253 deletions dynamic-mapping-ui/package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,30 @@ <h4>Add Mapping</h4>
#addMappingRef
>
<div>
<p
class="text-center text-medium text-16 sticky-top bg-white"
>
<p class="text-center text-medium text-16 sticky-top bg-white">
{{
'Select mapping type for ' +
(direction === Direction.INBOUND ? 'source ' : 'target') | translate
}}
</p>
<div class="p-24 modal-inner-scroll animated fadeIn">
<c8y-list-group class="separator-top">
<c8y-li *ngFor="let q of MappingType | keyvalue">
<c8y-li-radio
<ng-container *ngFor="let q of MappingType | keyvalue">
<c8y-li
*ngIf="
MAPPING_TYPE_DESCRIPTION[q.key].properties[direction]
.directionSupported
"
#liRadioOption1
name="mapping_type_group"
title="{{ q.value }}"
(click)="onSelectMappingType(q.value)"
></c8y-li-radio>
<span>{{ q.value | humanize }}</span>
</c8y-li>
>
<c8y-li-radio
#liRadioOption1
name="mapping_type_group"
title="{{ q.value }}"
(click)="onSelectMappingType(q.value)"
></c8y-li-radio>
<span>{{ q.value | humanize }}</span>
</c8y-li>
</ng-container>
</c8y-list-group>
<!-- <div
#mappingTypes
Expand Down Expand Up @@ -105,9 +106,12 @@ <h4>Add Mapping</h4>
</c8y-form-group>
<!-- <label>Mapping type description</label> -->
<c8y-form-group>
<textarea readonly c8y-textarea-autoresize class="form-control fit-w">{{
mappingTypeDescription
}}</textarea>
<textarea
readonly
c8y-textarea-autoresize
class="form-control fit-w"
>{{ mappingTypeDescription }}</textarea
>
</c8y-form-group>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class MappingStepPropertiesComponent implements OnInit, OnDestroy {
@Input() stepperConfiguration: StepperConfiguration;
@Input() propertyFormly: FormGroup;

@Output() targetTemplateChanged = new EventEmitter<any>();
@Output() targetAPIChanged = new EventEmitter<any>();
@Output() snoopStatusChanged = new EventEmitter<SnoopStatus>();

ValidationError = ValidationError;
Expand Down Expand Up @@ -281,9 +281,11 @@ export class MappingStepPropertiesComponent implements OnInit, OnDestroy {
wrappers: ['c8y-form-field'],
templateOptions: {
label: 'Target API',
options: Object.keys(API).map((key) => {
return { label: key, value: key };
}),
options: Object.keys(API)
.filter((key) => key != API.ALL.name)
.map((key) => {
return { label: key, value: key };
}),
disabled:
this.stepperConfiguration.editorMode == EditorMode.READ_ONLY,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down Expand Up @@ -462,13 +464,7 @@ export class MappingStepPropertiesComponent implements OnInit, OnDestroy {

onTargetAPIChanged(targetAPI) {
this.mapping.targetAPI = targetAPI;
if (this.stepperConfiguration.direction == Direction.INBOUND) {
this.targetTemplateChanged.emit(
SAMPLE_TEMPLATES_C8Y[this.mapping.targetAPI]
);
} else {
this.targetTemplateChanged.emit(getExternalTemplate(this.mapping));
}
this.targetAPIChanged.emit(targetAPI);
}

ngOnDestroy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ <h4 class="text-medium">
[deploymentMapEntry]="deploymentMapEntry"
[stepperConfiguration]="stepperConfiguration"
[propertyFormly]="propertyFormly"
(targetTemplateChanged)="onTemplateChanged($event)"
(targetAPIChanged)="onTargetAPIChanged($event)"
>
</d11r-mapping-properties>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export class MappingStepperComponent implements OnInit, OnDestroy {
private elementRef: ElementRef
) {}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
deploymentMapEntryChange(e) {
// console.log(
// 'New getDeploymentMap',
Expand Down Expand Up @@ -739,16 +740,27 @@ export class MappingStepperComponent implements OnInit, OnDestroy {
}
event.stepper.next();
} else if (this.step == 'Define substitutions') {
this.expandTemplates();
this.getTemplateForm();
const testSourceTemplate = this.editorSourceStep4
? this.editorSourceStep4.get()
: {};
this.editorTestingPayloadTemplateEmitter.emit(testSourceTemplate);
// const testSourceTemplate = this.editorSourceStep4
// ? this.editorSourceStep4.get()
// : {};
// this.editorTestingPayloadTemplateEmitter.emit(testSourceTemplate);
this.editorTestingPayloadTemplateEmitter.emit(this.templateSource);
this.onSelectSubstitution(0);
event.stepper.next();
} else if (this.step == 'Select templates') {
this.templateSource = this.editorSourceStep3.get();
this.templateTarget = this.editorTargetStep3.get();
console.log(
'onNextStep before',
event.step.label,
this.mapping,
this.editorSourceStep3.get(),
this.getCurrentMapping(true),
this.templateSource,
this.templateTarget
);
event.stepper.next();
} else {
event.stepper.next();
Expand All @@ -759,7 +771,15 @@ export class MappingStepperComponent implements OnInit, OnDestroy {
stepper: C8yStepper;
step: CdkStep;
}): Promise<void> {
// console.log('onBackStep', event.step.label, this.mapping);
// console.log(
// 'onBackStep before',
// event.step.label,
// this.mapping,
// this.getCurrentMapping(false),
// this.getCurrentMapping(true),
// this.templateSource,
// this.templateTarget
// );
this.step = event.step.label;
if (this.step == 'Test mapping') {
const editorTestingRequestRef =
Expand All @@ -768,10 +788,24 @@ export class MappingStepperComponent implements OnInit, OnDestroy {
editorTestingRequestRef.setAttribute('schema', undefined);
}
} else if (this.step == 'Select templates') {
this.mapping = this.getCurrentMapping(false);
// this.mapping = this.getCurrentMapping(true);
// this.expandTemplates();
} else if (this.step == 'Define substitutions') {
this.mapping = this.getCurrentMapping(false);
// this.mapping = this.getCurrentMapping(true);
// this.expandTemplates();
}

this.mapping = this.getCurrentMapping(true);
this.expandTemplates();
// console.log(
// 'onBackStep after',
// event.step.label,
// this.mapping,
// this.getCurrentMapping(false),
// this.getCurrentMapping(true),
// this.templateSource,
// this.templateTarget
// );
event.stepper.previous();
}

Expand Down Expand Up @@ -898,8 +932,20 @@ export class MappingStepperComponent implements OnInit, OnDestroy {
this.mapping.snoopStatus = SnoopStatus.STOPPED;
}

async onTargetTemplateChanged(templateTarget) {
this.templateTarget = templateTarget;
async onTargetAPIChanged(changedTargetAPI) {
if (this.stepperConfiguration.direction == Direction.INBOUND) {
this.mapping.target = SAMPLE_TEMPLATES_C8Y[changedTargetAPI];
this.mapping.source = getExternalTemplate(this.mapping);
this.schemaUpdateTarget.emit(
getSchema(this.mapping.targetAPI, this.mapping.direction, true)
);
} else {
this.mapping.source = SAMPLE_TEMPLATES_C8Y[changedTargetAPI];
this.mapping.target = getExternalTemplate(this.mapping);
this.schemaUpdateSource.emit(
getSchema(this.mapping.targetAPI, this.mapping.direction, false)
);
}
}

async updateTestResult(result) {
Expand Down
13 changes: 9 additions & 4 deletions dynamic-mapping-ui/src/shared/connector-configuration.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ export class ConnectorConfigurationService {
);
this.startConnectorConfigurations();
this.sharedConnectorConfigurations$ = this.connectorConfigurations$.pipe(
// tap(() => console.log('Further up I')),
shareReplay(1),
tap(() => console.log('Further up I')),
// shareReplay(1),
// tap(() => console.log('Further up II')),
switchMap((configurations: ConnectorConfiguration[]) => {
// console.log('Further up III');
return combineLatest([
from([configurations]),
from(this.getConnectorStatus())
Expand All @@ -80,7 +82,8 @@ export class ConnectorConfigurationService {
}));
})
);
})
}),
shareReplay(1)
);
}

Expand All @@ -107,7 +110,9 @@ export class ConnectorConfigurationService {
this.connectorConfigurations$ = merge(
from(this.getConnectorConfigurations()),
this.triggerConfigurations$.pipe(
switchMap(() => from(this.getConnectorConfigurations()))
switchMap(() => {
return from(this.getConnectorConfigurations());
})
)
).pipe(
// tap(() => console.log('Something happened')),
Expand Down
6 changes: 3 additions & 3 deletions dynamic-mapping-ui/src/shared/connector-status.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ export class ConnectorStatusService {
private statusLogs$: Observable<ConnectorStatusEvent[]>;

getStatusLogs(): Observable<ConnectorStatusEvent[]> {
console.log('Calling: getStatusLogs');
// console.log('Calling: getStatusLogs');
return this.statusLogs$;
}

async startConnectorStatusLogs() {
console.log('Calling: startConnectorStatusLogs');
// console.log('Calling: startConnectorStatusLogs');
if (!this.statusLogs$) {
await this.initConnectorLogsRealtime();
}
Expand All @@ -99,7 +99,7 @@ export class ConnectorStatusService {
// this._agentId
// );
const filteredConnectorStatus$ = this.triggerLogs$.pipe(
tap((x) => console.log('TriggerLogs In', x)),
// tap((x) => console.log('TriggerLogs In', x)),
switchMap((x) => {
const filter = {
pageSize: 5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ export class JsonEditor2Component implements OnInit, OnDestroy {
@Input() options;
@Input()
set data(value: unknown) {
if (value) {
if (value && Object.keys(value).length != 0) {
this.content['json'] = value;
}
// console.log('on setData', value, this.content);

if (this.editor) {
this.editor.destroy();
Expand Down