-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/set-up-intelligence-service
- Loading branch information
Showing
12 changed files
with
257 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
documentation: | ||
- changed-files: | ||
- any-glob-to-any-file: docs/** | ||
|
||
client: | ||
- changed-files: | ||
- any-glob-to-any-file: webapp/** | ||
|
||
application-server: | ||
- changed-files: | ||
- any-glob-to-any-file: server/application-server/** | ||
|
||
intelligence-service: | ||
- changed-files: | ||
- any-glob-to-any-file: "server/intelligence-service/**" | ||
|
||
feature: | ||
- head-branch: ['^feature', 'feature', '^feat', 'feat'] | ||
|
||
bug: | ||
- head-branch: ['^fix', 'fix', '^bug', 'bug'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: "Pull Request Labeler" | ||
on: | ||
pull_request_target: | ||
|
||
jobs: | ||
labeler: | ||
name: "Apply labels" | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
steps: | ||
- name: "Checkout repository" | ||
uses: actions/checkout@v4 | ||
|
||
- uses: actions/labeler@v5 | ||
with: | ||
configuration-path: .github/labeler.yml | ||
|
||
- name: "Apply size label" | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
console.log("Fetching pull request diff..."); | ||
const diff = await github.rest.pulls.get({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
pull_number: context.issue.number, | ||
mediaType: { | ||
format: "diff", | ||
}, | ||
}); | ||
console.log("Pull request diff fetched successfully."); | ||
const changedLines = diff.data | ||
.split("\n") | ||
.filter(line => line.startsWith('+') || line.startsWith('-')) | ||
.length; | ||
console.log(`Number of changed lines: ${changedLines}`); | ||
let label = ''; | ||
if (changedLines > 1000) label = 'size:XXL'; | ||
else if (changedLines > 499) label = 'size:XL'; | ||
else if (changedLines > 99) label = 'size:L'; | ||
else if (changedLines > 29) label = 'size:M'; | ||
else if (changedLines > 9) label = 'size:S'; | ||
else label = 'size:XS'; | ||
if (label) { | ||
console.log(`Applying label "${label}" to the pull request...`); | ||
await github.rest.issues.addLabels({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.issue.number, | ||
labels: [label] | ||
}); | ||
console.log(`Label "${label}" applied successfully.`); | ||
} else { | ||
console.log("No label to apply."); | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
on: | ||
pull_request: | ||
types: [opened] | ||
name: Pull Request | ||
jobs: | ||
assignAuthor: | ||
name: Assign author to PR | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Assign author to PR | ||
uses: technote-space/assign-author@v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
webapp/src/app/components/theme-switcher/theme-switcher.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<app-button (click)="toggleTheme()" variant="outline" size="icon"> | ||
<div [@iconTrigger]="this.themeSwitcherService.currentTheme() ?? 'dark'"> | ||
<lucide-angular [name]="this.themeSwitcherService.currentTheme() === 'dark' ? 'sun' : 'moon'" class="size-5" /> | ||
</div> | ||
</app-button> |
30 changes: 30 additions & 0 deletions
30
webapp/src/app/components/theme-switcher/theme-switcher.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Component, inject } from '@angular/core'; | ||
import { LucideAngularModule } from 'lucide-angular'; | ||
import { ButtonComponent } from 'app/ui/button/button.component'; | ||
import { AppTheme, ThemeSwitcherService } from './theme-switcher.service'; | ||
import { animate, state, style, transition, trigger } from '@angular/animations'; | ||
|
||
@Component({ | ||
selector: 'app-theme-switcher', | ||
standalone: true, | ||
imports: [ButtonComponent, LucideAngularModule], | ||
templateUrl: './theme-switcher.component.html', | ||
animations: [ | ||
trigger('iconTrigger', [ | ||
state('*', style({ transform: 'rotate(0deg)' })), | ||
transition('light => dark', animate('0.25s ease-out', style({ transform: 'rotate(90deg)' }))), | ||
transition('dark => light', animate('0.25s ease-out', style({ transform: 'rotate(360deg)' }))) | ||
]) | ||
] | ||
}) | ||
export class ThemeSwitcherComponent { | ||
themeSwitcherService = inject(ThemeSwitcherService); | ||
|
||
toggleTheme() { | ||
if (this.themeSwitcherService.currentTheme() === AppTheme.DARK) { | ||
this.themeSwitcherService.setLightTheme(); | ||
} else { | ||
this.themeSwitcherService.setDarkTheme(); | ||
} | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
webapp/src/app/components/theme-switcher/theme-switcher.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { Injectable, signal } from '@angular/core'; | ||
|
||
export enum AppTheme { | ||
LIGHT = 'light', | ||
DARK = 'dark' | ||
} | ||
|
||
const IS_CLIENT_RENDER = typeof localStorage !== 'undefined'; | ||
const LOCAL_STORAGE_THEME_KEY = 'theme'; | ||
|
||
let selectedTheme: AppTheme | undefined = undefined; | ||
|
||
if (IS_CLIENT_RENDER) { | ||
selectedTheme = (localStorage.getItem(LOCAL_STORAGE_THEME_KEY) as AppTheme) || undefined; | ||
} | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class ThemeSwitcherService { | ||
currentTheme = signal<AppTheme | undefined>(selectedTheme); | ||
|
||
setLightTheme() { | ||
this.currentTheme.set(AppTheme.LIGHT); | ||
this.setToLocalStorage(AppTheme.LIGHT); | ||
this.removeClassFromHtml('dark'); | ||
} | ||
|
||
setDarkTheme() { | ||
this.currentTheme.set(AppTheme.DARK); | ||
this.setToLocalStorage(AppTheme.DARK); | ||
this.addClassToHtml('dark'); | ||
} | ||
|
||
setSystemTheme() { | ||
this.currentTheme.set(undefined); | ||
this.removeFromLocalStorage(); | ||
|
||
const isSystemDark = window?.matchMedia('(prefers-color-scheme: dark)').matches ?? false; | ||
if (isSystemDark) { | ||
this.addClassToHtml('dark'); | ||
} else { | ||
this.removeClassFromHtml('dark'); | ||
} | ||
} | ||
|
||
private addClassToHtml(className: string) { | ||
if (IS_CLIENT_RENDER) { | ||
this.removeClassFromHtml(className); | ||
document.documentElement.classList.add(className); | ||
} | ||
} | ||
|
||
private removeClassFromHtml(className: string) { | ||
if (IS_CLIENT_RENDER) { | ||
document.documentElement.classList.remove(className); | ||
} | ||
} | ||
|
||
private setToLocalStorage(theme: AppTheme) { | ||
if (IS_CLIENT_RENDER) { | ||
localStorage.setItem(LOCAL_STORAGE_THEME_KEY, theme); | ||
} | ||
} | ||
|
||
private removeFromLocalStorage() { | ||
if (IS_CLIENT_RENDER) { | ||
localStorage.removeItem(LOCAL_STORAGE_THEME_KEY); | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
webapp/src/app/components/theme-switcher/theme-switcher.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { moduleMetadata, type Meta, type StoryObj } from '@storybook/angular'; | ||
import { LucideAngularModule, Sun, Moon } from 'lucide-angular'; | ||
import { ThemeSwitcherComponent } from './theme-switcher.component'; | ||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; | ||
|
||
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories | ||
const meta: Meta<ThemeSwitcherComponent> = { | ||
title: 'Components/ThemeSwitcher', | ||
component: ThemeSwitcherComponent, | ||
tags: ['autodocs'], | ||
decorators: [ | ||
moduleMetadata({ | ||
imports: [LucideAngularModule.pick({ Sun, Moon }), BrowserAnimationsModule] | ||
}) | ||
] | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<ThemeSwitcherComponent>; | ||
|
||
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args | ||
export const Default: Story = { | ||
render: () => ({ | ||
template: `<app-theme-switcher />` | ||
}) | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters