-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add canteen gql * feat: add colleagues gql * feat: add events gql * feat: add page gql * feat: add authors gql * feat: add posts gql * feat: add search gql * feat: add post gql * feat: add archive gql * feat: add label gql * feat: add menu gql * feat: add menu gql * fix: post fix * fix: post fix * fix: take(1) * feat: add Automatic Persisted Queries * fix: archive gql * fix: try fixing posts * feat: label and author search pagination * chore: fix gql url
- Loading branch information
Showing
53 changed files
with
834 additions
and
638 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,72 @@ | ||
import { Injectable } from '@angular/core' | ||
import { HttpClient } from '@angular/common/http' | ||
import { environment } from '../../../environments/environment' | ||
import {Apollo, gql} from "apollo-angular"; | ||
import {map, take} from "rxjs/operators"; | ||
import {Observable} from "rxjs"; | ||
import {Post} from "../../models/Post"; | ||
|
||
const infoQUERY = gql` | ||
query { | ||
archive { | ||
info { | ||
count | ||
year | ||
month | ||
} | ||
} | ||
} | ||
` | ||
|
||
const postsQUERY = gql` | ||
query Archive($year: Int!, $month: Int!) { | ||
archive { | ||
posts(year: $year, month: $month) { | ||
id | ||
date | ||
title | ||
description | ||
} | ||
} | ||
} | ||
` | ||
|
||
interface Result { | ||
archive: { | ||
info: Stats[] | ||
posts: Post[] | ||
} | ||
} | ||
|
||
export interface Stats { count: number, year: number, month: number} | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class ArchiveService { | ||
getArchives() { | ||
return this.http.get(environment.baseURL + '/posts/getCountByMonth') | ||
} | ||
constructor(private gql: Apollo) {} | ||
|
||
getDetailedArchives({ year, month }: { year: number; month: number }) { | ||
return this.http.get(environment.baseURL + '/posts/getPostsByYearMonth', { | ||
params: { | ||
year: year.toString(10), | ||
month: month.toString(10), | ||
}, | ||
}) | ||
getArchives(): Observable<Stats[]> { | ||
return this.gql.watchQuery<Result>({ | ||
query: infoQUERY | ||
}).valueChanges.pipe( | ||
map(res => { | ||
return res.data.archive.info | ||
}), | ||
take(1) | ||
) | ||
} | ||
|
||
constructor(private http: HttpClient) {} | ||
getDetailedArchives({ year, month }: { year: number; month: number }): Observable<Post[]> { | ||
return this.gql.watchQuery<Result>({ | ||
query: postsQUERY, | ||
variables: { | ||
year, | ||
month, | ||
} | ||
}).valueChanges.pipe( | ||
map(res => { | ||
return res.data.archive.posts | ||
}), | ||
take(1) | ||
) | ||
} | ||
} |
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
14 changes: 7 additions & 7 deletions
14
apps/frontend/src/app/modules/canteen/components/canteen/canteen.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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
<h2>Menza étlap</h2> | ||
<ng-container *ngFor="let week of [0, 1]"> | ||
<span class="menu-header">{{ week_prefixes[week] }}</span> | ||
<div class="day" *ngFor="let day of [1, 2, 3, 4, 5]"> | ||
<span class="day-name">{{ weekdays[day - 1] }}</span> | ||
<ng-container *ngIf="(canteen | async)[week][day] as thisDay"> | ||
<span class="food" *ngFor="let meal of thisDay.menus">{{ meal.menu }}</span> | ||
</ng-container> | ||
</div> | ||
<span class="menu-header">{{ week_prefixes[week] }}</span> | ||
<div class="day" *ngFor="let day of [0,1,2,3,4]"> | ||
<span class="day-name">{{ weekdays[day] }}</span> | ||
<ng-container *ngIf="(canteen | async)?.[week][day] as thisDay"> | ||
<span class="food" *ngFor="let meal of thisDay.menus">{{ meal.menu }}</span> | ||
</ng-container> | ||
</div> | ||
</ng-container> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export interface CanteenDay { | ||
id: number | ||
menus: [Menu, Menu, Menu?] | ||
date: string | ||
} | ||
|
||
export interface Menu { | ||
id: number | ||
menu: string | ||
type: number | ||
} |
30 changes: 0 additions & 30 deletions
30
apps/frontend/src/app/modules/canteen/reducer/canteen/canteen.actions.ts
This file was deleted.
Oops, something went wrong.
44 changes: 0 additions & 44 deletions
44
apps/frontend/src/app/modules/canteen/reducer/canteen/canteen.effects.spec.ts
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
apps/frontend/src/app/modules/canteen/reducer/canteen/canteen.effects.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.