Fixed some styling and token validation issues
This commit is contained in:
1 parent
3dbc562147
commit
a4c0898be8
3 files changed
+34
-19
No files matched your search
@@ -75,11 +75,13 @@ export class AdminComponent implements OnInit, OnDestroy {
|
|||||||
(isValid: boolean) => {
|
(isValid: boolean) => {
|
||||||
if (!isValid) {
|
if (!isValid) {
|
||||||
console.warn('Token is no longer valid. Logging out.');
|
console.warn('Token is no longer valid. Logging out.');
|
||||||
|
localStorage.removeItem('token');
|
||||||
this.navigateToLogin();
|
this.navigateToLogin();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
console.error('Error validating token:', error);
|
console.error('Error validating token:', error);
|
||||||
|
localStorage.removeItem('token');
|
||||||
this.navigateToLogin();
|
this.navigateToLogin();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,21 +1,14 @@
|
|||||||
/* Make the body fill the entire height of the viewport */
|
|
||||||
body, html {
|
|
||||||
height: 100%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Flexbox to center the container */
|
|
||||||
.container {
|
.container {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: flex-start;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
min-width: 300px;
|
min-width: 300px;
|
||||||
padding: 25px;
|
padding: 25px;
|
||||||
background-color: #ffffff;
|
background-color: #ffffff;
|
||||||
border-radius: 35px;
|
border-radius: 35px;
|
||||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||||
max-height: 80vh;
|
max-height: 90vh;
|
||||||
overflow: scroll;
|
overflow: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,7 +21,7 @@ body, html {
|
|||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
margin-top: 60px;
|
margin-top: 40px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: #333;
|
color: #333;
|
||||||
}
|
}
|
||||||
@@ -89,11 +82,6 @@ button:hover {
|
|||||||
opacity: 0.9;
|
opacity: 0.9;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* List styling */
|
|
||||||
.url-list {
|
|
||||||
margin-top: 40px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.url-list-items {
|
.url-list-items {
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
@@ -102,12 +90,16 @@ button:hover {
|
|||||||
.url-list-items li {
|
.url-list-items li {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
padding: 10px 15px;
|
padding: 10px 15px;
|
||||||
margin-bottom: 10px;
|
row-gap: 10px;
|
||||||
border: 1px solid #ddd;
|
border: 1px solid #ddd;
|
||||||
border-radius: 20px;
|
border-radius: 20px;
|
||||||
line-height: 1.5rem;
|
line-height: 1.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
li + li {
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
.url-list-items a {
|
.url-list-items a {
|
||||||
color: #007bff;
|
color: #007bff;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import {Title} from '@angular/platform-browser';
|
import {Title} from '@angular/platform-browser';
|
||||||
import {Router} from '@angular/router';
|
import {Router} from '@angular/router';
|
||||||
import {UserService} from '../shared/services/user.service';
|
|
||||||
import {ShortenerService} from '../shared/services/shortener.service';
|
import {ShortenerService} from '../shared/services/shortener.service';
|
||||||
import {Observer} from 'rxjs';
|
import {interval, Observer, Subscription} from 'rxjs';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {NgFor, NgIf, SlicePipe} from '@angular/common';
|
import {NgFor, NgIf, SlicePipe} from '@angular/common';
|
||||||
|
import {AuthService} from '../shared/services/auth.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-shortener',
|
selector: 'app-shortener',
|
||||||
@@ -27,11 +27,12 @@ export class ShortenerComponent implements OnInit {
|
|||||||
og_url: string = '';
|
og_url: string = '';
|
||||||
short_name: string | null = null;
|
short_name: string | null = null;
|
||||||
deleteId: number | null = null;
|
deleteId: number | null = null;
|
||||||
|
tokenValidationInterval: Subscription = new Subscription();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private shortenerService: ShortenerService,
|
private shortenerService: ShortenerService,
|
||||||
private userService: UserService,
|
|
||||||
private router: Router,
|
private router: Router,
|
||||||
|
private authService: AuthService,
|
||||||
private titleService: Title
|
private titleService: Title
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@@ -39,6 +40,26 @@ export class ShortenerComponent implements OnInit {
|
|||||||
this.titleService.setTitle('Shortener | itzMiney')
|
this.titleService.setTitle('Shortener | itzMiney')
|
||||||
this.checkToken()
|
this.checkToken()
|
||||||
this.loadURLs();
|
this.loadURLs();
|
||||||
|
this.startTokenValidation();
|
||||||
|
}
|
||||||
|
|
||||||
|
startTokenValidation() {
|
||||||
|
this.tokenValidationInterval = interval(300000).subscribe(() => {
|
||||||
|
this.authService.isTokenValid(this.token).subscribe(
|
||||||
|
(isValid: boolean) => {
|
||||||
|
if (!isValid) {
|
||||||
|
console.warn('Token is no longer valid. Logging out.');
|
||||||
|
localStorage.removeItem('token');
|
||||||
|
this.navigateToLogin();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
console.error('Error validating token:', error);
|
||||||
|
localStorage.removeItem('token');
|
||||||
|
this.navigateToLogin();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
checkToken() {
|
checkToken() {
|
||||||
|
|||||||
Reference in new issue
Block a user