Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
zsco committed Dec 6, 2024
2 parents 87ed851 + f34c05d commit d38c829
Show file tree
Hide file tree
Showing 97 changed files with 1,044 additions and 1,203 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
"@angular-eslint/component-selector": [
"error",
{
"type": "attribute",
"type": "string",
"prefix": "senergy",
"style": "camelCase"
"style": "kebab-case"
}
],
"brace-style": [
Expand Down
5 changes: 5 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
],
"styles": [
"src/styles.css",
{
"input": "src/themes/indigo.scss",
"bundleName": "indigo",
"inject": false
},
{
"input": "src/themes/lll.scss",
"bundleName": "lll",
Expand Down
8 changes: 7 additions & 1 deletion src/app/core/directives/matError.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ export class MatErrorMessagesDirective implements AfterViewInit, OnDestroy {
const container = this._inj.get(MatFormField);
this.inputRef = container._control;
if (this.formControl == null) {
this.formControl = this.inputRef.ngControl.control;
try {
this.formControl = this.inputRef.ngControl.control;
} catch (e) {
throw new Error('FormControl must be provided to mat-error with label: ' + this.label + '\n This ' +
'can be done by using formControlName, formControl, or ngModel in the relevant mat-form-field. ' +
'If there is no FormControl needed for the mat-form-field, then the mat-error is redundant, too.');
}
}

//console.log(this.label, ' inputRef: ', this.inputRef);
Expand Down
57 changes: 0 additions & 57 deletions src/app/core/model/permissions/permissions.ts

This file was deleted.

18 changes: 8 additions & 10 deletions src/app/modules/admin/permissions/shared/services/ladom.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,11 @@ export class LadonService {
const requests: AuthorizationRequest[] = [];
const methods: AllowedMethods[] = ['GET', 'DELETE', 'POST', 'PUT', 'PATCH'];

const ServiceEndpoints = [
const serviceEndpoints = [
environment.flowRepoUrl,
environment.flowEngineUrl,
environment.flowParserUrl,

environment.permissionSearchUrl,
environment.permissionSearchUrl + '/v3/resources/characteristics',
environment.permissionSearchUrl + '/v3/resources/device-classes',
environment.permissionSearchUrl + '/v3/resources/functions',
environment.permissionSearchUrl + '/v3/resources/concepts',
environment.permissionSearchUrl + '/v3/resources/device-types',

environment.apiAggregatorUrl,
environment.deviceRepoUrl,
environment.iotRepoUrl,
Expand All @@ -127,6 +120,11 @@ export class LadonService {

environment.deviceRepoUrl,
environment.deviceRepoUrl + '/aspects',
environment.deviceRepoUrl + '/v2/device-classes',
environment.deviceRepoUrl + '/characteristics',
environment.deviceRepoUrl + '/v2/concepts',
environment.deviceRepoUrl + '/device-types',
environment.deviceRepoUrl + '/functions',

environment.deviceManagerUrl,
environment.deviceManagerUrl + '/device-types',
Expand All @@ -149,7 +147,7 @@ export class LadonService {
environment.reportEngineUrl,
];

ServiceEndpoints.forEach(endpointURL => {
serviceEndpoints.forEach(endpointURL => {
const endpoint = new URL(endpointURL).pathname;

methods.forEach(method => {
Expand All @@ -160,7 +158,7 @@ export class LadonService {
return new Promise((resolve, _) => {
this.userIsAuthorized(requests).subscribe(authResponse => {
const allRules: Record<string, PermissionTestResponse> = {};
ServiceEndpoints.forEach((endpointURL, endpointIndex) => {
serviceEndpoints.forEach((endpointURL, endpointIndex) => {
allRules[endpointURL] = {
GET: true,
POST: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {Component, OnInit, ViewChild} from '@angular/core';
import {TimescaleRulesService} from './shared/timescale-rules.service';
import {TimescaleRuleModel, TimescaleRuleTemplateModel} from './shared/timescale-rule.model';
import {MatTable} from '@angular/material/table';
import {ImportTypePermissionSearchModel} from '../../imports/import-types/shared/import-types.model';
import {ImportTypeModel} from '../../imports/import-types/shared/import-types.model';
import {MatDialog, MatDialogConfig} from '@angular/material/dialog';
import {TimescaleRulesCreateEditComponent} from './timescale-rules-create-edit/timescale-rules-create-edit.component';
import {DialogsService} from '../../../core/services/dialogs.service';
Expand All @@ -35,7 +35,7 @@ import {
styleUrls: ['./timescale-rules.component.css']
})
export class TimescaleRulesComponent implements OnInit {
@ViewChild(MatTable, {static: false}) table!: MatTable<ImportTypePermissionSearchModel>;
@ViewChild(MatTable, {static: false}) table!: MatTable<ImportTypeModel>;

constructor(
private timescaleRuleService: TimescaleRulesService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ import { MatCardModule } from '@angular/material/card';
import { MatTooltipModule } from '@angular/material/tooltip';
import { CommonModule } from '@angular/common';
import { FlexLayoutModule } from '@angular/flex-layout';
import { DeviceTypeFunctionModel } from '../../../metadata/device-types-overview/shared/device-type.model';
import { DeviceClassesPermSearchModel } from '../../../metadata/device-classes/shared/device-classes-perm-search.model';
import { DeviceTypeDeviceClassModel, DeviceTypeFunctionModel } from '../../../metadata/device-types-overview/shared/device-type.model';
import { AspectsPermSearchModel } from '../../../metadata/aspects/shared/aspects-perm-search.model';
import { DeviceInstancesService } from '../../device-instances/shared/device-instances.service';

Expand Down Expand Up @@ -137,11 +136,8 @@ describe('DeviceGroupsEditComponent', () => {
id: 'device-class:id-1',
name: 'controller-type',
image: '',
creator: '',
permissions: { r: true, w: true, x: true, a: true },
shared: false,
},
] as DeviceClassesPermSearchModel[];
] as DeviceTypeDeviceClassModel[];

const knownAspects = [
{
Expand Down Expand Up @@ -481,7 +477,7 @@ describe('DeviceGroupsEditComponent', () => {
return of(JSON.parse(JSON.stringify(result)));
});
deviceGroupServiceSpy.getDeviceClassListByIds.and.callFake(function(ids: string[]) {
const result: DeviceClassesPermSearchModel[] = [];
const result: DeviceTypeDeviceClassModel[] = [];
for (const id of ids) {
for (const dc of knownDeviceClasses) {
if (id === dc.id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ import {
} from '../shared/device-groups.model';
import {Attribute, DeviceInstancesBaseModel} from '../../device-instances/shared/device-instances.model';
import { debounceTime, delay } from 'rxjs/operators';
import { DeviceTypeFunctionModel } from '../../../metadata/device-types-overview/shared/device-type.model';
import { AspectsPermSearchModel } from '../../../metadata/aspects/shared/aspects-perm-search.model';
import { DeviceClassesPermSearchModel } from '../../../metadata/device-classes/shared/device-classes-perm-search.model';
import { DeviceTypeAspectModel, DeviceTypeDeviceClassModel, DeviceTypeFunctionModel } from '../../../metadata/device-types-overview/shared/device-type.model';
import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
import { DeviceGroupsPipelineHelperDialogComponent } from './device-groups-pipeline-helper-dialog/device-groups-pipeline-helper-dialog.component';
import { PipelineRegistryService } from '../../../data/pipeline-registry/shared/pipeline-registry.service';
Expand All @@ -52,8 +50,8 @@ export class DeviceGroupsEditComponent implements OnInit {

deviceCache: Map<string, DeviceInstancesBaseModel> = new Map<string, DeviceInstancesBaseModel>();
functionsCache: Map<string, DeviceTypeFunctionModel> = new Map<string, DeviceTypeFunctionModel>();
aspectCache: Map<string, AspectsPermSearchModel> = new Map<string, AspectsPermSearchModel>();
deviceClassCache: Map<string, DeviceClassesPermSearchModel> = new Map<string, DeviceClassesPermSearchModel>();
aspectCache: Map<string, DeviceTypeAspectModel> = new Map<string, DeviceTypeAspectModel>();
deviceClassCache: Map<string, DeviceTypeDeviceClassModel> = new Map<string, DeviceTypeDeviceClassModel>();

debounceTimeInMs = 500;
rerouteAfterSaveDelayInMs = 2000;
Expand Down Expand Up @@ -307,8 +305,8 @@ export class DeviceGroupsEditComponent implements OnInit {
Promise.all([this.loadIotFunctions(functionIds), this.loadAspects(aspectIds), this.loadDeviceClasses(deviceClassIds)]).then(
(infos) => {
const functions: Map<string, DeviceTypeFunctionModel> = infos[0];
const aspects: Map<string, AspectsPermSearchModel> = infos[1];
const deviceClasses: Map<string, DeviceClassesPermSearchModel> = infos[2];
const aspects: Map<string, DeviceTypeAspectModel> = infos[1];
const deviceClasses: Map<string, DeviceTypeDeviceClassModel> = infos[2];
let result: DeviceGroupCapability[] = [];
for (const c of criteria) {
const element: DeviceGroupCapability = {
Expand Down Expand Up @@ -418,8 +416,8 @@ export class DeviceGroupsEditComponent implements OnInit {
}
}

private loadAspects(aspectIds: string[]): Promise<Map<string, AspectsPermSearchModel>> {
const result: Map<string, AspectsPermSearchModel> = new Map<string, AspectsPermSearchModel>();
private loadAspects(aspectIds: string[]): Promise<Map<string, DeviceTypeAspectModel>> {
const result: Map<string, DeviceTypeAspectModel> = new Map<string, DeviceTypeAspectModel>();
const idsForRepoSearch: string[] = [];
for (const id of aspectIds) {
const cachedElement = this.aspectCache.get(id);
Expand All @@ -430,7 +428,7 @@ export class DeviceGroupsEditComponent implements OnInit {
}
}
if (idsForRepoSearch.length) {
return new Promise<Map<string, AspectsPermSearchModel>>((resolve) => {
return new Promise<Map<string, DeviceTypeAspectModel>>((resolve) => {
this.deviceGroupService.getAspectListByIds(idsForRepoSearch).subscribe((value) => {
for (const element of value) {
result.set(element.id, element);
Expand All @@ -443,8 +441,8 @@ export class DeviceGroupsEditComponent implements OnInit {
}
}

private loadDeviceClasses(deviceClassIds: string[]): Promise<Map<string, DeviceClassesPermSearchModel>> {
const result: Map<string, DeviceClassesPermSearchModel> = new Map<string, DeviceClassesPermSearchModel>();
private loadDeviceClasses(deviceClassIds: string[]): Promise<Map<string, DeviceTypeDeviceClassModel>> {
const result: Map<string, DeviceTypeDeviceClassModel> = new Map<string, DeviceTypeDeviceClassModel>();
const idsForRepoSearch: string[] = [];
for (const id of deviceClassIds) {
const cachedElement = this.deviceClassCache.get(id);
Expand All @@ -455,7 +453,7 @@ export class DeviceGroupsEditComponent implements OnInit {
}
}
if (idsForRepoSearch.length) {
return new Promise<Map<string, DeviceClassesPermSearchModel>>((resolve) => {
return new Promise<Map<string, DeviceTypeDeviceClassModel>>((resolve) => {
this.deviceGroupService.getDeviceClassListByIds(idsForRepoSearch).subscribe((value) => {
for (const element of value) {
result.set(element.id, element);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ import {Observable} from 'rxjs';
import {environment} from '../../../../../environments/environment';
import {catchError, map} from 'rxjs/operators';
import {DeviceGroupCriteriaModel, DeviceGroupHelperResultModel, DeviceGroupModel} from './device-groups.model';
import {DeviceTypeFunctionModel} from '../../../metadata/device-types-overview/shared/device-type.model';
import {DeviceClassesPermSearchModel} from '../../../metadata/device-classes/shared/device-classes-perm-search.model';
import {AspectsPermSearchModel} from '../../../metadata/aspects/shared/aspects-perm-search.model';
import {DeviceTypeAspectModel, DeviceTypeDeviceClassModel, DeviceTypeFunctionModel} from '../../../metadata/device-types-overview/shared/device-type.model';
import { PermissionTestResponse } from 'src/app/modules/admin/permissions/shared/permission.model';
import { LadonService } from 'src/app/modules/admin/permissions/shared/services/ladom.service';

Expand Down Expand Up @@ -159,55 +157,25 @@ export class DeviceGroupsService {

getFunctionListByIds(ids: string[]): Observable<DeviceTypeFunctionModel[]> {
return this.http
.post<DeviceTypeFunctionModel[]>(environment.permissionSearchUrl + '/v3/query/functions', { // TODO SNRGY-3575
resource: 'functions',
list_ids: {
ids,
limit: ids.length,
offset: 0,
rights: 'r',
sort_by: 'name',
sort_desc: false,
},
})
.get<DeviceTypeFunctionModel[]>(environment.deviceRepoUrl + '/functions?ids='+ids.join(','))
.pipe(
map((resp) => resp || []),
catchError(this.errorHandlerService.handleError(DeviceGroupsService.name, 'getFunctionListByIds(ids)', [])),
);
}

getAspectListByIds(ids: string[]): Observable<AspectsPermSearchModel[]> {
getAspectListByIds(ids: string[]): Observable<DeviceTypeAspectModel[]> {
return this.http
.post<AspectsPermSearchModel[]>(environment.permissionSearchUrl + '/v3/query/aspects', { // TODO SNRGY-3576
resource: 'aspects',
list_ids: {
ids,
limit: ids.length,
offset: 0,
rights: 'r',
sort_by: 'name',
sort_desc: false,
},
})
.get<DeviceTypeAspectModel[]>(environment.deviceRepoUrl + '/v2/aspects?ids='+ids.join(','))
.pipe(
map((resp) => resp || []),
catchError(this.errorHandlerService.handleError(DeviceGroupsService.name, 'getAspectListByIds(ids)', [])),
);
}

getDeviceClassListByIds(ids: string[]): Observable<DeviceClassesPermSearchModel[]> {
getDeviceClassListByIds(ids: string[]): Observable<DeviceTypeDeviceClassModel[]> {
return this.http
.post<DeviceClassesPermSearchModel[]>(environment.permissionSearchUrl + '/v3/query/device-classes', { // TODO SNRGY-3577
resource: 'device-classes',
list_ids: {
ids,
limit: ids.length,
offset: 0,
rights: 'r',
sort_by: 'name',
sort_desc: false,
},
})
.get<DeviceTypeDeviceClassModel[]>(environment.deviceRepoUrl + '/v2/device-classes?ids='+ids.join(','))
.pipe(
map((resp) => resp || []),
catchError(this.errorHandlerService.handleError(DeviceGroupsService.name, 'getDeviceClassListByIds(ids)', [])),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('DeviceInstancesComponent', () => {
deviceInstanceServiceSpy.userHasCreateAuthorization.and.returnValue(true);
deviceInstanceServiceSpy.listUsedDeviceTypeIds.and.returnValue(of());
const deviceTypeServiceSpy: Spy<DeviceTypeService> = createSpyFromClass(DeviceTypeService);
deviceTypeServiceSpy.userHasPermSearchAuthorization.and.returnValue(true);
deviceTypeServiceSpy.userHasListAuthorization.and.returnValue(true);

const exportDataServiceSpy: Spy<ExportDataService> = createSpyFromClass(ExportDataService);
exportDataServiceSpy.userHasUsageAuthroization.and.returnValue(false);
Expand Down
2 changes: 1 addition & 1 deletion src/app/modules/devices/networks/networks.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<ng-container matColumnDef="shared">
<th mat-header-cell *matHeaderCellDef disableClear class="button-column">Shared</th>
<td mat-cell *matCellDef="let network">
<mat-icon matTooltip="Device is shared by {{userIdToName[network.creator]}}" *ngIf="network.shared" class="color-sidenav info-icon">
<mat-icon matTooltip="Network is shared by {{userIdToName[network.creator]}}" *ngIf="network.shared" class="color-sidenav info-icon">
share
</mat-icon>
</td>
Expand Down
8 changes: 4 additions & 4 deletions src/app/modules/devices/networks/networks.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {MatDialog} from '@angular/material/dialog';
import {NetworksDeleteDialogComponent} from './dialogs/networks-delete-dialog.component';
import {DeviceInstancesService} from '../device-instances/shared/device-instances.service';
import {MatTableDataSource} from '@angular/material/table';
import {MatSort, Sort, SortDirection} from '@angular/material/sort';
import {Sort, SortDirection} from '@angular/material/sort';
import {SelectionModel} from '@angular/cdk/collections';
import {MatPaginator} from '@angular/material/paginator';
import {DialogsService} from 'src/app/core/services/dialogs.service';
Expand Down Expand Up @@ -111,9 +111,9 @@ export class NetworksComponent implements OnInit, OnDestroy, AfterViewInit {
this.sortBy = $event.active;

// TODO Ingo suche connection
if (this.sortBy == 'connection') {
if (this.sortBy === 'connection') {
this.sortBy = 'annotations.connected';
} else if (this.sortBy == 'number_devices') {
} else if (this.sortBy === 'number_devices') {
this.sortBy = 'device_local_ids';
}
this.sortDirection = $event.direction;
Expand Down Expand Up @@ -298,6 +298,6 @@ export class NetworksComponent implements OnInit, OnDestroy, AfterViewInit {
}

shareNetwork(network: HubModel): void {
this.permissionsDialogService.openPermissionDialog('hubs', network.id, network.name );
this.permissionsDialogService.openPermissionV2Dialog('hubs', network.id, network.name );
}
}
Loading

0 comments on commit d38c829

Please sign in to comment.