extend tag authorizations
MODIFY
src/server/rest/v1/service/AuthorizationService.ts
src/server/rest/v1/service/AuthorizationService.ts
-import { Action, AuthorizationActions, AuthorizationContext, AuthorizationFilter, Entity, SiteAreaAuthorizationActions } from '../../../../types/Authorization';
+import { Action, AuthorizationActions, AuthorizationContext, AuthorizationFilter, Entity, SiteAreaAuthorizationActions, TagAuthorizationActions } from '../../../../types/Authorization';
import { Car, CarCatalog } from '../../../../types/Car';
import { CarCatalogDataResult, CarDataResult, CompanyDataResult, SiteAreaDataResult, SiteDataResult, TagDataResult, UserDataResult } from '../../../../types/DataResult';
import { HttpAssignAssetsToSiteAreaRequest, HttpSiteAreaRequest, HttpSiteAreasRequest } from '../../../../types/requests/HttpSiteAreaRequest';
@@ -34,7 +34,7 @@ import _ from 'lodash';
const MODULE_NAME = 'AuthorizationService';
export default class AuthorizationService {
- public static canPerformAction(authActions: AuthorizationActions | SiteAreaAuthorizationActions, action: Action): boolean {
+ public static canPerformAction(authActions: AuthorizationActions | SiteAreaAuthorizationActions | TagAuthorizationActions, action: Action): boolean {
switch (action) {
case Action.READ:
return authActions.canRead;
@@ -45,11 +45,11 @@ export default class AuthorizationService {
case Action.DELETE:
return authActions.canDelete;
case Action.UNASSIGN:
- return authActions.canUnassign;
+ return (authActions as TagAuthorizationActions).canUnassign;
case Action.ASSIGN:
- return authActions.canAssign;
+ return (authActions as TagAuthorizationActions).canAssign;
case Action.UPDATE_BY_VISUAL_ID:
- return authActions.canUpdateByVisualID;
+ return (authActions as TagAuthorizationActions).canUpdateByVisualID;
case Action.ASSIGN_CHARGING_STATIONS_TO_SITE_AREA:
return (authActions as SiteAreaAuthorizationActions).canAssignChargingStations;
case Action.UNASSIGN_CHARGING_STATIONS_TO_SITE_AREA:

MODIFY
src/types/Authorization.ts
src/types/Authorization.ts
@@ -184,11 +184,15 @@ export interface AuthorizationActions {
canRead?: boolean;
canCreate?: boolean;
canUpdate?: boolean;
- canUpdateByVisualID?: boolean;
canDelete?: boolean;
+}
+
+export interface TagAuthorizationActions extends AuthorizationActions {
canUnassign?: boolean;
canAssign?: boolean;
+ canUpdateByVisualID?: boolean;
}
+
export interface SiteAreaAuthorizationActions extends AuthorizationActions {
canAssignAssets?: boolean;
canUnassignAssets?: boolean;

MODIFY
src/types/Tag.ts
src/types/Tag.ts
-import { AuthorizationActions } from './Authorization';
import CreatedUpdatedProps from './CreatedUpdatedProps';
import { ImportStatus } from './GlobalType';
import { OCPIToken } from './ocpi/OCPIToken';
+import { TagAuthorizationActions } from './Authorization';
import User from './User';
-export default interface Tag extends CreatedUpdatedProps, AuthorizationActions {
+export default interface Tag extends CreatedUpdatedProps, TagAuthorizationActions {
id: string;
description?: string;
visualID?: string;

extend tag authorizations