From 74f11f0f1bd6ad7a07e18f26981d8b52832b03e5 Mon Sep 17 00:00:00 2001 From: Diamadis Tziotzios Date: Tue, 19 Dec 2017 17:59:34 +0200 Subject: [PATCH] no message --- dmp-frontend/src/app/app-routing.module.ts | 4 +- dmp-frontend/src/app/app.component.ts | 1 - dmp-frontend/src/app/app.module.ts | 6 +- .../googgle-sign-in.component.css | 11 -- .../googgle-sign-in.component.html | 12 --- .../googgle-sign-in.component.ts | 59 ---------- ...in.component.html => login.component.html} | 25 +++-- .../src/app/login/login.component.scss | 101 ++++++++++++++++++ dmp-frontend/src/app/login/login.component.ts | 74 +++++++++++++ .../main-sign-in/main-sign-in.component.css | 101 ------------------ .../main-sign-in/main-sign-in.component.ts | 56 ---------- .../snack-bar-notification.component.html | 13 +-- dmp-frontend/src/assets/custom.css | 0 dmp-frontend/src/assets/custom.js | 69 ------------ dmp-frontend/src/index.html | 4 +- 15 files changed, 195 insertions(+), 341 deletions(-) delete mode 100644 dmp-frontend/src/app/login/googgle-sign-in/googgle-sign-in.component.css delete mode 100644 dmp-frontend/src/app/login/googgle-sign-in/googgle-sign-in.component.html delete mode 100644 dmp-frontend/src/app/login/googgle-sign-in/googgle-sign-in.component.ts rename dmp-frontend/src/app/login/{main-sign-in/main-sign-in.component.html => login.component.html} (60%) create mode 100644 dmp-frontend/src/app/login/login.component.scss create mode 100644 dmp-frontend/src/app/login/login.component.ts delete mode 100644 dmp-frontend/src/app/login/main-sign-in/main-sign-in.component.css delete mode 100644 dmp-frontend/src/app/login/main-sign-in/main-sign-in.component.ts delete mode 100644 dmp-frontend/src/assets/custom.css delete mode 100644 dmp-frontend/src/assets/custom.js diff --git a/dmp-frontend/src/app/app-routing.module.ts b/dmp-frontend/src/app/app-routing.module.ts index ce736dd8d..c50fd0319 100644 --- a/dmp-frontend/src/app/app-routing.module.ts +++ b/dmp-frontend/src/app/app-routing.module.ts @@ -6,7 +6,6 @@ import { HomepageComponent } from './homepage/homepage.component'; import { DynamicFormComponent } from './form/dynamic-form.component'; import { AuthGuard } from './guards/auth.guard'; import { AppComponent } from './app.component'; -import { MainSignInComponent } from './login/main-sign-in/main-sign-in.component'; import { DmpDetailedComponent } from './viewers/dmp-detailed/dmp-detailed.component'; import { ProjectDetailedComponent } from './viewers/project-detailed/project-detailed.component'; import { ProjectListingModel } from './models/projects/ProjectListingModel'; @@ -15,6 +14,7 @@ import { DataManagementPlanListingComponent } from './dmps/dmp-listing.component import { ProjectEditorComponent } from './projects/editor/project-editor.component'; import { DataManagementPlanEditorComponent } from './dmps/editor/dmp-editor.component'; import { DataManagementPlanWizardComponent } from './dmp-wizard/dmp-wizard.component'; +import { LoginComponent } from './login/login.component'; const appRoutes: Routes = [ @@ -28,7 +28,7 @@ const appRoutes: Routes = [ { path: 'dmp/:id', component: DataManagementPlanEditorComponent, canActivate: [AuthGuard]}, { path: 'dmps/new', component: DataManagementPlanEditorComponent, canActivate: [AuthGuard]}, - { path: 'login', component: MainSignInComponent}, + { path: 'login', component: LoginComponent}, { path: "unauthorized", loadChildren: './unauthorized/unauthorized.module#UnauthorizedModule' }, { path: 'welcome', component: HomepageComponent, canActivate: [AuthGuard]}, { path: '', redirectTo: '/welcome', pathMatch: 'full' }, diff --git a/dmp-frontend/src/app/app.component.ts b/dmp-frontend/src/app/app.component.ts index 7d31d5dff..1c859401f 100644 --- a/dmp-frontend/src/app/app.component.ts +++ b/dmp-frontend/src/app/app.component.ts @@ -2,7 +2,6 @@ import { Component, OnInit, ViewEncapsulation} from '@angular/core'; import { ServerService } from './services/server.service'; import { JsonObjest } from '../app/entities/JsonObject.class'; import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, ActivatedRoute, NavigationExtras } from '@angular/router'; -import { MainSignInComponent } from './login/main-sign-in/main-sign-in.component'; import {BreadcrumbModule,MenuItem} from 'primeng/primeng'; import { BreadcrumbComponent } from './widgets/breadcrumb/breadcrumb.component'; diff --git a/dmp-frontend/src/app/app.module.ts b/dmp-frontend/src/app/app.module.ts index 59972db5a..87353a0bd 100644 --- a/dmp-frontend/src/app/app.module.ts +++ b/dmp-frontend/src/app/app.module.ts @@ -55,8 +55,6 @@ import { PDFService } from './services/transformers/pdf.service'; import { TabModule } from './tabs/tab.module'; import { AngularDraggableModule } from 'angular2-draggable'; -import { GooggleSignInComponent } from './login/googgle-sign-in/googgle-sign-in.component'; -import { MainSignInComponent } from './login/main-sign-in/main-sign-in.component'; import { NguiAutoCompleteModule } from '@ngui/auto-complete'; import { HTTP_INTERCEPTORS } from '@angular/common/http'; @@ -110,6 +108,7 @@ import { DataManagementPlanEditorComponent } from './dmps/editor/dmp-editor.comp import { FigurecardComponent } from './shared/components/figurecard/figurecard.component'; import { DataManagementPlanWizardComponent } from './dmp-wizard/dmp-wizard.component'; +import { LoginComponent } from './login/login.component'; @@ -126,8 +125,7 @@ import { DataManagementPlanWizardComponent } from './dmp-wizard/dmp-wizard.compo TableOfContentsFieldSetComponent, TableOfContentsGroupComponent, TableOfContentsSectionComponent, - GooggleSignInComponent, - MainSignInComponent, + LoginComponent, PageNotFoundComponent, HomepageComponent, ModalComponent, diff --git a/dmp-frontend/src/app/login/googgle-sign-in/googgle-sign-in.component.css b/dmp-frontend/src/app/login/googgle-sign-in/googgle-sign-in.component.css deleted file mode 100644 index 7ecba8a01..000000000 --- a/dmp-frontend/src/app/login/googgle-sign-in/googgle-sign-in.component.css +++ /dev/null @@ -1,11 +0,0 @@ -.nomargin{ - margin-top: 0px; - margin-bottom: 0px; - margin-left: 0px; - margin-right: 0px; -} - -.width-range { - max-width: 500px; - min-width: 300px; -} \ No newline at end of file diff --git a/dmp-frontend/src/app/login/googgle-sign-in/googgle-sign-in.component.html b/dmp-frontend/src/app/login/googgle-sign-in/googgle-sign-in.component.html deleted file mode 100644 index 057adc356..000000000 --- a/dmp-frontend/src/app/login/googgle-sign-in/googgle-sign-in.component.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - -
- - - - diff --git a/dmp-frontend/src/app/login/googgle-sign-in/googgle-sign-in.component.ts b/dmp-frontend/src/app/login/googgle-sign-in/googgle-sign-in.component.ts deleted file mode 100644 index 726cbd863..000000000 --- a/dmp-frontend/src/app/login/googgle-sign-in/googgle-sign-in.component.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { AuthService } from '../../services/auth/auth.service'; -import { HttpClient } from '@angular/common/http'; -import { Component, OnInit, ElementRef, AfterViewInit, VERSION, Injectable } from '@angular/core'; -import { Router, ActivatedRoute, Params } from "@angular/router"; -import { SnackBarNotificationComponent } from "../../shared/components/notificaiton/snack-bar-notification.component"; -import { MatPaginator, MatSort, MatSnackBar } from "@angular/material"; -import { TranslateService } from "@ngx-translate/core"; - -declare const gapi: any; - -declare const auth2 :any; - -declare function simple_notifier(type: string, title: string, message:string): any; - -@Component({ - selector: 'googgle-sign-in', - templateUrl: './googgle-sign-in.component.html', - styleUrls: ['./googgle-sign-in.component.css'] -}) -export class GooggleSignInComponent implements OnInit, Injectable { - - - constructor(private element: ElementRef, private router : Router,private authService:AuthService,private route:ActivatedRoute, - public snackBar: MatSnackBar,public language: TranslateService - ) { } - - - ngOnInit() { - this.initiateExternalProviders(); - } - - initiateExternalProviders(){ - - - - // if(gapi.auth2 == undefined){ - - // gapi.load('auth2', () => { - - // this.auth2 = gapi.auth2.getAuthInstance({ - // client_id: clientId, - // }) - // }); - - // }else{ - // this.auth2=gapi.auth2.getAuthInstance({ - // client_id: clientId, - // })} - - } - - - - - - -} - - diff --git a/dmp-frontend/src/app/login/main-sign-in/main-sign-in.component.html b/dmp-frontend/src/app/login/login.component.html similarity index 60% rename from dmp-frontend/src/app/login/main-sign-in/main-sign-in.component.html rename to dmp-frontend/src/app/login/login.component.html index 5e930fc8b..a346bbd81 100644 --- a/dmp-frontend/src/app/login/main-sign-in/main-sign-in.component.html +++ b/dmp-frontend/src/app/login/login.component.html @@ -1,23 +1,26 @@
-
-
+
+

Login

Or Be Classical

-
- face - - - -
email diff --git a/dmp-frontend/src/app/login/login.component.scss b/dmp-frontend/src/app/login/login.component.scss new file mode 100644 index 000000000..ae9fd9e11 --- /dev/null +++ b/dmp-frontend/src/app/login/login.component.scss @@ -0,0 +1,101 @@ +.container{ + height: 100%; + position: relative; + z-index: 1; +} + +.card{ + position: relative; + padding: 20px; + display: flex; + flex-direction: column; + align-items: center; + margin-top: 90px; + top: -90px; + -webkit-animation-name: card; + -moz-animation-name: card; + -o-animation-name: card; + animation-name: card; + -webkit-animation-duration: 600ms; + -moz-animation-duration: 600ms; + -o-animation-duration: 600ms; + animation-duration: 600ms; + -webkit-animation-fill-mode: forwards; + -moz-animation-fill-mode: forwards; + -o-animation-fill-mode: forwards; + animation-fill-mode: forwards; +} + +@-webkit-keyframes card { + from {top: -40px;} + to {top: 0;} +} + +@keyframes card { + from {top: -40px;} + to {top: 0;} +} + +.card-header{ + position: relative; + overflow: hidden; + top: -40px; + width: 100%; + padding: 25px; + border-radius: 3px; + background: linear-gradient(60deg, #ec407a, #d81b60); + box-shadow: 0 4px 20px 0px rgba(0, 0, 0, 0.14), 0 7px 10px -5px rgba(233, 30, 99, 0.4); + display: flex; + flex-direction: column; + align-items: center; +} + +.card-header h4{ + font-weight: 400; + color: #fff; + margin-bottom: 25px; + margin-top: 5px; +} + +.social-btns i{ + font-size: 21px; + color: #fff; +} + +.social-btns button{ + margin: 0 8px; +} + +.tip{ + margin-top: -20px; +} + +.form-row, .card-form, .mat-input-container{ + width: 100%; +} + +.card-form{ + padding: 5px; +} + +.form-row{ + position: relative; + display: flex; + align-items: center; + margin-top: 13px; +} + +.form-row i{ + position: relative; + top: -5px; + margin-right: 15px; + color: #555; +} + +.card-footer{ + margin: 10px; +} + +.card-footer button{ + color: #e91e63; +} \ No newline at end of file diff --git a/dmp-frontend/src/app/login/login.component.ts b/dmp-frontend/src/app/login/login.component.ts new file mode 100644 index 000000000..e12a84efd --- /dev/null +++ b/dmp-frontend/src/app/login/login.component.ts @@ -0,0 +1,74 @@ +import { HttpClient } from '@angular/common/http'; +import { Component, OnInit, ElementRef, AfterViewInit, VERSION, Injectable } from '@angular/core'; +import { Router, ActivatedRoute, Params } from "@angular/router"; +import { MatPaginator, MatSort, MatSnackBar } from "@angular/material"; +import { TranslateService } from "@ngx-translate/core"; +import { AuthService } from '../services/auth/auth.service'; +import { SnackBarNotificationComponent } from '../shared/components/notificaiton/snack-bar-notification.component'; + +declare const gapi: any; + +@Component({ + selector: 'login', + templateUrl: './login.component.html', + styleUrls: ['./login.component.scss'] +}) +export class LoginComponent implements OnInit { + + public auth2: any; + + constructor(private router: Router, + public authService: AuthService, + public route: ActivatedRoute, + public snackBar: MatSnackBar, + public language: TranslateService) { } + + ngOnInit() { + gapi.load('auth2', () => { + this.auth2 = gapi.auth2.init({ + client_id: '524432312250-sc9qsmtmbvlv05r44onl6l93ia3k9deo.apps.googleusercontent.com', + cookiepolicy: 'single_host_origin', + scope: 'profile email' + }); + this.attachGoogleSignin(document.getElementById('googleSignInButton')); + }); + } + + public attachGoogleSignin(element) { + this.auth2.attachClickHandler(element, {}, + (googleUser) => { + + var id_token = googleUser.getAuthResponse().id_token; + if (id_token) { + this.authService.login({ ticket: id_token, service: "google" }).subscribe( + res => this.onLogInSuccess(res), + error => this.onLogInError(error) + ) + } + + }, (error) => { + alert(JSON.stringify(error, undefined, 2)); + }); + } + + public onLogInSuccess(logoutMessage: any) { + this.snackBar.openFromComponent(SnackBarNotificationComponent, { + data: { message: 'GENERAL.SNACK-BAR.SUCCESSFUL-LOGIN', language: this.language }, + duration: 3000, + extraClasses: ['snackbar-success'] + }); + this.route.queryParams.subscribe((params: Params) => { + let redirectUrl = params['returnUrl'] ? params['returnUrl'] : '/'; + this.router.navigate([redirectUrl]); + }) + } + + public onLogInError(errorMessage: string) { + console.log(errorMessage); + this.snackBar.openFromComponent(SnackBarNotificationComponent, { + data: { message: 'GENERAL.SNACK-BAR.UNSUCCESSFUL-LOGIN', language: this.language }, + duration: 3000, + extraClasses: ['snackbar-warning'] + }) + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/login/main-sign-in/main-sign-in.component.css b/dmp-frontend/src/app/login/main-sign-in/main-sign-in.component.css deleted file mode 100644 index 6d6af91ce..000000000 --- a/dmp-frontend/src/app/login/main-sign-in/main-sign-in.component.css +++ /dev/null @@ -1,101 +0,0 @@ -.login{ - height: 100%; - position: relative; - z-index: 1; - } - - .card{ - position: relative; - padding: 20px; - display: flex; - flex-direction: column; - align-items: center; - margin-top: 90px; - top: -90px; - -webkit-animation-name: card; - -moz-animation-name: card; - -o-animation-name: card; - animation-name: card; - -webkit-animation-duration: 600ms; - -moz-animation-duration: 600ms; - -o-animation-duration: 600ms; - animation-duration: 600ms; - -webkit-animation-fill-mode: forwards; - -moz-animation-fill-mode: forwards; - -o-animation-fill-mode: forwards; - animation-fill-mode: forwards; - } - - @-webkit-keyframes card { - from {top: -40px;} - to {top: 0;} - } - - @keyframes card { - from {top: -40px;} - to {top: 0;} - } - - .card-header{ - position: relative; - overflow: hidden; - top: -40px; - width: 100%; - padding: 25px; - border-radius: 3px; - background: linear-gradient(60deg, #ec407a, #d81b60); - box-shadow: 0 4px 20px 0px rgba(0, 0, 0, 0.14), 0 7px 10px -5px rgba(233, 30, 99, 0.4); - display: flex; - flex-direction: column; - align-items: center; - } - - .card-header h4{ - font-weight: 400; - color: #fff; - margin-bottom: 25px; - margin-top: 5px; - } - - .social-btns i{ - font-size: 21px; - color: #fff; - } - - .social-btns button{ - margin: 0 8px; - } - - .tip{ - margin-top: -20px; - } - - .form-row, .card-form, .mat-input-container{ - width: 100%; - } - - .card-form{ - padding: 5px; - } - - .form-row{ - position: relative; - display: flex; - align-items: center; - margin-top: 13px; - } - - .form-row i{ - position: relative; - top: -5px; - margin-right: 15px; - color: #555; - } - - .card-footer{ - margin: 10px; - } - - .card-footer button{ - color: #e91e63; - } \ No newline at end of file diff --git a/dmp-frontend/src/app/login/main-sign-in/main-sign-in.component.ts b/dmp-frontend/src/app/login/main-sign-in/main-sign-in.component.ts deleted file mode 100644 index 95a2c6f7f..000000000 --- a/dmp-frontend/src/app/login/main-sign-in/main-sign-in.component.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { AuthService } from '../../services/auth/auth.service'; -import { HttpClient } from '@angular/common/http'; -import { Component, OnInit, ElementRef, AfterViewInit, VERSION, Injectable } from '@angular/core'; -import { Router, ActivatedRoute, Params } from "@angular/router"; -import { SnackBarNotificationComponent } from "../../shared/components/notificaiton/snack-bar-notification.component"; -import { MatPaginator, MatSort, MatSnackBar } from "@angular/material"; -import { TranslateService } from "@ngx-translate/core"; -declare const gapi: any; - -declare const auth2 :any; -@Component({ - selector: 'app-main-sign-in', - templateUrl: './main-sign-in.component.html', - styleUrls: ['./main-sign-in.component.css'] -}) -export class MainSignInComponent implements OnInit { - - constructor(private element: ElementRef, private router : Router,private authService:AuthService,private route:ActivatedRoute, - public snackBar: MatSnackBar,public language: TranslateService) { } - - ngOnInit() { - } - - loginBtn() { - } - - - public googleSignIn() { - auth2.grantOfflineAccess().then((authResult)=>this.signInCallback(authResult)) -} - -signInCallback(authResult){ - if (authResult['code']) { - this.authService.login({ticket:authResult['code'],service:"google"}).subscribe( - res => this.onLogInSuccess(res), - error => this.onLogInError(error) - ) - } -} - -public onLogInSuccess(logoutMessage: any) { - this.route.queryParams.subscribe((params: Params) => { - let redirectUrl = params['returnUrl'] ? params['returnUrl'] : '/'; - this.router.navigate([redirectUrl]); - }) -} - -public onLogInError(errorMessage: string) { - console.log(errorMessage); - this.snackBar.openFromComponent(SnackBarNotificationComponent, { - data: { message: 'GENERAL.SNACK-BAR.UNSUCCESSFUL-LOGIN', language: this.language }, - duration: 3000, - extraClasses: ['snackbar-warning'] - }) -} -} \ No newline at end of file diff --git a/dmp-frontend/src/app/shared/components/notificaiton/snack-bar-notification.component.html b/dmp-frontend/src/app/shared/components/notificaiton/snack-bar-notification.component.html index e407b738f..bd62cd6d1 100644 --- a/dmp-frontend/src/app/shared/components/notificaiton/snack-bar-notification.component.html +++ b/dmp-frontend/src/app/shared/components/notificaiton/snack-bar-notification.component.html @@ -1,12 +1 @@ - -
-

Hello {{ userInfo?.name!=null ? userInfo?.name : userInfo?.email }}

-

Welcome {{ userInfo?.created != userInfo?.lastloggedin ? "back" : "" }} to the Data Management Plans composer application.

- -
- - \ No newline at end of file +{{message}} \ No newline at end of file diff --git a/dmp-frontend/src/assets/custom.css b/dmp-frontend/src/assets/custom.css deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/assets/custom.js b/dmp-frontend/src/assets/custom.js deleted file mode 100644 index 7bdc5bece..000000000 --- a/dmp-frontend/src/assets/custom.js +++ /dev/null @@ -1,69 +0,0 @@ -var clientId = '1010962018903-glegmqudqtl1lub0150vacopbu06lgsg.apps.googleusercontent.com'; -var scope = [ - 'profile', - 'email' -].join(' '); - -if(gapi.auth2 == undefined){ - - gapi.load('auth2', () => { - - gapi.auth2.init({ - client_id: clientId, - cookiepolicy: 'single_host_origin', - scope: scope - }); - - //RE-Render the button (due to known issues of google-button with angular's lifecycle) - gapi.signin2.render('googleBtn'); - - //var buttonElement = this.element.nativeElement.querySelector('#googleBtn'); - //this.attachSignin(buttonElement); - - }); - -} - - -var sign_out_google = (function() { - var auth2 = gapi.auth2.getAuthInstance(); - auth2.signOut().then(function () { - console.log('User signed out from google.'); - }); -}); - - -var simple_notifier = (function(type, title, message) { - - setTimeout(function() { - $(".alert").remove(); - }, 11000); - - return notify(type, title, message, null, null, null, null, null, null, null, null, null, null); -}); - - - -function notify(type, title, message, delay, icon, url, target, allow_dismiss, offset_x, offset_y, animate_enter, animate_exit, newest_on_top){ - - var options = {}; - if(icon!=null) options.icon = icon; - if(title!=null) options.title = title; - if(message!=null) options.message = message; - if(url!=null) options.url = url; - if(target!=null) options.target = target; - - var settings = {}; - if(type!=null) settings.type = type; - if(allow_dismiss!=null) settings.allow_dismiss = allow_dismiss; - settings.delay = 5; - if(delay!=null) settings.delay = delay; - - return $.notify(options,settings, delay); - -} - - - - - diff --git a/dmp-frontend/src/index.html b/dmp-frontend/src/index.html index 467b91a55..7ccf21ccd 100644 --- a/dmp-frontend/src/index.html +++ b/dmp-frontend/src/index.html @@ -31,9 +31,7 @@ - +