Added button unassignFromEdge for entities. Added findAssetsByTenantIdAndEdgeIdAndType()
This commit is contained in:
parent
04e50696f6
commit
3ffa7e3592
@ -485,6 +485,7 @@ public class AssetController extends BaseController {
|
|||||||
@PathVariable(EDGE_ID) String strEdgeId,
|
@PathVariable(EDGE_ID) String strEdgeId,
|
||||||
@RequestParam int pageSize,
|
@RequestParam int pageSize,
|
||||||
@RequestParam int page,
|
@RequestParam int page,
|
||||||
|
@RequestParam(required = false) String type,
|
||||||
@RequestParam(required = false) String textSearch,
|
@RequestParam(required = false) String textSearch,
|
||||||
@RequestParam(required = false) String sortProperty,
|
@RequestParam(required = false) String sortProperty,
|
||||||
@RequestParam(required = false) String sortOrder,
|
@RequestParam(required = false) String sortOrder,
|
||||||
@ -496,7 +497,11 @@ public class AssetController extends BaseController {
|
|||||||
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
||||||
checkEdgeId(edgeId, Operation.READ);
|
checkEdgeId(edgeId, Operation.READ);
|
||||||
TimePageLink pageLink = createTimePageLink(pageSize, page, textSearch, sortProperty, sortOrder, startTime, endTime);
|
TimePageLink pageLink = createTimePageLink(pageSize, page, textSearch, sortProperty, sortOrder, startTime, endTime);
|
||||||
return checkNotNull(assetService.findAssetsByTenantIdAndEdgeId(tenantId, edgeId, pageLink));
|
if (type != null && type.trim().length() > 0) {
|
||||||
|
return checkNotNull(assetService.findAssetsByTenantIdAndEdgeIdAndType(tenantId, edgeId, type, pageLink));
|
||||||
|
} else {
|
||||||
|
return checkNotNull(assetService.findAssetsByTenantIdAndEdgeId(tenantId, edgeId, pageLink));
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw handleException(e);
|
throw handleException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -82,4 +82,6 @@ public interface AssetService {
|
|||||||
Asset unassignAssetFromEdge(TenantId tenantId, AssetId assetId, EdgeId edgeId);
|
Asset unassignAssetFromEdge(TenantId tenantId, AssetId assetId, EdgeId edgeId);
|
||||||
|
|
||||||
PageData<Asset> findAssetsByTenantIdAndEdgeId(TenantId tenantId, EdgeId edgeId, TimePageLink pageLink);
|
PageData<Asset> findAssetsByTenantIdAndEdgeId(TenantId tenantId, EdgeId edgeId, TimePageLink pageLink);
|
||||||
|
|
||||||
|
PageData<Asset> findAssetsByTenantIdAndEdgeIdAndType(TenantId tenantId, EdgeId edgeId, String type, TimePageLink pageLink);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -176,4 +176,15 @@ public interface AssetDao extends Dao<Asset> {
|
|||||||
* @return the list of asset objects
|
* @return the list of asset objects
|
||||||
*/
|
*/
|
||||||
PageData<Asset> findAssetsByTenantIdAndEdgeId(UUID tenantId, UUID edgeId, TimePageLink pageLink);
|
PageData<Asset> findAssetsByTenantIdAndEdgeId(UUID tenantId, UUID edgeId, TimePageLink pageLink);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find assets by tenantId, edgeId, type and page link.
|
||||||
|
*
|
||||||
|
* @param tenantId the tenantId
|
||||||
|
* @param edgeId the edgeId
|
||||||
|
* @param type the type
|
||||||
|
* @param pageLink the page link
|
||||||
|
* @return the list of asset objects
|
||||||
|
*/
|
||||||
|
PageData<Asset> findAssetsByTenantIdAndEdgeIdAndType(UUID tenantId, UUID edgeId, String type, TimePageLink pageLink);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -364,6 +364,16 @@ public class BaseAssetService extends AbstractEntityService implements AssetServ
|
|||||||
return assetDao.findAssetsByTenantIdAndEdgeId(tenantId.getId(), edgeId.getId(), pageLink);
|
return assetDao.findAssetsByTenantIdAndEdgeId(tenantId.getId(), edgeId.getId(), pageLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageData<Asset> findAssetsByTenantIdAndEdgeIdAndType(TenantId tenantId, EdgeId edgeId, String type, TimePageLink pageLink) {
|
||||||
|
log.trace("Executing findAssetsByTenantIdAndEdgeIdAndType, tenantId [{}], edgeId [{}], type [{}] pageLink [{}]", tenantId, edgeId, type, pageLink);
|
||||||
|
validateId(tenantId, INCORRECT_TENANT_ID + tenantId);
|
||||||
|
validateId(edgeId, INCORRECT_EDGE_ID + edgeId);
|
||||||
|
validateString(type, "Incorrect type " + type);
|
||||||
|
validatePageLink(pageLink);
|
||||||
|
return assetDao.findAssetsByTenantIdAndEdgeIdAndType(tenantId.getId(), edgeId.getId(), type, pageLink);
|
||||||
|
}
|
||||||
|
|
||||||
private DataValidator<Asset> assetValidator =
|
private DataValidator<Asset> assetValidator =
|
||||||
new DataValidator<Asset>() {
|
new DataValidator<Asset>() {
|
||||||
|
|
||||||
|
|||||||
@ -132,4 +132,15 @@ public interface AssetRepository extends PagingAndSortingRepository<AssetEntity,
|
|||||||
@Param("searchText") String searchText,
|
@Param("searchText") String searchText,
|
||||||
Pageable pageable);
|
Pageable pageable);
|
||||||
|
|
||||||
|
@Query("SELECT a FROM AssetEntity a, RelationEntity re WHERE a.tenantId = :tenantId " +
|
||||||
|
"AND a.id = re.toId AND re.toType = 'ASSET' AND re.relationTypeGroup = 'EDGE' " +
|
||||||
|
"AND re.relationType = 'Contains' AND re.fromId = :edgeId AND re.fromType = 'EDGE' " +
|
||||||
|
"AND a.type = :type " +
|
||||||
|
"AND LOWER(a.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
|
||||||
|
Page<AssetEntity> findByTenantIdAndEdgeIdAndType(@Param("tenantId") UUID tenantId,
|
||||||
|
@Param("edgeId") UUID edgeId,
|
||||||
|
@Param("type") String type,
|
||||||
|
@Param("searchText") String searchText,
|
||||||
|
Pageable pageable);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -196,4 +196,16 @@ public class JpaAssetDao extends JpaAbstractSearchTextDao<AssetEntity, Asset> im
|
|||||||
Objects.toString(pageLink.getTextSearch(), ""),
|
Objects.toString(pageLink.getTextSearch(), ""),
|
||||||
DaoUtil.toPageable(pageLink)));
|
DaoUtil.toPageable(pageLink)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageData<Asset> findAssetsByTenantIdAndEdgeIdAndType(UUID tenantId, UUID edgeId, String type, TimePageLink pageLink) {
|
||||||
|
log.debug("Try to find assets by tenantId [{}], edgeId [{}], type [{}] and pageLink [{}]", tenantId, edgeId, type, pageLink);
|
||||||
|
return DaoUtil.toPageData(assetRepository
|
||||||
|
.findByTenantIdAndEdgeIdAndType(
|
||||||
|
tenantId,
|
||||||
|
edgeId,
|
||||||
|
type,
|
||||||
|
Objects.toString(pageLink.getTextSearch(), ""),
|
||||||
|
DaoUtil.toPageable(pageLink)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -99,7 +99,7 @@ export class AssetService {
|
|||||||
return this.http.delete(`/api/edge/${edgeId}/asset/${assetId}`, defaultHttpOptionsFromConfig(config));
|
return this.http.delete(`/api/edge/${edgeId}/asset/${assetId}`, defaultHttpOptionsFromConfig(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
public getEdgeAssets(edgeId, pageLink: PageLink, type: string = '',
|
public getEdgeAssets(edgeId: string, pageLink: PageLink, type: string = '',
|
||||||
config?: RequestConfig): Observable<PageData<AssetInfo>> {
|
config?: RequestConfig): Observable<PageData<AssetInfo>> {
|
||||||
return this.http.get<PageData<AssetInfo>>(`/api/edge/${edgeId}/assets${pageLink.toQuery()}&type=${type}`,
|
return this.http.get<PageData<AssetInfo>>(`/api/edge/${edgeId}/assets${pageLink.toQuery()}&type=${type}`,
|
||||||
defaultHttpOptionsFromConfig(config));
|
defaultHttpOptionsFromConfig(config));
|
||||||
|
|||||||
@ -34,6 +34,12 @@
|
|||||||
[fxShow]="!isEdit && (assetScope === 'customer' || assetScope === 'tenant') && isAssignedToCustomer(entity)">
|
[fxShow]="!isEdit && (assetScope === 'customer' || assetScope === 'tenant') && isAssignedToCustomer(entity)">
|
||||||
{{ (entity?.customerIsPublic ? 'asset.make-private' : 'asset.unassign-from-customer') | translate }}
|
{{ (entity?.customerIsPublic ? 'asset.make-private' : 'asset.unassign-from-customer') | translate }}
|
||||||
</button>
|
</button>
|
||||||
|
<button mat-raised-button color="primary"
|
||||||
|
[disabled]="(isLoading$ | async)"
|
||||||
|
(click)="onEntityAction($event, 'unassignFromEdge')"
|
||||||
|
[fxShow]="!isEdit && assetScope === 'edge'">
|
||||||
|
{{ 'edge.unassign-from-edge' | translate }}
|
||||||
|
</button>
|
||||||
<button mat-raised-button color="primary"
|
<button mat-raised-button color="primary"
|
||||||
[disabled]="(isLoading$ | async)"
|
[disabled]="(isLoading$ | async)"
|
||||||
(click)="onEntityAction($event, 'delete')"
|
(click)="onEntityAction($event, 'delete')"
|
||||||
|
|||||||
@ -466,6 +466,9 @@ export class AssetsTableConfigResolver implements Resolve<EntityTableConfig<Asse
|
|||||||
case 'unassignFromCustomer':
|
case 'unassignFromCustomer':
|
||||||
this.unassignFromCustomer(action.event, action.entity);
|
this.unassignFromCustomer(action.event, action.entity);
|
||||||
return true;
|
return true;
|
||||||
|
case 'unassignFromEdge':
|
||||||
|
this.unassignFromEdge(action.event, action.entity);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,6 +53,12 @@
|
|||||||
[fxShow]="!isEdit && dashboardScope === 'customer' && !isCurrentPublicCustomer(entity)">
|
[fxShow]="!isEdit && dashboardScope === 'customer' && !isCurrentPublicCustomer(entity)">
|
||||||
{{ 'dashboard.unassign-from-customer' | translate }}
|
{{ 'dashboard.unassign-from-customer' | translate }}
|
||||||
</button>
|
</button>
|
||||||
|
<button mat-raised-button color="primary"
|
||||||
|
[disabled]="(isLoading$ | async)"
|
||||||
|
(click)="onEntityAction($event, 'unassignFromEdge')"
|
||||||
|
[fxShow]="!isEdit && dashboardScope === 'edge'">
|
||||||
|
{{ 'edge.unassign-from-edge' | translate }}
|
||||||
|
</button>
|
||||||
<button mat-raised-button color="primary"
|
<button mat-raised-button color="primary"
|
||||||
[disabled]="(isLoading$ | async)"
|
[disabled]="(isLoading$ | async)"
|
||||||
(click)="onEntityAction($event, 'delete')"
|
(click)="onEntityAction($event, 'delete')"
|
||||||
|
|||||||
@ -543,6 +543,9 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig<
|
|||||||
case 'unassignFromCustomer':
|
case 'unassignFromCustomer':
|
||||||
this.unassignFromCustomer(action.event, action.entity, this.config.componentsData.customerId);
|
this.unassignFromCustomer(action.event, action.entity, this.config.componentsData.customerId);
|
||||||
return true;
|
return true;
|
||||||
|
case 'unassignFromEdge':
|
||||||
|
this.unassignFromEdge(action.event, action.entity);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -572,7 +575,7 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig<
|
|||||||
$event.stopPropagation();
|
$event.stopPropagation();
|
||||||
}
|
}
|
||||||
this.dialogService.confirm(
|
this.dialogService.confirm(
|
||||||
this.translate.instant('dashboard.unassign-dashboard-from-edge-title', {dashboardName: dashboard.name}),
|
this.translate.instant('dashboard.unassign-dashboard-title', {dashboardTitle: dashboard.title}),
|
||||||
this.translate.instant('dashboard.unassign-dashboard-from-edge-text'),
|
this.translate.instant('dashboard.unassign-dashboard-from-edge-text'),
|
||||||
this.translate.instant('action.no'),
|
this.translate.instant('action.no'),
|
||||||
this.translate.instant('action.yes'),
|
this.translate.instant('action.yes'),
|
||||||
|
|||||||
@ -40,6 +40,12 @@
|
|||||||
[fxShow]="!isEdit">
|
[fxShow]="!isEdit">
|
||||||
{{ (deviceScope === 'customer_user' ? 'device.view-credentials' : 'device.manage-credentials') | translate }}
|
{{ (deviceScope === 'customer_user' ? 'device.view-credentials' : 'device.manage-credentials') | translate }}
|
||||||
</button>
|
</button>
|
||||||
|
<button mat-raised-button color="primary"
|
||||||
|
[disabled]="(isLoading$ | async)"
|
||||||
|
(click)="onEntityAction($event, 'unassignFromEdge')"
|
||||||
|
[fxShow]="!isEdit && deviceScope === 'edge'">
|
||||||
|
{{ 'edge.unassign-from-edge' | translate }}
|
||||||
|
</button>
|
||||||
<button mat-raised-button color="primary" fxFlex.xs
|
<button mat-raised-button color="primary" fxFlex.xs
|
||||||
[disabled]="(isLoading$ | async)"
|
[disabled]="(isLoading$ | async)"
|
||||||
(click)="onEntityAction($event, 'delete')"
|
(click)="onEntityAction($event, 'delete')"
|
||||||
|
|||||||
@ -519,6 +519,9 @@ export class DevicesTableConfigResolver implements Resolve<EntityTableConfig<Dev
|
|||||||
case 'unassignFromCustomer':
|
case 'unassignFromCustomer':
|
||||||
this.unassignFromCustomer(action.event, action.entity);
|
this.unassignFromCustomer(action.event, action.entity);
|
||||||
return true;
|
return true;
|
||||||
|
case 'unassignFromEdge':
|
||||||
|
this.unassignFromEdge(action.event, action.entity);
|
||||||
|
return true;
|
||||||
case 'manageCredentials':
|
case 'manageCredentials':
|
||||||
this.manageCredentials(action.event, action.entity);
|
this.manageCredentials(action.event, action.entity);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -34,6 +34,12 @@
|
|||||||
[fxShow]="!isEdit && (entityViewScope === 'customer' || entityViewScope === 'tenant') && isAssignedToCustomer(entity)">
|
[fxShow]="!isEdit && (entityViewScope === 'customer' || entityViewScope === 'tenant') && isAssignedToCustomer(entity)">
|
||||||
{{ (entity?.customerIsPublic ? 'entity-view.make-private' : 'entity-view.unassign-from-customer') | translate }}
|
{{ (entity?.customerIsPublic ? 'entity-view.make-private' : 'entity-view.unassign-from-customer') | translate }}
|
||||||
</button>
|
</button>
|
||||||
|
<button mat-raised-button color="primary"
|
||||||
|
[disabled]="(isLoading$ | async)"
|
||||||
|
(click)="onEntityAction($event, 'unassignFromEdge')"
|
||||||
|
[fxShow]="!isEdit && entityViewScope === 'edge'">
|
||||||
|
{{ 'edge.unassign-from-edge' | translate }}
|
||||||
|
</button>
|
||||||
<button mat-raised-button color="primary"
|
<button mat-raised-button color="primary"
|
||||||
[disabled]="(isLoading$ | async)"
|
[disabled]="(isLoading$ | async)"
|
||||||
(click)="onEntityAction($event, 'delete')"
|
(click)="onEntityAction($event, 'delete')"
|
||||||
|
|||||||
@ -441,6 +441,9 @@ export class EntityViewsTableConfigResolver implements Resolve<EntityTableConfig
|
|||||||
case 'unassignFromCustomer':
|
case 'unassignFromCustomer':
|
||||||
this.unassignFromCustomer(action.event, action.entity);
|
this.unassignFromCustomer(action.event, action.entity);
|
||||||
return true;
|
return true;
|
||||||
|
case 'unassignFromEdge':
|
||||||
|
this.unassignFromEdge(action.event, action.entity);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,21 +31,21 @@
|
|||||||
<button mat-raised-button color="primary"
|
<button mat-raised-button color="primary"
|
||||||
[disabled]="(isLoading$ | async)"
|
[disabled]="(isLoading$ | async)"
|
||||||
(click)="onEntityAction($event, 'setRoot')"
|
(click)="onEntityAction($event, 'setRoot')"
|
||||||
[fxShow]="!isEdit && !entity?.root && !isEdgeRuleChainScope()">
|
[fxShow]="!isEdit && !entity?.root && ruleChainScope === 'tenant'">
|
||||||
{{'rulechain.set-root' | translate }}
|
|
||||||
</button>
|
|
||||||
<button mat-raised-button color="primary"
|
|
||||||
[disabled]="(isLoading$ | async)"
|
|
||||||
(click)="onEntityAction($event, 'setRoot')"
|
|
||||||
[fxShow]="!isEdit && isEdgeRuleChainScope() && !isRootRuleChain()">
|
|
||||||
{{'rulechain.set-root' | translate }}
|
{{'rulechain.set-root' | translate }}
|
||||||
</button>
|
</button>
|
||||||
<button mat-raised-button color="primary"
|
<button mat-raised-button color="primary"
|
||||||
[disabled]="(isLoading$ | async)"
|
[disabled]="(isLoading$ | async)"
|
||||||
(click)="onEntityAction($event, 'setDefaultRoot')"
|
(click)="onEntityAction($event, 'setDefaultRoot')"
|
||||||
[fxShow]="!isEdit && !entity?.root && isEdgesRuleChainScope()">
|
[fxShow]="!isEdit && !entity?.root && ruleChainScope === 'edges'">
|
||||||
{{'rulechain.set-default-root-edge' | translate }}
|
{{'rulechain.set-default-root-edge' | translate }}
|
||||||
</button>
|
</button>
|
||||||
|
<button mat-raised-button color="primary"
|
||||||
|
[disabled]="(isLoading$ | async)"
|
||||||
|
(click)="onEntityAction($event, 'setRoot')"
|
||||||
|
[fxShow]="!isEdit && !isRootRuleChain() && ruleChainScope === 'edge'">
|
||||||
|
{{'rulechain.set-root' | translate }}
|
||||||
|
</button>
|
||||||
<button mat-raised-button color="primary"
|
<button mat-raised-button color="primary"
|
||||||
[disabled]="(isLoading$ | async)"
|
[disabled]="(isLoading$ | async)"
|
||||||
(click)="onEntityAction($event, 'delete')"
|
(click)="onEntityAction($event, 'delete')"
|
||||||
|
|||||||
@ -31,6 +31,8 @@ import { EntityTableConfig } from '@home/models/entity/entities-table-config.mod
|
|||||||
})
|
})
|
||||||
export class RuleChainComponent extends EntityComponent<RuleChain> {
|
export class RuleChainComponent extends EntityComponent<RuleChain> {
|
||||||
|
|
||||||
|
ruleChainScope: 'tenant' | 'edges' | 'edge';
|
||||||
|
|
||||||
constructor(protected store: Store<AppState>,
|
constructor(protected store: Store<AppState>,
|
||||||
protected translate: TranslateService,
|
protected translate: TranslateService,
|
||||||
@Inject('entity') protected entityValue: RuleChain,
|
@Inject('entity') protected entityValue: RuleChain,
|
||||||
@ -39,6 +41,11 @@ export class RuleChainComponent extends EntityComponent<RuleChain> {
|
|||||||
super(store, fb, entityValue, entitiesTableConfigValue);
|
super(store, fb, entityValue, entitiesTableConfigValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.ruleChainScope = this.entitiesTableConfig.componentsData.ruleChainScope;
|
||||||
|
super.ngOnInit();
|
||||||
|
}
|
||||||
|
|
||||||
hideDelete() {
|
hideDelete() {
|
||||||
if (this.entitiesTableConfig) {
|
if (this.entitiesTableConfig) {
|
||||||
return !this.entitiesTableConfig.deleteEnabled(this.entity);
|
return !this.entitiesTableConfig.deleteEnabled(this.entity);
|
||||||
@ -79,30 +86,6 @@ export class RuleChainComponent extends EntityComponent<RuleChain> {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
isTenantRuleChainScope() {
|
|
||||||
if (this.entitiesTableConfig) {
|
|
||||||
return this.entitiesTableConfig.componentsData.ruleChainScope == 'tenant';
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
isEdgesRuleChainScope() {
|
|
||||||
if (this.entitiesTableConfig) {
|
|
||||||
return this.entitiesTableConfig.componentsData.ruleChainScope == 'edges';
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
isEdgeRuleChainScope() {
|
|
||||||
if (this.entitiesTableConfig) {
|
|
||||||
return this.entitiesTableConfig.componentsData.ruleChainScope == 'edge';
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
isRootRuleChain() {
|
isRootRuleChain() {
|
||||||
if (this.entitiesTableConfig && this.entityValue) {
|
if (this.entitiesTableConfig && this.entityValue) {
|
||||||
return this.entitiesTableConfig.componentsData.rootRuleChainId == this.entityValue.id.id;
|
return this.entitiesTableConfig.componentsData.rootRuleChainId == this.entityValue.id.id;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user