Skip to content

Commit

Permalink
Login component clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
mdarif committed Jan 18, 2025
1 parent 6bad5f9 commit ed96d0e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 40 deletions.
16 changes: 16 additions & 0 deletions apps/login/src/app/remote-entry/entry.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.login-app {
width: 30vw;
border: 2px dashed black;
padding: 8px;
margin: 0 auto;
}
.login-form {
display: flex;
align-items: center;
flex-direction: column;
margin: 0 auto;
padding: 8px;
}
label {
display: block;
}
17 changes: 17 additions & 0 deletions apps/login/src/app/remote-entry/entry.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<div class="login-app">
<form class="login-form" (ngSubmit)="login()">
<label>
Username:
<input type="text" name="username" [(ngModel)]="username" />
</label>
<label>
Password:
<input type="password" name="password" [(ngModel)]="password" />
</label>
<button type="submit">Login</button>
</form>
<!-- This is the chat bot component that is exposed by the shared library -->
<ac-chat-bot></ac-chat-bot>
<div *ngIf="isLoggedIn$ | async">User is logged in!</div>
<div *ngIf="(isLoggedIn$ | async) === false">User is not logged in!</div>
</div>
53 changes: 13 additions & 40 deletions apps/login/src/app/remote-entry/entry.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,58 +5,31 @@ import { UserService } from '@ng-mf/data-access-user';
import { ChatBotComponent } from 'login/chatBot';

@Component({
standalone: true,
imports: [CommonModule, FormsModule, ChatBotComponent],
selector: 'ng-mf-login-entry',
template: `
<div class="login-app">
<form class="login-form" (ngSubmit)="login()">
<label>
Username:
<input type="text" name="username" [(ngModel)]="username" />
</label>
<label>
Password:
<input type="password" name="password" [(ngModel)]="password" />
</label>
<button type="submit">Login</button>
</form>
<!-- This is the chat bot component that is exposed by the shared library -->
<ac-chat-bot></ac-chat-bot>
<div *ngIf="isLoggedIn$ | async">User is logged in!</div>
<div *ngIf="(isLoggedIn$ | async) === false">User is not logged in!</div>
</div>
`,
styles: [
`
.login-app {
width: 30vw;
border: 2px dashed black;
padding: 8px;
margin: 0 auto;
}
.login-form {
display: flex;
align-items: center;
flex-direction: column;
margin: 0 auto;
padding: 8px;
}
label {
display: block;
}
`,
],
templateUrl: './entry.component.html',
styleUrls: ['./entry.component.css'],
})
/**
* This component is the entry point for the remote login application.
*/
export class RemoteEntryComponent {
username = '';
password = '';
isLoggedIn$;

/**
* Constructor for the RemoteEntryComponent.
*
* @param userService
*/
constructor(private userService: UserService) {
this.isLoggedIn$ = this.userService.isUserLoggedIn$;
}

/**
* Method to log in the user.
*/
login() {
this.userService.checkCredentials(this.username, this.password);
}
Expand Down

0 comments on commit ed96d0e

Please sign in to comment.