diff --git a/package.json b/package.json index a543c2ae..56b1d57d 100644 --- a/package.json +++ b/package.json @@ -1,16 +1,16 @@ { - "name": "hephaestus", - "workspaces": [ - "webapp/*" - ], - "scripts": { - "generate:api:clean": "rimraf webapp/src/app/core/modules/openapi", - "generate:api:application-server-specs": "cd server/application-server && mvn verify -DskipTests=true -Dapp.profiles=specs", - "generate:api:application-server-client": "npx openapi-generator-cli generate -i server/application-server/openapi.yaml -g typescript-angular -o webapp/src/app/core/modules/openapi --additional-properties fileNaming=kebab-case,withInterfaces=true --generate-alias-as-model", - "generate:api": "npm run generate:api:application-server-specs && npm run generate:api:clean && npm run generate:api:application-server-client" - }, - "devDependencies": { - "@openapitools/openapi-generator-cli": "2.13.5", - "rimraf": "6.0.1" - } + "name": "hephaestus", + "workspaces": [ + "webapp/*" + ], + "scripts": { + "generate:api:clean": "rimraf webapp/src/app/core/modules/openapi", + "generate:api:application-server-specs": "cd server/application-server && mvn verify -DskipTests=true -Dapp.profiles=specs", + "generate:api:application-server-client": "npx openapi-generator-cli generate -i server/application-server/openapi.yaml -g typescript-angular -o webapp/src/app/core/modules/openapi --additional-properties fileNaming=kebab-case,withInterfaces=true --generate-alias-as-model", + "generate:api": "npm run generate:api:application-server-specs && npm run generate:api:clean && npm run generate:api:application-server-client" + }, + "devDependencies": { + "@openapitools/openapi-generator-cli": "2.13.5", + "rimraf": "6.0.1" + } } diff --git a/server/application-server/openapi.yaml b/server/application-server/openapi.yaml index 0fc2dc6a..f525dcce 100644 --- a/server/application-server/openapi.yaml +++ b/server/application-server/openapi.yaml @@ -46,7 +46,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/TeamDTO" + $ref: "#/components/schemas/TeamInfoDTO" required: true responses: "200": @@ -54,7 +54,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Team" + $ref: "#/components/schemas/TeamInfo" /admin/config/repositories: post: tags: @@ -109,7 +109,7 @@ paths: schema: type: array items: - $ref: "#/components/schemas/Team" + $ref: "#/components/schemas/TeamInfo" /meta: get: tags: @@ -246,7 +246,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Team" + $ref: "#/components/schemas/TeamInfo" components: schemas: PullRequestInfo: @@ -315,20 +315,16 @@ components: updatedAt: type: string format: date-time - LabelInfo: + AdminConfig: required: - - color - - id - - name + - repositoriesToMonitor type: object properties: - id: - type: integer - format: int64 - name: - type: string - color: - type: string + repositoriesToMonitor: + uniqueItems: true + type: array + items: + type: string UserProfile: required: - contributedRepositories @@ -353,39 +349,6 @@ components: type: array items: $ref: "#/components/schemas/PullRequestInfo" - PullRequestReviewInfo: - required: - - codeComments - - htmlUrl - - id - - isDismissed - - state - type: object - properties: - id: - type: integer - format: int64 - isDismissed: - type: boolean - state: - type: string - enum: - - COMMENTED - - APPROVED - - CHANGES_REQUESTED - - UNKNOWN - codeComments: - type: integer - format: int32 - author: - $ref: "#/components/schemas/UserInfo" - pullRequest: - $ref: "#/components/schemas/PullRequestBaseInfo" - htmlUrl: - type: string - submittedAt: - type: string - format: date-time RepositoryInfo: required: - htmlUrl @@ -405,13 +368,6 @@ components: type: string htmlUrl: type: string - MetaData: - type: object - properties: - repositoriesToMonitor: - type: array - items: - type: string UserTeams: required: - id @@ -434,7 +390,7 @@ components: uniqueItems: true type: array items: - $ref: "#/components/schemas/Team" + $ref: "#/components/schemas/TeamInfo" PullRequestBaseInfo: required: - htmlUrl @@ -496,7 +452,21 @@ components: type: string htmlUrl: type: string - Team: + TeamInfo: + required: + - color + - id + - name + type: object + properties: + id: + type: integer + format: int64 + name: + type: string + color: + type: string + LabelInfo: required: - color - id @@ -510,6 +480,46 @@ components: type: string color: type: string + PullRequestReviewInfo: + required: + - codeComments + - htmlUrl + - id + - isDismissed + - state + type: object + properties: + id: + type: integer + format: int64 + isDismissed: + type: boolean + state: + type: string + enum: + - COMMENTED + - APPROVED + - CHANGES_REQUESTED + - UNKNOWN + codeComments: + type: integer + format: int32 + author: + $ref: "#/components/schemas/UserInfo" + pullRequest: + $ref: "#/components/schemas/PullRequestBaseInfo" + htmlUrl: + type: string + submittedAt: + type: string + format: date-time + MetaData: + type: object + properties: + repositoriesToMonitor: + type: array + items: + type: string LeaderboardEntry: required: - numberOfApprovals diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/ClassImportIntegratorIntegratorProvider.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/ClassImportIntegratorIntegratorProvider.java index 669e985a..7eb0922d 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/ClassImportIntegratorIntegratorProvider.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/ClassImportIntegratorIntegratorProvider.java @@ -13,7 +13,7 @@ import de.tum.in.www1.hephaestus.gitprovider.pullrequest.PullRequestInfoDTO; import de.tum.in.www1.hephaestus.gitprovider.pullrequestreview.PullRequestReviewInfoDTO; import de.tum.in.www1.hephaestus.gitprovider.repository.RepositoryInfoDTO; -import de.tum.in.www1.hephaestus.gitprovider.team.TeamDTO; +import de.tum.in.www1.hephaestus.gitprovider.team.TeamInfoDTO; import de.tum.in.www1.hephaestus.gitprovider.user.UserInfoDTO; import io.hypersistence.utils.hibernate.type.util.ClassImportIntegrator; @@ -25,7 +25,7 @@ public List getIntegrators() { @SuppressWarnings("rawtypes") List classes = new ArrayList<>(); classes.add(UserInfoDTO.class); - classes.add(TeamDTO.class); + classes.add(TeamInfoDTO.class); classes.add(IssueInfoDTO.class); classes.add(LabelInfoDTO.class); classes.add(MilestoneInfoDTO.class); diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/admin/AdminConfigDTO.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/admin/AdminConfigDTO.java new file mode 100644 index 00000000..a6aae7f4 --- /dev/null +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/admin/AdminConfigDTO.java @@ -0,0 +1,11 @@ +package de.tum.in.www1.hephaestus.admin; + +import java.util.Set; + +import org.springframework.lang.NonNull; + +public record AdminConfigDTO(@NonNull Set repositoriesToMonitor) { + public static AdminConfigDTO fromAdminConfig(AdminConfig adminConfig) { + return new AdminConfigDTO(adminConfig.getRepositoriesToMonitor()); + } +} diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/admin/AdminController.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/admin/AdminController.java index ffb462e4..1ae9a729 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/admin/AdminController.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/admin/AdminController.java @@ -3,6 +3,7 @@ import java.util.List; import java.util.Set; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.oauth2.core.oidc.StandardClaimNames; @@ -16,7 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import de.tum.in.www1.hephaestus.gitprovider.team.TeamDTO; +import de.tum.in.www1.hephaestus.gitprovider.team.TeamInfoDTO; import de.tum.in.www1.hephaestus.gitprovider.user.UserInfoDTO; import de.tum.in.www1.hephaestus.gitprovider.user.UserTeamsDTO; @@ -24,11 +25,8 @@ @RequestMapping("/admin") public class AdminController { - private final AdminService adminService; - - public AdminController(AdminService adminService) { - this.adminService = adminService; - } + @Autowired + private AdminService adminService; @GetMapping public String admin() { @@ -46,9 +44,9 @@ public static record AuthUserInfoDTO(String name, List roles) { } @GetMapping("/config") - public ResponseEntity getConfig() { + public ResponseEntity getConfig() { try { - return ResponseEntity.ok(adminService.getAdminConfig()); + return ResponseEntity.ok(AdminConfigDTO.fromAdminConfig(adminService.getAdminConfig())); } catch (NoAdminConfigFoundException e) { return ResponseEntity.notFound().build(); } @@ -79,12 +77,12 @@ public ResponseEntity removeTeamFromUser(@PathVariable String login } @PutMapping("/teams") - public ResponseEntity createTeam(@RequestBody TeamDTO team) { + public ResponseEntity createTeam(@RequestBody TeamInfoDTO team) { return ResponseEntity.ok(adminService.createTeam(team.name(), team.color())); } @DeleteMapping("/teams/{teamId}") - public ResponseEntity deleteTeam(@PathVariable Long teamId) { + public ResponseEntity deleteTeam(@PathVariable Long teamId) { return adminService.deleteTeam(teamId) .map(ResponseEntity::ok) .orElseGet(() -> ResponseEntity.notFound().build()); diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/admin/AdminService.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/admin/AdminService.java index 4abb09b9..a5c30b4e 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/admin/AdminService.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/admin/AdminService.java @@ -15,7 +15,7 @@ import org.springframework.stereotype.Service; import de.tum.in.www1.hephaestus.gitprovider.team.Team; -import de.tum.in.www1.hephaestus.gitprovider.team.TeamDTO; +import de.tum.in.www1.hephaestus.gitprovider.team.TeamInfoDTO; import de.tum.in.www1.hephaestus.gitprovider.team.TeamService; import de.tum.in.www1.hephaestus.gitprovider.user.User; import de.tum.in.www1.hephaestus.gitprovider.user.UserInfoDTO; @@ -56,7 +56,7 @@ public void run() { } } // make sure teams are initialized - List teams = teamService.getAllTeams(); + List teams = teamService.getAllTeams(); if (teams.isEmpty()) { logger.info("No teams found, creating default teams"); teamService.createDefaultTeams(); @@ -117,18 +117,18 @@ public Optional removeTeamFromUser(String login, Long teamId) { return Optional.of(UserInfoDTO.fromUser(user)); } - public TeamDTO createTeam(String name, String color) { + public TeamInfoDTO createTeam(String name, String color) { logger.info("Creating team with name: " + name + " and color: " + color); - return TeamDTO.fromTeam(teamService.createTeam(name, color)); + return TeamInfoDTO.fromTeam(teamService.createTeam(name, color)); } - public Optional deleteTeam(Long teamId) { + public Optional deleteTeam(Long teamId) { logger.info("Deleting team with ID: " + teamId); Optional optionalTeam = teamService.getTeam(teamId); if (optionalTeam.isEmpty()) { return Optional.empty(); } teamService.deleteTeam(teamId); - return Optional.of(TeamDTO.fromTeam(optionalTeam.get())); + return Optional.of(TeamInfoDTO.fromTeam(optionalTeam.get())); } } diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/team/TeamController.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/team/TeamController.java index 2eaacb9f..5aa1c7ee 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/team/TeamController.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/team/TeamController.java @@ -17,7 +17,7 @@ public TeamController(TeamService teamService) { } @GetMapping("/all") - public ResponseEntity> getTeams() { + public ResponseEntity> getTeams() { return ResponseEntity.ok(teamService.getAllTeams()); } } diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/team/TeamDTO.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/team/TeamDTO.java deleted file mode 100644 index 48a9b9b8..00000000 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/team/TeamDTO.java +++ /dev/null @@ -1,12 +0,0 @@ -package de.tum.in.www1.hephaestus.gitprovider.team; - -import org.springframework.lang.NonNull; - -import com.fasterxml.jackson.annotation.JsonInclude; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public record TeamDTO(@NonNull Long id, @NonNull String name, @NonNull String color) { - public static TeamDTO fromTeam(Team team) { - return new TeamDTO(team.getId(), team.getName(), team.getColor()); - } -} diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/team/TeamInfoDTO.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/team/TeamInfoDTO.java new file mode 100644 index 00000000..3d4858d8 --- /dev/null +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/team/TeamInfoDTO.java @@ -0,0 +1,9 @@ +package de.tum.in.www1.hephaestus.gitprovider.team; + +import org.springframework.lang.NonNull; + +public record TeamInfoDTO(@NonNull Long id, @NonNull String name, @NonNull String color) { + public static TeamInfoDTO fromTeam(Team team) { + return new TeamInfoDTO(team.getId(), team.getName(), team.getColor()); + } +} diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/team/TeamService.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/team/TeamService.java index fe066246..3d5edbad 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/team/TeamService.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/team/TeamService.java @@ -27,8 +27,8 @@ public Optional getTeam(String name) { return teamRepository.findByName(name); } - public List getAllTeams() { - List teams = teamRepository.findAll().stream().map(TeamDTO::fromTeam).toList(); + public List getAllTeams() { + List teams = teamRepository.findAll().stream().map(TeamInfoDTO::fromTeam).toList(); logger.info("Getting all (" + teams.size() + ") teams"); return teams; } diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/user/UserTeamsDTO.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/user/UserTeamsDTO.java index 1378c85a..65d7f466 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/user/UserTeamsDTO.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/user/UserTeamsDTO.java @@ -6,12 +6,13 @@ import org.springframework.lang.NonNull; -import de.tum.in.www1.hephaestus.gitprovider.team.TeamDTO; +import de.tum.in.www1.hephaestus.gitprovider.team.TeamInfoDTO; public record UserTeamsDTO(@NonNull Long id, @NonNull String login, @NonNull String name, @NonNull String url, - @NonNull Set teams) { + @NonNull Set teams) { public static UserTeamsDTO fromUser(User user) { return new UserTeamsDTO(user.getId(), user.getLogin(), user.getName(), user.getHtmlUrl(), - user.getTeams().stream().map(TeamDTO::fromTeam).collect(Collectors.toCollection(LinkedHashSet::new))); + user.getTeams().stream().map(TeamInfoDTO::fromTeam) + .collect(Collectors.toCollection(LinkedHashSet::new))); } } diff --git a/webapp/src/app/admin/teams/table/teams-table.component.ts b/webapp/src/app/admin/teams/table/teams-table.component.ts index 59ab843d..8d89b9fb 100644 --- a/webapp/src/app/admin/teams/table/teams-table.component.ts +++ b/webapp/src/app/admin/teams/table/teams-table.component.ts @@ -17,12 +17,12 @@ import { HlmSelectModule } from '@spartan-ng/ui-select-helm'; import { HlmSkeletonModule } from '@spartan-ng/ui-skeleton-helm'; import { HlmCardModule } from '@spartan-ng/ui-card-helm'; import { debounceTime, map } from 'rxjs'; -import { AdminService, TeamDTO } from '@app/core/modules/openapi'; +import { AdminService, TeamInfo } from '@app/core/modules/openapi'; import { RouterLink } from '@angular/router'; import { injectQueryClient } from '@tanstack/angular-query-experimental'; import { octNoEntry } from '@ng-icons/octicons'; -const LOADING_TEAMS: TeamDTO[] = [ +const LOADING_TEAMS: TeamInfo[] = [ { id: 1, name: 'Team A', @@ -74,7 +74,7 @@ export class AdminTeamsTableComponent { protected octNoEntry = octNoEntry; isLoading = input(false); - teamData = input.required(); + teamData = input.required(); _teams = computed(() => this.teamData() ?? LOADING_TEAMS); protected readonly _rawFilterInput = signal(''); @@ -85,8 +85,8 @@ export class AdminTeamsTableComponent { protected readonly _availablePageSizes = [5, 10, 20, 10000]; protected readonly _pageSize = signal(this._availablePageSizes[0]); - private readonly _selectionModel = new SelectionModel(true); - protected readonly _isUserSelected = (user: TeamDTO) => this._selectionModel.isSelected(user); + private readonly _selectionModel = new SelectionModel(true); + protected readonly _isUserSelected = (user: TeamInfo) => this._selectionModel.isSelected(user); protected readonly _selected = toSignal(this._selectionModel.changed.pipe(map((change) => change.source.selected)), { initialValue: [] }); @@ -122,7 +122,7 @@ export class AdminTeamsTableComponent { return noneSelected ? false : allSelectedOrIndeterminate; }); - protected readonly _trackBy: TrackByFunction = (_: number, u: TeamDTO) => u.id; + protected readonly _trackBy: TrackByFunction = (_: number, u: TeamInfo) => u.id; protected readonly _totalElements = computed(() => this._filteredNames().length); protected readonly _onStateChange = ({ startIndex, endIndex }: PaginatorState) => this._displayedIndices.set({ start: startIndex, end: endIndex }); @@ -132,7 +132,7 @@ export class AdminTeamsTableComponent { effect(() => this._nameFilter.set(this._debouncedFilter() ?? ''), { allowSignalWrites: true }); } - protected toggleTeam(team: TeamDTO) { + protected toggleTeam(team: TeamInfo) { this._selectionModel.toggle(team); } @@ -156,7 +156,7 @@ export class AdminTeamsTableComponent { } } - protected deleteTeam(team: TeamDTO) { + protected deleteTeam(team: TeamInfo) { if (this.isLoading()) { return; } @@ -164,7 +164,7 @@ export class AdminTeamsTableComponent { this.invalidateTeams(); } - protected copyName(element: TeamDTO) { + protected copyName(element: TeamInfo) { console.log('Copying name', element); navigator.clipboard.writeText(element.name!); } @@ -179,7 +179,7 @@ export class AdminTeamsTableComponent { const newTeam = { name: this._newTeamName.value, color: this._newTeamColor.value - } as TeamDTO; + } as TeamInfo; this.adminService.createTeam(newTeam).subscribe({ next: () => console.log('Team created'), error: (err) => console.error('Error creating team', err) diff --git a/webapp/src/app/admin/users/table/users-table.component.html b/webapp/src/app/admin/users/table/users-table.component.html index de78cea4..31888abd 100644 --- a/webapp/src/app/admin/users/table/users-table.component.html +++ b/webapp/src/app/admin/users/table/users-table.component.html @@ -76,7 +76,7 @@ Teams @for (team of element.teams; track team) { - @let label = { name: team.name, color: team.color ?? '69feff' }; + @let label = { id: team.id, name: team.name, color: team.color ?? '69feff' }; } diff --git a/webapp/src/app/admin/users/table/users-table.component.ts b/webapp/src/app/admin/users/table/users-table.component.ts index 72697e92..05af06af 100644 --- a/webapp/src/app/admin/users/table/users-table.component.ts +++ b/webapp/src/app/admin/users/table/users-table.component.ts @@ -16,13 +16,13 @@ import { BrnSelectModule } from '@spartan-ng/ui-select-brain'; import { HlmSelectModule } from '@spartan-ng/ui-select-helm'; import { HlmSkeletonModule } from '@spartan-ng/ui-skeleton-helm'; import { debounceTime, map } from 'rxjs'; -import { AdminService, TeamDTO, UserTeamsDTO } from '@app/core/modules/openapi'; +import { AdminService, TeamInfo, UserTeams } from '@app/core/modules/openapi'; import { RouterLink } from '@angular/router'; import { GithubLabelComponent } from '@app/ui/github-label/github-label.component'; import { injectQueryClient } from '@tanstack/angular-query-experimental'; import { octNoEntry } from '@ng-icons/octicons'; -const LOADING_DATA: UserTeamsDTO[] = [ +const LOADING_DATA: UserTeams[] = [ { id: 1, login: 'test1', @@ -51,7 +51,7 @@ const LOADING_DATA: UserTeamsDTO[] = [ } ]; -const LOADING_TEAMS: TeamDTO[] = [ +const LOADING_TEAMS: TeamInfo[] = [ { id: 1, name: 'Team A', @@ -98,7 +98,7 @@ export class AdminUsersTableComponent { protected octNoEntry = octNoEntry; isLoading = input(false); - userData = input.required(); + userData = input.required(); _users = computed(() => this.userData() ?? LOADING_DATA); protected readonly _rawFilterInput = signal(''); @@ -109,8 +109,8 @@ export class AdminUsersTableComponent { protected readonly _availablePageSizes = [5, 10, 20, 10000]; protected readonly _pageSize = signal(this._availablePageSizes[0]); - private readonly _selectionModel = new SelectionModel(true); - protected readonly _isUserSelected = (user: UserTeamsDTO) => this._selectionModel.isSelected(user); + private readonly _selectionModel = new SelectionModel(true); + protected readonly _isUserSelected = (user: UserTeams) => this._selectionModel.isSelected(user); protected readonly _selected = toSignal(this._selectionModel.changed.pipe(map((change) => change.source.selected)), { initialValue: [] }); @@ -147,7 +147,7 @@ export class AdminUsersTableComponent { return noneSelected ? false : allSelectedOrIndeterminate; }); - protected readonly _trackBy: TrackByFunction = (_: number, u: UserTeamsDTO) => u.id; + protected readonly _trackBy: TrackByFunction = (_: number, u: UserTeams) => u.id; protected readonly _totalElements = computed(() => this._filteredLogins().length); protected readonly _onStateChange = ({ startIndex, endIndex }: PaginatorState) => this._displayedIndices.set({ start: startIndex, end: endIndex }); @@ -157,7 +157,7 @@ export class AdminUsersTableComponent { effect(() => this._loginFilter.set(this._debouncedFilter() ?? ''), { allowSignalWrites: true }); } - protected toggleUser(user: UserTeamsDTO) { + protected toggleUser(user: UserTeams) { this._selectionModel.toggle(user); } @@ -181,15 +181,15 @@ export class AdminUsersTableComponent { } } - protected copyLogin(element: UserTeamsDTO) { + protected copyLogin(element: UserTeams) { console.log('Copying login', element); navigator.clipboard.writeText(element.login!); } // handle team add / remove - teams = input(); + teams = input(); protected readonly _availableTeams = computed(() => this.teams() ?? LOADING_TEAMS); - protected readonly _selectedTeam = signal(undefined); + protected readonly _selectedTeam = signal(undefined); protected addTeamToSelected() { for (const user of this._selected()) { diff --git a/webapp/src/app/core/modules/openapi/.gitignore b/webapp/src/app/core/modules/openapi/.gitignore new file mode 100644 index 00000000..149b5765 --- /dev/null +++ b/webapp/src/app/core/modules/openapi/.gitignore @@ -0,0 +1,4 @@ +wwwroot/*.js +node_modules +typings +dist diff --git a/webapp/src/app/core/modules/openapi/.openapi-generator-ignore b/webapp/src/app/core/modules/openapi/.openapi-generator-ignore new file mode 100644 index 00000000..7484ee59 --- /dev/null +++ b/webapp/src/app/core/modules/openapi/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/webapp/src/app/core/modules/openapi/.openapi-generator/FILES b/webapp/src/app/core/modules/openapi/.openapi-generator/FILES new file mode 100644 index 00000000..e77597b8 --- /dev/null +++ b/webapp/src/app/core/modules/openapi/.openapi-generator/FILES @@ -0,0 +1,35 @@ +.gitignore +.openapi-generator-ignore +README.md +api.module.ts +api/admin.service.ts +api/admin.serviceInterface.ts +api/api.ts +api/leaderboard.service.ts +api/leaderboard.serviceInterface.ts +api/meta.service.ts +api/meta.serviceInterface.ts +api/team.service.ts +api/team.serviceInterface.ts +api/user.service.ts +api/user.serviceInterface.ts +configuration.ts +encoder.ts +git_push.sh +index.ts +model/admin-config.ts +model/auth-user-info.ts +model/label-info.ts +model/leaderboard-entry.ts +model/meta-data.ts +model/models.ts +model/pull-request-base-info.ts +model/pull-request-info.ts +model/pull-request-review-info.ts +model/repository-info.ts +model/team-info.ts +model/user-info.ts +model/user-profile.ts +model/user-teams.ts +param.ts +variables.ts diff --git a/webapp/src/app/core/modules/openapi/.openapi-generator/VERSION b/webapp/src/app/core/modules/openapi/.openapi-generator/VERSION new file mode 100644 index 00000000..1985849f --- /dev/null +++ b/webapp/src/app/core/modules/openapi/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.7.0 diff --git a/webapp/src/app/core/modules/openapi/README.md b/webapp/src/app/core/modules/openapi/README.md new file mode 100644 index 00000000..de16f95a --- /dev/null +++ b/webapp/src/app/core/modules/openapi/README.md @@ -0,0 +1,226 @@ +## @ + +### Building + +To install the required dependencies and to build the typescript sources run: +``` +npm install +npm run build +``` + +### publishing + +First build the package then run ```npm publish dist``` (don't forget to specify the `dist` folder!) + +### consuming + +Navigate to the folder of your consuming project and run one of next commands. + +_published:_ + +``` +npm install @ --save +``` + +_without publishing (not recommended):_ + +``` +npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save +``` + +_It's important to take the tgz file, otherwise you'll get trouble with links on windows_ + +_using `npm link`:_ + +In PATH_TO_GENERATED_PACKAGE/dist: +``` +npm link +``` + +In your project: +``` +npm link +``` + +__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages. +Please refer to this issue https://github.com/angular/angular-cli/issues/8284 for a solution / workaround. +Published packages are not effected by this issue. + + +#### General usage + +In your Angular project: + + +``` +// without configuring providers +import { ApiModule } from ''; +import { HttpClientModule } from '@angular/common/http'; + +@NgModule({ + imports: [ + ApiModule, + // make sure to import the HttpClientModule in the AppModule only, + // see https://github.com/angular/angular/issues/20575 + HttpClientModule + ], + declarations: [ AppComponent ], + providers: [], + bootstrap: [ AppComponent ] +}) +export class AppModule {} +``` + +``` +// configuring providers +import { ApiModule, Configuration, ConfigurationParameters } from ''; + +export function apiConfigFactory (): Configuration { + const params: ConfigurationParameters = { + // set configuration parameters here. + } + return new Configuration(params); +} + +@NgModule({ + imports: [ ApiModule.forRoot(apiConfigFactory) ], + declarations: [ AppComponent ], + providers: [], + bootstrap: [ AppComponent ] +}) +export class AppModule {} +``` + +``` +// configuring providers with an authentication service that manages your access tokens +import { ApiModule, Configuration } from ''; + +@NgModule({ + imports: [ ApiModule ], + declarations: [ AppComponent ], + providers: [ + { + provide: Configuration, + useFactory: (authService: AuthService) => new Configuration( + { + basePath: environment.apiUrl, + accessToken: authService.getAccessToken.bind(authService) + } + ), + deps: [AuthService], + multi: false + } + ], + bootstrap: [ AppComponent ] +}) +export class AppModule {} +``` + +``` +import { DefaultApi } from ''; + +export class AppComponent { + constructor(private apiGateway: DefaultApi) { } +} +``` + +Note: The ApiModule is restricted to being instantiated once app wide. +This is to ensure that all services are treated as singletons. + +#### Using multiple OpenAPI files / APIs / ApiModules +In order to use multiple `ApiModules` generated from different OpenAPI files, +you can create an alias name when importing the modules +in order to avoid naming conflicts: +``` +import { ApiModule } from 'my-api-path'; +import { ApiModule as OtherApiModule } from 'my-other-api-path'; +import { HttpClientModule } from '@angular/common/http'; + +@NgModule({ + imports: [ + ApiModule, + OtherApiModule, + // make sure to import the HttpClientModule in the AppModule only, + // see https://github.com/angular/angular/issues/20575 + HttpClientModule + ] +}) +export class AppModule { + +} +``` + + +### Set service base path +If different than the generated base path, during app bootstrap, you can provide the base path to your service. + +``` +import { BASE_PATH } from ''; + +bootstrap(AppComponent, [ + { provide: BASE_PATH, useValue: 'https://your-web-service.com' }, +]); +``` +or + +``` +import { BASE_PATH } from ''; + +@NgModule({ + imports: [], + declarations: [ AppComponent ], + providers: [ provide: BASE_PATH, useValue: 'https://your-web-service.com' ], + bootstrap: [ AppComponent ] +}) +export class AppModule {} +``` + + +#### Using @angular/cli +First extend your `src/environments/*.ts` files by adding the corresponding base path: + +``` +export const environment = { + production: false, + API_BASE_PATH: 'http://127.0.0.1:8080' +}; +``` + +In the src/app/app.module.ts: +``` +import { BASE_PATH } from ''; +import { environment } from '../environments/environment'; + +@NgModule({ + declarations: [ + AppComponent + ], + imports: [ ], + providers: [{ provide: BASE_PATH, useValue: environment.API_BASE_PATH }], + bootstrap: [ AppComponent ] +}) +export class AppModule { } +``` + +### Customizing path parameter encoding + +Without further customization, only [path-parameters][parameter-locations-url] of [style][style-values-url] 'simple' +and Dates for format 'date-time' are encoded correctly. + +Other styles (e.g. "matrix") are not that easy to encode +and thus are best delegated to other libraries (e.g.: [@honoluluhenk/http-param-expander]). + +To implement your own parameter encoding (or call another library), +pass an arrow-function or method-reference to the `encodeParam` property of the Configuration-object +(see [General Usage](#general-usage) above). + +Example value for use in your Configuration-Provider: +```typescript +new Configuration({ + encodeParam: (param: Param) => myFancyParamEncoder(param), +}) +``` + +[parameter-locations-url]: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameter-locations +[style-values-url]: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-values +[@honoluluhenk/http-param-expander]: https://www.npmjs.com/package/@honoluluhenk/http-param-expander diff --git a/webapp/src/app/core/modules/openapi/api.module.ts b/webapp/src/app/core/modules/openapi/api.module.ts new file mode 100644 index 00000000..58d341fb --- /dev/null +++ b/webapp/src/app/core/modules/openapi/api.module.ts @@ -0,0 +1,30 @@ +import { NgModule, ModuleWithProviders, SkipSelf, Optional } from '@angular/core'; +import { Configuration } from './configuration'; +import { HttpClient } from '@angular/common/http'; + + +@NgModule({ + imports: [], + declarations: [], + exports: [], + providers: [] +}) +export class ApiModule { + public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders { + return { + ngModule: ApiModule, + providers: [ { provide: Configuration, useFactory: configurationFactory } ] + }; + } + + constructor( @Optional() @SkipSelf() parentModule: ApiModule, + @Optional() http: HttpClient) { + if (parentModule) { + throw new Error('ApiModule is already loaded. Import in your base AppModule only.'); + } + if (!http) { + throw new Error('You need to import the HttpClientModule in your AppModule! \n' + + 'See also https://github.com/angular/angular/issues/20575'); + } + } +} diff --git a/webapp/src/app/core/modules/openapi/api/admin.service.ts b/webapp/src/app/core/modules/openapi/api/admin.service.ts new file mode 100644 index 00000000..aa1a5472 --- /dev/null +++ b/webapp/src/app/core/modules/openapi/api/admin.service.ts @@ -0,0 +1,687 @@ +/** + * Hephaestus API + * API documentation for the Hephaestus application server. + * + * The version of the OpenAPI document: 0.0.1 + * Contact: felixtj.dietrich@tum.de + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +/* tslint:disable:no-unused-variable member-ordering */ + +import { Inject, Injectable, Optional } from '@angular/core'; +import { HttpClient, HttpHeaders, HttpParams, + HttpResponse, HttpEvent, HttpParameterCodec, HttpContext + } from '@angular/common/http'; +import { CustomHttpParameterCodec } from '../encoder'; +import { Observable } from 'rxjs'; + +// @ts-ignore +import { AdminConfig } from '../model/admin-config'; +// @ts-ignore +import { AuthUserInfo } from '../model/auth-user-info'; +// @ts-ignore +import { TeamInfo } from '../model/team-info'; +// @ts-ignore +import { TeamInfoDTO } from '../model/team-info-dto'; +// @ts-ignore +import { UserInfo } from '../model/user-info'; +// @ts-ignore +import { UserTeams } from '../model/user-teams'; + +// @ts-ignore +import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; +import { Configuration } from '../configuration'; +import { + AdminServiceInterface +} from './admin.serviceInterface'; + + + +@Injectable({ + providedIn: 'root' +}) +export class AdminService implements AdminServiceInterface { + + protected basePath = 'http://localhost'; + public defaultHeaders = new HttpHeaders(); + public configuration = new Configuration(); + public encoder: HttpParameterCodec; + + constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string|string[], @Optional() configuration: Configuration) { + if (configuration) { + this.configuration = configuration; + } + if (typeof this.configuration.basePath !== 'string') { + const firstBasePath = Array.isArray(basePath) ? basePath[0] : undefined; + if (firstBasePath != undefined) { + basePath = firstBasePath; + } + + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; + } + this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); + } + + + // @ts-ignore + private addToHttpParams(httpParams: HttpParams, value: any, key?: string): HttpParams { + if (typeof value === "object" && value instanceof Date === false) { + httpParams = this.addToHttpParamsRecursive(httpParams, value); + } else { + httpParams = this.addToHttpParamsRecursive(httpParams, value, key); + } + return httpParams; + } + + private addToHttpParamsRecursive(httpParams: HttpParams, value?: any, key?: string): HttpParams { + if (value == null) { + return httpParams; + } + + if (typeof value === "object") { + if (Array.isArray(value)) { + (value as any[]).forEach( elem => httpParams = this.addToHttpParamsRecursive(httpParams, elem, key)); + } else if (value instanceof Date) { + if (key != null) { + httpParams = httpParams.append(key, (value as Date).toISOString().substring(0, 10)); + } else { + throw Error("key may not be null if value is Date"); + } + } else { + Object.keys(value).forEach( k => httpParams = this.addToHttpParamsRecursive( + httpParams, value[k], key != null ? `${key}.${k}` : k)); + } + } else if (key != null) { + httpParams = httpParams.append(key, value); + } else { + throw Error("key may not be null if value is not object or array"); + } + return httpParams; + } + + /** + * @param login + * @param teamId + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public addTeamToUser(login: string, teamId: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public addTeamToUser(login: string, teamId: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public addTeamToUser(login: string, teamId: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public addTeamToUser(login: string, teamId: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + if (login === null || login === undefined) { + throw new Error('Required parameter login was null or undefined when calling addTeamToUser.'); + } + if (teamId === null || teamId === undefined) { + throw new Error('Required parameter teamId was null or undefined when calling addTeamToUser.'); + } + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + let localVarTransferCache: boolean | undefined = options && options.transferCache; + if (localVarTransferCache === undefined) { + localVarTransferCache = true; + } + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/admin/users/teamadd/${this.configuration.encodeParam({name: "login", value: login, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/${this.configuration.encodeParam({name: "teamId", value: teamId, in: "path", style: "simple", explode: false, dataType: "number", dataFormat: "int64"})}`; + return this.httpClient.request('put', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + transferCache: localVarTransferCache, + reportProgress: reportProgress + } + ); + } + + /** + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public admin(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public admin(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public admin(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public admin(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + let localVarTransferCache: boolean | undefined = options && options.transferCache; + if (localVarTransferCache === undefined) { + localVarTransferCache = true; + } + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/admin`; + return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + transferCache: localVarTransferCache, + reportProgress: reportProgress + } + ); + } + + /** + * @param body + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public createTeam(body: TeamInfoDTO, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public createTeam(body: TeamInfoDTO, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public createTeam(body: TeamInfoDTO, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public createTeam(body: TeamInfoDTO, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling createTeam.'); + } + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + let localVarTransferCache: boolean | undefined = options && options.transferCache; + if (localVarTransferCache === undefined) { + localVarTransferCache = true; + } + + + // to determine the Content-Type header + const consumes: string[] = [ + 'application/json' + ]; + const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); + if (httpContentTypeSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); + } + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/admin/teams`; + return this.httpClient.request('put', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + body: body, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + transferCache: localVarTransferCache, + reportProgress: reportProgress + } + ); + } + + /** + * @param teamId + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public deleteTeam(teamId: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public deleteTeam(teamId: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public deleteTeam(teamId: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public deleteTeam(teamId: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + if (teamId === null || teamId === undefined) { + throw new Error('Required parameter teamId was null or undefined when calling deleteTeam.'); + } + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + let localVarTransferCache: boolean | undefined = options && options.transferCache; + if (localVarTransferCache === undefined) { + localVarTransferCache = true; + } + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/admin/teams/${this.configuration.encodeParam({name: "teamId", value: teamId, in: "path", style: "simple", explode: false, dataType: "number", dataFormat: "int64"})}`; + return this.httpClient.request('delete', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + transferCache: localVarTransferCache, + reportProgress: reportProgress + } + ); + } + + /** + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public getConfig(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public getConfig(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getConfig(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getConfig(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + let localVarTransferCache: boolean | undefined = options && options.transferCache; + if (localVarTransferCache === undefined) { + localVarTransferCache = true; + } + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/admin/config`; + return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + transferCache: localVarTransferCache, + reportProgress: reportProgress + } + ); + } + + /** + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public getGretting(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public getGretting(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getGretting(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getGretting(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + let localVarTransferCache: boolean | undefined = options && options.transferCache; + if (localVarTransferCache === undefined) { + localVarTransferCache = true; + } + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/admin/me`; + return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + transferCache: localVarTransferCache, + reportProgress: reportProgress + } + ); + } + + /** + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public getUsersAsAdmin(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getUsersAsAdmin(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; + public getUsersAsAdmin(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; + public getUsersAsAdmin(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + let localVarTransferCache: boolean | undefined = options && options.transferCache; + if (localVarTransferCache === undefined) { + localVarTransferCache = true; + } + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/admin/users`; + return this.httpClient.request>('get', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + transferCache: localVarTransferCache, + reportProgress: reportProgress + } + ); + } + + /** + * @param login + * @param teamId + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public removeTeamFromUser(login: string, teamId: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public removeTeamFromUser(login: string, teamId: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public removeTeamFromUser(login: string, teamId: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public removeTeamFromUser(login: string, teamId: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + if (login === null || login === undefined) { + throw new Error('Required parameter login was null or undefined when calling removeTeamFromUser.'); + } + if (teamId === null || teamId === undefined) { + throw new Error('Required parameter teamId was null or undefined when calling removeTeamFromUser.'); + } + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + let localVarTransferCache: boolean | undefined = options && options.transferCache; + if (localVarTransferCache === undefined) { + localVarTransferCache = true; + } + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/admin/users/teamremove/${this.configuration.encodeParam({name: "login", value: login, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/${this.configuration.encodeParam({name: "teamId", value: teamId, in: "path", style: "simple", explode: false, dataType: "number", dataFormat: "int64"})}`; + return this.httpClient.request('delete', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + transferCache: localVarTransferCache, + reportProgress: reportProgress + } + ); + } + + /** + * @param requestBody + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public updateRepositories(requestBody: Array, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public updateRepositories(requestBody: Array, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; + public updateRepositories(requestBody: Array, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; + public updateRepositories(requestBody: Array, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + if (requestBody === null || requestBody === undefined) { + throw new Error('Required parameter requestBody was null or undefined when calling updateRepositories.'); + } + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + let localVarTransferCache: boolean | undefined = options && options.transferCache; + if (localVarTransferCache === undefined) { + localVarTransferCache = true; + } + + + // to determine the Content-Type header + const consumes: string[] = [ + 'application/json' + ]; + const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); + if (httpContentTypeSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); + } + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/admin/config/repositories`; + return this.httpClient.request>('post', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + body: requestBody, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + transferCache: localVarTransferCache, + reportProgress: reportProgress + } + ); + } + +} diff --git a/webapp/src/app/core/modules/openapi/api/admin.serviceInterface.ts b/webapp/src/app/core/modules/openapi/api/admin.serviceInterface.ts new file mode 100644 index 00000000..7ff12cc4 --- /dev/null +++ b/webapp/src/app/core/modules/openapi/api/admin.serviceInterface.ts @@ -0,0 +1,92 @@ +/** + * Hephaestus API + * API documentation for the Hephaestus application server. + * + * The version of the OpenAPI document: 0.0.1 + * Contact: felixtj.dietrich@tum.de + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +import { HttpHeaders } from '@angular/common/http'; + +import { Observable } from 'rxjs'; + +import { AdminConfig } from '../model/models'; +import { AuthUserInfo } from '../model/models'; +import { TeamInfo } from '../model/models'; +import { UserInfo } from '../model/models'; +import { UserTeams } from '../model/models'; + + +import { Configuration } from '../configuration'; + + + +export interface AdminServiceInterface { + defaultHeaders: HttpHeaders; + configuration: Configuration; + + /** + * + * + * @param login + * @param teamId + */ + addTeamToUser(login: string, teamId: number, extraHttpRequestParams?: any): Observable; + + /** + * + * + */ + admin(extraHttpRequestParams?: any): Observable; + + /** + * + * + * @param body + */ + createTeam(body: TeamInfo, extraHttpRequestParams?: any): Observable; + + /** + * + * + * @param teamId + */ + deleteTeam(teamId: number, extraHttpRequestParams?: any): Observable; + + /** + * + * + */ + getConfig(extraHttpRequestParams?: any): Observable; + + /** + * + * + */ + getGretting(extraHttpRequestParams?: any): Observable; + + /** + * + * + */ + getUsersAsAdmin(extraHttpRequestParams?: any): Observable>; + + /** + * + * + * @param login + * @param teamId + */ + removeTeamFromUser(login: string, teamId: number, extraHttpRequestParams?: any): Observable; + + /** + * + * + * @param requestBody + */ + updateRepositories(requestBody: Array, extraHttpRequestParams?: any): Observable>; + +} diff --git a/webapp/src/app/core/modules/openapi/api/api.ts b/webapp/src/app/core/modules/openapi/api/api.ts new file mode 100644 index 00000000..2c090d4c --- /dev/null +++ b/webapp/src/app/core/modules/openapi/api/api.ts @@ -0,0 +1,16 @@ +export * from './admin.service'; +import { AdminService } from './admin.service'; +export * from './admin.serviceInterface'; +export * from './leaderboard.service'; +import { LeaderboardService } from './leaderboard.service'; +export * from './leaderboard.serviceInterface'; +export * from './meta.service'; +import { MetaService } from './meta.service'; +export * from './meta.serviceInterface'; +export * from './team.service'; +import { TeamService } from './team.service'; +export * from './team.serviceInterface'; +export * from './user.service'; +import { UserService } from './user.service'; +export * from './user.serviceInterface'; +export const APIS = [AdminService, LeaderboardService, MetaService, TeamService, UserService]; diff --git a/webapp/src/app/core/modules/openapi/api/leaderboard.service.ts b/webapp/src/app/core/modules/openapi/api/leaderboard.service.ts new file mode 100644 index 00000000..0e73a1a9 --- /dev/null +++ b/webapp/src/app/core/modules/openapi/api/leaderboard.service.ts @@ -0,0 +1,175 @@ +/** + * Hephaestus API + * API documentation for the Hephaestus application server. + * + * The version of the OpenAPI document: 0.0.1 + * Contact: felixtj.dietrich@tum.de + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +/* tslint:disable:no-unused-variable member-ordering */ + +import { Inject, Injectable, Optional } from '@angular/core'; +import { HttpClient, HttpHeaders, HttpParams, + HttpResponse, HttpEvent, HttpParameterCodec, HttpContext + } from '@angular/common/http'; +import { CustomHttpParameterCodec } from '../encoder'; +import { Observable } from 'rxjs'; + +// @ts-ignore +import { LeaderboardEntry } from '../model/leaderboard-entry'; + +// @ts-ignore +import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; +import { Configuration } from '../configuration'; +import { + LeaderboardServiceInterface +} from './leaderboard.serviceInterface'; + + + +@Injectable({ + providedIn: 'root' +}) +export class LeaderboardService implements LeaderboardServiceInterface { + + protected basePath = 'http://localhost'; + public defaultHeaders = new HttpHeaders(); + public configuration = new Configuration(); + public encoder: HttpParameterCodec; + + constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string|string[], @Optional() configuration: Configuration) { + if (configuration) { + this.configuration = configuration; + } + if (typeof this.configuration.basePath !== 'string') { + const firstBasePath = Array.isArray(basePath) ? basePath[0] : undefined; + if (firstBasePath != undefined) { + basePath = firstBasePath; + } + + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; + } + this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); + } + + + // @ts-ignore + private addToHttpParams(httpParams: HttpParams, value: any, key?: string): HttpParams { + if (typeof value === "object" && value instanceof Date === false) { + httpParams = this.addToHttpParamsRecursive(httpParams, value); + } else { + httpParams = this.addToHttpParamsRecursive(httpParams, value, key); + } + return httpParams; + } + + private addToHttpParamsRecursive(httpParams: HttpParams, value?: any, key?: string): HttpParams { + if (value == null) { + return httpParams; + } + + if (typeof value === "object") { + if (Array.isArray(value)) { + (value as any[]).forEach( elem => httpParams = this.addToHttpParamsRecursive(httpParams, elem, key)); + } else if (value instanceof Date) { + if (key != null) { + httpParams = httpParams.append(key, (value as Date).toISOString().substring(0, 10)); + } else { + throw Error("key may not be null if value is Date"); + } + } else { + Object.keys(value).forEach( k => httpParams = this.addToHttpParamsRecursive( + httpParams, value[k], key != null ? `${key}.${k}` : k)); + } + } else if (key != null) { + httpParams = httpParams.append(key, value); + } else { + throw Error("key may not be null if value is not object or array"); + } + return httpParams; + } + + /** + * @param after + * @param before + * @param team + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public getLeaderboard(after?: string, before?: string, team?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getLeaderboard(after?: string, before?: string, team?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; + public getLeaderboard(after?: string, before?: string, team?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; + public getLeaderboard(after?: string, before?: string, team?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + + let localVarQueryParameters = new HttpParams({encoder: this.encoder}); + if (after !== undefined && after !== null) { + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + after, 'after'); + } + if (before !== undefined && before !== null) { + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + before, 'before'); + } + if (team !== undefined && team !== null) { + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + team, 'team'); + } + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + let localVarTransferCache: boolean | undefined = options && options.transferCache; + if (localVarTransferCache === undefined) { + localVarTransferCache = true; + } + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/leaderboard`; + return this.httpClient.request>('get', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + params: localVarQueryParameters, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + transferCache: localVarTransferCache, + reportProgress: reportProgress + } + ); + } + +} diff --git a/webapp/src/app/core/modules/openapi/api/leaderboard.serviceInterface.ts b/webapp/src/app/core/modules/openapi/api/leaderboard.serviceInterface.ts new file mode 100644 index 00000000..8297cef6 --- /dev/null +++ b/webapp/src/app/core/modules/openapi/api/leaderboard.serviceInterface.ts @@ -0,0 +1,36 @@ +/** + * Hephaestus API + * API documentation for the Hephaestus application server. + * + * The version of the OpenAPI document: 0.0.1 + * Contact: felixtj.dietrich@tum.de + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +import { HttpHeaders } from '@angular/common/http'; + +import { Observable } from 'rxjs'; + +import { LeaderboardEntry } from '../model/models'; + + +import { Configuration } from '../configuration'; + + + +export interface LeaderboardServiceInterface { + defaultHeaders: HttpHeaders; + configuration: Configuration; + + /** + * + * + * @param after + * @param before + * @param team + */ + getLeaderboard(after?: string, before?: string, team?: string, extraHttpRequestParams?: any): Observable>; + +} diff --git a/webapp/src/app/core/modules/openapi/api/meta.service.ts b/webapp/src/app/core/modules/openapi/api/meta.service.ts new file mode 100644 index 00000000..9ea8e973 --- /dev/null +++ b/webapp/src/app/core/modules/openapi/api/meta.service.ts @@ -0,0 +1,157 @@ +/** + * Hephaestus API + * API documentation for the Hephaestus application server. + * + * The version of the OpenAPI document: 0.0.1 + * Contact: felixtj.dietrich@tum.de + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +/* tslint:disable:no-unused-variable member-ordering */ + +import { Inject, Injectable, Optional } from '@angular/core'; +import { HttpClient, HttpHeaders, HttpParams, + HttpResponse, HttpEvent, HttpParameterCodec, HttpContext + } from '@angular/common/http'; +import { CustomHttpParameterCodec } from '../encoder'; +import { Observable } from 'rxjs'; + +// @ts-ignore +import { MetaData } from '../model/meta-data'; + +// @ts-ignore +import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; +import { Configuration } from '../configuration'; +import { + MetaServiceInterface +} from './meta.serviceInterface'; + + + +@Injectable({ + providedIn: 'root' +}) +export class MetaService implements MetaServiceInterface { + + protected basePath = 'http://localhost'; + public defaultHeaders = new HttpHeaders(); + public configuration = new Configuration(); + public encoder: HttpParameterCodec; + + constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string|string[], @Optional() configuration: Configuration) { + if (configuration) { + this.configuration = configuration; + } + if (typeof this.configuration.basePath !== 'string') { + const firstBasePath = Array.isArray(basePath) ? basePath[0] : undefined; + if (firstBasePath != undefined) { + basePath = firstBasePath; + } + + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; + } + this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); + } + + + // @ts-ignore + private addToHttpParams(httpParams: HttpParams, value: any, key?: string): HttpParams { + if (typeof value === "object" && value instanceof Date === false) { + httpParams = this.addToHttpParamsRecursive(httpParams, value); + } else { + httpParams = this.addToHttpParamsRecursive(httpParams, value, key); + } + return httpParams; + } + + private addToHttpParamsRecursive(httpParams: HttpParams, value?: any, key?: string): HttpParams { + if (value == null) { + return httpParams; + } + + if (typeof value === "object") { + if (Array.isArray(value)) { + (value as any[]).forEach( elem => httpParams = this.addToHttpParamsRecursive(httpParams, elem, key)); + } else if (value instanceof Date) { + if (key != null) { + httpParams = httpParams.append(key, (value as Date).toISOString().substring(0, 10)); + } else { + throw Error("key may not be null if value is Date"); + } + } else { + Object.keys(value).forEach( k => httpParams = this.addToHttpParamsRecursive( + httpParams, value[k], key != null ? `${key}.${k}` : k)); + } + } else if (key != null) { + httpParams = httpParams.append(key, value); + } else { + throw Error("key may not be null if value is not object or array"); + } + return httpParams; + } + + /** + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public getMetaData(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public getMetaData(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getMetaData(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getMetaData(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + let localVarTransferCache: boolean | undefined = options && options.transferCache; + if (localVarTransferCache === undefined) { + localVarTransferCache = true; + } + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/meta`; + return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + transferCache: localVarTransferCache, + reportProgress: reportProgress + } + ); + } + +} diff --git a/webapp/src/app/core/modules/openapi/api/meta.serviceInterface.ts b/webapp/src/app/core/modules/openapi/api/meta.serviceInterface.ts new file mode 100644 index 00000000..693ec87e --- /dev/null +++ b/webapp/src/app/core/modules/openapi/api/meta.serviceInterface.ts @@ -0,0 +1,33 @@ +/** + * Hephaestus API + * API documentation for the Hephaestus application server. + * + * The version of the OpenAPI document: 0.0.1 + * Contact: felixtj.dietrich@tum.de + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +import { HttpHeaders } from '@angular/common/http'; + +import { Observable } from 'rxjs'; + +import { MetaData } from '../model/models'; + + +import { Configuration } from '../configuration'; + + + +export interface MetaServiceInterface { + defaultHeaders: HttpHeaders; + configuration: Configuration; + + /** + * + * + */ + getMetaData(extraHttpRequestParams?: any): Observable; + +} diff --git a/webapp/src/app/core/modules/openapi/api/team.service.ts b/webapp/src/app/core/modules/openapi/api/team.service.ts new file mode 100644 index 00000000..d45ae1dc --- /dev/null +++ b/webapp/src/app/core/modules/openapi/api/team.service.ts @@ -0,0 +1,157 @@ +/** + * Hephaestus API + * API documentation for the Hephaestus application server. + * + * The version of the OpenAPI document: 0.0.1 + * Contact: felixtj.dietrich@tum.de + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +/* tslint:disable:no-unused-variable member-ordering */ + +import { Inject, Injectable, Optional } from '@angular/core'; +import { HttpClient, HttpHeaders, HttpParams, + HttpResponse, HttpEvent, HttpParameterCodec, HttpContext + } from '@angular/common/http'; +import { CustomHttpParameterCodec } from '../encoder'; +import { Observable } from 'rxjs'; + +// @ts-ignore +import { TeamInfo } from '../model/team-info'; + +// @ts-ignore +import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; +import { Configuration } from '../configuration'; +import { + TeamServiceInterface +} from './team.serviceInterface'; + + + +@Injectable({ + providedIn: 'root' +}) +export class TeamService implements TeamServiceInterface { + + protected basePath = 'http://localhost'; + public defaultHeaders = new HttpHeaders(); + public configuration = new Configuration(); + public encoder: HttpParameterCodec; + + constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string|string[], @Optional() configuration: Configuration) { + if (configuration) { + this.configuration = configuration; + } + if (typeof this.configuration.basePath !== 'string') { + const firstBasePath = Array.isArray(basePath) ? basePath[0] : undefined; + if (firstBasePath != undefined) { + basePath = firstBasePath; + } + + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; + } + this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); + } + + + // @ts-ignore + private addToHttpParams(httpParams: HttpParams, value: any, key?: string): HttpParams { + if (typeof value === "object" && value instanceof Date === false) { + httpParams = this.addToHttpParamsRecursive(httpParams, value); + } else { + httpParams = this.addToHttpParamsRecursive(httpParams, value, key); + } + return httpParams; + } + + private addToHttpParamsRecursive(httpParams: HttpParams, value?: any, key?: string): HttpParams { + if (value == null) { + return httpParams; + } + + if (typeof value === "object") { + if (Array.isArray(value)) { + (value as any[]).forEach( elem => httpParams = this.addToHttpParamsRecursive(httpParams, elem, key)); + } else if (value instanceof Date) { + if (key != null) { + httpParams = httpParams.append(key, (value as Date).toISOString().substring(0, 10)); + } else { + throw Error("key may not be null if value is Date"); + } + } else { + Object.keys(value).forEach( k => httpParams = this.addToHttpParamsRecursive( + httpParams, value[k], key != null ? `${key}.${k}` : k)); + } + } else if (key != null) { + httpParams = httpParams.append(key, value); + } else { + throw Error("key may not be null if value is not object or array"); + } + return httpParams; + } + + /** + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public getTeams(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getTeams(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; + public getTeams(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; + public getTeams(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + let localVarTransferCache: boolean | undefined = options && options.transferCache; + if (localVarTransferCache === undefined) { + localVarTransferCache = true; + } + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/team/all`; + return this.httpClient.request>('get', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + transferCache: localVarTransferCache, + reportProgress: reportProgress + } + ); + } + +} diff --git a/webapp/src/app/core/modules/openapi/api/team.serviceInterface.ts b/webapp/src/app/core/modules/openapi/api/team.serviceInterface.ts new file mode 100644 index 00000000..c68387ce --- /dev/null +++ b/webapp/src/app/core/modules/openapi/api/team.serviceInterface.ts @@ -0,0 +1,33 @@ +/** + * Hephaestus API + * API documentation for the Hephaestus application server. + * + * The version of the OpenAPI document: 0.0.1 + * Contact: felixtj.dietrich@tum.de + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +import { HttpHeaders } from '@angular/common/http'; + +import { Observable } from 'rxjs'; + +import { TeamInfo } from '../model/models'; + + +import { Configuration } from '../configuration'; + + + +export interface TeamServiceInterface { + defaultHeaders: HttpHeaders; + configuration: Configuration; + + /** + * + * + */ + getTeams(extraHttpRequestParams?: any): Observable>; + +} diff --git a/webapp/src/app/core/modules/openapi/api/user.service.ts b/webapp/src/app/core/modules/openapi/api/user.service.ts new file mode 100644 index 00000000..413fbca9 --- /dev/null +++ b/webapp/src/app/core/modules/openapi/api/user.service.ts @@ -0,0 +1,161 @@ +/** + * Hephaestus API + * API documentation for the Hephaestus application server. + * + * The version of the OpenAPI document: 0.0.1 + * Contact: felixtj.dietrich@tum.de + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +/* tslint:disable:no-unused-variable member-ordering */ + +import { Inject, Injectable, Optional } from '@angular/core'; +import { HttpClient, HttpHeaders, HttpParams, + HttpResponse, HttpEvent, HttpParameterCodec, HttpContext + } from '@angular/common/http'; +import { CustomHttpParameterCodec } from '../encoder'; +import { Observable } from 'rxjs'; + +// @ts-ignore +import { UserProfile } from '../model/user-profile'; + +// @ts-ignore +import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; +import { Configuration } from '../configuration'; +import { + UserServiceInterface +} from './user.serviceInterface'; + + + +@Injectable({ + providedIn: 'root' +}) +export class UserService implements UserServiceInterface { + + protected basePath = 'http://localhost'; + public defaultHeaders = new HttpHeaders(); + public configuration = new Configuration(); + public encoder: HttpParameterCodec; + + constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string|string[], @Optional() configuration: Configuration) { + if (configuration) { + this.configuration = configuration; + } + if (typeof this.configuration.basePath !== 'string') { + const firstBasePath = Array.isArray(basePath) ? basePath[0] : undefined; + if (firstBasePath != undefined) { + basePath = firstBasePath; + } + + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; + } + this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); + } + + + // @ts-ignore + private addToHttpParams(httpParams: HttpParams, value: any, key?: string): HttpParams { + if (typeof value === "object" && value instanceof Date === false) { + httpParams = this.addToHttpParamsRecursive(httpParams, value); + } else { + httpParams = this.addToHttpParamsRecursive(httpParams, value, key); + } + return httpParams; + } + + private addToHttpParamsRecursive(httpParams: HttpParams, value?: any, key?: string): HttpParams { + if (value == null) { + return httpParams; + } + + if (typeof value === "object") { + if (Array.isArray(value)) { + (value as any[]).forEach( elem => httpParams = this.addToHttpParamsRecursive(httpParams, elem, key)); + } else if (value instanceof Date) { + if (key != null) { + httpParams = httpParams.append(key, (value as Date).toISOString().substring(0, 10)); + } else { + throw Error("key may not be null if value is Date"); + } + } else { + Object.keys(value).forEach( k => httpParams = this.addToHttpParamsRecursive( + httpParams, value[k], key != null ? `${key}.${k}` : k)); + } + } else if (key != null) { + httpParams = httpParams.append(key, value); + } else { + throw Error("key may not be null if value is not object or array"); + } + return httpParams; + } + + /** + * @param login + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public getUserProfile(login: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public getUserProfile(login: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getUserProfile(login: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getUserProfile(login: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + if (login === null || login === undefined) { + throw new Error('Required parameter login was null or undefined when calling getUserProfile.'); + } + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + let localVarTransferCache: boolean | undefined = options && options.transferCache; + if (localVarTransferCache === undefined) { + localVarTransferCache = true; + } + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/user/${this.configuration.encodeParam({name: "login", value: login, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/profile`; + return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + transferCache: localVarTransferCache, + reportProgress: reportProgress + } + ); + } + +} diff --git a/webapp/src/app/core/modules/openapi/api/user.serviceInterface.ts b/webapp/src/app/core/modules/openapi/api/user.serviceInterface.ts new file mode 100644 index 00000000..b3ccf040 --- /dev/null +++ b/webapp/src/app/core/modules/openapi/api/user.serviceInterface.ts @@ -0,0 +1,34 @@ +/** + * Hephaestus API + * API documentation for the Hephaestus application server. + * + * The version of the OpenAPI document: 0.0.1 + * Contact: felixtj.dietrich@tum.de + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +import { HttpHeaders } from '@angular/common/http'; + +import { Observable } from 'rxjs'; + +import { UserProfile } from '../model/models'; + + +import { Configuration } from '../configuration'; + + + +export interface UserServiceInterface { + defaultHeaders: HttpHeaders; + configuration: Configuration; + + /** + * + * + * @param login + */ + getUserProfile(login: string, extraHttpRequestParams?: any): Observable; + +} diff --git a/webapp/src/app/core/modules/openapi/configuration.ts b/webapp/src/app/core/modules/openapi/configuration.ts new file mode 100644 index 00000000..526b454f --- /dev/null +++ b/webapp/src/app/core/modules/openapi/configuration.ts @@ -0,0 +1,166 @@ +import { HttpParameterCodec } from '@angular/common/http'; +import { Param } from './param'; + +export interface ConfigurationParameters { + /** + * @deprecated Since 5.0. Use credentials instead + */ + apiKeys?: {[ key: string ]: string}; + username?: string; + password?: string; + /** + * @deprecated Since 5.0. Use credentials instead + */ + accessToken?: string | (() => string); + basePath?: string; + withCredentials?: boolean; + /** + * Takes care of encoding query- and form-parameters. + */ + encoder?: HttpParameterCodec; + /** + * Override the default method for encoding path parameters in various + * styles. + *

