-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bring common cod on par with other branches
Signed-off-by: Minecraftschurli <[email protected]>
- Loading branch information
1 parent
e24d993
commit 7095e9f
Showing
27 changed files
with
519 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import { Component } from '@angular/core'; | ||
import {Component, HostBinding} from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-root', | ||
// eslint-disable-next-line @angular-eslint/component-selector | ||
selector: 'body', | ||
templateUrl: './app.component.html' | ||
}) | ||
export class AppComponent { | ||
title = 'Pfarre-Machstrasse'; | ||
@HostBinding('class') class = 'mat-typography'; | ||
title = 'Pfarre Machstrasse - Hl. Klaus von Flüe'; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { JsonInterceptor } from './json.interceptor'; | ||
|
||
describe('JsonInterceptor', () => { | ||
beforeEach(() => TestBed.configureTestingModule({ | ||
providers: [ | ||
JsonInterceptor | ||
] | ||
})); | ||
|
||
it('should be created', () => { | ||
const interceptor: JsonInterceptor = TestBed.inject(JsonInterceptor); | ||
expect(interceptor).toBeTruthy(); | ||
}); | ||
}); |
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,57 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { | ||
HttpRequest, | ||
HttpHandler, | ||
HttpEvent, | ||
HttpInterceptor, HttpResponse | ||
} from '@angular/common/http'; | ||
import { Observable } from 'rxjs'; | ||
import {map} from 'rxjs/operators'; | ||
|
||
const isArray = Array.isArray; | ||
|
||
const isObject = (o) => o === Object(o) && !isArray(o) && typeof o !== 'function'; | ||
|
||
const toCamel = (s) => s.replace(/([-_][a-z])/ig, ($1) => $1.toUpperCase() | ||
.replace('-', '') | ||
.replace('_', '')); | ||
|
||
const keysToCamel = (o) => { | ||
if (isObject(o)) { | ||
const n = {}; | ||
|
||
Object.keys(o) | ||
.forEach((k) => { | ||
n[toCamel(k)] = keysToCamel(o[k]); | ||
}); | ||
|
||
return n; | ||
} else if (isArray(o)) { | ||
return o.map((i) => keysToCamel(i)); | ||
} | ||
|
||
return o; | ||
}; | ||
|
||
/** | ||
* Intercept json responses and convert them to camelCase | ||
*/ | ||
@Injectable() | ||
export class JsonInterceptor implements HttpInterceptor { | ||
|
||
intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> { | ||
if (request.responseType === 'json') { | ||
return next.handle(request).pipe(map(value => { | ||
if (value instanceof HttpResponse) { | ||
try { | ||
return value.clone({body: keysToCamel(value.body)}); | ||
} catch (ignored) { | ||
} | ||
} | ||
return value; | ||
})); | ||
} else { | ||
return next.handle(request); | ||
} | ||
} | ||
} |
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,13 +1,33 @@ | ||
import {Observable} from 'rxjs'; | ||
import {Page} from './page'; | ||
|
||
/** | ||
* The DTO (DataTransferObject) for a category | ||
*/ | ||
export interface CategoryDTO { | ||
/** | ||
* The id of this category | ||
*/ | ||
id: string; | ||
/** | ||
* The title of this category | ||
*/ | ||
title: string; | ||
/** | ||
* The ordering number of this category | ||
*/ | ||
order: number; | ||
} | ||
|
||
export interface Category { | ||
id: string; | ||
title: string; | ||
/** | ||
* The full category object | ||
*/ | ||
export interface Category extends CategoryDTO { | ||
/** | ||
* The direct accessor for all pages of this category<br> | ||
* Executes a http request to fetch the pages | ||
* | ||
* @see Page | ||
*/ | ||
pages$?: Observable<Page[]>; | ||
} |
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,32 @@ | ||
export type ChangeType = 1 | 0 | -1; | ||
export type ChangeData = ([ChangeType, string])[]; | ||
|
||
export interface Change { | ||
/** | ||
* The UUID of the User creating this change | ||
* | ||
* @type string uuid | ||
*/ | ||
author: string; | ||
/** | ||
* The id of the category which the page of this change belongs to | ||
* | ||
* @see Category.id | ||
* @see Page.category | ||
*/ | ||
category: string; | ||
/** | ||
* The id of the page this change was made on | ||
* | ||
* @see Page.id | ||
*/ | ||
page: string; | ||
/** | ||
* The timestamp of creation of this change | ||
*/ | ||
createdAt: Date; | ||
/** | ||
* The data of this change | ||
*/ | ||
data: ChangeData; | ||
} |
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,16 @@ | ||
import {Observable} from 'rxjs'; | ||
import {Media} from './media'; | ||
|
||
export interface EventDTO { | ||
id: string; | ||
name: string; | ||
details: string; | ||
start: Date; | ||
end: Date; | ||
media: string | null; | ||
owner: string; | ||
} | ||
|
||
export interface Event extends EventDTO { | ||
media$: Observable<Media>; | ||
} |
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,8 @@ | ||
import {Media} from './media'; | ||
|
||
export interface Gallery { | ||
id: string; | ||
title: string; | ||
owner: string; | ||
media: Media[]; | ||
} |
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,5 +1,13 @@ | ||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
/** | ||
* The login result containing the JWT tokens for access and refresh | ||
*/ | ||
export interface LoginResult { | ||
access_token: string; | ||
refresh_token?: string; | ||
/** | ||
* The JWT token used to authenticate with the backend | ||
*/ | ||
accessToken: string; | ||
/** | ||
* The JWT token used to refresh the access token | ||
*/ | ||
refreshToken?: string; | ||
} |
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,13 @@ | ||
export interface MediaLinks { | ||
file: string; | ||
thumbnail: string; | ||
} | ||
|
||
export interface Media { | ||
_links: MediaLinks; | ||
id: string; //uuid | ||
name: string; | ||
mimetype: string; | ||
extension: string; | ||
owner: string; //uuid | ||
} |
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,12 +1,33 @@ | ||
import {Observable} from 'rxjs'; | ||
|
||
/** | ||
* The DTO (DataTransferObject) for a page | ||
*/ | ||
export interface PageDTO { | ||
/** | ||
* The id of this page | ||
*/ | ||
id: string; | ||
/** | ||
* The title of this page | ||
*/ | ||
title: string; | ||
/** | ||
* The category this page belongs to | ||
*/ | ||
category: string; | ||
/** | ||
* The position of the page insede the category | ||
*/ | ||
order: number; | ||
} | ||
|
||
export interface Page { | ||
id: string; | ||
title: string; | ||
/** | ||
* The full page object | ||
*/ | ||
export interface Page extends PageDTO { | ||
/** | ||
* The direct accessor for the content of this page | ||
*/ | ||
content$: Observable<string>; | ||
} |
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 @@ | ||
export interface UploadResult { | ||
name: string; | ||
url: string; | ||
media: boolean; | ||
} |
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,5 +1,27 @@ | ||
export type Role = 'admin' | 'author'; | ||
|
||
/** | ||
* The object representing a user | ||
*/ | ||
export interface User { | ||
username: string; | ||
/** | ||
* The UUID of the user | ||
*/ | ||
id: string; | ||
/** | ||
* The users email | ||
*/ | ||
email: string; | ||
/** | ||
* The users first name | ||
*/ | ||
firstName: string; | ||
/** | ||
* The users last name | ||
*/ | ||
lastName: string; | ||
/** | ||
* The users role | ||
*/ | ||
role: Role; | ||
} |
Oops, something went wrong.