Skip to content

Commit

Permalink
add module authorization server.
Browse files Browse the repository at this point in the history
  • Loading branch information
vnobo committed Mar 8, 2024
1 parent 1746a24 commit fb574ae
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 7 deletions.
1 change: 0 additions & 1 deletion ui/projects/web/src/app/pages/layout/layout.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {PageComponent} from "./page/page.component";


@NgModule({
declarations: [],
imports: [
Expand Down
3 changes: 1 addition & 2 deletions ui/projects/web/src/app/pages/layout/page/page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import {Component} from '@angular/core';

@Component({
selector: 'app-page',
standalone: true,
imports: [],
templateUrl: './page.component.html',
standalone: true,
styleUrl: './page.component.scss'
})
export class PageComponent {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<form (ngSubmit)="submitForm()" [formGroup]="validateForm" class="login-form" nz-form>
<nz-form-item>
<nz-form-control nzErrorTip="Please input your username!">
<nz-input-group nzPrefixIcon="user">
<input formControlName="userName" nz-input placeholder="Username" type="text"/>
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-control nzErrorTip="Please input your Password!">
<nz-input-group nzPrefixIcon="lock">
<input formControlName="password" nz-input placeholder="Password" type="password"/>
</nz-input-group>
</nz-form-control>
</nz-form-item>
<div class="login-form-margin" nz-row>
<div [nzSpan]="12" nz-col>
<label formControlName="remember" nz-checkbox>
<span>Remember me</span>
<input name="peas" type="checkbox" />
</label>
</div>
<div [nzSpan]="12" nz-col>
<a class="login-form-forgot">Forgot password</a>
</div>
</div>
<button [nzType]="'primary'" class="login-form-button login-form-margin" nz-button>Log in</button>
Or
<a>register now!</a>
</form>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

.login-form {
max-width: 300px;
}

.login-form-margin {
margin-bottom: 16px;
}

.login-form-forgot {
float: right;
}

.login-form-button {
width: 100%;
}
35 changes: 35 additions & 0 deletions ui/projects/web/src/app/pages/security/loginv1/login.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {Component} from '@angular/core';
import {FormControl, FormGroup, NonNullableFormBuilder, Validators} from '@angular/forms';

@Component({
selector: 'app-login-v1',
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss']
})
export class LoginV1Component {
validateForm: FormGroup<{
userName: FormControl<string>;
password: FormControl<string>;
remember: FormControl<boolean>;
}> = this.fb.group({
userName: ['', [Validators.required]],
password: ['', [Validators.required]],
remember: [true]
});

constructor(private fb: NonNullableFormBuilder) {
}

submitForm(): void {
if (this.validateForm.valid) {
console.log('submit', this.validateForm.value);
} else {
Object.values(this.validateForm.controls).forEach(control => {
if (control.invalid) {
control.markAsDirty();
control.updateValueAndValidity({onlySelf: true});
}
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import {NgModule} from '@angular/core';
import {RouterModule, Routes, TitleStrategy} from '@angular/router';
import {LoginComponent} from "./login/login.component";
import {PageTitleStrategy} from "../../core/title-strategy.service";
import {LoginV1Component} from "./loginv1/login.component";

const routes: Routes = [
{path: 'login', component: LoginComponent, title: "系统登录"},
{path: 'login1', component: LoginV1Component, title: "系统登录"},
{path: '', component: LoginComponent}
];

Expand Down
12 changes: 8 additions & 4 deletions ui/projects/web/src/app/pages/security/security.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@ import {SecurityRoutingModule} from './security-routing.module';
import {LoginComponent} from './login/login.component';
import {NzDividerModule} from "ng-zorro-antd/divider";
import {SharedModule} from '../../shared/shared.module';

import {LoginV1Component} from "./loginv1/login.component";
import {NzCheckboxModule} from "ng-zorro-antd/checkbox";

@NgModule({
imports: [
SharedModule,
SecurityRoutingModule,
NzDividerModule
NzDividerModule,
NzCheckboxModule
],
declarations: [
LoginComponent
LoginComponent,
LoginV1Component
],
exports: [
LoginComponent
LoginComponent,
LoginV1Component
],
providers: [
]
Expand Down

0 comments on commit fb574ae

Please sign in to comment.