Skip to content

Commit

Permalink
ng lint
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuj committed Jan 28, 2025
1 parent b330408 commit 4de7542
Show file tree
Hide file tree
Showing 28 changed files with 141 additions and 131 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ import { HttpErrorResponse } from '@angular/common/http';
import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { CategoryDTO } from '../../../Models/category.dto';
import { CategoryService, deleteResponse } from '../../../Services/category.service';
import {
CategoryService,
deleteResponse
} from '../../../Services/category.service';
import { LocalStorageService } from '../../../Services/local-storage.service';
import { SharedService } from '../../../Services/shared.service';

@Component({
selector: 'app-categories-list',
// eslint-disable-next-line @angular-eslint/prefer-standalone
standalone: false,
templateUrl: './categories-list.component.html',
styleUrls: ['./categories-list.component.scss']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h1>Category form</h1>

<div *ngIf="title.errors">
<div
*ngIf="title.errors && isValidForm != null && !isValidForm"
*ngIf="title.errors && isValidForm !== null && !isValidForm"
[ngClass]="'error'"
>
<div *ngIf="title.errors.required">Title is required</div>
Expand All @@ -32,7 +32,7 @@ <h1>Category form</h1>

<div *ngIf="description.errors">
<div
*ngIf="description.errors && isValidForm != null && !isValidForm"
*ngIf="description.errors && isValidForm !== null && !isValidForm"
[ngClass]="'error'"
>
<div *ngIf="description.errors.required">Description is required</div>
Expand All @@ -50,7 +50,7 @@ <h1>Category form</h1>

<div *ngIf="css_color.errors">
<div
*ngIf="css_color.errors && isValidForm != null && !isValidForm"
*ngIf="css_color.errors && isValidForm !== null && !isValidForm"
[ngClass]="'error'"
>
<div *ngIf="css_color.errors.required">Css color is required</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
UntypedFormBuilder,
UntypedFormControl,
UntypedFormGroup,
Validators,
Validators
} from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { finalize } from 'rxjs/operators';
Expand All @@ -15,9 +15,10 @@ import { SharedService } from '../../../Services/shared.service';

@Component({
selector: 'app-category-form',
// eslint-disable-next-line @angular-eslint/prefer-standalone
standalone: false,
templateUrl: './category-form.component.html',
styleUrls: ['./category-form.component.scss'],
styleUrls: ['./category-form.component.scss']
})
export class CategoryFormComponent implements OnInit {
category: CategoryDTO;
Expand Down Expand Up @@ -46,23 +47,23 @@ export class CategoryFormComponent implements OnInit {

this.title = new UntypedFormControl(this.category.title, [
Validators.required,
Validators.maxLength(55),
Validators.maxLength(55)
]);

this.description = new UntypedFormControl(this.category.description, [
Validators.required,
Validators.maxLength(255),
Validators.maxLength(255)
]);

this.css_color = new UntypedFormControl(this.category.css_color, [
Validators.required,
Validators.maxLength(7),
Validators.maxLength(7)
]);

this.categoryForm = this.formBuilder.group({
title: this.title,
description: this.description,
css_color: this.css_color,
css_color: this.css_color
});
}

Expand All @@ -86,7 +87,7 @@ export class CategoryFormComponent implements OnInit {
this.categoryForm = this.formBuilder.group({
title: this.title,
description: this.description,
css_color: this.css_color,
css_color: this.css_color
});
},
(error: HttpErrorResponse) => {
Expand All @@ -99,7 +100,7 @@ export class CategoryFormComponent implements OnInit {

private editCategory(): void {
let errorResponse: any;
let responseOK: boolean = false;
let responseOK = false;
if (this.categoryId) {
const userId = this.localStorageService.get('user_id');
if (userId) {
Expand Down Expand Up @@ -135,7 +136,7 @@ export class CategoryFormComponent implements OnInit {

private createCategory(): void {
let errorResponse: any;
let responseOK: boolean = false;
let responseOK = false;
const userId = this.localStorageService.get('user_id');
if (userId) {
this.category.userId = userId;
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/app/Components/dashboard/dashboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ import { SharedService } from '../../Services/shared.service';

@Component({
selector: 'app-dashboard',
// eslint-disable-next-line @angular-eslint/prefer-standalone
standalone: false,
templateUrl: './dashboard.component.html',
styleUrls: ['./dashboard.component.scss'],
styleUrls: ['./dashboard.component.scss']
})
export class DashboardComponent implements OnInit {
posts!: PostDTO[];

numLikes: number = 0;
numDislikes: number = 0;
numLikes = 0;
numDislikes = 0;

constructor(
private postService: PostService,
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/Components/footer/footer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Component } from '@angular/core';

@Component({
selector: 'app-footer',
// eslint-disable-next-line @angular-eslint/prefer-standalone
standalone: false,
templateUrl: './footer.component.html',
styleUrls: ['./footer.component.scss']
})
export class FooterComponent {
}
export class FooterComponent {}
1 change: 1 addition & 0 deletions frontend/src/app/Components/header/header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { LocalStorageService } from '../../Services/local-storage.service';

@Component({
selector: 'app-header',
// eslint-disable-next-line @angular-eslint/prefer-standalone
standalone: false,
templateUrl: './header.component.html',
styleUrls: ['./header.component.scss']
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/app/Components/home/home.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HttpErrorResponse } from '@angular/common/http';
import { Component } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { HeaderMenus } from '../../Models/header-menus.dto';
import { PostDTO } from '../../Models/post.dto';
Expand All @@ -10,11 +10,12 @@ import { SharedService } from '../../Services/shared.service';

@Component({
selector: 'app-home',
// eslint-disable-next-line @angular-eslint/prefer-standalone
standalone: false,
templateUrl: './home.component.html',
styleUrls: ['./home.component.scss'],
styleUrls: ['./home.component.scss']
})
export class HomeComponent {
export class HomeComponent implements OnInit {
posts!: PostDTO[];
showButtons: boolean;
constructor(
Expand Down
17 changes: 9 additions & 8 deletions frontend/src/app/Components/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
UntypedFormBuilder,
UntypedFormControl,
UntypedFormGroup,
Validators,
Validators
} from '@angular/forms';
import { Router } from '@angular/router';
import { finalize } from 'rxjs/operators';
Expand All @@ -17,9 +17,10 @@ import { SharedService } from '../../Services/shared.service';

@Component({
selector: 'app-login',
// eslint-disable-next-line @angular-eslint/prefer-standalone
standalone: false,
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss'],
styleUrls: ['./login.component.scss']
})
export class LoginComponent implements OnInit {
loginUser: AuthDTO;
Expand All @@ -39,25 +40,25 @@ export class LoginComponent implements OnInit {

this.email = new UntypedFormControl('', [
Validators.required,
Validators.pattern('[a-z0-9._%+-]+@[a-z0-9.-]+.[a-z]{2,4}$'),
Validators.pattern('[a-z0-9._%+-]+@[a-z0-9.-]+.[a-z]{2,4}$')
]);

this.password = new UntypedFormControl('', [
Validators.required,
Validators.minLength(8),
Validators.maxLength(16),
Validators.maxLength(16)
]);

this.loginForm = this.formBuilder.group({
email: this.email,
password: this.password,
password: this.password
});
}

ngOnInit(): void {}

login(): void {
let responseOK: boolean = false;
let responseOK = false;
let errorResponse: any;

this.loginUser.email = this.email.value;
Expand All @@ -76,7 +77,7 @@ export class LoginComponent implements OnInit {
if (responseOK) {
const headerInfo: HeaderMenus = {
showAuthSection: true,
showNoAuthSection: false,
showNoAuthSection: false
};
this.headerMenusService.headerManagement.next(headerInfo);
this.router.navigateByUrl('home');
Expand All @@ -100,7 +101,7 @@ export class LoginComponent implements OnInit {
errorResponse = error.error;
const headerInfo: HeaderMenus = {
showAuthSection: false,
showNoAuthSection: true,
showNoAuthSection: true
};
this.headerMenusService.headerManagement.next(headerInfo);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ <h1>Post form</h1>

<div *ngIf="title.errors">
<div
*ngIf="title.errors && isValidForm != null && !isValidForm"
*ngIf="title.errors && isValidForm !== null && !isValidForm"
[ngClass]="'error'"
>
<div *ngIf="title.errors.required">Title is required</div>
Expand All @@ -28,7 +28,7 @@ <h1>Post form</h1>

<div *ngIf="description.errors">
<div
*ngIf="description.errors && isValidForm != null && !isValidForm"
*ngIf="description.errors && isValidForm !== null && !isValidForm"
[ngClass]="'error'"
>
<div *ngIf="description.errors.required">Description is required</div>
Expand All @@ -44,7 +44,7 @@ <h1>Post form</h1>
<label for="publicationDate">Publication date: </label>
<input type="date" [formControl]="publication_date" />
<div
*ngIf="publication_date.errors && isValidForm != null && !isValidForm"
*ngIf="publication_date.errors && isValidForm !== null && !isValidForm"
[ngClass]="'error'"
>
<div *ngIf="publication_date.errors.required">
Expand Down
19 changes: 10 additions & 9 deletions frontend/src/app/Components/posts/post-form/post-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
UntypedFormBuilder,
UntypedFormControl,
UntypedFormGroup,
Validators,
Validators
} from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { finalize } from 'rxjs/operators';
Expand All @@ -18,9 +18,10 @@ import { SharedService } from '../../../Services/shared.service';

@Component({
selector: 'app-post-form',
// eslint-disable-next-line @angular-eslint/prefer-standalone
standalone: false,
templateUrl: './post-form.component.html',
styleUrls: ['./post-form.component.scss'],
styleUrls: ['./post-form.component.scss']
})
export class PostFormComponent implements OnInit {
post: PostDTO;
Expand Down Expand Up @@ -55,12 +56,12 @@ export class PostFormComponent implements OnInit {

this.title = new UntypedFormControl(this.post.title, [
Validators.required,
Validators.maxLength(55),
Validators.maxLength(55)
]);

this.description = new UntypedFormControl(this.post.description, [
Validators.required,
Validators.maxLength(255),
Validators.maxLength(255)
]);

this.publication_date = new UntypedFormControl(
Expand All @@ -82,7 +83,7 @@ export class PostFormComponent implements OnInit {
publication_date: this.publication_date,
categories: this.categories,
num_likes: this.num_likes,
num_dislikes: this.num_dislikes,
num_dislikes: this.num_dislikes
});
}

Expand Down Expand Up @@ -120,7 +121,7 @@ export class PostFormComponent implements OnInit {
formatDate(this.post.publication_date, 'yyyy-MM-dd', 'en')
);

let categoriesIds: string[] = [];
const categoriesIds: string[] = [];
this.post.categories.forEach((cat: CategoryDTO) => {
categoriesIds.push(cat.categoryId);
});
Expand All @@ -136,7 +137,7 @@ export class PostFormComponent implements OnInit {
publication_date: this.publication_date,
categories: this.categories,
num_likes: this.num_likes,
num_dislikes: this.num_dislikes,
num_dislikes: this.num_dislikes
});
},
(error: HttpErrorResponse) => {
Expand All @@ -149,7 +150,7 @@ export class PostFormComponent implements OnInit {

private editPost(): void {
let errorResponse: any;
let responseOK: boolean = false;
let responseOK = false;
if (this.postId) {
const userId = this.localStorageService.get('user_id');
if (userId) {
Expand Down Expand Up @@ -185,7 +186,7 @@ export class PostFormComponent implements OnInit {

private createPost(): void {
let errorResponse: any;
let responseOK: boolean = false;
let responseOK = false;
const userId = this.localStorageService.get('user_id');
if (userId) {
this.post.userId = userId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { SharedService } from '../../../Services/shared.service';

@Component({
selector: 'app-posts-list',
// eslint-disable-next-line @angular-eslint/prefer-standalone
standalone: false,
templateUrl: './posts-list.component.html',
styleUrls: ['./posts-list.component.scss']
Expand Down
Loading

0 comments on commit 4de7542

Please sign in to comment.