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) => {
|
||||
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();
|
||||
}
|
||||
);
|
||||
|
||||
@@ -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 {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
min-width: 300px;
|
||||
padding: 25px;
|
||||
background-color: #ffffff;
|
||||
border-radius: 35px;
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||
max-height: 80vh;
|
||||
max-height: 90vh;
|
||||
overflow: scroll;
|
||||
}
|
||||
|
||||
@@ -28,7 +21,7 @@ body, html {
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin-top: 60px;
|
||||
margin-top: 40px;
|
||||
text-align: center;
|
||||
color: #333;
|
||||
}
|
||||
@@ -89,11 +82,6 @@ button:hover {
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
/* List styling */
|
||||
.url-list {
|
||||
margin-top: 40px;
|
||||
}
|
||||
|
||||
.url-list-items {
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
@@ -102,12 +90,16 @@ button:hover {
|
||||
.url-list-items li {
|
||||
background-color: #fff;
|
||||
padding: 10px 15px;
|
||||
margin-bottom: 10px;
|
||||
row-gap: 10px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 20px;
|
||||
line-height: 1.5rem;
|
||||
}
|
||||
|
||||
li + li {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.url-list-items a {
|
||||
color: #007bff;
|
||||
text-decoration: none;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import {Title} from '@angular/platform-browser';
|
||||
import {Router} from '@angular/router';
|
||||
import {UserService} from '../shared/services/user.service';
|
||||
import {ShortenerService} from '../shared/services/shortener.service';
|
||||
import {Observer} from 'rxjs';
|
||||
import {interval, Observer, Subscription} from 'rxjs';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {NgFor, NgIf, SlicePipe} from '@angular/common';
|
||||
import {AuthService} from '../shared/services/auth.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-shortener',
|
||||
@@ -27,11 +27,12 @@ export class ShortenerComponent implements OnInit {
|
||||
og_url: string = '';
|
||||
short_name: string | null = null;
|
||||
deleteId: number | null = null;
|
||||
tokenValidationInterval: Subscription = new Subscription();
|
||||
|
||||
constructor(
|
||||
private shortenerService: ShortenerService,
|
||||
private userService: UserService,
|
||||
private router: Router,
|
||||
private authService: AuthService,
|
||||
private titleService: Title
|
||||
) {}
|
||||
|
||||
@@ -39,6 +40,26 @@ export class ShortenerComponent implements OnInit {
|
||||
this.titleService.setTitle('Shortener | itzMiney')
|
||||
this.checkToken()
|
||||
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() {
|
||||
|
||||
Reference in new issue
Block a user