@c8y/ngx-components 1018.503.23 → 1018.503.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/services.d.ts +1 -1
- package/core/forms/validation-pattern.d.ts +4 -0
- package/device-grid/device-grid.component.d.ts +7 -2
- package/esm2020/api/services.mjs +2 -2
- package/esm2020/child-devices/child-devices.component.mjs +1 -1
- package/esm2020/core/bootstrap/bootstrap.component.mjs +3 -3
- package/esm2020/core/dynamic-forms/json-schema/c8y-json-schema.service.mjs +8 -2
- package/esm2020/core/forms/validation-pattern.mjs +5 -1
- package/esm2020/device-grid/device-grid-extension.service.mjs +13 -8
- package/esm2020/device-grid/device-grid.component.mjs +30 -15
- package/esm2020/device-list/device-list.component.mjs +1 -1
- package/esm2020/operations/device-selector/device-selector.component.mjs +1 -1
- package/esm2020/replace-device-wizard/replace-device-wizard.component.mjs +2 -2
- package/esm2020/sub-assets/add-group/add-group.component.mjs +4 -3
- package/esm2020/sub-assets/asset-properties-item.component.mjs +7 -3
- package/esm2020/sub-assets/asset-properties.component.mjs +25 -10
- package/esm2020/sub-assets/assign-devices/assign-devices.component.mjs +4 -3
- package/esm2020/sub-assets/location/asset-location.component.mjs +5 -3
- package/esm2020/trusted-certificates/crl/crl-check-settings.component.mjs +39 -0
- package/esm2020/trusted-certificates/crl/crl-settings.component.mjs +109 -0
- package/esm2020/trusted-certificates/crl/crl-settings.module.mjs +46 -0
- package/esm2020/trusted-certificates/factories/tabs.factory.mjs +36 -0
- package/esm2020/trusted-certificates/factories/trusted-certificates-navigation.factory.mjs +26 -0
- package/esm2020/trusted-certificates/index.mjs +4 -4
- package/esm2020/trusted-certificates/{add-trusted-certificate.component.mjs → list/add-trusted-certificate.component.mjs} +1 -1
- package/esm2020/trusted-certificates/list/trusted-certificate-list.component.mjs +184 -0
- package/esm2020/trusted-certificates/list/trusted-certificate-list.module.mjs +54 -0
- package/esm2020/trusted-certificates/list/trusted-certificate.model.mjs +36 -0
- package/esm2020/trusted-certificates/trusted-certificates.module.mjs +24 -35
- package/fesm2015/c8y-ngx-components-api.mjs +3 -2
- package/fesm2015/c8y-ngx-components-api.mjs.map +1 -1
- package/fesm2015/c8y-ngx-components-child-devices.mjs +1 -1
- package/fesm2015/c8y-ngx-components-child-devices.mjs.map +1 -1
- package/fesm2015/c8y-ngx-components-device-grid.mjs +41 -21
- package/fesm2015/c8y-ngx-components-device-grid.mjs.map +1 -1
- package/fesm2015/c8y-ngx-components-device-list.mjs +1 -1
- package/fesm2015/c8y-ngx-components-device-list.mjs.map +1 -1
- package/fesm2015/c8y-ngx-components-operations-device-selector.mjs +1 -1
- package/fesm2015/c8y-ngx-components-operations-device-selector.mjs.map +1 -1
- package/fesm2015/c8y-ngx-components-replace-device-wizard.mjs +1 -1
- package/fesm2015/c8y-ngx-components-replace-device-wizard.mjs.map +1 -1
- package/fesm2015/c8y-ngx-components-sub-assets.mjs +39 -18
- package/fesm2015/c8y-ngx-components-sub-assets.mjs.map +1 -1
- package/fesm2015/c8y-ngx-components-trusted-certificates.mjs +329 -86
- package/fesm2015/c8y-ngx-components-trusted-certificates.mjs.map +1 -1
- package/fesm2015/c8y-ngx-components.mjs +10 -3
- package/fesm2015/c8y-ngx-components.mjs.map +1 -1
- package/fesm2020/c8y-ngx-components-api.mjs +3 -2
- package/fesm2020/c8y-ngx-components-api.mjs.map +1 -1
- package/fesm2020/c8y-ngx-components-child-devices.mjs +1 -1
- package/fesm2020/c8y-ngx-components-child-devices.mjs.map +1 -1
- package/fesm2020/c8y-ngx-components-device-grid.mjs +41 -21
- package/fesm2020/c8y-ngx-components-device-grid.mjs.map +1 -1
- package/fesm2020/c8y-ngx-components-device-list.mjs +1 -1
- package/fesm2020/c8y-ngx-components-device-list.mjs.map +1 -1
- package/fesm2020/c8y-ngx-components-operations-device-selector.mjs +1 -1
- package/fesm2020/c8y-ngx-components-operations-device-selector.mjs.map +1 -1
- package/fesm2020/c8y-ngx-components-replace-device-wizard.mjs +1 -1
- package/fesm2020/c8y-ngx-components-replace-device-wizard.mjs.map +1 -1
- package/fesm2020/c8y-ngx-components-sub-assets.mjs +38 -17
- package/fesm2020/c8y-ngx-components-sub-assets.mjs.map +1 -1
- package/fesm2020/c8y-ngx-components-trusted-certificates.mjs +314 -85
- package/fesm2020/c8y-ngx-components-trusted-certificates.mjs.map +1 -1
- package/fesm2020/c8y-ngx-components.mjs +13 -3
- package/fesm2020/c8y-ngx-components.mjs.map +1 -1
- package/locales/locales.pot +48 -0
- package/package.json +1 -1
- package/sub-assets/add-group/add-group.component.d.ts +2 -1
- package/sub-assets/asset-properties.component.d.ts +6 -0
- package/sub-assets/assign-devices/assign-devices.component.d.ts +2 -1
- package/trusted-certificates/crl/crl-check-settings.component.d.ts +18 -0
- package/trusted-certificates/crl/crl-settings.component.d.ts +28 -0
- package/trusted-certificates/crl/crl-settings.module.d.ts +13 -0
- package/trusted-certificates/factories/tabs.factory.d.ts +10 -0
- package/trusted-certificates/index.d.ts +3 -3
- package/trusted-certificates/{trusted-certificates.component.d.ts → list/trusted-certificate-list.component.d.ts} +4 -4
- package/trusted-certificates/list/trusted-certificate-list.module.d.ts +15 -0
- package/trusted-certificates/trusted-certificates.module.d.ts +4 -10
- package/esm2020/trusted-certificates/trusted-certificate.model.mjs +0 -36
- package/esm2020/trusted-certificates/trusted-certificates-navigation.factory.mjs +0 -26
- package/esm2020/trusted-certificates/trusted-certificates.component.mjs +0 -184
- /package/trusted-certificates/{trusted-certificates-navigation.factory.d.ts → factories/trusted-certificates-navigation.factory.d.ts} +0 -0
- /package/trusted-certificates/{add-trusted-certificate.component.d.ts → list/add-trusted-certificate.component.d.ts} +0 -0
- /package/trusted-certificates/{trusted-certificate.model.d.ts → list/trusted-certificate.model.d.ts} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { Injectable, NgModule } from '@angular/core';
|
|
3
3
|
import * as i1 from '@c8y/client';
|
|
4
|
-
import { AlarmService, ApplicationService, AuditService, BasicAuth, CookieAuth, DeviceRegistrationBulkService, DeviceRegistrationService, EventBinaryService, EventService, FetchClient, IdentityService, InventoryBinaryService, InventoryRoleService, InventoryService, MeasurementService, OperationBulkService, OperationService, Realtime, SmartGroupsService, SmartRulesService, SystemOptionsService, TenantLoginOptionsService, TenantOptionsService, TenantSecurityOptionsService, TenantService, TrustedCertificateService, UserGroupService, UserRoleService, UserService } from '@c8y/client';
|
|
5
|
-
export { AlarmService, ApplicationService, AuditService, BasicAuth, CookieAuth, DeviceRegistrationBulkService, DeviceRegistrationService, EventBinaryService, EventService, FetchClient, IdentityService, InventoryBinaryService, InventoryRoleService, InventoryService, MeasurementService, OperationBulkService, OperationService, Realtime, SmartGroupsService, SmartRulesService, SystemOptionsService, TenantLoginOptionsService, TenantOptionsService, TenantSecurityOptionsService, TenantService, TrustedCertificateService, UserGroupService, UserRoleService, UserService } from '@c8y/client';
|
|
4
|
+
import { AlarmService, ApplicationService, AuditService, BasicAuth, CookieAuth, CrlService, DeviceRegistrationBulkService, DeviceRegistrationService, EventBinaryService, EventService, FetchClient, IdentityService, InventoryBinaryService, InventoryRoleService, InventoryService, MeasurementService, OperationBulkService, OperationService, Realtime, SmartGroupsService, SmartRulesService, SystemOptionsService, TenantLoginOptionsService, TenantOptionsService, TenantSecurityOptionsService, TenantService, TrustedCertificateService, UserGroupService, UserRoleService, UserService } from '@c8y/client';
|
|
5
|
+
export { AlarmService, ApplicationService, AuditService, BasicAuth, CookieAuth, CrlService, DeviceRegistrationBulkService, DeviceRegistrationService, EventBinaryService, EventService, FetchClient, IdentityService, InventoryBinaryService, InventoryRoleService, InventoryService, MeasurementService, OperationBulkService, OperationService, Realtime, SmartGroupsService, SmartRulesService, SystemOptionsService, TenantLoginOptionsService, TenantOptionsService, TenantSecurityOptionsService, TenantService, TrustedCertificateService, UserGroupService, UserRoleService, UserService } from '@c8y/client';
|
|
6
6
|
import { from, Subject, pipe } from 'rxjs';
|
|
7
7
|
import { filter } from 'rxjs/operators';
|
|
8
8
|
|
|
@@ -163,6 +163,7 @@ var services = /*#__PURE__*/Object.freeze({
|
|
|
163
163
|
AuditService: AuditService,
|
|
164
164
|
BasicAuth: BasicAuth,
|
|
165
165
|
CookieAuth: CookieAuth,
|
|
166
|
+
CrlService: CrlService,
|
|
166
167
|
DeviceRegistrationBulkService: DeviceRegistrationBulkService,
|
|
167
168
|
DeviceRegistrationService: DeviceRegistrationService,
|
|
168
169
|
EventBinaryService: EventBinaryService,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"c8y-ngx-components-api.mjs","sources":["../../api/interceptor.model.ts","../../api/http-handler.model.ts","../../api/api.service.ts","../../api/data.module.ts","../../api/index.ts","../../api/c8y-ngx-components-api.ts"],"sourcesContent":["import { ApiCall } from './api.model';\nimport { Observable } from 'rxjs';\nimport { IFetchResponse } from '@c8y/client';\n\nexport interface HttpInterceptor {\n intercept(req: ApiCall, next: HttpHandler): Observable<IFetchResponse>;\n}\n\nexport abstract class HttpHandler {\n abstract handle(req: ApiCall): Observable<IFetchResponse>;\n}\n","import { ApiCall } from './api.model';\nimport { Observable, from } from 'rxjs';\nimport { FetchClient, IFetchResponse } from '@c8y/client';\nimport { HttpHandler, HttpInterceptor } from './interceptor.model';\n\nexport class HttpInterceptHandler extends HttpHandler {\n constructor(protected interceptor: HttpInterceptor, protected nextHandler: HttpHandler) {\n super();\n }\n\n handle(req: ApiCall): Observable<IFetchResponse> {\n return this.interceptor.intercept(req, this.nextHandler);\n }\n}\n\nexport interface RequestStartAndFinish {\n onStart(req: ApiCall): void;\n onFinish(res: ApiCall): void;\n}\n\nexport class HttpRequestHandler extends HttpHandler {\n constructor(protected fetch: FetchClient['fetch'], protected apiService?: RequestStartAndFinish) {\n super();\n }\n\n handle(req: ApiCall): Observable<IFetchResponse> {\n const { options, url } = req;\n const { method } = options;\n this.apiService?.onStart({ method, options, url });\n let fetchPromise = this.fetch(url, options);\n if (typeof options.responseInterceptor === 'function') {\n fetchPromise = fetchPromise.then(options.responseInterceptor);\n }\n fetchPromise.then(\n (response: IFetchResponse) => this.apiService?.onFinish({ method, options, url, response }),\n (response: IFetchResponse) => this.apiService?.onFinish({ method, options, url, response })\n );\n return from(fetchPromise);\n }\n}\n","import { Injectable } from '@angular/core';\nimport { FetchClient, IFetchOptions, IFetchResponse } from '@c8y/client';\nimport { MonoTypeOperatorFunction, Observable, Subject, pipe } from 'rxjs';\nimport { filter } from 'rxjs/operators';\nimport { ApiCall, ApiCallOptions } from './api.model';\nimport {\n HttpInterceptHandler,\n HttpRequestHandler,\n RequestStartAndFinish\n} from './http-handler.model';\nimport { HttpHandler, HttpInterceptor } from './interceptor.model';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class ApiService implements RequestStartAndFinish {\n calls: Observable<ApiCall>;\n private callsSubject = new Subject<ApiCall>();\n private interceptors = new Map<string, HttpInterceptor>();\n private interceptorCounter = 0;\n\n constructor(private client: FetchClient) {\n this.calls = this.callsSubject.asObservable();\n this.hookIntoClientFetch();\n }\n\n /**\n * Allows to hook into the responses received by the FetchClient.\n * This is meant to be used to react on the responses, not for manipulation of the responses.\n * @param hookFilter A filter function to filter for specific responses.\n * @returns An Observable of the filtered responses.\n */\n hookResponse(hookFilter: (call: ApiCall) => boolean) {\n return this.callsSubject.pipe(\n filter(({ phase }) => phase === 'finish'),\n filter(hookFilter)\n );\n }\n\n /**\n * Allows to hook into the requests performed by the FetchClient.\n * This is meant to be used to react on the requests, not for manipulation of the requests.\n * @param hookFilter A filter function to filter for specific requests.\n * @returns An Observable of the filtered requests.\n */\n hookRequest(hookFilter: (call: ApiCall) => boolean) {\n return this.callsSubject.pipe(\n filter(({ phase }) => phase === 'start'),\n filter(hookFilter)\n );\n }\n\n onFinish(call: ApiCall) {\n this.callsSubject.next({ phase: 'finish', ...call });\n }\n\n onStart(call: ApiCall) {\n this.callsSubject.next({ phase: 'start', ...call });\n }\n\n resolveData<T = unknown>(call: ApiCall): Promise<{ data: T; method: string; url: string }> {\n const { response, method, url } = call;\n if ('data' in response) {\n return Promise.resolve({ data: response.data, method, url });\n } else {\n // No Content success status, for example DELETE request.\n if ((response as Response)?.status === 204) {\n return Promise.resolve({ data: null, method, url });\n }\n const cb = data => ({ data, method, url });\n return (response as Response).clone().json().then(cb, cb);\n }\n }\n\n /**\n * Can be added to a pipe to exclude any permission call. Permission calls are PUT\n * request with only an id in it, to verify if the user has access to this managed object.\n * @returns The operator to be added to a pipe.\n */\n excludePermissionCall(): MonoTypeOperatorFunction<ApiCall> {\n return pipe(\n filter(({ method, options }) => {\n if (method === 'PUT' && options.body && typeof options.body === 'string') {\n const parsedBody = JSON.parse(options.body as string);\n const bodyKeys = Object.keys(parsedBody);\n return !(bodyKeys.length === 1 && bodyKeys[0] === 'id');\n }\n return true;\n })\n );\n }\n\n /**\n * Allows to intercept requests performed via the FetchClient requests.\n * @param interceptor The interceptor to be added.\n * @param id An optional unique identifier for the interceptor. The chain of interceptors is ordered by this id. And it can be used to remove the interceptor later on.\n * @returns The id of the interceptor (same as provided id if one was provided, otherwise an id will be generated).\n */\n addInterceptor(interceptor: HttpInterceptor, id?: string): string {\n if (!id) {\n id = `${++this.interceptorCounter}`;\n }\n this.interceptors.set(id, interceptor);\n return id;\n }\n\n /**\n * Allows to remove a previously added interceptor by it's id.\n * @param id The id of the interceptor that should be removed.\n * @returns true if an interceptor existed and has been removed, or false if id does not exist.\n */\n removeInterceptor(id: string): boolean {\n return this.interceptors.delete(id);\n }\n\n /**\n * Checks if an interceptor with a given id exists.\n * @param id The id of the interceptor.\n * @returns - Returns true if an interceptor with the given id exists, otherwise false.\n */\n hasInterceptor(id: string): boolean {\n return this.interceptors.has(id);\n }\n\n private hookIntoClientFetch() {\n const fetch: FetchClient['fetch'] = this.client.fetch.bind(this.client);\n const requestHandler = new HttpRequestHandler(fetch, this);\n this.client.fetch = async (\n url,\n options: ApiCallOptions & IFetchOptions = { method: 'GET' }\n ) => {\n const { method } = options;\n return this.createInterceptorChain({ url, options, method }, requestHandler).toPromise();\n };\n }\n\n private createInterceptorChain(\n call: ApiCall,\n requestHandler: HttpRequestHandler\n ): Observable<IFetchResponse> {\n let handler: HttpHandler = requestHandler;\n // Do some sorting to always apply the interceptors in the specific order\n const sortedInterceptorIds = Array.from(this.interceptors.keys()).sort((a, b) =>\n b.localeCompare(a)\n );\n for (const interceptorId of sortedInterceptorIds) {\n handler = new HttpInterceptHandler(this.interceptors.get(interceptorId), handler);\n }\n return handler.handle(call);\n }\n}\n","import { ModuleWithProviders, NgModule, Provider, Type } from '@angular/core';\nimport { BasicAuth, FetchClient, Realtime, CookieAuth } from '@c8y/client';\nimport { ApiService } from './api.service';\nimport * as services from './services';\n\nfunction toProvider(provide: Type<unknown>): Provider {\n let deps: Array<Type<FetchClient | Realtime | CookieAuth>> = [FetchClient, Realtime];\n if (provide === FetchClient) {\n deps = [CookieAuth];\n }\n if (provide === BasicAuth || provide === CookieAuth) {\n deps = [];\n }\n if (provide === Realtime) {\n deps = [FetchClient];\n }\n return { provide, useClass: provide, deps };\n}\n\nconst providers: Provider[] = Object.keys(services)\n .map(k => toProvider(services[k]))\n .concat([{ provide: ApiService, useClass: ApiService, deps: [FetchClient] }]);\n// @dynamic\n@NgModule({\n providers\n})\nexport class DataModule {\n static providers(): Provider[] {\n return providers;\n }\n static forRoot(): ModuleWithProviders<DataModule> {\n return {\n ngModule: DataModule,\n providers\n };\n }\n}\n","export * from './api.service';\nexport * from './api.model';\nexport * from './data.module';\nexport * from './services';\nexport * from './interceptor.model';\n// do not expose as it might confuse people on what to implement\n// export * from './http-handler.model';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;MAQsB,WAAW,CAAA;AAEhC;;ACLK,MAAO,oBAAqB,SAAQ,WAAW,CAAA;IACnD,WAAsB,CAAA,WAA4B,EAAY,WAAwB,EAAA;AACpF,QAAA,KAAK,EAAE,CAAC;QADY,IAAW,CAAA,WAAA,GAAX,W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EAAE,IAAI,EAAE,CAAC;AAC9C,CAAC;AAED,MAAM,SAAS,GAAe,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;AAChD,KAAA,GAAG,CAAC,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AACjC,KAAA,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC;AAChF;MAIa,UAAU,CAAA;AACrB,IAAA,OAAO,SAAS,GAAA;AACd,QAAA,OAAO,SAAS,CAAC;KAClB;AACD,IAAA,OAAO,OAAO,GAAA;QACZ,OAAO;AACL,YAAA,QAAQ,EAAE,UAAU;YACpB,SAAS;SACV,CAAC;KACH;;uGATU,UAAU,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;wGAAV,UAAU,EAAA,CAAA,CAAA;AAAV,UAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,UAAU,aAFrB,SAAS,EAAA,CAAA,CAAA;2FAEE,UAAU,EAAA,UAAA,EAAA,CAAA;kBAHtB,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACR,SAAS;AACV,iBAAA,CAAA;;;ACpBD;AACA;;ACNA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"c8y-ngx-components-api.mjs","sources":["../../api/interceptor.model.ts","../../api/http-handler.model.ts","../../api/api.service.ts","../../api/data.module.ts","../../api/index.ts","../../api/c8y-ngx-components-api.ts"],"sourcesContent":["import { ApiCall } from './api.model';\nimport { Observable } from 'rxjs';\nimport { IFetchResponse } from '@c8y/client';\n\nexport interface HttpInterceptor {\n intercept(req: ApiCall, next: HttpHandler): Observable<IFetchResponse>;\n}\n\nexport abstract class HttpHandler {\n abstract handle(req: ApiCall): Observable<IFetchResponse>;\n}\n","import { ApiCall } from './api.model';\nimport { Observable, from } from 'rxjs';\nimport { FetchClient, IFetchResponse } from '@c8y/client';\nimport { HttpHandler, HttpInterceptor } from './interceptor.model';\n\nexport class HttpInterceptHandler extends HttpHandler {\n constructor(protected interceptor: HttpInterceptor, protected nextHandler: HttpHandler) {\n super();\n }\n\n handle(req: ApiCall): Observable<IFetchResponse> {\n return this.interceptor.intercept(req, this.nextHandler);\n }\n}\n\nexport interface RequestStartAndFinish {\n onStart(req: ApiCall): void;\n onFinish(res: ApiCall): void;\n}\n\nexport class HttpRequestHandler extends HttpHandler {\n constructor(protected fetch: FetchClient['fetch'], protected apiService?: RequestStartAndFinish) {\n super();\n }\n\n handle(req: ApiCall): Observable<IFetchResponse> {\n const { options, url } = req;\n const { method } = options;\n this.apiService?.onStart({ method, options, url });\n let fetchPromise = this.fetch(url, options);\n if (typeof options.responseInterceptor === 'function') {\n fetchPromise = fetchPromise.then(options.responseInterceptor);\n }\n fetchPromise.then(\n (response: IFetchResponse) => this.apiService?.onFinish({ method, options, url, response }),\n (response: IFetchResponse) => this.apiService?.onFinish({ method, options, url, response })\n );\n return from(fetchPromise);\n }\n}\n","import { Injectable } from '@angular/core';\nimport { FetchClient, IFetchOptions, IFetchResponse } from '@c8y/client';\nimport { MonoTypeOperatorFunction, Observable, Subject, pipe } from 'rxjs';\nimport { filter } from 'rxjs/operators';\nimport { ApiCall, ApiCallOptions } from './api.model';\nimport {\n HttpInterceptHandler,\n HttpRequestHandler,\n RequestStartAndFinish\n} from './http-handler.model';\nimport { HttpHandler, HttpInterceptor } from './interceptor.model';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class ApiService implements RequestStartAndFinish {\n calls: Observable<ApiCall>;\n private callsSubject = new Subject<ApiCall>();\n private interceptors = new Map<string, HttpInterceptor>();\n private interceptorCounter = 0;\n\n constructor(private client: FetchClient) {\n this.calls = this.callsSubject.asObservable();\n this.hookIntoClientFetch();\n }\n\n /**\n * Allows to hook into the responses received by the FetchClient.\n * This is meant to be used to react on the responses, not for manipulation of the responses.\n * @param hookFilter A filter function to filter for specific responses.\n * @returns An Observable of the filtered responses.\n */\n hookResponse(hookFilter: (call: ApiCall) => boolean) {\n return this.callsSubject.pipe(\n filter(({ phase }) => phase === 'finish'),\n filter(hookFilter)\n );\n }\n\n /**\n * Allows to hook into the requests performed by the FetchClient.\n * This is meant to be used to react on the requests, not for manipulation of the requests.\n * @param hookFilter A filter function to filter for specific requests.\n * @returns An Observable of the filtered requests.\n */\n hookRequest(hookFilter: (call: ApiCall) => boolean) {\n return this.callsSubject.pipe(\n filter(({ phase }) => phase === 'start'),\n filter(hookFilter)\n );\n }\n\n onFinish(call: ApiCall) {\n this.callsSubject.next({ phase: 'finish', ...call });\n }\n\n onStart(call: ApiCall) {\n this.callsSubject.next({ phase: 'start', ...call });\n }\n\n resolveData<T = unknown>(call: ApiCall): Promise<{ data: T; method: string; url: string }> {\n const { response, method, url } = call;\n if ('data' in response) {\n return Promise.resolve({ data: response.data, method, url });\n } else {\n // No Content success status, for example DELETE request.\n if ((response as Response)?.status === 204) {\n return Promise.resolve({ data: null, method, url });\n }\n const cb = data => ({ data, method, url });\n return (response as Response).clone().json().then(cb, cb);\n }\n }\n\n /**\n * Can be added to a pipe to exclude any permission call. Permission calls are PUT\n * request with only an id in it, to verify if the user has access to this managed object.\n * @returns The operator to be added to a pipe.\n */\n excludePermissionCall(): MonoTypeOperatorFunction<ApiCall> {\n return pipe(\n filter(({ method, options }) => {\n if (method === 'PUT' && options.body && typeof options.body === 'string') {\n const parsedBody = JSON.parse(options.body as string);\n const bodyKeys = Object.keys(parsedBody);\n return !(bodyKeys.length === 1 && bodyKeys[0] === 'id');\n }\n return true;\n })\n );\n }\n\n /**\n * Allows to intercept requests performed via the FetchClient requests.\n * @param interceptor The interceptor to be added.\n * @param id An optional unique identifier for the interceptor. The chain of interceptors is ordered by this id. And it can be used to remove the interceptor later on.\n * @returns The id of the interceptor (same as provided id if one was provided, otherwise an id will be generated).\n */\n addInterceptor(interceptor: HttpInterceptor, id?: string): string {\n if (!id) {\n id = `${++this.interceptorCounter}`;\n }\n this.interceptors.set(id, interceptor);\n return id;\n }\n\n /**\n * Allows to remove a previously added interceptor by it's id.\n * @param id The id of the interceptor that should be removed.\n * @returns true if an interceptor existed and has been removed, or false if id does not exist.\n */\n removeInterceptor(id: string): boolean {\n return this.interceptors.delete(id);\n }\n\n /**\n * Checks if an interceptor with a given id exists.\n * @param id The id of the interceptor.\n * @returns - Returns true if an interceptor with the given id exists, otherwise false.\n */\n hasInterceptor(id: string): boolean {\n return this.interceptors.has(id);\n }\n\n private hookIntoClientFetch() {\n const fetch: FetchClient['fetch'] = this.client.fetch.bind(this.client);\n const requestHandler = new HttpRequestHandler(fetch, this);\n this.client.fetch = async (\n url,\n options: ApiCallOptions & IFetchOptions = { method: 'GET' }\n ) => {\n const { method } = options;\n return this.createInterceptorChain({ url, options, method }, requestHandler).toPromise();\n };\n }\n\n private createInterceptorChain(\n call: ApiCall,\n requestHandler: HttpRequestHandler\n ): Observable<IFetchResponse> {\n let handler: HttpHandler = requestHandler;\n // Do some sorting to always apply the interceptors in the specific order\n const sortedInterceptorIds = Array.from(this.interceptors.keys()).sort((a, b) =>\n b.localeCompare(a)\n );\n for (const interceptorId of sortedInterceptorIds) {\n handler = new HttpInterceptHandler(this.interceptors.get(interceptorId), handler);\n }\n return handler.handle(call);\n }\n}\n","import { ModuleWithProviders, NgModule, Provider, Type } from '@angular/core';\nimport { BasicAuth, FetchClient, Realtime, CookieAuth } from '@c8y/client';\nimport { ApiService } from './api.service';\nimport * as services from './services';\n\nfunction toProvider(provide: Type<unknown>): Provider {\n let deps: Array<Type<FetchClient | Realtime | CookieAuth>> = [FetchClient, Realtime];\n if (provide === FetchClient) {\n deps = [CookieAuth];\n }\n if (provide === BasicAuth || provide === CookieAuth) {\n deps = [];\n }\n if (provide === Realtime) {\n deps = [FetchClient];\n }\n return { provide, useClass: provide, deps };\n}\n\nconst providers: Provider[] = Object.keys(services)\n .map(k => toProvider(services[k]))\n .concat([{ provide: ApiService, useClass: ApiService, deps: [FetchClient] }]);\n// @dynamic\n@NgModule({\n providers\n})\nexport class DataModule {\n static providers(): Provider[] {\n return providers;\n }\n static forRoot(): ModuleWithProviders<DataModule> {\n return {\n ngModule: DataModule,\n providers\n };\n }\n}\n","export * from './api.service';\nexport * from './api.model';\nexport * from './data.module';\nexport * from './services';\nexport * from './interceptor.model';\n// do not expose as it might confuse people on what to implement\n// export * from './http-handler.model';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;MAQsB,WAAW,CAAA;AAEhC;;ACLK,MAAO,oBAAqB,SAAQ,WAAW,CAAA;IACnD,WAAsB,CAAA,WAA4B,EAAY,WAAwB,EAAA;AACpF,QAAA,KAAK,EAAE,CAAC;QADY,IAAW,CAAA,WAAA,GAAX,WAAW,CAAiB;QAAY,IAAW,CAAA,WAAA,GAAX,WAAW,CAAa;KAErF;AAED,IAAA,MAAM,CAAC,GAAY,EAAA;AACjB,QAAA,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;KAC1D;AACF,CAAA;AAOK,MAAO,kBAAmB,SAAQ,WAAW,CAAA;IACjD,WAAsB,CAAA,KAA2B,EAAY,UAAkC,EAAA;AAC7F,QAAA,KAAK,EAAE,CAAC;QADY,IAAK,CAAA,KAAA,GAAL,KAAK,CAAsB;QAAY,IAAU,CAAA,UAAA,GAAV,UAAU,CAAwB;KAE9F;AAED,IAAA,MAAM,CAAC,GAAY,EAAA;AACjB,QAAA,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;AAC7B,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;AAC3B,QAAA,IAAI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AA,EAAA,CAAA,CAAA;wGAAV,UAAU,EAAA,CAAA,CAAA;AAAV,UAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,UAAU,aAFrB,SAAS,EAAA,CAAA,CAAA;2FAEE,UAAU,EAAA,UAAA,EAAA,CAAA;kBAHtB,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACR,SAAS;AACV,iBAAA,CAAA;;;ACpBD;AACA;;ACNA;;AAEG;;;;"}
|
|
@@ -23,7 +23,7 @@ class ChildDevicesComponent {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
ChildDevicesComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ChildDevicesComponent, deps: [{ token: i1.ActivatedRoute }, { token: i2.DeviceGridService }], target: i0.ɵɵFactoryTarget.Component });
|
|
26
|
-
ChildDevicesComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.7", type: ChildDevicesComponent, selector: "c8y-child-devices", providers: [ManagedObjectRealtimeService], ngImport: i0, template: "<div class=\"content-fullpage border-top border-bottom\">\n <c8y-device-grid\n [title]=\"'Child devices' | translate\"\n [childDeviceGrid]=\"true\"\n [columns]=\"columns\"\n [parentDeviceId]=\"id\"\n c8yProductExperience\n [actionName]=\"'childDevices'\"\n ></c8y-device-grid>\n</div>\n", dependencies: [{ kind: "directive", type: i3.ProductExperienceDirective, selector: "[c8yProductExperience]", inputs: ["actionName", "actionData", "inherit", "suppressDataOverriding"] }, { kind: "component", type: i2.DeviceGridComponent, selector: "c8y-device-grid", inputs: ["dataCallback", "refresh", "title", "loadMoreItemsLabel", "loadingItemsLabel", "legacyConfigKey", "legacyFilterKey", "columns", "pagination", "infiniteScroll", "actionControls", "selectable", "singleSelection", "baseQuery", "bulkActionControls", "headerActionControls", "childDeviceGrid", "parentDeviceId", "withChildren", "showSearch", "activeClassName"], outputs: ["onColumnsChange", "onFilterChange", "onDeviceQueryStringChange", "itemsSelect"] }, { kind: "pipe", type: i3.C8yTranslatePipe, name: "translate" }] });
|
|
26
|
+
ChildDevicesComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.7", type: ChildDevicesComponent, selector: "c8y-child-devices", providers: [ManagedObjectRealtimeService], ngImport: i0, template: "<div class=\"content-fullpage border-top border-bottom\">\n <c8y-device-grid\n [title]=\"'Child devices' | translate\"\n [childDeviceGrid]=\"true\"\n [columns]=\"columns\"\n [parentDeviceId]=\"id\"\n c8yProductExperience\n [actionName]=\"'childDevices'\"\n ></c8y-device-grid>\n</div>\n", dependencies: [{ kind: "directive", type: i3.ProductExperienceDirective, selector: "[c8yProductExperience]", inputs: ["actionName", "actionData", "inherit", "suppressDataOverriding"] }, { kind: "component", type: i2.DeviceGridComponent, selector: "c8y-device-grid", inputs: ["dataCallback", "refresh", "title", "loadMoreItemsLabel", "loadingItemsLabel", "legacyConfigKey", "legacyFilterKey", "columns", "pagination", "infiniteScroll", "builtInActionsToHide", "actionControls", "selectable", "singleSelection", "baseQuery", "bulkActionControls", "headerActionControls", "childDeviceGrid", "parentDeviceId", "withChildren", "showSearch", "activeClassName"], outputs: ["onColumnsChange", "onFilterChange", "onDeviceQueryStringChange", "itemsSelect"] }, { kind: "pipe", type: i3.C8yTranslatePipe, name: "translate" }] });
|
|
27
27
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ChildDevicesComponent, decorators: [{
|
|
28
28
|
type: Component,
|
|
29
29
|
args: [{ selector: 'c8y-child-devices', providers: [ManagedObjectRealtimeService], template: "<div class=\"content-fullpage border-top border-bottom\">\n <c8y-device-grid\n [title]=\"'Child devices' | translate\"\n [childDeviceGrid]=\"true\"\n [columns]=\"columns\"\n [parentDeviceId]=\"id\"\n c8yProductExperience\n [actionName]=\"'childDevices'\"\n ></c8y-device-grid>\n</div>\n" }]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"c8y-ngx-components-child-devices.mjs","sources":["../../child-devices/child-devices.component.ts","../../child-devices/child-devices.component.html","../../child-devices/child-devices.guard.ts","../../child-devices/child-devices.module.ts","../../child-devices/c8y-ngx-components-child-devices.ts"],"sourcesContent":["import { Component, OnInit } from '@angular/core';\nimport { ActivatedRoute } from '@angular/router';\nimport { Column, ManagedObjectRealtimeService } from '@c8y/ngx-components';\nimport { DeviceGridService } from '@c8y/ngx-components/device-grid';\n\n@Component({\n selector: 'c8y-child-devices',\n templateUrl: './child-devices.component.html',\n providers: [ManagedObjectRealtimeService]\n})\nexport class ChildDevicesComponent implements OnInit {\n id: string;\n columns: Column[];\n\n constructor(private route: ActivatedRoute, private deviceGridService: DeviceGridService) {}\n\n async ngOnInit() {\n await this.getAllDevices();\n this.columns = this.deviceGridService.getChildDeviceGridColumns();\n }\n\n async getAllDevices() {\n this.id = this.route.snapshot.parent.data.contextData;\n }\n}\n","<div class=\"content-fullpage border-top border-bottom\">\n <c8y-device-grid\n [title]=\"'Child devices' | translate\"\n [childDeviceGrid]=\"true\"\n [columns]=\"columns\"\n [parentDeviceId]=\"id\"\n c8yProductExperience\n [actionName]=\"'childDevices'\"\n ></c8y-device-grid>\n</div>\n","import { Injectable } from '@angular/core';\nimport { ActivatedRouteSnapshot, CanActivate } from '@angular/router';\nimport { InventoryService } from '@c8y/client';\nimport { isEmpty } from 'lodash-es';\n\n@Injectable()\nexport class ChildDevicesTabGuard implements CanActivate {\n constructor(private inventory: InventoryService) {}\n\n async canActivate(route: ActivatedRouteSnapshot): Promise<boolean> {\n const contextData = route.data.contextData;\n\n const filter: object = {\n pageSize: 1\n };\n\n if (isEmpty(contextData)) {\n return true;\n }\n const device = await this.inventory.childDevicesList(contextData.id, filter);\n const hasChildren = device.data.length;\n const isVendme = route.data.contextData.type === 'com_nsn_startups_vendme_VendingMachine';\n return hasChildren && !isVendme;\n }\n}\n","import { NgModule } from '@angular/core';\nimport { CoreModule, gettext, hookRoute, ViewContext } from '@c8y/ngx-components';\nimport { DeviceGridModule } from '@c8y/ngx-components/device-grid';\nimport { PopoverModule } from 'ngx-bootstrap/popover';\nimport { ChildDevicesComponent } from './child-devices.component';\nimport { ChildDevicesTabGuard } from './child-devices.guard';\n\n@NgModule({\n declarations: [ChildDevicesComponent],\n imports: [CoreModule, DeviceGridModule, PopoverModule],\n entryComponents: [ChildDevicesComponent],\n providers: [\n ChildDevicesTabGuard,\n hookRoute({\n context: ViewContext.Device,\n path: 'child-devices',\n priority: 1000,\n icon: 'code-fork',\n label: gettext('Child devices'),\n component: ChildDevicesComponent,\n canActivate: [ChildDevicesTabGuard]\n })\n ]\n})\nexport class ChildDevicesModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1"],"mappings":";;;;;;;;;;;MAUa,qBAAqB,CAAA;IAIhC,WAAoB,CAAA,KAAqB,EAAU,iBAAoC,EAAA;QAAnE,IAAK,CAAA,KAAA,GAAL,KAAK,CAAgB;QAAU,IAAiB,CAAA,iBAAA,GAAjB,iBAAiB,CAAmB;KAAI;AAE3F,IAAA,MAAM,QAAQ,GAAA;AACZ,QAAA,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,yBAAyB,EAAE,CAAC;KACnE;AAED,IAAA,MAAM,aAAa,GAAA;AACjB,QAAA,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC;KACvD;;kHAbU,qBAAqB,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAA,EAAA,CAAA,cAAA,EAAA,EAAA,EAAA,KAAA,EAAA,EAAA,CAAA,iBAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,C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AEG;;;;"}
|
|
1
|
+
{"version":3,"file":"c8y-ngx-components-child-devices.mjs","sources":["../../child-devices/child-devices.component.ts","../../child-devices/child-devices.component.html","../../child-devices/child-devices.guard.ts","../../child-devices/child-devices.module.ts","../../child-devices/c8y-ngx-components-child-devices.ts"],"sourcesContent":["import { Component, OnInit } from '@angular/core';\nimport { ActivatedRoute } from '@angular/router';\nimport { Column, ManagedObjectRealtimeService } from '@c8y/ngx-components';\nimport { DeviceGridService } from '@c8y/ngx-components/device-grid';\n\n@Component({\n selector: 'c8y-child-devices',\n templateUrl: './child-devices.component.html',\n providers: [ManagedObjectRealtimeService]\n})\nexport class ChildDevicesComponent implements OnInit {\n id: string;\n columns: Column[];\n\n constructor(private route: ActivatedRoute, private deviceGridService: DeviceGridService) {}\n\n async ngOnInit() {\n await this.getAllDevices();\n this.columns = this.deviceGridService.getChildDeviceGridColumns();\n }\n\n async getAllDevices() {\n this.id = this.route.snapshot.parent.data.contextData;\n }\n}\n","<div class=\"content-fullpage border-top border-bottom\">\n <c8y-device-grid\n [title]=\"'Child devices' | translate\"\n [childDeviceGrid]=\"true\"\n [columns]=\"columns\"\n [parentDeviceId]=\"id\"\n c8yProductExperience\n [actionName]=\"'childDevices'\"\n ></c8y-device-grid>\n</div>\n","import { Injectable } from '@angular/core';\nimport { ActivatedRouteSnapshot, CanActivate } from '@angular/router';\nimport { InventoryService } from '@c8y/client';\nimport { isEmpty } from 'lodash-es';\n\n@Injectable()\nexport class ChildDevicesTabGuard implements CanActivate {\n constructor(private inventory: InventoryService) {}\n\n async canActivate(route: ActivatedRouteSnapshot): Promise<boolean> {\n const contextData = route.data.contextData;\n\n const filter: object = {\n pageSize: 1\n };\n\n if (isEmpty(contextData)) {\n return true;\n }\n const device = await this.inventory.childDevicesList(contextData.id, filter);\n const hasChildren = device.data.length;\n const isVendme = route.data.contextData.type === 'com_nsn_startups_vendme_VendingMachine';\n return hasChildren && !isVendme;\n }\n}\n","import { NgModule } from '@angular/core';\nimport { CoreModule, gettext, hookRoute, ViewContext } from '@c8y/ngx-components';\nimport { DeviceGridModule } from '@c8y/ngx-components/device-grid';\nimport { PopoverModule } from 'ngx-bootstrap/popover';\nimport { ChildDevicesComponent } from './child-devices.component';\nimport { ChildDevicesTabGuard } from './child-devices.guard';\n\n@NgModule({\n declarations: [ChildDevicesComponent],\n imports: [CoreModule, DeviceGridModule, PopoverModule],\n entryComponents: [ChildDevicesComponent],\n providers: [\n ChildDevicesTabGuard,\n hookRoute({\n context: ViewContext.Device,\n path: 'child-devices',\n priority: 1000,\n icon: 'code-fork',\n label: gettext('Child devices'),\n component: ChildDevicesComponent,\n canActivate: [ChildDevicesTabGuard]\n })\n ]\n})\nexport class ChildDevicesModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1"],"mappings":";;;;;;;;;;;MAUa,qBAAqB,CAAA;IAIhC,WAAoB,CAAA,KAAqB,EAAU,iBAAoC,EAAA;QAAnE,IAAK,CAAA,KAAA,GAAL,KAAK,CAAgB;QAAU,IAAiB,CAAA,iBAAA,GAAjB,iBAAiB,CAAmB;KAAI;AAE3F,IAAA,MAAM,QAAQ,GAAA;AACZ,QAAA,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,yBAAyB,EAAE,CAAC;KACnE;AAED,IAAA,MAAM,aAAa,GAAA;AACjB,QAAA,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC;KACvD;;kHAbU,qBAAqB,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAA,EAAA,CAAA,cAAA,EAAA,EAAA,EAAA,KAAA,EAAA,EAAA,CAAA,iBAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAAA;AAArB,qBAAA,CAAA,IAAA,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extends ExtensionPointWithoutStateForPlugins {
|
|
|
1077
1077
|
}
|
|
1078
1078
|
setupItemsObservable() {
|
|
1079
1079
|
return fromTriggerOnce(this.router, this.refresh$, [
|
|
1080
|
-
() =>
|
|
1081
|
-
{
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1080
|
+
() => {
|
|
1081
|
+
const actions = flatten(this.injectors.map(injector => injector.get(HOOK_DEVICE_GRID_ACTION, [], { self: true })));
|
|
1082
|
+
const hasDeleteAction = actions.some(action => action.type === "DELETE" /* BuiltInActionType.Delete */);
|
|
1083
|
+
if (!hasDeleteAction) {
|
|
1084
|
+
actions.push({
|
|
1085
|
+
type: "DELETE" /* BuiltInActionType.Delete */,
|
|
1086
|
+
deviceMatches: (_mo) => true,
|
|
1087
|
+
onAction: (mo) => this.deviceGridService.delete(mo),
|
|
1088
|
+
refreshAfterActionDone: true
|
|
1089
|
+
});
|
|
1086
1090
|
}
|
|
1087
|
-
|
|
1091
|
+
return actions;
|
|
1092
|
+
},
|
|
1088
1093
|
() => this.factories
|
|
1089
1094
|
]).pipe(shareReplay(1));
|
|
1090
1095
|
}
|
|
@@ -1152,6 +1157,11 @@ class DeviceGridComponent {
|
|
|
1152
1157
|
this.loadingItemsLabel = gettext('Loading devices…');
|
|
1153
1158
|
/** The list of columns to be displayed in the grid. If not given, it defaults to standard columns. */
|
|
1154
1159
|
this.columns = this.deviceGridService.getDefaultColumns();
|
|
1160
|
+
/**
|
|
1161
|
+
* Represents the input property for hiding specific built-in action types.
|
|
1162
|
+
* The `actionsToHide` input allows specifying an array of `BuiltInActionType` values or the string 'ALL' to hide all action controls
|
|
1163
|
+
*/
|
|
1164
|
+
this.builtInActionsToHide = [];
|
|
1155
1165
|
/** Determines whether items can be selected by clicking a checkbox in the first column. */
|
|
1156
1166
|
this.selectable = false;
|
|
1157
1167
|
/** Restricts selection to a single row only. Selection column displays radio button instead of checkboxes */
|
|
@@ -1231,29 +1241,37 @@ class DeviceGridComponent {
|
|
|
1231
1241
|
return serverSideDataResult;
|
|
1232
1242
|
}
|
|
1233
1243
|
setActionControls() {
|
|
1244
|
+
if (this.builtInActionsToHide === 'ALL') {
|
|
1245
|
+
return;
|
|
1246
|
+
}
|
|
1234
1247
|
const asArrayOfGroupedActionHooks = (hooks) => Object.values(groupBy(hooks, 'type'));
|
|
1235
1248
|
this.dgExtensionService.items$
|
|
1236
1249
|
.pipe(map$1(asArrayOfGroupedActionHooks), switchMap(from), map$1((hooks) => {
|
|
1237
1250
|
const { type, icon, text, showOnHover } = hooks[0];
|
|
1251
|
+
const actionsToHide = this.builtInActionsToHide;
|
|
1252
|
+
const shouldPushToActionControls = actionsToHide.length === 0 || !actionsToHide.includes(type);
|
|
1238
1253
|
const matchingHooks = (device) => hooks.filter(hook => hook.deviceMatches(device));
|
|
1239
1254
|
const hasMatchingHooks = (device) => !!matchingHooks(device).length;
|
|
1240
1255
|
const useInventoryDelete = (device) => !hasMatchingHooks(device) && type === "DELETE" /* BuiltInActionType.Delete */;
|
|
1241
1256
|
const resolveAction = (device) => useInventoryDelete(device)
|
|
1242
1257
|
? this.deviceGridService.delete(device)
|
|
1243
1258
|
: matchingHooks(device)[0].onAction(device);
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1259
|
+
if (shouldPushToActionControls) {
|
|
1260
|
+
this.actionControls.push({
|
|
1261
|
+
type,
|
|
1262
|
+
icon,
|
|
1263
|
+
text,
|
|
1264
|
+
showOnHover,
|
|
1265
|
+
showIf: (device) => type === "DELETE" /* BuiltInActionType.Delete */ || hasMatchingHooks(device),
|
|
1266
|
+
callback: (device) => toObservable(resolveAction(device))
|
|
1267
|
+
.pipe(catchError(_err => EMPTY), takeUntil(this.destroyed$))
|
|
1268
|
+
.subscribe(_success => {
|
|
1269
|
+
if (useInventoryDelete(device) ||
|
|
1270
|
+
matchingHooks(device)[0].refreshAfterActionDone)
|
|
1271
|
+
this.refresh.emit();
|
|
1272
|
+
})
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1257
1275
|
}), takeUntil(this.destroyed$))
|
|
1258
1276
|
.subscribe();
|
|
1259
1277
|
}
|
|
@@ -1268,7 +1286,7 @@ class DeviceGridComponent {
|
|
|
1268
1286
|
}
|
|
1269
1287
|
}
|
|
1270
1288
|
DeviceGridComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: DeviceGridComponent, deps: [{ token: DeviceGridService }, { token: DeviceGridExtensionService }], target: i0.ɵɵFactoryTarget.Component });
|
|
1271
|
-
DeviceGridComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.7", type: DeviceGridComponent, selector: "c8y-device-grid", inputs: { dataCallback: "dataCallback", refresh: "refresh", title: "title", loadMoreItemsLabel: "loadMoreItemsLabel", loadingItemsLabel: "loadingItemsLabel", legacyConfigKey: "legacyConfigKey", legacyFilterKey: "legacyFilterKey", columns: "columns", _pagination: ["pagination", "_pagination"], _infiniteScroll: ["infiniteScroll", "_infiniteScroll"], _actionControls: ["actionControls", "_actionControls"], selectable: "selectable", singleSelection: "singleSelection", baseQuery: "baseQuery", _bulkActionControls: ["bulkActionControls", "_bulkActionControls"], _headerActionControls: ["headerActionControls", "_headerActionControls"], childDeviceGrid: "childDeviceGrid", parentDeviceId: "parentDeviceId", withChildren: "withChildren", showSearch: "showSearch", activeClassName: "activeClassName" }, outputs: { onColumnsChange: "onColumnsChange", onFilterChange: "onFilterChange", onDeviceQueryStringChange: "onDeviceQueryStringChange", itemsSelect: "itemsSelect" }, providers: [
|
|
1289
|
+
DeviceGridComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.7", type: DeviceGridComponent, selector: "c8y-device-grid", inputs: { dataCallback: "dataCallback", refresh: "refresh", title: "title", loadMoreItemsLabel: "loadMoreItemsLabel", loadingItemsLabel: "loadingItemsLabel", legacyConfigKey: "legacyConfigKey", legacyFilterKey: "legacyFilterKey", columns: "columns", _pagination: ["pagination", "_pagination"], _infiniteScroll: ["infiniteScroll", "_infiniteScroll"], builtInActionsToHide: "builtInActionsToHide", _actionControls: ["actionControls", "_actionControls"], selectable: "selectable", singleSelection: "singleSelection", baseQuery: "baseQuery", _bulkActionControls: ["bulkActionControls", "_bulkActionControls"], _headerActionControls: ["headerActionControls", "_headerActionControls"], childDeviceGrid: "childDeviceGrid", parentDeviceId: "parentDeviceId", withChildren: "withChildren", showSearch: "showSearch", activeClassName: "activeClassName" }, outputs: { onColumnsChange: "onColumnsChange", onFilterChange: "onFilterChange", onDeviceQueryStringChange: "onDeviceQueryStringChange", itemsSelect: "itemsSelect" }, providers: [
|
|
1272
1290
|
{
|
|
1273
1291
|
provide: PRODUCT_EXPERIENCE_EVENT_SOURCE,
|
|
1274
1292
|
useExisting: forwardRef(() => DeviceGridComponent)
|
|
@@ -1305,6 +1323,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
1305
1323
|
}], _infiniteScroll: [{
|
|
1306
1324
|
type: Input,
|
|
1307
1325
|
args: ['infiniteScroll']
|
|
1326
|
+
}], builtInActionsToHide: [{
|
|
1327
|
+
type: Input
|
|
1308
1328
|
}], _actionControls: [{
|
|
1309
1329
|
type: Input,
|
|
1310
1330
|
args: ['actionControls']
|