Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component, OnInit } from '@angular/core';
- import { SwiperComponent, SwiperDirective, SwiperConfigInterface,
- SwiperScrollbarInterface, SwiperPaginationInterface } from 'ngx-swiper-wrapper';
- import { SliderComponent, UserNavComponent } from '../../components/index';
- import { User } from '../../_models/index';
- import { FormGroup, FormBuilder, Validators } from '@angular/forms';
- import { UserService, AuthenticationService } from '../../services/index';
- @Component({
- moduleId: module.id.toString(),
- selector: 'app-user-dashboard',
- templateUrl: './userdashboard.component.html',
- styleUrls: ['userdashboard.component.css'],
- })
- // tslint:disable-next-line:component-class-suffix
- export class UserDashboard implements OnInit {
- currentUser: User;
- users: User[] = [];
- model: any = {};
- userDetails: any = {};
- userUpdate: FormGroup;
- constructor(private userService: UserService, private auth: AuthenticationService, private fb: FormBuilder) {
- this.currentUser = JSON.parse(localStorage.getItem('currentUser'));
- let test = this.auth.getUserDetails(this.currentUser.id);
- test.subscribe(res => {
- if (res && res.hasOwnProperty('Users') {
- this.userDetails = res.Users[0];
- }
- });
- }
- ngOnInit() {
- this.loadAllUsers();
- }
- deleteUser(id: number) {
- this.userService.delete(id).subscribe(() => { this.loadAllUsers();
- });
- }
- private userUpdate(){
- this.auth.update(this.model.username, this.model.password,
- this.model.email, this.model.firstName, this.model.lastName,
- this.model.ageMonth, this.model.ageDay, this.model.ageYear).subscribe(
- data => {
- this.alertService.success('Update successful', true);
- },
- }
- private loadAllUsers() {
- this.userService.getAll().subscribe(users => { this.users = users; });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement