From a7dc06e81285431d1eafa8f46a842ed746588d83 Mon Sep 17 00:00:00 2001 From: Boris Voropaev Date: Tue, 12 Dec 2023 09:25:36 +0300 Subject: [PATCH] modal login --- .../auth/auth-modal/auth-modal.component.html | 19 ++++++++++++++ .../auth/auth-modal/auth-modal.component.scss | 0 .../auth-modal/auth-modal.component.spec.ts | 23 +++++++++++++++++ .../auth/auth-modal/auth-modal.component.ts | 25 +++++++++++++++++++ src/app/_modules/auth/auth.module.ts | 11 ++++++-- .../auth-form-password-forget.component.html | 3 +-- .../auth-form-password-forget.component.ts | 7 ++++++ .../login/auth-form-login.component.html | 5 ++-- .../forms/login/auth-form-login.component.ts | 14 +++++++++++ .../_modules/auth/page/auth-page.component.ts | 5 +--- .../layout/footer/footer.component.ts | 1 - .../user-bar/header-user-bar.component.ts | 2 -- src/app/_services/authentication.service.ts | 6 +++-- src/environments/environment.ts | 2 +- src/environments/vniigaz-v2.env.dev.ts | 2 +- .../layout/footer/footer.component.html | 2 +- .../layout/footer/footer.component.ts | 14 +++++------ src/vniigaz-v2/css/_basics.scss | 4 +++ 18 files changed, 119 insertions(+), 26 deletions(-) create mode 100644 src/app/_modules/auth/auth-modal/auth-modal.component.html create mode 100644 src/app/_modules/auth/auth-modal/auth-modal.component.scss create mode 100644 src/app/_modules/auth/auth-modal/auth-modal.component.spec.ts create mode 100644 src/app/_modules/auth/auth-modal/auth-modal.component.ts diff --git a/src/app/_modules/auth/auth-modal/auth-modal.component.html b/src/app/_modules/auth/auth-modal/auth-modal.component.html new file mode 100644 index 0000000..5ceb3c0 --- /dev/null +++ b/src/app/_modules/auth/auth-modal/auth-modal.component.html @@ -0,0 +1,19 @@ + +
+

Вход в систему

+

Восстановление пароля

+
+
+ +
+
+ + + + +

{{url}} is undefined

