Skip to content

Commit

Permalink
change navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
ck-c8y committed Jan 9, 2025
1 parent 05b8a9b commit 35a6ed2
Show file tree
Hide file tree
Showing 19 changed files with 315 additions and 230 deletions.
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>Service configuration</c8y-title>
<c8y-action-bar-item [placement]="'right'">
<button
class="btn btn-link"
Expand All @@ -42,11 +42,6 @@
</c8y-action-bar-item>

<div class="card card--fullpage">
<div class="card-header p-l-32 separator j-c-between">
<h4 class="card-title">
{{ 'Service configuration' | translate }}
</h4>
</div>
<div class="card-block">
<form [formGroup]="serviceForm">
<div class="col-lg-8 col-lg-offset-2">
Expand Down
3 changes: 0 additions & 3 deletions dynamic-mapping-ui/src/dynamic-mapping.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ import { FormlyPresetModule } from '@ngx-formly/core/preset';

import {
MappingNavigationFactory,
MappingTabFactory,
OverviewGuard,
SharedModule,
} from './shared';
import { TestingModule } from './testing-device/testing.module';
import './shared/styles/shared.css';
Expand Down Expand Up @@ -74,7 +72,6 @@ import { LandingModule } from './landing/landing.module';
OverviewGuard,
BsModalService,
hookNavigator(MappingNavigationFactory),
hookTab(MappingTabFactory),
],
})
export class DynamicMappingModule {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
~ @authors Christof Strack
-->

<c8y-title>{{ 'Configuration' | translate }}</c8y-title>
<c8y-title>{{ 'Processor extension' | translate }}</c8y-title>

<c8y-breadcrumb>
<!-- <c8y-breadcrumb-item [icon]="'c8y-atom'" [label]="'Processor' | translate"></c8y-breadcrumb-item> -->
Expand Down
92 changes: 92 additions & 0 deletions dynamic-mapping-ui/src/mapping-tree/mapping-tree.factory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* 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 { Injectable } from '@angular/core';
import { ApplicationService } from '@c8y/client';
import * as _ from 'lodash';
import {
AlertService,
AppStateService,
gettext,
NavigatorNode,
NavigatorNodeFactory
} from '@c8y/ngx-components';
import { Router } from '@angular/router';
import { NODE2, SharedService } from '../shared';

@Injectable()
export class MappingTreeNavigationFactory implements NavigatorNodeFactory {
private static readonly APPLICATION_DYNAMIC_MAPPING_SERVICE =
'dynamic-mapping-service';

appName: string;
isStandaloneApp: boolean = false;
staticNodes = {
treegMappingNode: new NavigatorNode({
parent: gettext('Monitoring'),
label: gettext('Hierarchy mapping'),
icon: 'monitoring',
path: `sag-ps-pkg-dynamic-mapping/${NODE2}/tree`,
priority: 500,
preventDuplicates: true
}),
} as const;

constructor(
private applicationService: ApplicationService,
private alertService: AlertService,
private sharedService: SharedService,
private appStateService: AppStateService,
public router: Router
) {
this.appStateService.currentApplication.subscribe((cur) => {
this.isStandaloneApp =
_.has(cur?.manifest, 'isPackage') || _.has(cur?.manifest, 'blueprint');
this.appName = cur.name;
});
}

async get() {
const feature: any = await this.sharedService.getFeatures();
let navs;
let copyStaticNodesPlugin;

copyStaticNodesPlugin = _.clone(this.staticNodes);
if (!feature?.outputMappingEnabled) {
delete copyStaticNodesPlugin.mappingOutboundNode;
delete copyStaticNodesPlugin.subscriptionOutboundNode;
}
navs = Object.values(copyStaticNodesPlugin) as NavigatorNode[];

return this.applicationService
.isAvailable(MappingTreeNavigationFactory.APPLICATION_DYNAMIC_MAPPING_SERVICE)
.then((data) => {
if (!data.data || !feature) {
this.alertService.danger(
'Microservice:dynamic-mapping-service not subscribed. Please subscribe this service before using the mapping editor!'
);
console.error('dynamic-mapping-service microservice not subscribed!');
return [];
}
return navs;
});
}
}
43 changes: 0 additions & 43 deletions dynamic-mapping-ui/src/mapping-tree/tree-tab.factory.ts

This file was deleted.

2 changes: 1 addition & 1 deletion dynamic-mapping-ui/src/mapping-tree/tree.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
~ @authors Christof Strack
-->

<c8y-title>Monitoring</c8y-title>
<c8y-title>Hierachy mapping</c8y-title>

Check warning on line 22 in dynamic-mapping-ui/src/mapping-tree/tree.component.html

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"Hierachy" should be "Hierarchy".
<c8y-action-bar-item placement="right">
<button
class="btn btn-link"
Expand Down
6 changes: 3 additions & 3 deletions dynamic-mapping-ui/src/mapping-tree/tree.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
* @authors Christof Strack
*/
import { NgModule } from '@angular/core';
import { CoreModule, hookRoute, hookTab } from '@c8y/ngx-components';
import { CoreModule, hookNavigator, hookRoute } from '@c8y/ngx-components';
import { MappingTreeComponent } from './tree.component';
import { NODE2, SharedModule } from '../shared';
import { TreeTabFactory } from './tree-tab.factory';
import { treeResolver } from './utils';
import { MappingTreeNavigationFactory } from './mapping-tree.factory';

@NgModule({
declarations: [MappingTreeComponent],
Expand All @@ -35,7 +35,7 @@ import { treeResolver } from './utils';
component: MappingTreeComponent,
resolve: { mappingTree: treeResolver }
}),
hookTab(TreeTabFactory)
hookNavigator(MappingTreeNavigationFactory),
]
})
export class MappingTreeModule {}
4 changes: 2 additions & 2 deletions dynamic-mapping-ui/src/monitoring/chart/chart.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
~ @authors Christof Strack
-->

