Commit f1b58a9df16d63be44576ea6e966d6d9c14261df

Authored by Artem Babak
1 parent 716ed83d

Fixed and refactored customer edges

@@ -27,6 +27,7 @@ import { DashboardsTableConfigResolver } from '@modules/home/pages/dashboard/das @@ -27,6 +27,7 @@ import { DashboardsTableConfigResolver } from '@modules/home/pages/dashboard/das
27 import { DashboardPageComponent } from '@home/pages/dashboard/dashboard-page.component'; 27 import { DashboardPageComponent } from '@home/pages/dashboard/dashboard-page.component';
28 import { BreadCrumbConfig } from '@shared/components/breadcrumb'; 28 import { BreadCrumbConfig } from '@shared/components/breadcrumb';
29 import { dashboardBreadcumbLabelFunction, DashboardResolver } from '@home/pages/dashboard/dashboard-routing.module'; 29 import { dashboardBreadcumbLabelFunction, DashboardResolver } from '@home/pages/dashboard/dashboard-routing.module';
  30 +import {EdgesTableConfigResolver} from "@home/pages/edge/edges-table-config.resolver";
30 31
31 const routes: Routes = [ 32 const routes: Routes = [
32 { 33 {
@@ -97,6 +98,22 @@ const routes: Routes = [ @@ -97,6 +98,22 @@ const routes: Routes = [
97 } 98 }
98 }, 99 },
99 { 100 {
  101 + path: ':customerId/edges',
  102 + component: EntitiesTableComponent,
  103 + data: {
  104 + auth: [Authority.TENANT_ADMIN],
  105 + title: 'customer.edges',
  106 + edgesType: 'customer',
  107 + breadcrumb: {
  108 + label: 'customer.edges',
  109 + icon: 'router'
  110 + }
  111 + },
  112 + resolve: {
  113 + entitiesTableConfig: EdgesTableConfigResolver
  114 + }
  115 + },
  116 + {
100 path: ':customerId/dashboards', 117 path: ':customerId/dashboards',
101 data: { 118 data: {
102 breadcrumb: { 119 breadcrumb: {
@@ -95,7 +95,18 @@ export class CustomersTableConfigResolver implements Resolve<EntityTableConfig<C @@ -95,7 +95,18 @@ export class CustomersTableConfigResolver implements Resolve<EntityTableConfig<C
95 icon: 'dashboard', 95 icon: 'dashboard',
96 isEnabled: (customer) => true, 96 isEnabled: (customer) => true,
97 onAction: ($event, entity) => this.manageCustomerDashboards($event, entity) 97 onAction: ($event, entity) => this.manageCustomerDashboards($event, entity)
98 - } 98 + },
  99 + {
  100 + name: this.translate.instant('customer.manage-customer-edges'),
  101 + nameFunction: (customer) => {
  102 + return customer.additionalInfo && customer.additionalInfo.isPublic
  103 + ? this.translate.instant('customer.manage-public-edges')
  104 + : this.translate.instant('customer.manage-customer-edges');
  105 + },
  106 + icon: 'router',
  107 + isEnabled: (customer) => true,
  108 + onAction: ($event, entity) => this.manageCustomerEdges($event, entity)
  109 + },
99 ); 110 );
100 111
101 this.config.deleteEntityTitle = customer => this.translate.instant('customer.delete-customer-title', { customerTitle: customer.title }); 112 this.config.deleteEntityTitle = customer => this.translate.instant('customer.delete-customer-title', { customerTitle: customer.title });
@@ -147,6 +158,13 @@ export class CustomersTableConfigResolver implements Resolve<EntityTableConfig<C @@ -147,6 +158,13 @@ export class CustomersTableConfigResolver implements Resolve<EntityTableConfig<C
147 this.router.navigateByUrl(`customers/${customer.id.id}/dashboards`); 158 this.router.navigateByUrl(`customers/${customer.id.id}/dashboards`);
148 } 159 }
149 160
  161 + manageCustomerEdges($event: Event, customer: Customer) {
  162 + if ($event) {
  163 + $event.stopPropagation();
  164 + }
  165 + this.router.navigateByUrl(`customers/${customer.id.id}/edges`);
  166 + }
  167 +
150 onCustomerAction(action: EntityAction<Customer>): boolean { 168 onCustomerAction(action: EntityAction<Customer>): boolean {
151 switch (action.action) { 169 switch (action.action) {
152 case 'manageUsers': 170 case 'manageUsers':
@@ -40,7 +40,7 @@ const routes: Routes = [ @@ -40,7 +40,7 @@ const routes: Routes = [
40 component: EntitiesTableComponent, 40 component: EntitiesTableComponent,
41 data: { 41 data: {
42 auth: [Authority.TENANT_ADMIN, Authority.CUSTOMER_USER], 42 auth: [Authority.TENANT_ADMIN, Authority.CUSTOMER_USER],
43 - edgeScope: 'tenant' 43 + edgesType: 'tenant'
44 }, 44 },
45 resolve: { 45 resolve: {
46 entitiesTableConfig: EdgesTableConfigResolver 46 entitiesTableConfig: EdgesTableConfigResolver
@@ -107,7 +107,7 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI @@ -107,7 +107,7 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI
107 resolve(route: ActivatedRouteSnapshot): Observable<EntityTableConfig<EdgeInfo>> { 107 resolve(route: ActivatedRouteSnapshot): Observable<EntityTableConfig<EdgeInfo>> {
108 const routeParams = route.params; 108 const routeParams = route.params;
109 this.config.componentsData = { 109 this.config.componentsData = {
110 - edgeScope: route.data.edgeScope, 110 + edgeScope: route.data.edgesType,
111 edgeType: '' 111 edgeType: ''
112 }; 112 };
113 this.customerId = routeParams.customerId; 113 this.customerId = routeParams.customerId;
@@ -36,7 +36,6 @@ export interface Edge extends BaseData<EdgeId> { @@ -36,7 +36,6 @@ export interface Edge extends BaseData<EdgeId> {
36 export interface EdgeInfo extends Edge { 36 export interface EdgeInfo extends Edge {
37 customerTitle: string; 37 customerTitle: string;
38 customerIsPublic: boolean; 38 customerIsPublic: boolean;
39 - // assignedCustomers?: Array<ShortCustomerInfo> //TODO: deaflynx check usage  
40 } 39 }
41 40
42 export interface EdgeSearchQuery extends EntitySearchQuery { 41 export interface EdgeSearchQuery extends EntitySearchQuery {
@@ -422,6 +422,7 @@ @@ -422,6 +422,7 @@
422 "devices": "Customer Devices", 422 "devices": "Customer Devices",
423 "entity-views": "Customer Entity Views", 423 "entity-views": "Customer Entity Views",
424 "assets": "Customer Assets", 424 "assets": "Customer Assets",
  425 + "edges": "Customer Edges",
425 "public-dashboards": "Public Dashboards", 426 "public-dashboards": "Public Dashboards",
426 "public-devices": "Public Devices", 427 "public-devices": "Public Devices",
427 "public-assets": "Public Assets", 428 "public-assets": "Public Assets",
@@ -436,6 +437,8 @@ @@ -436,6 +437,8 @@
436 "manage-public-dashboards": "Manage public dashboards", 437 "manage-public-dashboards": "Manage public dashboards",
437 "manage-customer-assets": "Manage customer assets", 438 "manage-customer-assets": "Manage customer assets",
438 "manage-public-assets": "Manage public assets", 439 "manage-public-assets": "Manage public assets",
  440 + "manage-customer-edges": "Manage customer edges",
  441 + "manage-public-edges": "Manage customer edges",
439 "add-customer-text": "Add new customer", 442 "add-customer-text": "Add new customer",
440 "no-customers-text": "No customers found", 443 "no-customers-text": "No customers found",
441 "customer-details": "Customer details", 444 "customer-details": "Customer details",
@@ -446,6 +449,7 @@ @@ -446,6 +449,7 @@
446 "delete-customers-text": "Be careful, after the confirmation all selected customers will be removed and all related data will become unrecoverable.", 449 "delete-customers-text": "Be careful, after the confirmation all selected customers will be removed and all related data will become unrecoverable.",
447 "manage-users": "Manage users", 450 "manage-users": "Manage users",
448 "manage-assets": "Manage assets", 451 "manage-assets": "Manage assets",
  452 + "manage-edges": "Manage edges",
449 "manage-devices": "Manage devices", 453 "manage-devices": "Manage devices",
450 "manage-dashboards": "Manage dashboards", 454 "manage-dashboards": "Manage dashboards",
451 "title": "Title", 455 "title": "Title",
@@ -980,7 +984,9 @@ @@ -980,7 +984,9 @@
980 "set-root-rule-chain-to-edges-text": "Set root rule chain for { count, plural, 1 {1 edge} other {# edges} }", 984 "set-root-rule-chain-to-edges-text": "Set root rule chain for { count, plural, 1 {1 edge} other {# edges} }",
981 "status": "Received by edge", 985 "status": "Received by edge",
982 "success": "Deployed", 986 "success": "Deployed",
983 - "failed": "Pending" 987 + "failed": "Pending",
  988 + "search": "Search edges",
  989 + "selected-edges": "{ count, plural, 1 {1 edge} other {# edges} } selected"
984 }, 990 },
985 "error": { 991 "error": {
986 "unable-to-connect": "Unable to connect to the server! Please check your internet connection.", 992 "unable-to-connect": "Unable to connect to the server! Please check your internet connection.",