mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2025-06-28 17:45:11 +00:00
Use iframe webcomponent to allow more flexibility in terms of languages
This commit is contained in:
39
src/app/web/web.component.html
Normal file
39
src/app/web/web.component.html
Normal file
@ -0,0 +1,39 @@
|
||||
<!--
|
||||
<div>
|
||||
<h1>Login page</h1>
|
||||
<form #loginForm="ngForm" (submit)="onSubmit()" [hidden]="submitted">
|
||||
<div class="form-group">
|
||||
<label for="email_input">Email:</label>
|
||||
<input
|
||||
id="email_input"
|
||||
class="form-control"
|
||||
type="email"
|
||||
name="email"
|
||||
placeholder="Enter email"
|
||||
[(ngModel)]="model.email"
|
||||
>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password_input">Password:</label>
|
||||
<input
|
||||
id="password_input"
|
||||
class="form-control"
|
||||
type="password"
|
||||
name="password"
|
||||
placeholder="Password"
|
||||
[(ngModel)]="model.password"
|
||||
>
|
||||
</div>
|
||||
<button type="submit" class="btn tao-btn-primary">Submit</button>
|
||||
</form>
|
||||
<div [hidden]="!submitted">
|
||||
<p>
|
||||
Logged in as {{logged_in_email}}.
|
||||
You <em><span *ngIf="!is_admin">don't </span>have</em> admin privileges.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<div class="row-container">
|
||||
|
||||
</div>
|
0
src/app/web/web.component.scss
Normal file
0
src/app/web/web.component.scss
Normal file
36
src/app/web/web.component.ts
Normal file
36
src/app/web/web.component.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import {Component, OnDestroy, OnInit} from '@angular/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Login } from './web';
|
||||
import {DeploymentNotificationService} from '../services/deployment-notification.service';
|
||||
import {Subscription} from 'rxjs/Subscription';
|
||||
|
||||
@Component({
|
||||
selector: 'app-web',
|
||||
templateUrl: './web.component.html',
|
||||
styleUrls: ['./web.component.scss']
|
||||
})
|
||||
export class LoginComponent {
|
||||
model = new Login('', '');
|
||||
submitted = false;
|
||||
is_admin: boolean;
|
||||
logged_in_email: string;
|
||||
|
||||
constructor(
|
||||
private http: HttpClient
|
||||
) {}
|
||||
|
||||
onSubmit() {
|
||||
this.postLogin(this.model).subscribe(
|
||||
res => {
|
||||
this.logged_in_email = res['email'];
|
||||
this.is_admin = res['is_admin'];
|
||||
}
|
||||
);
|
||||
this.submitted = true;
|
||||
}
|
||||
|
||||
postLogin(login: Login): Observable<any> {
|
||||
return this.http.post<Login>('/web', login);
|
||||
}
|
||||
}
|
8
src/app/web/web.ts
Normal file
8
src/app/web/web.ts
Normal file
@ -0,0 +1,8 @@
|
||||
export class Login {
|
||||
|
||||
constructor(
|
||||
public email: string,
|
||||
public password: string
|
||||
) {}
|
||||
|
||||
}
|
Reference in New Issue
Block a user