<c8y-title translate>Monitoring</c8y-title>
<c8y-title translate>Chart processed</c8y-title>

<div class="card">
<div class="card-header p-l-32">
<h4 class="card-title">Messages processed by mappings</h4>
<h4 class="card-title">Messages processed</h4>
</div>
<div class="card-block">
<div class="col-lg-10 col-lg-offset-1">
Expand Down
2 changes: 1 addition & 1 deletion dynamic-mapping-ui/src/monitoring/chart/chart.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class MonitoringChartComponent implements OnInit, OnDestroy {
this.echartOptions = {
title: {
show: false,
text: 'Messages processed by mappings',
text: 'Messages processed',
textStyle: {
color: this.textColor,
fontFamily: this.fontFamily,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
~ @authors Christof Strack
-->

<c8y-title translate>Monitoring</c8y-title>
<c8y-title translate>Service events</c8y-title>
<c8y-action-bar-item [placement]="'left'" itemClass="navbar-form hidden-xs">
<c8y-form-group class="p-l-12">
<div class="d-flex">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
~ @authors Christof Strack
-->

<c8y-title translate>Monitoring</c8y-title>
<c8y-title translate>Statistic processed</c8y-title>
<c8y-action-bar-item [placement]="'right'">
<button class="btn btn-link" title="{{ 'Reset monitoring' | translate }}" (click)="resetStatusMapping()">
<i c8yIcon="reset"></i>
Expand Down
109 changes: 109 additions & 0 deletions dynamic-mapping-ui/src/monitoring/monitoring-navigation.factory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* 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 { Injectable } from '@angular/core';
import { ApplicationService } from '@c8y/client';
import * as _ from 'lodash';
import {
AlertService,
AppStateService,
gettext,
NavigatorNode,
NavigatorNodeFactory
} from '@c8y/ngx-components';
import { Router } from '@angular/router';
import { NODE2, SharedService } from '../shared';

@Injectable()
export class MonitoringNavigationFactory implements NavigatorNodeFactory {
private static readonly APPLICATION_DYNAMIC_MAPPING_SERVICE =
'dynamic-mapping-service';

appName: string;
isStandaloneApp: boolean = false;
staticNodes = {
monitoringMappingNode: new NavigatorNode({
parent: gettext('Monitoring'),
label: gettext('Statistic processed'),
icon: 'monitoring',
path: `sag-ps-pkg-dynamic-mapping/${NODE2}/monitoring/grid`,
priority: 500,
preventDuplicates: true
}),
monitoringChartNode: new NavigatorNode({
parent: gettext('Monitoring'),
label: gettext('Chart processed'),
icon: 'pie-chart',
path: `sag-ps-pkg-dynamic-mapping/${NODE2}/monitoring/chart`,
priority: 500,
preventDuplicates: true
}),
monitoringMappingEventsNode: new NavigatorNode({
parent: gettext('Monitoring'),
label: gettext('Service events'),
icon: 'logs',
path: `sag-ps-pkg-dynamic-mapping/${NODE2}/monitoring/serviceEvent`,
priority: 500,
preventDuplicates: true
}),

} as const;

constructor(
private applicationService: ApplicationService,
private alertService: AlertService,
private sharedService: SharedService,
private appStateService: AppStateService,
public router: Router
) {
this.appStateService.currentApplication.subscribe((cur) => {
this.isStandaloneApp =
_.has(cur?.manifest, 'isPackage') || _.has(cur?.manifest, 'blueprint');
this.appName = cur.name;
});
}

async get() {
const feature: any = await this.sharedService.getFeatures();
let navs;
let copyStaticNodesPlugin;

copyStaticNodesPlugin = _.clone(this.staticNodes);
if (!feature?.outputMappingEnabled) {
delete copyStaticNodesPlugin.mappingOutboundNode;
delete copyStaticNodesPlugin.subscriptionOutboundNode;
}
navs = Object.values(copyStaticNodesPlugin) as NavigatorNode[];

return this.applicationService
.isAvailable(MonitoringNavigationFactory.APPLICATION_DYNAMIC_MAPPING_SERVICE)
.then((data) => {
if (!data.data || !feature) {
this.alertService.danger(
'Microservice:dynamic-mapping-service not subscribed. Please subscribe this service before using the mapping editor!'
);
console.error('dynamic-mapping-service microservice not subscribed!');
return [];
}
return navs;
});
}
}
Loading

0 comments on commit 35a6ed2

Please sign in to comment.