edit and delete changes
This commit is contained in:
@@ -4,7 +4,7 @@ import {TranslateService} from "../../service/language/translate.service";
|
|||||||
import {ReadTranslateJsonService} from "../../service/language/readTranslateJson.service";
|
import {ReadTranslateJsonService} from "../../service/language/readTranslateJson.service";
|
||||||
import {cookieService} from "../../service/cookie.service";
|
import {cookieService} from "../../service/cookie.service";
|
||||||
import {UserService} from "../../service/http/user.service";
|
import {UserService} from "../../service/http/user.service";
|
||||||
import {UserEntity} from "../../interface/UserEntity";
|
import {newUser, UserEntity} from "../../interface/UserEntity";
|
||||||
import {loginTranslations} from "../../interface/translations";
|
import {loginTranslations} from "../../interface/translations";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -35,7 +35,7 @@ export class LoginComponent implements OnInit {
|
|||||||
this.loginTranslation = this.readTranslationJsonService.getLoginTranslations();
|
this.loginTranslation = this.readTranslationJsonService.getLoginTranslations();
|
||||||
}
|
}
|
||||||
|
|
||||||
createNewUser(createUser: UserEntity) {
|
createNewUser(createUser: newUser) {
|
||||||
console.log(createUser.username+" "+createUser.password);
|
console.log(createUser.username+" "+createUser.password);
|
||||||
if (createUser.username == '' || createUser.password == '') {
|
if (createUser.username == '' || createUser.password == '') {
|
||||||
this.errorCreateUser = true;
|
this.errorCreateUser = true;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {Component, OnInit} from '@angular/core';
|
import {Component, OnInit} from '@angular/core';
|
||||||
import {UserEntity} from "../../interface/UserEntity";
|
import {newUser, UserEntity} from "../../interface/UserEntity";
|
||||||
import {LocationEntity} from "../../interface/LocationEntity";
|
import {LocationEntity} from "../../interface/LocationEntity";
|
||||||
import {newWaypoint, WaypointsEntity} from "../../interface/WaypointsEntity";
|
import {newWaypoint, WaypointsEntity} from "../../interface/WaypointsEntity";
|
||||||
import {Router} from "@angular/router";
|
import {Router} from "@angular/router";
|
||||||
@@ -24,7 +24,7 @@ export class ManagementComponent implements OnInit {
|
|||||||
showLocationForm: boolean = false;
|
showLocationForm: boolean = false;
|
||||||
showWaypointForm: boolean = false;
|
showWaypointForm: boolean = false;
|
||||||
|
|
||||||
newUser: UserEntity = {password: "", username: ""};
|
newUser: newUser = {password: "", username: ""};
|
||||||
newLocation: LocationEntity = {location: "", lat: 0, lon: 0, region: ""};
|
newLocation: LocationEntity = {location: "", lat: 0, lon: 0, region: ""};
|
||||||
newWaypoint: newWaypoint = {description: "", img: "", lat: 0, locationName: "", lon: 0, name: ""};
|
newWaypoint: newWaypoint = {description: "", img: "", lat: 0, locationName: "", lon: 0, name: ""};
|
||||||
|
|
||||||
@@ -133,11 +133,11 @@ export class ManagementComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// editUser(user: UserEntity) {
|
editUser(user: UserEntity) {
|
||||||
// this.userService.updateUser(user, user.id).subscribe(user => {
|
this.userService.updateUser(user, user.id).subscribe(user => {
|
||||||
// this.users?.splice(this.users?.indexOf(user), 1, user);
|
this.users?.splice(this.users?.indexOf(user), 1, user);
|
||||||
// });
|
});
|
||||||
// }
|
}
|
||||||
|
|
||||||
openEditLocationForm(location: LocationEntity) {
|
openEditLocationForm(location: LocationEntity) {
|
||||||
this.newLocation = location;
|
this.newLocation = location;
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
export interface UserEntity {
|
export interface UserEntity {
|
||||||
id?: number;
|
id: number;
|
||||||
username: string;
|
username: string;
|
||||||
password: string;
|
password: string;
|
||||||
admin?: boolean;
|
admin?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface newUser {
|
||||||
|
username: string;
|
||||||
|
password: string;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {Injectable} from "@angular/core";
|
import {Injectable} from "@angular/core";
|
||||||
import {HttpClient} from "@angular/common/http";
|
import {HttpClient} from "@angular/common/http";
|
||||||
import {UserEntity} from "../../interface/UserEntity";
|
import {newUser, UserEntity} from "../../interface/UserEntity";
|
||||||
import {catchError, of} from "rxjs";
|
import {catchError, of} from "rxjs";
|
||||||
|
|
||||||
const BASE_URL = "progetto152";
|
const BASE_URL = "progetto152";
|
||||||
@@ -41,7 +41,7 @@ export class UserService {
|
|||||||
return this.http.get<UserEntity>(GET_USER_BY_ID + "/" + id);
|
return this.http.get<UserEntity>(GET_USER_BY_ID + "/" + id);
|
||||||
}
|
}
|
||||||
|
|
||||||
createUser(user: UserEntity) {
|
createUser(user: newUser) {
|
||||||
console.log("create " + user);
|
console.log("create " + user);
|
||||||
return this.http.post<UserEntity>(USER, user);
|
return this.http.post<UserEntity>(USER, user);
|
||||||
|
|
||||||
@@ -52,6 +52,6 @@ export class UserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
deleteUser(id: number) {
|
deleteUser(id: number) {
|
||||||
return this.http.delete<UserEntity>(USER + id);
|
return this.http.delete<UserEntity>(USER+"/" + id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,6 @@ export class WaypointService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
deleteWaypoint(id: number) {
|
deleteWaypoint(id: number) {
|
||||||
return this.http.delete<WaypointsEntity>(WAYPOINT + id);
|
return this.http.delete<WaypointsEntity>(WAYPOINT+"/" + id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user