Skip to content

Commit

Permalink
chore: format project using prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
eTallang committed Jun 25, 2024
1 parent 3360571 commit 8fa66d5
Show file tree
Hide file tree
Showing 7 changed files with 199 additions and 199 deletions.
132 changes: 66 additions & 66 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
import { Component, HostListener, OnInit } from '@angular/core';
import { Subject } from 'rxjs';
import { Router } from '@angular/router';
import { MatDialog } from '@angular/material/dialog';
import { RouterOutlet } from '@angular/router';

import { IdleTimeoutComponent } from './idle-timeout/idle-timeout.component';
import { routeTransitionAnimations } from './route-transition-animations';
import { environment } from '../environments/environment';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
animations: [routeTransitionAnimations],
standalone: true,
imports: [RouterOutlet],
})
export class AppComponent implements OnInit {
title = 'Teknisk Museum';

userActivity = 0;
userInactive = new Subject<any>();

isDialogOpen = false;
inactivityTime = environment.inactivityTime;

constructor(private router: Router, public dialog: MatDialog) {}

ngOnInit(): void {
this.setDialogTimeout();
this.userInactive.subscribe(() => {
if (this.router.url !== '/' && this.router.url !== '/admin') {
this.openDialog();
}
});
}

openDialog() {
if (!this.isDialogOpen) {
this.dialog
.open(IdleTimeoutComponent)
.afterClosed()
.subscribe(() => {
this.isDialogOpen = false;
});
this.isDialogOpen = true;
}
}

setDialogTimeout() {
this.userActivity = window.setTimeout(() => this.userInactive.next(undefined), this.inactivityTime);
}

prepareRoute(outlet: RouterOutlet) {
const animationState = 'animationState';
return outlet && outlet.activatedRouteData && outlet.activatedRouteData[animationState];
}

@HostListener('window:mousemove')
@HostListener('document:touchmove')
refreshUserState() {
clearTimeout(this.userActivity);
this.setDialogTimeout();
}
}
import { Component, HostListener, OnInit } from '@angular/core';
import { Subject } from 'rxjs';
import { Router } from '@angular/router';
import { MatDialog } from '@angular/material/dialog';
import { RouterOutlet } from '@angular/router';

import { IdleTimeoutComponent } from './idle-timeout/idle-timeout.component';
import { routeTransitionAnimations } from './route-transition-animations';
import { environment } from '../environments/environment';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
animations: [routeTransitionAnimations],
standalone: true,
imports: [RouterOutlet],
})
export class AppComponent implements OnInit {
title = 'Teknisk Museum';

userActivity = 0;
userInactive = new Subject<any>();

isDialogOpen = false;
inactivityTime = environment.inactivityTime;

constructor(private router: Router, public dialog: MatDialog) {}

ngOnInit(): void {
this.setDialogTimeout();
this.userInactive.subscribe(() => {
if (this.router.url !== '/' && this.router.url !== '/admin') {
this.openDialog();
}
});
}

openDialog() {
if (!this.isDialogOpen) {
this.dialog
.open(IdleTimeoutComponent)
.afterClosed()
.subscribe(() => {
this.isDialogOpen = false;
});
this.isDialogOpen = true;
}
}

setDialogTimeout() {
this.userActivity = window.setTimeout(() => this.userInactive.next(undefined), this.inactivityTime);
}

prepareRoute(outlet: RouterOutlet) {
const animationState = 'animationState';
return outlet && outlet.activatedRouteData && outlet.activatedRouteData[animationState];
}

@HostListener('window:mousemove')
@HostListener('document:touchmove')
refreshUserState() {
clearTimeout(this.userActivity);
this.setDialogTimeout();
}
}
80 changes: 40 additions & 40 deletions src/app/route-transition-animations.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
import { trigger, transition, style, query, animateChild, group, animate } from '@angular/animations';

export const routeTransitionAnimations = trigger('triggerName', [
transition('welcome => game', [
style({ position: 'relative' }),
query(':enter, :leave', [
style({
position: 'absolute',
top: 0,
right: 0,
width: '100%',
}),
]),
query(':enter', [style({ right: '-100%', opacity: 0 })]),
query(':leave', animateChild()),
group([
query(':leave', [animate('0.4s ease-out', style({ right: '100%', opacity: 0 }))]),
query(':enter', [animate('0.4s ease-out', style({ right: '0%', opacity: 1 }))]),
]),
query(':enter', animateChild()),
]),
transition('game => welcome, game => game', [
style({ position: 'relative' }),
query(':enter, :leave', [
style({
position: 'absolute',
top: 0,
left: 0,
width: '100%',
}),
]),
query(':enter', [style({ left: '-100%', opacity: 0 })]),
query(':leave', animateChild()),
group([
query(':leave', [animate('0.4s ease-out', style({ left: '100%', opacity: 0 }))]),
query(':enter', [animate('0.4s ease-out', style({ left: '0%', opacity: 1 }))]),
]),
query(':enter', animateChild()),
]),
]);
import { trigger, transition, style, query, animateChild, group, animate } from '@angular/animations';

