<repo_name>IbrahimAdDandan/axess-front-end<file_sep>/src/app/interceptor.interceptor.ts
import { Injectable } from '@angular/core';
import {
  HttpRequest,
  HttpHandler,
  HttpEvent,
  HttpInterceptor,
  HttpErrorResponse,
  HttpParams,
  HttpHeaders
} from '@angular/common/http';
import { environment } from "../environments/environment.prod";
import { Observable } from 'rxjs';

@Injectable()
export class InterceptorInterceptor implements HttpInterceptor {

  constructor() { }

  intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
    const _sid = localStorage.getItem('sid');
    // if (_sid && request.url.toLowerCase().indexOf("hash") !== -1) {
    //   // const header = request.headers.append('Content-Type', 'application/x-www-form-urlencoded');
    //   // const cloneReq = request.clone({ url: request.url + "?sid=" + _sid, headers: request.headers.append('Content-Type', 'application/x-www-form-urlencoded') });
    //   const cloneReq = request.clone({ url: request.url + "?sid=" + _sid});
    //   debugger;
    //   return next.handle(cloneReq);
    // }
    if (_sid && request.url.toLowerCase().indexOf(environment.apiEndpoint.toLowerCase()) !== -1) {
      // request.params.append('sid', _sid)
      const cloneReq = request.clone({ params: request.params.append('sid', _sid) });
      // const cloneReq = request.clone({ url: request.url + "?&type=json&sid=" + _sid });
      // debugger;
      return next.handle(cloneReq);
    }
    // else if (request.url.toLowerCase().indexOf("login") !== -1) {
    //   const cloneReq = request.clone( { url: environment.apiEndpoint + request.url });
    // return next.handle(cloneReq);
    // }
    const cloneReq = request.clone({ url: request.url });
    return next.handle(cloneReq);
  }

  private handleAuthError(err: HttpErrorResponse): Observable<any> {
    // console.log('from interceptor: ' + err);
    // if (err.status === 401 || err.status === 403) {
    //   return Observable.throw(err);
    // }
    return Observable.throw(err);
  }

}
<file_sep>/src/app/rooms/rooms.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { RoomsRoutingModule } from './rooms-routing.module';
import { ViewRoomsComponent } from './view-rooms/view-rooms.component';
import { GroupRoomsComponent } from './group-rooms/group-rooms.component';
import {  MatSnackBarModule } from "@angular/material/snack-bar";


@NgModule({
  declarations: [ViewRoomsComponent, GroupRoomsComponent],
  imports: [
    CommonModule,
    RoomsRoutingModule,
    MatSnackBarModule
  ],
  exports: [GroupRoomsComponent]
})
export class RoomsModule { }
<file_sep>/src/app/home/home.service.ts
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { environment } from 'src/environments/environment.prod';

@Injectable({
  providedIn: 'root'
})
export class HomeService {

  mailUrl = environment.apiEndpoint + 'user/mail';

  constructor(private _http: HttpClient) { }

  sendMail(subject: string, content: string, mail: string) {
    let form = new URLSearchParams();
    form.append('subject', subject);
    form.append('content', content);
    form.append('email', mail);
    return this._http.post<any>(this.mailUrl, form.toString, { headers: new HttpHeaders({
      'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
    }) });
  }

  sendmail1(object: any) {
    
    return this._http.post<any>("https://smtpjs.com/v3/smtpjs.aspx?", JSON.stringify(object), { headers: new HttpHeaders({
      'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
    }) });
  }



}
<file_sep>/src/app/models/appointment.model.ts
import { Room } from './room.model';
import { User } from './user.model';

export class Appointment {
    id: number;
    connectedEvent: boolean;
    deleted: boolean;
    description: string;
    end: Date;
    passwordProtected: boolean;
    start: Date;
    title: string;
    room: Room;
    owner: User;
}
<file_sep>/src/app/app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import {SharedModule } from './shared/shared.module';
import { SecurityModule } from "./security/security.module";
import { DashboardModule } from "./dashboard/dashboard.module";
import { GroupsModule } from "./groups/groups.module";
import { RoomsModule } from "./rooms/rooms.module";

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { InterceptorInterceptor } from "./interceptor.interceptor";
import { AuthGuardGuard } from './auth-guard.guard';
import { HomeComponent } from './home/home.component';
import { NotfoundComponent } from './notfound/notfound.component';
import { WelcomeSectionComponent } from './home/sections/welcome-section/welcome-section.component';
import { ServicesSectionComponent } from './home/sections/services-section/services-section.component';
import { AboutusComponent } from './home/sections/aboutus/aboutus.component';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import {MatCardModule} from '@angular/material/card';
import { AgmCoreModule } from '@agm/core';
import { PricingComponent } from './pricing/pricing.component';
import { MatSlideToggleModule } from "@angular/material/slide-toggle";
import { UserProfileComponent } from './user-profile/user-profile.component';
import { MatFormFieldModule } from "@angular/material/form-field";
import { MatPasswordStrengthModule } from '@angular-material-extensions/password-strength';
import { WhoWeAreComponent } from './home/sections/who-we-are/who-we-are.component';


@NgModule({
  declarations: [
    AppComponent,
    HomeComponent,
    NotfoundComponent,
    WelcomeSectionComponent,
    ServicesSectionComponent,
    AboutusComponent,
    PricingComponent,
    UserProfileComponent,
    WhoWeAreComponent
  ],
  imports: [
    BrowserModule,
    RouterModule,
    FormsModule,
    AppRoutingModule,
    SharedModule,
    SecurityModule,
    DashboardModule,
    GroupsModule,
    RoomsModule,
    FontAwesomeModule,
    BrowserAnimationsModule,
    MatCardModule,
    MatSlideToggleModule,
    AgmCoreModule.forRoot({
      apiKey: '<KEY>'
    }),
    MatFormFieldModule,
    MatPasswordStrengthModule
  ],
  providers: [AuthGuardGuard, {
    provide: HTTP_INTERCEPTORS,
    useClass: InterceptorInterceptor,
    multi: true
  }],
  bootstrap: [AppComponent]
})
export class AppModule { }
<file_sep>/src/app/models/user.model.ts
import { Group } from './group.model';

