Merge branch 'feature/4661-gateway-sync' of github.com:maxunbearable/thingsboard into feature/4661-gateway-sync

This commit is contained in:
Vladyslav_Prykhodko 2024-10-24 11:39:44 +03:00
commit 24bcdd89e0
15 changed files with 142 additions and 27 deletions

View File

@ -88,6 +88,7 @@ export enum MenuId {
devices = 'devices', devices = 'devices',
assets = 'assets', assets = 'assets',
entity_views = 'entity_views', entity_views = 'entity_views',
gateways = 'gateways',
profiles = 'profiles', profiles = 'profiles',
device_profiles = 'device_profiles', device_profiles = 'device_profiles',
asset_profiles = 'asset_profiles', asset_profiles = 'asset_profiles',
@ -508,6 +509,16 @@ export const menuSectionMap = new Map<MenuId, MenuSection>([
icon: 'view_quilt' icon: 'view_quilt'
} }
], ],
[
MenuId.gateways,
{
id: MenuId.gateways,
name: 'gateway.gateways',
type: 'link',
path: '/entities/gateways',
icon: 'tb_gateway'
}
],
[ [
MenuId.profiles, MenuId.profiles,
{ {
@ -725,7 +736,8 @@ const defaultUserMenuMap = new Map<Authority, MenuReference[]>([
pages: [ pages: [
{id: MenuId.devices}, {id: MenuId.devices},
{id: MenuId.assets}, {id: MenuId.assets},
{id: MenuId.entity_views} {id: MenuId.entity_views},
{id: MenuId.gateways}
] ]
}, },
{ {

View File

@ -15,4 +15,4 @@
limitations under the License. limitations under the License.
--> -->
<tb-dashboard-page [embedded]="true" [dashboard]="apiUsageDashboard"></tb-dashboard-page> <tb-dashboard-page [embedded]="true" [dashboard]="dashboard"></tb-dashboard-page>

View File

@ -22,13 +22,13 @@ import { Dashboard } from '@shared/models/dashboard.models';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
@Component({ @Component({
selector: 'tb-api-usage', selector: 'tb-dashboard-view',
templateUrl: './api-usage.component.html', templateUrl: './dashboard-view.component.html',
styleUrls: ['./api-usage.component.scss'] styleUrls: ['./dashboard-view.component.scss']
}) })
export class ApiUsageComponent extends PageComponent { export class DashboardViewComponent extends PageComponent {
apiUsageDashboard: Dashboard = this.route.snapshot.data.apiUsageDashboard; dashboard: Dashboard = this.route.snapshot.data.dashboard;
constructor(protected store: Store<AppState>, constructor(protected store: Store<AppState>,
private route: ActivatedRoute) { private route: ActivatedRoute) {

View File

@ -182,6 +182,7 @@ import {
SelectDashboardBreakpointComponent SelectDashboardBreakpointComponent
} from '@home/components/dashboard-page/layout/select-dashboard-breakpoint.component'; } from '@home/components/dashboard-page/layout/select-dashboard-breakpoint.component';
import { EntityChipsComponent } from '@home/components/entity/entity-chips.component'; import { EntityChipsComponent } from '@home/components/entity/entity-chips.component';
import { DashboardViewComponent } from '@home/components/dashboard-view/dashboard-view.component';
@NgModule({ @NgModule({
declarations: declarations:
@ -324,7 +325,8 @@ import { EntityChipsComponent } from '@home/components/entity/entity-chips.compo
RateLimitsTextComponent, RateLimitsTextComponent,
RateLimitsDetailsDialogComponent, RateLimitsDetailsDialogComponent,
SendNotificationButtonComponent, SendNotificationButtonComponent,
EntityChipsComponent EntityChipsComponent,
DashboardViewComponent
], ],
imports: [ imports: [
CommonModule, CommonModule,
@ -460,7 +462,8 @@ import { EntityChipsComponent } from '@home/components/entity/entity-chips.compo
RateLimitsTextComponent, RateLimitsTextComponent,
RateLimitsDetailsDialogComponent, RateLimitsDetailsDialogComponent,
SendNotificationButtonComponent, SendNotificationButtonComponent,
EntityChipsComponent EntityChipsComponent,
DashboardViewComponent
], ],
providers: [ providers: [
WidgetComponentService, WidgetComponentService,

View File

@ -17,11 +17,11 @@
import { inject, NgModule } from '@angular/core'; import { inject, NgModule } from '@angular/core';
import { ActivatedRouteSnapshot, ResolveFn, RouterModule, RouterStateSnapshot, Routes } from '@angular/router'; import { ActivatedRouteSnapshot, ResolveFn, RouterModule, RouterStateSnapshot, Routes } from '@angular/router';
import { Authority } from '@shared/models/authority.enum'; import { Authority } from '@shared/models/authority.enum';
import { ApiUsageComponent } from '@home/pages/api-usage/api-usage.component';
import { Dashboard } from '@shared/models/dashboard.models'; import { Dashboard } from '@shared/models/dashboard.models';
import { ResourcesService } from '@core/services/resources.service'; import { ResourcesService } from '@core/services/resources.service';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { MenuId } from '@core/services/menu.models'; import { MenuId } from '@core/services/menu.models';
import { DashboardViewComponent } from '@home/components/dashboard-view/dashboard-view.component';
const apiUsageDashboardJson = '/assets/dashboard/api_usage.json'; const apiUsageDashboardJson = '/assets/dashboard/api_usage.json';
@ -34,7 +34,7 @@ export const apiUsageDashboardResolver: ResolveFn<Dashboard> = (
const routes: Routes = [ const routes: Routes = [
{ {
path: 'usage', path: 'usage',
component: ApiUsageComponent, component: DashboardViewComponent,
data: { data: {
auth: [Authority.TENANT_ADMIN], auth: [Authority.TENANT_ADMIN],
title: 'api-usage.api-usage', title: 'api-usage.api-usage',
@ -43,7 +43,7 @@ const routes: Routes = [
} }
}, },
resolve: { resolve: {
apiUsageDashboard: apiUsageDashboardResolver dashboard: apiUsageDashboardResolver
} }
} }
]; ];

View File

@ -18,14 +18,9 @@ import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { SharedModule } from '@app/shared/shared.module'; import { SharedModule } from '@app/shared/shared.module';
import { HomeComponentsModule } from '@modules/home/components/home-components.module'; import { HomeComponentsModule } from '@modules/home/components/home-components.module';
import { ApiUsageComponent } from '@home/pages/api-usage/api-usage.component';
import { ApiUsageRoutingModule } from '@home/pages/api-usage/api-usage-routing.module'; import { ApiUsageRoutingModule } from '@home/pages/api-usage/api-usage-routing.module';
@NgModule({ @NgModule({
declarations:
[
ApiUsageComponent
],
imports: [ imports: [
CommonModule, CommonModule,
SharedModule, SharedModule,

View File

@ -24,8 +24,6 @@ import { EntityDetailsPageComponent } from '@home/components/entity/entity-detai
import { ConfirmOnExitGuard } from '@core/guards/confirm-on-exit.guard'; import { ConfirmOnExitGuard } from '@core/guards/confirm-on-exit.guard';
import { entityDetailsPageBreadcrumbLabelFunction } from '@home/pages/home-pages.models'; import { entityDetailsPageBreadcrumbLabelFunction } from '@home/pages/home-pages.models';
import { BreadCrumbConfig } from '@shared/components/breadcrumb'; import { BreadCrumbConfig } from '@shared/components/breadcrumb';
import { assetRoutes } from '@home/pages/asset/asset-routing.module';
import { entityViewRoutes } from '@home/pages/entity-view/entity-view-routing.module';
import { MenuId } from '@core/services/menu.models'; import { MenuId } from '@core/services/menu.models';
export const deviceRoutes: Routes = [ export const deviceRoutes: Routes = [

View File

@ -20,6 +20,7 @@ import { NgModule } from '@angular/core';
import { deviceRoutes } from '@home/pages/device/device-routing.module'; import { deviceRoutes } from '@home/pages/device/device-routing.module';
import { assetRoutes } from '@home/pages/asset/asset-routing.module'; import { assetRoutes } from '@home/pages/asset/asset-routing.module';
import { entityViewRoutes } from '@home/pages/entity-view/entity-view-routing.module'; import { entityViewRoutes } from '@home/pages/entity-view/entity-view-routing.module';
import { gatewaysRoutes } from '@home/pages/gateways/gateways-routing.module';
const routes: Routes = [ const routes: Routes = [
{ {
@ -41,7 +42,8 @@ const routes: Routes = [
}, },
...deviceRoutes, ...deviceRoutes,
...assetRoutes, ...assetRoutes,
...entityViewRoutes ...entityViewRoutes,
...gatewaysRoutes
] ]
} }
]; ];

View File

@ -0,0 +1,63 @@
///
/// Copyright © 2016-2024 The Thingsboard Authors
///
/// 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.
///
import { inject, NgModule } from '@angular/core';
import { ActivatedRouteSnapshot, ResolveFn, RouterModule, RouterStateSnapshot, Routes } from '@angular/router';
import { Authority } from '@shared/models/authority.enum';
import { Dashboard } from '@shared/models/dashboard.models';
import { ResourcesService } from '@core/services/resources.service';
import { Observable } from 'rxjs';
import { MenuId } from '@core/services/menu.models';
import { DashboardViewComponent } from '@home/components/dashboard-view/dashboard-view.component';
const gatewaysDashboardJson = '/api/resource/dashboard/system/gateways_dashboard.json';
export const gatewaysDashboardResolver: ResolveFn<Dashboard> = (
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot,
resourcesService = inject(ResourcesService)
): Observable<Dashboard> => resourcesService.loadJsonResource(gatewaysDashboardJson);
export const gatewaysRoutes: Routes = [
{
path: 'gateways',
component: DashboardViewComponent,
data: {
auth: [Authority.TENANT_ADMIN],
title: 'gateway.gateways',
breadcrumb: {
menuId: MenuId.gateways
}
},
resolve: {
dashboard: gatewaysDashboardResolver
}
}
];
const routes: Routes = [
{
path: 'gateways',
pathMatch: 'full',
redirectTo: '/entities/gateways'
},
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class GatewaysRoutingModule { }

View File

@ -0,0 +1,31 @@
///
/// Copyright © 2016-2024 The Thingsboard Authors
///
/// 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.
///
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { SharedModule } from '@app/shared/shared.module';
import { HomeComponentsModule } from '@modules/home/components/home-components.module';
import { GatewaysRoutingModule } from '@home/pages/gateways/gateways-routing.module';
@NgModule({
imports: [
CommonModule,
SharedModule,
HomeComponentsModule,
GatewaysRoutingModule
]
})
export class GatewaysModule { }

View File

@ -44,6 +44,7 @@ import { FeaturesModule } from '@home/pages/features/features.module';
import { NotificationModule } from '@home/pages/notification/notification.module'; import { NotificationModule } from '@home/pages/notification/notification.module';
import { AccountModule } from '@home/pages/account/account.module'; import { AccountModule } from '@home/pages/account/account.module';
import { ScadaSymbolModule } from '@home/pages/scada-symbol/scada-symbol.module'; import { ScadaSymbolModule } from '@home/pages/scada-symbol/scada-symbol.module';
import { GatewaysModule } from '@home/pages/gateways/gateways.module';
@NgModule({ @NgModule({
exports: [ exports: [
@ -70,6 +71,7 @@ import { ScadaSymbolModule } from '@home/pages/scada-symbol/scada-symbol.module'
DashboardModule, DashboardModule,
AuditLogModule, AuditLogModule,
ApiUsageModule, ApiUsageModule,
GatewaysModule,
OtaUpdateModule, OtaUpdateModule,
UserModule, UserModule,
VcModule, VcModule,

View File

@ -62,7 +62,20 @@ export const svgIcons: {[key: string]: string} = {
'4.6760606 4.678212,7.3604329 7.3397982,4.6839955 4.6657413,2.0041717 6.6653477,2.2309572e-4 9.3360035,2.6766286 11.997681,' + '4.6760606 4.678212,7.3604329 7.3397982,4.6839955 4.6657413,2.0041717 6.6653477,2.2309572e-4 9.3360035,2.6766286 11.997681,' +
'0 14.659287,2.6765011 Z m -5.332255,4.0079963 1.999613,2.003945 -7.99844,8.0158157 -1.9996133,-2.004017 z m 1.676684,4.3522483 ' + '0 14.659287,2.6765011 Z m -5.332255,4.0079963 1.999613,2.003945 -7.99844,8.0158157 -1.9996133,-2.004017 z m 1.676684,4.3522483 ' +
'1.999613,2.0039454 -6.6654242,6.679793 -1.9996133,-2.003874 z m 2.988987,7.0033574 -1.999544,-2.003945 -4.6658108,4.675848 ' + '1.999613,2.0039454 -6.6654242,6.679793 -1.9996133,-2.003874 z m 2.988987,7.0033574 -1.999544,-2.003945 -4.6658108,4.675848 ' +
'1.9996128,2.004015 z"/></svg>' '1.9996128,2.004015 z"/></svg>',
tb_gateway: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="6 4 42 46" width="18" height="18">
<path d="M41.633 47.719c0-.559.453-1.012 1.008-1.012.554 0 1.007.453 1.007 1.012v1.008c0 .558-.453 1.011-1.007 1.011a1.011 1.011 0 0 1-1.008-1.011ZM38.617 47.719c0-.559.45-1.012 1.004-1.012.559 0 1.008.453 1.008 1.012v1.008c0 .558-.45 1.011-1.008 1.011a1.008 1.008 0 0 1-1.004-1.011ZM35.598 47.719c0-.559.449-1.012 1.004-1.012.558 0 1.007.453 1.007 1.012v1.008c0 .558-.449 1.011-1.007 1.011a1.008 1.008 0 0 1-1.004-1.011ZM32.578 47.719c0-.559.453-1.012 1.008-1.012.555 0 1.004.453 1.004 1.012v1.008c0 .558-.45 1.011-1.004 1.011a1.011 1.011 0 0 1-1.008-1.011ZM44.652 44.684a1.01 1.01 0 0 1 1.008-1.008h1.004c.559 0 1.008.453 1.008 1.008 0 .558-.45 1.011-1.008 1.011H45.66a1.011 1.011 0 0 1-1.008-1.011ZM28.555 44.684c0-.555.449-1.008 1.004-1.008h1.007a1.01 1.01 0 0 1 0 2.02H29.56a1.008 1.008 0 0 1-1.004-1.012Z"/>
<path d="M15.477 35.59h-3.02v3.031c0 2.234 1.8 4.043 4.023 4.043h2.012a4.035 4.035 0 0 0 4.028-4.043V35.59H19.5v2.023h-4.023ZM7.074 41.309a.75.75 0 0 0-.746.75c0 3.73 3.012 6.754 6.723 6.754a.751.751 0 0 0 0-1.504c-2.887 0-5.227-2.352-5.227-5.25a.75.75 0 0 0-.75-.75Z"/>
<path d="M9.977 41.023a.75.75 0 0 0-.747.75 4.118 4.118 0 0 0 4.11 4.125.747.747 0 0 0 .746-.75.747.747 0 0 0-.746-.75 2.622 2.622 0 0 1-2.617-2.625.747.747 0 0 0-.746-.75Z"/>
<path d="M44.652 41.66c0-.558.453-1.012 1.008-1.012h1.004c.559 0 1.008.454 1.008 1.012 0 .555-.45 1.008-1.008 1.008H45.66a1.01 1.01 0 0 1-1.008-1.008ZM28.555 41.66c0-.558.449-1.012 1.004-1.012h1.007a1.01 1.01 0 0 1 0 2.02H29.56a1.007 1.007 0 0 1-1.004-1.008ZM44.652 38.621c0-.559.453-1.012 1.008-1.012h1.004c.559 0 1.008.453 1.008 1.012 0 .559-.45 1.012-1.008 1.012H45.66a1.011 1.011 0 0 1-1.008-1.012ZM28.555 38.621c0-.559.449-1.012 1.004-1.012h1.007a1.011 1.011 0 0 1 0 2.024H29.56a1.008 1.008 0 0 1-1.004-1.012ZM44.652 35.594c0-.559.453-1.012 1.008-1.012h1.004c.559 0 1.008.453 1.008 1.012 0 .558-.45 1.011-1.008 1.011H45.66a1.011 1.011 0 0 1-1.008-1.011ZM28.555 35.594c0-.559.449-1.012 1.004-1.012h1.007a1.011 1.011 0 0 1 0 2.023H29.56a1.008 1.008 0 0 1-1.004-1.011Z"/>
<path d="M12.457 33.57c0-.558.45-1.011 1.004-1.011h8.05c.555 0 1.009.453 1.009 1.011v1.008H12.457Z"/>
<path d="M41.633 31.55c0-.558.453-1.01 1.008-1.01.554 0 1.007.452 1.007 1.01v1.009c0 .558-.453 1.011-1.007 1.011a1.011 1.011 0 0 1-1.008-1.011Z"/>
<path d="M27.547 10.184v2.168h2.015v-2.168a3.592 3.592 0 0 1-2.015 0Zm3.02 16.316v-4.043h2.011V26.5h4.027c1.11 0 2.012.906 2.012 2.023v2.02h-2.012v-2.02h-4.027a2.019 2.019 0 0 1-2.012-2.023Zm-4.024-4.043V26.5a2.019 2.019 0 0 1-2.012 2.023h-6.039v2.02H16.48v-2.02c0-1.117.903-2.023 2.012-2.023h6.04v-4.043Z"/>
<path d="M32.578 31.55c0-.558.453-1.01 1.008-1.01.555 0 1.004.452 1.004 1.01v1.009c0 .558-.45 1.011-1.004 1.011a1.011 1.011 0 0 1-1.008-1.011Z"/>
<path d="M32.578 32.559c-1.11 0-2.012.906-2.012 2.02v11.116c0 1.117.903 2.024 2.012 2.024h11.067a2.02 2.02 0 0 0 2.015-2.024V34.578c0-1.113-.902-2.02-2.015-2.02Zm1.008 2.02c-.559 0-1.008.452-1.008 1.01v9.099c0 .558.45 1.007 1.008 1.007h9.055c.554 0 1.004-.449 1.004-1.008V35.59c0-.559-.45-1.012-1.004-1.012Z"/>
<path d="M38.617 40.648h3.016v3.032h-3.016ZM34.59 40.648h3.02v3.032h-3.02ZM38.617 36.602h3.016v3.035h-3.016ZM34.59 36.602h3.02v3.035h-3.02Z"/>
<path d="M28.555 9.313a2.518 2.518 0 0 0 2.515-2.524 2.519 2.519 0 0 0-2.515-2.527 2.519 2.519 0 0 0-2.516 2.527 2.518 2.518 0 0 0 2.516 2.524Zm-11.067 4.042a2.02 2.02 0 0 0-2.015 2.024v4.043c0 1.113.902 2.02 2.015 2.02h22.133a2.016 2.016 0 0 0 2.012-2.02v-4.043a2.016 2.016 0 0 0-2.012-2.024Zm1.004 4.043a1.01 1.01 0 0 0 0-2.02c-.555 0-1.004.454-1.004 1.013 0 .554.45 1.007 1.004 1.007Zm4.028-1.007a1.01 1.01 0 0 1-1.008 1.007 1.01 1.01 0 0 1 0-2.02c.554 0 1.008.454 1.008 1.013Z"/>
</svg>`,
}; };
export const svgIconsUrl: { [key: string]: string } = { export const svgIconsUrl: { [key: string]: string } = {

View File

@ -2837,13 +2837,9 @@
"function": "Function" "function": "Function"
}, },
"gateway": { "gateway": {
"gateway-exists": "Device with same name is already exists.",
"gateway-name": "Gateway name", "gateway-name": "Gateway name",
"gateway-name-required": "Gateway name is required.", "gateway-name-required": "Gateway name is required.",
"gateway-saved": "Gateway configuration successfully saved.", "gateways": "Gateways",
"gateway": "Gateway",
"launch-gateway": "Launch gateway",
"launch-command": "Launch command",
"create-new-gateway": "Create a new gateway", "create-new-gateway": "Create a new gateway",
"create-new-gateway-text": "Are you sure you want create a new gateway with name: '{{gatewayName}}'?", "create-new-gateway-text": "Are you sure you want create a new gateway with name: '{{gatewayName}}'?",
"no-gateway-found": "No gateway found.", "no-gateway-found": "No gateway found.",

File diff suppressed because one or more lines are too long