Running Prettier in Project
This commit is contained in:
@@ -1,17 +1,25 @@
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import {first, firstValueFrom, map, Observable, of, Subject, take, tap} from 'rxjs';
|
||||
import {
|
||||
first,
|
||||
firstValueFrom,
|
||||
map,
|
||||
Observable,
|
||||
of,
|
||||
Subject,
|
||||
take,
|
||||
tap,
|
||||
} from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { HttpError } from '../model/httpError/httpError.model';
|
||||
import { User } from '../model/user/user.model';
|
||||
import * as http from "http";
|
||||
import * as http from 'http';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class AuthService {
|
||||
|
||||
private userAuthenticated!: User;
|
||||
|
||||
authSubject = new Subject<User | HttpError | null>();
|
||||
@@ -20,30 +28,35 @@ export class AuthService {
|
||||
|
||||
readonly BACKEND_OAUTH_PATH = environment.backendOAuthPath;
|
||||
|
||||
constructor(private http: HttpClient) { }
|
||||
constructor(private http: HttpClient) {}
|
||||
login(userAuthAtempt: User): void {
|
||||
this.validateUser(this.loginUser(userAuthAtempt));
|
||||
}
|
||||
|
||||
googleLogin() {
|
||||
window.open(this.BACKEND_OAUTH_PATH + '/oauth2/authorization/google', '_self');
|
||||
window.open(
|
||||
this.BACKEND_OAUTH_PATH + '/oauth2/authorization/google',
|
||||
'_self',
|
||||
);
|
||||
}
|
||||
|
||||
githubLogin() {
|
||||
window.open(this.BACKEND_OAUTH_PATH + '/oauth2/authorization/github', '_self');
|
||||
window.open(
|
||||
this.BACKEND_OAUTH_PATH + '/oauth2/authorization/github',
|
||||
'_self',
|
||||
);
|
||||
}
|
||||
|
||||
loginGoogleUser(p: any): void {
|
||||
this.validateUser(this.fetchGoogleOAuthToken(p))
|
||||
this.validateUser(this.fetchGoogleOAuthToken(p));
|
||||
}
|
||||
|
||||
loginGithubUser(p: any): void {
|
||||
this.validateUser(this.fetchGithubOAuthToken(p))
|
||||
this.validateUser(this.fetchGithubOAuthToken(p));
|
||||
}
|
||||
|
||||
signup(userAuthAtempt: User): void {
|
||||
this.validateUser(this.createUser(userAuthAtempt));
|
||||
|
||||
}
|
||||
|
||||
refresh(): void {
|
||||
@@ -56,7 +69,7 @@ export class AuthService {
|
||||
|
||||
logout() {
|
||||
this.authSubject.next(null);
|
||||
this.destroySessions().subscribe()
|
||||
this.destroySessions().subscribe();
|
||||
}
|
||||
|
||||
deleteAccount() {
|
||||
@@ -66,7 +79,7 @@ export class AuthService {
|
||||
addProfilePicture(file: File): void {
|
||||
const fileType = file.type.split('/')[1];
|
||||
this.getAddProfilePictureUrl(fileType).subscribe({
|
||||
next: (url: string|null) => {
|
||||
next: (url: string | null) => {
|
||||
if (url != null) {
|
||||
this.uploadProfilePicture(url, file).then(
|
||||
(response: Observable<any>) => {
|
||||
@@ -75,169 +88,160 @@ export class AuthService {
|
||||
this.processProfilePicture().subscribe(
|
||||
() => {
|
||||
this.refresh();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private loginUser(userAuthAtempt: User): Observable<User|any> {
|
||||
|
||||
private loginUser(userAuthAtempt: User): Observable<User | any> {
|
||||
let loginParams = new URLSearchParams();
|
||||
loginParams.set("username", userAuthAtempt.username!);
|
||||
loginParams.set("password", userAuthAtempt.password!);
|
||||
loginParams.set('username', userAuthAtempt.username!);
|
||||
loginParams.set('password', userAuthAtempt.password!);
|
||||
|
||||
let headers = new HttpHeaders({
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
});
|
||||
|
||||
return this.http.post<User>(
|
||||
this.BACKEND_PATH + "/user/login",
|
||||
loginParams,
|
||||
{ headers: headers, withCredentials: true }
|
||||
).pipe(
|
||||
first()
|
||||
)
|
||||
return this.http
|
||||
.post<User>(this.BACKEND_PATH + '/user/login', loginParams, {
|
||||
headers: headers,
|
||||
withCredentials: true,
|
||||
})
|
||||
.pipe(first());
|
||||
}
|
||||
|
||||
private fetchGoogleOAuthToken(p: any): Observable<User|any> {
|
||||
private fetchGoogleOAuthToken(p: any): Observable<User | any> {
|
||||
let params = new HttpParams({
|
||||
fromObject: p,
|
||||
});
|
||||
|
||||
let params = new HttpParams(
|
||||
{
|
||||
fromObject: p
|
||||
}
|
||||
);
|
||||
|
||||
return this.http.get<User>(
|
||||
this.BACKEND_OAUTH_PATH + '/login/oauth2/code/google',
|
||||
{
|
||||
return this.http
|
||||
.get<User>(this.BACKEND_OAUTH_PATH + '/login/oauth2/code/google', {
|
||||
withCredentials: true,
|
||||
params: params
|
||||
},
|
||||
).pipe(
|
||||
first()
|
||||
);
|
||||
params: params,
|
||||
})
|
||||
.pipe(first());
|
||||
}
|
||||
|
||||
private fetchGithubOAuthToken(p: any): Observable<User|any> {
|
||||
private fetchGithubOAuthToken(p: any): Observable<User | any> {
|
||||
let params = new HttpParams({
|
||||
fromObject: p,
|
||||
});
|
||||
|
||||
let params = new HttpParams(
|
||||
{
|
||||
fromObject: p
|
||||
}
|
||||
);
|
||||
|
||||
return this.http.get<User>(
|
||||
this.BACKEND_OAUTH_PATH + '/login/oauth2/code/github',
|
||||
{
|
||||
return this.http
|
||||
.get<User>(this.BACKEND_OAUTH_PATH + '/login/oauth2/code/github', {
|
||||
withCredentials: true,
|
||||
params: params
|
||||
},
|
||||
).pipe(
|
||||
first()
|
||||
);
|
||||
params: params,
|
||||
})
|
||||
.pipe(first());
|
||||
}
|
||||
|
||||
private createUser(newUser: User) {
|
||||
return this.http.post<User>(
|
||||
this.BACKEND_PATH + "/user/signup",
|
||||
newUser,
|
||||
{ withCredentials: true }
|
||||
).pipe(
|
||||
first()
|
||||
)
|
||||
return this.http
|
||||
.post<User>(this.BACKEND_PATH + '/user/signup', newUser, {
|
||||
withCredentials: true,
|
||||
})
|
||||
.pipe(first());
|
||||
}
|
||||
|
||||
private refreshAccessToken() {
|
||||
return this.http.post<User>(
|
||||
this.BACKEND_PATH + "/user/login/refresh",
|
||||
this.BACKEND_PATH + '/user/login/refresh',
|
||||
this.userAuthenticated.refreshToken,
|
||||
{ withCredentials: true }
|
||||
{ withCredentials: true },
|
||||
);
|
||||
}
|
||||
|
||||
private validateSession(): Observable<User> {
|
||||
return this.http.get<User>(
|
||||
this.BACKEND_PATH + '/session/validate',
|
||||
{ withCredentials: true }
|
||||
);
|
||||
}
|
||||
|
||||
private destroySessions() {
|
||||
return this.http.delete(
|
||||
this.BACKEND_PATH + '/session/destroy',
|
||||
{ withCredentials: true }
|
||||
);
|
||||
}
|
||||
|
||||
private deleteAccountRequest() {
|
||||
let headers = this.createAuthorizationHeader()
|
||||
|
||||
return this.http.delete(
|
||||
this.BACKEND_PATH + `/user/delete`,
|
||||
{ headers: headers, withCredentials: true }
|
||||
);
|
||||
}
|
||||
|
||||
private validateUser(userAuthAtempt: Observable<User>) {
|
||||
userAuthAtempt.pipe(
|
||||
catchError(error => {
|
||||
if (error.status == 0) {
|
||||
return of(<HttpError>{
|
||||
title: "Service Unavailable",
|
||||
status: 500,
|
||||
details: "Service Unavailable, please try again later.",
|
||||
developerMessage: "Service Unavailable, please try again later.",
|
||||
timestamp: new Date().toISOString()
|
||||
});
|
||||
}
|
||||
return of(<HttpError>error.error);
|
||||
}),
|
||||
first()
|
||||
).subscribe({
|
||||
next: userAuthentication => {
|
||||
this.userAuthenticated = <User>userAuthentication;
|
||||
this.authSubject.next(this.userAuthenticated);
|
||||
}
|
||||
return this.http.get<User>(this.BACKEND_PATH + '/session/validate', {
|
||||
withCredentials: true,
|
||||
});
|
||||
}
|
||||
|
||||
private getAddProfilePictureUrl(fileType: string): Observable<string|null> {
|
||||
return this.http.post<{ presigned_url: string, file_key: string }>(
|
||||
this.BACKEND_PATH + '/user/profile-picture?fileType=' + fileType,
|
||||
null,
|
||||
{
|
||||
headers: this.createAuthorizationHeader(),
|
||||
withCredentials: true
|
||||
}
|
||||
).pipe(
|
||||
first(),
|
||||
map((res) => {
|
||||
if (!!res && !!res.presigned_url) {
|
||||
return res.presigned_url;
|
||||
}
|
||||
return null
|
||||
})
|
||||
)
|
||||
private destroySessions() {
|
||||
return this.http.delete(this.BACKEND_PATH + '/session/destroy', {
|
||||
withCredentials: true,
|
||||
});
|
||||
}
|
||||
|
||||
private async uploadProfilePicture(url: string, file: File): Promise<Observable<any>> {
|
||||
private deleteAccountRequest() {
|
||||
let headers = this.createAuthorizationHeader();
|
||||
|
||||
return this.http.delete(this.BACKEND_PATH + `/user/delete`, {
|
||||
headers: headers,
|
||||
withCredentials: true,
|
||||
});
|
||||
}
|
||||
|
||||
private validateUser(userAuthAtempt: Observable<User>) {
|
||||
userAuthAtempt
|
||||
.pipe(
|
||||
catchError((error) => {
|
||||
if (error.status == 0) {
|
||||
return of(<HttpError>{
|
||||
title: 'Service Unavailable',
|
||||
status: 500,
|
||||
details:
|
||||
'Service Unavailable, please try again later.',
|
||||
developerMessage:
|
||||
'Service Unavailable, please try again later.',
|
||||
timestamp: new Date().toISOString(),
|
||||
});
|
||||
}
|
||||
return of(<HttpError>error.error);
|
||||
}),
|
||||
first(),
|
||||
)
|
||||
.subscribe({
|
||||
next: (userAuthentication) => {
|
||||
this.userAuthenticated = <User>userAuthentication;
|
||||
this.authSubject.next(this.userAuthenticated);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private getAddProfilePictureUrl(
|
||||
fileType: string,
|
||||
): Observable<string | null> {
|
||||
return this.http
|
||||
.post<{ presigned_url: string; file_key: string }>(
|
||||
this.BACKEND_PATH +
|
||||
'/user/profile-picture?fileType=' +
|
||||
fileType,
|
||||
null,
|
||||
{
|
||||
headers: this.createAuthorizationHeader(),
|
||||
withCredentials: true,
|
||||
},
|
||||
)
|
||||
.pipe(
|
||||
first(),
|
||||
map((res) => {
|
||||
if (!!res && !!res.presigned_url) {
|
||||
return res.presigned_url;
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
private async uploadProfilePicture(
|
||||
url: string,
|
||||
file: File,
|
||||
): Promise<Observable<any>> {
|
||||
const fileData = await this.readAsArrayBuffer(file);
|
||||
let headers = new HttpHeaders({
|
||||
'Content-Type': file.type
|
||||
})
|
||||
return this.http.put(
|
||||
url,
|
||||
fileData,
|
||||
{
|
||||
headers: headers,
|
||||
}
|
||||
);
|
||||
'Content-Type': file.type,
|
||||
});
|
||||
return this.http.put(url, fileData, {
|
||||
headers: headers,
|
||||
});
|
||||
}
|
||||
|
||||
private processProfilePicture() {
|
||||
@@ -246,21 +250,22 @@ export class AuthService {
|
||||
null,
|
||||
{
|
||||
headers: this.createAuthorizationHeader(),
|
||||
withCredentials: true
|
||||
}
|
||||
)
|
||||
withCredentials: true,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
private createAuthorizationHeader(): HttpHeaders {
|
||||
return new HttpHeaders({
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer ' + this.userAuthenticated.accessToken?.token
|
||||
Authorization:
|
||||
'Bearer ' + this.userAuthenticated.accessToken?.token,
|
||||
});
|
||||
}
|
||||
|
||||
private async readAsArrayBuffer(file: File): Promise<ArrayBuffer> {
|
||||
const reader = new FileReader();
|
||||
reader.readAsArrayBuffer(file)
|
||||
reader.readAsArrayBuffer(file);
|
||||
return new Promise<ArrayBuffer>((resolve, reject) => {
|
||||
reader.onload = () => {
|
||||
resolve(reader.result as ArrayBuffer);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800;900&display=swap');
|
||||
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800;900&display=swap");
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
font-family: 'Poppins', sans-serif;
|
||||
font-family: "Poppins", sans-serif;
|
||||
}
|
||||
|
||||
.popup-background {
|
||||
@@ -51,7 +51,7 @@
|
||||
background: #808080;
|
||||
border-radius: 5px;
|
||||
position: fixed;
|
||||
content: '';
|
||||
content: "";
|
||||
width: 25px;
|
||||
height: 5px;
|
||||
}
|
||||
@@ -73,11 +73,9 @@
|
||||
height: 60px;
|
||||
}
|
||||
|
||||
@media (min-width:767px) {
|
||||
|
||||
@media (min-width: 767px) {
|
||||
.popup {
|
||||
width: fit-content;
|
||||
max-width: unset;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
<div #popup
|
||||
class="popup-background"
|
||||
[@popupState]="popupState"
|
||||
(@popupState.done)="animationStop()">
|
||||
<div class="popup"
|
||||
appClickedOutside
|
||||
(clickOutside)="closePopup()"
|
||||
[ignoreElementList]="ignoreClickOutside">
|
||||
<div
|
||||
#popup
|
||||
class="popup-background"
|
||||
[@popupState]="popupState"
|
||||
(@popupState.done)="animationStop()"
|
||||
>
|
||||
<div
|
||||
class="popup"
|
||||
appClickedOutside
|
||||
(clickOutside)="closePopup()"
|
||||
[ignoreElementList]="ignoreClickOutside"
|
||||
>
|
||||
<div class="popup-header">
|
||||
<div class="popup-close-btn" (click)="closePopup()"></div>
|
||||
</div>
|
||||
@@ -14,4 +18,4 @@ class="popup-background"
|
||||
</div>
|
||||
<div class="popup-footer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -8,9 +8,8 @@ describe('PopupComponent', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ PopupComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [PopupComponent],
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(PopupComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
import { animate, animateChild, group, query, state, style, transition, trigger } from '@angular/animations';
|
||||
import { Component, ElementRef, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core';
|
||||
import {
|
||||
animate,
|
||||
animateChild,
|
||||
group,
|
||||
query,
|
||||
state,
|
||||
style,
|
||||
transition,
|
||||
trigger,
|
||||
} from '@angular/animations';
|
||||
import {
|
||||
Component,
|
||||
ElementRef,
|
||||
EventEmitter,
|
||||
Input,
|
||||
Output,
|
||||
ViewEncapsulation,
|
||||
} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-popup',
|
||||
@@ -7,49 +23,46 @@ import { Component, ElementRef, EventEmitter, Input, Output, ViewEncapsulation }
|
||||
styleUrls: ['./popup.component.css'],
|
||||
animations: [
|
||||
trigger('popupState', [
|
||||
state('hide', style({
|
||||
'opacity': '0'
|
||||
})),
|
||||
state('show', style({
|
||||
'opacity': '1'
|
||||
})),
|
||||
state(
|
||||
'hide',
|
||||
style({
|
||||
opacity: '0',
|
||||
}),
|
||||
),
|
||||
state(
|
||||
'show',
|
||||
style({
|
||||
opacity: '1',
|
||||
}),
|
||||
),
|
||||
transition(
|
||||
'* => show',
|
||||
group([
|
||||
query(
|
||||
"@*",
|
||||
animateChild(),
|
||||
{ optional: true }
|
||||
),
|
||||
animate('250ms ease-in')
|
||||
])
|
||||
query('@*', animateChild(), { optional: true }),
|
||||
animate('250ms ease-in'),
|
||||
]),
|
||||
),
|
||||
transition(
|
||||
'show => hide',
|
||||
group([
|
||||
query(
|
||||
"@*",
|
||||
animateChild(),
|
||||
{ optional: true }
|
||||
),
|
||||
animate('250ms ease-out')
|
||||
])
|
||||
)
|
||||
])
|
||||
]
|
||||
query('@*', animateChild(), { optional: true }),
|
||||
animate('250ms ease-out'),
|
||||
]),
|
||||
),
|
||||
]),
|
||||
],
|
||||
})
|
||||
export class PopupComponent {
|
||||
@Input()
|
||||
state: boolean = false;
|
||||
|
||||
@Input()
|
||||
state: boolean = false;
|
||||
|
||||
@Input()
|
||||
ignoreClickOutside!: HTMLDivElement[];
|
||||
ignoreClickOutside!: HTMLDivElement[];
|
||||
|
||||
@Output()
|
||||
stateChange = new EventEmitter<boolean>(false);
|
||||
stateChange = new EventEmitter<boolean>(false);
|
||||
|
||||
constructor() { }
|
||||
constructor() {}
|
||||
|
||||
get popupState(): string {
|
||||
return this.state ? 'show' : 'hide';
|
||||
@@ -57,7 +70,7 @@ export class PopupComponent {
|
||||
|
||||
animationStop() {
|
||||
if (!this.state) {
|
||||
this.closePopup()
|
||||
this.closePopup();
|
||||
this.stateChange.emit(false);
|
||||
}
|
||||
}
|
||||
@@ -65,5 +78,4 @@ export class PopupComponent {
|
||||
closePopup(): void {
|
||||
this.state = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,9 +8,8 @@ describe('SliderItemComponent', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ SliderItemComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [SliderItemComponent],
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(SliderItemComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
||||
@@ -1,46 +1,56 @@
|
||||
import { animate, state, style, transition, trigger } from '@angular/animations';
|
||||
import {
|
||||
animate,
|
||||
state,
|
||||
style,
|
||||
transition,
|
||||
trigger,
|
||||
} from '@angular/animations';
|
||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-slider-item',
|
||||
templateUrl: './slider-item.component.html',
|
||||
styleUrls: ['./slider-item.component.css'],
|
||||
animations:[
|
||||
trigger('animateSliderItem',[
|
||||
state('hide', style({
|
||||
'opacity': '0',
|
||||
'transform': 'translateX(150px)'
|
||||
}),
|
||||
{
|
||||
params: {
|
||||
fadeInTime: 600,
|
||||
fadeOutTime: 600
|
||||
}
|
||||
}),
|
||||
state('show', style({
|
||||
'opacity': '1',
|
||||
'transform': 'translateX(0px)'
|
||||
}),
|
||||
{
|
||||
params: {
|
||||
fadeOutTime: 600,
|
||||
fadeInTime: 600
|
||||
animations: [
|
||||
trigger('animateSliderItem', [
|
||||
state(
|
||||
'hide',
|
||||
style({
|
||||
opacity: '0',
|
||||
transform: 'translateX(150px)',
|
||||
}),
|
||||
{
|
||||
params: {
|
||||
fadeInTime: 600,
|
||||
fadeOutTime: 600,
|
||||
},
|
||||
},
|
||||
}),
|
||||
),
|
||||
state(
|
||||
'show',
|
||||
style({
|
||||
opacity: '1',
|
||||
transform: 'translateX(0px)',
|
||||
}),
|
||||
{
|
||||
params: {
|
||||
fadeOutTime: 600,
|
||||
fadeInTime: 600,
|
||||
},
|
||||
},
|
||||
),
|
||||
transition('hide => show', animate(`{{ fadeInTime }}s ease-in`)),
|
||||
transition('show => hide', animate(`{{ fadeOutTime }}s ease-out`))
|
||||
])
|
||||
]
|
||||
transition('show => hide', animate(`{{ fadeOutTime }}s ease-out`)),
|
||||
]),
|
||||
],
|
||||
})
|
||||
export class SliderItemComponent {
|
||||
|
||||
@Input()
|
||||
public state:boolean = false;
|
||||
|
||||
constructor() { }
|
||||
public state: boolean = false;
|
||||
|
||||
constructor() {}
|
||||
|
||||
get itemStatus(): string {
|
||||
return this.state ? 'show' : 'hide';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,44 +1,42 @@
|
||||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {NgcCookieConsentConfig, NgcCookieConsentModule} from "ngx-cookieconsent";
|
||||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import {
|
||||
NgcCookieConsentConfig,
|
||||
NgcCookieConsentModule,
|
||||
} from 'ngx-cookieconsent';
|
||||
|
||||
const cookieConfig: NgcCookieConsentConfig = {
|
||||
"cookie": {
|
||||
"domain": "tinesoft.github.io"
|
||||
cookie: {
|
||||
domain: 'tinesoft.github.io',
|
||||
},
|
||||
"position": "bottom-left",
|
||||
"theme": "classic",
|
||||
"palette": {
|
||||
"popup": {
|
||||
"background": "#4e4e4e",
|
||||
"text": "#ffffff",
|
||||
"link": "#ffffff"
|
||||
position: 'bottom-left',
|
||||
theme: 'classic',
|
||||
palette: {
|
||||
popup: {
|
||||
background: '#4e4e4e',
|
||||
text: '#ffffff',
|
||||
link: '#ffffff',
|
||||
},
|
||||
button: {
|
||||
background: '#fa2f22',
|
||||
text: '#ffffff',
|
||||
border: 'transparent',
|
||||
},
|
||||
"button": {
|
||||
"background": "#fa2f22",
|
||||
"text": "#ffffff",
|
||||
"border": "transparent"
|
||||
}
|
||||
},
|
||||
"type": "opt-in",
|
||||
"content": {
|
||||
"message": "This website uses cookies to ensure you get the best experience on our website.",
|
||||
"dismiss": "Got it!",
|
||||
"deny": "Refuse cookies",
|
||||
"link": "",
|
||||
"href": "",
|
||||
"policy": "Cookie Policy"
|
||||
}
|
||||
type: 'opt-in',
|
||||
content: {
|
||||
message:
|
||||
'This website uses cookies to ensure you get the best experience on our website.',
|
||||
dismiss: 'Got it!',
|
||||
deny: 'Refuse cookies',
|
||||
link: '',
|
||||
href: '',
|
||||
policy: 'Cookie Policy',
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@NgModule({
|
||||
declarations: [],
|
||||
imports: [
|
||||
CommonModule,
|
||||
NgcCookieConsentModule.forRoot(cookieConfig)
|
||||
]
|
||||
imports: [CommonModule, NgcCookieConsentModule.forRoot(cookieConfig)],
|
||||
})
|
||||
export class CookieConsentModule {
|
||||
}
|
||||
export class CookieConsentModule {}
|
||||
|
||||
@@ -3,14 +3,14 @@ import { TestBed } from '@angular/core/testing';
|
||||
import { CookieConsertService } from './cookie-consert.service';
|
||||
|
||||
describe('CookieConsertService', () => {
|
||||
let service: CookieConsertService;
|
||||
let service: CookieConsertService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(CookieConsertService);
|
||||
});
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(CookieConsertService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {BehaviorSubject, Subject, Subscription} from "rxjs";
|
||||
import {CookieService} from "ngx-cookie-service";
|
||||
import { Injectable } from '@angular/core';
|
||||
import { BehaviorSubject, Subject, Subscription } from 'rxjs';
|
||||
import { CookieService } from 'ngx-cookie-service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class CookieConsertService {
|
||||
|
||||
private storage: Storage;
|
||||
|
||||
cookieStatusChangeSubscription!: BehaviorSubject<boolean>
|
||||
cookieStatusChangeSubscription!: BehaviorSubject<boolean>;
|
||||
|
||||
constructor(private cookieService: CookieService) {
|
||||
this.storage = window.localStorage
|
||||
this.storage = window.localStorage;
|
||||
|
||||
this.cookieStatusChangeSubscription = new BehaviorSubject<boolean>(
|
||||
this.getCookieConsentStatusFromLocalStorage()
|
||||
this.getCookieConsentStatusFromLocalStorage(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -48,5 +47,4 @@ export class CookieConsertService {
|
||||
|
||||
return status === 'true';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,28 @@
|
||||
import { DOCUMENT } from '@angular/common';
|
||||
import { AfterViewInit, Directive, ElementRef, EventEmitter, Inject, Input, OnDestroy, Output, ViewChild } from '@angular/core';
|
||||
import { combineLatest, combineLatestWith, filter, fromEvent, merge, Subscription } from 'rxjs';
|
||||
import {
|
||||
AfterViewInit,
|
||||
Directive,
|
||||
ElementRef,
|
||||
EventEmitter,
|
||||
Inject,
|
||||
Input,
|
||||
OnDestroy,
|
||||
Output,
|
||||
ViewChild,
|
||||
} from '@angular/core';
|
||||
import {
|
||||
combineLatest,
|
||||
combineLatestWith,
|
||||
filter,
|
||||
fromEvent,
|
||||
merge,
|
||||
Subscription,
|
||||
} from 'rxjs';
|
||||
|
||||
@Directive({
|
||||
selector: '[appClickedOutside]'
|
||||
selector: '[appClickedOutside]',
|
||||
})
|
||||
export class ClickedOutsideDirective implements AfterViewInit, OnDestroy {
|
||||
|
||||
@Input()
|
||||
ignoreElementList!: HTMLDivElement[];
|
||||
|
||||
@@ -23,27 +39,27 @@ export class ClickedOutsideDirective implements AfterViewInit, OnDestroy {
|
||||
|
||||
constructor(
|
||||
private element: ElementRef,
|
||||
@Inject(DOCUMENT) private document: Document
|
||||
) { }
|
||||
@Inject(DOCUMENT) private document: Document,
|
||||
) {}
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
|
||||
const clickListener$ = fromEvent(this.document, 'click');
|
||||
|
||||
this.eventListener = clickListener$.pipe(
|
||||
filter((click) => {
|
||||
return (
|
||||
(
|
||||
this.isOutside(click.target as HTMLElement) ||
|
||||
this.isInIncludedList(click.target as HTMLElement)
|
||||
) &&
|
||||
this.notInIgnoredList(click.target as HTMLElement)
|
||||
);
|
||||
})
|
||||
). subscribe( () => {
|
||||
!this.clickOutsideStopWatching && this.clickOutside.emit();
|
||||
});
|
||||
|
||||
this.eventListener = clickListener$
|
||||
.pipe(
|
||||
filter((click) => {
|
||||
return (
|
||||
(this.isOutside(click.target as HTMLElement) ||
|
||||
this.isInIncludedList(
|
||||
click.target as HTMLElement,
|
||||
)) &&
|
||||
this.notInIgnoredList(click.target as HTMLElement)
|
||||
);
|
||||
}),
|
||||
)
|
||||
.subscribe(() => {
|
||||
!this.clickOutsideStopWatching && this.clickOutside.emit();
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
@@ -52,12 +68,14 @@ export class ClickedOutsideDirective implements AfterViewInit, OnDestroy {
|
||||
|
||||
private isOutside(elementToCheck: HTMLElement): boolean {
|
||||
let status = true;
|
||||
if (this.element.nativeElement === elementToCheck ||
|
||||
this.element.nativeElement.contains(elementToCheck)) {
|
||||
if (
|
||||
this.element.nativeElement === elementToCheck ||
|
||||
this.element.nativeElement.contains(elementToCheck)
|
||||
) {
|
||||
status = false;
|
||||
}
|
||||
|
||||
console.log('isOutside', status)
|
||||
console.log('isOutside', status);
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -68,26 +86,32 @@ export class ClickedOutsideDirective implements AfterViewInit, OnDestroy {
|
||||
}
|
||||
|
||||
let validateIsIgnored = (ignoreElement: HTMLDivElement): boolean => {
|
||||
return ignoreElement === elementToCheck
|
||||
|| ignoreElement.contains(elementToCheck)
|
||||
|| elementToCheck.contains(ignoreElement)
|
||||
}
|
||||
return (
|
||||
ignoreElement === elementToCheck ||
|
||||
ignoreElement.contains(elementToCheck) ||
|
||||
elementToCheck.contains(ignoreElement)
|
||||
);
|
||||
};
|
||||
|
||||
return !this.ignoreElementList.some(validateIsIgnored)
|
||||
return !this.ignoreElementList.some(validateIsIgnored);
|
||||
}
|
||||
|
||||
private isInIncludedList(elementToCheck: HTMLElement): boolean {
|
||||
if (!this.includeClickedOutside || this.includeClickedOutside.length === 0) {
|
||||
if (
|
||||
!this.includeClickedOutside ||
|
||||
this.includeClickedOutside.length === 0
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let validateIsIncluded = (includedElement: HTMLDivElement): boolean => {
|
||||
return includedElement === elementToCheck
|
||||
|| includedElement.contains(elementToCheck)
|
||||
|| elementToCheck.contains(includedElement)
|
||||
}
|
||||
return (
|
||||
includedElement === elementToCheck ||
|
||||
includedElement.contains(elementToCheck) ||
|
||||
elementToCheck.contains(includedElement)
|
||||
);
|
||||
};
|
||||
|
||||
return !this.includeClickedOutside.some(validateIsIncluded)
|
||||
return !this.includeClickedOutside.some(validateIsIncluded);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
/**
|
||||
* This module was automatically generated by `ts-interface-builder`
|
||||
*/
|
||||
import * as t from "ts-interface-checker";
|
||||
import * as t from 'ts-interface-checker';
|
||||
// tslint:disable:object-literal-key-quotes
|
||||
|
||||
export const HttpError = t.iface([], {
|
||||
"title": "string",
|
||||
"status": "number",
|
||||
"details": "string",
|
||||
"developerMessage": "string",
|
||||
"timestamp": "string",
|
||||
title: 'string',
|
||||
status: 'number',
|
||||
details: 'string',
|
||||
developerMessage: 'string',
|
||||
timestamp: 'string',
|
||||
});
|
||||
|
||||
const exportedTypeSuite: t.ITypeSuite = {
|
||||
|
||||
@@ -4,4 +4,4 @@ export interface HttpError {
|
||||
details: string;
|
||||
developerMessage: string;
|
||||
timestamp: string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createCheckers } from "ts-interface-checker";
|
||||
import HttpError from "./httpError.model-ti";
|
||||
import { createCheckers } from 'ts-interface-checker';
|
||||
import HttpError from './httpError.model-ti';
|
||||
|
||||
const HttpErrorChecker = createCheckers(HttpError)['HttpError'];
|
||||
export default HttpErrorChecker;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/**
|
||||
* This module was automatically generated by `ts-interface-builder`
|
||||
*/
|
||||
import * as t from "ts-interface-checker";
|
||||
import * as t from 'ts-interface-checker';
|
||||
// tslint:disable:object-literal-key-quotes
|
||||
|
||||
export const Token = t.iface([], {
|
||||
"token": "string",
|
||||
"expirationDate": t.union("string", "number"),
|
||||
token: 'string',
|
||||
expirationDate: t.union('string', 'number'),
|
||||
});
|
||||
|
||||
const exportedTypeSuite: t.ITypeSuite = {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export interface Token {
|
||||
token: string,
|
||||
expirationDate: string|number
|
||||
}
|
||||
token: string;
|
||||
expirationDate: string | number;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { createCheckers } from "ts-interface-checker";
|
||||
import User from "./user.model-ti";
|
||||
import Token from "../token/token.model-ti";
|
||||
import { createCheckers } from 'ts-interface-checker';
|
||||
import User from './user.model-ti';
|
||||
import Token from '../token/token.model-ti';
|
||||
|
||||
const UserChecker = createCheckers(User, Token)['User'];
|
||||
export default UserChecker;
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
/**
|
||||
* This module was automatically generated by `ts-interface-builder`
|
||||
*/
|
||||
import * as t from "ts-interface-checker";
|
||||
import * as t from 'ts-interface-checker';
|
||||
// tslint:disable:object-literal-key-quotes
|
||||
|
||||
export const User = t.iface([], {
|
||||
"id": t.opt("number"),
|
||||
"name": t.opt("string"),
|
||||
"email": t.opt("string"),
|
||||
"username": "string",
|
||||
"password": t.opt("string"),
|
||||
"profilePictureUrl": t.opt("string"),
|
||||
"accessToken": t.opt("Token"),
|
||||
"refreshToken": t.opt("Token"),
|
||||
"roles": t.opt(t.array("string")),
|
||||
id: t.opt('number'),
|
||||
name: t.opt('string'),
|
||||
email: t.opt('string'),
|
||||
username: 'string',
|
||||
password: t.opt('string'),
|
||||
profilePictureUrl: t.opt('string'),
|
||||
accessToken: t.opt('Token'),
|
||||
refreshToken: t.opt('Token'),
|
||||
roles: t.opt(t.array('string')),
|
||||
});
|
||||
|
||||
const exportedTypeSuite: t.ITypeSuite = {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { Token } from "../token/token.model";
|
||||
import { Token } from '../token/token.model';
|
||||
|
||||
export interface User {
|
||||
id?: number,
|
||||
name?: string,
|
||||
email?: string,
|
||||
username: string,
|
||||
password?: string,
|
||||
profilePictureUrl?: string,
|
||||
accessToken?: Token,
|
||||
refreshToken?: Token,
|
||||
roles?: Array<string>,
|
||||
id?: number;
|
||||
name?: string;
|
||||
email?: string;
|
||||
username: string;
|
||||
password?: string;
|
||||
profilePictureUrl?: string;
|
||||
accessToken?: Token;
|
||||
refreshToken?: Token;
|
||||
roles?: Array<string>;
|
||||
validateAccessToken?: () => Token | undefined;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,14 +3,14 @@ import { TestBed } from '@angular/core/testing';
|
||||
import { UpdateService } from './update.service';
|
||||
|
||||
describe('UpdateService', () => {
|
||||
let service: UpdateService;
|
||||
let service: UpdateService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(UpdateService);
|
||||
});
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(UpdateService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,26 +1,27 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {SwUpdate} from "@angular/service-worker";
|
||||
import {interval} from "rxjs";
|
||||
import { SwUpdate } from '@angular/service-worker';
|
||||
import { interval } from 'rxjs';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class UpdateService {
|
||||
|
||||
constructor(private swUpdate: SwUpdate) {
|
||||
if (swUpdate.isEnabled) {
|
||||
interval(6 * 60 * 60).subscribe(() => swUpdate.checkForUpdate()
|
||||
.then(() => console.log('checking for updates')));
|
||||
interval(6 * 60 * 60).subscribe(() =>
|
||||
swUpdate
|
||||
.checkForUpdate()
|
||||
.then(() => console.log('checking for updates')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public checkForUpdates(): void {
|
||||
this.swUpdate.available.subscribe(event => this.promptUser());
|
||||
this.swUpdate.available.subscribe((event) => this.promptUser());
|
||||
}
|
||||
|
||||
private promptUser(): void {
|
||||
console.log('updating to new version');
|
||||
this.swUpdate.activateUpdate().then(() => document.location.reload());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { PopupComponent } from './components/popup/popup.component';
|
||||
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
|
||||
import {CookieConsentModule} from "./cookie-consent/cookie-consent.module";
|
||||
import { CookieConsentModule } from './cookie-consent/cookie-consent.module';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
@@ -19,12 +19,8 @@ import {CookieConsentModule} from "./cookie-consent/cookie-consent.module";
|
||||
HttpClientModule,
|
||||
BrowserAnimationsModule,
|
||||
FontAwesomeModule,
|
||||
CookieConsentModule
|
||||
CookieConsentModule,
|
||||
],
|
||||
exports: [
|
||||
ClickedOutsideDirective,
|
||||
SliderItemComponent,
|
||||
PopupComponent
|
||||
]
|
||||
exports: [ClickedOutsideDirective, SliderItemComponent, PopupComponent],
|
||||
})
|
||||
export class SharedModule { }
|
||||
export class SharedModule {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {AbstractControl} from "@angular/forms";
|
||||
import { AbstractControl } from '@angular/forms';
|
||||
|
||||
export function ValidateEmailValidator(control: AbstractControl) {
|
||||
const email = control.value;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {AbstractControl} from "@angular/forms";
|
||||
import { AbstractControl } from '@angular/forms';
|
||||
|
||||
export function ValidateNotEmptyValidator(control: AbstractControl) {
|
||||
const value = control.value;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import {AbstractControl} from "@angular/forms";
|
||||
import { AbstractControl } from '@angular/forms';
|
||||
|
||||
export function ValidatePasswordValidator(control: AbstractControl) {
|
||||
var password = control.value;
|
||||
var passwordRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/g;
|
||||
var passwordRegex =
|
||||
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/g;
|
||||
var passwordValid = passwordRegex.test(password);
|
||||
if (!passwordValid) {
|
||||
return { invalidPassword: true };
|
||||
|
||||
Reference in New Issue
Block a user