Browse Source

IoT Hub widget initial implementation

pull/15508/head
Igor Kulikov 5 months ago
parent
commit
35964a37dd
  1. 39
      application/src/main/data/json/system/widget_types/iot_hub.json
  2. 7
      ui-ngx/src/app/modules/home/components/widget/lib/home-page/home-page-widgets.module.ts
  3. 30
      ui-ngx/src/app/modules/home/components/widget/lib/home-page/iot-hub-widget.component.html
  4. 46
      ui-ngx/src/app/modules/home/components/widget/lib/home-page/iot-hub-widget.component.scss
  5. 57
      ui-ngx/src/app/modules/home/components/widget/lib/home-page/iot-hub-widget.component.ts
  6. 71
      ui-ngx/src/assets/dashboard/tenant_admin_home_page.json
  7. 3
      ui-ngx/src/assets/locale/locale.constant-en_US.json

39
application/src/main/data/json/system/widget_types/iot_hub.json

File diff suppressed because one or more lines are too long

7
ui-ngx/src/app/modules/home/components/widget/lib/home-page/home-page-widgets.module.ts

@ -35,6 +35,7 @@ import { AddQuickLinkDialogComponent } from '@home/components/widget/lib/home-pa
import {
RecentDashboardsWidgetComponent
} from '@home/components/widget/lib/home-page/recent-dashboards-widget.component';
import { IotHubWidgetComponent } from '@home/components/widget/lib/home-page/iot-hub-widget.component';
@NgModule({
declarations:
@ -52,7 +53,8 @@ import {
QuickLinksWidgetComponent,
QuickLinkComponent,
AddQuickLinkDialogComponent,
RecentDashboardsWidgetComponent
RecentDashboardsWidgetComponent,
IotHubWidgetComponent
],
imports: [
CommonModule,
@ -72,7 +74,8 @@ import {
QuickLinksWidgetComponent,
QuickLinkComponent,
AddQuickLinkDialogComponent,
RecentDashboardsWidgetComponent
RecentDashboardsWidgetComponent,
IotHubWidgetComponent
]
})
export class HomePageWidgetsModule { }

30
ui-ngx/src/app/modules/home/components/widget/lib/home-page/iot-hub-widget.component.html

@ -0,0 +1,30 @@
<!--
Copyright © 2016-2026 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.
-->
<div class="tb-card-content flex flex-col gap-2">
@if (hasIotHubAccess) {
<div class="tb-card-header flex flex-col gap-2.5">
<div class="tb-card-title-text">{{ 'widgets.iot-hub.title-text' | translate }}&nbsp;<a routerLink="/iot-hub">IoT Hub</a></div>
<mat-divider></mat-divider>
</div>
} @else {
<div class="tb-no-data-available">
<div class="tb-no-data-bg"></div>
<div class="tb-no-data-text" translate>widgets.home.no-data-available</div>
</div>
}
</div>

46
ui-ngx/src/app/modules/home/components/widget/lib/home-page/iot-hub-widget.component.scss

@ -0,0 +1,46 @@
/**
* Copyright © 2016-2026 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 "../../../../../../../scss/constants";
:host {
.tb-card-header {
.tb-card-title-text {
font-size: 14px;
font-style: normal;
font-weight: 500;
line-height: 20px;
color: rgba(0, 0, 0, 0.76);
a {
display: inline-block;
font-weight: 500;
border: none;
color: $tb-primary-color;
}
}
.mat-divider {
margin-left: -16px;
margin-right: -16px;
@media #{$mat-md-lg} {
margin-left: -8px;
margin-right: -8px;
@media #{$mat-lt-lg} {
margin-left: -2px;
margin-right: -2px;
}
}
}
}
}

57
ui-ngx/src/app/modules/home/components/widget/lib/home-page/iot-hub-widget.component.ts

@ -0,0 +1,57 @@
///
/// Copyright © 2016-2026 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 { Component, Input, OnInit } from '@angular/core';
import { PageComponent } from '@shared/components/page.component';
import { Authority } from '@shared/models/authority.enum';
import { getCurrentAuthUser } from '@core/auth/auth.selectors';
import { WidgetContext } from '@home/models/widget-component.models';
@Component({
selector: 'tb-iot-hub-widget',
templateUrl: './iot-hub-widget.component.html',
styleUrls: ['./home-page-widget.scss', './iot-hub-widget.component.scss'],
standalone: false
})
export class IotHubWidgetComponent extends PageComponent implements OnInit {
@Input()
ctx: WidgetContext;
authority = Authority;
authUser = getCurrentAuthUser(this.store);
hasIotHubAccess = true;
constructor() {
super();
}
ngOnInit() {
this.ctx.overflowVisible = true;
this.hasIotHubAccess = [Authority.TENANT_ADMIN].includes(this.authUser.authority);
if (this.hasIotHubAccess) {
this.load();
}
}
private load() {
}
}

71
ui-ngx/src/assets/dashboard/tenant_admin_home_page.json

@ -6,6 +6,31 @@
"configuration": {
"description": "",
"widgets": {
"fe678c4f-ea86-4cae-8d81-6fca493fe311": {
"type": "static",
"sizeX": 7.5,
"sizeY": 6.5,
"config": {
"showTitle": false,
"backgroundColor": "rgb(255, 255, 255)",
"color": "rgba(0, 0, 0, 0.87)",
"padding": "16px",
"settings": {},
"title": "IoT Hub",
"dropShadow": true,
"enableFullscreen": false,
"widgetStyle": {},
"widgetCss": "",
"pageSize": 1024,
"noDataDisplayMessage": "",
"showLegend": false,
"datasources": []
},
"row": 0,
"col": 0,
"id": "fe678c4f-ea86-4cae-8d81-6fca493fe311",
"typeFullFqn": "system.home_page_widgets.iot_hub"
},
"d70cc256-4c7b-ee06-9905-b8c5e546605f": {
"type": "latest",
"sizeX": 5,
@ -1228,55 +1253,63 @@
"widgets": {
"d70cc256-4c7b-ee06-9905-b8c5e546605f": {
"sizeX": 42,
"sizeY": 29,
"row": 13,
"sizeY": 17,
"row": 27,
"col": 43,
"mobileOrder": 4,
"mobileOrder": 5,
"mobileHeight": 10
},
"867f82cf-ecf2-2d5c-35cb-08c6f2edc3a4": {
"sizeX": 29,
"sizeY": 16,
"row": 42,
"sizeY": 14,
"row": 44,
"col": 28,
"mobileHide": true
},
"ebbd0a6e-8a47-e770-5086-7f4974250f2d": {
"sizeX": 28,
"sizeY": 16,
"row": 42,
"sizeY": 14,
"row": 44,
"col": 57,
"mobileOrder": 3,
"mobileOrder": 4,
"mobileHeight": 10
},
"9e3ef045-d8bc-1640-a3f4-2dd10b19d50e": {
"sizeX": 28,
"sizeY": 16,
"row": 42,
"sizeY": 14,
"row": 44,
"col": 0,
"mobileHide": true
},
"6d6e2b1d-6ce7-4678-3745-c6b0897b2674": {
"sizeX": 43,
"sizeY": 29,
"row": 13,
"sizeY": 17,
"row": 27,
"col": 0,
"mobileOrder": 2,
"mobileHeight": 10
},
"fe678c4f-ea86-4cae-8d81-6fca493fe311": {
"sizeX": 85,
"sizeY": 15,
"row": 0,
"col": 0,
"mobileOrder": 3,
"mobileHeight": 12
},
"35d3ac3b-f1af-dc3d-a1d1-11f351d16fc6": {
"sizeX": 43,
"sizeY": 13,
"row": 0,
"sizeY": 12,
"row": 15,
"col": 0,
"mobileHeight": 9,
"mobileOrder": 1
},
"7ac20b6a-dc40-b18e-9f5f-bca20bc693bb": {
"sizeX": 42,
"sizeY": 13,
"sizeY": 12,
"mobileHeight": 9,
"row": 0,
"row": 15,
"col": 43,
"mobileOrder": 0
},
@ -1365,15 +1398,15 @@
"widgets": {
"ed33e56f-293b-aaaa-ad19-0cf499dc926f": {
"sizeX": 120,
"sizeY": 45,
"sizeY": 44,
"row": 0,
"col": 0,
"mobileHide": true
},
"8c5207d8-7103-4dc2-db48-d61c0c8c61fd": {
"sizeX": 120,
"sizeY": 17,
"row": 45,
"sizeY": 14,
"row": 44,
"col": 0
}
},

3
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -9591,6 +9591,9 @@
"no-links-matching": "No links matching '{{name}}' were found.",
"columns": "Columns"
},
"iot-hub": {
"title-text": "Build faster with community-proven resources from"
},
"recent-dashboards": {
"title": "Dashboards",
"last": "Last viewed",

Loading…
Cancel
Save