export class User {
    id: number;
    firstname: string;
    lastname: string;
    login: string;
    password: string;
    external_id: number;
    external_type: string;
    pictureuri: string;
    displayName: string;
    timeZoneId: string;
    type: string;
    rights: string[];
    address: Address;
    languageId: number;
    groups: Group[];
}

export class Address {
    id: number;
    deleted: boolean;
    country: string;
    email: string;
}<file_sep>/src/app/rooms/services/room.service.ts
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { environment } from "../../../environments/environment.prod";
import { Room } from "../../models/room.model";
import { Invitation } from "src/app/models/invitation.model";
import { Appointment } from "src/app/models/appointment.model";

@Injectable({
  providedIn: 'root'
})
export class RoomService {

  private _roomsByGroupUrl = environment.apiEndpoint + 'group/';
  private _invitationUrl = environment.apiEndpoint + 'user/invitations/';

  constructor(private _http: HttpClient) { }

  get(groupId) {
    return this._http.get<{roomDTO: Room[]}>(environment.apiEndpoint + 'group/' + groupId + '/rooms');
  }

  getInvitations(userId: number) {
    return this._http.get<Invitation[]>(this._invitationUrl + userId);
  }

  getAppointments(groupId: number) {
    return this._http.get<{appointmentDTO: Appointment[]}>(environment.apiEndpoint + 'calendar/group/' + groupId);
  }

  getRoomHash(roomId) {

    const body = {
      user: JSON.stringify({
        firstname: localStorage.getItem('firstname'),
        lastname: localStorage.getItem('lastname'),
        id: localStorage.getItem('userId'),
        login: localStorage.getItem('login'),
        externalId: 1,
        externalType: null
      }),
      options: JSON.stringify({
        roomId: roomId,
        moderator: false,
        showAudioVideoTest: true,
      })
    };

    let form = new URLSearchParams();
    form.append('user', body.user);
    form.append('options', body.options);
    
    return this._http.post<any>(environment.apiEndpoint + 'user/hash', form.toString(), { headers: new HttpHeaders({ 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }) });
  }

}
<file_sep>/src/app/security/register/register.component.ts
import { ChangeDetectionStrategy, Component, OnInit, ViewEncapsulation } from '@angular/core';
import { FormControl, FormGroupDirective, NgForm } from '@angular/forms';
import { Router } from '@angular/router';
import { User, Address } from 'src/app/models/user.model';
import { LoginService } from '../services/login-service.service';
import { MatPasswordStrengthComponent } from '@angular-material-extensions/password-strength';
import { MatFormField } from "@angular/material/form-field/form-field";
import {
  MatSnackBar, MatSnackBarHorizontalPosition,
  MatSnackBarVerticalPosition,
} from '@angular/material/snack-bar';

