diff --git a/app/src/app/admin.service.ts b/app/src/app/admin.service.ts
index 1c33c04..ba58e22 100644
--- a/app/src/app/admin.service.ts
+++ b/app/src/app/admin.service.ts
@@ -8,6 +8,7 @@ export class AdminService {
readonly #APPS: { [key: string]: string } = {
registries: 'did:dht:jtubj7jooigmx9y7dz13j9kxhoy3pyo6jzizh3irkmwity3saxko',
+ communities: 'did:dht:jtubj7jooigmx9y7dz13j9kxhoy3pyo6jzizh3irkmwity3saxko',
};
readonly #ADMIN_DIDS: string[] = [
diff --git a/app/src/app/admin/admin.component.html b/app/src/app/admin/admin.component.html
index 778af41..3554cee 100644
--- a/app/src/app/admin/admin.component.html
+++ b/app/src/app/admin/admin.component.html
@@ -3,9 +3,20 @@
Owners
-
+
@if (roles() && roles().length > 0) {
User's with roles:
diff --git a/app/src/app/admin/admin.component.ts b/app/src/app/admin/admin.component.ts
index 0ed6bfe..ac665aa 100644
--- a/app/src/app/admin/admin.component.ts
+++ b/app/src/app/admin/admin.component.ts
@@ -9,6 +9,7 @@ import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { HttpClient } from '@angular/common/http';
import { registry } from '../../protocols';
+import { community } from '../../protocols';
import { AdminService } from '../admin.service';
import { LayoutService } from '../layout.service';
import { IdentityService } from '../identity.service';
@@ -102,9 +103,15 @@ export class AdminComponent {
}
}
- async givePermissions() {
+ async givePermissionsToRegistry() {
for (let did of this.admin.getAdminDids()) {
- await this.givePermission(did);
+ await this.givePermissionToCommunity(did);
+ }
+ }
+
+ async givePermissionsToCommunity() {
+ for (let did of this.admin.getAdminDids()) {
+ await this.givePermissionToCommunity(did);
}
}
@@ -184,7 +191,7 @@ export class AdminComponent {
// }
}
- async givePermission(did: string) {
+ async givePermissionToRegistry(did: string) {
// Assign collaborator role to the DID.
const tags = {
role: true,
@@ -237,6 +244,59 @@ export class AdminComponent {
console.log('Role record:', roleRecord);
}
+ async givePermissionToCommunity(did: string) {
+ // Assign collaborator role to the DID.
+ const tags = {
+ role: true,
+ };
+
+ // const query = {
+ // data: {},
+ // message: {
+ // tags: tags,
+ // recipient: collaborator,
+ // protocol: taskDefinition.protocol,
+ // parentContextId: record.contextId, // Make the role a child of the list.
+ // // protocolPath: 'list/collaborator',
+ // protocolPath: 'list/collaborator',
+ // schema: taskDefinition.types.collaborator.schema,
+ // // dataFormat: taskDefinition.types.collaborator.dataFormats[0],
+ // },
+ // };
+
+ const query = {
+ store: false,
+ data: {},
+ message: {
+ tags: tags,
+ recipient: did,
+ protocol: community.uri,
+ // parentContextId: record.contextId, // Make the role a child of the list.
+ // protocolPath: 'list/collaborator',
+ schema: 'https://schema.ariton.app/community/globalAdmin',
+ protocolPath: 'globalAdmin',
+ // protocolRole: 'profile/admin',
+ // schema: registry.definition.types.profile.dataFormats.types.collaborator.schema,
+ // dataFormat: taskDefinition.types.collaborator.dataFormats[0],
+ },
+ };
+
+ console.log('QUERY:', query);
+
+ // This will fail if the DID already have a role assigned.
+ // TODO: Implement a query to see if the user already has role assigned and skip this step.
+ const { record: roleRecord, status: roleStatus } = await this.identity.web5.dwn.records.create(query);
+
+ const ownerDid = this.admin.getIdentifierForApp('communities');
+ const { status: sendStatus } = await roleRecord!.send(ownerDid);
+
+ console.log('Send status:', sendStatus);
+
+ console.log('!!!!!');
+ console.log('Role status:', roleStatus);
+ console.log('Role record:', roleRecord);
+ }
+
async deleteRegistries() {
const did = this.admin.getIdentifierForApp('registries');
diff --git a/app/src/app/app.routes.ts b/app/src/app/app.routes.ts
index 167883e..e2cb3a3 100644
--- a/app/src/app/app.routes.ts
+++ b/app/src/app/app.routes.ts
@@ -61,6 +61,12 @@ export const routes: Routes = [
title: 'Communities',
data: { hide: true, icon: 'diversity_2' },
},
+ {
+ path: 'community/:id/:did',
+ loadComponent: () => import('./community/community.component').then((c) => c.CommunityComponent),
+ title: 'Communities',
+ data: { hide: true, icon: 'diversity_2' },
+ },
{
path: 'friends',
loadComponent: () => import('./friends/friends.component').then((c) => c.FriendsComponent),
diff --git a/app/src/app/community/community.component.html b/app/src/app/community/community.component.html
index 052d103..bd497a2 100644
--- a/app/src/app/community/community.component.html
+++ b/app/src/app/community/community.component.html
@@ -45,6 +45,20 @@
+
+ @if (admin.isAdmin(identity.did)) {
+
+
+ Administration
+
+
+
+
+
+
+ }
diff --git a/app/src/app/community/community.component.ts b/app/src/app/community/community.component.ts
index dfbc739..64c6366 100644
--- a/app/src/app/community/community.component.ts
+++ b/app/src/app/community/community.component.ts
@@ -17,6 +17,8 @@ import { RecordEntry } from '../data';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { MatTooltipModule } from '@angular/material/tooltip';
import { ProfileHeaderComponent } from '../shared/components/profile-header/profile-header.component';
+import { AdminService } from '../admin.service';
+import { IdentityService } from '../identity.service';
@Component({
selector: 'app-community',
@@ -53,10 +55,16 @@ export class CommunityComponent {
data = inject(DataService);
+ admin = inject(AdminService);
+
+ identity = inject(IdentityService);
+
selectedCommunity = signal