Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/src/app/common/components/logo/logo.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, inject } from '@angular/core';
import {Component, inject, Input} from '@angular/core';
import {Router} from '@angular/router';

@Component({
Expand All @@ -7,8 +7,8 @@ import {Router} from '@angular/router';
templateUrl: './logo.component.html',
styleUrl: './logo.component.scss'
})
export class LogoComponent {
private router = inject(Router);
export class LogoComponent {
private router = inject(Router);

@Input() height: number = 50;
@Input() fontSize: number = 35;
Expand Down
6 changes: 3 additions & 3 deletions src/src/app/common/interface/oauth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface OAuth {
bearer: string,
refresh: string,
expiresUtc: string
bearer: string,
refresh: string,
expiresUtc: string
}
6 changes: 3 additions & 3 deletions src/src/app/service/nullinside-null.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, inject } from '@angular/core';
import {inject, Injectable} from '@angular/core';
import {Observable} from 'rxjs';
import {environment} from '../../environments/environment';
import {HttpClient} from '@angular/common/http';
Expand All @@ -7,8 +7,8 @@ import {ImdbSearch} from '../common/interface/imdb-search';
@Injectable({
providedIn: 'root'
})
export class NullinsideNullService {
private httpClient = inject(HttpClient);
export class NullinsideNullService {
private httpClient = inject(HttpClient);


getImdbSearchQuick(search: string): Observable<ImdbSearch> {
Expand Down
6 changes: 3 additions & 3 deletions src/src/app/service/nullinside-twitch-bot.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, inject } from '@angular/core';
import {inject, Injectable} from '@angular/core';
import {HttpClient} from "@angular/common/http";
import {Observable} from "rxjs";
import {environment} from "../../environments/environment";
Expand All @@ -8,8 +8,8 @@ import {TwitchBotConfig} from "../common/interface/twitch-bot-config";
@Injectable({
providedIn: 'root'
})
export class NullinsideTwitchBotService {
private httpClient = inject(HttpClient);
export class NullinsideTwitchBotService {
private httpClient = inject(HttpClient);


getIsMod(): Observable<TwitchBotIsModResponse> {
Expand Down
6 changes: 3 additions & 3 deletions src/src/app/service/nullinside.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, inject } from '@angular/core';
import {inject, Injectable} from '@angular/core';
import {HttpClient} from "@angular/common/http";
import {Observable} from "rxjs";
import {environment} from "../../environments/environment";
Expand All @@ -9,8 +9,8 @@ import {FeatureToggleResponse} from "../common/interface/feature-toggle-response
@Injectable({
providedIn: 'root'
})
export class NullinsideService {
private httpClient = inject(HttpClient);
export class NullinsideService {
private httpClient = inject(HttpClient);


validateToken(token: string): Observable<boolean> {
Expand Down
8 changes: 4 additions & 4 deletions src/src/app/view/home/home.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, inject } from '@angular/core';
import {Component, inject, OnInit} from '@angular/core';
import {NullinsideService} from "../../service/nullinside.service";
import {VM_ADMIN} from "../../common/constants";
import {WebsiteApp} from "../../common/interface/website-app";
Expand All @@ -17,9 +17,9 @@ import {UserRolesResponse} from "../../common/interface/user-roles-response";
templateUrl: './home.component.html',
styleUrl: './home.component.scss'
})
export class HomeComponent implements OnInit {
private api = inject(NullinsideService);
private router = inject(Router);
export class HomeComponent implements OnInit {
private api = inject(NullinsideService);
private router = inject(Router);

public roles: string[] | null = null;
public error: string | null = null;
Expand Down
6 changes: 3 additions & 3 deletions src/src/app/view/imdb-search/imdb-search.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnDestroy, inject } from '@angular/core';
import {Component, inject, OnDestroy} from '@angular/core';
import {LogoComponent} from '../../common/components/logo/logo.component';
import {NullinsideNullService} from '../../service/nullinside-null.service';
import {MatFormFieldModule} from '@angular/material/form-field';
Expand All @@ -20,8 +20,8 @@ import {ImdbSearchItems} from '../../common/interface/imdb-search';
templateUrl: './imdb-search.component.html',
styleUrl: './imdb-search.component.scss'
})
export class ImdbSearchComponent implements OnDestroy {
private api = inject(NullinsideNullService);
export class ImdbSearchComponent implements OnDestroy {
private api = inject(NullinsideNullService);

searching: boolean = false;
quickSubscription: Subscription | null = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, inject } from '@angular/core';
import {Component, inject, OnInit} from '@angular/core';
import {ActivatedRoute, ParamMap} from "@angular/router";
import {Errors} from "../login-landing/errors";
import {HttpErrorResponse} from "@angular/common/http";
Expand All @@ -10,106 +10,106 @@ import {CdkCopyToClipboard} from "@angular/cdk/clipboard";
import {interval, Subscription} from "rxjs";

@Component({
selector: 'app-login-landing-desktop',
imports: [
LoadingIconComponent,
LogoComponent,
MatButton,
CdkCopyToClipboard
],
templateUrl: './login-landing-desktop.component.html',
styleUrl: './login-landing-desktop.component.scss'
selector: 'app-login-landing-desktop',
imports: [
LoadingIconComponent,
LogoComponent,
MatButton,
CdkCopyToClipboard
],
templateUrl: './login-landing-desktop.component.html',
styleUrl: './login-landing-desktop.component.scss'
})
export class LoginLandingDesktopComponent implements OnInit {
private route = inject(ActivatedRoute);
private timer: Subscription | undefined;
private desktopData: string | undefined;
private route = inject(ActivatedRoute);
private timer: Subscription | undefined;
private desktopData: string | undefined;

loggedIn: boolean = false;
error: string = '';
oAuth: OAuth | null = null;
loading: boolean = true;
loggedIn: boolean = false;
error: string = '';
oAuth: OAuth | null = null;
loading: boolean = true;

ngOnInit(): void {
this.route.queryParamMap.subscribe({
next: (params: ParamMap) => {
const error = params.get('error');
if (null !== error) {
const errorNum = +error;
if (Errors.TWITCH_ACCOUNT_HAS_NO_EMAIL === errorNum) {
this.onLoginFailed('Your Twitch account must have a valid e-mail address, please add one and try again')
} else if (Errors.TWITCH_ERROR_WITH_TOKEN === errorNum) {
this.onLoginFailed('Twitch failed to give us a valid token, please try again')
} else {
this.onLoginFailed('Sorry we did something wrong trying to log you in, please try again')
}
ngOnInit(): void {
this.route.queryParamMap.subscribe({
next: (params: ParamMap) => {
const error = params.get('error');
if (null !== error) {
const errorNum = +error;
if (Errors.TWITCH_ACCOUNT_HAS_NO_EMAIL === errorNum) {
this.onLoginFailed('Your Twitch account must have a valid e-mail address, please add one and try again')
} else if (Errors.TWITCH_ERROR_WITH_TOKEN === errorNum) {
this.onLoginFailed('Twitch failed to give us a valid token, please try again')
} else {
this.onLoginFailed('Sorry we did something wrong trying to log you in, please try again')
}

return;
}
return;
}

const oAuth = {
bearer: params.get('bearer'),
refresh: params.get('refresh'),
expiresUtc: params.get('expiresUtc'),
};
const oAuth = {
bearer: params.get('bearer'),
refresh: params.get('refresh'),
expiresUtc: params.get('expiresUtc'),
};

if (null === oAuth.bearer || null === oAuth.refresh || null === oAuth.expiresUtc) {
this.onLoginFailed();
return;
}
if (null === oAuth.bearer || null === oAuth.refresh || null === oAuth.expiresUtc) {
this.onLoginFailed();
return;
}

this.oAuth = {
bearer: oAuth.bearer,
refresh: oAuth.refresh,
expiresUtc: oAuth.expiresUtc
};
this.oAuth = {
bearer: oAuth.bearer,
refresh: oAuth.refresh,
expiresUtc: oAuth.expiresUtc
};

// DO NOT assign this.desktopData until AFTER you update the clipboard successfully.
// The absence of a value on this.desktopData is what tells the application we haven't logged in yet.
const json = JSON.stringify(oAuth);
navigator.clipboard.writeText(json);
this.desktopData = json;
// DO NOT assign this.desktopData until AFTER you update the clipboard successfully.
// The absence of a value on this.desktopData is what tells the application we haven't logged in yet.
const json = JSON.stringify(oAuth);
navigator.clipboard.writeText(json);
this.desktopData = json;

this.loading = false;
this.timer = interval(1000)
.subscribe({
next: _ => {
this.runCheckForLogin();
},
error: e => {
console.error(e);
}
});
this.loading = false;
this.timer = interval(1000)
.subscribe({
next: _ => {
this.runCheckForLogin();
},
error: (_: HttpErrorResponse) => {
this.onLoginFailed();
error: e => {
console.error(e);
}
});
}
});
},
error: (_: HttpErrorResponse) => {
this.onLoginFailed();
}
});
}

private runCheckForLogin() {
try {
navigator.clipboard.readText().then(text => {
// If the text matches what we put on the clipboard then we aren't signed in yet.
if (undefined === this.desktopData || text === this.desktopData) {
return;
}
private runCheckForLogin() {
try {
navigator.clipboard.readText().then(text => {
// If the text matches what we put on the clipboard then we aren't signed in yet.
if (undefined === this.desktopData || text === this.desktopData) {
return;
}

// If the text does match, we are signed in on the desktop app. Maybe...kinda....might be...you never know...
// Don't judge me. -.-
this.timer?.unsubscribe();
this.loggedIn = true;
})
} catch {
// Do nothing, just don't crash.
}
// If the text does match, we are signed in on the desktop app. Maybe...kinda....might be...you never know...
// Don't judge me. -.-
this.timer?.unsubscribe();
this.loggedIn = true;
})
} catch {
// Do nothing, just don't crash.
}
}

onLoginFailed(message = ':( Failed to login, please try again'): void {
this.error = message;
this.loading = false;
}
onLoginFailed(message = ':( Failed to login, please try again'): void {
this.error = message;
this.loading = false;
}

protected readonly JSON = JSON;
protected readonly window = window;
protected readonly JSON = JSON;
protected readonly window = window;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnDestroy, OnInit, inject } from '@angular/core';
import {Component, inject, OnDestroy, OnInit} from '@angular/core';
import {NullinsideService} from "../../service/nullinside.service";
import {LogoComponent} from "../../common/components/logo/logo.component";
import {LoadingIconComponent} from "../../common/components/loading-icon/loading-icon.component";
Expand Down
10 changes: 5 additions & 5 deletions src/src/app/view/login/login.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, inject } from '@angular/core';
import {Component, inject, OnInit} from '@angular/core';
import {LogoComponent} from "../../common/components/logo/logo.component";
import {environment} from "../../../environments/environment";
import {NullinsideService} from "../../service/nullinside.service";
Expand All @@ -17,10 +17,10 @@ import {TwitchLoginComponent} from '../../common/components/twitch-login/twitch-
templateUrl: './login.component.html',
styleUrl: './login.component.scss'
})
export class LoginComponent implements OnInit {
private api = inject(NullinsideService);
private router = inject(Router);
private route = inject(ActivatedRoute);
export class LoginComponent implements OnInit {
private api = inject(NullinsideService);
private router = inject(Router);
private route = inject(ActivatedRoute);

loginUrl: string;
checkingLogin = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnDestroy, OnInit, inject } from '@angular/core';
import {Component, inject, OnDestroy, OnInit} from '@angular/core';
import {LogoComponent} from '../../../common/components/logo/logo.component';
import {MatButton} from '@angular/material/button';
import {NullinsideTwitchBotService} from "../../../service/nullinside-twitch-bot.service";
Expand Down
2 changes: 1 addition & 1 deletion src/src/app/view/vm-manager/vm-manager.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnDestroy, OnInit, inject } from '@angular/core';
import {Component, inject, OnDestroy, OnInit} from '@angular/core';
import {LogoComponent} from '../../common/components/logo/logo.component';
import {NullinsideService} from '../../service/nullinside.service';
import {MatIcon} from '@angular/material/icon';
Expand Down