@Component({
  selector: 'app-register',
  templateUrl: './register.component.html',
  styleUrls: ['./register.component.sass'],
  encapsulation: ViewEncapsulation.None,
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class RegisterComponent implements OnInit {

  user: User;
  horizontalPosition: MatSnackBarHorizontalPosition = 'center';
  verticalPosition: MatSnackBarVerticalPosition = 'bottom';

  constructor(private _auth: LoginService, private _router: Router, private _snackBar: MatSnackBar) { }

  ngOnInit(): void {
    this.user = new User();
    this.user.address = new Address();
    this.user.languageId = 14;
  }

  formSubmit(ngForm: NgForm) {

    // this._auth
    //   .getSid()
    //   .subscribe(sid => {
    //     console.log(sid);
    //     localStorage.setItem('sid', sid);
    this.user.firstname = ngForm.form.controls['firstname'].value;
    this.user.lastname = ngForm.form.controls['lastname'].value;
    this.user.login = ngForm.form.controls['username'].value;
    this.user.address.email = ngForm.form.controls['username'].value;
    this.user.password = ngForm.form.controls['<PASSWORD>'].value;
    this._auth
      .register(this.user)
      .subscribe(res => {

        // console.log("Register Result is: ");
        // console.log(res);
        localStorage.removeItem('sid');
        this._router.navigate(['security']);
      }, err => {
        if (err.status === 401 || err.status === 403) {
          // alert('invalid user ID or password');
          const message = 'ليس مسموحاً لك القيام بهذا';
          const action = 'إغلاق';
          this._snackBar.open(message, action, {
            duration: 2000,
          });
        } else {
          // alert('There is an error occured, please try later.');
          const message = 'حدث خطأ ما، يرجى المحاولة لاحقاً';
          const action = 'إغلاق';
          this._snackBar.open(message, action, {
            duration: 4000,
            horizontalPosition: this.horizontalPosition,
            verticalPosition: this.verticalPosition,
          });
        }
      });

    // }, er => { });

  }

}
<file_sep>/src/app/shared/navbar/navbar.component.ts
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';

@Component({
  selector: 'app-navbar',
  templateUrl: './navbar.component.html',
  styleUrls: ['./navbar.component.sass']
})
export class NavbarComponent implements OnInit {

  username: string;
  isLoggedIn: boolean;
  constructor(private _router: Router) { }

  ngOnInit(): void {


  }

  LoggedIn() {
    this.username = localStorage.getItem('username');
    this.isLoggedIn = !!this.username;
    // console.log("userEmail" + this.userEmail);
    return this.isLoggedIn;
  }

  logout() {
    localStorage.clear();
    // localStorage.removeItem('email');
    // localStorage.removeItem('username');
    // localStorage.removeItem('userId');
    this._router.navigate(['/']);
  }

}
<file_sep>/src/app/rooms/view-rooms/view-rooms.component.ts
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from "@angular/router";
import { RoomService } from "../services/room.service";
import { environment } from "../../../environments/environment.prod";
import {
  MatSnackBar, MatSnackBarHorizontalPosition,
  MatSnackBarVerticalPosition,
} from '@angular/material/snack-bar';

@Component({
  selector: 'app-view-rooms',
  templateUrl: './view-rooms.component.html',
  styleUrls: ['./view-rooms.component.sass']
})
export class ViewRoomsComponent implements OnInit {

  groupId: string;
  rooms: any[];
  horizontalPosition: MatSnackBarHorizontalPosition = 'center';
  verticalPosition: MatSnackBarVerticalPosition = 'bottom';

  constructor(private _route: ActivatedRoute, private _roomService: RoomService, private _snackBar: MatSnackBar) { }

  ngOnInit(): void {
    this.groupId = this._route.snapshot.paramMap.get("id");

    this._roomService
      .get(this.groupId)
      .subscribe(res => {
          this.rooms = res.roomDTO;
          console.log(this.rooms);
      },
        err => {
          if (err.status === 401 || err.status === 403) {
            // alert('invalid user ID or password');
            const message = 'ليس مسموحاً لك القيام بهذا';
            const action = 'إغلاق';
            this._snackBar.open(message, action, {
              duration: 2000,
            });
          } else {
            // alert('There is an error occured, please try later.');
            const message = 'حدث خطأ ما، يرجى المحاولة لاحقاً';
            const action = 'إغلاق';
            this._snackBar.open(message, action, {
              duration: 4000,
              horizontalPosition: this.horizontalPosition,
              verticalPosition: this.verticalPosition,
            });
          }
        });


  }

  enterRoom(roomId) {
    // alert(roomId);

    // get hash
    this._roomService
    .getRoomHash(roomId)
    .subscribe(res => {
      
      // console.log(res);
      // debugger;
      if(res.serviceResult.type === 'SUCCESS') {
        const message = 'تمت العملية بنجاح';
              const action = 'إغلاق';
              this._snackBar.open(message, action, {
                duration: 4000,
                horizontalPosition: this.horizontalPosition,
                verticalPosition: this.verticalPosition,
              });
        const _link = environment.roomLink + res.serviceResult.message;
        window.open(_link, '_blank');
      }
      // got o the link
      
  },
    err => {
      if (err.status === 401 || err.status === 403) {
        // alert('invalid user ID or password');
        const message = 'ليس مسموحاً لك القيام بهذا';
        const action = 'إغلاق';
        this._snackBar.open(message, action, {
          duration: 2000,
        });
      } else {
        // alert('There is an error occured, please try later.');
        const message = 'حدث خطأ ما، يرجى المحاولة لاحقاً';
        const action = 'إغلاق';
        this._snackBar.open(message, action, {
          duration: 4000,
          horizontalPosition: this.horizontalPosition,
          verticalPosition: this.verticalPosition,
        });
      }
    });
    
    
  }


}
<file_sep>/src/app/groups/services/group.service.ts
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { environment } from "../../../environments/environment.prod";
import { Group } from "../../models/group.model";


@Injectable({
  providedIn: 'root'
})
export class GroupService {

  private _Url = environment.secondaryApi + 'Groups/';
  private _OPUrl = environment.apiEndpoint;

  constructor(private _http: HttpClient) { }

  get() {
    return this._http.get<{groupDTO: Group[]}>(this._OPUrl + 'group/');
  }

  getUserGroups(id: number) {
    return this._http.get<{groupDTO: Group[]}>(this._OPUrl + 'user/groups/' + id);
  }

  getOtherGroups(id: number) {
    return this._http.get<Group[]>(this._Url + 'OtherGroups/' + id);
  }

  joinGroup(groupId: number) {
    debugger;
    const userId = localStorage.getItem('userId');
    return this._http.post<any>(this._OPUrl + 'group/' + groupId + '/users/' + userId, null);
  }

}
<file_sep>/src/app/models/invitation.model.ts
export class Invitation {
    id: number;
    deleted: number;
    hash: string;
    password_protected: number;
    invited_by: number;
    invitee_id: number;
    room_id: number;
    recording_id: number;
    valid_from: Date;
    valid_to: Date;
    comment: string;
    name: string;
}
<file_sep>/src/app/home/sections/welcome-section/welcome-section.component.ts
import { Component, OnInit } from '@angular/core';
import { environment } from 'src/environments/environment.prod';
import { Router } from '@angular/router';

@Component({
  selector: 'app-welcome-section',
  templateUrl: './welcome-section.component.html',
  styleUrls: ['./welcome-section.component.sass']
})
export class WelcomeSectionComponent implements OnInit {

  username: string;
  isLoggedIn: boolean;
  calendarUrl: string

  constructor(private _router: Router) { }

  ngOnInit(): void {
    this.calendarUrl = environment.calendar;
  }

  goToCalendar() {
    window.location.href = this.calendarUrl;
  }

  goToGroups() {
    window.location.href = environment.groupsUrl;
  }

  LoggedIn() {
    this.username = localStorage.getItem('username');
    this.isLoggedIn = !!this.username;
    // console.log("userEmail" + this.userEmail);
    return this.isLoggedIn;
  }

}
<file_sep>/src/app/groups/view-groups/view-groups.component.ts
import { Component, OnInit, OnDestroy } from '@angular/core';
import { GroupService } from "../services/group.service";
import { Group } from 'src/app/models/group.model';
import {
  MatSnackBar, MatSnackBarHorizontalPosition,
  MatSnackBarVerticalPosition,
} from '@angular/material/snack-bar';
import { interval } from 'rxjs';


@Component({
  selector: 'app-view-groups',
  templateUrl: './view-groups.component.html',
  styleUrls: ['./view-groups.component.sass']
})
export class ViewGroupsComponent implements OnInit, OnDestroy{

  groups: Group[];
  otherGroups: Group[];
  myGroups: Group[];
  horizontalPosition: MatSnackBarHorizontalPosition = 'center';
  verticalPosition: MatSnackBarVerticalPosition = 'bottom';
  timerInterval:any;

  constructor(private _groupService: GroupService, private _snackBar: MatSnackBar) {

  }

  ngOnInit(): void {
    this.otherGroups = new Array();
    this.groups = new Array();
    this.myGroups = new Array();

    this._groupService
      .get()
      .subscribe(res => {

        this.groups = res.groupDTO.filter((v, i) => {
          v.name !== null;
        });
        console.log("groups:");
        console.log(this.groups);

        this._groupService
          .getUserGroups(+localStorage.getItem('userId'))
          .subscribe(res => {
            console.log("my groups: ");
            console.log(res);

            this.myGroups = res.groupDTO;
            // debugger;
            this.groups.forEach((group, index) => {
                if (group && group.name && !this.found(group)) {
                  this.otherGroups.push(group);
                }
            });
            console.log(this.otherGroups);

          },
            err => {
              if (err.status === 401 || err.status === 403) {
                // alert('invalid user ID or password');
                const message = 'ليس مسموحاً لك القيام بهذا';
                const action = 'إغلاق';
                this._snackBar.open(message, action, {
                  duration: 2000,
                });
              } else {
                // alert('There is an error occured, please try later.');
                const message = 'حدث خطأ ما، يرجى المحاولة لاحقاً';
                const action = 'إغلاق';
                this._snackBar.open(message, action, {
                  duration: 4000,
                  horizontalPosition: this.horizontalPosition,
                  verticalPosition: this.verticalPosition,
                });
              }
            });
      },
        err => {
          if (err.status === 401 || err.status === 403) {
            const message = 'ليس مسموحاً لك القيام بهذا';
            const action = 'إغلاق';
            this._snackBar.open(message, action, {
              duration: 4000,
            });
          } else {
            const message = 'حدث خطأ ما، يرجى المحاولة لاحقاً';
            const action = 'إغلاق';
            this._snackBar.open(message, action, {
              duration: 4000,
              horizontalPosition: this.horizontalPosition,
              verticalPosition: this.verticalPosition,
            });
          }
        });

        this.timerInterval = setInterval(() => {

          this._groupService
          .getUserGroups(+localStorage.getItem('userId'))
          .subscribe(res => {
            console.log("my groups: ");
            console.log(res);

            this.myGroups = res.groupDTO;
            // debugger;
            this.groups.forEach((group, index) => {
                if (group && group.name &&  !this.found(group) ) {
                  this.otherGroups.push(group);
                }
            });
            console.log(this.otherGroups);

          },
            err => {});
        },30000);


        // interval(1000).subscribe(x => {
          
        //   });

    // this._groupService
    //   .getOtherGroups(+localStorage.getItem('userId'))
    //   .subscribe(res => {
    //     this.otherGroups = res;
    //   },
    //     err => {
    //       if (err.status === 401 || err.status === 403) {
    //         alert('please re-login');
    //       } else {
    //         alert('There is an error occured, please try later.');
    //       }
    //     });



  } // end of ngInit




  private found(group: Group): boolean {
    for(let i = 0; i < this.myGroups.length; i++){
      if (group.id === this.myGroups[i].id) {
        return true;
      }
    };
    return false;
  }


  join(groupId) {
    this._groupService
      .joinGroup(groupId)
      .subscribe(res => {
        console.log("join group result is: " + res);
        console.log(res);

        this.myGroups.push(this.otherGroups.filter(value => value.id === groupId)[0]);
        this.otherGroups = this.otherGroups.filter(value => value.id !== groupId);
      }, err => {
        if (err.status === 401 || err.status === 403) {
          // alert('invalid user ID or password');
          const message = 'ليس مسموحاً لك القيام بهذا';
          const action = 'إغلاق';
          this._snackBar.open(message, action, {
            duration: 2000,
          });
        } else {
          // alert('There is an error occured, please try later.');
          const message = 'حدث خطأ ما، يرجى المحاولة لاحقاً';
          const action = 'إغلاق';
          this._snackBar.open(message, action, {
            duration: 4000,
            horizontalPosition: this.horizontalPosition,
            verticalPosition: this.verticalPosition,
          });
        }
      });

  }


  LoggedIn() {
    return !!localStorage.getItem('sid');
  }

  ngOnDestroy(){
    clearInterval(this.timerInterval);
  }

}
<file_sep>/src/environments/environment.prod.ts
export const environment = {
  production: true,
  origin: 'http://vps-22637d08.vps.ovh.us:5080/',
  calendar: 'http://vps-22637d08.vps.ovh.us:5080/openmeetings/#user/calendar',
  groupsUrl: 'http://vps-22637d08.vps.ovh.us:5080/openmeetings/#user/group',
  apiEndpoint: 'http://vps-22637d08.vps.ovh.us:5080/openmeetings/services/',
  secondaryApi: 'http://localhost:7000/',
  wicket: 'http://vps-22637d08.vps.ovh.us:5080/openmeetings/wicket/bookmarkable/',
  roomLink: 'http://vps-22637d08.vps.ovh.us:5080/openmeetings/hash?secure='
};
// http://localhost/<file_sep>/src/app/rooms/group-rooms/group-rooms.component.ts
import { Component, OnInit, Input } from '@angular/core';
import { RoomService } from "../services/room.service";
import { environment } from "../../../environments/environment.prod";
import { Room } from 'src/app/models/room.model';
import { LoginService } from "../../security/services/login-service.service";
import {
  MatSnackBar, MatSnackBarHorizontalPosition,
  MatSnackBarVerticalPosition,
} from '@angular/material/snack-bar';
import { Appointment } from 'src/app/models/appointment.model';
import { Router } from '@angular/router';


@Component({
  selector: 'group-rooms',
  templateUrl: './group-rooms.component.html',
  styleUrls: ['./group-rooms.component.sass']
})
export class GroupRoomsComponent implements OnInit {

  @Input() groupId: number;
  rooms: Room[];
  invit: Appointment[];
  firstTime: boolean;
  horizontalPosition: MatSnackBarHorizontalPosition = 'center';
  verticalPosition: MatSnackBarVerticalPosition = 'bottom';

  constructor(private _roomService: RoomService, private _authService: LoginService, private _snackBar: MatSnackBar, private _router: Router) { }

  ngOnInit(): void {

    this.firstTime = true;

    // this._roomService
    //   .get(this.groupId)
    //   .subscribe(res => {
    //     this.rooms = res.roomDTO;
    //     console.log(this.rooms);
    //   },
    //     err => {
    //       if (err.status === 401 || err.status === 403) {
    //         // alert('invalid user ID or password');
    //         const message = 'ليس مسموحاً لك القيام بهذا';
    //         const action = 'إغلاق';
    //         this._snackBar.open(message, action, {
    //           duration: 2000,
    //         });
    //       } else {
    //         // alert('There is an error occured, please try later.');
    //         const message = 'حدث خطأ ما، يرجى المحاولة لاحقاً';
    //         const action = 'إغلاق';
    //         this._snackBar.open(message, action, {
    //           duration: 4000,
    //           horizontalPosition: this.horizontalPosition,
    //           verticalPosition: this.verticalPosition,
    //         });
    //       }
    //     });

    this._roomService
      .getAppointments(this.groupId)
      .subscribe(res => {
        this.invit = res.appointmentDTO;
        // console.log(this.rooms);
      },
        err => {
          if (err.status === 401 || err.status === 403) {
            // alert('invalid user ID or password');
            const message = 'ليس مسموحاً لك القيام بهذا';
            const action = 'إغلاق';
            this._snackBar.open(message, action, {
              duration: 2000,
            });
          } else {
            // alert('There is an error occured, please try later.');
            const message = 'حدث خطأ ما، يرجى المحاولة لاحقاً';
            const action = 'إغلاق';
            this._snackBar.open(message, action, {
              duration: 4000,
              horizontalPosition: this.horizontalPosition,
              verticalPosition: this.verticalPosition,
            });
          }
        });

  }

  enterRoom(roomId) {

    if (!this.firstTime) {
      const message = 'لا يمكن الدخول ﻷكثر من غرفة بنفس الوقت، يرجى إغلاق الغرفة السابقة وإعادة تسجيل الدخول';
      const action = 'إغلاق';
      this._snackBar.open(message, action, {
        duration: 4000,
        horizontalPosition: this.horizontalPosition,
        verticalPosition: this.verticalPosition,
      });
      setTimeout(() => {
        localStorage.clear();
        this._router.navigate(['/security/login']);
      }, 3000);
      //   // alert("not first time");
      //   localStorage.removeItem('sid');
      //   this._authService
      //     .getSid()
      //     .subscribe(res => {
      //       if (res) {
      //         console.log("sid is: ");
      //         console.log(res);

      //         localStorage.setItem('sid', res);
      //         this.firstTime = false;
      //         // get hash
      //         this.callRoomService(roomId);
      //       }
      //     }, err => { if (err.status === 401 || err.status === 403) {
      //       // alert('invalid user ID or password');
      //       const message = 'ليس مسموحاً لك القيام بهذا';
      //       const action = 'إغلاق';
      //       this._snackBar.open(message, action, {
      //         duration: 2000,
      //       });
      //     } else {
      //       // alert('There is an error occured, please try later.');
      //       const message = 'حدث خطأ ما، يرجى المحاولة لاحقاً';
      //       const action = 'إغلاق';
      //       this._snackBar.open(message, action, {
      //         duration: 4000,
      //         horizontalPosition: this.horizontalPosition,
      //         verticalPosition: this.verticalPosition,
      //       });
      //     }
      //   });
    } else {
      this.firstTime = false;
      // get hash
      this.callRoomService(roomId);
    }



  } // end of enter room function


  callRoomService(roomId) {
    this._roomService
      .getRoomHash(roomId)
      .subscribe(res => {

        // console.log(res);
        // debugger;
        if (res.serviceResult.type === 'SUCCESS') {
          const message = 'تمت العملية بنجاح';
          const action = 'إغلاق';
          this._snackBar.open(message, action, {
            duration: 4000,
            horizontalPosition: this.horizontalPosition,
            verticalPosition: this.verticalPosition,
          });
          localStorage.setItem('roomHash', res.serviceResult.message);
          const _link = environment.roomLink + res.serviceResult.message;
          window.open(_link, '_blank');
        }
        // got o the link

      },
        err => {
          if (err.status === 401 || err.status === 403) {
            // alert('invalid user ID or password');
            const message = 'ليس مسموحاً لك القيام بهذا';
            const action = 'إغلاق';
            this._snackBar.open(message, action, {
              duration: 2000,
            });
          } else {
            // alert('There is an error occured, please try later.');
            // const message = 'حدث خطأ ما، يرجى المحاولة لاحقاً';
            // const action = 'إغلاق';
            // this._snackBar.open(message, action, {
            //   duration: 4000,
            //   horizontalPosition: this.horizontalPosition,
            //   verticalPosition: this.verticalPosition,
            // });
          }
        });
  }


}
<file_sep>/src/app/models/room.model.ts
export class Room {
    room_id: number;
    id:number;
    name: string;
    group_id: number;
    owner_id: number;
    type: string;
    ismoderatedroom: number;
    allow_recording: number;
    ispublic: number;
    allow_user_questions: number;
    redirect_url: string;
    appointment: number;
    capacity: number;
    chat_moderated: number;
    chat_opened: number;
    comment: string;
    confno: any;
    demo_room: number;
    deleted: number;
    demo_time: any;
    external_id: number;
    external_type: number;
    files_opened: number;
    wait_for_recording: number;
}
<file_sep>/src/app/user-profile/user-profile.component.ts
import { Component, OnInit } from '@angular/core';
import { NgForm } from '@angular/forms';
import { MatSnackBar, MatSnackBarHorizontalPosition, MatSnackBarVerticalPosition } from '@angular/material/snack-bar';
import { Address, User } from '../models/user.model';
import { LoginService } from "../security/services/login-service.service";

@Component({
  selector: 'app-user-profile',
  templateUrl: './user-profile.component.html',
  styleUrls: ['./user-profile.component.sass']
})
export class UserProfileComponent implements OnInit {

  user: User;
  horizontalPosition: MatSnackBarHorizontalPosition = 'center';
  verticalPosition: MatSnackBarVerticalPosition = 'bottom';

  constructor(private _auth: LoginService, private _snackBar: MatSnackBar) { }

  ngOnInit(): void {
    this.user = new User();
    this.user.address = new Address();
    this._auth
      .getUserInfo(localStorage.getItem('userId'))
      .subscribe(userInfo => {
        // console.log(userInfo);
        this.user = userInfo.userDTO;
      },
        err => {
          const message = 'حدث خطأ ما، يرجى المحاولة لاحقاً';
          const action = 'إغلاق';
          this._snackBar.open(message, action, {
            duration: 4000,
            horizontalPosition: this.horizontalPosition,
            verticalPosition: this.verticalPosition,
          });
        });
  }


  formSubmit(ngForm: NgForm) {
    let firstname = ngForm.form.controls['firstname'].value;
    let lastname = ngForm.form.controls['lastname'].value;
    let login = ngForm.form.controls['username'].value;
    let email = ngForm.form.controls['username'].value;

    this.user.firstname = (!!firstname || firstname !== '')? firstname : this.user.firstname;
    this.user.lastname = (!!lastname || lastname !== '')? lastname : this.user.lastname;
    this.user.login = (!!email || email !== '')? email : this.user.login;
    this.user.address.email = (!!email || email !== '')? email : this.user.address.email;
    
    this._auth
      .updateProfile(this.user)
      .subscribe(res => {
          this._snackBar.open('تم تحديث البيانات بنجاح، سيتم تطبيق التغييرات في تسجيل الدخول التالي', 'إغلاق', {
            duration: 4000,
            horizontalPosition: this.horizontalPosition,
            verticalPosition: this.verticalPosition,
          });
      }, err => {
        if (err.status === 401 || err.status === 403) {
          const message = 'ليس مسموحاً لك القيام بهذا';
          const action = 'إغلاق';
          this._snackBar.open(message, action, {
            duration: 4000,
            horizontalPosition: this.horizontalPosition,
            verticalPosition: this.verticalPosition,
          });
        } else {
          const message = 'حدث خطأ ما، يرجى المحاولة لاحقاً';
          const action = 'إغلاق';
          this._snackBar.open(message, action, {
            duration: 4000,
            horizontalPosition: this.horizontalPosition,
            verticalPosition: this.verticalPosition,
          });
        }
      });
  }

  form1Submit(ngForm1: NgForm) {
    let password = ngForm1.form.controls['password'].value;
    debugger;
    this._auth
      .changePass(password)
      .subscribe(res => {
        if (res.serviceResult.type === "SUCCESS") {
          this._snackBar.open('تم تغيير كلمة السر', 'إغلاق', {
            duration: 4000,
            horizontalPosition: this.horizontalPosition,
            verticalPosition: this.verticalPosition,
          });
        } else if (res.serviceResult.type === "ERROR") {
          this._snackBar.open('ليس لديك الصلاحية لتغيير كلمة السر لك أو لشخص آخر', 'إغلاق', {
            duration: 4000,
            horizontalPosition: this.horizontalPosition,
            verticalPosition: this.verticalPosition,
          });
        }
      }, err => {
        if (err.status === 401 || err.status === 403) {
          const message = 'ليس مسموحاً لك القيام بهذا';
          const action = 'إغلاق';
          this._snackBar.open(message, action, {
            duration: 4000,
            horizontalPosition: this.horizontalPosition,
            verticalPosition: this.verticalPosition,
          });
        } else {
          const message = 'حدث خطأ ما، يرجى المحاولة لاحقاً';
          const action = 'إغلاق';
          this._snackBar.open(message, action, {
            duration: 4000,
            horizontalPosition: this.horizontalPosition,
            verticalPosition: this.verticalPosition,
          });
        }
      });
  }

}
<file_sep>/src/app/home/sections/aboutus/aboutus.component.ts
import { Component, OnInit } from '@angular/core';
// import {AgmMarker, AgmMap} from '@agm/core';
import { FormGroup } from '@angular/forms';
import { HomeService } from "../../home.service";
import { MatSnackBar, MatSnackBarHorizontalPosition, MatSnackBarVerticalPosition } from '@angular/material/snack-bar';
// import '../../../../assets/smtp.js';
// declare let Email: any;

@Component({
  selector: 'app-aboutus',
  templateUrl: './aboutus.component.html',
  styles:[`
  agm-map {
    height: 300px;
  }
`],
  styleUrls: ['./aboutus.component.sass']
})
export class AboutusComponent implements OnInit {


  lat = 31.9539;
  lng = 35.9106;

  complain: string;
  suggestion: string;
  mail: string;
  notice: string;

  horizontalPosition: MatSnackBarHorizontalPosition = 'center';
  verticalPosition: MatSnackBarVerticalPosition = 'bottom';


  constructor(private _homeService: HomeService, private _snackBar: MatSnackBar) { }

  ngOnInit(): void {
  }

  formSubmit(form: FormGroup) {
    // const mail = {
    //     Host : 'smtp.ethereal.email',
    //     Username : '<EMAIL>',
    //     port: 587,
    //     Password : '<PASSWORD>',
    //     To : '<EMAIL>',
    //     From : '<EMAIL>',
    //     Subject : 'subject',
    //     Body : `
    //     <i>This is sent as a feedback from my resume page.</i> <br/> <b>Name: </b> <br /> <b>Email: </b><br /> <b>Subject: 
    //     </b><br /> <b>Message:</b> <br /> <br><br> <b>~End of Message.~</b> `,
    //     Action:"Send"
    //     };
    const subject = "Complain From Contact us in Edu Room AXESS!";
    const content = " a Complain: " + this.complain + " a suggestion: " + this.suggestion + " notice: " + this.notice;
    this._homeService
      .sendMail(subject, content, this.mail)
      .subscribe(res => {
        this._snackBar.open('تم الإرسال بنجاح', 'إغلاق', {
          duration: 4000,
          horizontalPosition: this.horizontalPosition,
          verticalPosition: this.verticalPosition,
        });
    }, err => {
        const message = 'حدث خطأ ما، يرجى المحاولة لاحقاً';
        const action = 'إغلاق';
        this._snackBar.open(message, action, {
          duration: 4000,
          horizontalPosition: this.horizontalPosition,
          verticalPosition: this.verticalPosition,
        });
    });


  }

}
<file_sep>/src/app/security/login/login.component.ts
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { LoginService } from '../services/login-service.service';
import { User } from 'src/app/models/user.model';
import { FormGroup } from '@angular/forms';
import { MatSnackBar,MatSnackBarHorizontalPosition,
  MatSnackBarVerticalPosition, } from '@angular/material/snack-bar';


@Component({
  selector: 'app-login',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.sass']
})
export class LoginComponent implements OnInit {

  user: User;
    horizontalPosition: MatSnackBarHorizontalPosition = 'center';
    verticalPosition: MatSnackBarVerticalPosition = 'bottom';

  constructor(private _auth: LoginService, private _router: Router, private _snackBar: MatSnackBar) { }

  ngOnInit(): void {
    // if (this._auth.loggedIn()) {
    //   this._router.navigate(['home']);
    // }
  }

  forgotPass(form: FormGroup) {
    this._auth
      .forgotPass(form.value.username)
      .subscribe(res => {
        if (res.serviceResult.type === "SUCCESS") {
          this._snackBar.open('تم تغيير كلمة السر بنجاح، كلمة السر الجديدة في بريدك الإلكتروني', 'إغلاق', {
            duration: 2000,
          });
        } else if (res.serviceResult.type === "ERROR") {
          this._snackBar.open('البريد الإلكتروني خاطئ', 'إغلاق', {
            duration: 2000,
          });
        }
      },
        err => {
          if (err.status === 401 || err.status === 403) {
            // alert('invalid user ID or password');
            const message = 'ليس مسموحاً لك القيام بهذا';
            const action = 'إغلاق';
            this._snackBar.open(message, action, {
              duration: 2000,
            });
          } else {
            // alert('There is an error occured, please try later.');
            const message = 'حدث خطأ ما، يرجى المحاولة لاحقاً';
            const action = 'إغلاق';
            this._snackBar.open(message, action, {
              duration: 4000,
              horizontalPosition: this.horizontalPosition,
              verticalPosition: this.verticalPosition,
            });
          }
        });
  }


  formSubmit(form: FormGroup) {
    // console.log("password is: " + form.value.password);
    this._auth
      .login(form.value.username, form.value.password)
      .subscribe(res => {
        // console.log(res);
        if (res.serviceResult.type === "SUCCESS") {
          let result = JSON.parse(res.serviceResult.message);
          // console.log(result);
          
          localStorage.setItem('sid', result.sid);
          localStorage.setItem('userId', result.user_id);
          localStorage.setItem('email', form.value.username);
          // localStorage.setItem('pass', <PASSWORD>);

          this._auth
            .getUserInfo(result.user_id)
            .subscribe(userInfo => {
              // console.log(userInfo);
              this.user = userInfo.userDTO;
              localStorage.setItem('username', this.user.firstname + ' ' + this.user.lastname);
              localStorage.setItem('firstname', this.user.firstname);
              localStorage.setItem('lastname', this.user.lastname);
              localStorage.setItem('login', this.user.login);
              this._router.navigate(['/groups']);
            },
              err => {

              });
        } else if (res.serviceResult.type === "ERROR") {
          // alert an ERROR
          // alert("Bad Credintials");
          this._snackBar.open('كلمة السر أو اسم المستخدم خاطئ', 'إغلاق', {
            duration: 2000,
          });
        }
        // this._auth
        //   .loginToWicket('ibra', form.value.password)
        //   .subscribe(result => {
        //     console.log("the result is: ");

        //     console.log(result);
        //   }, e => {
        //     console.log("the error is: ");

        //     console.log(e)
        //   });


      },
        err => {
          if (err.status === 401 || err.status === 403) {
            // alert('invalid user ID or password');
            const message = 'ليس مسموحاً لك القيام بهذا';
            const action = 'إغلاق';
            this._snackBar.open(message, action, {
              duration: 2000,
            });
          } else {
            // alert('There is an error occured, please try later.');
            const message = 'حدث خطأ ما، يرجى المحاولة لاحقاً';
            const action = 'إغلاق';
            this._snackBar.open(message, action, {
              duration: 4000,
              horizontalPosition: this.horizontalPosition,
              verticalPosition: this.verticalPosition,
            });
          }
        });
  }


}
<file_sep>/src/app/groups/groups.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
// import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
// import { InterceptorInterceptor } from "../interceptor.interceptor";

import { GroupsRoutingModule } from './groups-routing.module';
import { ViewGroupsComponent } from './view-groups/view-groups.component';
import { SharedModule } from "../shared/shared.module";
import { RoomsModule } from "../rooms/rooms.module";
import {  MatSnackBarModule } from "@angular/material/snack-bar";
import { MatTabsModule } from "@angular/material/tabs";


@NgModule({
  declarations: [ViewGroupsComponent],
  imports: [
    CommonModule,
    GroupsRoutingModule,
    SharedModule,
    RoomsModule,
    MatSnackBarModule,
    MatTabsModule
  ],
  // providers: [{
  //   provide: HTTP_INTERCEPTORS,
  //   useClass: InterceptorInterceptor,
  //   multi: true
  // }]
})
export class GroupsModule { }
<file_sep>/src/app/home/sections/services-section/services-section.component.ts
import { Component, OnInit } from '@angular/core';
import { faChevronCircleLeft, faChevronCircleRight } from '@fortawesome/free-solid-svg-icons';

@Component({
  selector: 'app-services-section',
  templateUrl: './services-section.component.html',
  styleUrls: ['./services-section.component.sass']
})
export class ServicesSectionComponent implements OnInit {

  faChevronCircleLeft = faChevronCircleLeft;
  faChevronCircleRight = faChevronCircleRight;

  constructor() { }

  ngOnInit(): void {
  }

}
<file_sep>/src/app/services/base-service.service.ts
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { environment } from "../../environments/environment";

@Injectable({
  providedIn: 'root'
})
export class BaseService {

  private _apiUrl = environment.apiEndpoint;

  constructor(private _http: HttpClient) { }

  get() {
    return this._http.get<any>(this._apiUrl);
  }

  getById(id) {
    return this._http.get<any>(this._apiUrl + id);
  }

  add(data) {
    return this._http.post<any>(this._apiUrl, data);
  }

  deleteProgram(id) {
    return this._http.delete<any>(this._apiUrl + id);
  }

  update(data, id) {
    return this._http.put<any>(this._apiUrl + id, data);
  }

}
<file_sep>/src/app/security/security.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { HttpClientModule } from '@angular/common/http';
import { SharedModule } from '../shared/shared.module';
import { FormsModule } from '@angular/forms';

import { SecurityRoutingModule } from './security-routing.module';
import { LoginComponent } from './login/login.component';
import { RegisterComponent } from './register/register.component';
import { MatPasswordStrengthModule } from '@angular-material-extensions/password-strength';
import { MatFormFieldModule } from "@angular/material/form-field";
import {  MatSnackBarModule } from "@angular/material/snack-bar";


@NgModule({
  declarations: [LoginComponent, RegisterComponent],
  imports: [
    CommonModule,
    HttpClientModule,
    FormsModule,
    SecurityRoutingModule,
    SharedModule,
    MatPasswordStrengthModule,
    MatFormFieldModule,
    MatSnackBarModule
  ],
  exports: []
})
export class SecurityModule { }
<file_sep>/src/app/security/services/login-service.service.ts
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { User } from "../../models/user.model";
import { environment } from '../../../environments/environment.prod';
import { Router } from '@angular/router';

@Injectable({
  providedIn: 'root'
})
export class LoginService {

  private _loginUrl = environment.apiEndpoint + 'user/login';
  private _userURL = environment.apiEndpoint + 'user';
  private _wicketLogin = environment.wicket + 'org.apache.openmeetings.web.pages.auth.SignInPage?0-1.2-signin';


  constructor(private _http: HttpClient, private _router: Router) { }

  login(username: string, password: string) {
    // console.log("from service pass is: " + password);
    return this._http.get<any>(this._loginUrl + '?user=' + encodeURIComponent(username) + '&pass=' + encodeURIComponent(password));
  }

  changePass(password: string) {
    // debugger;
    const id = localStorage.getItem('userId');
    if (this.loggedIn && !!id) {
      
      return this._http.post<any>(this._userURL + '/changepass?id=' + id + '&pass=' + password, null);
    } else {
      this._router.navigate(['/security/login']);
    }

  }

  forgotPass(mail: string) {
    return this._http.get<any>(this._userURL + '/forgot?email=' + mail);
  }

  loginToWicket(username: string, password: string) {
    //login=USERNAME&pass=<PASSWORD>
    const header = new HttpHeaders({
      'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
      'Wicket-Ajax': 'true',
      'Wicket-Ajax-BaseURL': 'signin',
      'Wicket-FocusedElementId': 'btnc5',
      'X-Requested-With': 'XMLHttpRequest'
    });

    let form = new URLSearchParams();
    form.append('login', username);
    form.append('pass', password);

    return this._http.post<any>(this._wicketLogin, form.toString(), { headers: header });
  }

  updateProfile(user: User) {
    const header = new HttpHeaders({
      'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
    });

    let form = new URLSearchParams();
    form.append('user', JSON.stringify(user));
    const id = localStorage.getItem('userId');

    return this._http.post<any>(this._userURL + '/' + id, form.toString(), { headers: header });
  }

  register(user: User) {
    const header = new HttpHeaders({
      'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
    });

    let form = new URLSearchParams();
    form.append('user', JSON.stringify(user));
    form.append('confirm', 'false');

    return this._http.post<any>(this._userURL + '/register', form.toString(), { headers: header });
  }

  loggedIn() {
    return !!localStorage.getItem('sid');
  }

  getUserName() {
    return localStorage.getItem('email');
  }

  getUserInfo(id: string) {
    // return this._http.get<{"userDTO": User}>(this._userURL + '/' + id);
    return this._http.get<any>(this._userURL + '/' + id);
  }

  // getSid() {
  //   return this._http.get<string>(environment.secondaryApi + 'GetSid');
  // }

}
<file_sep>/src/app/models/invitation.model.spec.ts
import { Invitation } from './invitation.model';

describe('Invitation', () => {
  it('should create an instance', () => {
    expect(new Invitation()).toBeTruthy();
  });
});
