Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Connect PR data in client #68

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/deploy_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,5 @@ jobs:
proxy_port: ${{ vars.DEPLOYMENT_GATEWAY_PORT }}
script: |
cd ${{ vars.WORKING_DIR }}
docker compose -f compose.prod.yaml --env-file=.env up --pull=always -d
docker compose -f compose.prod.yaml --env-file=.env up --pull=always -d
docker restart nginx
14 changes: 13 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
{
"java.debug.settings.hotCodeReplace": "auto",
"java.configuration.updateBuildConfiguration": "interactive"
"java.configuration.updateBuildConfiguration": "interactive",
"sqltools.connections": [
{
"previewLimit": 50,
"server": "localhost",
"port": 5432,
"driver": "PostgreSQL",
"name": "application-service-dev",
"password": "helios",
"username": "helios",
"database": "helios"
}
]
}
8 changes: 4 additions & 4 deletions client/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@
"budgets": [
{
"type": "initial",
"maximumWarning": "500kB",
"maximumError": "1MB"
"maximumWarning": "2mb",
"maximumError": "2.5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "4kB",
"maximumError": "8kB"
"maximumWarning": "6kb",
"maximumError": "10kb"
Comment on lines -48 to +54
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I increased those limits but we need to have a Github action (in the future) to check if the build passes or not. Because when I was trying, the build step was failing due to the limits.

}
],
"outputHashing": "all"
Expand Down
1 change: 1 addition & 0 deletions client/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = [
},
{
files: ['src/**/*.ts'],
extends: [ 'prettier'],
languageOptions: {
parser: typescriptParser,
parserOptions: {
Expand Down
3 changes: 2 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@angular/router": "^19.0.0-next.0",
"@tanstack/angular-query-experimental": "^5.60.5",
"angular-tabler-icons": "^3.1.0",
"eslint-config-prettier": "^9.1.0",
"primeicons": "^7.0.0",
"primeng": "^17.18.11",
"rxjs": "~7.8.0",
Expand Down Expand Up @@ -54,4 +55,4 @@
"tailwindcss": "^3.4.14",
"typescript": "~5.6.2"
}
}
}
2 changes: 1 addition & 1 deletion client/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class AppComponent implements OnInit {
{
label: 'CI/CD',
icon: 'arrow-guide',
path: '/pr/list',
path: '/ci-cd',
},
{
label: 'Release Management',
Expand Down
20 changes: 19 additions & 1 deletion client/src/app/app.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
import { ApplicationConfig, provideExperimentalZonelessChangeDetection } from '@angular/core';
import { provideRouter, withComponentInputBinding } from '@angular/router';
import { provideTanStackQuery, QueryClient } from '@tanstack/angular-query-experimental';
import { provideQueryClient, provideTanStackQuery, QueryClient } from '@tanstack/angular-query-experimental';

import { routes } from './app.routes';
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
import { MessageService } from 'primeng/api';
import { provideHttpClient } from '@angular/common/http';
import { provideAnimations } from '@angular/platform-browser/animations';
import { BASE_PATH } from './core/modules/openapi';
import { environment } from 'environments/environment';

const queryClient = new QueryClient({
defaultOptions: {
queries: {
refetchOnWindowFocus: false, // default true
staleTime: 1000 * 60 * 5, // 5 minutes
retry: 2,
},
},
});

export const appConfig: ApplicationConfig = {
providers: [
Expand All @@ -13,5 +27,9 @@ export const appConfig: ApplicationConfig = {
provideAnimationsAsync(),
provideTanStackQuery(new QueryClient()),
MessageService,
provideHttpClient(),
provideAnimations(),
provideQueryClient(queryClient),
{ provide: BASE_PATH, useValue: environment.serverUrl },
],
};
13 changes: 6 additions & 7 deletions client/src/app/app.routes.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Routes } from '@angular/router';
import { EnvironmentListComponent } from './pages/environment-list/environment-list.component';
import { CiCdComponent } from './pages/ci-cd/ci-cd.component';
import { EnvironmentEditComponent } from './pages/environment-edit/environment-edit.component';
import { PrListComponent } from './pages/pr-list/pr-list.component';
import { ReleaseComponent } from './pages/release/release.component';
import { EnvironmentListComponent } from './pages/environment-list/environment-list.component';
import { PageNotFoundComponent } from './pages/page-not-found/page-not-found.component';
import { ReleaseComponent } from './pages/release/release.component';

export const routes: Routes = [
{ path: '', redirectTo: 'pr/list', pathMatch: 'full' },
{ path: '', redirectTo: 'ci-cd', pathMatch: 'full' },
{
path: 'environment',
children: [
Expand All @@ -20,10 +20,9 @@ export const routes: Routes = [
children: [{ path: '', component: ReleaseComponent }],
},
{
path: 'pr',
path: 'ci-cd',
children: [
{ path: '', redirectTo: 'list', pathMatch: 'full' },
{ path: 'list', component: PrListComponent },
{ path: '', component: CiCdComponent },
],
},
{
Expand Down
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this loading doesn't look that good, but I think it is the default one from the library 😞

Dec-02-2024 07-37-49

For the next week maybe we can also talk about loading animation for pages, I am not sure

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<p-table [value]="pullRequests()" [loading]="isLoading()" styleClass="p-datatable-sm">
<ng-template pTemplate="header">
<tr>
<th>Title</th>
<th>Draft</th>
<th>Status</th>
<th>Author</th>
<th>Assignee</th>
<th>Created</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-pr>
<tr>
<td>
<div class="flex align-items-center gap-2">
<span class="font-bold">{{ pr.title }}</span>
<button pButton class="p-button-text p-button-sm" (click)="openPR(pr.htmlUrl)"><i-tabler name="external-link"></i-tabler></button>
</div>
</td>
<td>
<p-tag *ngIf="pr.isDraft" value="Draft" severity="secondary"> </p-tag>
</td>
<td>
<p-tag [value]="getStatus(pr)" [severity]="getStatusSeverity(pr)"> </p-tag>
</td>
<td>
<div class="flex align-items-center gap-2">
<p-avatar [image]="pr.author.avatarUrl" shape="circle" size="normal"> </p-avatar>
<span>{{ pr.author.name }}</span>
</div>
</td>
<td>
<div class="flex align-items-center gap-2" *ngIf="pr.assignees?.length">
<p-avatar *ngFor="let assignee of pr.assignees" [image]="assignee.avatarUrl" shape="circle" size="normal"> </p-avatar>
</div>
</td>
<td>
{{ formatDate(pr.createdAt) }}
</td>
</tr>
</ng-template>
</p-table>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { PullRequestTableComponent } from './pull-request-table.component';

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

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [PullRequestTableComponent]
})
.compileComponents();

fixture = TestBed.createComponent(PullRequestTableComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the initial run it creates the table but after switching tabs, the table stuck at loading state.
(also checked the network tab and it doesn't make a new request)

Dec-02-2024 07-43-06

Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { Component, inject, signal } from '@angular/core';
import { CommonModule } from '@angular/common';
import { TableModule } from 'primeng/table';
import { AvatarModule } from 'primeng/avatar';
import { TagModule } from 'primeng/tag';
import { injectQuery } from '@tanstack/angular-query-experimental';
import { tap } from 'rxjs';
import { IconsModule } from 'icons.module';
import { PullRequestControllerService, PullRequestInfoDTO } from '@app/core/modules/openapi';


@Component({
selector: 'app-pull-request-table',
imports: [CommonModule, TableModule, AvatarModule, TagModule, IconsModule],
templateUrl: './pull-request-table.component.html',
styles: [`
:host ::ng-deep {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not an expert on this but is it ok to use ng-deep in component or in general?

.p-avatar {
img {
width: 100%;
height: 100%;
object-fit: cover;
}
}
}
`]
})
export class PullRequestTableComponent {
pullRequestService = inject(PullRequestControllerService);


pullRequests = signal<PullRequestInfoDTO[]>([]);
isLoading = signal(true);

query = injectQuery(() => ({
queryKey: ['pullRequests'],
queryFn: () => this.pullRequestService.getAllPullRequests()
.pipe(
tap(data => {
this.pullRequests.set(data);
this.isLoading.set(false);
})
).subscribe(),
}));

getStatus(pr: PullRequestInfoDTO): string {
if (pr.isMerged) return 'Merged';
return pr.state === 'OPEN' ? 'Open' : 'Closed';
}

getStatusSeverity(pr: PullRequestInfoDTO): ('success' | 'danger' | 'info') {
if (pr.isMerged) return 'info';
return pr.state === 'OPEN' ? 'success' : 'danger';
}

formatDate(date: string): string {
return new Date(date).toLocaleDateString('en-US', {
year: 'numeric',
month: 'short',
day: 'numeric'
});
}

openPR(url: string): void {
window.open(url, '_blank');
}
}
Empty file.
6 changes: 6 additions & 0 deletions client/src/app/pages/ci-cd/ci-cd.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<p-tabView>
<p-tabPanel header="Pull Requests">
<app-pull-request-table></app-pull-request-table>
</p-tabPanel>
<p-tabPanel header="Branches"> Branch List view goes here </p-tabPanel>
</p-tabView>
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { PrListComponent } from './pr-list.component';
import { CiCdComponent } from './ci-cd.component';

describe('PrListComponent', () => {
let component: PrListComponent;
let fixture: ComponentFixture<PrListComponent>;
describe('CiCdComponent', () => {
let component: CiCdComponent;
let fixture: ComponentFixture<CiCdComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [PrListComponent],
}).compileComponents();
imports: [CiCdComponent]
})
.compileComponents();

fixture = TestBed.createComponent(PrListComponent);
fixture = TestBed.createComponent(CiCdComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
Expand Down
10 changes: 10 additions & 0 deletions client/src/app/pages/ci-cd/ci-cd.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Component } from '@angular/core';
import { PullRequestTableComponent } from '@app/components/pull-request-table/pull-request-table.component';
import { TabViewModule } from 'primeng/tabview';
@Component({
selector: 'app-ci-cd',
imports: [PullRequestTableComponent, TabViewModule],
templateUrl: './ci-cd.component.html',
styleUrl: './ci-cd.component.css'
})
export class CiCdComponent {}
1 change: 0 additions & 1 deletion client/src/app/pages/pr-list/pr-list.component.html

This file was deleted.

9 changes: 0 additions & 9 deletions client/src/app/pages/pr-list/pr-list.component.ts

This file was deleted.

2 changes: 1 addition & 1 deletion client/src/environments/environment.dev.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const environment = {
clientUrl: 'http://localhost:4200',
production: false,
serverUrl: 'http://localhost:8080',
};
4 changes: 2 additions & 2 deletions client/src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const environment = {
clientUrl: 'http://localhost:4200',
serverUrl: 'http://localhost:8080',
production: true,
serverUrl: 'https://helios.artemis.cit.tum.de',
};
2 changes: 1 addition & 1 deletion client/src/environments/environment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const environment = {
clientUrl: 'http://localhost:4200',
production: false,
serverUrl: 'http://localhost:8080',
};
2 changes: 2 additions & 0 deletions client/src/icons.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
IconLockOpen,
IconPencil,
IconUser,
IconBrandGithub,
} from 'angular-tabler-icons/icons';

// Select some icons (use an object, not an array)
Expand All @@ -36,6 +37,7 @@ const icons = {
IconExternalLink,
IconPencil,
IconHistory,
IconBrandGithub
};

@NgModule({
Expand Down
5 changes: 5 additions & 0 deletions client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4117,6 +4117,11 @@ escape-string-regexp@^4.0.0:
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34"
integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==

eslint-config-prettier@^9.1.0:
version "9.1.0"
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz#31af3d94578645966c082fcb71a5846d3c94867f"
integrity sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==

eslint-import-resolver-node@^0.3.9:
version "0.3.9"
resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz#d4eaac52b8a2e7c3cd1903eb00f7e053356118ac"
Expand Down
Loading