+ * See {@link README.md} for more details + *

+ */ + encodeParam?: (param: Param) => string; + /** + * The keys are the names in the securitySchemes section of the OpenAPI + * document. They should map to the value used for authentication + * minus any standard prefixes such as 'Basic' or 'Bearer'. + */ + credentials?: {[ key: string ]: string | (() => string | undefined)}; +} + +export class Configuration { + /** + * @deprecated Since 5.0. Use credentials instead + */ + apiKeys?: {[ key: string ]: string}; + username?: string; + password?: string; + /** + * @deprecated Since 5.0. Use credentials instead + */ + accessToken?: string | (() => string); + basePath?: string; + withCredentials?: boolean; + /** + * Takes care of encoding query- and form-parameters. + */ + encoder?: HttpParameterCodec; + /** + * Encoding of various path parameter + * styles. + *

+ * See {@link README.md} for more details + *

+ */ + encodeParam: (param: Param) => string; + /** + * The keys are the names in the securitySchemes section of the OpenAPI + * document. They should map to the value used for authentication + * minus any standard prefixes such as 'Basic' or 'Bearer'. + */ + credentials: {[ key: string ]: string | (() => string | undefined)}; + + constructor(configurationParameters: ConfigurationParameters = {}) { + this.apiKeys = configurationParameters.apiKeys; + this.username = configurationParameters.username; + this.password = configurationParameters.password; + this.accessToken = configurationParameters.accessToken; + this.basePath = configurationParameters.basePath; + this.withCredentials = configurationParameters.withCredentials; + this.encoder = configurationParameters.encoder; + if (configurationParameters.encodeParam) { + this.encodeParam = configurationParameters.encodeParam; + } + else { + this.encodeParam = param => this.defaultEncodeParam(param); + } + if (configurationParameters.credentials) { + this.credentials = configurationParameters.credentials; + } + else { + this.credentials = {}; + } + } + + /** + * Select the correct content-type to use for a request. + * Uses {@link Configuration#isJsonMime} to determine the correct content-type. + * If no content type is found return the first found type if the contentTypes is not empty + * @param contentTypes - the array of content types that are available for selection + * @returns the selected content-type or undefined if no selection could be made. + */ + public selectHeaderContentType (contentTypes: string[]): string | undefined { + if (contentTypes.length === 0) { + return undefined; + } + + const type = contentTypes.find((x: string) => this.isJsonMime(x)); + if (type === undefined) { + return contentTypes[0]; + } + return type; + } + + /** + * Select the correct accept content-type to use for a request. + * Uses {@link Configuration#isJsonMime} to determine the correct accept content-type. + * If no content type is found return the first found type if the contentTypes is not empty + * @param accepts - the array of content types that are available for selection. + * @returns the selected content-type or undefined if no selection could be made. + */ + public selectHeaderAccept(accepts: string[]): string | undefined { + if (accepts.length === 0) { + return undefined; + } + + const type = accepts.find((x: string) => this.isJsonMime(x)); + if (type === undefined) { + return accepts[0]; + } + return type; + } + + /** + * Check if the given MIME is a JSON MIME. + * JSON MIME examples: + * application/json + * application/json; charset=UTF8 + * APPLICATION/JSON + * application/vnd.company+json + * @param mime - MIME (Multipurpose Internet Mail Extensions) + * @return True if the given MIME is JSON, false otherwise. + */ + public isJsonMime(mime: string): boolean { + const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i'); + return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json'); + } + + public lookupCredential(key: string): string | undefined { + const value = this.credentials[key]; + return typeof value === 'function' + ? value() + : value; + } + + private defaultEncodeParam(param: Param): string { + // This implementation exists as fallback for missing configuration + // and for backwards compatibility to older typescript-angular generator versions. + // It only works for the 'simple' parameter style. + // Date-handling only works for the 'date-time' format. + // All other styles and Date-formats are probably handled incorrectly. + // + // But: if that's all you need (i.e.: the most common use-case): no need for customization! + + const value = param.dataFormat === 'date-time' && param.value instanceof Date + ? (param.value as Date).toISOString() + : param.value; + + return encodeURIComponent(String(value)); + } +} diff --git a/webapp/src/app/core/modules/openapi/encoder.ts b/webapp/src/app/core/modules/openapi/encoder.ts new file mode 100644 index 00000000..138c4d5c --- /dev/null +++ b/webapp/src/app/core/modules/openapi/encoder.ts @@ -0,0 +1,20 @@ +import { HttpParameterCodec } from '@angular/common/http'; + +/** + * Custom HttpParameterCodec + * Workaround for https://github.com/angular/angular/issues/18261 + */ +export class CustomHttpParameterCodec implements HttpParameterCodec { + encodeKey(k: string): string { + return encodeURIComponent(k); + } + encodeValue(v: string): string { + return encodeURIComponent(v); + } + decodeKey(k: string): string { + return decodeURIComponent(k); + } + decodeValue(v: string): string { + return decodeURIComponent(v); + } +} diff --git a/webapp/src/app/core/modules/openapi/git_push.sh b/webapp/src/app/core/modules/openapi/git_push.sh new file mode 100644 index 00000000..f53a75d4 --- /dev/null +++ b/webapp/src/app/core/modules/openapi/git_push.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/webapp/src/app/core/modules/openapi/index.ts b/webapp/src/app/core/modules/openapi/index.ts new file mode 100644 index 00000000..104dd3d2 --- /dev/null +++ b/webapp/src/app/core/modules/openapi/index.ts @@ -0,0 +1,6 @@ +export * from './api/api'; +export * from './model/models'; +export * from './variables'; +export * from './configuration'; +export * from './api.module'; +export * from './param'; diff --git a/webapp/src/app/core/modules/openapi/model/admin-config.ts b/webapp/src/app/core/modules/openapi/model/admin-config.ts new file mode 100644 index 00000000..f59e8c37 --- /dev/null +++ b/webapp/src/app/core/modules/openapi/model/admin-config.ts @@ -0,0 +1,17 @@ +/** + * Hephaestus API + * API documentation for the Hephaestus application server. + * + * The version of the OpenAPI document: 0.0.1 + * Contact: felixtj.dietrich@tum.de + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export interface AdminConfig { + repositoriesToMonitor: Set; +} + diff --git a/webapp/src/app/core/modules/openapi/model/auth-user-info.ts b/webapp/src/app/core/modules/openapi/model/auth-user-info.ts new file mode 100644 index 00000000..6eaf9b25 --- /dev/null +++ b/webapp/src/app/core/modules/openapi/model/auth-user-info.ts @@ -0,0 +1,18 @@ +/** + * Hephaestus API + * API documentation for the Hephaestus application server. + * + * The version of the OpenAPI document: 0.0.1 + * Contact: felixtj.dietrich@tum.de + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export interface AuthUserInfo { + name?: string; + roles?: Array; +} + diff --git a/webapp/src/app/core/modules/openapi/model/label-info.ts b/webapp/src/app/core/modules/openapi/model/label-info.ts new file mode 100644 index 00000000..3eac7c02 --- /dev/null +++ b/webapp/src/app/core/modules/openapi/model/label-info.ts @@ -0,0 +1,19 @@ +/** + * Hephaestus API + * API documentation for the Hephaestus application server. + * + * The version of the OpenAPI document: 0.0.1 + * Contact: felixtj.dietrich@tum.de + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export interface LabelInfo { + id: number; + name: string; + color: string; +} + diff --git a/webapp/src/app/core/modules/openapi/model/leaderboard-entry.ts b/webapp/src/app/core/modules/openapi/model/leaderboard-entry.ts new file mode 100644 index 00000000..c29e816f --- /dev/null +++ b/webapp/src/app/core/modules/openapi/model/leaderboard-entry.ts @@ -0,0 +1,26 @@ +/** + * Hephaestus API + * API documentation for the Hephaestus application server. + * + * The version of the OpenAPI document: 0.0.1 + * Contact: felixtj.dietrich@tum.de + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +import { UserInfo } from './user-info'; + + +export interface LeaderboardEntry { + rank: number; + score: number; + user: UserInfo; + numberOfReviewedPRs: number; + numberOfApprovals: number; + numberOfChangeRequests: number; + numberOfComments: number; + numberOfUnknowns: number; + numberOfCodeComments: number; +} + diff --git a/webapp/src/app/core/modules/openapi/model/meta-data.ts b/webapp/src/app/core/modules/openapi/model/meta-data.ts new file mode 100644 index 00000000..6e8dcc24 --- /dev/null +++ b/webapp/src/app/core/modules/openapi/model/meta-data.ts @@ -0,0 +1,17 @@ +/** + * Hephaestus API + * API documentation for the Hephaestus application server. + * + * The version of the OpenAPI document: 0.0.1 + * Contact: felixtj.dietrich@tum.de + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export interface MetaData { + repositoriesToMonitor?: Array; +} + diff --git a/webapp/src/app/core/modules/openapi/model/models.ts b/webapp/src/app/core/modules/openapi/model/models.ts new file mode 100644 index 00000000..ce361e43 --- /dev/null +++ b/webapp/src/app/core/modules/openapi/model/models.ts @@ -0,0 +1,13 @@ +export * from './admin-config'; +export * from './auth-user-info'; +export * from './label-info'; +export * from './leaderboard-entry'; +export * from './meta-data'; +export * from './pull-request-base-info'; +export * from './pull-request-info'; +export * from './pull-request-review-info'; +export * from './repository-info'; +export * from './team-info'; +export * from './user-info'; +export * from './user-profile'; +export * from './user-teams'; diff --git a/webapp/src/app/core/modules/openapi/model/pull-request-base-info.ts b/webapp/src/app/core/modules/openapi/model/pull-request-base-info.ts new file mode 100644 index 00000000..87bffe0b --- /dev/null +++ b/webapp/src/app/core/modules/openapi/model/pull-request-base-info.ts @@ -0,0 +1,33 @@ +/** + * Hephaestus API + * API documentation for the Hephaestus application server. + * + * The version of the OpenAPI document: 0.0.1 + * Contact: felixtj.dietrich@tum.de + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +import { RepositoryInfo } from './repository-info'; + + +export interface PullRequestBaseInfo { + id: number; + number: number; + title: string; + state: PullRequestBaseInfo.StateEnum; + isDraft: boolean; + isMerged: boolean; + repository?: RepositoryInfo; + htmlUrl: string; +} +export namespace PullRequestBaseInfo { + export type StateEnum = 'OPEN' | 'CLOSED'; + export const StateEnum = { + Open: 'OPEN' as StateEnum, + Closed: 'CLOSED' as StateEnum + }; +} + + diff --git a/webapp/src/app/core/modules/openapi/model/pull-request-info.ts b/webapp/src/app/core/modules/openapi/model/pull-request-info.ts new file mode 100644 index 00000000..89247cb7 --- /dev/null +++ b/webapp/src/app/core/modules/openapi/model/pull-request-info.ts @@ -0,0 +1,45 @@ +/** + * Hephaestus API + * API documentation for the Hephaestus application server. + * + * The version of the OpenAPI document: 0.0.1 + * Contact: felixtj.dietrich@tum.de + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +import { LabelInfo } from './label-info'; +import { RepositoryInfo } from './repository-info'; +import { UserInfo } from './user-info'; + + +export interface PullRequestInfo { + id: number; + number: number; + title: string; + state: PullRequestInfo.StateEnum; + isDraft: boolean; + isMerged: boolean; + commentsCount: number; + author?: UserInfo; + labels?: Array; + assignees?: Array; + repository?: RepositoryInfo; + additions: number; + deletions: number; + mergedAt?: string; + closedAt?: string; + htmlUrl: string; + createdAt?: string; + updatedAt?: string; +} +export namespace PullRequestInfo { + export type StateEnum = 'OPEN' | 'CLOSED'; + export const StateEnum = { + Open: 'OPEN' as StateEnum, + Closed: 'CLOSED' as StateEnum + }; +} + + diff --git a/webapp/src/app/core/modules/openapi/model/pull-request-review-info.ts b/webapp/src/app/core/modules/openapi/model/pull-request-review-info.ts new file mode 100644 index 00000000..d9f4d53b --- /dev/null +++ b/webapp/src/app/core/modules/openapi/model/pull-request-review-info.ts @@ -0,0 +1,36 @@ +/** + * Hephaestus API + * API documentation for the Hephaestus application server. + * + * The version of the OpenAPI document: 0.0.1 + * Contact: felixtj.dietrich@tum.de + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +import { PullRequestBaseInfo } from './pull-request-base-info'; +import { UserInfo } from './user-info'; + + +export interface PullRequestReviewInfo { + id: number; + isDismissed: boolean; + state: PullRequestReviewInfo.StateEnum; + codeComments: number; + author?: UserInfo; + pullRequest?: PullRequestBaseInfo; + htmlUrl: string; + submittedAt?: string; +} +export namespace PullRequestReviewInfo { + export type StateEnum = 'COMMENTED' | 'APPROVED' | 'CHANGES_REQUESTED' | 'UNKNOWN'; + export const StateEnum = { + Commented: 'COMMENTED' as StateEnum, + Approved: 'APPROVED' as StateEnum, + ChangesRequested: 'CHANGES_REQUESTED' as StateEnum, + Unknown: 'UNKNOWN' as StateEnum + }; +} + + diff --git a/webapp/src/app/core/modules/openapi/model/repository-info.ts b/webapp/src/app/core/modules/openapi/model/repository-info.ts new file mode 100644 index 00000000..42dcf703 --- /dev/null +++ b/webapp/src/app/core/modules/openapi/model/repository-info.ts @@ -0,0 +1,21 @@ +/** + * Hephaestus API + * API documentation for the Hephaestus application server. + * + * The version of the OpenAPI document: 0.0.1 + * Contact: felixtj.dietrich@tum.de + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export interface RepositoryInfo { + id: number; + name: string; + nameWithOwner: string; + description?: string; + htmlUrl: string; +} + diff --git a/webapp/src/app/core/modules/openapi/model/team-info.ts b/webapp/src/app/core/modules/openapi/model/team-info.ts new file mode 100644 index 00000000..de1d274c --- /dev/null +++ b/webapp/src/app/core/modules/openapi/model/team-info.ts @@ -0,0 +1,19 @@ +/** + * Hephaestus API + * API documentation for the Hephaestus application server. + * + * The version of the OpenAPI document: 0.0.1 + * Contact: felixtj.dietrich@tum.de + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export interface TeamInfo { + id: number; + name: string; + color: string; +} + diff --git a/webapp/src/app/core/modules/openapi/model/user-info.ts b/webapp/src/app/core/modules/openapi/model/user-info.ts new file mode 100644 index 00000000..ced80a51 --- /dev/null +++ b/webapp/src/app/core/modules/openapi/model/user-info.ts @@ -0,0 +1,21 @@ +/** + * Hephaestus API + * API documentation for the Hephaestus application server. + * + * The version of the OpenAPI document: 0.0.1 + * Contact: felixtj.dietrich@tum.de + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export interface UserInfo { + id: number; + login: string; + avatarUrl: string; + name: string; + htmlUrl: string; +} + diff --git a/webapp/src/app/core/modules/openapi/model/user-profile.ts b/webapp/src/app/core/modules/openapi/model/user-profile.ts new file mode 100644 index 00000000..86463a2b --- /dev/null +++ b/webapp/src/app/core/modules/openapi/model/user-profile.ts @@ -0,0 +1,25 @@ +/** + * Hephaestus API + * API documentation for the Hephaestus application server. + * + * The version of the OpenAPI document: 0.0.1 + * Contact: felixtj.dietrich@tum.de + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +import { PullRequestInfo } from './pull-request-info'; +import { PullRequestReviewInfo } from './pull-request-review-info'; +import { RepositoryInfo } from './repository-info'; +import { UserInfo } from './user-info'; + + +export interface UserProfile { + userInfo: UserInfo; + firstContribution: string; + contributedRepositories: Array; + reviewActivity?: Array; + openPullRequests?: Array; +} + diff --git a/webapp/src/app/core/modules/openapi/model/user-teams.ts b/webapp/src/app/core/modules/openapi/model/user-teams.ts new file mode 100644 index 00000000..b1ef01f5 --- /dev/null +++ b/webapp/src/app/core/modules/openapi/model/user-teams.ts @@ -0,0 +1,22 @@ +/** + * Hephaestus API + * API documentation for the Hephaestus application server. + * + * The version of the OpenAPI document: 0.0.1 + * Contact: felixtj.dietrich@tum.de + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +import { TeamInfo } from './team-info'; + + +export interface UserTeams { + id: number; + login: string; + name: string; + url: string; + teams: Set; +} + diff --git a/webapp/src/app/core/modules/openapi/param.ts b/webapp/src/app/core/modules/openapi/param.ts new file mode 100644 index 00000000..78a2d20a --- /dev/null +++ b/webapp/src/app/core/modules/openapi/param.ts @@ -0,0 +1,69 @@ +/** + * Standard parameter styles defined by OpenAPI spec + */ +export type StandardParamStyle = + | 'matrix' + | 'label' + | 'form' + | 'simple' + | 'spaceDelimited' + | 'pipeDelimited' + | 'deepObject' + ; + +/** + * The OpenAPI standard {@link StandardParamStyle}s may be extended by custom styles by the user. + */ +export type ParamStyle = StandardParamStyle | string; + +/** + * Standard parameter locations defined by OpenAPI spec + */ +export type ParamLocation = 'query' | 'header' | 'path' | 'cookie'; + +/** + * Standard types as defined in OpenAPI Specification: Data Types + */ +export type StandardDataType = + | "integer" + | "number" + | "boolean" + | "string" + | "object" + | "array" + ; + +/** + * Standard {@link DataType}s plus your own types/classes. + */ +export type DataType = StandardDataType | string; + +/** + * Standard formats as defined in OpenAPI Specification: Data Types + */ +export type StandardDataFormat = + | "int32" + | "int64" + | "float" + | "double" + | "byte" + | "binary" + | "date" + | "date-time" + | "password" + ; + +export type DataFormat = StandardDataFormat | string; + +/** + * The parameter to encode. + */ +export interface Param { + name: string; + value: unknown; + in: ParamLocation; + style: ParamStyle, + explode: boolean; + dataType: DataType; + dataFormat: DataFormat | undefined; +} diff --git a/webapp/src/app/core/modules/openapi/variables.ts b/webapp/src/app/core/modules/openapi/variables.ts new file mode 100644 index 00000000..6fe58549 --- /dev/null +++ b/webapp/src/app/core/modules/openapi/variables.ts @@ -0,0 +1,9 @@ +import { InjectionToken } from '@angular/core'; + +export const BASE_PATH = new InjectionToken('basePath'); +export const COLLECTION_FORMATS = { + 'csv': ',', + 'tsv': ' ', + 'ssv': ' ', + 'pipes': '|' +} diff --git a/webapp/src/app/ui/github-label/github-label.component.ts b/webapp/src/app/ui/github-label/github-label.component.ts index 2cf36870..9a1a57fd 100644 --- a/webapp/src/app/ui/github-label/github-label.component.ts +++ b/webapp/src/app/ui/github-label/github-label.component.ts @@ -1,5 +1,5 @@ import { Component, computed, input } from '@angular/core'; -import type { PullRequestLabel } from '@app/core/modules/openapi'; +import type { LabelInfo } from '@app/core/modules/openapi'; import { HlmSkeletonModule } from '@spartan-ng/ui-skeleton-helm'; @Component({ @@ -27,11 +27,14 @@ import { HlmSkeletonModule } from '@spartan-ng/ui-skeleton-helm'; }) export class GithubLabelComponent { isLoading = input(false); - label = input.required(); + label = input.required(); protected colors = computed(() => this.hexToRgb(this.label().color ?? 'FFFFFF')); hexToRgb(hex: string) { + if (hex.charAt(0) === '#') { + hex = hex.slice(1); + } const bigint = parseInt(hex, 16); const r = (bigint >> 16) & 255; const g = (bigint >> 8) & 255;