Fixed and refactored customer edges

This commit is contained in:
Artem Babak 2020-10-20 12:04:13 +03:00
parent 716ed83d8e
commit f1b58a9df1
6 changed files with 45 additions and 5 deletions

View File

@ -27,6 +27,7 @@ import { DashboardsTableConfigResolver } from '@modules/home/pages/dashboard/das
import { DashboardPageComponent } from '@home/pages/dashboard/dashboard-page.component'; import { DashboardPageComponent } from '@home/pages/dashboard/dashboard-page.component';
import { BreadCrumbConfig } from '@shared/components/breadcrumb'; import { BreadCrumbConfig } from '@shared/components/breadcrumb';
import { dashboardBreadcumbLabelFunction, DashboardResolver } from '@home/pages/dashboard/dashboard-routing.module'; import { dashboardBreadcumbLabelFunction, DashboardResolver } from '@home/pages/dashboard/dashboard-routing.module';
import {EdgesTableConfigResolver} from "@home/pages/edge/edges-table-config.resolver";
const routes: Routes = [ const routes: Routes = [
{ {
@ -96,6 +97,22 @@ const routes: Routes = [
entitiesTableConfig: AssetsTableConfigResolver entitiesTableConfig: AssetsTableConfigResolver
} }
}, },
{
path: ':customerId/edges',
component: EntitiesTableComponent,
data: {
auth: [Authority.TENANT_ADMIN],
title: 'customer.edges',
edgesType: 'customer',
breadcrumb: {
label: 'customer.edges',
icon: 'router'
}
},
resolve: {
entitiesTableConfig: EdgesTableConfigResolver
}
},
{ {
path: ':customerId/dashboards', path: ':customerId/dashboards',
data: { data: {

View File

@ -95,7 +95,18 @@ export class CustomersTableConfigResolver implements Resolve<EntityTableConfig<C
icon: 'dashboard', icon: 'dashboard',
isEnabled: (customer) => true, isEnabled: (customer) => true,
onAction: ($event, entity) => this.manageCustomerDashboards($event, entity) onAction: ($event, entity) => this.manageCustomerDashboards($event, entity)
} },
{
name: this.translate.instant('customer.manage-customer-edges'),
nameFunction: (customer) => {
return customer.additionalInfo && customer.additionalInfo.isPublic
? this.translate.instant('customer.manage-public-edges')
: this.translate.instant('customer.manage-customer-edges');
},
icon: 'router',
isEnabled: (customer) => true,
onAction: ($event, entity) => this.manageCustomerEdges($event, entity)
},
); );
this.config.deleteEntityTitle = customer => this.translate.instant('customer.delete-customer-title', { customerTitle: customer.title }); 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
this.router.navigateByUrl(`customers/${customer.id.id}/dashboards`); this.router.navigateByUrl(`customers/${customer.id.id}/dashboards`);
} }
manageCustomerEdges($event: Event, customer: Customer) {
if ($event) {
$event.stopPropagation();
}
this.router.navigateByUrl(`customers/${customer.id.id}/edges`);
}
onCustomerAction(action: EntityAction<Customer>): boolean { onCustomerAction(action: EntityAction<Customer>): boolean {
switch (action.action) { switch (action.action) {
case 'manageUsers': case 'manageUsers':

View File

@ -40,7 +40,7 @@ const routes: Routes = [
component: EntitiesTableComponent, component: EntitiesTableComponent,
data: { data: {
auth: [Authority.TENANT_ADMIN, Authority.CUSTOMER_USER], auth: [Authority.TENANT_ADMIN, Authority.CUSTOMER_USER],
edgeScope: 'tenant' edgesType: 'tenant'
}, },
resolve: { resolve: {
entitiesTableConfig: EdgesTableConfigResolver entitiesTableConfig: EdgesTableConfigResolver

View File

@ -107,7 +107,7 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI
resolve(route: ActivatedRouteSnapshot): Observable<EntityTableConfig<EdgeInfo>> { resolve(route: ActivatedRouteSnapshot): Observable<EntityTableConfig<EdgeInfo>> {
const routeParams = route.params; const routeParams = route.params;
this.config.componentsData = { this.config.componentsData = {
edgeScope: route.data.edgeScope, edgeScope: route.data.edgesType,
edgeType: '' edgeType: ''
}; };
this.customerId = routeParams.customerId; this.customerId = routeParams.customerId;

View File

@ -36,7 +36,6 @@ export interface Edge extends BaseData<EdgeId> {
export interface EdgeInfo extends Edge { export interface EdgeInfo extends Edge {
customerTitle: string; customerTitle: string;
customerIsPublic: boolean; customerIsPublic: boolean;
// assignedCustomers?: Array<ShortCustomerInfo> //TODO: deaflynx check usage
} }
export interface EdgeSearchQuery extends EntitySearchQuery { export interface EdgeSearchQuery extends EntitySearchQuery {

View File

@ -422,6 +422,7 @@
"devices": "Customer Devices", "devices": "Customer Devices",
"entity-views": "Customer Entity Views", "entity-views": "Customer Entity Views",
"assets": "Customer Assets", "assets": "Customer Assets",
"edges": "Customer Edges",
"public-dashboards": "Public Dashboards", "public-dashboards": "Public Dashboards",
"public-devices": "Public Devices", "public-devices": "Public Devices",
"public-assets": "Public Assets", "public-assets": "Public Assets",
@ -436,6 +437,8 @@
"manage-public-dashboards": "Manage public dashboards", "manage-public-dashboards": "Manage public dashboards",
"manage-customer-assets": "Manage customer assets", "manage-customer-assets": "Manage customer assets",
"manage-public-assets": "Manage public assets", "manage-public-assets": "Manage public assets",
"manage-customer-edges": "Manage customer edges",
"manage-public-edges": "Manage customer edges",
"add-customer-text": "Add new customer", "add-customer-text": "Add new customer",
"no-customers-text": "No customers found", "no-customers-text": "No customers found",
"customer-details": "Customer details", "customer-details": "Customer details",
@ -446,6 +449,7 @@
"delete-customers-text": "Be careful, after the confirmation all selected customers will be removed and all related data will become unrecoverable.", "delete-customers-text": "Be careful, after the confirmation all selected customers will be removed and all related data will become unrecoverable.",
"manage-users": "Manage users", "manage-users": "Manage users",
"manage-assets": "Manage assets", "manage-assets": "Manage assets",
"manage-edges": "Manage edges",
"manage-devices": "Manage devices", "manage-devices": "Manage devices",
"manage-dashboards": "Manage dashboards", "manage-dashboards": "Manage dashboards",
"title": "Title", "title": "Title",
@ -980,7 +984,9 @@
"set-root-rule-chain-to-edges-text": "Set root rule chain for { count, plural, 1 {1 edge} other {# edges} }", "set-root-rule-chain-to-edges-text": "Set root rule chain for { count, plural, 1 {1 edge} other {# edges} }",
"status": "Received by edge", "status": "Received by edge",
"success": "Deployed", "success": "Deployed",
"failed": "Pending" "failed": "Pending",
"search": "Search edges",
"selected-edges": "{ count, plural, 1 {1 edge} other {# edges} } selected"
}, },
"error": { "error": {
"unable-to-connect": "Unable to connect to the server! Please check your internet connection.", "unable-to-connect": "Unable to connect to the server! Please check your internet connection.",