aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.vs/DevHive-Angular/v16/.suobin65024 -> 58368 bytes
-rw-r--r--.vs/VSWorkspaceState.json6
-rw-r--r--.vs/slnx.sqlitebin167936 -> 176128 bytes
-rw-r--r--e2e/protractor.conf.js37
-rw-r--r--e2e/src/app.e2e-spec.ts23
-rw-r--r--e2e/src/app.po.ts11
-rw-r--r--e2e/tsconfig.json13
-rw-r--r--src/app/app-shell/app-shell.component.css0
-rw-r--r--src/app/app-shell/app-shell.component.html1
-rw-r--r--src/app/app-shell/app-shell.component.spec.ts25
-rw-r--r--src/app/app-shell/app-shell.component.ts15
-rw-r--r--src/app/components/admin-panel-page/admin-panel-page.component.ts122
-rw-r--r--src/app/components/comment-page/comment-page.component.ts22
-rw-r--r--src/app/components/comment/comment.component.ts16
-rw-r--r--src/app/components/feed/feed.component.ts28
-rw-r--r--src/app/components/login/login.component.ts18
-rw-r--r--src/app/components/post-page/post-page.component.ts34
-rw-r--r--src/app/components/post/post.component.ts14
-rw-r--r--src/app/components/profile-settings/profile-settings.component.ts70
-rw-r--r--src/app/components/profile/profile.component.ts56
-rw-r--r--src/app/components/register/register.component.ts30
-rw-r--r--src/app/services/comment.service.ts2
-rw-r--r--src/app/services/language.service.ts2
-rw-r--r--src/app/services/post.service.ts2
-rw-r--r--src/app/services/technology.service.ts2
-rw-r--r--src/app/services/user.service.ts6
-rw-r--r--src/models/comment.model.ts (renamed from src/models/comment.ts)0
-rw-r--r--src/models/identity/friend.model.ts (renamed from src/models/identity/friend.ts)0
-rw-r--r--src/models/identity/role.model.ts (renamed from src/models/identity/role.ts)0
-rw-r--r--src/models/identity/user.model.ts (renamed from src/models/identity/user.ts)8
-rw-r--r--src/models/language.model.ts (renamed from src/models/language.ts)0
-rw-r--r--src/models/post-comment.model.ts (renamed from src/models/post-comment.ts)0
-rw-r--r--src/models/post.model.ts (renamed from src/models/post.ts)4
-rw-r--r--src/models/technology.model.ts (renamed from src/models/technology.ts)0
34 files changed, 216 insertions, 351 deletions
diff --git a/.vs/DevHive-Angular/v16/.suo b/.vs/DevHive-Angular/v16/.suo
index 60e79b7..4fde92a 100644
--- a/.vs/DevHive-Angular/v16/.suo
+++ b/.vs/DevHive-Angular/v16/.suo
Binary files differ
diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json
index 9d81b57..de42564 100644
--- a/.vs/VSWorkspaceState.json
+++ b/.vs/VSWorkspaceState.json
@@ -4,10 +4,10 @@
"\\src",
"\\src\\app",
"\\src\\app\\components",
- "\\src\\app\\components\\post",
- "\\src\\app\\services",
+ "\\src\\app\\components\\feed",
+ "\\src\\app\\components\\profile",
"\\src\\models"
],
- "SelectedNode": "\\src\\app\\components\\post\\post.component.ts",
+ "SelectedNode": "\\src\\app\\components\\feed\\feed.component.html",
"PreviewInSolutionExplorer": false
} \ No newline at end of file
diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite
index 36ca8dd..c0e7093 100644
--- a/.vs/slnx.sqlite
+++ b/.vs/slnx.sqlite
Binary files differ
diff --git a/e2e/protractor.conf.js b/e2e/protractor.conf.js
deleted file mode 100644
index 361e7f0..0000000
--- a/e2e/protractor.conf.js
+++ /dev/null
@@ -1,37 +0,0 @@
-// @ts-check
-// Protractor configuration file, see link for more information
-// https://github.com/angular/protractor/blob/master/lib/config.ts
-
-const { SpecReporter, StacktraceOption } = require('jasmine-spec-reporter');
-
-/**
- * @type { import("protractor").Config }
- */
-exports.config = {
- allScriptsTimeout: 11000,
- specs: [
- './src/**/*.e2e-spec.ts'
- ],
- capabilities: {
- browserName: 'chrome'
- },
- directConnect: true,
- SELENIUM_PROMISE_MANAGER: false,
- baseUrl: 'http://localhost:4200/',
- framework: 'jasmine',
- jasmineNodeOpts: {
- showColors: true,
- defaultTimeoutInterval: 30000,
- print: function() {}
- },
- onPrepare() {
- require('ts-node').register({
- project: require('path').join(__dirname, './tsconfig.json')
- });
- jasmine.getEnv().addReporter(new SpecReporter({
- spec: {
- displayStacktrace: StacktraceOption.PRETTY
- }
- }));
- }
-}; \ No newline at end of file
diff --git a/e2e/src/app.e2e-spec.ts b/e2e/src/app.e2e-spec.ts
deleted file mode 100644
index 359bbf9..0000000
--- a/e2e/src/app.e2e-spec.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { AppPage } from './app.po';
-import { browser, logging } from 'protractor';
-
-describe('workspace-project App', () => {
- let page: AppPage;
-
- beforeEach(() => {
- page = new AppPage();
- });
-
- it('should display welcome message', async () => {
- await page.navigateTo();
- expect(await page.getTitleText()).toEqual('Angular app is running!');
- });
-
- afterEach(async () => {
- // Assert that there are no errors emitted from the browser
- const logs = await browser.manage().logs().get(logging.Type.BROWSER);
- expect(logs).not.toContain(jasmine.objectContaining({
- level: logging.Level.SEVERE,
- } as logging.Entry));
- });
-});
diff --git a/e2e/src/app.po.ts b/e2e/src/app.po.ts
deleted file mode 100644
index c9c85ab..0000000
--- a/e2e/src/app.po.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { browser, by, element } from 'protractor';
-
-export class AppPage {
- async navigateTo(): Promise<unknown> {
- return browser.get(browser.baseUrl);
- }
-
- async getTitleText(): Promise<string> {
- return element(by.css('app-root .content span')).getText();
- }
-}
diff --git a/e2e/tsconfig.json b/e2e/tsconfig.json
deleted file mode 100644
index 0782539..0000000
--- a/e2e/tsconfig.json
+++ /dev/null
@@ -1,13 +0,0 @@
-/* To learn more about this file see: https://angular.io/config/tsconfig. */
-{
- "extends": "../tsconfig.json",
- "compilerOptions": {
- "outDir": "../out-tsc/e2e",
- "module": "commonjs",
- "target": "es2018",
- "types": [
- "jasmine",
- "node"
- ]
- }
-}
diff --git a/src/app/app-shell/app-shell.component.css b/src/app/app-shell/app-shell.component.css
deleted file mode 100644
index e69de29..0000000
--- a/src/app/app-shell/app-shell.component.css
+++ /dev/null
diff --git a/src/app/app-shell/app-shell.component.html b/src/app/app-shell/app-shell.component.html
deleted file mode 100644
index b5f713a..0000000
--- a/src/app/app-shell/app-shell.component.html
+++ /dev/null
@@ -1 +0,0 @@
-<p>app-shell works!</p>
diff --git a/src/app/app-shell/app-shell.component.spec.ts b/src/app/app-shell/app-shell.component.spec.ts
deleted file mode 100644
index 2c4fabc..0000000
--- a/src/app/app-shell/app-shell.component.spec.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { ComponentFixture, TestBed } from '@angular/core/testing';
-
-import { AppShellComponent } from './app-shell.component';
-
-describe('AppShellComponent', () => {
- let component: AppShellComponent;
- let fixture: ComponentFixture<AppShellComponent>;
-
- beforeEach(async () => {
- await TestBed.configureTestingModule({
- declarations: [ AppShellComponent ]
- })
- .compileComponents();
- });
-
- beforeEach(() => {
- fixture = TestBed.createComponent(AppShellComponent);
- component = fixture.componentInstance;
- fixture.detectChanges();
- });
-
- it('should create', () => {
- expect(component).toBeTruthy();
- });
-});
diff --git a/src/app/app-shell/app-shell.component.ts b/src/app/app-shell/app-shell.component.ts
deleted file mode 100644
index f1bca89..0000000
--- a/src/app/app-shell/app-shell.component.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { Component, OnInit } from '@angular/core';
-
-@Component({
- selector: 'app-app-shell',
- templateUrl: './app-shell.component.html',
- styleUrls: ['./app-shell.component.css']
-})
-export class AppShellComponent implements OnInit {
-
- constructor() { }
-
- ngOnInit(): void {
- }
-
-}
diff --git a/src/app/components/admin-panel-page/admin-panel-page.component.ts b/src/app/components/admin-panel-page/admin-panel-page.component.ts
index 95d69d3..9beb8bc 100644
--- a/src/app/components/admin-panel-page/admin-panel-page.component.ts
+++ b/src/app/components/admin-panel-page/admin-panel-page.component.ts
@@ -11,9 +11,9 @@ import { PostService } from 'src/app/services/post.service';
import { TechnologyService } from 'src/app/services/technology.service';
import { TokenService } from 'src/app/services/token.service';
import { UserService } from 'src/app/services/user.service';
-import { User } from 'src/models/identity/user';
-import { Language } from 'src/models/language';
-import { Technology } from 'src/models/technology';
+import { User } from 'src/models/identity/user.model';
+import { Language } from 'src/models/language.model';
+import { Technology } from 'src/models/technology.model';
import { ErrorBarComponent } from '../error-bar/error-bar.component';
import { SuccessBarComponent } from '../success-bar/success-bar.component';
@@ -46,17 +46,17 @@ export class AdminPanelPageComponent implements OnInit {
return;
}
- this._userService.getUserFromSessionStorageRequest().subscribe(
- (result: object) => {
+ this._userService.getUserFromSessionStorageRequest().subscribe({
+ next: (result: object) => {
const user = result as User;
if (!user.roles.map(x => x.name).includes(AppConstants.ADMIN_ROLE_NAME)) {
this._router.navigate(['/login']);
}
},
- () => {
+ error: () => {
this._router.navigate(['/login']);
}
- );
+ });
this.languageForm = this._fb.group({
languageCreate: new FormControl(''),
@@ -65,9 +65,11 @@ export class AdminPanelPageComponent implements OnInit {
deleteLanguageName: new FormControl('')
});
- this.languageForm.valueChanges.subscribe(() => {
- this._successBar?.hideMsg();
- this._errorBar?.hideError();
+ this.languageForm.valueChanges.subscribe({
+ next: () => {
+ this._successBar?.hideMsg();
+ this._errorBar?.hideError();
+ }
});
this.technologyForm = this._fb.group({
@@ -77,9 +79,11 @@ export class AdminPanelPageComponent implements OnInit {
deleteTechnologyName: new FormControl('')
});
- this.technologyForm.valueChanges.subscribe(() => {
- this._successBar?.hideMsg();
- this._errorBar?.hideError();
+ this.technologyForm.valueChanges.subscribe({
+ next: () => {
+ this._successBar?.hideMsg();
+ this._errorBar?.hideError();
+ }
});
this.deleteForm = this._fb.group({
@@ -88,9 +92,11 @@ export class AdminPanelPageComponent implements OnInit {
deleteComment: new FormControl('')
});
- this.deleteForm.valueChanges.subscribe(() => {
- this._successBar?.hideMsg();
- this._errorBar?.hideError();
+ this.deleteForm.valueChanges.subscribe({
+ next: () => {
+ this._successBar?.hideMsg();
+ this._errorBar?.hideError();
+ }
});
this.loadAvailableLanguages();
@@ -128,14 +134,14 @@ export class AdminPanelPageComponent implements OnInit {
const languageCreate: string = this.languageForm.get('languageCreate')?.value;
if (languageCreate !== '' && languageCreate !== null) {
- this._languageService.createLanguageWithSessionStorageRequest(languageCreate.trim()).subscribe(
- () => {
+ this._languageService.createLanguageWithSessionStorageRequest(languageCreate.trim()).subscribe({
+ next: () => {
this.languageModifiedSuccess('Successfully updated languages!');
},
- (err: HttpErrorResponse) => {
+ error: (err: HttpErrorResponse) => {
this._errorBar.showError(err);
}
- );
+ });
}
}
@@ -146,14 +152,14 @@ export class AdminPanelPageComponent implements OnInit {
if (updateLanguageOldName !== '' && updateLanguageOldName !== null && updateLanguageNewName !== '' && updateLanguageNewName !== null) {
const langId = this.availableLanguages.filter(x => x.name === updateLanguageOldName.trim())[0].id;
- this._languageService.putLanguageWithSessionStorageRequest(langId, updateLanguageNewName.trim()).subscribe(
- () => {
+ this._languageService.putLanguageWithSessionStorageRequest(langId, updateLanguageNewName.trim()).subscribe({
+ next: () => {
this.languageModifiedSuccess('Successfully updated languages!');
},
- (err: HttpErrorResponse) => {
+ error: (err: HttpErrorResponse) => {
this._errorBar.showError(err);
}
- );
+ });
}
}
@@ -163,14 +169,14 @@ export class AdminPanelPageComponent implements OnInit {
if (deleteLanguageName !== '' && deleteLanguageName !== null) {
const langId = this.availableLanguages.filter(x => x.name === deleteLanguageName.trim())[0].id;
- this._languageService.deleteLanguageWithSessionStorageRequest(langId).subscribe(
- () => {
+ this._languageService.deleteLanguageWithSessionStorageRequest(langId).subscribe({
+ next: () => {
this.languageModifiedSuccess('Successfully deleted language!');
},
- (err: HttpErrorResponse) => {
+ error: (err: HttpErrorResponse) => {
this._errorBar.showError(err);
}
- );
+ });
}
}
@@ -181,11 +187,11 @@ export class AdminPanelPageComponent implements OnInit {
}
private loadAvailableLanguages(): void {
- this._languageService.getAllLanguagesWithSessionStorageRequest().subscribe(
- (result: object) => {
+ this._languageService.getAllLanguagesWithSessionStorageRequest().subscribe({
+ next: (result: object) => {
this.availableLanguages = result as Language[];
}
- );
+ });
}
// Technology modifying
@@ -204,14 +210,14 @@ export class AdminPanelPageComponent implements OnInit {
const technologyCreate: string = this.technologyForm.get('technologyCreate')?.value;
if (technologyCreate !== '' && technologyCreate !== null) {
- this._technologyService.createTechnologyWithSessionStorageRequest(technologyCreate.trim()).subscribe(
- () => {
+ this._technologyService.createTechnologyWithSessionStorageRequest(technologyCreate.trim()).subscribe({
+ next: () => {
this.technologyModifiedSuccess('Successfully updated technologies!');
},
- (err: HttpErrorResponse) => {
+ error: (err: HttpErrorResponse) => {
this._errorBar.showError(err);
}
- );
+ });
}
}
@@ -222,14 +228,14 @@ export class AdminPanelPageComponent implements OnInit {
if (updateTechnologyOldName !== '' && updateTechnologyOldName !== null && updateTechnologyNewName !== '' && updateTechnologyNewName !== null) {
const techId = this.availableTechnologies.filter(x => x.name === updateTechnologyOldName.trim())[0].id;
- this._technologyService.putTechnologyWithSessionStorageRequest(techId, updateTechnologyNewName.trim()).subscribe(
- () => {
+ this._technologyService.putTechnologyWithSessionStorageRequest(techId, updateTechnologyNewName.trim()).subscribe({
+ next: () => {
this.technologyModifiedSuccess('Successfully updated technologies!');
},
- (err: HttpErrorResponse) => {
+ error: (err: HttpErrorResponse) => {
this._errorBar.showError(err);
}
- );
+ });
}
}
@@ -239,14 +245,14 @@ export class AdminPanelPageComponent implements OnInit {
if (deleteTechnologyName !== '' && deleteTechnologyName !== null) {
const techId = this.availableTechnologies.filter(x => x.name === deleteTechnologyName.trim())[0].id;
- this._technologyService.deleteTechnologyWithSessionStorageRequest(techId).subscribe(
- () => {
+ this._technologyService.deleteTechnologyWithSessionStorageRequest(techId).subscribe({
+ next: () => {
this.technologyModifiedSuccess('Successfully deleted technology!');
},
- (err: HttpErrorResponse) => {
+ error: (err: HttpErrorResponse) => {
this._errorBar.showError(err);
}
- );
+ });
}
}
@@ -257,11 +263,11 @@ export class AdminPanelPageComponent implements OnInit {
}
private loadAvailableTechnologies(): void {
- this._technologyService.getAllTechnologiesWithSessionStorageRequest().subscribe(
- (result: object) => {
+ this._technologyService.getAllTechnologiesWithSessionStorageRequest().subscribe({
+ next: (result: object) => {
this.availableTechnologies = result as Technology[];
}
- );
+ });
}
// Deletions
@@ -282,14 +288,14 @@ export class AdminPanelPageComponent implements OnInit {
if (deleteUser !== '' && deleteUser !== null) {
const userId: Guid = Guid.parse(deleteUser);
- this._userService.deleteUserRequest(userId, this._tokenService.getTokenFromSessionStorage()).subscribe(
- () => {
+ this._userService.deleteUserRequest(userId, this._tokenService.getTokenFromSessionStorage()).subscribe({
+ next: () => {
this.deletionSuccess('Successfully deleted user!');
},
- (err: HttpErrorResponse) => {
+ error: (err: HttpErrorResponse) => {
this._errorBar.showError(err);
}
- );
+ });
}
}
@@ -299,14 +305,14 @@ export class AdminPanelPageComponent implements OnInit {
if (deletePost !== '' && deletePost !== null) {
const postId: Guid = Guid.parse(deletePost);
- this._postService.deletePostRequest(postId, this._tokenService.getTokenFromSessionStorage()).subscribe(
- () => {
+ this._postService.deletePostRequest(postId, this._tokenService.getTokenFromSessionStorage()).subscribe({
+ next: () => {
this.deletionSuccess('Successfully deleted user!');
},
- (err: HttpErrorResponse) => {
+ error: (err: HttpErrorResponse) => {
this._errorBar.showError(err);
}
- );
+ });
}
}
@@ -316,14 +322,14 @@ export class AdminPanelPageComponent implements OnInit {
if (deleteComment !== '' && deleteComment !== null) {
const commentId: Guid = Guid.parse(deleteComment);
- this._commentService.deleteCommentWithSessionStorage(commentId).subscribe(
- () => {
+ this._commentService.deleteCommentWithSessionStorage(commentId).subscribe({
+ next: () => {
this.deletionSuccess('Successfully deleted comment!');
},
- (err: HttpErrorResponse) => {
+ error: (err: HttpErrorResponse) => {
this._errorBar.showError(err);
}
- );
+ });
}
}
diff --git a/src/app/components/comment-page/comment-page.component.ts b/src/app/components/comment-page/comment-page.component.ts
index 413436e..5d256bf 100644
--- a/src/app/components/comment-page/comment-page.component.ts
+++ b/src/app/components/comment-page/comment-page.component.ts
@@ -5,7 +5,7 @@ import { Router } from '@angular/router';
import { Guid } from 'guid-typescript';
import { CommentService } from 'src/app/services/comment.service';
import { TokenService } from 'src/app/services/token.service';
-import { Comment } from 'src/models/comment';
+import { Comment } from 'src/models/comment.model';
@Component({
selector: 'app-comment-page',
@@ -32,8 +32,8 @@ export class CommentPageComponent implements OnInit {
// Gets the post and the logged in user and compares them,
// to determine if the current post is made by the user
- this._commentService.getCommentRequest(this.commentId).subscribe(
- (result: object) => {
+ this._commentService.getCommentRequest(this.commentId).subscribe({
+ next: (result: object) => {
this.comment = result as Comment;
if (this.loggedIn) {
this.editable = this.comment.issuerUsername === this._tokenService.getUsernameFromSessionStorageToken();
@@ -41,10 +41,10 @@ export class CommentPageComponent implements OnInit {
}
this.loaded = true;
},
- () => {
+ error: () => {
this._router.navigate(['/not-found']);
}
- );
+ });
this.editCommentFormGroup = this._fb.group({
newCommentMessage: new FormControl('')
@@ -66,22 +66,22 @@ export class CommentPageComponent implements OnInit {
if (newMessage !== '' && newMessage !== this.comment.message) {
console.log(this.commentId);
- this._commentService.putCommentWithSessionStorageRequest(this.commentId, this.comment.postId, newMessage).subscribe(
- () => {
+ this._commentService.putCommentWithSessionStorageRequest(this.commentId, this.comment.postId, newMessage).subscribe({
+ next: () => {
this.reloadPage();
}
- );
+ });
}
}
this.editingComment = !this.editingComment;
}
deleteComment(): void {
- this._commentService.deleteCommentWithSessionStorage(this.commentId).subscribe(
- () => {
+ this._commentService.deleteCommentWithSessionStorage(this.commentId).subscribe({
+ next: () => {
this.toPost();
}
- );
+ });
}
private reloadPage(): void {
diff --git a/src/app/components/comment/comment.component.ts b/src/app/components/comment/comment.component.ts
index 5076769..7da896d 100644
--- a/src/app/components/comment/comment.component.ts
+++ b/src/app/components/comment/comment.component.ts
@@ -3,8 +3,8 @@ import { Router } from '@angular/router';
import { Guid } from 'guid-typescript';
import { CommentService } from 'src/app/services/comment.service';
import { UserService } from 'src/app/services/user.service';
-import { Comment } from 'src/models/comment';
-import { User } from 'src/models/identity/user';
+import { Comment } from 'src/models/comment.model';
+import { User } from 'src/models/identity/user.model';
@Component({
selector: 'app-comment',
@@ -25,23 +25,23 @@ export class CommentComponent implements OnInit {
this.comment = this._commentService.getDefaultComment();
this.user = this._userService.getDefaultUser();
- this._commentService.getCommentRequest(Guid.parse(this.paramId)).subscribe(
- (result: object) => {
+ this._commentService.getCommentRequest(Guid.parse(this.paramId)).subscribe({
+ next: (result: object) => {
Object.assign(this.comment, result);
this.timeCreated = new Date(this.comment.timeCreated).toLocaleString('en-GB');
this.loadUser();
}
- );
+ });
}
private loadUser(): void {
- this._userService.getUserByUsernameRequest(this.comment.issuerUsername).subscribe(
- (result: object) => {
+ this._userService.getUserByUsernameRequest(this.comment.issuerUsername).subscribe({
+ next: (result: object) => {
Object.assign(this.user, result);
this.loaded = true;
}
- );
+ });
}
goToAuthorProfile(): void {
diff --git a/src/app/components/feed/feed.component.ts b/src/app/components/feed/feed.component.ts
index eaa0ef1..895bf76 100644
--- a/src/app/components/feed/feed.component.ts
+++ b/src/app/components/feed/feed.component.ts
@@ -1,11 +1,11 @@
import { Component, OnInit } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { Router } from '@angular/router';
-import { User } from 'src/models/identity/user';
+import { User } from 'src/models/identity/user.model';
import { UserService } from '../../services/user.service';
import { AppConstants } from 'src/app/app-constants.module';
import { FeedService } from 'src/app/services/feed.service';
-import { Post } from 'src/models/post';
+import { Post } from 'src/models/post.model';
import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
import { PostService } from 'src/app/services/post.service';
import { TokenService } from 'src/app/services/token.service';
@@ -49,27 +49,27 @@ export class FeedComponent implements OnInit {
fileUpload: new FormControl('')
});
- this._userService.getUserFromSessionStorageRequest().subscribe(
- (res: object) => {
+ this._userService.getUserFromSessionStorageRequest().subscribe({
+ next: (res: object) => {
Object.assign(this.user, res);
this.loadFeed();
},
- () => {
+ error: () => {
this.logout();
}
- );
+ });
}
private loadFeed(): void {
- this._feedService.getUserFeedFromSessionStorageRequest(this._currentPage++, this._timeLoaded, AppConstants.PAGE_SIZE).subscribe(
- (result: object) => {
+ this._feedService.getUserFeedFromSessionStorageRequest(this._currentPage++, this._timeLoaded, AppConstants.PAGE_SIZE).subscribe({
+ next: (result: object) => {
this.posts.push(...Object.values(result)[0]);
this.finishUserLoading();
},
- () => {
+ error: () => {
this.finishUserLoading();
}
- );
+ });
}
private finishUserLoading(): void {
@@ -102,14 +102,14 @@ export class FeedComponent implements OnInit {
const postMessage = this.createPostFormGroup.get('newPostMessage')?.value;
this.dataArrived = false;
- this._postService.createPostWithSessionStorageRequest(postMessage, this.files).subscribe(
- () => {
+ this._postService.createPostWithSessionStorageRequest(postMessage, this.files).subscribe({
+ next: () => {
this.goToProfile();
},
- () => {
+ error: () => {
this.dataArrived = true;
}
- );
+ });
}
onScroll(event: any): void {
diff --git a/src/app/components/login/login.component.ts b/src/app/components/login/login.component.ts
index c3fb79c..edbc461 100644
--- a/src/app/components/login/login.component.ts
+++ b/src/app/components/login/login.component.ts
@@ -1,5 +1,5 @@
import { Component, OnInit, ViewChild } from '@angular/core';
-import { FormGroup, FormBuilder, Validators, FormControl, AbstractControl } from '@angular/forms';
+import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms';
import { Router } from '@angular/router';
import { Title } from '@angular/platform-browser';
import { UserService } from 'src/app/services/user.service';
@@ -34,26 +34,18 @@ export class LoginComponent implements OnInit {
onSubmit(): void {
this._errorBar.hideError();
- this._userService.loginUserRequest(this.loginUserFormGroup).subscribe(
- (res: object) => {
+ this._userService.loginUserRequest(this.loginUserFormGroup).subscribe({
+ next: (res: object) => {
this._tokenService.setUserTokenToSessionStorage(res);
this._router.navigate(['/']);
},
- (err: HttpErrorResponse) => {
+ error: (err: HttpErrorResponse) => {
this._errorBar.showError(err);
}
- );
+ });
}
onRedirectRegister(): void {
this._router.navigate(['/register']);
}
-
- get username(): AbstractControl | null {
- return this.loginUserFormGroup.get('username');
- }
-
- get password(): AbstractControl | null {
- return this.loginUserFormGroup.get('password');
- }
}
diff --git a/src/app/components/post-page/post-page.component.ts b/src/app/components/post-page/post-page.component.ts
index 1ac89f4..a60f4da 100644
--- a/src/app/components/post-page/post-page.component.ts
+++ b/src/app/components/post-page/post-page.component.ts
@@ -6,7 +6,7 @@ import { Guid } from 'guid-typescript';
import { CommentService } from 'src/app/services/comment.service';
import { PostService } from 'src/app/services/post.service';
import { TokenService } from 'src/app/services/token.service';
-import { Post } from 'src/models/post';
+import { Post } from 'src/models/post.model';
import { CloudinaryService } from 'src/app/services/cloudinary.service';
@Component({
@@ -37,8 +37,8 @@ export class PostPageComponent implements OnInit {
// Gets the post and the logged in user and compares them,
// to determine if the current post is made by the user
- this._postService.getPostRequest(this.postId).subscribe(
- (result: object) => {
+ this._postService.getPostRequest(this.postId).subscribe({
+ next: (result: object) => {
this.post = result as Post;
this.post.fileURLs = Object.values(result)[7];
if (this.loggedIn) {
@@ -52,10 +52,10 @@ export class PostPageComponent implements OnInit {
this.dataArrived = true;
}
},
- () => {
+ error: () => {
this._router.navigate(['/not-found']);
}
- );
+ });
this.editPostFormGroup = this._fb.group({
newPostMessage: new FormControl(''),
@@ -69,8 +69,8 @@ export class PostPageComponent implements OnInit {
private loadFiles(): void {
for (const fileURL of this.post.fileURLs) {
- this._cloudinaryService.getFileRequest(fileURL).subscribe(
- (result: object) => {
+ this._cloudinaryService.getFileRequest(fileURL).subscribe({
+ next: (result: object) => {
const file = result as File;
const tmp = {
name: fileURL.match('(?<=\/)(?:.(?!\/))+$')?.pop() ?? 'Attachment'
@@ -83,7 +83,7 @@ export class PostPageComponent implements OnInit {
this.dataArrived = true;
}
}
- );
+ });
}
}
@@ -118,11 +118,11 @@ export class PostPageComponent implements OnInit {
const newMessage = this.editPostFormGroup.get('newPostMessage')?.value;
if (newMessage === '' && newMessage !== this.post.message) {
- this._postService.putPostWithSessionStorageRequest(this.postId, newMessage, this.files).subscribe(
- () => {
+ this._postService.putPostWithSessionStorageRequest(this.postId, newMessage, this.files).subscribe({
+ next: () => {
this.reloadPage();
}
- );
+ });
this.dataArrived = false;
}
}
@@ -137,21 +137,21 @@ export class PostPageComponent implements OnInit {
const newComment = this.addCommentFormGroup.get('newComment')?.value;
if (newComment !== '' && newComment !== null) {
- this._commentService.createCommentWithSessionStorageRequest(this.postId, newComment).subscribe(
- () => {
+ this._commentService.createCommentWithSessionStorageRequest(this.postId, newComment).subscribe({
+ next: () => {
this.editPostFormGroup.reset();
this.reloadPage();
}
- );
+ });
}
}
deletePost(): void {
- this._postService.deletePostWithSessionStorage(this.postId).subscribe(
- () => {
+ this._postService.deletePostWithSessionStorage(this.postId).subscribe({
+ next: () => {
this._router.navigate(['/profile/' + this._tokenService.getUsernameFromSessionStorageToken()]);
}
- );
+ });
}
private reloadPage(): void {
diff --git a/src/app/components/post/post.component.ts b/src/app/components/post/post.component.ts
index a38d507..4bb41a7 100644
--- a/src/app/components/post/post.component.ts
+++ b/src/app/components/post/post.component.ts
@@ -32,9 +32,9 @@ export class PostComponent implements OnInit {
this.post = this._postService.getDefaultPost();
this.user = this._userService.getDefaultUser();
- this._postService.getPostRequest(Guid.parse(this.paramId)).subscribe(
- (result: object) => {
- Object.assign(this.post, result);
+ this._postService.getPostRequest(Guid.parse(this.paramId)).subscribe({
+ next: (result: object) => {
+ Object.assign(this.post, result);
this.post.fileURLs = Object.values(result)[7];
this.votesNumber = this.post.currentRating;
@@ -45,19 +45,19 @@ export class PostComponent implements OnInit {
this.loadUser();
}
- );
+ });
}
private loadUser(): void {
- this._userService.getUserByUsernameRequest(this.post.creatorUsername).subscribe(
- (result: object) => {
+ this._userService.getUserByUsernameRequest(this.post.creatorUsername).subscribe({
+ next: (result: object) => {
Object.assign(this.user, result);
this.highlightButtonsOnInit();
this.loaded = true;
}
- );
+ });
}
goToAuthorProfile(): void {
diff --git a/src/app/components/profile-settings/profile-settings.component.ts b/src/app/components/profile-settings/profile-settings.component.ts
index f3cd4c1..b314a9a 100644
--- a/src/app/components/profile-settings/profile-settings.component.ts
+++ b/src/app/components/profile-settings/profile-settings.component.ts
@@ -6,11 +6,11 @@ import { Router } from '@angular/router';
import { LanguageService } from 'src/app/services/language.service';
import { UserService } from 'src/app/services/user.service';
import { TechnologyService } from 'src/app/services/technology.service';
-import { User } from 'src/models/identity/user';
+import { User } from 'src/models/identity/user.model';
import { ErrorBarComponent } from '../error-bar/error-bar.component';
import { SuccessBarComponent } from '../success-bar/success-bar.component';
-import { Language } from 'src/models/language';
-import { Technology } from 'src/models/technology';
+import { Language } from 'src/models/language.model';
+import { Technology } from 'src/models/technology.model';
import { TokenService } from 'src/app/services/token.service';
import { Title } from '@angular/platform-browser';
import { AppConstants } from 'src/app/app-constants.module';
@@ -50,35 +50,35 @@ export class ProfileSettingsComponent implements OnInit {
this.availableTechnologies = [];
this.newProfilePicture = new File([], '');
- this._userService.getUserByUsernameRequest(this._urlUsername).subscribe(
- (res: object) => {
+ this._userService.getUserByUsernameRequest(this._urlUsername).subscribe({
+ next: (res: object) => {
Object.assign(this.user, res);
this.isAdminUser = this.user.roles.map(x => x.name).includes(AppConstants.ADMIN_ROLE_NAME);
this.finishUserLoading();
},
- () => {
+ error: () => {
this._router.navigate(['/not-found']);
}
- );
+ });
- this._languageService.getAllLanguagesWithSessionStorageRequest().subscribe(
- (result: object) => {
+ this._languageService.getAllLanguagesWithSessionStorageRequest().subscribe({
+ next: (result: object) => {
this.availableLanguages = result as Language[];
}
- );
- this._technologyService.getAllTechnologiesWithSessionStorageRequest().subscribe(
- (result: object) => {
+ });
+ this._technologyService.getAllTechnologiesWithSessionStorageRequest().subscribe({
+ next: (result: object) => {
this.availableTechnologies = result as Technology[];
}
- );
+ });
}
private finishUserLoading(): void {
if (sessionStorage.getItem('UserCred')) {
const userFromToken: User = this._userService.getDefaultUser();
- this._userService.getUserFromSessionStorageRequest().subscribe(
- (tokenRes: object) => {
+ this._userService.getUserFromSessionStorageRequest().subscribe({
+ next: (tokenRes: object) => {
Object.assign(userFromToken, tokenRes);
if (userFromToken.userName === this._urlUsername) {
@@ -89,10 +89,10 @@ export class ProfileSettingsComponent implements OnInit {
this.goToProfile();
}
},
- () => {
+ error: () => {
this.logout();
}
- );
+ });
}
else {
this.goToProfile();
@@ -147,9 +147,11 @@ export class ProfileSettingsComponent implements OnInit {
fileUpload: new FormControl('')
});
- this.updateUserFormGroup.valueChanges.subscribe(() => {
- this._successBar?.hideMsg();
- this._errorBar?.hideError();
+ this.updateUserFormGroup.valueChanges.subscribe({
+ next: () => {
+ this._successBar?.hideMsg();
+ this._errorBar?.hideError();
+ }
});
}
@@ -180,11 +182,11 @@ export class ProfileSettingsComponent implements OnInit {
return;
}
- this._userService.putProfilePictureFromSessionStorageRequest(this.newProfilePicture).subscribe(
- () => {
+ this._userService.putProfilePictureFromSessionStorageRequest(this.newProfilePicture).subscribe({
+ next: () => {
this.reloadPage();
}
- );
+ });
this.dataArrived = false;
}
@@ -195,14 +197,20 @@ export class ProfileSettingsComponent implements OnInit {
this.patchLanguagesControl();
this.patchTechnologiesControl();
- this._userService.putUserFromSessionStorageRequest(this.updateUserFormGroup, this.user.roles, this.user.friends).subscribe(
- () => {
+ this._userService.putUserFromSessionStorageRequest(this.updateUserFormGroup, this.user.roles, this.user.friends).subscribe({
+ next: () => {
this._successBar.showMsg('Profile updated successfully!');
+
+ // "Reload" page when changing username
+ const newUsername = this.updateUserFormGroup.get('username')?.value;
+ if (newUsername !== this._urlUsername) {
+ this._router.navigate(['/profile/' + newUsername + '/settings']);
+ }
},
- (err: HttpErrorResponse) => {
+ error: (err: HttpErrorResponse) => {
this._errorBar.showError(err);
}
- );
+ });
}
private patchLanguagesControl(): void {
@@ -284,14 +292,14 @@ export class ProfileSettingsComponent implements OnInit {
deleteAccount(): void {
if (this.deleteAccountConfirm) {
- this._userService.deleteUserFromSessionStorageRequest().subscribe(
- () => {
+ this._userService.deleteUserFromSessionStorageRequest().subscribe({
+ next: () => {
this.logout();
},
- (err: HttpErrorResponse) => {
+ error: (err: HttpErrorResponse) => {
this._errorBar.showError(err);
}
- );
+ });
this.dataArrived = false;
}
else {
diff --git a/src/app/components/profile/profile.component.ts b/src/app/components/profile/profile.component.ts
index eaa1bec..ed17f33 100644
--- a/src/app/components/profile/profile.component.ts
+++ b/src/app/components/profile/profile.component.ts
@@ -1,16 +1,16 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { UserService } from 'src/app/services/user.service';
-import { User } from 'src/models/identity/user';
+import { User } from 'src/models/identity/user.model';
import { AppConstants } from 'src/app/app-constants.module';
import { Location } from '@angular/common';
import { LanguageService } from 'src/app/services/language.service';
import { TechnologyService } from 'src/app/services/technology.service';
-import { Post } from 'src/models/post';
+import { Post } from 'src/models/post.model';
import { FeedService } from 'src/app/services/feed.service';
import { TokenService } from 'src/app/services/token.service';
import { Title } from '@angular/platform-browser';
-import { Friend } from 'src/models/identity/friend';
+import { Friend } from 'src/models/identity/friend.model';
import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
@Component({
@@ -52,16 +52,16 @@ export class ProfileComponent implements OnInit {
password: new FormControl('')
});
- this._userService.getUserByUsernameRequest(this._urlUsername).subscribe(
- (res: object) => {
+ this._userService.getUserByUsernameRequest(this._urlUsername).subscribe({
+ next: (res: object) => {
Object.assign(this.user, res);
this.isAdminUser = this.user.roles.map(x => x.name).includes(AppConstants.ADMIN_ROLE_NAME);
this.loadLanguages();
},
- () => {
+ error: () => {
this._router.navigate(['/not-found']);
}
- );
+ });
}
private loadLanguages(): void {
@@ -91,17 +91,17 @@ export class ProfileComponent implements OnInit {
}
private loadPosts(): void {
- this._feedService.getUserPostsRequest(this.user.userName, this._currentPage++, this._timeLoaded, AppConstants.PAGE_SIZE).subscribe(
- (result: object) => {
+ this._feedService.getUserPostsRequest(this.user.userName, this._currentPage++, this._timeLoaded, AppConstants.PAGE_SIZE).subscribe({
+ next: (result: object) => {
const resultArr: Post[] = Object.values(result)[0];
this.userPosts.push(...resultArr);
this.finishUserLoading();
},
- () => {
+ error: () => {
this._currentPage = -1;
this.finishUserLoading();
}
- );
+ });
}
private finishUserLoading(): void {
@@ -109,8 +109,8 @@ export class ProfileComponent implements OnInit {
this.isUserLoggedIn = true;
const userFromToken: User = this._userService.getDefaultUser();
- this._userService.getUserFromSessionStorageRequest().subscribe(
- (tokenRes: object) => {
+ this._userService.getUserFromSessionStorageRequest().subscribe({
+ next: (tokenRes: object) => {
Object.assign(userFromToken, tokenRes);
if (userFromToken.friends.map(x => x.userName).includes(this._urlUsername)) {
@@ -121,10 +121,10 @@ export class ProfileComponent implements OnInit {
}
this.dataArrived = true;
},
- () => {
+ error: () => {
this.logout();
}
- );
+ });
}
else {
this.dataArrived = true;
@@ -156,8 +156,8 @@ export class ProfileComponent implements OnInit {
if (this.updatingFriendship) {
this.dataArrived = false;
- this._userService.getUserFromSessionStorageRequest().subscribe(
- (result: object) => {
+ this._userService.getUserFromSessionStorageRequest().subscribe({
+ next: (result: object) => {
const loggedInUser: User = result as User;
if (this.friendOfUser) {
@@ -169,20 +169,24 @@ export class ProfileComponent implements OnInit {
loggedInUser.friends.push(newFriend);
}
- this._userService.putBareUserFromSessionStorageRequest(loggedInUser, this.updateFrienship.get('password')?.value).subscribe(
- () => {
- this.reloadPage();
- },
- () => {
- this._router.navigate(['/']);
- }
- );
+ this.updateUserWithNewFriends(loggedInUser);
}
- );
+ });
}
this.updatingFriendship = !this.updatingFriendship;
}
+ private updateUserWithNewFriends(loggedInUser: User): void {
+ this._userService.putBareUserFromSessionStorageRequest(loggedInUser, this.updateFrienship.get('password')?.value).subscribe({
+ next: () => {
+ this.reloadPage();
+ },
+ error: () => {
+ this._router.navigate(['/']);
+ }
+ });
+ }
+
onScroll(event: any): void {
// Detects when the element has reached the bottom, thx https://stackoverflow.com/a/50038429/12036073
if (event.target.offsetHeight + event.target.scrollTop >= event.target.scrollHeight && this._currentPage > 0) {
diff --git a/src/app/components/register/register.component.ts b/src/app/components/register/register.component.ts
index 36eaa55..07b8976 100644
--- a/src/app/components/register/register.component.ts
+++ b/src/app/components/register/register.component.ts
@@ -1,6 +1,6 @@
import { HttpErrorResponse } from '@angular/common/http';
import { Component, OnInit, ViewChild } from '@angular/core';
-import { AbstractControl, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
+import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { Title } from '@angular/platform-browser';
import { Router } from '@angular/router';
import { TokenService } from 'src/app/services/token.service';
@@ -50,37 +50,17 @@ export class RegisterComponent implements OnInit {
}
onSubmit(): void {
- this._userService.registerUserRequest(this.registerUserFormGroup).subscribe(
- res => {
+ this._userService.registerUserRequest(this.registerUserFormGroup).subscribe({
+ next: (res: object) => {
this._tokenService.setUserTokenToSessionStorage(res);
this._router.navigate(['/']);
},
- (err: HttpErrorResponse) => {
+ error: (err: HttpErrorResponse) => {
this._errorBar.showError(err);
}
- );
+ });
}
onRedirectLogin(): void {
this._router.navigate(['/login']);
}
-
- get firstName(): AbstractControl | null {
- return this.registerUserFormGroup.get('firstName');
- }
-
- get lastName(): AbstractControl | null {
- return this.registerUserFormGroup.get('lastName');
- }
-
- get username(): AbstractControl | null {
- return this.registerUserFormGroup.get('username');
- }
-
- get email(): AbstractControl | null {
- return this.registerUserFormGroup.get('email');
- }
-
- get password(): AbstractControl | null {
- return this.registerUserFormGroup.get('password');
- }
}
diff --git a/src/app/services/comment.service.ts b/src/app/services/comment.service.ts
index c9dbf35..29707ab 100644
--- a/src/app/services/comment.service.ts
+++ b/src/app/services/comment.service.ts
@@ -2,7 +2,7 @@ import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Guid } from 'guid-typescript';
import { Observable } from 'rxjs';
-import { Comment } from 'src/models/comment';
+import { Comment } from 'src/models/comment.model';
import { AppConstants } from '../app-constants.module';
import { TokenService } from './token.service';
diff --git a/src/app/services/language.service.ts b/src/app/services/language.service.ts
index 15e241f..5846dd6 100644
--- a/src/app/services/language.service.ts
+++ b/src/app/services/language.service.ts
@@ -2,7 +2,7 @@ import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Guid } from 'guid-typescript';
import { Observable } from 'rxjs';
-import { Language } from 'src/models/language';
+import { Language } from 'src/models/language.model';
import { AppConstants } from '../app-constants.module';
import { TokenService } from './token.service';
diff --git a/src/app/services/post.service.ts b/src/app/services/post.service.ts
index d582085..c8bd892 100644
--- a/src/app/services/post.service.ts
+++ b/src/app/services/post.service.ts
@@ -3,7 +3,7 @@ import { Injectable } from '@angular/core';
import * as FormData from 'form-data';
import { Guid } from 'guid-typescript';
import { Observable } from 'rxjs';
-import { Post } from 'src/models/post';
+import { Post } from 'src/models/post.model';
import { AppConstants } from '../app-constants.module';
import { TokenService } from './token.service';
diff --git a/src/app/services/technology.service.ts b/src/app/services/technology.service.ts
index dbdc039..fcc3d4c 100644
--- a/src/app/services/technology.service.ts
+++ b/src/app/services/technology.service.ts
@@ -2,7 +2,7 @@ import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Guid } from 'guid-typescript';
import { Observable } from 'rxjs';
-import { Technology } from 'src/models/technology';
+import { Technology } from 'src/models/technology.model';
import { AppConstants } from '../app-constants.module';
import { TokenService } from './token.service';
diff --git a/src/app/services/user.service.ts b/src/app/services/user.service.ts
index 31862c4..f22952e 100644
--- a/src/app/services/user.service.ts
+++ b/src/app/services/user.service.ts
@@ -1,12 +1,12 @@
import { Injectable } from '@angular/core';
import { Guid } from 'guid-typescript';
-import { User } from '../../models/identity/user';
+import { User } from '../../models/identity/user.model';
import { FormGroup } from '@angular/forms';
import { AppConstants } from 'src/app/app-constants.module';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs';
-import { Role } from 'src/models/identity/role';
-import { Friend } from 'src/models/identity/friend';
+import { Role } from 'src/models/identity/role.model';
+import { Friend } from 'src/models/identity/friend.model';
import { TokenService } from './token.service';
@Injectable({
diff --git a/src/models/comment.ts b/src/models/comment.model.ts
index 0d1755f..0d1755f 100644
--- a/src/models/comment.ts
+++ b/src/models/comment.model.ts
diff --git a/src/models/identity/friend.ts b/src/models/identity/friend.model.ts
index 22290cd..22290cd 100644
--- a/src/models/identity/friend.ts
+++ b/src/models/identity/friend.model.ts
diff --git a/src/models/identity/role.ts b/src/models/identity/role.model.ts
index 132b0b0..132b0b0 100644
--- a/src/models/identity/role.ts
+++ b/src/models/identity/role.model.ts
diff --git a/src/models/identity/user.ts b/src/models/identity/user.model.ts
index e0038e0..e2f54a4 100644
--- a/src/models/identity/user.ts
+++ b/src/models/identity/user.model.ts
@@ -1,8 +1,8 @@
import { Guid } from 'guid-typescript';
-import { Language } from '../language';
-import { Technology } from '../technology';
-import { Friend } from './friend';
-import { Role } from './role';
+import { Language } from '../language.model';
+import { Technology } from '../technology.model';
+import { Friend } from './friend.model';
+import { Role } from './role.model';
export class User {
private _id : Guid;
diff --git a/src/models/language.ts b/src/models/language.model.ts
index e3aa61e..e3aa61e 100644
--- a/src/models/language.ts
+++ b/src/models/language.model.ts
diff --git a/src/models/post-comment.ts b/src/models/post-comment.model.ts
index 5d1e346..5d1e346 100644
--- a/src/models/post-comment.ts
+++ b/src/models/post-comment.model.ts
diff --git a/src/models/post.ts b/src/models/post.model.ts
index 8c1890a..9751c26 100644
--- a/src/models/post.ts
+++ b/src/models/post.model.ts
@@ -1,6 +1,6 @@
import { Guid } from 'guid-typescript';
-import { Comment } from './comment';
-import { PostComment } from './post-comment';
+import { Comment } from './comment.model';
+import { PostComment } from './post-comment.model';
export class Post {
private _postId: Guid;
diff --git a/src/models/technology.ts b/src/models/technology.model.ts
index 1869d14..1869d14 100644
--- a/src/models/technology.ts
+++ b/src/models/technology.model.ts