export const routeTransitionAnimations = trigger('triggerName', [
transition('welcome => game', [
style({ position: 'relative' }),
query(':enter, :leave', [
style({
position: 'absolute',
top: 0,
right: 0,
width: '100%',
}),
]),
query(':enter', [style({ right: '-100%', opacity: 0 })]),
query(':leave', animateChild()),
group([
query(':leave', [animate('0.4s ease-out', style({ right: '100%', opacity: 0 }))]),
query(':enter', [animate('0.4s ease-out', style({ right: '0%', opacity: 1 }))]),
]),
query(':enter', animateChild()),
]),
transition('game => welcome, game => game', [
style({ position: 'relative' }),
query(':enter, :leave', [
style({
position: 'absolute',
top: 0,
left: 0,
width: '100%',
}),
]),
query(':enter', [style({ left: '-100%', opacity: 0 })]),
query(':leave', animateChild()),
group([
query(':leave', [animate('0.4s ease-out', style({ left: '100%', opacity: 0 }))]),
query(':enter', [animate('0.4s ease-out', style({ left: '0%', opacity: 1 }))]),
]),
query(':enter', animateChild()),
]),
]);
96 changes: 48 additions & 48 deletions src/app/routes.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
import { Routes } from '@angular/router';
import { WelcomeComponent } from './welcome/welcome.component';
import { GameComponent } from './game/game.component';
import { routes as r } from './shared/models/routes';
import { GameResultComponent } from './game/game-result/game-result.component';
import { GameDrawComponent } from './game/game-draw/game-draw.component';
import { AdminComponent } from './admin/admin.component';
import { InfoComponent } from './admin/info/info.component';
import { authGuard } from './admin/auth-guard';
import { MultiplayerComponent } from './game/game-multiplayer/multiplayer.component';

export const routes: Routes = [
{
path: r.LANDING,
component: WelcomeComponent,
data: { animationState: 'welcome' },
},
{
path: r.SINGLEPLAYER,
component: GameComponent,
data: { animationState: 'game' },
},
{
path: r.MULTIPLAYER,
component: MultiplayerComponent,
},
{
path: 'summary',
component: GameResultComponent,
},
{
path: 'summary/multiplayer',
component: GameResultComponent,
},
{
path: 'drawing',
component: GameDrawComponent,
},
{
path: 'admin',
component: AdminComponent,
},
{
path: 'admin/info',
component: InfoComponent,
canActivate: [authGuard],
},
];
import { Routes } from '@angular/router';
import { WelcomeComponent } from './welcome/welcome.component';
import { GameComponent } from './game/game.component';
import { routes as r } from './shared/models/routes';
import { GameResultComponent } from './game/game-result/game-result.component';
import { GameDrawComponent } from './game/game-draw/game-draw.component';
import { AdminComponent } from './admin/admin.component';
import { InfoComponent } from './admin/info/info.component';
import { authGuard } from './admin/auth-guard';
import { MultiplayerComponent } from './game/game-multiplayer/multiplayer.component';

export const routes: Routes = [
{
path: r.LANDING,
component: WelcomeComponent,
data: { animationState: 'welcome' },
},
{
path: r.SINGLEPLAYER,
component: GameComponent,
data: { animationState: 'game' },
},
{
path: r.MULTIPLAYER,
component: MultiplayerComponent,
},
{
path: 'summary',
component: GameResultComponent,
},
{
path: 'summary/multiplayer',
component: GameResultComponent,
},
{
path: 'drawing',
component: GameDrawComponent,
},
{
path: 'admin',
component: AdminComponent,
},
{
path: 'admin/info',
component: InfoComponent,
canActivate: [authGuard],
},
];
16 changes: 8 additions & 8 deletions src/environments/environment.computas.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export const environment = {
production: true,
WS_ENDPOINT: 'wss://teknisk-museum-backend.azurewebsites.net',
// TEKNISKBACKEND_ENDPOINT :'https://tekniskback.azurewebsites.net',
TEKNISKBACKEND_ENDPOINT: 'https://teknisk-museum-backend-singleplayer.azurewebsites.net',
inactivityTime: 60 * 1000,
PAIR_ID: 'f368b28b-4d39-4362-8c8c-c1f230c64fb0',
};
export const environment = {
production: true,
WS_ENDPOINT: 'wss://teknisk-museum-backend.azurewebsites.net',
// TEKNISKBACKEND_ENDPOINT :'https://tekniskback.azurewebsites.net',
TEKNISKBACKEND_ENDPOINT: 'https://teknisk-museum-backend-singleplayer.azurewebsites.net',
inactivityTime: 60 * 1000,
PAIR_ID: 'f368b28b-4d39-4362-8c8c-c1f230c64fb0',
};
14 changes: 7 additions & 7 deletions src/environments/environment.dev.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const environment = {
production: false,
WS_ENDPOINT: 'ws://localhost:8000',
TEKNISKBACKEND_ENDPOINT : 'http://localhost:8000',
inactivityTime: 60 * 1000,
PAIR_ID: 'dev-1'
};
export const environment = {
production: false,
WS_ENDPOINT: 'ws://localhost:8000',
TEKNISKBACKEND_ENDPOINT: 'http://localhost:8000',
inactivityTime: 60 * 1000,
PAIR_ID: 'dev-1',
};
16 changes: 8 additions & 8 deletions src/environments/environment.tekniskmuseumprod.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export const environment = {
production: true,
WS_ENDPOINT: 'wss://tekniskmuseumbackendmultiplayer.azurewebsites.net',
// TEKNISKBACKEND_ENDPOINT :'https://tekniskback.azurewebsites.net',
TEKNISKBACKEND_ENDPOINT :'https://tekniskmuseumbackendsingleplayer-dev.azurewebsites.net',
inactivityTime: 60 * 1000,
PAIR_ID: 'teknisk-1'
};
export const environment = {
production: true,
WS_ENDPOINT: 'wss://tekniskmuseumbackendmultiplayer.azurewebsites.net',
// TEKNISKBACKEND_ENDPOINT :'https://tekniskback.azurewebsites.net',
TEKNISKBACKEND_ENDPOINT: 'https://tekniskmuseumbackendsingleplayer-dev.azurewebsites.net',
inactivityTime: 60 * 1000,
PAIR_ID: 'teknisk-1',
};
Loading

0 comments on commit 8fa66d5

Please sign in to comment.