Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';

import { PolicyCardComponent } from './policy-card.component';

describe('AssetCardComponent', () => {
describe('PolicyCardComponent', () => {
let component: PolicyCardComponent;
let fixture: ComponentFixture<PolicyCardComponent>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,28 @@ export class PolicyCardComponent implements OnChanges {
this.id = this.policyDefinition?.id;
this.policy = this.policyDefinition?.policy;

this.hasPermissions = false;
this.hasProhibitions = false;
this.hasObligations = false;
this.policyType = undefined;

if (!this.policy) {
return;
}

// Extract the last part of the policy type URL
const types = this.policy!.types();
const types = this.policy.types();
if (types && types.length > 0) {
this.policyType = types[0].split('/').pop(); // Get the last element after the last '/'
}

if (this.policy && this.policy.permissions.length > 0) {
if (this.policy.permissions.length > 0) {
this.hasPermissions = true;
}
if (this.policy && this.policy.prohibitions.length > 0) {
if (this.policy.prohibitions.length > 0) {
this.hasProhibitions = true;
}
if (this.policy && this.policy.obligations.length > 0) {
if (this.policy.obligations.length > 0) {
this.hasObligations = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
></lib-item-count-selector>
<lib-pagination
[items]="filteredPolicies$ | async"
[pageItemCount]="15"
[pageItemCount]="pageItemCount"
(pageItems)="paginationEvent($event)"
class="shadow-xl rounded-2xl bg-base-300 [&_button:hover]:bg-base-100 [&_.join>button]:first:rounded-l-2xl [&_.join>button]:last:rounded-r-2xl"
></lib-pagination>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { PolicyCardComponent } from '../policy-card/policy-card.component';
styleUrl: './policy-view.component.css',
})
export class PolicyViewComponent implements OnInit, OnDestroy {
policyService = inject(PolicyService);
private readonly policyService = inject(PolicyService);
private readonly modalAndAlertService = inject(ModalAndAlertService);
private readonly stateService = inject(DashboardStateService);

Expand All @@ -57,7 +57,7 @@ export class PolicyViewComponent implements OnInit, OnDestroy {
this.fetchPolicies();
}

async openDetails(policy: PolicyDefinition) {
openDetails(policy: PolicyDefinition) {
this.modalAndAlertService.openModal(JsonldViewerComponent, { jsonLdObject: policy });
}

Expand Down Expand Up @@ -87,7 +87,7 @@ export class PolicyViewComponent implements OnInit, OnDestroy {
this.modalAndAlertService.openModal(PolicyCreateComponent, undefined, callbacks);
}

async editPolicy(policyDefinition: PolicyDefinition) {
editPolicy(policyDefinition: PolicyDefinition) {
const callbacks = {
updated: () => {
this.modalAndAlertService.closeModal();
Expand Down Expand Up @@ -124,7 +124,7 @@ export class PolicyViewComponent implements OnInit, OnDestroy {
})
.catch(error => {
console.error(error);
const msg = `Deletion of asset '${policy.id}' failed`;
const msg = `Deletion of policy '${policy.id}' failed`;
this.modalAndAlertService.showAlert(msg, undefined, 'error', 5);
});
},
Expand Down
6 changes: 3 additions & 3 deletions projects/dashboard-core/policies/src/policy.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { EdcClientService } from '@eclipse-edc/dashboard-core';
import { IdResponse, PolicyDefinition, PolicyDefinitionInput } from '@think-it-labs/edc-connector-client';

/**
* Service to manage and retrieve assets.
* Service to manage and retrieve policy definitions.
*/
@Injectable({
providedIn: 'root',
Expand All @@ -26,8 +26,8 @@ export class PolicyService {
private readonly edc = inject(EdcClientService);

/**
* Retrieves all assets from the management API.
* @returns A promise that resolves to an array of assets.
* Retrieves all policy definitions from the management API.
* @returns A promise that resolves to an array of policy definitions.
*/
public async getAllPolicies(): Promise<PolicyDefinition[]> {
return (await this.edc.getClient()).management.policyDefinitions.queryAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ export class PaginationComponent<T> implements OnInit, OnChanges {
}

emitCurrentPageItems() {
if (!this.items) {
return;
}
const start = this.currentPage * this.pageItemCount;
const end = start + this.pageItemCount;
this.pageItems.emit(this.items!.slice(start, end));
this.pageItems.emit(this.items.slice(start, end));
}

forward() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
class="btn btn-lg btn-circle btn-ghost hover:text-primary-content hover:bg-primary border-none"
role="button"
(click)="stateService.toggleMenuOpen()"
[disabled]="((appConfig | async)?.menuItems)!.length < 2"
[disabled]="((appConfig | async)?.menuItems?.length || 0) < 2"
>
@if (stateService.isMenuOpen$ | async) {
<span class="material-symbols-rounded h7 w-7 !text-[1.75rem]">menu_open</span>
Expand Down Expand Up @@ -63,7 +63,7 @@
(edcClientService.isHealthy$ | async)
? 'hover:bg-success/25 hover:text-success'
: 'hover:bg-error/25 hover:text-error',
(stateService.edcConfigs$ | async)!.length > 1 ? '' : 'cursor-default',
((stateService.edcConfigs$ | async)?.length || 0) > 1 ? '' : 'cursor-default',
]"
>
<div class="inline-grid [&_>*]:[grid-area:1/1] mr-6">
Expand Down Expand Up @@ -175,7 +175,7 @@
</div>

<div class="box-border py-4 pl-4 flex flex-auto overflow-auto">
@if (((appConfig | async)?.menuItems)!.length > 1) {
@if (((appConfig | async)?.menuItems?.length || 0) > 1) {
<ul
class="menu flex-nowrap shrink-0 h-full rounded-2xl bg-neutral text-neutral-content shadow-xl [&_li>a]:px-4 overflow-auto"
>
Expand All @@ -202,7 +202,7 @@
<div
id="router-content"
class="px-4 box-border w-full"
[ngClass]="((appConfig | async)?.menuItems)!.length > 1 ? '' : 'pl-0'"
[ngClass]="((appConfig | async)?.menuItems?.length || 0) > 1 ? '' : 'pl-0'"
>
<router-outlet></router-outlet>
</div>
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"paths": {
"@eclipse-edc/dashboard-core": ["./dist/@eclipse-edc/dashboard-core"],
"@eclipse-edc/dashboard-core/*": ["./dist/@eclipse-edc/dashboard-core/*"]
Expand Down