-
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.
- Loading branch information
Showing
17 changed files
with
245 additions
and
119 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
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
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
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
79 changes: 4 additions & 75 deletions
79
webapp/src/app/home/leaderboard/filter/filter.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 |
---|---|---|
@@ -1,88 +1,17 @@ | ||
import { Component, computed, effect, input, signal } from '@angular/core'; | ||
import { Component, input } from '@angular/core'; | ||
import { FormsModule } from '@angular/forms'; | ||
import { Router, RouterLink } from '@angular/router'; | ||
import dayjs from 'dayjs'; | ||
import weekOfYear from 'dayjs/plugin/weekOfYear'; | ||
import { BrnSelectModule } from '@spartan-ng/ui-select-brain'; | ||
import { HlmSelectModule } from '@spartan-ng/ui-select-helm'; | ||
import { HlmLabelModule } from '@spartan-ng/ui-label-helm'; | ||
import { ListFilter, LucideAngularModule } from 'lucide-angular'; | ||
|
||
interface SelectOption { | ||
id: number; | ||
value: string; | ||
label: string; | ||
} | ||
|
||
dayjs.extend(weekOfYear); | ||
|
||
function formatLabel(startDate: dayjs.Dayjs, endDate: dayjs.Dayjs | undefined) { | ||
const calendarWeek = startDate.week(); | ||
if (!endDate) { | ||
return `CW\xa0${calendarWeek}:\xa0${startDate.format('MMM D')}\xa0-\xa0Today`; | ||
} | ||
|
||
const sameMonth = startDate.month() === endDate.month(); | ||
if (sameMonth) { | ||
return `CW\xa0${calendarWeek}:\xa0${startDate.format('MMM D')}\xa0-\xa0${endDate.format('D')}`; | ||
} else { | ||
return `CW\xa0${calendarWeek}:\xa0${startDate.format('MMM D')}\xa0-\xa0${endDate.format('MMM D')}`; | ||
} | ||
} | ||
import { LeaderboardFilterTimeframeComponent } from './timeframe/timeframe.component'; | ||
import { LeaderboardFilterRepositoryComponent } from './repository/repository.component'; | ||
|
||
@Component({ | ||
selector: 'app-leaderboard-filter', | ||
standalone: true, | ||
imports: [RouterLink, LucideAngularModule, BrnSelectModule, HlmSelectModule, HlmLabelModule, FormsModule], | ||
imports: [LucideAngularModule, FormsModule, LeaderboardFilterTimeframeComponent, LeaderboardFilterRepositoryComponent], | ||
templateUrl: './filter.component.html' | ||
}) | ||
export class LeaderboardFilterComponent { | ||
protected ListFilter = ListFilter; | ||
after = input<string>(''); | ||
before = input<string>(''); | ||
|
||
value = signal<string>(`${this.after()}.${this.before()}`); | ||
|
||
placeholder = computed(() => { | ||
return formatLabel(dayjs(this.after()) ?? dayjs().day(1), this.before() === undefined ? undefined : dayjs(this.before())); | ||
}); | ||
|
||
options = computed(() => { | ||
const now = dayjs(); | ||
let currentDate = dayjs().day(1); | ||
const options: SelectOption[] = [ | ||
{ | ||
id: now.unix(), | ||
value: `${currentDate.format('YYYY-MM-DD')}.${now.format('YYYY-MM-DD')}`, | ||
label: formatLabel(currentDate, undefined) | ||
} | ||
]; | ||
|
||
for (let i = 0; i < 4; i++) { | ||
const startDate = currentDate.subtract(7, 'day'); | ||
const endDate = currentDate.subtract(1, 'day'); | ||
options.push({ | ||
id: startDate.unix(), | ||
value: `${startDate.format('YYYY-MM-DD')}.${endDate.format('YYYY-MM-DD')}`, | ||
label: formatLabel(startDate, endDate) | ||
}); | ||
currentDate = startDate; | ||
} | ||
|
||
return options; | ||
}); | ||
|
||
constructor(private router: Router) { | ||
effect(() => { | ||
if (this.value().length === 1) return; | ||
const dates = this.value().split('.'); | ||
// change query params | ||
this.router.navigate([], { | ||
queryParams: { | ||
after: dates[0], | ||
before: dates[1] | ||
} | ||
}); | ||
}); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
webapp/src/app/home/leaderboard/filter/repository/repository.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,11 @@ | ||
<hlm-select [placeholder]="placeholder()" [(ngModel)]="value" name="value"> | ||
<label hlmLabel>Select repository</label> | ||
<hlm-select-trigger class="w-56"> | ||
<hlm-select-value /> | ||
</hlm-select-trigger> | ||
<hlm-select-content class="w-56"> | ||
@for (option of options(); track option.id) { | ||
<hlm-option [value]="option.value">{{ option.label }}</hlm-option> | ||
} | ||
</hlm-select-content> | ||
</hlm-select> |
Oops, something went wrong.