aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/app')
-rw-r--r--frontend/src/app/Shared.ts25
-rw-r--r--frontend/src/app/_elements/navbar/navbar.component.ts4
-rw-r--r--frontend/src/app/_modals/alert-dialog/alert-dialog.component.css0
-rw-r--r--frontend/src/app/_modals/alert-dialog/alert-dialog.component.html7
-rw-r--r--frontend/src/app/_modals/alert-dialog/alert-dialog.component.spec.ts25
-rw-r--r--frontend/src/app/_modals/alert-dialog/alert-dialog.component.ts28
-rw-r--r--frontend/src/app/_modals/login-modal/login-modal.component.html2
-rw-r--r--frontend/src/app/_modals/login-modal/login-modal.component.ts5
-rw-r--r--frontend/src/app/_modals/register-modal/register-modal.component.ts12
-rw-r--r--frontend/src/app/_pages/add-model/add-model.component.ts18
-rw-r--r--frontend/src/app/_pages/filter-datasets/filter-datasets.component.ts8
-rw-r--r--frontend/src/app/_pages/my-models/my-models.component.ts3
-rw-r--r--frontend/src/app/_pages/predict/predict.component.ts4
-rw-r--r--frontend/src/app/_pages/profile/profile.component.ts13
-rw-r--r--frontend/src/app/app.module.ts10
-rw-r--r--frontend/src/app/material.module.ts7
16 files changed, 136 insertions, 35 deletions
diff --git a/frontend/src/app/Shared.ts b/frontend/src/app/Shared.ts
index 31afb1a6..86e26687 100644
--- a/frontend/src/app/Shared.ts
+++ b/frontend/src/app/Shared.ts
@@ -1,9 +1,32 @@
+import { ElementRef } from "@angular/core";
+import { NgbModal } from "@ng-bootstrap/ng-bootstrap";
+import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
+import { AlertDialogComponent } from './_modals/alert-dialog/alert-dialog.component';
+
class Shared {
constructor(
public loggedIn: boolean,
public username: string = '',
- public photoId: string = '1'
+ public photoId: string = '1',
+ public dialog?: MatDialog
+ //public alertDialog?: ElementRef
) { }
+
+
+ openDialog(title: string, message: string): void {
+ console.log("USAO U OPEN DIALOG 1");
+
+ if (this.dialog) {
+ console.log("USAO U OPEN DIALOG 2");
+ const dialogRef = this.dialog.open(AlertDialogComponent, {
+ //width: '250px',
+ data: { title: title, message: message }
+ });
+ dialogRef.afterClosed().subscribe(res => {
+ //nesto
+ });
+ }
+ }
}
export default new Shared(false); \ No newline at end of file
diff --git a/frontend/src/app/_elements/navbar/navbar.component.ts b/frontend/src/app/_elements/navbar/navbar.component.ts
index 2e4bde91..368508ed 100644
--- a/frontend/src/app/_elements/navbar/navbar.component.ts
+++ b/frontend/src/app/_elements/navbar/navbar.component.ts
@@ -3,6 +3,7 @@ import { Location } from '@angular/common';
import { AuthService } from '../../_services/auth.service';
import shared from 'src/app/Shared';
import { UserInfoService } from 'src/app/_services/user-info.service';
+import { MatDialog } from '@angular/material/dialog';
@Component({
selector: 'app-navbar',
@@ -14,7 +15,8 @@ export class NavbarComponent implements OnInit {
currentUrl: string;
shared = shared;
- constructor(public location: Location, private auth: AuthService, private userInfoService: UserInfoService) {
+ constructor(public location: Location, private auth: AuthService, private userInfoService: UserInfoService, private matDialog: MatDialog) {
+ shared.dialog = matDialog;
this.currentUrl = this.location.path();
this.location.onUrlChange(() => {
this.currentUrl = this.location.path();
diff --git a/frontend/src/app/_modals/alert-dialog/alert-dialog.component.css b/frontend/src/app/_modals/alert-dialog/alert-dialog.component.css
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/frontend/src/app/_modals/alert-dialog/alert-dialog.component.css
diff --git a/frontend/src/app/_modals/alert-dialog/alert-dialog.component.html b/frontend/src/app/_modals/alert-dialog/alert-dialog.component.html
new file mode 100644
index 00000000..82365193
--- /dev/null
+++ b/frontend/src/app/_modals/alert-dialog/alert-dialog.component.html
@@ -0,0 +1,7 @@
+<h2 mat-dialog-title class="text-muted">{{data.title}}</h2>
+<div mat-dialog-content class="mt-4" style="color: rgb(81, 76, 76);">
+ {{data.message}}
+</div>
+<div mat-dialog-actions class="d-flex justify-content-center mt-4">
+ <button mat-button cdkFocusInitial (click)="onOkClick()" style="background-color: lightgray;">OK</button>
+</div> \ No newline at end of file
diff --git a/frontend/src/app/_modals/alert-dialog/alert-dialog.component.spec.ts b/frontend/src/app/_modals/alert-dialog/alert-dialog.component.spec.ts
new file mode 100644
index 00000000..a93fc493
--- /dev/null
+++ b/frontend/src/app/_modals/alert-dialog/alert-dialog.component.spec.ts
@@ -0,0 +1,25 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { AlertDialogComponent } from './alert-dialog.component';
+
+describe('AlertDialogComponent', () => {
+ let component: AlertDialogComponent;
+ let fixture: ComponentFixture<AlertDialogComponent>;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [ AlertDialogComponent ]
+ })
+ .compileComponents();
+ });
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(AlertDialogComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/frontend/src/app/_modals/alert-dialog/alert-dialog.component.ts b/frontend/src/app/_modals/alert-dialog/alert-dialog.component.ts
new file mode 100644
index 00000000..e15f3c6f
--- /dev/null
+++ b/frontend/src/app/_modals/alert-dialog/alert-dialog.component.ts
@@ -0,0 +1,28 @@
+import { Component, OnInit } from '@angular/core';
+import { Inject} from '@angular/core';
+import { MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog';
+
+interface DialogData {
+ title: string;
+ message: string;
+}
+
+@Component({
+ selector: 'app-alert-dialog',
+ templateUrl: './alert-dialog.component.html',
+ styleUrls: ['./alert-dialog.component.css']
+})
+export class AlertDialogComponent {
+
+ constructor(
+ public dialogRef: MatDialogRef<AlertDialogComponent>,
+ @Inject(MAT_DIALOG_DATA) public data: DialogData,
+ //public dialog: MatDialog
+ ) {}
+
+ onOkClick(): void {
+ this.dialogRef.close();
+ }
+
+
+}
diff --git a/frontend/src/app/_modals/login-modal/login-modal.component.html b/frontend/src/app/_modals/login-modal/login-modal.component.html
index d7836848..03048155 100644
--- a/frontend/src/app/_modals/login-modal/login-modal.component.html
+++ b/frontend/src/app/_modals/login-modal/login-modal.component.html
@@ -3,7 +3,7 @@
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header" style="background-color: #003459;">
- <button id="closeButton" type="button" class="btn-close" style="background-color:white;" data-bs-dismiss="modal" aria-label="Close" (click)="resetData()"></button>
+ <button #closeButton type="button" class="btn-close" style="background-color:white;" data-bs-dismiss="modal" aria-label="Close" (click)="resetData()"></button>
</div>
<div class="modal-body px-5" style="color:#003459">
<h1 class="text-center mt-2 mb-4">Prijavite se</h1>
diff --git a/frontend/src/app/_modals/login-modal/login-modal.component.ts b/frontend/src/app/_modals/login-modal/login-modal.component.ts
index c86c269a..e1535a25 100644
--- a/frontend/src/app/_modals/login-modal/login-modal.component.ts
+++ b/frontend/src/app/_modals/login-modal/login-modal.component.ts
@@ -4,6 +4,7 @@ import { CookieService } from 'ngx-cookie-service';
import { AuthService } from 'src/app/_services/auth.service';
import { UserInfoService } from 'src/app/_services/user-info.service';
import shared from '../../Shared';
+import {AfterViewInit, ElementRef} from '@angular/core';
@Component({
selector: 'app-login-modal',
@@ -12,6 +13,8 @@ import shared from '../../Shared';
})
export class LoginModalComponent implements OnInit {
+ @ViewChild('closeButton') closeButton?: ElementRef;
+
username: string = '';
password: string = '';
@@ -38,7 +41,7 @@ export class LoginModalComponent implements OnInit {
}
else {
this.authService.authenticate(response);
- (<HTMLSelectElement>document.getElementById('closeButton')).click();
+ (<HTMLSelectElement>this.closeButton?.nativeElement).click();
this.userInfoService.getUserInfo().subscribe((response) => {
shared.photoId = response.photoId;
});
diff --git a/frontend/src/app/_modals/register-modal/register-modal.component.ts b/frontend/src/app/_modals/register-modal/register-modal.component.ts
index 13ef7eba..05888589 100644
--- a/frontend/src/app/_modals/register-modal/register-modal.component.ts
+++ b/frontend/src/app/_modals/register-modal/register-modal.component.ts
@@ -1,6 +1,9 @@
import { Component, OnInit } from '@angular/core';
import { AuthService } from 'src/app/_services/auth.service';
import User from 'src/app/_data/User';
+import { DOCUMENT } from '@angular/common';
+import { Inject } from '@angular/core';
+import shared from 'src/app/Shared';
@Component({
selector: 'app-register-modal',
@@ -29,8 +32,11 @@ export class RegisterModalComponent implements OnInit {
pattEmail: RegExp = /^[a-zA-Z0-9]+([\.\-\+][a-zA-Z0-9]+)*\@([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}$/;
pattPassword: RegExp = /.{6,30}$/;
+ shared = shared;
+
constructor(
- private authService: AuthService
+ private authService: AuthService,
+ @Inject(DOCUMENT) document: Document
) { }
ngOnInit(): void {
@@ -149,11 +155,11 @@ export class RegisterModalComponent implements OnInit {
}, (error) => console.warn(error));
}
else if (response == 'Email Already Exists') {
- alert('Nalog sa unetim email-om već postoji!');
+ shared.openDialog("Greška!", "Nalog sa unetim email-om već postoji!");
(<HTMLSelectElement>document.getElementById('email')).focus();
}
else if (response == 'Username Already Exists') {
- alert('Nalog sa unetim korisničkim imenom već postoji!');
+ shared.openDialog("Greška!", "Nalog sa unetim korisničkim imenom već postoji!");
(<HTMLSelectElement>document.getElementById('username-register')).focus();
}
}
diff --git a/frontend/src/app/_pages/add-model/add-model.component.ts b/frontend/src/app/_pages/add-model/add-model.component.ts
index 2121dc3b..945a58b5 100644
--- a/frontend/src/app/_pages/add-model/add-model.component.ts
+++ b/frontend/src/app/_pages/add-model/add-model.component.ts
@@ -143,14 +143,14 @@ export class AddModelComponent implements OnInit {
this.models.addModel(this.newModel).subscribe((response) => {
callback(response);
}, (error) => {
- alert("Model sa unetim nazivom već postoji u Vašoj kolekciji.\nPromenite naziv modela i nastavite sa kreiranim datasetom.");
+ shared.openDialog("Neuspeo pokušaj!", "Model sa unetim nazivom već postoji u Vašoj kolekciji. Promenite naziv modela i nastavite sa kreiranim datasetom.");
}); //kraj addModel subscribe
}, (error) => {
- alert("Dataset sa unetim nazivom već postoji u Vašoj kolekciji.\nIzmenite naziv ili iskoristite postojeći dataset.");
+ shared.openDialog("Neuspeo pokušaj!", "Dataset sa unetim nazivom već postoji u Vašoj kolekciji. Izmenite naziv ili iskoristite postojeći dataset.");
}); //kraj addDataset subscribe
} //kraj treceg ifa
}, (error) => {
- //alert("greska uploadData");
+
}); //kraj uploadData subscribe
} //kraj drugog ifa
@@ -174,12 +174,12 @@ export class AddModelComponent implements OnInit {
this.models.addModel(this.newModel).subscribe((response) => {
callback(response);
}, (error) => {
- alert("Model sa unetim nazivom već postoji u Vašoj kolekciji.\nPromenite naziv modela i nastavite sa kreiranim datasetom.");
+ shared.openDialog("Neuspeo pokušaj!", "Model sa unetim nazivom već postoji u Vašoj kolekciji. Promenite naziv modela i nastavite sa kreiranim datasetom.");
});
}
}
else {
- alert("Molimo Vas da izaberete neki dataset iz kolekcije.");
+ shared.openDialog("Obaveštenje", "Molimo Vas da izaberete neki dataset iz kolekcije.");
}
}
@@ -213,21 +213,21 @@ export class AddModelComponent implements OnInit {
}
validationInputsOutput(): boolean {
if (this.newModel.inputColumns.length == 0 && this.newModel.columnToPredict == '') {
- alert("Molimo Vas da izaberete ulazne i izlazne kolone za mrežu.");
+ shared.openDialog("Neuspeo pokušaj!", "Molimo Vas da izaberete ulazne i izlazne kolone za mrežu.");
return false;
}
else if (this.newModel.inputColumns.length == 0) {
- alert("Molimo Vas da izaberete ulaznu kolonu/kolone za mrežu.");
+ shared.openDialog("Neuspeo pokušaj!", "Molimo Vas da izaberete ulaznu kolonu/kolone za mrežu.");
return false;
}
else if (this.newModel.columnToPredict == '') {
- alert("Molimo Vas da izaberete izlaznu kolonu za mrežu.");
+ shared.openDialog("Neuspeo pokušaj!", "Molimo Vas da izaberete izlaznu kolonu za mrežu.");
return false;
}
for (let i = 0; i < this.newModel.inputColumns.length; i++) {
if (this.newModel.inputColumns[i] == this.newModel.columnToPredict) {
let colName = this.newModel.columnToPredict;
- alert("Izabrali ste istu kolonu (" + colName + ") kao ulaznu i izlaznu iz mreže. Korigujte izbor.");
+ shared.openDialog("Neuspeo pokušaj!", "Izabrali ste istu kolonu (" + colName + ") kao ulaznu i izlaznu iz mreže. Korigujte izbor.");
return false;
}
}
diff --git a/frontend/src/app/_pages/filter-datasets/filter-datasets.component.ts b/frontend/src/app/_pages/filter-datasets/filter-datasets.component.ts
index b75decf2..fc146046 100644
--- a/frontend/src/app/_pages/filter-datasets/filter-datasets.component.ts
+++ b/frontend/src/app/_pages/filter-datasets/filter-datasets.component.ts
@@ -4,6 +4,7 @@ import Dataset from 'src/app/_data/Dataset';
import {Router} from '@angular/router'
import { JwtHelperService } from '@auth0/angular-jwt';
import { CookieService } from 'ngx-cookie-service';
+import shared from 'src/app/Shared';
@Component({
selector: 'app-filter-datasets',
@@ -12,6 +13,7 @@ import { CookieService } from 'ngx-cookie-service';
})
export class FilterDatasetsComponent implements OnInit {
+ shared = shared;
publicDatasets?: Dataset[];
term: string = "";
constructor(private datasets: DatasetsService,private router:Router, private cookie: CookieService) {
@@ -37,11 +39,9 @@ export class FilterDatasetsComponent implements OnInit {
if(name!=null && name!="")
this.datasets.addDataset(newDataset).subscribe((response:string)=>{
console.log(response);
- alert("Uspenso ste dodali dataset sa imenom "+newDataset.name);
+ shared.openDialog("Obaveštenje", "Uspešno ste dodali dataset sa nazivom " + newDataset.name);
},(error)=>{
- alert("Vec imate dataset sa istim imenom molim vas unesite drugo ime");
-
-
+ shared.openDialog("Obaveštenje", "U svojoj kolekciji već imate dataset sa ovim imenom. Molimo Vas da unesete drugo ime.");
});
};
diff --git a/frontend/src/app/_pages/my-models/my-models.component.ts b/frontend/src/app/_pages/my-models/my-models.component.ts
index bd6b0a2b..6086b1b1 100644
--- a/frontend/src/app/_pages/my-models/my-models.component.ts
+++ b/frontend/src/app/_pages/my-models/my-models.component.ts
@@ -1,4 +1,5 @@
import { Component, OnInit } from '@angular/core';
+import shared from 'src/app/Shared';
import Model from 'src/app/_data/Model';
import { ModelsService } from 'src/app/_services/models.service';
@@ -38,7 +39,7 @@ deleteThisModel(model: Model): void{
this.getAllMyModels();
}, (error) =>{
if (error.error == "Model with name = {name} deleted") {
- alert("Greška pri brisanju modela!");
+ shared.openDialog("Obaveštenje", "Greška prilikom brisanja modela.");
}
});
diff --git a/frontend/src/app/_pages/predict/predict.component.ts b/frontend/src/app/_pages/predict/predict.component.ts
index 71cf93ce..b541e1f0 100644
--- a/frontend/src/app/_pages/predict/predict.component.ts
+++ b/frontend/src/app/_pages/predict/predict.component.ts
@@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import Predictor from 'src/app/_data/Predictor';
import { PredictorsService } from 'src/app/_services/predictors.service';
+import shared from 'src/app/Shared';
@Component({
selector: 'app-predict',
@@ -29,8 +30,7 @@ export class PredictComponent implements OnInit {
usePredictor(): void{
this.predictS.usePredictor(this.predictor, this.inputs).subscribe(p => {
-
- alert("Prediktor je uspesno poslat na treniranje!");
+ shared.openDialog("Obaveštenje", "Prediktor je uspešno poslat na probu."); //pisalo je "na treniranje" ??
})
console.log(this.inputs);
}
diff --git a/frontend/src/app/_pages/profile/profile.component.ts b/frontend/src/app/_pages/profile/profile.component.ts
index 7a7796da..d055fad3 100644
--- a/frontend/src/app/_pages/profile/profile.component.ts
+++ b/frontend/src/app/_pages/profile/profile.component.ts
@@ -6,6 +6,7 @@ import { Router } from '@angular/router';
import { PICTURES } from 'src/app/_data/ProfilePictures';
import { Picture } from 'src/app/_data/ProfilePictures';
import shared from '../../Shared';
+import { share } from 'rxjs';
@Component({
@@ -15,8 +16,6 @@ import shared from '../../Shared';
})
export class ProfileComponent implements OnInit {
-
-
user: User = new User();
pictures: Picture[] = PICTURES;
@@ -90,18 +89,18 @@ export class ProfileComponent implements OnInit {
if (this.user.username != editedUser.username) { //promenio username, ide logout
this.user = editedUser;
this.resetInfo();
- alert("Nakon promene korisničkog imena, moraćete ponovo da se ulogujete.");
+ shared.openDialog("Obaveštenje", "Nakon promene korisničkog imena, moraćete ponovo da se ulogujete.");
this.authService.logOut();
this.router.navigate(['']);
return;
}
- alert("Podaci su uspešno promenjeni.");
+ shared.openDialog("Obaveštenje", "Podaci su uspešno promenjeni.");
this.user = editedUser;
console.log(this.user);
this.resetInfo();
}, (error: any) =>{
if (error.error == "Username already exists!") {
- alert("Ukucano korisničko ime je već zauzeto!\nIzaberite neko drugo.");
+ shared.openDialog("Obaveštenje", "Ukucano korisničko ime je već zauzeto! Izaberite neko drugo.");
//(<HTMLSelectElement>document.getElementById("inputUsername")).focus();
//poruka obavestenja ispod inputa
this.resetInfo();
@@ -131,7 +130,7 @@ export class ProfileComponent implements OnInit {
this.userInfoService.changeUserPassword(passwordArray).subscribe((response: any) => {
//console.log("PROMENIO LOZINKU");
this.resetNewPassInputs();
- alert("Nakon promene lozinke, moraćete ponovo da se ulogujete.");
+ shared.openDialog("Obaveštenje", "Nakon promene lozinke, moraćete ponovo da se ulogujete.");
this.authService.logOut();
this.router.navigate(['']);
}, (error: any) => {
@@ -142,7 +141,7 @@ export class ProfileComponent implements OnInit {
return;
}
else if (error.error == 'Identical password!') {
- alert("Stara i nova lozinka su identične.");
+ shared.openDialog("Obaveštenje", "Stara i nova lozinka su identične.");
this.resetNewPassInputs();
//(<HTMLSelectElement>document.getElementById("inputNewPassword")).focus();
return;
diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts
index d90de54d..8098df40 100644
--- a/frontend/src/app/app.module.ts
+++ b/frontend/src/app/app.module.ts
@@ -1,4 +1,4 @@
-import { NgModule } from '@angular/core';
+import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { AppRoutingModule } from './app-routing.module';
@@ -39,6 +39,7 @@ import { FilterDatasetsComponent } from './_pages/filter-datasets/filter-dataset
import { ReactiveBackgroundComponent } from './_elements/reactive-background/reactive-background.component';
import { ItemModelComponent } from './_elements/item-model/item-model.component';
import { AnnvisualComponent } from './_elements/annvisual/annvisual.component';
+import { AlertDialogComponent } from './_modals/alert-dialog/alert-dialog.component';
@NgModule({
declarations: [
@@ -67,7 +68,8 @@ import { AnnvisualComponent } from './_elements/annvisual/annvisual.component';
FilterDatasetsComponent,
ReactiveBackgroundComponent,
ItemModelComponent,
- AnnvisualComponent
+ AnnvisualComponent,
+ AlertDialogComponent
],
imports: [
BrowserModule,
@@ -84,6 +86,8 @@ import { AnnvisualComponent } from './_elements/annvisual/annvisual.component';
Ng2SearchPipeModule,
],
providers: [],
- bootstrap: [AppComponent]
+ bootstrap: [AppComponent],
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
+ entryComponents: [AlertDialogComponent]
})
export class AppModule { }
diff --git a/frontend/src/app/material.module.ts b/frontend/src/app/material.module.ts
index e85419ee..d16cef3d 100644
--- a/frontend/src/app/material.module.ts
+++ b/frontend/src/app/material.module.ts
@@ -1,18 +1,21 @@
import { NgModule } from '@angular/core';
-
+import { CommonModule } from '@angular/common';
import { MatDialogModule } from '@angular/material/dialog';
import { MatButtonModule } from '@angular/material/button';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { MatCheckboxModule } from '@angular/material/checkbox';
+import { MatIconModule } from '@angular/material/icon';
@NgModule({
exports: [
+ CommonModule,
MatDialogModule,
MatButtonModule,
MatFormFieldModule,
MatInputModule,
- MatCheckboxModule
+ MatCheckboxModule,
+ MatIconModule
]
})
export class MaterialModule {} \ No newline at end of file