Skip to content

Edits #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 20 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -21,7 +21,7 @@
"@angular/material": "^13.1.3",
"@angular/platform-browser": "^14.2.8",
"@angular/platform-browser-dynamic": "^14.2.8",
"@angular/router": "^14.2.8",
"@angular/router": "^14.2.12",
"@ckeditor/ckeditor5-angular": "^3.0.0",
"@ckeditor/ckeditor5-build-classic": "^33.0.0",
"@ckeditor/ckeditor5-upload": "^33.0.0",
Expand Down Expand Up @@ -57,4 +57,4 @@
"karma-jasmine-html-reporter": "~1.7.0",
"typescript": "~4.8.4"
}
}
}
10 changes: 5 additions & 5 deletions src/app/app.component.ts
Expand Up @@ -53,7 +53,7 @@ export class AppComponent {
this.dataService.setCurrentUser(user);
this.user = user;
this.loggedIn = (user != null);

if (this.loggedIn) {
this.adminsService.isAdmin(user.email).subscribe((result) => {
this.isLoggedInUserAdmin = result;
Expand All @@ -62,12 +62,11 @@ export class AppComponent {
this._snackBar.open('Welcome ' + user.firstName + ' ' + user.lastName + '!', 'Dismiss', {
duration: 3000,
});
}
else {
this.isLoggedInUserAdmin = false;
this._router.navigate(['']);
localStorage.setItem('user',user.name);
}
});


}

goToUrl() {
Expand All @@ -85,5 +84,6 @@ export class AppComponent {

signOut(): void {
this.authService.signOut(true);
localStorage.removeItem('user')
}
}
112 changes: 46 additions & 66 deletions src/app/components/item/item.component.ts
Expand Up @@ -143,6 +143,7 @@ export class ItemComponent implements OnInit {
this.encyclopediaService
.getRelatedPages(params.get('id'))
.subscribe((result) => {
console.log(result);
this.relatedPages = result;
this.recommendedSectionIsLoaded = true;
this.relatedPages.forEach((value) => {
Expand All @@ -167,19 +168,21 @@ export class ItemComponent implements OnInit {
// load external pages
this.encyclopediaService
.getExternalPages(item.title, this.externalPageCardIndex + 1)
.subscribe(
(result) => {
.subscribe({
next: (result) => {
console.log(result)
if (result == null || result.length == 0)
this.externalSectionLoadError = true;
else this.externalPages[this.externalPageCardIndex] = result[0];

this.externalSectionIsLoaded = true;
},
() => {
error: () => {
console.log('error')
this.externalSectionLoadError = true;
this.externalSectionIsLoaded = true;
}
);
});

this.isPageLoading = false;
},
Expand All @@ -200,18 +203,18 @@ export class ItemComponent implements OnInit {
if (result !== null && result !== undefined) {
this.encyclopediaService
.updateEntry(this.encyclopediaItem.id, { title: result } as any)
.subscribe(
(data) => {
.subscribe({
next: (data) => {
this.encyclopediaItem.title = data.title;
this._snackBar.open('Updated title!', 'Dismiss', {
duration: 3000,
});
},
(error: any) =>
error: (error: any) =>
this._snackBar.open('Error updating title!', 'Dismiss', {
duration: 3000,
})
);
});
}
});
}
Expand Down Expand Up @@ -299,49 +302,33 @@ export class ItemComponent implements OnInit {
}

openDeletePromptDialog() {
this.encyclopediaService.login().subscribe(
(name) => {
if (!this.dataService.getFlag()) {
this._snackBar.open('Welcome ' + name + '!', 'Dismiss', {
duration: 3000,
});
this.dataService.setFlag(true);
}
const dialogRef = this.dialog.open(DeletePromptDialogComponent, {});

dialogRef.afterClosed().subscribe((result: boolean) => {
if (result) {
this.encyclopediaService
.deleteEntry(this.encyclopediaItem.id)
.subscribe(
() => {
this.location.back();
this._snackBar.open(
'Deleted page from encyclopedia!',
'Dismiss',
{
duration: 3000,
}
);
},
(error: any) =>
this._snackBar.open(
'Error deleting page from encyclopedia!',
'Dismiss',
{
duration: 3000,
}
)
if (!this.dataService.getFlag()) {
let name = localStorage.getItem('user');
this._snackBar.open('Welcome ' + name + '!', 'Dismiss', {
duration: 3000,
});
this.dataService.setFlag(true);
}
const dialogRef = this.dialog.open(DeletePromptDialogComponent, {});

dialogRef.afterClosed().subscribe((result: boolean) => {
if (result) {
this.encyclopediaService
.deleteEntry(this.encyclopediaItem.id)
.subscribe(
() => {
this.location.back();
this._snackBar.open(
'Deleted page from encyclopedia!',
'Dismiss',
{
duration: 3000,
}
);
}
});
},
(_error) => {
this._snackBar.open('Unable to login!', 'Dismiss', {
duration: 3000,
});
}
);
}
);
});
}

onDownloadClick(file: Files) {
Expand Down Expand Up @@ -391,23 +378,16 @@ export class ItemComponent implements OnInit {
}

toggleEditMode() {
if (this.showEditButtons == false)
this.encyclopediaService.login().subscribe(
(name) => {
if (!this.dataService.getFlag()) {
this._snackBar.open('Welcome ' + name + '!', 'Dismiss', {
duration: 3000,
});
this.dataService.setFlag(true);
}
this.showEditButtons = true;
},
(_error) => {
this._snackBar.open('Unable to login!', 'Dismiss', {
duration: 3000,
});
}
);
if (this.showEditButtons == false) {
let name = localStorage.getItem('user');
if (!this.dataService.getFlag()) {
this._snackBar.open('Welcome ' + name + '!', 'Dismiss', {
duration: 3000,
});
this.dataService.setFlag(true);
}
this.showEditButtons = true;
}
else this.showEditButtons = false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/services/admins.service.ts
Expand Up @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
import {
HttpClient,
} from '@angular/common/http';
import { environment } from 'src/environments/environment';
import { environment } from 'src/environments/environment.prod';
import { Admins } from '../models/admins.model';

@Injectable()
Expand All @@ -24,7 +24,7 @@ export class AdminsService {
}

removeAdmin(userSid: string) {
return this.http.delete(
return this.http.get(
this.rootURL + '/RemoveAdmin?userSid=' + userSid
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/app/services/comments.service.ts
Expand Up @@ -6,7 +6,7 @@ import {
HttpErrorResponse,
HttpResponse,
} from '@angular/common/http';
import { environment } from 'src/environments/environment';
import { environment } from 'src/environments/environment.prod';
import { Comments } from '../models/comments.model';
import { CommentsExternalCollection } from '../models/comments-external-collection.model';

Expand Down Expand Up @@ -43,11 +43,11 @@ export class CommentsService {
}

delete(id: string, userSid: string) {
return this.http.delete(this.rootURL + '/' + id + '?userSid=' + userSid);
return this.http.get(this.rootURL + '/delete/' + id + '?userSid=' + userSid);
}

update(id: string, comment: string, userSid: string) {
return this.http.put(this.rootURL + '/' + id + '?comment=' + comment + '&userSid=' + userSid, {
return this.http.post(this.rootURL + '/' + id + '?comment=' + comment + '&userSid=' + userSid, {
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/services/email.service.ts
Expand Up @@ -6,7 +6,7 @@ import {
HttpErrorResponse,
HttpResponse,
} from '@angular/common/http';
import { environment } from 'src/environments/environment';
import { environment } from 'src/environments/environment.prod';

@Injectable()
export class EmailService {
Expand Down