+
+
+ {{settings.icon}}
+ {{translatedName}}
+
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/navigation-card-widget.component.scss b/ui-ngx/src/app/modules/home/components/widget/lib/navigation-card-widget.component.scss
new file mode 100644
index 0000000000..18a81aa216
--- /dev/null
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/navigation-card-widget.component.scss
@@ -0,0 +1,60 @@
+/**
+ * Copyright © 2016-2021 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.
+ */
+
+:host {
+ width: 100%;
+ height: 100%;
+}
+
+:host ::ng-deep {
+ .tb-nav-button {
+ width: 100%;
+ height: 100%;
+ &:hover {
+ border-bottom: none;
+ }
+ &:focus {
+ border-bottom: none;
+ }
+ .mat-button-wrapper {
+ width: 100%;
+ height: 100%;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ mat-icon {
+ margin: auto;
+ }
+ span {
+ height: 18px;
+ min-height: 36px;
+ max-height: 36px;
+ padding: 0 0 20px 0;
+ margin: auto;
+ font-size: 18px;
+ font-weight: 400;
+ line-height: 18px;
+ white-space: normal;
+ }
+ }
+ &.mat-raised-button.mat-primary {
+ .mat-ripple-element {
+ opacity: 0.3;
+ background-color: rgba(255, 255, 255, 0.3);
+ }
+ }
+ }
+}
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/navigation-card-widget.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/navigation-card-widget.component.ts
new file mode 100644
index 0000000000..5dbd8022ce
--- /dev/null
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/navigation-card-widget.component.ts
@@ -0,0 +1,66 @@
+///
+/// Copyright © 2016-2021 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 { PageComponent } from '@shared/components/page.component';
+import { Component, Input, NgZone, OnInit } from '@angular/core';
+import { WidgetContext } from '@home/models/widget-component.models';
+import { Store } from '@ngrx/store';
+import { AppState } from '@core/core.state';
+import { Router } from '@angular/router';
+import { UtilsService } from '@core/services/utils.service';
+
+interface NavigationCardWidgetSettings {
+ name: string;
+ icon: string;
+ path: string;
+}
+
+@Component({
+ selector: 'tb-navigation-card-widget',
+ templateUrl: './navigation-card-widget.component.html',
+ styleUrls: ['./navigation-card-widget.component.scss']
+})
+export class NavigationCardWidgetComponent extends PageComponent implements OnInit {
+
+ settings: NavigationCardWidgetSettings;
+
+ translatedName: string;
+
+ @Input()
+ ctx: WidgetContext;
+
+ constructor(protected store: Store,
+ private utils: UtilsService,
+ private ngZone: NgZone,
+ private router: Router) {
+ super(store);
+ }
+
+ ngOnInit(): void {
+ this.ctx.$scope.navigationCardWidget = this;
+ this.settings = this.ctx.settings;
+ this.translatedName = this.utils.customTranslation(this.settings.name, this.settings.name);
+ }
+
+
+ navigate($event: Event, path: string) {
+ $event.preventDefault();
+ this.ngZone.run(() => {
+ this.router.navigateByUrl(path);
+ });
+ }
+
+}
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/navigation-cards-widget.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/navigation-cards-widget.component.html
new file mode 100644
index 0000000000..a9ed8e76bb
--- /dev/null
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/navigation-cards-widget.component.html
@@ -0,0 +1,37 @@
+
+
+
+
+
+ {{section.name}}
+
+
+
+
+
+ {{place.icon}}
+
+ {{place.name}}
+
+
+
+
+
+
+
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/navigation-cards-widget.component.scss b/ui-ngx/src/app/modules/home/components/widget/lib/navigation-cards-widget.component.scss
new file mode 100644
index 0000000000..6a0e60c20b
--- /dev/null
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/navigation-cards-widget.component.scss
@@ -0,0 +1,85 @@
+/**
+ * Copyright © 2016-2021 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 {
+ width: 100%;
+ height: 100%;
+}
+
+:host ::ng-deep {
+ .tb-navigation-cards {
+ .mat-headline {
+ font-size: 20px;
+ @media #{$mat-gt-xmd} {
+ font-size: 24px;
+ }
+ }
+ mat-card {
+ padding: 0;
+ margin: 8px;
+ mat-card-title {
+ margin: 0;
+ padding: 24px 16px 16px;
+ }
+ mat-card-title+mat-card-content {
+ padding-top: 0;
+ }
+ mat-card-content {
+ padding: 16px;
+ }
+ }
+ .tb-card-button {
+ width: 100%;
+ height: 100%;
+ max-width: 240px;
+ &:hover {
+ border-bottom: none;
+ }
+ &:focus {
+ border-bottom: none;
+ }
+ .mat-button-wrapper {
+ width: 100%;
+ height: 100%;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ mat-icon {
+ margin: auto;
+ }
+ span {
+ height: 18px;
+ min-height: 36px;
+ max-height: 36px;
+ padding: 0 0 20px 0;
+ margin: auto;
+ font-size: 18px;
+ font-weight: 400;
+ line-height: 18px;
+ white-space: normal;
+ }
+ }
+ &.mat-raised-button.mat-primary {
+ .mat-ripple-element {
+ opacity: 0.3;
+ background-color: rgba(255, 255, 255, 0.3);
+ }
+ }
+ }
+ }
+}
+
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/navigation-cards-widget.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/navigation-cards-widget.component.ts
new file mode 100644
index 0000000000..7628c30457
--- /dev/null
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/navigation-cards-widget.component.ts
@@ -0,0 +1,114 @@
+///
+/// Copyright © 2016-2021 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 { PageComponent } from '@shared/components/page.component';
+import { Component, Input, NgZone, OnInit } from '@angular/core';
+import { WidgetContext } from '@home/models/widget-component.models';
+import { Store } from '@ngrx/store';
+import { AppState } from '@core/core.state';
+import { MenuService } from '@core/services/menu.service';
+import { HomeSection, HomeSectionPlace } from '@core/services/menu.models';
+import { Router } from '@angular/router';
+import { map } from 'rxjs/operators';
+
+interface NavigationCardsWidgetSettings {
+ filterType: 'all' | 'include' | 'exclude';
+ filter: string[];
+}
+
+@Component({
+ selector: 'tb-navigation-cards-widget',
+ templateUrl: './navigation-cards-widget.component.html',
+ styleUrls: ['./navigation-cards-widget.component.scss']
+})
+export class NavigationCardsWidgetComponent extends PageComponent implements OnInit {
+
+ homeSections$ = this.menuService.homeSections();
+ showHomeSections$ = this.homeSections$.pipe(
+ map((sections) => {
+ return sections.filter((section) => this.sectionPlaces(section).length > 0);
+ })
+ );
+
+ cols = null;
+
+ settings: NavigationCardsWidgetSettings;
+
+ @Input()
+ ctx: WidgetContext;
+
+ constructor(protected store: Store,
+ private menuService: MenuService,
+ private ngZone: NgZone,
+ private router: Router) {
+ super(store);
+ }
+
+ ngOnInit(): void {
+ this.ctx.$scope.navigationCardsWidget = this;
+ this.settings = this.ctx.settings;
+ }
+
+ resize() {
+ this.updateColumnCount();
+ }
+
+ private updateColumnCount() {
+ this.cols = 2;
+ const width = this.ctx.width;
+ if (width >= 1280) {
+ this.cols = 3;
+ if (width >= 1920) {
+ this.cols = 4;
+ }
+ }
+ this.ctx.detectChanges();
+ }
+
+ navigate($event: Event, path: string) {
+ $event.preventDefault();
+ this.ngZone.run(() => {
+ this.router.navigateByUrl(path);
+ });
+ }
+
+ sectionPlaces(section: HomeSection): HomeSectionPlace[] {
+ return section && section.places ? section.places.filter((place) => this.filterPlace(place)) : [];
+ }
+
+ private filterPlace(place: HomeSectionPlace): boolean {
+ if (this.settings.filterType === 'include') {
+ return this.settings.filter.includes(place.path);
+ } else if (this.settings.filterType === 'exclude') {
+ return !this.settings.filter.includes(place.path);
+ }
+ return true;
+ }
+
+ sectionColspan(section: HomeSection): number {
+ if (this.ctx.width >= 960) {
+ let colspan = this.cols;
+ const places = this.sectionPlaces(section);
+ if (places.length <= colspan) {
+ colspan = places.length;
+ }
+ return colspan;
+ } else {
+ return 2;
+ }
+ }
+
+}
diff --git a/ui-ngx/src/app/modules/home/components/widget/widget-components.module.ts b/ui-ngx/src/app/modules/home/components/widget/widget-components.module.ts
index 0c143f2b57..2d080bc8e9 100644
--- a/ui-ngx/src/app/modules/home/components/widget/widget-components.module.ts
+++ b/ui-ngx/src/app/modules/home/components/widget/widget-components.module.ts
@@ -35,6 +35,8 @@ import { TripAnimationComponent } from './trip-animation/trip-animation.componen
import { PhotoCameraInputWidgetComponent } from './lib/photo-camera-input.component';
import { GatewayFormComponent } from './lib/gateway/gateway-form.component';
import { ImportExportService } from '@home/components/import-export/import-export.service';
+import { NavigationCardsWidgetComponent } from '@home/components/widget/lib/navigation-cards-widget.component';
+import { NavigationCardWidgetComponent } from '@home/components/widget/lib/navigation-card-widget.component';
@NgModule({
declarations:
@@ -50,7 +52,9 @@ import { ImportExportService } from '@home/components/import-export/import-expor
MultipleInputWidgetComponent,
TripAnimationComponent,
PhotoCameraInputWidgetComponent,
- GatewayFormComponent
+ GatewayFormComponent,
+ NavigationCardsWidgetComponent,
+ NavigationCardWidgetComponent
],
imports: [
CommonModule,
@@ -68,7 +72,9 @@ import { ImportExportService } from '@home/components/import-export/import-expor
MultipleInputWidgetComponent,
TripAnimationComponent,
PhotoCameraInputWidgetComponent,
- GatewayFormComponent
+ GatewayFormComponent,
+ NavigationCardsWidgetComponent,
+ NavigationCardWidgetComponent
],
providers: [
CustomDialogService,
diff --git a/ui-ngx/src/app/modules/home/pages/admin/admin-routing.module.ts b/ui-ngx/src/app/modules/home/pages/admin/admin-routing.module.ts
index 1df4aed59e..1928a1f404 100644
--- a/ui-ngx/src/app/modules/home/pages/admin/admin-routing.module.ts
+++ b/ui-ngx/src/app/modules/home/pages/admin/admin-routing.module.ts
@@ -32,6 +32,7 @@ import { getCurrentAuthUser } from '@core/auth/auth.selectors';
import { OAuth2Service } from '@core/http/oauth2.service';
import { UserProfileResolver } from '@home/pages/profile/profile-routing.module';
import { SmsProviderComponent } from '@home/pages/admin/sms-provider.component';
+import { HomeSettingsComponent } from '@home/pages/admin/home-settings.component';
@Injectable()
export class OAuth2LoginProcessingUrlResolver implements Resolve {
@@ -48,7 +49,7 @@ const routes: Routes = [
{
path: 'settings',
data: {
- auth: [Authority.SYS_ADMIN],
+ auth: [Authority.SYS_ADMIN, Authority.TENANT_ADMIN],
breadcrumb: {
label: 'admin.system-settings',
icon: 'settings'
@@ -57,8 +58,13 @@ const routes: Routes = [
children: [
{
path: '',
- redirectTo: 'general',
- pathMatch: 'full'
+ data: {
+ auth: [Authority.SYS_ADMIN, Authority.TENANT_ADMIN],
+ redirectTo: {
+ SYS_ADMIN: '/settings/general',
+ TENANT_ADMIN: '/settings/home'
+ }
+ }
},
{
path: 'general',
@@ -127,6 +133,19 @@ const routes: Routes = [
resolve: {
loginProcessingUrl: OAuth2LoginProcessingUrlResolver
}
+ },
+ {
+ path: 'home',
+ component: HomeSettingsComponent,
+ canDeactivate: [ConfirmOnExitGuard],
+ data: {
+ auth: [Authority.TENANT_ADMIN],
+ title: 'admin.home-settings',
+ breadcrumb: {
+ label: 'admin.home-settings',
+ icon: 'settings_applications'
+ }
+ }
}
]
}
diff --git a/ui-ngx/src/app/modules/home/pages/admin/admin.module.ts b/ui-ngx/src/app/modules/home/pages/admin/admin.module.ts
index a170ce10b4..1671220cfe 100644
--- a/ui-ngx/src/app/modules/home/pages/admin/admin.module.ts
+++ b/ui-ngx/src/app/modules/home/pages/admin/admin.module.ts
@@ -26,6 +26,7 @@ import { HomeComponentsModule } from '@modules/home/components/home-components.m
import { OAuth2SettingsComponent } from '@modules/home/pages/admin/oauth2-settings.component';
import { SmsProviderComponent } from '@home/pages/admin/sms-provider.component';
import { SendTestSmsDialogComponent } from '@home/pages/admin/send-test-sms-dialog.component';
+import { HomeSettingsComponent } from '@home/pages/admin/home-settings.component';
@NgModule({
declarations:
@@ -35,7 +36,8 @@ import { SendTestSmsDialogComponent } from '@home/pages/admin/send-test-sms-dial
SmsProviderComponent,
SendTestSmsDialogComponent,
SecuritySettingsComponent,
- OAuth2SettingsComponent
+ OAuth2SettingsComponent,
+ HomeSettingsComponent
],
imports: [
CommonModule,
diff --git a/ui-ngx/src/app/modules/home/pages/admin/home-settings.component.html b/ui-ngx/src/app/modules/home/pages/admin/home-settings.component.html
new file mode 100644
index 0000000000..0191724a24
--- /dev/null
+++ b/ui-ngx/src/app/modules/home/pages/admin/home-settings.component.html
@@ -0,0 +1,54 @@
+
+
+
+
+
+ admin.home-settings
+
+
+
+
+
+
+
+
+
+
diff --git a/ui-ngx/src/app/modules/home/pages/admin/home-settings.component.scss b/ui-ngx/src/app/modules/home/pages/admin/home-settings.component.scss
new file mode 100644
index 0000000000..482889cf77
--- /dev/null
+++ b/ui-ngx/src/app/modules/home/pages/admin/home-settings.component.scss
@@ -0,0 +1,36 @@
+/**
+ * Copyright © 2016-2021 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-default-dashboard {
+ tb-dashboard-autocomplete {
+ @media #{$mat-gt-sm} {
+ padding-right: 12px;
+ }
+
+ @media #{$mat-lt-md} {
+ padding-bottom: 12px;
+ }
+ }
+ mat-checkbox {
+ @media #{$mat-gt-sm} {
+ margin-top: 16px;
+ }
+ }
+ }
+}
diff --git a/ui-ngx/src/app/modules/home/pages/admin/home-settings.component.ts b/ui-ngx/src/app/modules/home/pages/admin/home-settings.component.ts
new file mode 100644
index 0000000000..a92579d701
--- /dev/null
+++ b/ui-ngx/src/app/modules/home/pages/admin/home-settings.component.ts
@@ -0,0 +1,84 @@
+///
+/// Copyright © 2016-2021 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, OnInit } from '@angular/core';
+import { Store } from '@ngrx/store';
+import { AppState } from '@core/core.state';
+import { PageComponent } from '@shared/components/page.component';
+import { Router } from '@angular/router';
+import { FormBuilder, FormGroup } from '@angular/forms';
+import { HasConfirmForm } from '@core/guards/confirm-on-exit.guard';
+import { DashboardService } from '@core/http/dashboard.service';
+import { HomeDashboardInfo } from '@shared/models/dashboard.models';
+import { isDefinedAndNotNull } from '@core/utils';
+import { DashboardId } from '@shared/models/id/dashboard-id';
+
+@Component({
+ selector: 'tb-home-settings',
+ templateUrl: './home-settings.component.html',
+ styleUrls: ['./home-settings.component.scss', './settings-card.scss']
+})
+export class HomeSettingsComponent extends PageComponent implements OnInit, HasConfirmForm {
+
+ homeSettings: FormGroup;
+
+ constructor(protected store: Store,
+ private router: Router,
+ private dashboardService: DashboardService,
+ public fb: FormBuilder) {
+ super(store);
+ }
+
+ ngOnInit() {
+ this.homeSettings = this.fb.group({
+ dashboardId: [null],
+ hideDashboardToolbar: [true]
+ });
+ this.dashboardService.getTenantHomeDashboardInfo().subscribe(
+ (homeDashboardInfo) => {
+ this.setHomeDashboardInfo(homeDashboardInfo);
+ }
+ );
+ }
+
+ save(): void {
+ const strDashboardId = this.homeSettings.get('dashboardId').value;
+ const dashboardId: DashboardId = strDashboardId ? new DashboardId(strDashboardId) : null;
+ const hideDashboardToolbar = this.homeSettings.get('hideDashboardToolbar').value;
+ const homeDashboardInfo: HomeDashboardInfo = {
+ dashboardId,
+ hideDashboardToolbar
+ };
+ this.dashboardService.setTenantHomeDashboardInfo(homeDashboardInfo).subscribe(
+ () => {
+ this.setHomeDashboardInfo(homeDashboardInfo);
+ }
+ );
+ }
+
+ confirmForm(): FormGroup {
+ return this.homeSettings;
+ }
+
+ private setHomeDashboardInfo(homeDashboardInfo: HomeDashboardInfo) {
+ this.homeSettings.reset({
+ dashboardId: homeDashboardInfo?.dashboardId?.id,
+ hideDashboardToolbar: isDefinedAndNotNull(homeDashboardInfo?.hideDashboardToolbar) ?
+ homeDashboardInfo?.hideDashboardToolbar : true
+ });
+ }
+
+}
diff --git a/ui-ngx/src/app/modules/home/pages/customer/customer.component.html b/ui-ngx/src/app/modules/home/pages/customer/customer.component.html
index fce5c1926c..392ae7b6c4 100644
--- a/ui-ngx/src/app/modules/home/pages/customer/customer.component.html
+++ b/ui-ngx/src/app/modules/home/pages/customer/customer.component.html
@@ -72,6 +72,21 @@
customer.description
+
+
+
+
+ {{ 'dashboard.home-dashboard-hide-toolbar' | translate }}
+
+
+
diff --git a/ui-ngx/src/app/modules/home/pages/customer/customer.component.scss b/ui-ngx/src/app/modules/home/pages/customer/customer.component.scss
new file mode 100644
index 0000000000..3a4ec550cd
--- /dev/null
+++ b/ui-ngx/src/app/modules/home/pages/customer/customer.component.scss
@@ -0,0 +1,35 @@
+/**
+ * Copyright © 2016-2021 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-default-dashboard {
+ tb-dashboard-autocomplete {
+ @media #{$mat-gt-sm} {
+ padding-right: 12px;
+ }
+
+ @media #{$mat-lt-md} {
+ padding-bottom: 12px;
+ }
+ }
+ mat-checkbox {
+ @media #{$mat-gt-sm} {
+ margin-top: 16px;
+ }
+ }
+ }
+}
diff --git a/ui-ngx/src/app/modules/home/pages/customer/customer.component.ts b/ui-ngx/src/app/modules/home/pages/customer/customer.component.ts
index 809beef5cd..8c609fe2ef 100644
--- a/ui-ngx/src/app/modules/home/pages/customer/customer.component.ts
+++ b/ui-ngx/src/app/modules/home/pages/customer/customer.component.ts
@@ -23,10 +23,12 @@ import { ActionNotificationShow } from '@app/core/notification/notification.acti
import { TranslateService } from '@ngx-translate/core';
import { ContactBasedComponent } from '../../components/entity/contact-based.component';
import { EntityTableConfig } from '@home/models/entity/entities-table-config.models';
+import { isDefinedAndNotNull } from '@core/utils';
@Component({
selector: 'tb-customer',
- templateUrl: './customer.component.html'
+ templateUrl: './customer.component.html',
+ styleUrls: ['./customer.component.scss']
})
export class CustomerComponent extends ContactBasedComponent
{
@@ -54,7 +56,10 @@ export class CustomerComponent extends ContactBasedComponent {
title: [entity ? entity.title : '', [Validators.required]],
additionalInfo: this.fb.group(
{
- description: [entity && entity.additionalInfo ? entity.additionalInfo.description : '']
+ description: [entity && entity.additionalInfo ? entity.additionalInfo.description : ''],
+ homeDashboardId: [entity && entity.additionalInfo ? entity.additionalInfo.homeDashboardId : null],
+ homeDashboardHideToolbar: [entity && entity.additionalInfo &&
+ isDefinedAndNotNull(entity.additionalInfo.homeDashboardHideToolbar) ? entity.additionalInfo.homeDashboardHideToolbar : true]
}
)
}
@@ -65,6 +70,11 @@ export class CustomerComponent extends ContactBasedComponent {
this.isPublic = entity.additionalInfo && entity.additionalInfo.isPublic;
this.entityForm.patchValue({title: entity.title});
this.entityForm.patchValue({additionalInfo: {description: entity.additionalInfo ? entity.additionalInfo.description : ''}});
+ this.entityForm.patchValue({additionalInfo:
+ {homeDashboardId: entity.additionalInfo ? entity.additionalInfo.homeDashboardId : null}});
+ this.entityForm.patchValue({additionalInfo:
+ {homeDashboardHideToolbar: entity.additionalInfo &&
+ isDefinedAndNotNull(entity.additionalInfo.homeDashboardHideToolbar) ? entity.additionalInfo.homeDashboardHideToolbar : true}});
}
onCustomerIdCopied(event) {
diff --git a/ui-ngx/src/app/modules/home/pages/home-links/home-links-routing.module.ts b/ui-ngx/src/app/modules/home/pages/home-links/home-links-routing.module.ts
index c1aa7764f0..003ba5d34a 100644
--- a/ui-ngx/src/app/modules/home/pages/home-links/home-links-routing.module.ts
+++ b/ui-ngx/src/app/modules/home/pages/home-links/home-links-routing.module.ts
@@ -14,11 +14,25 @@
/// limitations under the License.
///
-import { NgModule } from '@angular/core';
-import { RouterModule, Routes } from '@angular/router';
+import { Injectable, NgModule } from '@angular/core';
+import { Resolve, RouterModule, Routes } from '@angular/router';
import { HomeLinksComponent } from './home-links.component';
import { Authority } from '@shared/models/authority.enum';
+import { Observable } from 'rxjs';
+import { HomeDashboard } from '@shared/models/dashboard.models';
+import { DashboardService } from '@core/http/dashboard.service';
+
+@Injectable()
+export class HomeDashboardResolver implements Resolve {
+
+ constructor(private dashboardService: DashboardService) {
+ }
+
+ resolve(): Observable {
+ return this.dashboardService.getHomeDashboard();
+ }
+}
const routes: Routes = [
{
@@ -31,12 +45,18 @@ const routes: Routes = [
label: 'home.home',
icon: 'home'
}
+ },
+ resolve: {
+ homeDashboard: HomeDashboardResolver
}
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
- exports: [RouterModule]
+ exports: [RouterModule],
+ providers: [
+ HomeDashboardResolver
+ ]
})
export class HomeLinksRoutingModule { }
diff --git a/ui-ngx/src/app/modules/home/pages/home-links/home-links.component.html b/ui-ngx/src/app/modules/home/pages/home-links/home-links.component.html
index 85b5b388a7..f519d22637 100644
--- a/ui-ngx/src/app/modules/home/pages/home-links/home-links.component.html
+++ b/ui-ngx/src/app/modules/home/pages/home-links/home-links.component.html
@@ -15,23 +15,26 @@
limitations under the License.
-->
-
-
-
-
- {{section.name}}
-
-
-
-
-
- {{place.icon}}
-
- {{place.name}}
-
-
-
-
-
-
-
+
+
+
+
+
+
+ {{section.name}}
+
+
+
+
+
+ {{place.icon}}
+
+ {{place.name}}
+
+
+
+
+
+
+
+
diff --git a/ui-ngx/src/app/modules/home/pages/home-links/home-links.component.scss b/ui-ngx/src/app/modules/home/pages/home-links/home-links.component.scss
index a97e7083e0..20949642ab 100644
--- a/ui-ngx/src/app/modules/home/pages/home-links/home-links.component.scss
+++ b/ui-ngx/src/app/modules/home/pages/home-links/home-links.component.scss
@@ -15,6 +15,11 @@
*/
@import '../../../../../scss/constants';
+:host {
+ width: 100%;
+ height: 100%;
+}
+
:host ::ng-deep {
.tb-home-links {
.mat-headline {
diff --git a/ui-ngx/src/app/modules/home/pages/home-links/home-links.component.ts b/ui-ngx/src/app/modules/home/pages/home-links/home-links.component.ts
index 7d5348c04f..7f485df45c 100644
--- a/ui-ngx/src/app/modules/home/pages/home-links/home-links.component.ts
+++ b/ui-ngx/src/app/modules/home/pages/home-links/home-links.component.ts
@@ -19,6 +19,8 @@ import { MenuService } from '@core/services/menu.service';
import { BreakpointObserver, BreakpointState } from '@angular/cdk/layout';
import { MediaBreakpoints } from '@shared/models/constants';
import { HomeSection } from '@core/services/menu.models';
+import { ActivatedRoute } from '@angular/router';
+import { HomeDashboard } from '@shared/models/dashboard.models';
@Component({
selector: 'tb-home-links',
@@ -31,15 +33,20 @@ export class HomeLinksComponent implements OnInit {
cols = 2;
+ homeDashboard: HomeDashboard = this.route.snapshot.data.homeDashboard;
+
constructor(private menuService: MenuService,
- public breakpointObserver: BreakpointObserver) {
+ public breakpointObserver: BreakpointObserver,
+ private route: ActivatedRoute) {
}
ngOnInit() {
- this.updateColumnCount();
- this.breakpointObserver
- .observe([MediaBreakpoints.lg, MediaBreakpoints['gt-lg']])
- .subscribe((state: BreakpointState) => this.updateColumnCount());
+ if (!this.homeDashboard) {
+ this.updateColumnCount();
+ this.breakpointObserver
+ .observe([MediaBreakpoints.lg, MediaBreakpoints['gt-lg']])
+ .subscribe((state: BreakpointState) => this.updateColumnCount());
+ }
}
private updateColumnCount() {
diff --git a/ui-ngx/src/app/modules/home/pages/home-links/home-links.module.ts b/ui-ngx/src/app/modules/home/pages/home-links/home-links.module.ts
index e64b9b1768..644645c1a9 100644
--- a/ui-ngx/src/app/modules/home/pages/home-links/home-links.module.ts
+++ b/ui-ngx/src/app/modules/home/pages/home-links/home-links.module.ts
@@ -20,6 +20,7 @@ import { CommonModule } from '@angular/common';
import { HomeLinksRoutingModule } from './home-links-routing.module';
import { HomeLinksComponent } from './home-links.component';
import { SharedModule } from '@app/shared/shared.module';
+import { HomeComponentsModule } from '@home/components/home-components.module';
@NgModule({
declarations:
@@ -29,6 +30,7 @@ import { SharedModule } from '@app/shared/shared.module';
imports: [
CommonModule,
SharedModule,
+ HomeComponentsModule,
HomeLinksRoutingModule
]
})
diff --git a/ui-ngx/src/app/modules/home/pages/profile/profile.component.html b/ui-ngx/src/app/modules/home/pages/profile/profile.component.html
index 7ab52a373a..eaca7133a0 100644
--- a/ui-ngx/src/app/modules/home/pages/profile/profile.component.html
+++ b/ui-ngx/src/app/modules/home/pages/profile/profile.component.html
@@ -63,6 +63,20 @@
+
+
+
+ {{ 'dashboard.home-dashboard-hide-toolbar' | translate }}
+
+
diff --git a/ui-ngx/src/app/modules/home/pages/tenant/tenant.component.scss b/ui-ngx/src/app/modules/home/pages/tenant/tenant.component.scss
new file mode 100644
index 0000000000..3a4ec550cd
--- /dev/null
+++ b/ui-ngx/src/app/modules/home/pages/tenant/tenant.component.scss
@@ -0,0 +1,35 @@
+/**
+ * Copyright © 2016-2021 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-default-dashboard {
+ tb-dashboard-autocomplete {
+ @media #{$mat-gt-sm} {
+ padding-right: 12px;
+ }
+
+ @media #{$mat-lt-md} {
+ padding-bottom: 12px;
+ }
+ }
+ mat-checkbox {
+ @media #{$mat-gt-sm} {
+ margin-top: 16px;
+ }
+ }
+ }
+}
diff --git a/ui-ngx/src/app/modules/home/pages/tenant/tenant.component.ts b/ui-ngx/src/app/modules/home/pages/tenant/tenant.component.ts
index a24a17e6bf..30c0dc36aa 100644
--- a/ui-ngx/src/app/modules/home/pages/tenant/tenant.component.ts
+++ b/ui-ngx/src/app/modules/home/pages/tenant/tenant.component.ts
@@ -23,11 +23,12 @@ import { ActionNotificationShow } from '@app/core/notification/notification.acti
import { TranslateService } from '@ngx-translate/core';
import { ContactBasedComponent } from '../../components/entity/contact-based.component';
import { EntityTableConfig } from '@home/models/entity/entities-table-config.models';
+import { isDefinedAndNotNull } from '@core/utils';
@Component({
selector: 'tb-tenant',
templateUrl: './tenant.component.html',
- styleUrls: []
+ styleUrls: ['./tenant.component.scss']
})
export class TenantComponent extends ContactBasedComponent {
@@ -54,7 +55,10 @@ export class TenantComponent extends ContactBasedComponent {
tenantProfileId: [entity ? entity.tenantProfileId : null, [Validators.required]],
additionalInfo: this.fb.group(
{
- description: [entity && entity.additionalInfo ? entity.additionalInfo.description : '']
+ description: [entity && entity.additionalInfo ? entity.additionalInfo.description : ''],
+ homeDashboardId: [entity && entity.additionalInfo ? entity.additionalInfo.homeDashboardId : null],
+ homeDashboardHideToolbar: [entity && entity.additionalInfo &&
+ isDefinedAndNotNull(entity.additionalInfo.homeDashboardHideToolbar) ? entity.additionalInfo.homeDashboardHideToolbar : true]
}
)
}
@@ -65,6 +69,11 @@ export class TenantComponent extends ContactBasedComponent {
this.entityForm.patchValue({title: entity.title});
this.entityForm.patchValue({tenantProfileId: entity.tenantProfileId});
this.entityForm.patchValue({additionalInfo: {description: entity.additionalInfo ? entity.additionalInfo.description : ''}});
+ this.entityForm.patchValue({additionalInfo:
+ {homeDashboardId: entity.additionalInfo ? entity.additionalInfo.homeDashboardId : null}});
+ this.entityForm.patchValue({additionalInfo:
+ {homeDashboardHideToolbar: entity.additionalInfo &&
+ isDefinedAndNotNull(entity.additionalInfo.homeDashboardHideToolbar) ? entity.additionalInfo.homeDashboardHideToolbar : true}});
}
updateFormState() {
diff --git a/ui-ngx/src/app/modules/home/pages/user/user.component.html b/ui-ngx/src/app/modules/home/pages/user/user.component.html
index fbc5f3c1c7..20821031b0 100644
--- a/ui-ngx/src/app/modules/home/pages/user/user.component.html
+++ b/ui-ngx/src/app/modules/home/pages/user/user.component.html
@@ -95,6 +95,20 @@
{{ 'user.always-fullscreen' | translate }}
+
+
+
+ {{ 'dashboard.home-dashboard-hide-toolbar' | translate }}
+
+
diff --git a/ui-ngx/src/app/modules/home/pages/user/user.component.ts b/ui-ngx/src/app/modules/home/pages/user/user.component.ts
index 585723b659..b9326a696f 100644
--- a/ui-ngx/src/app/modules/home/pages/user/user.component.ts
+++ b/ui-ngx/src/app/modules/home/pages/user/user.component.ts
@@ -23,7 +23,7 @@ import { User } from '@shared/models/user.model';
import { selectAuth } from '@core/auth/auth.selectors';
import { map } from 'rxjs/operators';
import { Authority } from '@shared/models/authority.enum';
-import { isUndefined } from '@core/utils';
+import { isDefinedAndNotNull, isUndefined } from '@core/utils';
import { EntityTableConfig } from '@home/models/entity/entities-table-config.models';
@Component({
@@ -74,6 +74,9 @@ export class UserComponent extends EntityComponent