aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2021-01-16 11:53:20 +0200
committerSyndamia <kamen.d.mladenov@protonmail.com>2021-01-16 11:53:20 +0200
commit4332e0adec2d7768355cea9177dee41b50dc9f66 (patch)
tree264a373e58abad83d05ead9dcb7ce0f561c3b1fb /src
parent785be4cff44aed1ab7db58cf238667f7c7d2319a (diff)
downloadDevHive-4332e0adec2d7768355cea9177dee41b50dc9f66.tar
DevHive-4332e0adec2d7768355cea9177dee41b50dc9f66.tar.gz
DevHive-4332e0adec2d7768355cea9177dee41b50dc9f66.zip
Fixed naming of private properties, replaced tab indentation with spaces, fixed return type of getters and setters, fixed some other spacing
Diffstat (limited to 'src')
-rw-r--r--src/DevHive.Angular/src/app/components/feed/feed.component.ts8
-rw-r--r--src/DevHive.Angular/src/app/components/login/login.component.ts21
-rw-r--r--src/DevHive.Angular/src/app/components/post/post.component.ts34
-rw-r--r--src/DevHive.Angular/src/app/components/register/register.component.ts27
-rw-r--r--src/DevHive.Angular/src/models/identity/register-user.ts37
-rw-r--r--src/DevHive.Angular/src/models/identity/user.ts94
6 files changed, 91 insertions, 130 deletions
diff --git a/src/DevHive.Angular/src/app/components/feed/feed.component.ts b/src/DevHive.Angular/src/app/components/feed/feed.component.ts
index 144e76a..33e0ba0 100644
--- a/src/DevHive.Angular/src/app/components/feed/feed.component.ts
+++ b/src/DevHive.Angular/src/app/components/feed/feed.component.ts
@@ -17,8 +17,8 @@ export class FeedComponent implements OnInit {
public user: User;
public posts: PostComponent[];
- constructor(private titleService: Title, private router: Router, private userService: UserService) {
- this.titleService.setTitle(this._title);
+ constructor(private _titleService: Title, private _router: Router, private _userService: UserService) {
+ this._titleService.setTitle(this._title);
}
ngOnInit(): void {
@@ -34,7 +34,7 @@ export class FeedComponent implements OnInit {
// TODO: properly wait for it, before loading the page contents
setTimeout(() =>
{
- this.user = this.userService.fetchUserFromSessionStorage();
+ this.user = this._userService.fetchUserFromSessionStorage();
},
this._timeoutFetchData);
setTimeout(() =>
@@ -43,7 +43,7 @@ export class FeedComponent implements OnInit {
},
this._timeoutFetchData + 100);
} else {
- this.router.navigate(['/login']);
+ this._router.navigate(['/login']);
}
}
}
diff --git a/src/DevHive.Angular/src/app/components/login/login.component.ts b/src/DevHive.Angular/src/app/components/login/login.component.ts
index de40a21..a9206f2 100644
--- a/src/DevHive.Angular/src/app/components/login/login.component.ts
+++ b/src/DevHive.Angular/src/app/components/login/login.component.ts
@@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core';
-import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms';
+import { FormGroup, FormBuilder, Validators, FormControl, AbstractControl } from '@angular/forms';
import { Router } from '@angular/router';
import { Title } from '@angular/platform-browser';
import { UserService } from 'src/app/services/user.service';
@@ -10,16 +10,15 @@ import { UserService } from 'src/app/services/user.service';
styleUrls: ['./login.component.css']
})
export class LoginComponent implements OnInit {
- loginUserFormGroup: FormGroup;
-
private _title = 'Login';
+ loginUserFormGroup: FormGroup;
- constructor(private titleService: Title, private fb: FormBuilder, private router: Router, private userService: UserService) {
- titleService.setTitle(this._title);
+ constructor(private _titleService: Title, private _fb: FormBuilder, private _router: Router, private _userService: UserService) {
+ this._titleService.setTitle(this._title);
}
ngOnInit(): void {
- this.loginUserFormGroup = this.fb.group({
+ this.loginUserFormGroup = this._fb.group({
username: new FormControl('', [
Validators.required
]),
@@ -30,19 +29,19 @@ export class LoginComponent implements OnInit {
}
async onSubmit(): Promise<void> {
- this.userService.loginUser(this.loginUserFormGroup);
- this.router.navigate(['/']);
+ this._userService.loginUser(this.loginUserFormGroup);
+ this._router.navigate(['/']);
}
onRedirectRegister(): void {
- this.router.navigate(['/register']);
+ this._router.navigate(['/register']);
}
- get username() {
+ get username(): AbstractControl | null {
return this.loginUserFormGroup.get('username');
}
- get password() {
+ get password(): AbstractControl | null {
return this.loginUserFormGroup.get('password');
}
}
diff --git a/src/DevHive.Angular/src/app/components/post/post.component.ts b/src/DevHive.Angular/src/app/components/post/post.component.ts
index 72c7aec..b4bb2f0 100644
--- a/src/DevHive.Angular/src/app/components/post/post.component.ts
+++ b/src/DevHive.Angular/src/app/components/post/post.component.ts
@@ -3,26 +3,26 @@ import { Guid } from 'guid-typescript';
import { User } from 'src/models/identity/user';
@Component({
- selector: 'app-post',
- templateUrl: './post.component.html',
- styleUrls: ['./post.component.css'],
+ selector: 'app-post',
+ templateUrl: './post.component.html',
+ styleUrls: ['./post.component.css'],
})
export class PostComponent implements OnInit {
- public user: User;
- public votesNumber: number;
+ public user: User;
+ public votesNumber: number;
- constructor() {}
+ constructor() {}
- ngOnInit(): void {
- //Fetch data in post service
- this.user = new User(
- Guid.create(),
- 'gosho_trapov',
- 'Gosho',
- 'Trapov',
- 'assets/images/feed/profile-pic.png'
- );
+ ngOnInit(): void {
+ // Fetch data in post service
+ this.user = new User(
+ Guid.create(),
+ 'gosho_trapov',
+ 'Gosho',
+ 'Trapov',
+ 'assets/images/feed/profile-pic.png'
+ );
- this.votesNumber = 23;
- }
+ this.votesNumber = 23;
+ }
}
diff --git a/src/DevHive.Angular/src/app/components/register/register.component.ts b/src/DevHive.Angular/src/app/components/register/register.component.ts
index b8bd779..3fdfbcd 100644
--- a/src/DevHive.Angular/src/app/components/register/register.component.ts
+++ b/src/DevHive.Angular/src/app/components/register/register.component.ts
@@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core';
-import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
+import { AbstractControl, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { Title } from '@angular/platform-browser';
import { Router } from '@angular/router';
import { UserService } from 'src/app/services/user.service';
@@ -10,16 +10,15 @@ import { UserService } from 'src/app/services/user.service';
styleUrls: ['./register.component.css']
})
export class RegisterComponent implements OnInit {
- public registerUserFormGroup: FormGroup;
-
private _title = 'Register';
+ public registerUserFormGroup: FormGroup;
- constructor(private titleService: Title, private fb: FormBuilder, private router: Router, private userService: UserService) {
- titleService.setTitle(this._title);
+ constructor(private _titleService: Title, private _fb: FormBuilder, private _router: Router, private _userService: UserService) {
+ this._titleService.setTitle(this._title);
}
ngOnInit(): void {
- this.registerUserFormGroup = this.fb.group({
+ this.registerUserFormGroup = this._fb.group({
firstName: new FormControl('', [
Validators.required,
Validators.minLength(3)
@@ -47,31 +46,31 @@ export class RegisterComponent implements OnInit {
}
onSubmit(): void {
- this.userService.registerUser(this.registerUserFormGroup);
- this.router.navigate(['/']);
+ this._userService.registerUser(this.registerUserFormGroup);
+ this._router.navigate(['/']);
}
onRedirectRegister(): void {
- this.router.navigate(['/login']);
+ this._router.navigate(['/login']);
}
- get firstName() {
+ get firstName(): AbstractControl | null {
return this.registerUserFormGroup.get('firstName');
}
- get lastName() {
+ get lastName(): AbstractControl | null {
return this.registerUserFormGroup.get('lastName');
}
- get username() {
+ get username(): AbstractControl | null {
return this.registerUserFormGroup.get('username');
}
- get email() {
+ get email(): AbstractControl | null {
return this.registerUserFormGroup.get('email');
}
- get password() {
+ get password(): AbstractControl | null {
return this.registerUserFormGroup.get('password');
}
}
diff --git a/src/DevHive.Angular/src/models/identity/register-user.ts b/src/DevHive.Angular/src/models/identity/register-user.ts
deleted file mode 100644
index f96b8bb..0000000
--- a/src/DevHive.Angular/src/models/identity/register-user.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-export class RegisterUser
-{
- private _userName: string;
- private _password: string;
-
- // constructor(userName: string, password: string)
- // {
- // this.userName = userName;
- // this.password = password;
- // }
-
- public get userName()
- {
- return this._userName;
- }
-
- public set userName(userName: string)
- {
- if (userName.length <= 3)
- throw new Error('Username cannot be less than 3 characters long!');
-
- this._userName = userName;
- }
-
- public get password()
- {
- return this._password;
- }
-
- public set password(pass: string)
- {
- if (pass.length <= 5)
- throw Error("Password too short!");
-
- this._password = pass;
- }
-}
diff --git a/src/DevHive.Angular/src/models/identity/user.ts b/src/DevHive.Angular/src/models/identity/user.ts
index e16c908..2c5c57d 100644
--- a/src/DevHive.Angular/src/models/identity/user.ts
+++ b/src/DevHive.Angular/src/models/identity/user.ts
@@ -1,52 +1,52 @@
-import { Guid } from "guid-typescript";
+import { Guid } from 'guid-typescript';
export class User {
- private _id : Guid;
- private _lastName : string;
- private _firstName : string;
- private _userName : string;
- private _imageUrl : string;
+ private _id : Guid;
+ private _lastName : string;
+ private _firstName : string;
+ private _userName : string;
+ private _imageUrl : string;
- constructor(id: Guid, userName: string, firstName: string, lastName: string, imageUrl: string) {
- this.id = id;
- this.userName = userName;
- this.firstName = firstName;
- this.lastName = lastName;
- }
+ constructor(id: Guid, userName: string, firstName: string, lastName: string, imageUrl: string) {
+ this.id = id;
+ this.userName = userName;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.imageUrl = imageUrl;
+ }
-
- public get id() : Guid {
- return this._id;
- }
- public set id(v : Guid) {
- this._id = v;
- }
-
- public get userName() : string {
- return this._userName;
- }
- public set userName(v : string) {
- this._userName = v;
- }
-
- public get firstName() : string {
- return this._firstName;
- }
- public set firstName(v : string) {
- this._firstName = v;
- }
-
- public get lastName() : string {
- return this._lastName;
- }
- public set lastName(v: string) {
- this._lastName = v;
- }
-
- public get imageUrl() : string {
- return this._imageUrl;
- }
- public set imageUrl(v : string) {
- this._imageUrl = v;
- }
+ public get id(): Guid {
+ return this._id;
+ }
+ public set id(v: Guid) {
+ this._id = v;
+ }
+
+ public get userName(): string {
+ return this._userName;
+ }
+ public set userName(v: string) {
+ this._userName = v;
+ }
+
+ public get firstName(): string {
+ return this._firstName;
+ }
+ public set firstName(v: string) {
+ this._firstName = v;
+ }
+
+ public get lastName(): string {
+ return this._lastName;
+ }
+ public set lastName(v: string) {
+ this._lastName = v;
+ }
+
+ public get imageUrl(): string {
+ return this._imageUrl;
+ }
+ public set imageUrl(v: string) {
+ this._imageUrl = v;
+ }
}