diff --git a/frontend/pages/_user/index.vue b/frontend/pages/_user/index.vue
index 7740b625..2569bd95 100644
--- a/frontend/pages/_user/index.vue
+++ b/frontend/pages/_user/index.vue
@@ -13,11 +13,19 @@
{{ $t('author.orgs') }}
-
- {{ org.name }}
+
+
+
+
+
+ {{ orgName }}
+
+
+ {{ orgRole.role.title }}
+
-
+
{{ $t('author.noOrgs', [user.name]) }}
@@ -62,6 +70,7 @@
import { Component } from 'nuxt-property-decorator';
import { PaginatedResult, Project, ProjectCompact, Role } from 'hangar-api';
import { Context } from '@nuxt/types';
+import { RoleTable } from 'hangar-internal';
import { UserAvatar } from '~/components/users';
import { ProjectList } from '~/components/projects';
import { UserPropPage } from '~/components/mixins';
@@ -76,8 +85,7 @@ import MemberList from '~/components/projects/MemberList.vue';
})
export default class AuthorPage extends UserPropPage {
projects!: PaginatedResult;
- // todo load orgs from server
- orgs: PaginatedResult = { result: [], pagination: { offset: 0, count: 0, limit: 20 } };
+ organizations!: { [key: string]: RoleTable };
starred!: PaginatedResult;
watching!: PaginatedResult;
orgRoles!: Role[];
@@ -88,17 +96,18 @@ export default class AuthorPage extends UserPropPage {
};
}
- async asyncData({ $api, route, $util }: Context) {
+ async asyncData({ $api, params, $util }: Context) {
const data = await Promise.all([
- $api.request>(`users/${route.params.user}/starred`, false),
- $api.request>(`users/${route.params.user}/watching`, false),
+ $api.request>(`users/${params.user}/starred`, false),
+ $api.request>(`users/${params.user}/watching`, false),
$api.request>(`projects`, false, 'get', {
- owner: route.params.user,
+ owner: params.user,
}),
$api.requestInternal('data/orgRoles', false, 'get'),
+ $api.requestInternal<{ [key: string]: RoleTable }>(`organizations/${params.user}/userOrganizations`, false),
]).catch($util.handlePageRequestError);
if (typeof data === 'undefined') return;
- return { starred: data[1], watching: data[0], projects: data[2], orgRoles: data[3] };
+ return { starred: data[1], watching: data[0], projects: data[2], orgRoles: data[3], organizations: data[4] };
}
}
diff --git a/src/main/java/io/papermc/hangar/controller/internal/OrganizationController.java b/src/main/java/io/papermc/hangar/controller/internal/OrganizationController.java
index 2b3faf5c..6c09fe33 100644
--- a/src/main/java/io/papermc/hangar/controller/internal/OrganizationController.java
+++ b/src/main/java/io/papermc/hangar/controller/internal/OrganizationController.java
@@ -1,6 +1,7 @@
package io.papermc.hangar.controller.internal;
import io.papermc.hangar.exceptions.HangarApiException;
+import io.papermc.hangar.model.db.roles.OrganizationRoleTable;
import io.papermc.hangar.model.internal.HangarOrganization;
import io.papermc.hangar.model.internal.api.requests.CreateOrganizationForm;
import io.papermc.hangar.security.annotations.Anyone;
@@ -22,6 +23,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import javax.validation.Valid;
+import java.util.Map;
@Controller
@RequestMapping("/api/internal/organizations")
@@ -59,4 +61,10 @@ public class OrganizationController {
System.out.println(createOrganizationForm);
organizationFactory.createOrganization(createOrganizationForm.getName(), createOrganizationForm.getNewMembers());
}
+
+ @Anyone
+ @GetMapping(path = "/{user}/userOrganizations", produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity