diff --git a/bun.lock b/bun.lock
index 8b844527..a914cc63 100644
--- a/bun.lock
+++ b/bun.lock
@@ -15,10 +15,10 @@
"@angular/platform-browser": "21.2.6",
"@angular/platform-browser-dynamic": "21.2.6",
"@angular/router": "21.2.6",
- "@kompakkt/common": "git+https://github.com/Kompakkt/Common.git#6797ea53a6f976ebc3310db5d434ee20848793bd",
+ "@kompakkt/common": "git+https://github.com/Kompakkt/Common.git#49b7d222f9d6edd719ae7183ba53c96acedd9d0f",
"@kompakkt/komponents": "git+https://github.com/Kompakkt/Komponents#445b8ac",
- "@kompakkt/plugins": "git+https://github.com/Kompakkt/Plugins.git#5e5274042bee8730dc8789de610a09a741e77c60",
- "@kompakkt/server-openapi": "git+https://github.com/Kompakkt/Server.git#b6b5bfcccd4247285eafc77652f0a4b7a43f37ca",
+ "@kompakkt/plugins": "git+https://github.com/Kompakkt/Plugins.git#2c754b80adc41be0c2e1010027a8ce2cd3712ce8",
+ "@kompakkt/server-openapi": "git+https://github.com/Kompakkt/Server.git#d73de702a6b2a94c4824f95e5fef008ac18d572b",
"bson-objectid": "^2.0.4",
"fast-deep-equal": "^3.1.3",
"fscreen": "1.2.0",
@@ -464,13 +464,13 @@
"@jsonjoy.com/util": ["@jsonjoy.com/util@1.9.0", "", { "dependencies": { "@jsonjoy.com/buffers": "^1.0.0", "@jsonjoy.com/codegen": "^1.0.0" }, "peerDependencies": { "tslib": "2" } }, "sha512-pLuQo+VPRnN8hfPqUTLTHk126wuYdXVxE6aDmjSeV4NCAgyxWbiOIeNJVtID3h1Vzpoi9m4jXezf73I6LgabgQ=="],
- "@kompakkt/common": ["@kompakkt/common@github:Kompakkt/Common#6797ea5", { "dependencies": { "elysia": "^1.4.28" } }, "Kompakkt-Common-6797ea5", "sha512-87N1EqrdUWAAk2PVSa6GIPauib8v4SCUU/LBNI6TMqq5yOAsYZ1MoDa4nvpL8yL/yHv5InRd3rqoBSTn/+Jedw=="],
+ "@kompakkt/common": ["@kompakkt/common@github:Kompakkt/Common#49b7d22", { "dependencies": { "elysia": "^1.4.28" } }, "Kompakkt-Common-49b7d22", "sha512-PujVgRn0bLS+yLJZ/+XD3cK3qLe5h5ZWOMOfLfsZuhbRQx/IJqhHquaoJQ/zLRRKmx850mJshg/fwUh13etdhg=="],
"@kompakkt/komponents": ["@kompakkt/komponents@github:Kompakkt/Komponents#445b8ac", { "dependencies": { "@angular/common": "21.2.6", "@angular/core": "21.2.6", "@angular/forms": "21.2.6", "@angular/platform-browser": "21.2.6", "rxjs": "7.8.2", "tslib": "^2.8.1", "zone.js": "0.16.1" } }, "Kompakkt-Komponents-445b8ac", "sha512-CCN6xkjgI3aSu2h9iDVVVa2biFd6FLR/+to0mLfy4SDIGV/5UOulrKfJwQz9pYYIFjXCHhqTVDDYNh8HmB9SSw=="],
- "@kompakkt/plugins": ["@kompakkt/plugins@github:Kompakkt/Plugins#5e52740", { "dependencies": { "@angular/animations": "21.2.6", "@angular/cdk": "21.2.4", "@angular/common": "21.2.6", "@angular/compiler": "21.2.6", "@angular/core": "21.2.6", "@angular/forms": "21.2.6", "@angular/material": "21.2.4", "@angular/platform-browser": "21.2.6", "@angular/platform-browser-dynamic": "21.2.6", "@angular/router": "21.2.6", "@kompakkt/common": "git+https://github.com/Kompakkt/Common.git#6797ea53a6f976ebc3310db5d434ee20848793bd", "@kompakkt/komponents": "git+https://github.com/Kompakkt/Komponents.git#3681d5c7674b6c059a9447356a3a50289ccd689f", "bson": "^7.2.0", "bson-objectid": "^2.0.4", "rxjs": "7.8.2", "slugify": "^1.6.6", "tslib": "^2.3.0", "uuid": "^14.0.0", "zone.js": "0.16.1" } }, "Kompakkt-Plugins-5e52740", "sha512-Uqv/oNwzLzjC1FX9756RHK1Xz2Z8YeqNDb4t5HmcjLLsb/zuvgonKSUw+P93xsmst2cT7pm4IJwpUDVz14vKOQ=="],
+ "@kompakkt/plugins": ["@kompakkt/plugins@github:Kompakkt/Plugins#2c754b8", { "dependencies": { "@angular/animations": "21.2.6", "@angular/cdk": "21.2.4", "@angular/common": "21.2.6", "@angular/compiler": "21.2.6", "@angular/core": "21.2.6", "@angular/forms": "21.2.6", "@angular/material": "21.2.4", "@angular/platform-browser": "21.2.6", "@angular/platform-browser-dynamic": "21.2.6", "@angular/router": "21.2.6", "@kompakkt/common": "git+https://github.com/Kompakkt/Common.git#1ec9e452e73a999d2b5ff725febd95dc0774a19f", "@kompakkt/komponents": "git+https://github.com/Kompakkt/Komponents.git#b3d39c96cb22c682999ca180de2ab584bca03a8d", "bson": "^7.2.0", "bson-objectid": "^2.0.4", "rxjs": "7.8.2", "slugify": "^1.6.6", "tslib": "^2.3.0", "uuid": "^14.0.0", "zone.js": "0.16.1" } }, "Kompakkt-Plugins-2c754b8", "sha512-NnpwvcjiYNdcASv0SBLkiPvortJU7kjwztEJDs9SU+vKCpRADZRqYE7ovKLcSDB7G/ih5PnCpde3yf9vauZc/w=="],
- "@kompakkt/server-openapi": ["@kompakkt/server-openapi@github:Kompakkt/Server#b6b5bfc", {}, "Kompakkt-Server-b6b5bfc", "sha512-lWa+h1/HNlJvtPJeddmEbLcD4pcLhR2mCctITEOnMlvFe/ZS/JV7M+c3uVu6/u+lwng6SfDtcW6WYmD62QeQDQ=="],
+ "@kompakkt/server-openapi": ["@kompakkt/server-openapi@github:Kompakkt/Server#d73de70", {}, "Kompakkt-Server-d73de70", "sha512-vc9s5caCLXi6RTmOilfrLKFIIe2+w/XHd3EeaX8ncRaoJfy/GyvHc7tpYjQqm/epRkw83PQ6RuyPNUub9Kt6sw=="],
"@leichtgewicht/ip-codec": ["@leichtgewicht/ip-codec@2.0.5", "", {}, "sha512-Vo+PSpZG2/fmgmiNzYK9qWRh8h/CHrwD0mo1h1DzL4yzHNSfWYujGTYsWGreD000gcgmZ7K4Ys6Tx9TxtsKdDw=="],
@@ -988,7 +988,7 @@
"browserslist": ["browserslist@4.28.1", "", { "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", "electron-to-chromium": "^1.5.263", "node-releases": "^2.0.27", "update-browserslist-db": "^1.2.0" }, "bin": { "browserslist": "cli.js" } }, "sha512-ZC5Bd0LgJXgwGqUknZY/vkUQ04r8NXnJZ3yYi4vDmSiZmC/pdSN0NbNRPxZpbtO4uAfDUAFffO8IZoM3Gj8IkA=="],
- "bson": ["bson@7.3.1", "", {}, "sha512-h/C0qe6857pQhcSJHLfsR1uYGj98Ge3wKAD3Ed9KqH3wcVh+BM4Jq4xISD7vs9OPuT07n+q3QQVjslJ286j6ag=="],
+ "bson": ["bson@7.3.3", "", {}, "sha512-oz3LwE3qGEhTCSyhzQRLY3Bj1NLOsjFMf6tcmY5J8M+3R7EVcmoBfSHWvjUK3yXCLDUsGpIuB3aQL4nDZ1EV/g=="],
"bson-objectid": ["bson-objectid@2.0.4", "", {}, "sha512-vgnKAUzcDoa+AeyYwXCoHyF2q6u/8H46dxu5JN+4/TZeq/Dlinn0K6GvxsCLb3LHUJl0m/TLiEK31kUwtgocMQ=="],
@@ -1842,7 +1842,7 @@
"utils-merge": ["utils-merge@1.0.1", "", {}, "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA=="],
- "uuid": ["uuid@14.0.1", "", { "bin": { "uuid": "dist-node/bin/uuid" } }, "sha512-6ZxzVpzDXDa3bJWaHilVayA+BH/1zmxCJoVgvmqJnid/gPoKHxUrS/aC/T6LGQtNHT+XHG9fXPJB4d+IrU30Ew=="],
+ "uuid": ["uuid@14.0.3", "", { "bin": { "uuid": "dist-node/bin/uuid" } }, "sha512-Sc5u1VVln93y1Xnz4R+CunOZc7R9LUcTmhj7Rc7Eg3HVcf7rVn2FOoa812fe0W8p3jD7xeoGSYbfqCGGH2B6xw=="],
"v8-compile-cache-lib": ["v8-compile-cache-lib@3.0.1", "", {}, "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg=="],
@@ -1940,7 +1940,9 @@
"@jsonjoy.com/util/@jsonjoy.com/buffers": ["@jsonjoy.com/buffers@1.2.1", "", { "peerDependencies": { "tslib": "2" } }, "sha512-12cdlDwX4RUM3QxmUbVJWqZ/mrK6dFQH4Zxq6+r1YXKXYBNgZXndx2qbCJwh3+WWkCSn67IjnlG3XYTvmvYtgA=="],
- "@kompakkt/plugins/@kompakkt/komponents": ["@kompakkt/komponents@github:Kompakkt/Komponents#3681d5c", { "dependencies": { "@angular/common": "21.2.6", "@angular/core": "21.2.6", "@angular/forms": "21.2.6", "@angular/platform-browser": "21.2.6", "rxjs": "7.8.2", "tslib": "^2.8.1", "zone.js": "0.16.1" } }, "Kompakkt-Komponents-3681d5c", "sha512-805yurwpDREPcbEpqRP2S3SvQiev1H7izk4CDGkpu6lLIXObOinmqEXNgMGfgMZD/LanV07J5/muI9jB+abo9w=="],
+ "@kompakkt/plugins/@kompakkt/common": ["@kompakkt/common@github:Kompakkt/Common#1ec9e45", { "dependencies": { "elysia": "^1.4.28" } }, "Kompakkt-Common-1ec9e45", "sha512-pnXFvIqvl1ru2E5Hhdd049LHLfDrpokPC9L/ogzhdaaohXhekSduwBMLh1iBvgKQ6OOb43bOjxg3ZY8132AlkA=="],
+
+ "@kompakkt/plugins/@kompakkt/komponents": ["@kompakkt/komponents@github:Kompakkt/Komponents#b3d39c9", { "dependencies": { "@angular/common": "21.2.6", "@angular/compiler": "^22.0.6", "@angular/core": "21.2.6", "@angular/platform-browser": "21.2.6", "rxjs": "7.8.2", "tslib": "^2.8.1", "zone.js": "0.16.1" } }, "Kompakkt-Komponents-b3d39c9", "sha512-6AaQMdK/NKpLxZK7uakgckRDKsIt8+5d6u4so56CWnVi2T8VKZDIUiXIPMdgmjVBgxBVdILy8RjIim2qk3e3hg=="],
"@modelcontextprotocol/sdk/express": ["express@5.2.1", "", { "dependencies": { "accepts": "^2.0.0", "body-parser": "^2.2.1", "content-disposition": "^1.0.0", "content-type": "^1.0.5", "cookie": "^0.7.1", "cookie-signature": "^1.2.1", "debug": "^4.4.0", "depd": "^2.0.0", "encodeurl": "^2.0.0", "escape-html": "^1.0.3", "etag": "^1.8.1", "finalhandler": "^2.1.0", "fresh": "^2.0.0", "http-errors": "^2.0.0", "merge-descriptors": "^2.0.0", "mime-types": "^3.0.0", "on-finished": "^2.4.1", "once": "^1.4.0", "parseurl": "^1.3.3", "proxy-addr": "^2.0.7", "qs": "^6.14.0", "range-parser": "^1.2.1", "router": "^2.2.0", "send": "^1.1.0", "serve-static": "^2.2.0", "statuses": "^2.0.1", "type-is": "^2.0.1", "vary": "^1.1.2" } }, "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw=="],
@@ -2084,6 +2086,8 @@
"@jsonjoy.com/fs-snapshot/@jsonjoy.com/util/@jsonjoy.com/codegen": ["@jsonjoy.com/codegen@17.67.0", "", { "peerDependencies": { "tslib": "2" } }, "sha512-idnkUplROpdBOV0HMcwhsCUS5TRUi9poagdGs70A6S4ux9+/aPuKbh8+UYRTLYQHtXvAdNfQWXDqZEx5k4Dj2Q=="],
+ "@kompakkt/plugins/@kompakkt/komponents/@angular/compiler": ["@angular/compiler@22.2.2", "", { "dependencies": { "tslib": "^2.3.0" } }, "sha512-hg8Kvhq29w97vs3O5KsSeqA+oobrAKpr/GvsWBIqjRzfrxxeFdjRRoEv1/MVgMSJK36VLigNCjB1qPF3MB17uA=="],
+
"@modelcontextprotocol/sdk/express/accepts": ["accepts@2.0.0", "", { "dependencies": { "mime-types": "^3.0.0", "negotiator": "^1.0.0" } }, "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng=="],
"@modelcontextprotocol/sdk/express/body-parser": ["body-parser@2.2.2", "", { "dependencies": { "bytes": "^3.1.2", "content-type": "^1.0.5", "debug": "^4.4.3", "http-errors": "^2.0.0", "iconv-lite": "^0.7.0", "on-finished": "^2.4.1", "qs": "^6.14.1", "raw-body": "^3.0.1", "type-is": "^2.0.1" } }, "sha512-oP5VkATKlNwcgvxi0vM0p/D3n2C3EReYVX+DNYs5TjZFn/oQt2j+4sVJtSMr18pdRr8wjTcBl6LoV+FUwzPmNA=="],
diff --git a/package.json b/package.json
index 573ba6da..b6d78357 100644
--- a/package.json
+++ b/package.json
@@ -51,10 +51,10 @@
"@angular/platform-browser": "21.2.6",
"@angular/platform-browser-dynamic": "21.2.6",
"@angular/router": "21.2.6",
- "@kompakkt/common": "git+https://github.com/Kompakkt/Common.git#6797ea53a6f976ebc3310db5d434ee20848793bd",
+ "@kompakkt/common": "git+https://github.com/Kompakkt/Common.git#49b7d222f9d6edd719ae7183ba53c96acedd9d0f",
"@kompakkt/komponents": "git+https://github.com/Kompakkt/Komponents#445b8ac",
- "@kompakkt/plugins": "git+https://github.com/Kompakkt/Plugins.git#5e5274042bee8730dc8789de610a09a741e77c60",
- "@kompakkt/server-openapi": "git+https://github.com/Kompakkt/Server.git#b6b5bfcccd4247285eafc77652f0a4b7a43f37ca",
+ "@kompakkt/plugins": "git+https://github.com/Kompakkt/Plugins.git#2c754b80adc41be0c2e1010027a8ce2cd3712ce8",
+ "@kompakkt/server-openapi": "git+https://github.com/Kompakkt/Server.git#d73de702a6b2a94c4824f95e5fef008ac18d572b",
"bson-objectid": "^2.0.4",
"fast-deep-equal": "^3.1.3",
"fscreen": "1.2.0",
diff --git a/src/app/components/compilation-detail/compilation-detail.component.html b/src/app/components/compilation-detail/compilation-detail.component.html
index 41299cee..f1b6e1b6 100644
--- a/src/app/components/compilation-detail/compilation-detail.component.html
+++ b/src/app/components/compilation-detail/compilation-detail.component.html
@@ -2,12 +2,6 @@
{{ compilation.name }}
{{ compilation.description }}
- @if (compilation.creator) {
-
- {{ 'Created by' | translate }} {{ compilation.creator.fullname }} {{ 'on' | translate }}
- {{ creationDate() }}
-
- }
-
+ @if (account.flags.testingCanManageOrganizations$ | async) {
+
+ }
@if (account.role.isAdmin$ | async) {
diff --git a/src/app/components/navigation/navbar/navbar.component.scss b/src/app/components/navigation/navbar/navbar.component.scss
index b45ae0c8..4d119165 100644
--- a/src/app/components/navigation/navbar/navbar.component.scss
+++ b/src/app/components/navigation/navbar/navbar.component.scss
@@ -109,6 +109,20 @@ img.account-image {
width: 36px;
height: 36px;
}
+
+ &.menu-avatar {
+ width: 24px;
+ height: 24px;
+ flex-shrink: 0;
+ margin-right: var(--mat-menu-item-spacing, 12px);
+ }
+}
+
+.other-profiles-hint {
+ text-align: center;
+ margin: 0 0 8px;
+ color: gray;
+ font-size: 12px;
}
.account-preview {
diff --git a/src/app/components/navigation/navbar/navbar.component.ts b/src/app/components/navigation/navbar/navbar.component.ts
index a8c29acf..49ea3854 100644
--- a/src/app/components/navigation/navbar/navbar.component.ts
+++ b/src/app/components/navigation/navbar/navbar.component.ts
@@ -9,6 +9,7 @@ import { MatProgressBar, MatProgressBarModule } from '@angular/material/progress
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatTooltipModule } from '@angular/material/tooltip';
import { Router, RouterLink, RouterLinkActive } from '@angular/router';
+import { firstValueFrom } from 'rxjs';
import { CustomBrandingPlugin } from '@kompakkt/plugins/custom-branding';
import { IsCompilationPipe } from 'src/app/pipes/is-compilation.pipe';
import { IsEntityPipe } from 'src/app/pipes/is-entity.pipe';
@@ -25,6 +26,7 @@ import {
Collection,
ICompilation,
IEntity,
+ ProfileMemberRole,
ProfileType,
isCompilation,
isEntity,
@@ -73,16 +75,33 @@ export class NavbarComponent implements AfterViewInit {
});
allProfiles = toSignal(this.account.profiles$, { initialValue: [] });
- organizationalProfiles = toSignal(this.account.organizationProfiles$, { initialValue: [] });
currentProfile = toSignal(this.account.currentProfile$, { initialValue: null });
+ otherProfiles = computed(() =>
+ this.allProfiles().filter(profile => profile._id !== this.currentProfile()?._id),
+ );
userProfile = toSignal(this.account.userProfile$, { initialValue: null });
+ user = toSignal(this.account.user$, { initialValue: undefined });
- currentProfileImageUrl = computed(() => {
- const imageUrl = this.currentProfile()?.imageUrl;
- if (!imageUrl) return '/assets/kompakkt-logo-cube.svg';
- return imageUrl.startsWith('data:') ? imageUrl : getServerUrl(`${imageUrl}?t=${Date.now()}`);
+ canCreateInCurrentProfile = computed(() => {
+ const profile = this.currentProfile();
+ if (!profile) return false;
+ const userId = this.user()?._id;
+ if (!userId) return false;
+ if (profile._id === this.userProfile()?._id || profile.ownerId === userId) return true;
+ const membership = profile.members?.find(member => member.userId === userId);
+ return !!membership && membership.role !== ProfileMemberRole.viewer;
});
+ profileImageUrl = (profile: IPublicProfile | null | undefined): string | undefined => {
+ const imageUrl = profile?.imageUrl;
+ if (!imageUrl) return undefined;
+ return imageUrl.startsWith('data:') ? imageUrl : getServerUrl(`${imageUrl}?t=${Date.now()}`);
+ };
+
+ currentProfileImageUrl = computed(
+ () => this.profileImageUrl(this.currentProfile()) ?? '/assets/kompakkt-logo-cube.svg',
+ );
+
constructor(
public account: AccountService,
private progress: ProgressBarService,
@@ -112,9 +131,7 @@ export class NavbarComponent implements AfterViewInit {
#sidenavService = inject(SidenavService);
public async onToggleSidenav() {
- const result = await this.#sidenavService.openWithResult(SidenavListComponent);
- if (!result) return;
- console.log(result);
+ await this.#sidenavService.openWithResult(SidenavListComponent);
}
public openLoginDialog() {
@@ -126,6 +143,15 @@ export class NavbarComponent implements AfterViewInit {
}
public editProfile(profile?: IPublicProfile) {
- this.dialogHelper.editProfile(profile ? profile : { type: ProfileType.organization });
+ const isCreate = !profile;
+ firstValueFrom(
+ this.dialogHelper
+ .editProfile(profile ? profile : { type: ProfileType.organization })
+ .afterClosed(),
+ ).then(createdProfile => {
+ if (!isCreate || !createdProfile) return;
+ this.account.switchToProfile(createdProfile);
+ this.router.navigateByUrl(`/profile/${createdProfile.type}/${createdProfile._id}`);
+ });
}
}
diff --git a/src/app/components/outlined-input/outlined-input.component.scss b/src/app/components/outlined-input/outlined-input.component.scss
index 1a0cf8eb..4bd5a8e7 100644
--- a/src/app/components/outlined-input/outlined-input.component.scss
+++ b/src/app/components/outlined-input/outlined-input.component.scss
@@ -3,11 +3,9 @@
width: 100%;
font-family: var(--font-stack);
display: block;
- padding-top: 32px;
label {
position: absolute;
- top: calc(32px + 0.5em); // padding top + half of font size
left: 12px;
font-size: 14px;
color: #666;
@@ -20,7 +18,7 @@
position: absolute;
right: 0;
bottom: 0;
- height: calc(100% - 32px);
+ height: 100%;
display: flex;
justify-content: center;
align-content: center;
@@ -29,17 +27,6 @@
max-width: 50%;
}
- &:focus-within label,
- label.active {
- top: 8px;
- left: -4px;
- font-size: 12px;
- // color: var(--brand-color);
- // background-color: #f5f5f5;
- border-radius: 4px;
- padding: 0 4px;
- }
-
input,
textarea {
width: 100%;
@@ -65,20 +52,6 @@
}
}
- &.has-label {
- input,
- textarea {
- &::placeholder {
- color: transparent;
- transition: color 200ms ease;
- }
-
- &:focus::placeholder {
- color: #555;
- }
- }
- }
-
textarea {
height: auto;
}
@@ -86,7 +59,7 @@
mat-icon {
position: absolute;
right: 12px;
- top: calc(50% + 16px);
+ top: 50%;
transform: translateY(-50%);
height: 24px;
width: 24px;
@@ -94,4 +67,43 @@
color: #666;
pointer-events: none;
}
+
+ &.has-label {
+ padding-top: 32px;
+
+ label {
+ top: calc(32px + 0.5em);
+ }
+
+ &:focus-within label,
+ label.active {
+ top: 8px;
+ left: -4px;
+ font-size: 12px;
+ // color: var(--brand-color);
+ // background-color: #f5f5f5;
+ border-radius: 4px;
+ padding: 0 4px;
+ }
+
+ div.suffix {
+ height: calc(100% - 32px);
+ }
+
+ mat-icon {
+ top: calc(50% + 16px);
+ }
+
+ input,
+ textarea {
+ &::placeholder {
+ color: transparent;
+ transition: color 200ms ease;
+ }
+
+ &:focus::placeholder {
+ color: #555;
+ }
+ }
+ }
}
diff --git a/src/app/components/uploaded-by/uploaded-by.component.html b/src/app/components/uploaded-by/uploaded-by.component.html
new file mode 100644
index 00000000..166aa25c
--- /dev/null
+++ b/src/app/components/uploaded-by/uploaded-by.component.html
@@ -0,0 +1,20 @@
+@if (profile(); as profile) {
+
+}
diff --git a/src/app/components/uploaded-by/uploaded-by.component.scss b/src/app/components/uploaded-by/uploaded-by.component.scss
new file mode 100644
index 00000000..0ab70913
--- /dev/null
+++ b/src/app/components/uploaded-by/uploaded-by.component.scss
@@ -0,0 +1,64 @@
+@use '@angular/material' as mat;
+@use '../../../theme.scss' as theme;
+
+:host {
+ display: block;
+}
+
+.uploaded-by {
+ background: white;
+
+ .title {
+ font-weight: bold;
+ margin-bottom: 0;
+ }
+
+ .profile-card {
+ margin-top: 1rem;
+ display: flex;
+ align-items: center;
+ gap: 0.5rem;
+ max-width: 100%;
+ cursor: pointer;
+ text-decoration: none;
+ color: inherit;
+
+ .profile-image {
+ flex: 0 0 auto;
+ width: 3rem;
+ height: 3rem;
+ overflow: hidden;
+ border-radius: 50%;
+
+ img {
+ display: block;
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ }
+ }
+
+ .profile-text {
+ min-width: 0;
+ display: flex;
+ flex-direction: column;
+ gap: 0.125rem;
+
+ .profile-name {
+ line-height: 1.2;
+ font-weight: 500;
+ color: mat.m2-get-color-from-palette(theme.$kompakkt-primary, 500);
+ }
+
+ .profile-description {
+ display: -webkit-box;
+ -webkit-line-clamp: 2;
+ -webkit-box-orient: vertical;
+ overflow: hidden;
+ font-size: 0.875rem;
+ line-height: 1.3;
+ color: #6b6b6b;
+ }
+ }
+ }
+}
diff --git a/src/app/components/uploaded-by/uploaded-by.component.ts b/src/app/components/uploaded-by/uploaded-by.component.ts
new file mode 100644
index 00000000..c1a85757
--- /dev/null
+++ b/src/app/components/uploaded-by/uploaded-by.component.ts
@@ -0,0 +1,73 @@
+import { Component, computed, effect, inject, input, signal } from '@angular/core';
+import { RouterLink } from '@angular/router';
+import {
+ isProfileType,
+ isPublicProfile,
+ type CreatorField,
+ type IPublicProfile,
+ type ProfileReference,
+} from '@kompakkt/common';
+import { AnimatedImageDirective } from 'src/app/directives/animated-image.directive';
+import { TranslatePipe } from 'src/app/pipes';
+import { BackendService } from 'src/app/services';
+import { getServerUrl } from 'src/app/util/get-server-url';
+
+@Component({
+ selector: 'app-uploaded-by',
+ templateUrl: './uploaded-by.component.html',
+ styleUrls: ['./uploaded-by.component.scss'],
+ imports: [RouterLink, TranslatePipe, AnimatedImageDirective],
+})
+export class UploadedByComponent {
+ #backend = inject(BackendService);
+ #requestedProfileId: string | undefined = undefined;
+
+ creator = input();
+
+ profile = signal(undefined);
+
+ #profileReference = computed(() => {
+ const profile: unknown = this.creator()?.profile;
+ if (!profile || typeof profile !== 'object') return undefined;
+ const { profileId, type } = profile as Partial;
+ if (typeof profileId !== 'string' || !profileId) return undefined;
+ if (!isProfileType(type)) return undefined;
+ return { profileId, type };
+ });
+
+ name = computed(
+ () => this.profile()?.displayName || this.creator()?.fullname || this.creator()?.username || '',
+ );
+
+ description = computed(() => this.profile()?.description ?? '');
+
+ imageUrl = computed(() => {
+ const imageUrl = this.profile()?.imageUrl;
+ if (!imageUrl) return '/assets/kompakkt-logo-cube.svg';
+ return imageUrl.startsWith('data:') ? imageUrl : getServerUrl(imageUrl);
+ });
+
+ constructor() {
+ effect(() => {
+ const reference = this.#profileReference();
+ if (!reference) {
+ this.#requestedProfileId = undefined;
+ this.profile.set(undefined);
+ return;
+ }
+ if (reference.profileId === this.#requestedProfileId) return;
+ this.#requestedProfileId = reference.profileId;
+ this.profile.set(undefined);
+ this.#backend
+ .getProfileById(reference.profileId)
+ .then(profile => {
+ if (this.#requestedProfileId !== reference.profileId) return;
+ this.profile.set(isPublicProfile(profile) ? profile : undefined);
+ })
+ .catch(() => {
+ if (this.#requestedProfileId !== reference.profileId) return;
+ this.profile.set(undefined);
+ });
+ });
+ }
+}
diff --git a/src/app/dialogs/create-new-entity/create-new-entity.component.ts b/src/app/dialogs/create-new-entity/create-new-entity.component.ts
index 9be04406..bd53cc19 100644
--- a/src/app/dialogs/create-new-entity/create-new-entity.component.ts
+++ b/src/app/dialogs/create-new-entity/create-new-entity.component.ts
@@ -571,7 +571,7 @@ export class CreateNewEntityComponent implements AfterViewInit, OnInit, OnDestro
}
const serverEntity = await this.backend
- .pushEntity(entity)
+ .pushEntity(entity, { profileId: this.#currentProfile()?._id })
.then(res => res)
.catch(err => {
console.error(err);
@@ -905,7 +905,7 @@ export class CreateNewEntityComponent implements AfterViewInit, OnInit, OnDestro
};
const serverEntity = await this.backend
- .pushEntity(entity)
+ .pushEntity(entity, { profileId: this.#currentProfile()?._id })
.then(res => res)
.catch(err => {
console.error(err);
diff --git a/src/app/dialogs/manage-ownership/manage-ownership.component.html b/src/app/dialogs/manage-ownership/manage-ownership.component.html
index 7c4e1a1a..3343e682 100644
--- a/src/app/dialogs/manage-ownership/manage-ownership.component.html
+++ b/src/app/dialogs/manage-ownership/manage-ownership.component.html
@@ -42,7 +42,7 @@
{{
- 'If you transfer the ownership to another user, you lose all ownership rights like deletion and changing the owner.'
+ 'If you transfer the ownership to another profile, you lose all ownership rights like deletion and changing the owner.'
| translate
}}
@@ -55,42 +55,70 @@
- @if (filteredAccounts$ | async; as filteredAccounts) {
+ @if (filteredProfiles$ | async; as filteredProfiles) {
- @for (account of filteredAccounts; track account._id) {
-
- {{ account.fullname }} ({{ account.username }})
+ @for (profile of filteredProfiles; track profile._id) {
+
+ {{ profile.displayName }} ({{ profileTypeLabel(profile) | translate }})
}
} @else {
- {{ 'Fetching accounts' | translate }}...
+ {{ 'Search for a profile' | translate }}...
}
} @else {
{{ 'No data available' | translate }}
}
-@if (targetOwner(); as targetOwner) {
-
-
person_outline
-
-
{{ targetOwner.fullname }}
-
{{ targetOwner.username }}
+@if (targetProfile(); as targetProfile) {
+
}
@@ -98,7 +126,7 @@
{{ 'Cancel' | translate }}
-
+
{{ 'Transfer' | translate }}
diff --git a/src/app/dialogs/manage-ownership/manage-ownership.component.scss b/src/app/dialogs/manage-ownership/manage-ownership.component.scss
index ffb61409..ac033801 100644
--- a/src/app/dialogs/manage-ownership/manage-ownership.component.scss
+++ b/src/app/dialogs/manage-ownership/manage-ownership.component.scss
@@ -5,10 +5,12 @@
flex-direction: column;
align-items: stretch;
gap: 16px;
- max-width: 420px;
+ max-width: 560px;
@include dialog-style();
+ min-width: min(560px, 90vw);
+
h2,
h3,
p {
@@ -72,6 +74,76 @@ div.name {
}
}
+div.profile-card {
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+ border: 1px solid lightgray;
+ border-radius: 4px;
+ padding: 12px;
+
+ div.profile-card-header {
+ display: grid;
+ align-items: center;
+ gap: 12px;
+ grid-template-columns: auto 1fr auto;
+
+ div.profile-avatar {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 40px;
+ height: 40px;
+ border-radius: 50%;
+ overflow: hidden;
+
+ img {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ }
+ }
+
+ div.name-stack {
+ display: flex;
+ flex-direction: column;
+ }
+
+ div.profile-card-actions {
+ display: flex;
+ align-items: center;
+ }
+ }
+
+ div.profile-meta {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ font-size: 14px;
+
+ span.profile-location {
+ display: flex;
+ align-items: center;
+ gap: 4px;
+
+ mat-icon {
+ font-size: 16px;
+ width: 16px;
+ height: 16px;
+ }
+ }
+
+ p.profile-description {
+ margin: 0;
+ opacity: 0.8;
+
+ &.placeholder {
+ font-style: italic;
+ }
+ }
+ }
+}
+
div.owner {
display: flex;
justify-content: flex-start;
diff --git a/src/app/dialogs/manage-ownership/manage-ownership.component.ts b/src/app/dialogs/manage-ownership/manage-ownership.component.ts
index a97ca053..f6817b7d 100644
--- a/src/app/dialogs/manage-ownership/manage-ownership.component.ts
+++ b/src/app/dialogs/manage-ownership/manage-ownership.component.ts
@@ -6,18 +6,44 @@ import {
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
import { AsyncPipe } from '@angular/common';
-import { toSignal } from '@angular/core/rxjs-interop';
+import { toObservable, toSignal } from '@angular/core/rxjs-interop';
import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
+import { RouterLink } from '@angular/router';
import { MatButtonModule } from '@angular/material/button';
import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
import { MatSelectModule } from '@angular/material/select';
import { MatTooltipModule } from '@angular/material/tooltip';
-import { catchError, combineLatestWith, from, map, of, startWith } from 'rxjs';
-import { AccountService, BackendService, DialogHelperService } from 'src/app/services';
-import { Collection, ICompilation, IEntity, isEntity, IStrippedUserData } from '@kompakkt/common';
+import {
+ catchError,
+ combineLatest,
+ debounce,
+ distinctUntilChanged,
+ from,
+ map,
+ of,
+ startWith,
+ switchMap,
+ timer,
+} from 'rxjs';
+import {
+ AccountService,
+ BackendService,
+ DialogHelperService,
+ SnackbarService,
+} from 'src/app/services';
+import {
+ Collection,
+ EntityAccessRole,
+ ICompilation,
+ IEntity,
+ IPublicProfile,
+ ProfileType,
+ isEntity,
+} from '@kompakkt/common';
import { TranslatePipe } from '../../pipes/translate.pipe';
import { OutlinedInputComponent } from 'src/app/components/outlined-input/outlined-input.component';
+import { getServerUrl } from 'src/app/util/get-server-url';
@Component({
selector: 'app-manage-ownership',
@@ -35,6 +61,7 @@ import { OutlinedInputComponent } from 'src/app/components/outlined-input/outlin
TranslatePipe,
OutlinedInputComponent,
AsyncPipe,
+ RouterLink,
],
templateUrl: './manage-ownership.component.html',
styleUrl: './manage-ownership.component.scss',
@@ -43,6 +70,7 @@ export class ManageOwnershipComponent {
#backend = inject(BackendService);
#account = inject(AccountService);
#helper = inject(DialogHelperService);
+ #snackbar = inject(SnackbarService);
#dialogRef = inject(MatDialogRef
);
element: IEntity | IEntity[] | ICompilation | ICompilation[] = inject(MAT_DIALOG_DATA);
data = computed(() => {
@@ -63,52 +91,103 @@ export class ManageOwnershipComponent {
searchControl = new FormControl('', { nonNullable: true });
- targetOwner = signal(undefined);
currentOwner = toSignal(this.#account.strippedUser$);
+ #ownProfiles = toSignal(this.#account.profiles$, { initialValue: [] as IPublicProfile[] });
+ #ownProfiles$ = toObservable(this.#ownProfiles);
- allAccounts$ = from(this.#backend.getAccounts()).pipe(
- catchError(err => {
- console.error('Failed fetching accounts', err);
- return of([]);
- }),
- map(accounts =>
- accounts.map(account => ({
- ...account,
- searchText: [account.fullname, account.username].join('').toLowerCase(),
- })),
- ),
- );
- filteredAccounts$ = this.allAccounts$.pipe(
- combineLatestWith(
- this.searchControl.valueChanges.pipe(
- startWith(''),
- map(value => (typeof value === 'string' ? value.toLowerCase().trim() : '')),
- ),
- this.#account.strippedUser$,
- ),
- map(([accounts, search, user]) =>
- search.length >= 1
- ? accounts.filter(
- account => account._id !== user?._id && account.searchText.includes(search),
- )
- : [],
+ targetProfile = signal(undefined);
+ targetUserId = signal(undefined);
+
+ #ownerProfileIds = computed(() => {
+ const ids = new Set();
+ for (const doc of this.data()) {
+ const profileId = this.#ownerProfileId(doc);
+ if (profileId) ids.add(profileId);
+ }
+ return ids;
+ });
+ #ownerProfileIds$ = toObservable(this.#ownerProfileIds);
+
+ #ownerProfileId(doc: IEntity | ICompilation): string | undefined {
+ const userId = this.currentOwner()?._id;
+ const ownEntry = doc.access?.find(
+ entry => entry._id === userId && entry.role === EntityAccessRole.owner,
+ );
+ return ownEntry?.profile?.profileId ?? doc.creator?.profile?.profileId;
+ }
+
+ filteredProfiles$ = combineLatest([
+ this.searchControl.valueChanges.pipe(
+ startWith(''),
+ debounce(value => (typeof value === 'string' && value.trim() ? timer(300) : of(0))),
+ distinctUntilChanged(),
+ switchMap(value => {
+ const query = typeof value === 'string' ? value.trim() : '';
+ if (!query) return of({ query, results: [] as IPublicProfile[] });
+ return from(this.#backend.searchProfiles(query, 'all')).pipe(
+ map(results => ({ query, results })),
+ catchError(err => {
+ console.error('Failed searching profiles', err);
+ return of({ query, results: [] as IPublicProfile[] });
+ }),
+ );
+ }),
),
+ this.#ownProfiles$,
+ this.#ownerProfileIds$,
+ ]).pipe(
+ map(([{ query, results }, ownProfiles, ownerProfileIds]) => {
+ const normalizedQuery = query.toLowerCase();
+ const isSelectable = (profile: IPublicProfile) => !ownerProfileIds.has(profile._id);
+ const otherProfiles = ownProfiles.filter(
+ profile =>
+ isSelectable(profile) &&
+ (!normalizedQuery || (profile.displayName ?? '').toLowerCase().includes(normalizedQuery)),
+ );
+ const leadingIds = new Set(otherProfiles.map(profile => profile._id));
+ return [
+ ...otherProfiles,
+ ...results.filter(profile => !leadingIds.has(profile._id) && isSelectable(profile)),
+ ];
+ }),
);
- public async userSelected(event: MatAutocompleteSelectedEvent) {
- const newOwner = event.option.value;
- this.targetOwner.set(newOwner);
+ public async profileSelected(event: MatAutocompleteSelectedEvent) {
+ const profile = event.option.value as IPublicProfile;
+ this.targetProfile.set(profile);
+ this.targetUserId.set(await this.#resolveTargetUserId(profile));
+ }
+
+ public profileImageUrl(profile: IPublicProfile): string {
+ const imageUrl = profile.imageUrl;
+ if (!imageUrl) return '/assets/kompakkt-logo-cube.svg';
+ return imageUrl.startsWith('data:') ? imageUrl : getServerUrl(imageUrl);
+ }
+
+ public profileTypeLabel(profile: IPublicProfile): string {
+ return profile.type === ProfileType.organization ? 'Organization' : 'User profile';
+ }
+
+ async #resolveTargetUserId(profile: IPublicProfile): Promise {
+ if (profile.type === ProfileType.organization && profile.ownerId) return profile.ownerId;
+ const user = await this.#backend.getUserOfProfile(profile._id).catch(err => {
+ console.error('Failed resolving user for profile', err);
+ return undefined;
+ });
+ return user?._id;
}
- public async removeUser() {
- this.targetOwner.set(undefined);
+ public removeTarget() {
+ this.targetProfile.set(undefined);
+ this.targetUserId.set(undefined);
}
- public async transferUser() {
+ public async transferOwnership() {
const data = this.data();
- const targetOwner = this.targetOwner();
+ const targetProfile = this.targetProfile();
+ const targetUserId = this.targetUserId();
- if (!targetOwner) return;
+ if (!targetProfile || !targetUserId) return;
const loginData = await this.#helper.verifyAuthentication(
'Validate login before transferring ownership',
@@ -119,7 +198,9 @@ export class ManageOwnershipComponent {
const savePromises = data.map(doc =>
this.#backend.transferOwnerShip({
docId: doc._id,
- targetUserId: targetOwner._id,
+ targetUserId,
+ profileId: targetProfile._id,
+ actingProfileId: this.#ownerProfileId(doc),
collection: isEntity(doc) ? Collection.entity : Collection.compilation,
}),
);
@@ -127,7 +208,8 @@ export class ManageOwnershipComponent {
this.#dialogRef.close(data);
} catch (error) {
- console.error('Owner could not be transfered: ', error);
+ console.error('Owner could not be transferred: ', error);
+ this.#snackbar.showMessage('Ownership could not be transferred');
}
}
diff --git a/src/app/dialogs/profile-page-edit/profile-page-edit.component.html b/src/app/dialogs/profile-page-edit/profile-page-edit.component.html
index a8929243..999defd2 100644
--- a/src/app/dialogs/profile-page-edit/profile-page-edit.component.html
+++ b/src/app/dialogs/profile-page-edit/profile-page-edit.component.html
@@ -27,7 +27,7 @@
{{ 'Name' | translate }}*
} @else {
@@ -57,6 +57,83 @@
placeholder="Add a short description"
/>
+
+ @if (isOrganization()) {
+
+
+
+ }
diff --git a/src/app/dialogs/profile-page-edit/profile-page-edit.component.scss b/src/app/dialogs/profile-page-edit/profile-page-edit.component.scss
index 8d588240..51bf488a 100644
--- a/src/app/dialogs/profile-page-edit/profile-page-edit.component.scss
+++ b/src/app/dialogs/profile-page-edit/profile-page-edit.component.scss
@@ -73,15 +73,15 @@ textarea[matInput] {
.form-row-textarea {
align-items: flex-start;
-}
-.form-row-textarea label {
- margin-top: 8px;
-}
+ label {
+ margin-top: 8px;
+ }
-.form-row-textarea textarea[matInput] {
- min-height: 96px;
- resize: vertical;
+ textarea[matInput] {
+ min-height: 96px;
+ resize: vertical;
+ }
}
.form-actions {
@@ -90,3 +90,48 @@ textarea[matInput] {
gap: 8px;
margin-top: 24px;
}
+
+.members-row {
+ align-items: flex-start;
+
+ .members-col {
+ flex: 1 1 0%;
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+ min-width: 0;
+
+ .member-list {
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+
+ .person {
+ display: grid;
+ grid-template-columns: auto 3fr 2fr 1fr;
+ gap: 8px;
+ align-items: center;
+
+ > mat-icon {
+ margin-right: 8px;
+ }
+
+ > span {
+ line-height: 1;
+ }
+ }
+ }
+
+ .mat-mdc-select {
+ font-size: 16px;
+ border: solid 1px #d9d9d9;
+ padding: 8px 12px;
+ box-sizing: border-box;
+ border-radius: 4px;
+ }
+
+ .text-warning {
+ color: #b00020;
+ }
+ }
+}
diff --git a/src/app/dialogs/profile-page-edit/profile-page-edit.component.ts b/src/app/dialogs/profile-page-edit/profile-page-edit.component.ts
index a677ac1c..cc397b53 100644
--- a/src/app/dialogs/profile-page-edit/profile-page-edit.component.ts
+++ b/src/app/dialogs/profile-page-edit/profile-page-edit.component.ts
@@ -1,18 +1,39 @@
+import { AsyncPipe } from '@angular/common';
import { Component, computed, inject, signal } from '@angular/core';
import { toSignal } from '@angular/core/rxjs-interop';
-import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms';
+import { FormBuilder, FormControl, ReactiveFormsModule, Validators } from '@angular/forms';
+import {
+ MatAutocompleteModule,
+ MatAutocompleteSelectedEvent,
+} from '@angular/material/autocomplete';
import { MatButtonModule } from '@angular/material/button';
+import { MatOptionModule } from '@angular/material/core';
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
+import { MatDividerModule } from '@angular/material/divider';
import { MatFormFieldModule } from '@angular/material/form-field';
+import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
-import { startWith } from 'rxjs';
+import { MatSelectModule } from '@angular/material/select';
+import { catchError, combineLatestWith, from, map, of, startWith } from 'rxjs';
import { OutlinedInputComponent } from 'src/app/components/outlined-input/outlined-input.component';
import { AnimatedImageDirective } from 'src/app/directives/animated-image.directive';
import { TranslatePipe } from 'src/app/pipes';
import { AccountService } from 'src/app/services';
import { BackendService } from 'src/app/services/backend.service';
import { getServerUrl } from 'src/app/util/get-server-url';
-import { IPublicProfile, ProfileType } from '@kompakkt/common';
+import {
+ IPublicProfile,
+ IStrippedUserData,
+ ProfileMemberRole,
+ ProfileType,
+} from '@kompakkt/common';
+
+type MemberRow = {
+ userId: string;
+ fullname?: string;
+ username?: string;
+ role: string;
+};
@Component({
selector: 'app-profile-page-edit',
@@ -23,6 +44,12 @@ import { IPublicProfile, ProfileType } from '@kompakkt/common';
MatFormFieldModule,
MatInputModule,
MatButtonModule,
+ MatAutocompleteModule,
+ MatOptionModule,
+ MatSelectModule,
+ MatIconModule,
+ MatDividerModule,
+ AsyncPipe,
TranslatePipe,
AnimatedImageDirective,
OutlinedInputComponent,
@@ -58,6 +85,133 @@ export class ProfilePageEditComponent {
return imageUrl.startsWith('data:') ? imageUrl : getServerUrl(imageUrl);
});
+ profileId = this.data?._id;
+
+ members = signal([]);
+ membersLoadFailed = signal(false);
+
+ #currentUser = toSignal(this.#account.user$, { initialValue: undefined });
+
+ canManageMembers = computed(() => {
+ const userId = this.#currentUser()?._id;
+ if (!userId) return false;
+ if (this.data?.ownerId === userId) return true;
+ return this.members().find(member => member.userId === userId)?.role === ProfileMemberRole.owner;
+ });
+
+ roleOptions = [
+ { value: ProfileMemberRole.editor, label: 'Member' },
+ ] as const;
+
+ searchControl = new FormControl('', { nonNullable: true });
+
+ #memberIds = computed(() => new Set(this.members().map(member => member.userId)));
+
+ allAccounts$ = from(this.backend.getAccounts()).pipe(
+ catchError(error => {
+ console.error('Failed fetching accounts', error);
+ return of([]);
+ }),
+ );
+
+ filteredAccounts$ = this.allAccounts$.pipe(
+ combineLatestWith(
+ this.searchControl.valueChanges.pipe(
+ startWith(''),
+ map(value => value.toLowerCase().trim()),
+ ),
+ ),
+ map(([accounts, search]) =>
+ search.length >= 1
+ ? accounts.filter(
+ account =>
+ !this.#memberIds().has(account._id) &&
+ Object.values(account).join('').toLowerCase().includes(search),
+ )
+ : [],
+ ),
+ );
+
+ isBootstrapOwner = (userId: string): boolean => this.data?.ownerId === userId;
+
+ constructor() {
+ if (this.isOrganization()) {
+ void this.#refreshMembers();
+ }
+ }
+
+ async #refreshMembers() {
+ if (!this.profileId) return;
+ try {
+ const [result, accounts] = await Promise.all([
+ this.backend.getOrganizationMembers(this.profileId),
+ this.backend.getAccounts().catch(() => [] as IStrippedUserData[]),
+ ]);
+ const accountById = new Map(accounts.map(account => [account._id, account] as const));
+ const owner = result.owner;
+ const rows: MemberRow[] = [
+ {
+ userId: owner._id,
+ fullname: owner.fullname,
+ username: owner.username,
+ role: ProfileMemberRole.owner,
+ },
+ ...(result.members ?? [])
+ .filter(member => member.userId !== owner._id)
+ .map(member => ({
+ userId: member.userId,
+ fullname: accountById.get(member.userId)?.fullname,
+ username: accountById.get(member.userId)?.username,
+ role: member.role,
+ })),
+ ];
+ this.members.set(rows);
+ this.membersLoadFailed.set(false);
+ } catch (error) {
+ console.error('Failed loading organization members', error);
+ this.membersLoadFailed.set(true);
+ }
+ }
+
+ public userSelected(event: MatAutocompleteSelectedEvent) {
+ const account = event.option.value as IStrippedUserData;
+ this.searchControl.setValue('');
+ void this.#addMember(account);
+ }
+
+ async #addMember(account: IStrippedUserData) {
+ if (!this.profileId) return;
+ try {
+ await this.backend.addOrganizationMember(this.profileId, {
+ userId: account._id,
+ role: ProfileMemberRole.editor,
+ });
+ await this.#refreshMembers();
+ } catch (error) {
+ console.error('Failed adding member', error);
+ }
+ }
+
+ public async updateMemberRole(role: ProfileMemberRole, member: MemberRow) {
+ if (!this.profileId) return;
+ try {
+ await this.backend.updateOrganizationMemberRole(this.profileId, member.userId, { role });
+ await this.#refreshMembers();
+ } catch (error) {
+ console.error('Failed updating member role', error);
+ }
+ }
+
+ public async removeMember(member: MemberRow) {
+ if (!this.profileId) return;
+ try {
+ await this.backend.removeOrganizationMember(this.profileId, member.userId);
+ await this.#refreshMembers();
+ } catch (error) {
+ console.error('Failed removing member', error);
+ }
+ }
+
async save() {
if (this.form.valid) {
const formValue = this.form.value;
diff --git a/src/app/pages/explore/explore.component.html b/src/app/pages/explore/explore.component.html
index 7145badc..6eac4505 100644
--- a/src/app/pages/explore/explore.component.html
+++ b/src/app/pages/explore/explore.component.html
@@ -127,6 +127,31 @@ {{ 'Explore' | translate }}
+ @if (selectedTab() === 'institutions') {
+ @for (profile of profileResults(); track profile._id) {
+
+ @if (profile.imageUrl; as profileImage) {
+
+ } @else {
+ apartment
+ }
+ {{ profile.displayName }}
+ @if (profile.description; as description) {
+ {{ description }}
+ }
+
+ } @empty {
+
+
{{ 'No results found' | translate }}
+
+ }
+ } @else {
@for (element of filteredResults; track element._id) {
{{ 'Explore' | translate }}
}
}
+ }
diff --git a/src/app/pages/explore/explore.component.scss b/src/app/pages/explore/explore.component.scss
index 1305fbe0..92477386 100644
--- a/src/app/pages/explore/explore.component.scss
+++ b/src/app/pages/explore/explore.component.scss
@@ -142,8 +142,46 @@ div.loading-overlay {
.pseudo-disabled {
color: rgba(0, 0, 0, 0.38);
+
+ mat-icon {
+ opacity: 0.38;
+ }
}
-.pseudo-disabled mat-icon {
- opacity: 0.38;
+.institution-card {
+ display: flex;
+ flex-direction: column;
+ gap: 0.5rem;
+ padding: 1rem;
+ border: 1px solid var(--border-color, #ddd);
+ border-radius: 8px;
+ text-decoration: none;
+ color: inherit;
+
+ img {
+ width: 100%;
+ aspect-ratio: 1;
+ object-fit: cover;
+ border-radius: 8px;
+ }
+
+ mat-icon {
+ width: 100%;
+ height: auto;
+ font-size: 4rem;
+ text-align: center;
+ }
+
+ .institution-name {
+ font-weight: 600;
+ }
+
+ .institution-description {
+ font-size: 0.85rem;
+ opacity: 0.75;
+ display: -webkit-box;
+ -webkit-line-clamp: 3;
+ -webkit-box-orient: vertical;
+ overflow: hidden;
+ }
}
diff --git a/src/app/pages/explore/explore.component.ts b/src/app/pages/explore/explore.component.ts
index 80fe3881..35ea52eb 100644
--- a/src/app/pages/explore/explore.component.ts
+++ b/src/app/pages/explore/explore.component.ts
@@ -43,7 +43,7 @@ import {
SnackbarService,
} from 'src/app/services';
import { SidenavService } from 'src/app/services/sidenav.service';
-import { ICompilation, IEntity, isCompilation, isEntity } from '@kompakkt/common';
+import { ICompilation, IEntity, IPublicProfile, isCompilation, isEntity } from '@kompakkt/common';
import { GridElementComponent } from '../../components/grid-element/grid-element.component';
import { ExploreFilterOption } from './explore-filter-option/explore-filter-option.component';
import { ExploreFilterSidenavToggleComponent } from './explore-filter-sidenav-toggle/explore-filter-sidenav-toggle.component';
@@ -66,6 +66,7 @@ import { MatCheckboxModule } from '@angular/material/checkbox';
import { IsEntityPipe } from 'src/app/pipes/is-entity.pipe';
import { ExploreRequestBody } from 'src/app/services/types/backend-types';
import { scrollToMainContent } from 'src/app/util/scroll-to-main-content';
+import { getServerUrl } from 'src/app/util/get-server-url';
type Pagination = {
pageCount: number;
@@ -74,6 +75,15 @@ type Pagination = {
totalItemCount: number;
};
+const EXPLORE_TABS = [
+ { label: 'Objects', value: 'objects' },
+ { label: 'Collections', value: 'collections' },
+ // Hidden until the Organizations designs are finished; uncomment to re-enable.
+ // { label: 'Organizations', value: 'institutions' },
+] as const satisfies Array<{ label: string; value: ExploreCategory }>;
+
+const DEFAULT_EXPLORE_TAB: ExploreCategory = 'objects';
+
@Component({
selector: 'app-explore-entities',
templateUrl: './explore.component.html',
@@ -139,6 +149,8 @@ export class ExploreComponent implements OnInit {
public searchTextSuggestions = signal([]);
public popularSearches = signal([]);
public filteredResults: Array = [];
+ public profileResults = signal([]);
+ public getServerUrl = getServerUrl;
public paginator = signal(
(() => {
@@ -157,12 +169,7 @@ export class ExploreComponent implements OnInit {
// For quick-adding to compilation
public selectObjectId = '';
- public availableTabs = [
- { label: 'Objects', value: 'objects' },
- { label: 'Collections', value: 'collections' },
- // TODO: Enable institutions once public profiles are ready
- // { label: 'Institutions', value: 'institutions' },
- ] as const satisfies Array<{ label: string; value: ExploreCategory }>;
+ public availableTabs = EXPLORE_TABS;
public updateSelectedTab(tab: string) {
if (isExploreCategory(tab)) {
@@ -172,8 +179,8 @@ export class ExploreComponent implements OnInit {
}
public selectedTab = signal(
(() => {
- const category = this.#searchParams().get('category') as ExploreCategory | null;
- return category ?? 'objects';
+ const category = this.#searchParams().get('category');
+ return EXPLORE_TABS.find(tab => tab.value === category)?.value ?? DEFAULT_EXPLORE_TAB;
})(),
);
@@ -354,6 +361,12 @@ export class ExploreComponent implements OnInit {
}
public updateFilter() {
+ if (this.selectedTab() === 'institutions') {
+ this.updateProfileResults();
+ return;
+ }
+ this.profileResults.set([]);
+
const filters = this.selectedFilterOptions();
const sortBy = (filters.find(o => o.category === 'sortBy')?.value ??
SortByOptions.find(o => o.default)?.value ??
@@ -425,6 +438,16 @@ export class ExploreComponent implements OnInit {
.finally(() => this.isWaitingForExploreResult.set(false));
}
+ public updateProfileResults() {
+ this.isWaitingForExploreResult.set(true);
+ this.filteredResults = [];
+ this.backend
+ .searchProfiles(this.searchText().trim())
+ .then(profiles => this.profileResults.set(profiles ?? []))
+ .catch(e => console.error(e))
+ .finally(() => this.isWaitingForExploreResult.set(false));
+ }
+
canNavigatePrevious = computed(() => {
const { pageIndex } = this.paginator();
return pageIndex > 0;
diff --git a/src/app/pages/profile-page/profile-page-header/profile-page-header.component.html b/src/app/pages/profile-page/profile-page-header/profile-page-header.component.html
index 06708c38..76c07f67 100644
--- a/src/app/pages/profile-page/profile-page-header/profile-page-header.component.html
+++ b/src/app/pages/profile-page/profile-page-header/profile-page-header.component.html
@@ -11,10 +11,12 @@
@if (profileData()?.location; as location) {
diff --git a/src/app/pages/profile-page/profile-page-header/profile-page-header.component.ts b/src/app/pages/profile-page/profile-page-header/profile-page-header.component.ts
index bbfe977b..cfd70085 100644
--- a/src/app/pages/profile-page/profile-page-header/profile-page-header.component.ts
+++ b/src/app/pages/profile-page/profile-page-header/profile-page-header.component.ts
@@ -4,7 +4,7 @@ import { MatIconModule } from '@angular/material/icon';
import { MatTooltipModule } from '@angular/material/tooltip';
import { AnimatedImageDirective } from 'src/app/directives/animated-image.directive';
import { getServerUrl } from 'src/app/util/get-server-url';
-import { IPublicProfile, IUserDataWithoutData, IUserData } from '@kompakkt/common';
+import { IPublicProfile, ProfileType, IUserDataWithoutData, IUserData } from '@kompakkt/common';
import { TranslatePipe } from '../../../pipes/translate.pipe';
@Component({
@@ -22,6 +22,7 @@ import { TranslatePipe } from '../../../pipes/translate.pipe';
})
export class ProfilePageHeaderComponent {
profileData = input();
+ isOwnProfile = input(true);
editProfile = output();
availableName = computed(() => {
@@ -32,4 +33,5 @@ export class ProfilePageHeaderComponent {
if (!imageUrl) return '/assets/kompakkt-logo-cube.svg';
return imageUrl.startsWith('data:') ? imageUrl : getServerUrl(`${imageUrl}?t=${Date.now()}`);
});
+ isOrganization = computed(() => this.profileData()?.type === ProfileType.organization);
}
diff --git a/src/app/pages/profile-page/profile-page.component.html b/src/app/pages/profile-page/profile-page.component.html
index 77879059..e5f7f656 100644
--- a/src/app/pages/profile-page/profile-page.component.html
+++ b/src/app/pages/profile-page/profile-page.component.html
@@ -1,8 +1,22 @@
-@if (currentProfile(); as profileData) {
+@if (isForeignProfileView()) {
-
+ @if (viewedProfile(); as viewedProfileData) {
+
+ } @else {
+
+
{{ 'Loading profile data' | translate }}...
+
+
+ }
+
+} @else if (currentProfile(); as profileData) {
+
+ @if (isOwnProfile(profileData)) {
+
- @if (userProfile()?._id === profileData._id) {
+ } @else if (viewedProfile(); as viewedProfileData) {
+
} @else {
-
- {{
- 'Organizational profile features are coming soon. Please check back later!' | translate
- }}
-
+
}
} @else {
diff --git a/src/app/pages/profile-page/profile-page.component.ts b/src/app/pages/profile-page/profile-page.component.ts
index 56b6b77b..5643ba87 100644
--- a/src/app/pages/profile-page/profile-page.component.ts
+++ b/src/app/pages/profile-page/profile-page.component.ts
@@ -16,10 +16,17 @@ import { debounceTime, map } from 'rxjs';
import { SearchBarComponent } from 'src/app/components/search-bar/search-bar.component';
import { Tab, TabsComponent } from 'src/app/components/tabs/tabs.component';
import { TranslatePipe } from 'src/app/pipes';
-import { AccountService, DialogHelperService, SnackbarService } from 'src/app/services';
+import {
+ AccountService,
+ BackendService,
+ DialogHelperService,
+ SnackbarService,
+} from 'src/app/services';
+import { isPublicProfile, type IPublicProfile } from '@kompakkt/common';
import { ProfileCompilationsComponent } from './compilations/compilations.component';
import { ProfileEntitiesComponent } from './entities/entities.component';
import { ProfilePageHeaderComponent } from './profile-page-header/profile-page-header.component';
+import { ProfilePublicViewComponent } from './public-view/profile-public-view.component';
import { ProfilePageHelpComponent } from './profile-page-help.component';
import { MatIconModule } from '@angular/material/icon';
import { SelectionTab } from 'src/app/components/selection/selection-tab/selection-tab.component';
@@ -60,6 +67,7 @@ import {
ProfileEntitiesComponent,
ProfileCompilationsComponent,
ProfilePageHeaderComponent,
+ ProfilePublicViewComponent,
TabsComponent,
SearchBarComponent,
SelectionTab,
@@ -96,25 +104,56 @@ export class ProfilePageComponent implements OnInit {
constructor() {
effect(() => {
- console.log('ProfilePageComponent: params changed to', this.#routeParams());
+ const params = this.#routeParams();
+ if (!params.id || params.id === this.currentProfile()?._id) {
+ this.viewedProfile.set(undefined);
+ return;
+ }
+ this.#backend
+ .getProfileById(params.id)
+ .then(profile => {
+ this.viewedProfile.set(isPublicProfile(profile) ? profile : undefined);
+ })
+ .catch(() => this.viewedProfile.set(undefined));
});
let isInitialChange = true;
effect(() => {
const updatedOptions = this.#sidenavOptionsService.selectedOptions();
- console.log('Sidenav options updated in background:', updatedOptions, isInitialChange);
if (isInitialChange) {
isInitialChange = false;
return;
}
this.selectedFilterOptions.set(updatedOptions);
});
+
+ effect(() => {
+ const name = this.displayedProfile()?.displayName;
+ this.#titleService.setTitle(name ? `Kompakkt – ${name}` : 'Kompakkt – Profile');
+ });
}
userData = toSignal(this.#account.user$);
userProfile = toSignal(this.#account.userProfile$, { initialValue: undefined });
currentProfile = toSignal(this.#account.currentProfile$, { initialValue: undefined });
+ viewedProfile = signal(undefined);
+
+ isForeignProfileView = computed(() => {
+ const params = this.#routeParams();
+ if (!params.id) return false;
+ return params.id !== this.currentProfile()?._id;
+ });
+
+ displayedProfile = computed(() => {
+ const params = this.#routeParams();
+ const currentProfile = this.currentProfile();
+ if (!params.id || params.id === currentProfile?._id) return currentProfile;
+ return this.viewedProfile();
+ });
+
+ #backend = inject(BackendService);
+
availableTabs = [
{ label: 'Objects', value: 'objects' },
{ label: 'Drafts', value: 'drafts' },
@@ -138,8 +177,12 @@ export class ProfilePageComponent implements OnInit {
this.#dialog.open(ProfilePageHelpComponent);
}
- public openEditDialog() {
- this.#helper.editProfile(this.userProfile());
+ public openEditDialog(profile?: IPublicProfile) {
+ this.#helper.editProfile(profile ?? this.userProfile());
+ }
+
+ public isOwnProfile(profile: IPublicProfile): boolean {
+ return profile._id === this.currentProfile()?._id;
}
public onChangeTab(value) {
@@ -194,14 +237,11 @@ export class ProfilePageComponent implements OnInit {
}
ngOnInit() {
- this.#titleService.setTitle('Kompakkt – Profile');
-
this.#account.user$.pipe(debounceTime(5000)).subscribe(userdata => {
- if (!userdata) {
- // User is not logged in and not authenticated
- this.#snackbar.showMessage('You are not logged in or your session expired.');
- this.#router.navigate(['/']);
- }
+ if (userdata) return;
+ if (this.#routeParams().id) return;
+ this.#snackbar.showMessage('You are not logged in or your session expired.');
+ this.#router.navigate(['/']).catch(() => {});
});
}
}
diff --git a/src/app/pages/profile-page/public-view/profile-public-view.component.html b/src/app/pages/profile-page/public-view/profile-public-view.component.html
new file mode 100644
index 00000000..c821fbe4
--- /dev/null
+++ b/src/app/pages/profile-page/public-view/profile-public-view.component.html
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+
+ 0
+ ? ('You have activated filters, modifying the search results' | translate)
+ : ''
+ "
+ (click)="openFilterSidenav()"
+ />
+
+ @switch (tabs.selectedTab()?.value) {
+ @case ('objects') {
+
+ @for (entity of filteredEntities(); track entity._id) {
+
+ } @empty {
+
{{ 'No published objects yet' | translate }}
+ }
+
+ }
+ @case ('collections') {
+
+ @for (compilation of filteredCompilations(); track compilation._id) {
+
+ } @empty {
+
{{ 'No published collections yet' | translate }}
+ }
+
+ }
+ }
+
+
diff --git a/src/app/pages/profile-page/public-view/profile-public-view.component.scss b/src/app/pages/profile-page/public-view/profile-public-view.component.scss
new file mode 100644
index 00000000..720bc1df
--- /dev/null
+++ b/src/app/pages/profile-page/public-view/profile-public-view.component.scss
@@ -0,0 +1,11 @@
+.public-profile-view {
+ display: flex;
+ flex-direction: column;
+ gap: 1.5rem;
+ padding: 0 1rem 2rem;
+
+ .center-page-text {
+ text-align: center;
+ opacity: 0.7;
+ }
+}
diff --git a/src/app/pages/profile-page/public-view/profile-public-view.component.ts b/src/app/pages/profile-page/public-view/profile-public-view.component.ts
new file mode 100644
index 00000000..f355bbe6
--- /dev/null
+++ b/src/app/pages/profile-page/public-view/profile-public-view.component.ts
@@ -0,0 +1,239 @@
+import { Component, computed, effect, inject, input, signal } from '@angular/core';
+import { toSignal } from '@angular/core/rxjs-interop';
+import { MatIconModule } from '@angular/material/icon';
+import { MatTooltipModule } from '@angular/material/tooltip';
+import { type ICompilation, type IEntity, type IPublicProfile } from '@kompakkt/common';
+import { GridElementComponent } from 'src/app/components';
+import { SearchBarComponent } from 'src/app/components/search-bar/search-bar.component';
+import { Tab, TabsComponent } from 'src/app/components/tabs/tabs.component';
+import { TranslatePipe } from 'src/app/pipes';
+import { AccountService, BackendService, DialogHelperService } from 'src/app/services';
+import { SidenavService } from 'src/app/services/sidenav.service';
+import { ExploreFilterOption } from '../../explore/explore-filter-option/explore-filter-option.component';
+import { ExploreFilterSidenavToggleComponent } from '../../explore/explore-filter-sidenav-toggle/explore-filter-sidenav-toggle.component';
+import {
+ ExploreFilterSidenavComponent,
+ ExploreFilterSidenavData,
+ ExploreFilterSidenavOptionsService,
+} from '../../explore/explore-filter-sidenav/explore-filter-sidenav.component';
+import {
+ AnnotationOptions,
+ ExploreCategory,
+ LicenceOptions,
+ MediaTypeOptions,
+ MiscOptions,
+ reduceExploreFilterOptions,
+ SortByOptions,
+ SortOrder,
+} from '../../explore/shared-types';
+import { ProfilePageHeaderComponent } from '../profile-page-header/profile-page-header.component';
+
+type FilterableProfileItem = {
+ name: string;
+ __normalizedName?: string;
+ __hits?: number;
+ __createdAt?: number;
+ __annotationCount?: number;
+ __licenses?: string[];
+ __mediaTypes?: string[];
+ __downloadable?: boolean;
+ annotations?: Record;
+ mediaType?: string;
+};
+
+@Component({
+ selector: 'app-profile-public-view',
+ templateUrl: './profile-public-view.component.html',
+ styleUrls: ['./profile-public-view.component.scss'],
+ standalone: true,
+ imports: [
+ MatIconModule,
+ MatTooltipModule,
+ TranslatePipe,
+ GridElementComponent,
+ ProfilePageHeaderComponent,
+ SearchBarComponent,
+ TabsComponent,
+ ExploreFilterSidenavToggleComponent,
+ ],
+})
+export class ProfilePublicViewComponent {
+ #backend = inject(BackendService);
+ #account = inject(AccountService);
+ #helper = inject(DialogHelperService);
+ #sidenavService = inject(SidenavService);
+ #sidenavOptionsService = inject(ExploreFilterSidenavOptionsService);
+
+ profile = input.required();
+
+ entities = signal([]);
+ compilations = signal([]);
+
+ searchText = signal('');
+ selectedTab = signal('objects');
+
+ selectedFilterOptions = signal([]);
+ numFilterOptions = computed(
+ () => this.selectedFilterOptions().filter(option => option.category !== 'sortBy').length,
+ );
+
+ availableTabs = [
+ { label: 'Objects', value: 'objects' },
+ { label: 'Collections', value: 'collections' },
+ ] as const satisfies Tab[];
+
+ #userProfile = toSignal(this.#account.userProfile$, { initialValue: undefined });
+
+ isOwnProfile = computed(() => {
+ const profile = this.profile();
+ return profile._id === this.#userProfile()?._id || profile.ownerId === this.#userProfile()?._id;
+ });
+
+ matchesSearch = (name: string | undefined): boolean => {
+ const query = this.searchText().toLowerCase().trim();
+ if (!query) return true;
+ return (name ?? '').toLowerCase().includes(query);
+ };
+
+ #annotationCount = (item: FilterableProfileItem): number =>
+ item.__annotationCount ?? Object.keys(item.annotations ?? {}).length;
+
+ #effectiveMediaTypes = (item: FilterableProfileItem): string[] =>
+ item.__mediaTypes ?? (item.mediaType ? [item.mediaType] : []);
+
+ #applyFilters = (items: T[]): T[] => {
+ const filters = reduceExploreFilterOptions(this.selectedFilterOptions());
+
+ const withAnnotations = filters.annotation?.includes('with-annotations');
+ const withoutAnnotations = filters.annotation?.includes('without-annotations');
+
+ const filtered = items.filter(item => {
+ if (filters.mediaType?.length) {
+ const mediaTypes = this.#effectiveMediaTypes(item);
+ if (!filters.mediaType.some(type => mediaTypes.includes(type))) return false;
+ }
+ if (filters.annotation?.length) {
+ const count = this.#annotationCount(item);
+ if (withAnnotations && withoutAnnotations) {
+ } else {
+ if (withAnnotations && count === 0) return false;
+ if (withoutAnnotations && count > 0) return false;
+ }
+ }
+ if (filters.licence?.length) {
+ if (!item.__licenses || !filters.licence.some(l => item.__licenses?.includes(l)))
+ return false;
+ }
+ if (filters.misc?.includes('downloadable') && !item.__downloadable) return false;
+ return this.matchesSearch(item.name);
+ });
+
+ const sortBy = (filters.sortBy?.at(0) ?? SortOrder.newest) as string;
+ const reversed = sortBy.endsWith('-reversed');
+ const sortKey = reversed ? sortBy.replace('-reversed', '') : sortBy;
+
+ return [...filtered].sort((a, b) => {
+ switch (sortKey) {
+ case SortOrder.annotations:
+ return this.#annotationCount(b) - this.#annotationCount(a);
+ case SortOrder.name: {
+ const comparison = (a.__normalizedName ?? a.name).localeCompare(
+ b.__normalizedName ?? b.name,
+ );
+ return reversed ? -comparison : comparison;
+ }
+ case SortOrder.popularity:
+ return (b.__hits ?? 0) - (a.__hits ?? 0);
+ case SortOrder.newest:
+ return (b.__createdAt ?? 0) - (a.__createdAt ?? 0);
+ default:
+ return (b.__hits ?? 0) - (a.__hits ?? 0);
+ }
+ });
+ };
+
+ filteredEntities = computed(() => this.#applyFilters(this.entities()));
+ filteredCompilations = computed(() => this.#applyFilters(this.compilations()));
+
+ constructor() {
+ effect(() => {
+ const profile = this.profile();
+ if (!profile) return;
+ const profileId = profile._id;
+ this.#backend
+ .getPublicProfileEntities(profileId)
+ .then(entities => this.entities.set(entities ?? []))
+ .catch(() => this.entities.set([]));
+
+ this.#backend
+ .getPublicProfileCompilations(profileId)
+ .then(compilations => this.compilations.set(compilations ?? []))
+ .catch(() => this.compilations.set([]));
+ });
+
+ effect(() => {
+ const counts = {
+ objects: this.filteredEntities().length,
+ collections: this.filteredCompilations().length,
+ };
+ const tab = this.selectedTab();
+ this.#sidenavOptionsService.setResultCount(
+ counts[tab === 'collections' ? 'collections' : 'objects'],
+ );
+ });
+
+ let isInitialChange = true;
+ effect(() => {
+ const updatedOptions = this.#sidenavOptionsService.selectedOptions();
+ if (isInitialChange) {
+ isInitialChange = false;
+ return;
+ }
+ this.selectedFilterOptions.set(updatedOptions);
+ });
+ }
+
+ public async openFilterSidenav() {
+ if (this.#sidenavService.state().opened) return;
+ const tab = this.selectedTab();
+ const category: ExploreCategory = tab === 'collections' ? 'collections' : 'objects';
+
+ const filterOptions =
+ tab === 'collections'
+ ? ({
+ sortBy: SortByOptions,
+ mediaType: [],
+ annotation: AnnotationOptions,
+ licence: LicenceOptions,
+ misc: MiscOptions,
+ } satisfies ExploreFilterSidenavData['filterOptions'])
+ : ({
+ sortBy: SortByOptions,
+ mediaType: MediaTypeOptions,
+ annotation: AnnotationOptions,
+ licence: LicenceOptions,
+ misc: MiscOptions,
+ } satisfies ExploreFilterSidenavData['filterOptions']);
+
+ const result = await this.#sidenavService.openWithResult<
+ ExploreFilterOption[],
+ ExploreFilterSidenavData
+ >(ExploreFilterSidenavComponent, {
+ options: this.selectedFilterOptions(),
+ category,
+ filterOptions,
+ });
+ if (result) {
+ this.selectedFilterOptions.set(result);
+ }
+ }
+
+ public onChangeTab(value: string) {
+ this.selectedTab.set(value);
+ this.selectedFilterOptions.set([]);
+ }
+
+ public openEditDialog() {
+ this.#helper.editProfile(this.profile());
+ }
+}
diff --git a/src/app/services/account.service.ts b/src/app/services/account.service.ts
index 42bb7163..9e41671d 100644
--- a/src/app/services/account.service.ts
+++ b/src/app/services/account.service.ts
@@ -39,6 +39,7 @@ export class AccountService {
updateTrigger$ = new BehaviorSubject<'all' | Collection | 'profile'>('all');
constructor() {
+ this.#restoreSelectedProfile();
combineLatest([this.user$, this.draftEntities$]).subscribe(([user, unfinishedEntities]) => {
if (!user) return;
let message = `Logged in as ${user.fullname}`;
@@ -86,6 +87,25 @@ export class AccountService {
switchToProfile(profile: IPublicProfile) {
this.selectedProfile$.next(profile);
+ this.#cache.setItem('selected-profile-id', profile._id).catch(() => {});
+ }
+
+ #restoreSelectedProfile() {
+ this.profiles$
+ .pipe(
+ filter(profiles => profiles.length > 0),
+ switchMap(async profiles => {
+ if (this.selectedProfile$.value) return;
+ const cachedId = await firstValueFrom(
+ this.#cache.getItem('selected-profile-id').pipe(defaultIfEmpty(undefined)),
+ );
+ const profile = profiles.find(candidate => candidate._id === cachedId);
+ if (profile && profile._id !== (await firstValueFrom(this.userProfile$))?._id) {
+ this.selectedProfile$.next(profile);
+ }
+ }),
+ )
+ .subscribe();
}
organizationProfiles$ = this.profiles$.pipe(
@@ -141,9 +161,10 @@ export class AccountService {
filter(user => !!user),
combineLatestWith(this.updateTrigger$),
filter(([_, trigger]) => trigger === 'all' || trigger === Collection.annotation),
- switchMap(() =>
+ switchMap(() => this.currentProfile$),
+ switchMap(profile =>
this.#cache.getItem('profile-annotations', () =>
- this.#backend.getUserDataAnnotations({}),
+ this.#backend.getUserDataAnnotations({ profileId: profile?._id }),
),
),
map(result => result ?? []),
@@ -177,6 +198,9 @@ export class AccountService {
canModifyNews$: this.user$.pipe(
map(user => user?.flags?.includes(UserFlag.canModifyNews) ?? false),
),
+ testingCanManageOrganizations$: this.user$.pipe(
+ map(user => user?.flags?.includes(UserFlag.testingCanManageOrganizations) ?? false),
+ ),
};
// Finished:
@@ -209,7 +233,9 @@ export class AccountService {
localStorage.removeItem('jwt');
this.#userdata$.next(undefined);
this.#events.updateSearchEvent();
- this.#cache.removeItem('user-data');
+ this.#cache.removeItem('user-data').catch(() => {});
+ this.#cache.removeItem('selected-profile-id').catch(() => {});
+ this.selectedProfile$.next(null);
}
/**
diff --git a/src/app/services/backend.service.ts b/src/app/services/backend.service.ts
index c3295520..0a37a480 100644
--- a/src/app/services/backend.service.ts
+++ b/src/app/services/backend.service.ts
@@ -9,6 +9,8 @@ import {
IEntity,
IInstitution,
IPerson,
+ IPublicProfile,
+ ProfileMemberRole,
ProfileType,
isEntity,
isPerson,
@@ -359,8 +361,65 @@ export class BackendService {
});
}
- public async getCurrentUserProfile() {
- return this.createGet('/server/api/v2/profile/user', { pathParams: {}, queryParams: {} });
+ public async getPublicProfileEntities(id: string): Promise {
+ return this.createGet('/server/api/v2/profile/via-id/{id}/entities', {
+ pathParams: { id },
+ queryParams: {},
+ });
+ }
+
+ public async getPublicProfileCompilations(id: string): Promise {
+ return this.createGet('/server/api/v2/profile/via-id/{id}/compilations', {
+ pathParams: { id },
+ queryParams: {},
+ });
+ }
+
+ public async getOrganizationMembers(id: string) {
+ return this.createGet('/server/api/v2/profile/organization/{id}/members', {
+ pathParams: { id },
+ queryParams: {},
+ });
+ }
+
+ public async addOrganizationMember(
+ id: string,
+ body: { userId: string; role: ProfileMemberRole },
+ ) {
+ return this.createPost('/server/api/v2/profile/organization/{id}/members', {
+ body,
+ pathParams: { id },
+ queryParams: {},
+ });
+ }
+
+ public async updateOrganizationMemberRole(
+ id: string,
+ userId: string,
+ body: { role: ProfileMemberRole },
+ ) {
+ return this.createPost('/server/api/v2/profile/organization/{id}/members/{userId}', {
+ body,
+ pathParams: { id, userId },
+ queryParams: {},
+ });
+ }
+
+ public async removeOrganizationMember(id: string, userId: string) {
+ return this.createDelete('/server/api/v2/profile/organization/{id}/members/{userId}', {
+ pathParams: { id, userId },
+ queryParams: {},
+ });
+ }
+
+ public async searchProfiles(
+ query: string,
+ type?: 'user' | 'organization' | 'all',
+ ): Promise {
+ return this.createGet('/server/api/v2/profile/search', {
+ pathParams: {},
+ queryParams: { q: query, type },
+ });
}
public async updateProfile(
@@ -414,9 +473,13 @@ export class BackendService {
collection: Collection,
document: T,
guard: (obj: unknown) => obj is T,
+ options?: { profileId?: string },
): Promise {
+ const body = options?.profileId
+ ? ({ ...document, profileId: options.profileId } as T)
+ : document;
return this.createPost('/server/api/v1/post/push/{collection}', {
- body: document,
+ body,
pathParams: { collection },
queryParams: {},
}).then(res => {
@@ -425,8 +488,8 @@ export class BackendService {
});
}
- public async pushEntity(entity: IEntity) {
- return this.pushSingleDocumentToCollection(Collection.entity, entity, isEntity);
+ public async pushEntity(entity: IEntity, options?: { profileId?: string }) {
+ return this.pushSingleDocumentToCollection(Collection.entity, entity, isEntity, options);
}
public async pushPerson(person: IPerson) {
@@ -578,13 +641,23 @@ export class BackendService {
docId,
collection,
targetUserId,
+ profileId,
+ actingProfileId,
}: {
docId: string;
collection: (typeof Collection)['entity'] | (typeof Collection)['compilation'];
targetUserId: string;
+ profileId?: string;
+ actingProfileId?: string;
}) {
return this.createPost('/server/api/v2/user-data/transfer-ownership', {
- body: { collection, docId, targetUserId },
+ body: {
+ collection,
+ docId,
+ targetUserId,
+ profileId,
+ actingProfileId,
+ },
pathParams: {},
queryParams: {},
});
diff --git a/src/app/services/permissions.service.ts b/src/app/services/permissions.service.ts
index bed41612..b5fe4b61 100644
--- a/src/app/services/permissions.service.ts
+++ b/src/app/services/permissions.service.ts
@@ -1,11 +1,19 @@
import { inject, Injectable } from '@angular/core';
-import { EntityAccessRole, ICompilation, IEntity } from '@kompakkt/common';
+import {
+ EntityAccessRole,
+ ICompilation,
+ IEntity,
+ IUserDataWithoutData,
+ ProfileType,
+} from '@kompakkt/common';
import { AccountService } from './account.service';
import { SelectionService } from './selection.service';
import { toSignal } from '@angular/core/rxjs-interop';
type AccessTarget = IEntity | ICompilation;
+type MembershipEntry = { profileId: string; type: ProfileType; role?: EntityAccessRole };
+
export enum Permission {
EditMetaData = 'editMetadata',
EditAnnotation = 'editAnnotation',
@@ -47,6 +55,7 @@ export class PermissionService {
private selection = inject(SelectionService);
private user = toSignal(this.account.user$);
+ private currentProfile = toSignal(this.account.currentProfile$, { initialValue: null });
private readonly rolePriority = [
EntityAccessRole.viewer,
@@ -54,11 +63,38 @@ export class PermissionService {
EntityAccessRole.owner,
] as const;
- public getRole(element: AccessTarget) {
- const userId = this.user()?._id;
+ public getRole(element: AccessTarget): EntityAccessRole {
+ const user = this.user();
+ const userId = user?._id;
if (!userId || !element.access) return EntityAccessRole.viewer;
- return element.access.find(user => user._id === userId)?.role ?? EntityAccessRole.viewer;
+ const userEntries = element.access.filter(entry => entry._id === userId);
+ if (userEntries.length > 0) {
+ const readonlyProfileId = this.currentProfile()?._id;
+ const scoped = readonlyProfileId
+ ? userEntries.find(entry => entry.profile?.profileId === readonlyProfileId)
+ : undefined;
+ if (scoped) return scoped.role;
+
+ const legacy = userEntries.find(entry => !entry.profile);
+ return (legacy ?? userEntries[0])?.role ?? EntityAccessRole.viewer;
+ }
+
+ return this.#membershipBaselineRole(element, user) ?? EntityAccessRole.viewer;
+ }
+
+ #membershipBaselineRole(
+ element: AccessTarget,
+ user: IUserDataWithoutData | undefined,
+ ): EntityAccessRole | undefined {
+ const ownerProfileId = element.creator?.profile?.profileId;
+ if (!ownerProfileId || !user?.profiles) return undefined;
+
+ const membership = (user.profiles as MembershipEntry[]).find(
+ entry => entry.profileId === ownerProfileId && entry.type === ProfileType.organization,
+ );
+
+ return membership?.role;
}
getLowestRole(targets: AccessTarget[]): EntityAccessRole {
diff --git a/src/app/util/get-server-url.ts b/src/app/util/get-server-url.ts
index e5affb0a..09035d3b 100644
--- a/src/app/util/get-server-url.ts
+++ b/src/app/util/get-server-url.ts
@@ -15,6 +15,10 @@ export const getServerUrl = (path: string, opts = { randomTimestamp: true }): st
// Some compilations have incorrect server urls
path = path.replaceAll('https://kompakkt.uni-koeln.de:8080', '/server');
+ if (path.startsWith('/') && !path.startsWith('//')) {
+ path = path.slice(1);
+ }
+
const url = new URL(path, serverUrl);
if (opts.randomTimestamp) {
url.searchParams.set('t', Date.now().toString());
diff --git a/src/styles.scss b/src/styles.scss
index 1be37271..8dda7307 100644
--- a/src/styles.scss
+++ b/src/styles.scss
@@ -762,6 +762,11 @@ app-annotate {
}
}
+.mat-mdc-menu-panel.profile-dropdown {
+ width: 300px;
+ max-width: 300px !important;
+}
+
/* Dialogs */
.mdc-text-field--filled:not(.mdc-text-field--disabled),