+
+
+
+
+ diff --git a/src/app/_modules/auth/auth-modal/auth-modal.component.scss b/src/app/_modules/auth/auth-modal/auth-modal.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/_modules/auth/auth-modal/auth-modal.component.spec.ts b/src/app/_modules/auth/auth-modal/auth-modal.component.spec.ts new file mode 100644 index 0000000..0ad439c --- /dev/null +++ b/src/app/_modules/auth/auth-modal/auth-modal.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AuthModalComponent } from './auth-modal.component'; + +describe('AuthModalComponent', () => { + let component: AuthModalComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ AuthModalComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(AuthModalComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/_modules/auth/auth-modal/auth-modal.component.ts b/src/app/_modules/auth/auth-modal/auth-modal.component.ts new file mode 100644 index 0000000..fdd60dd --- /dev/null +++ b/src/app/_modules/auth/auth-modal/auth-modal.component.ts @@ -0,0 +1,25 @@ +import { Component } from '@angular/core'; +import {Router} from "@angular/router"; + +@Component({ + selector: 'auth-modal', + templateUrl: './auth-modal.component.html', + styleUrls: ['./auth-modal.component.scss'] +}) +export class AuthModalComponent { + constructor(private router: Router) { + } + + get url() { + let str = this.router.url + return str.substring( + str.indexOf(':') + 1, + str.lastIndexOf(')') + ); + } + + close() { + console.log('CLS') + this.router.navigate([{outlets: {auth: null}}]).then(); + } +} diff --git a/src/app/_modules/auth/auth.module.ts b/src/app/_modules/auth/auth.module.ts index ed5eab6..052f32a 100644 --- a/src/app/_modules/auth/auth.module.ts +++ b/src/app/_modules/auth/auth.module.ts @@ -9,11 +9,15 @@ import {AuthFormPasswordResetComponent} from "@app/_modules/auth/forms/reset/aut import {AuthFormSignupComponent} from "@app/_modules/auth/forms/signup/auth-form-signup.component"; import {AuthPageComponent} from "@app/_modules/auth/page/auth-page.component"; import {NotAuthGuard} from "@app/_helpers/not-auth.guard"; +import { AuthModalComponent } from './auth-modal/auth-modal.component'; +import { WidjetModule } from '../widjet/widjet.module'; const routes = [ {path: 'login', component: AuthPageComponent, canActivate: [NotAuthGuard]}, + {path: 'login', component: AuthModalComponent, canActivate: [NotAuthGuard], outlet: 'auth'}, {path: 'signup', component: AuthPageComponent, canActivate: [NotAuthGuard]}, - {path: 'password/forget', component: AuthPageComponent, canActivate: [NotAuthGuard]}, + {path: 'signup', component: AuthModalComponent, canActivate: [NotAuthGuard], outlet: 'auth'}, + {path: 'password/forget', component: AuthModalComponent, canActivate: [NotAuthGuard], outlet: 'auth'}, {path: 'password/reset/:token/:email', component: AuthPageComponent, canActivate: [NotAuthGuard]} ]; @@ -23,17 +27,20 @@ const routes = [ FormsModule, ReactiveFormsModule, CommonModule, + WidjetModule, RouterModule.forRoot(routes) ], exports: [ ], declarations: [ + AuthModalComponent, AuthPageComponent, AuthFormLoginComponent, AuthFormSignupComponent, AuthFormPasswordForgetComponent, - AuthFormPasswordResetComponent + AuthFormPasswordResetComponent, + AuthModalComponent ], }) export class AuthModule {} diff --git a/src/app/_modules/auth/forms/forget/auth-form-password-forget.component.html b/src/app/_modules/auth/forms/forget/auth-form-password-forget.component.html index cac3db7..94a514d 100644 --- a/src/app/_modules/auth/forms/forget/auth-form-password-forget.component.html +++ b/src/app/_modules/auth/forms/forget/auth-form-password-forget.component.html @@ -1,4 +1,3 @@ -

Восстановление пароля

@@ -8,7 +7,7 @@
{{error}}
Если указанный адрес зарегистрирован, то на него будет выслан новый пароль
- +
diff --git a/src/app/_modules/auth/forms/forget/auth-form-password-forget.component.ts b/src/app/_modules/auth/forms/forget/auth-form-password-forget.component.ts index 0354137..fddffcc 100644 --- a/src/app/_modules/auth/forms/forget/auth-form-password-forget.component.ts +++ b/src/app/_modules/auth/forms/forget/auth-form-password-forget.component.ts @@ -47,4 +47,11 @@ export class AuthFormPasswordForgetComponent implements OnInit { let trans = {'The given data was invalid.': 'Указанный адрес почты не найден'}; this.error = trans[error] || error; } + + login(){ + this.router.navigate( + [ {outlets: {auth: 'login'}}], + {skipLocationChange: true} + ).then(); + } } diff --git a/src/app/_modules/auth/forms/login/auth-form-login.component.html b/src/app/_modules/auth/forms/login/auth-form-login.component.html index c1ed254..a1e3929 100644 --- a/src/app/_modules/auth/forms/login/auth-form-login.component.html +++ b/src/app/_modules/auth/forms/login/auth-form-login.component.html @@ -1,5 +1,5 @@ 
-

Вход в систему

+
@@ -14,7 +14,8 @@
- Забыли пароль? + Забыли пароль? + Регистрация
diff --git a/src/app/_modules/auth/forms/login/auth-form-login.component.ts b/src/app/_modules/auth/forms/login/auth-form-login.component.ts index 9fed5d6..d9c8259 100644 --- a/src/app/_modules/auth/forms/login/auth-form-login.component.ts +++ b/src/app/_modules/auth/forms/login/auth-form-login.component.ts @@ -49,4 +49,18 @@ export class AuthFormLoginComponent implements OnInit { let trans = {'The user credentials were incorrect.': 'Имя пользователя или пароль указаны неверно.'}; this.error = trans[error] || error; } + + forget(){ + this.router.navigate( + [ {outlets: {auth: 'password/forget'}}], + {skipLocationChange: true} + ).then(); + } + + signup(){ + this.router.navigate( + [ {outlets: {auth: 'signup'}}], + {skipLocationChange: true} + ).then(); + } } diff --git a/src/app/_modules/auth/page/auth-page.component.ts b/src/app/_modules/auth/page/auth-page.component.ts index 76ca9d4..c85456d 100644 --- a/src/app/_modules/auth/page/auth-page.component.ts +++ b/src/app/_modules/auth/page/auth-page.component.ts @@ -6,7 +6,7 @@ import {Router} from "@angular/router"; templateUrl: 'auth-page.component.html', styleUrls: ['auth-page.component.scss'] }) -export class AuthPageComponent implements OnInit { +export class AuthPageComponent { constructor(private router: Router) { } @@ -14,8 +14,5 @@ export class AuthPageComponent implements OnInit { return this.router.url.split('?')[0].split('(')[0].split('/').slice(1, 3).join('/'); } - ngOnInit() { - } - } diff --git a/src/app/_modules/layout/footer/footer.component.ts b/src/app/_modules/layout/footer/footer.component.ts index 61a6cad..2d5fadf 100644 --- a/src/app/_modules/layout/footer/footer.component.ts +++ b/src/app/_modules/layout/footer/footer.component.ts @@ -1,6 +1,5 @@ import {Component} from '@angular/core'; import {AuthenticationService} from "@app/_services"; -import {Subscription} from "rxjs"; @Component({ selector: 'footer', diff --git a/src/app/_modules/layout/header/user-bar/header-user-bar.component.ts b/src/app/_modules/layout/header/user-bar/header-user-bar.component.ts index 14a1c23..cd4188a 100644 --- a/src/app/_modules/layout/header/user-bar/header-user-bar.component.ts +++ b/src/app/_modules/layout/header/user-bar/header-user-bar.component.ts @@ -1,7 +1,6 @@ import {Component, Input} from '@angular/core'; import {AuthenticationService} from "@app/_services"; import {Router} from "@angular/router"; -import {Subscription} from "rxjs"; import { PagesService } from '@app/_services/pages.service'; @@ -13,7 +12,6 @@ import { PagesService } from '@app/_services/pages.service'; export class HeaderUserBarComponent { public menuItems = []; public ddHidden = true; - subscriptionUser: Subscription; constructor(public authService: AuthenticationService, private router: Router, private pagesService: PagesService) { } diff --git a/src/app/_services/authentication.service.ts b/src/app/_services/authentication.service.ts index 7443c36..904fb54 100644 --- a/src/app/_services/authentication.service.ts +++ b/src/app/_services/authentication.service.ts @@ -88,7 +88,9 @@ export class AuthenticationService { popup(path: any) { - this.router.navigate([path]).then(); - //this.router.navigate([ {outlets: {auth: path}}], {skipLocationChange: true}).then(); + this.router.navigate( + [ {outlets: {auth: path}}], + {skipLocationChange: true} + ).then(); } } diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 7fb86bf..ce30fb1 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -6,7 +6,7 @@ export const environment = { production: false, apiUrl: 'http://api.nircms.lc', clientId: 2, - clientSecret: 'gVk3jjKq6rWWM52025xgXlw2XGW1UACowyMIyhRR', + clientSecret: 'E4BoAclC9X3gre4Wr4XXmU3Y7sXTEtFSk3iCSkIm', project: null, defaultLocale: 'ru' }; diff --git a/src/environments/vniigaz-v2.env.dev.ts b/src/environments/vniigaz-v2.env.dev.ts index 3da4e0e..35abe38 100644 --- a/src/environments/vniigaz-v2.env.dev.ts +++ b/src/environments/vniigaz-v2.env.dev.ts @@ -6,7 +6,7 @@ export const environment = { production: false, apiUrl: 'http://api.nircms.lc', clientId: 2, - clientSecret: 'v49Z7dwUb1cobcTIJ5JQVJBzOFcNyJMzMmiDspUm', + clientSecret: 'E4BoAclC9X3gre4Wr4XXmU3Y7sXTEtFSk3iCSkIm', project: 'vniigaz-v2', defaultLocale: 'ru' }; diff --git a/src/vniigaz-v2/component/layout/footer/footer.component.html b/src/vniigaz-v2/component/layout/footer/footer.component.html index e3e04e2..2225070 100644 --- a/src/vniigaz-v2/component/layout/footer/footer.component.html +++ b/src/vniigaz-v2/component/layout/footer/footer.component.html @@ -2,7 +2,7 @@