Skip to content

Commit

Permalink
add connectors in as navigation nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
ck-c8y committed Jan 2, 2025
1 parent d529344 commit d6f9b1e
Show file tree
Hide file tree
Showing 29 changed files with 468 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public ResponseEntity<HttpStatus> createConnectorConfiguration(
}
}

@GetMapping(value = "/connector/instances",produces = MediaType.APPLICATION_JSON_VALUE)
@GetMapping(value = "/connector/instance",produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<ConnectorConfiguration>> getConnectionConfigurations(@RequestParam(required = false) String name) {
String tenant = contextService.getContext().getTenant();
log.debug("Tenant {} - Get connection details", tenant);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ private void registerExtensionInProcessor(String tenant, String id, String exten
.newInstance();
// springUtil.registerBean(key, clazz);
extensionEntry.setExtensionImplSource(extensionImpl);
extensionEntry.setExtensionType(ExtensionType.PROCESSOR_EXTENSION_SOURCE);
extensionEntry.setExtensionType(ExtensionType.EXTENSION_SOURCE);
log.debug("Tenant {} - Successfully registered extensionImplSource : {} for key: {}",
tenant,
newExtensions.getProperty(key),
Expand All @@ -637,7 +637,7 @@ private void registerExtensionInProcessor(String tenant, String id, String exten
// springUtil.registerBean(key, clazz);
extensionEntry.setExtensionImplTarget(extensionImpl);
// overwrite type since it implements both
extensionEntry.setExtensionType(ExtensionType.PROCESSOR_EXTENSION_SOURCE_TARGET);
extensionEntry.setExtensionType(ExtensionType.EXTENSION_SOURCE_TARGET);
log.debug("Tenant {} - Successfully registered extensionImplTarget : {} for key: {}",
tenant,
newExtensions.getProperty(key),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ MappingType.JSON, new JSONProcessorInbound(this),
MappingType.FLAT_FILE, new FlatFileProcessorInbound(this),
MappingType.GENERIC_BINARY, new GenericBinaryProcessorInbound(this),
MappingType.PROTOBUF_STATIC, new StaticProtobufProcessor(this),
MappingType.PROCESSOR_EXTENSION_SOURCE, extensibleProcessor,
MappingType.PROCESSOR_EXTENSION_SOURCE_TARGET, extensibleProcessor);
MappingType.EXTENSION_SOURCE, extensibleProcessor,
MappingType.EXTENSION_SOURCE_TARGET, extensibleProcessor);
}

public AConnectorClient createConnectorClient(ConnectorConfiguration connectorConfiguration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
package dynamic.mapping.model;

public enum ExtensionType {
PROCESSOR_EXTENSION_SOURCE,
PROCESSOR_EXTENSION_SOURCE_TARGET
EXTENSION_SOURCE,
EXTENSION_SOURCE_TARGET
}
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ static public ArrayList<ValidationError> isSubstitutionValid(Mapping mapping) {
.count();

if (mapping.snoopStatus != SnoopStatus.ENABLED && mapping.snoopStatus != SnoopStatus.STARTED
&& !mapping.mappingType.equals(MappingType.PROCESSOR_EXTENSION_SOURCE)
&& !mapping.mappingType.equals(MappingType.PROCESSOR_EXTENSION_SOURCE_TARGET)
&& !mapping.mappingType.equals(MappingType.EXTENSION_SOURCE)
&& !mapping.mappingType.equals(MappingType.EXTENSION_SOURCE_TARGET)
&& !mapping.mappingType.equals(MappingType.PROTOBUF_STATIC)
&& !mapping.direction.equals(Direction.OUTBOUND)) {
if (count > 1) {
Expand Down Expand Up @@ -416,7 +416,7 @@ static Collection<ValidationError> areJSONTemplatesValid(Mapping mapping) {
result.add(ValidationError.Source_Template_Must_Be_Valid_JSON);
}

if (!mapping.mappingType.equals(MappingType.PROCESSOR_EXTENSION_SOURCE)
if (!mapping.mappingType.equals(MappingType.EXTENSION_SOURCE)
&& !mapping.mappingType.equals(MappingType.PROTOBUF_STATIC)) {
try {
new JSONObject(mapping.targetTemplate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public enum MappingType {
FLAT_FILE("FLAT_FILE"),
GENERIC_BINARY("GENERIC_BINARY"),
PROTOBUF_STATIC("PROTOBUF_STATIC"),
PROCESSOR_EXTENSION_SOURCE("PROCESSOR_EXTENSION_SOURCE"),
PROCESSOR_EXTENSION_SOURCE_TARGET("PROCESSOR_EXTENSION_SOURCE_TARGET");
EXTENSION_SOURCE("EXTENSION_SOURCE"),
EXTENSION_SOURCE_TARGET("EXTENSION_SOURCE_TARGET");

public final String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
~ @authors Christof Strack
-->

<c8y-title>Configuration</c8y-title>
<c8y-title>Connectors</c8y-title>
<c8y-action-bar-item [placement]="'right'">
<button class="btn btn-link" title="{{ 'Add connector' | translate }}" (click)="onConfigurationAdd()">
<i c8yIcon="connected"></i>
Expand All @@ -33,16 +33,29 @@
</button>
</c8y-action-bar-item>

<c8y-breadcrumb>
<c8y-breadcrumb-item
[icon]="'cog'"
[label]="'Configuration' | translate"
[path]="'sag-ps-pkg-dynamic-mapping/node3/serviceConfiguration'"
>
</c8y-breadcrumb-item>
<c8y-breadcrumb-item
[icon]="''"
[label]="'Connectors' | translate"
></c8y-breadcrumb-item>
</c8y-breadcrumb>

<div class="card content-fullpage d-grid grid__row--6-6--md">
<div class="card card--grid card--grid__inner-scroll">
<div class="p-l-16 p-r-16">
<d11r-mapping-connector-configuration #connectorConfigurationBroker
[selectable]="false"></d11r-mapping-connector-configuration>
</div>
</div>
<div class="card card--grid card--grid__inner-scroll">
<!-- <div class="card card--grid card--grid__inner-scroll">
<div class="p-l-16 p-r-16">
<d11r-mapping-connector-log></d11r-mapping-connector-log>
</div>
</div>
</div> -->
</div>
16 changes: 14 additions & 2 deletions dynamic-mapping-ui/src/connector/connector-configuration.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@

import { NgModule } from '@angular/core';
import { CoreModule, hookRoute } from '@c8y/ngx-components';
import { SharedModule } from '../shared';
import { connectorResolver, SharedModule } from '../shared';
import { ConnectorConfigurationComponent } from './connector-configuration.component';
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
import { NODE3 } from '../shared/mapping/util';
import { ConnectorDetailsComponent } from '../shared/connector-details/connector-details.component';

@NgModule({
declarations: [ConnectorConfigurationComponent],
Expand All @@ -38,7 +39,18 @@ import { NODE3 } from '../shared/mapping/util';
providers: [
hookRoute({
path: `sag-ps-pkg-dynamic-mapping/${NODE3}/connectorConfiguration`,
component: ConnectorConfigurationComponent,
children: [
{
path: '',
pathMatch: 'full',
component: ConnectorConfigurationComponent
},
{
path: 'details/:identifier',
component: ConnectorDetailsComponent,
resolve: { connector: connectorResolver }
}
]
})
]
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
} from '@c8y/client';
import { ProcessingContext } from '../processor/processor.model';
import { HttpStatusCode } from '@angular/common/http';
import { randomIdAsString } from 'src/mapping/shared/util';
import { randomIdAsString } from '../../../mapping/shared/util';

@Injectable({ providedIn: 'root' })
export class FacadeOperationService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { HttpStatusCode } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { IdReference, IFetchResponse, IManagedObject, IResult } from '@c8y/client';
import * as _ from 'lodash';
import { randomIdAsString } from 'src/mapping/shared/util';
import { randomIdAsString } from '../../../mapping/shared/util';

@Injectable({ providedIn: 'root' })
export class MockInventoryService {
Expand Down
8 changes: 4 additions & 4 deletions dynamic-mapping-ui/src/mapping/grid/mapping.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -532,17 +532,17 @@ export class MappingComponent implements OnInit, OnDestroy {
...mapping,
sourceTemplate: sampleSource
};
} else if (this.mappingType == MappingType.PROCESSOR_EXTENSION_SOURCE) {
} else if (this.mappingType == MappingType.EXTENSION_SOURCE) {
mapping.extension = {
extensionName: undefined,
eventName: undefined,
extensionType: ExtensionType.PROCESSOR_EXTENSION_SOURCE,
extensionType: ExtensionType.EXTENSION_SOURCE,
};
} else if (this.mappingType == MappingType.PROCESSOR_EXTENSION_SOURCE_TARGET) {
} else if (this.mappingType == MappingType.EXTENSION_SOURCE_TARGET) {
mapping.extension = {
extensionName: undefined,
eventName: undefined,
extensionType: ExtensionType.PROCESSOR_EXTENSION_SOURCE_TARGET,
extensionType: ExtensionType.EXTENSION_SOURCE_TARGET,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import { StatusEnabledRendererComponent } from './renderer/status-enabled-render
import { ConnectorStatusRendererComponent } from './renderer/connector-status.renderer.component';
import { CheckedRendererComponent } from './renderer/checked-renderer.component';
import { LabelRendererComponent } from '../component/renderer/label.renderer.component';
import { ConnectorDetailCellRendererComponent } from './renderer/connector-link.renderer.component';

@Component({
selector: 'd11r-mapping-connector-configuration',
Expand Down Expand Up @@ -165,6 +166,7 @@ export class ConnectorGridComponent implements OnInit, AfterViewInit {
filterable: false,
sortOrder: 'asc',
visible: true,
cellRendererComponent: ConnectorDetailCellRendererComponent,
gridTrackSize: '30%'
},
{
Expand Down Expand Up @@ -398,7 +400,7 @@ export class ConnectorGridComponent implements OnInit, AfterViewInit {
gettext('Failed to delete connector configuration')
);
}
await this.reloadData();
this.refresh();
}
confirmDeletionModalRef.hide();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
* @authors Christof Strack
*/

import { inject } from "@angular/core";
import { ResolveFn } from "@angular/router";
import { ConnectorConfigurationService } from "../service/connector-configuration.service";

export enum ConnectorPropertyType {
ID_STRING_PROPERTY = 'ID_STRING_PROPERTY',
STRING_PROPERTY = 'STRING_PROPERTY',
Expand Down Expand Up @@ -60,3 +64,9 @@ export interface ConnectorSpecification {
supportsWildcardInTopic: boolean;
properties: { [name: string]: ConnectorProperty };
}

export const connectorResolver: ResolveFn<ConnectorConfiguration> = (route) => {
const connectorConfigurationService = inject(ConnectorConfigurationService);
const identifier = route.paramMap.get('identifier');
return connectorConfigurationService.getConnectorConfiguration(identifier);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2022 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA,
* and/or its subsidiaries and/or its affiliates and/or their licensors.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @authors Christof Strack
*/
import { Component } from '@angular/core';
import { CellRendererContext } from '@c8y/ngx-components';

/**
* The example component for custom cell renderer.
* It gets `context` with the current row item and the column.
* Additionally, a service is injected to provide a helper method.
* The template displays the icon and the label with additional styling.
*/
@Component({
template: `
<a
class="interact"
[title]="context.item.name"
*ngIf="context?.property?.callback; else router"
(click)="context.property.callback(context.item)"
>
{{ context.item.name }}
</a>
<ng-template #router>
<a class="interact" [title]="context.item.name" [routerLink]="['details/' + context.item.identifier]">
{{ context.item.name }}
</a>
</ng-template>
`
})
export class ConnectorDetailCellRendererComponent {
constructor(public context: CellRendererContext) { }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<!--
~ Copyright (c) 2022 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA,
~ and/or its subsidiaries and/or its affiliates and/or their licensors.
~
~ SPDX-License-Identifier: Apache-2.0
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
~ @authors Christof Strack
-->
<c8y-title>Connectors</c8y-title>
<c8y-breadcrumb>
<c8y-breadcrumb-item
[icon]="'cog'"
[label]="'Configuration' | translate"
[path]="'sag-ps-pkg-dynamic-mapping/node3/serviceConfiguration'"
>
</c8y-breadcrumb-item>
<c8y-breadcrumb-item
[icon]="''"
[label]="'Connectors' | translate"
></c8y-breadcrumb-item>
<c8y-breadcrumb-item
[icon]="''"
[label]="'Connector' | translate"
></c8y-breadcrumb-item>
</c8y-breadcrumb>
<div class="">
<c8y-form-group class="p-l-24">
<form class="form-inline">
<label class="control-label m-r-8" title="{{ 'Filter connector logs' | translate }}">Filter connector logs</label>
<div class="c8y-select-wrapper">
<select class="form-control" style="width: 280px" [(ngModel)]="filterStatusLog.type" name="type">
<ng-container *ngFor="let lt of LoggingEventTypeMap | keyvalue">
<option [ngValue]="lt.key"
*ngIf="lt.value['component'] == 'd11r_connector' || lt.value['component'] == LoggingEventTypeMap[LoggingEventType.ALL].component">
{{ lt.key | formatStringAsWords }}
</option>
</ng-container>
</select>
</div>
<div class="c8y-select-wrapper m-l-16">
<select class="form-control" style="width: 180px" [(ngModel)]="filterStatusLog.connectorIdentifier"
name="connectorIdentifier">
<option [value]="'ALL'">ALL connectors</option>

<option [value]="t.identifier" *ngFor="let t of configurations$ | async">
{{ t.name }}
</option>
</select>
</div>
<button type="submit" (click)="updateStatusLogs()" class="btn btn-default btn-sm m-l-16">
Update
</button>
</form>
</c8y-form-group>
<div class="hidden-xs c8y-list__item c8y-list--timeline">
<div class="d-flex">
<div class="c8y-list--timeline__item__date">
<p class="m-0 text-medium text-truncate" title="Date">Date</p>
</div>
<div class="c8y-list__item__block flex-grow">
<div class="c8y-list__item__body">
<div class="d-flex">
<div class="col-md-1">Status</div>
<div class="col-md-2">Connector</div>
<div class="col-md-9">Message</div>
</div>
</div>
</div>
</div>
</div>
<c8y-list-group>
<c8y-li-timeline *ngFor="let event of statusLogs$ | async">
{{ event.date | date: 'dd.MM.yy hh:mm:ss' }}
<c8y-li>
<c8y-li-body>
<div class="d-flex">
<div class="col-md-1">
<div class="label label-primary">
{{ event.status ? event.status : '-' }}
</div>
</div>
<div class="col-md-2">{{ event.connectorName }}</div>
<div class="col-md-9">
<div>{{ event.message ? event.message : '-' }}</div>
</div>
</div>
</c8y-li-body>
</c8y-li>
</c8y-li-timeline>
</c8y-list-group>
</div>
Loading

0 comments on commit d6f9b1e

Please sign in to comment.