Fix standalone problem
parent
e8e5d8eb5d
commit
3f0906d8c7
|
@ -1,4 +1,4 @@
|
||||||
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.
|
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
||||||
|
|
||||||
# Compiled output
|
# Compiled output
|
||||||
/dist
|
/dist
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# OgWebconsole
|
# OgWebconsole
|
||||||
|
|
||||||
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 17.3.7.
|
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 17.0.7.
|
||||||
|
|
||||||
## Development server
|
## Development server
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,17 @@
|
||||||
"projects": {
|
"projects": {
|
||||||
"ogWebconsole": {
|
"ogWebconsole": {
|
||||||
"projectType": "application",
|
"projectType": "application",
|
||||||
"schematics": {},
|
"schematics": {
|
||||||
|
"@schematics/angular:component": {
|
||||||
|
"standalone": false
|
||||||
|
},
|
||||||
|
"@schematics/angular:directive": {
|
||||||
|
"standalone": false
|
||||||
|
},
|
||||||
|
"@schematics/angular:pipe": {
|
||||||
|
"standalone": false
|
||||||
|
}
|
||||||
|
},
|
||||||
"root": "",
|
"root": "",
|
||||||
"sourceRoot": "src",
|
"sourceRoot": "src",
|
||||||
"prefix": "app",
|
"prefix": "app",
|
||||||
|
@ -25,15 +35,9 @@
|
||||||
"src/assets"
|
"src/assets"
|
||||||
],
|
],
|
||||||
"styles": [
|
"styles": [
|
||||||
"src/custom-theme.scss",
|
|
||||||
"src/styles.css"
|
"src/styles.css"
|
||||||
],
|
],
|
||||||
"scripts": [],
|
"scripts": []
|
||||||
"server": "src/main.server.ts",
|
|
||||||
"prerender": true,
|
|
||||||
"ssr": {
|
|
||||||
"entry": "server.ts"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"production": {
|
"production": {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -6,42 +6,33 @@
|
||||||
"start": "ng serve",
|
"start": "ng serve",
|
||||||
"build": "ng build",
|
"build": "ng build",
|
||||||
"watch": "ng build --watch --configuration development",
|
"watch": "ng build --watch --configuration development",
|
||||||
"test": "ng test",
|
"test": "ng test"
|
||||||
"serve:ssr:ogWebconsole": "node dist/og-webconsole/server/server.mjs"
|
|
||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/animations": "^17.3.0",
|
"@angular/animations": "^17.0.0",
|
||||||
"@angular/cdk": "^17.3.9",
|
"@angular/common": "^17.0.0",
|
||||||
"@angular/common": "^17.3.0",
|
"@angular/compiler": "^17.0.0",
|
||||||
"@angular/compiler": "^17.3.0",
|
"@angular/core": "^17.0.0",
|
||||||
"@angular/core": "^17.3.0",
|
"@angular/forms": "^17.0.0",
|
||||||
"@angular/forms": "^17.3.0",
|
"@angular/platform-browser": "^17.0.0",
|
||||||
"@angular/material": "^17.3.9",
|
"@angular/platform-browser-dynamic": "^17.0.0",
|
||||||
"@angular/platform-browser": "^17.3.0",
|
"@angular/router": "^17.0.0",
|
||||||
"@angular/platform-browser-dynamic": "^17.3.0",
|
|
||||||
"@angular/platform-server": "^17.3.0",
|
|
||||||
"@angular/router": "^17.3.0",
|
|
||||||
"@angular/ssr": "^17.3.7",
|
|
||||||
"bootstrap": "^5.3.3",
|
|
||||||
"express": "^4.18.2",
|
|
||||||
"rxjs": "~7.8.0",
|
"rxjs": "~7.8.0",
|
||||||
"tslib": "^2.3.0",
|
"tslib": "^2.3.0",
|
||||||
"zone.js": "~0.14.3"
|
"zone.js": "~0.14.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular-devkit/build-angular": "^17.3.7",
|
"@angular-devkit/build-angular": "^17.0.7",
|
||||||
"@angular/cli": "^17.3.7",
|
"@angular/cli": "^17.0.7",
|
||||||
"@angular/compiler-cli": "^17.3.0",
|
"@angular/compiler-cli": "^17.0.0",
|
||||||
"@types/express": "^4.17.17",
|
|
||||||
"@types/jasmine": "~5.1.0",
|
"@types/jasmine": "~5.1.0",
|
||||||
"@types/node": "^18.18.0",
|
|
||||||
"jasmine-core": "~5.1.0",
|
"jasmine-core": "~5.1.0",
|
||||||
"karma": "~6.4.0",
|
"karma": "~6.4.0",
|
||||||
"karma-chrome-launcher": "~3.2.0",
|
"karma-chrome-launcher": "~3.2.0",
|
||||||
"karma-coverage": "~2.2.0",
|
"karma-coverage": "~2.2.0",
|
||||||
"karma-jasmine": "~5.1.0",
|
"karma-jasmine": "~5.1.0",
|
||||||
"karma-jasmine-html-reporter": "~2.1.0",
|
"karma-jasmine-html-reporter": "~2.1.0",
|
||||||
"typescript": "~5.4.2"
|
"typescript": "~5.2.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,56 +0,0 @@
|
||||||
import { APP_BASE_HREF } from '@angular/common';
|
|
||||||
import { CommonEngine } from '@angular/ssr';
|
|
||||||
import express from 'express';
|
|
||||||
import { fileURLToPath } from 'node:url';
|
|
||||||
import { dirname, join, resolve } from 'node:path';
|
|
||||||
import bootstrap from './src/main.server';
|
|
||||||
|
|
||||||
// The Express app is exported so that it can be used by serverless Functions.
|
|
||||||
export function app(): express.Express {
|
|
||||||
const server = express();
|
|
||||||
const serverDistFolder = dirname(fileURLToPath(import.meta.url));
|
|
||||||
const browserDistFolder = resolve(serverDistFolder, '../browser');
|
|
||||||
const indexHtml = join(serverDistFolder, 'index.server.html');
|
|
||||||
|
|
||||||
const commonEngine = new CommonEngine();
|
|
||||||
|
|
||||||
server.set('view engine', 'html');
|
|
||||||
server.set('views', browserDistFolder);
|
|
||||||
|
|
||||||
// Example Express Rest API endpoints
|
|
||||||
// server.get('/api/**', (req, res) => { });
|
|
||||||
// Serve static files from /browser
|
|
||||||
server.get('*.*', express.static(browserDistFolder, {
|
|
||||||
maxAge: '1y'
|
|
||||||
}));
|
|
||||||
|
|
||||||
// All regular routes use the Angular engine
|
|
||||||
server.get('*', (req, res, next) => {
|
|
||||||
const { protocol, originalUrl, baseUrl, headers } = req;
|
|
||||||
|
|
||||||
commonEngine
|
|
||||||
.render({
|
|
||||||
bootstrap,
|
|
||||||
documentFilePath: indexHtml,
|
|
||||||
url: `${protocol}://${headers.host}${originalUrl}`,
|
|
||||||
publicPath: browserDistFolder,
|
|
||||||
providers: [{ provide: APP_BASE_HREF, useValue: baseUrl }],
|
|
||||||
})
|
|
||||||
.then((html) => res.send(html))
|
|
||||||
.catch((err) => next(err));
|
|
||||||
});
|
|
||||||
|
|
||||||
return server;
|
|
||||||
}
|
|
||||||
|
|
||||||
function run(): void {
|
|
||||||
const port = process.env['PORT'] || 4000;
|
|
||||||
|
|
||||||
// Start up the Node server
|
|
||||||
const server = app();
|
|
||||||
server.listen(port, () => {
|
|
||||||
console.log(`Node Express server listening on http://localhost:${port}`);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
run();
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { RouterModule, Routes } from '@angular/router';
|
||||||
|
import { MainLayoutComponent } from './components/layout/main-layout/main-layout.component';
|
||||||
|
import { AuthLayoutComponent } from './components/layout/auth-layout/auth-layout.component';
|
||||||
|
import { LoginComponent } from './components/login/login.component';
|
||||||
|
import { DashboardComponent } from './components/dashboard/dashboard.component';
|
||||||
|
import { PageNotFoundComponent } from './components/page-not-found/page-not-found.component';
|
||||||
|
|
||||||
|
const routes: Routes = [
|
||||||
|
{ path: '', redirectTo: 'auth/login', pathMatch: 'full' },
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
component: MainLayoutComponent,
|
||||||
|
children: [
|
||||||
|
{ path: 'dashboard', component: DashboardComponent },
|
||||||
|
// otras rutas que usan el MainLayoutComponent
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'auth',
|
||||||
|
component: AuthLayoutComponent,
|
||||||
|
children: [
|
||||||
|
{ path: 'login', component: LoginComponent },
|
||||||
|
// otras rutas de autenticación
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{ path: '**', component: PageNotFoundComponent },
|
||||||
|
];
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [RouterModule.forRoot(routes)],
|
||||||
|
exports: [RouterModule]
|
||||||
|
})
|
||||||
|
export class AppRoutingModule { }
|
|
@ -1,10 +1,16 @@
|
||||||
import { TestBed } from '@angular/core/testing';
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
|
|
||||||
describe('AppComponent', () => {
|
describe('AppComponent', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
imports: [AppComponent],
|
imports: [
|
||||||
|
RouterTestingModule
|
||||||
|
],
|
||||||
|
declarations: [
|
||||||
|
AppComponent
|
||||||
|
],
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -14,7 +20,7 @@ describe('AppComponent', () => {
|
||||||
expect(app).toBeTruthy();
|
expect(app).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should have the 'ogWebconsole' title`, () => {
|
it(`should have as title 'ogWebconsole'`, () => {
|
||||||
const fixture = TestBed.createComponent(AppComponent);
|
const fixture = TestBed.createComponent(AppComponent);
|
||||||
const app = fixture.componentInstance;
|
const app = fixture.componentInstance;
|
||||||
expect(app.title).toEqual('ogWebconsole');
|
expect(app.title).toEqual('ogWebconsole');
|
||||||
|
|
|
@ -1,15 +1,7 @@
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { RouterOutlet } from '@angular/router';
|
|
||||||
import { SidebarComponent } from './components/layout/sidebar/sidebar.component';
|
|
||||||
import { FooterComponent } from './components/layout/footer/footer.component';
|
|
||||||
import { HeaderComponent } from './components/layout/header/header.component';
|
|
||||||
import { FormsModule } from '@angular/forms';
|
|
||||||
import { HttpClientModule } from '@angular/common/http';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
standalone: true,
|
|
||||||
imports: [RouterOutlet, SidebarComponent, FooterComponent, HeaderComponent, FormsModule, HttpClientModule],
|
|
||||||
templateUrl: './app.component.html',
|
templateUrl: './app.component.html',
|
||||||
styleUrl: './app.component.css'
|
styleUrl: './app.component.css'
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';
|
|
||||||
import { provideServerRendering } from '@angular/platform-server';
|
|
||||||
import { appConfig } from './app.config';
|
|
||||||
|
|
||||||
const serverConfig: ApplicationConfig = {
|
|
||||||
providers: [
|
|
||||||
provideServerRendering()
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
export const config = mergeApplicationConfig(appConfig, serverConfig);
|
|
|
@ -1,11 +0,0 @@
|
||||||
import { ApplicationConfig } from '@angular/core';
|
|
||||||
import { provideRouter } from '@angular/router';
|
|
||||||
|
|
||||||
import { routes } from './app.routes';
|
|
||||||
import { provideClientHydration } from '@angular/platform-browser';
|
|
||||||
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
|
|
||||||
import { provideHttpClient } from '@angular/common/http';
|
|
||||||
|
|
||||||
export const appConfig: ApplicationConfig = {
|
|
||||||
providers: [provideRouter(routes), provideClientHydration(), provideAnimationsAsync(), provideHttpClient(),]
|
|
||||||
};
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
|
|
||||||
|
import { AppRoutingModule } from './app-routing.module';
|
||||||
|
import { AppComponent } from './app.component';
|
||||||
|
import { AuthLayoutComponent } from './components/layout/auth-layout/auth-layout.component';
|
||||||
|
import { MainLayoutComponent } from './components/layout/main-layout/main-layout.component';
|
||||||
|
import { FooterComponent } from './components/layout/footer/footer.component';
|
||||||
|
import { HeaderComponent } from './components/layout/header/header.component';
|
||||||
|
import { SidebarComponent } from './components/layout/sidebar/sidebar.component';
|
||||||
|
import { LoginComponent } from './components/login/login.component';
|
||||||
|
import { FormsModule } from '@angular/forms';
|
||||||
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [
|
||||||
|
AppComponent,
|
||||||
|
AuthLayoutComponent,
|
||||||
|
MainLayoutComponent,
|
||||||
|
FooterComponent,
|
||||||
|
HeaderComponent,
|
||||||
|
SidebarComponent,
|
||||||
|
LoginComponent,
|
||||||
|
MainLayoutComponent,
|
||||||
|
],
|
||||||
|
imports: [
|
||||||
|
BrowserModule,
|
||||||
|
AppRoutingModule,
|
||||||
|
FormsModule,
|
||||||
|
HttpClientModule
|
||||||
|
],
|
||||||
|
providers: [],
|
||||||
|
bootstrap: [AppComponent]
|
||||||
|
})
|
||||||
|
export class AppModule { }
|
|
@ -1,30 +0,0 @@
|
||||||
import { NgModule } from '@angular/core';
|
|
||||||
import { RouterModule, Routes } from '@angular/router';
|
|
||||||
import { MainLayoutComponent } from './components/layout/main-layout/main-layout.component';
|
|
||||||
import { AuthLayoutComponent } from './components/layout/auth-layout/auth-layout.component';
|
|
||||||
import { LoginComponent } from './components/login/login.component';
|
|
||||||
import { DashboardComponent } from './components/dashboard/dashboard.component';
|
|
||||||
import { PageNotFoundComponent } from './components/page-not-found/page-not-found.component';
|
|
||||||
import {AuthGuard } from './auth.guard';
|
|
||||||
|
|
||||||
export const routes: Routes = [
|
|
||||||
{ path: '', redirectTo: 'auth/login', pathMatch: 'full' },
|
|
||||||
{
|
|
||||||
path: '',
|
|
||||||
component: MainLayoutComponent,
|
|
||||||
pathMatch: 'full', canActivate: [AuthGuard],
|
|
||||||
children: [
|
|
||||||
{ path: 'dashboard', component: DashboardComponent },
|
|
||||||
// otras rutas que usan el MainLayoutComponent
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'auth',
|
|
||||||
component: AuthLayoutComponent,
|
|
||||||
children: [
|
|
||||||
{ path: 'login', component: LoginComponent },
|
|
||||||
// otras rutas de autenticación
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{ path: '**', component: PageNotFoundComponent },
|
|
||||||
];
|
|
|
@ -1,17 +0,0 @@
|
||||||
import { TestBed } from '@angular/core/testing';
|
|
||||||
import { CanActivateFn } from '@angular/router';
|
|
||||||
|
|
||||||
import { authGuard } from './auth.guard';
|
|
||||||
|
|
||||||
describe('authGuard', () => {
|
|
||||||
const executeGuard: CanActivateFn = (...guardParameters) =>
|
|
||||||
TestBed.runInInjectionContext(() => authGuard(...guardParameters));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
TestBed.configureTestingModule({});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be created', () => {
|
|
||||||
expect(executeGuard).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,24 +0,0 @@
|
||||||
import { Injectable } from '@angular/core';
|
|
||||||
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, Router } from '@angular/router';
|
|
||||||
import { Observable } from 'rxjs';
|
|
||||||
import { AuthService } from './auth.service';
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root'
|
|
||||||
})
|
|
||||||
export class AuthGuard implements CanActivate {
|
|
||||||
|
|
||||||
constructor(private authService: AuthService, private router: Router) { }
|
|
||||||
|
|
||||||
canActivate(
|
|
||||||
next: ActivatedRouteSnapshot,
|
|
||||||
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
|
|
||||||
const token = this.authService.getToken();
|
|
||||||
if (token) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
this.router.navigate(['/login']);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
import { TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { AuthService } from './auth.service';
|
|
||||||
|
|
||||||
describe('AuthService', () => {
|
|
||||||
let service: AuthService;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
TestBed.configureTestingModule({});
|
|
||||||
service = TestBed.inject(AuthService);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be created', () => {
|
|
||||||
expect(service).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,33 +0,0 @@
|
||||||
import { Injectable } from '@angular/core';
|
|
||||||
import { HttpClient } from '@angular/common/http';
|
|
||||||
import { Observable } from 'rxjs';
|
|
||||||
import { tap } from 'rxjs/operators';
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root'
|
|
||||||
})
|
|
||||||
export class AuthService {
|
|
||||||
private apiUrl = 'http://127.0.0.1:8080/auth/login'; // Reemplaza con la URL de tu API
|
|
||||||
|
|
||||||
constructor(private http: HttpClient) { }
|
|
||||||
|
|
||||||
login(username: string, password: string): Observable<any> {
|
|
||||||
return this.http.post<any>(this.apiUrl, { username, password }).pipe(
|
|
||||||
tap(response => {
|
|
||||||
if (response.token) {
|
|
||||||
localStorage.setItem('token', response.token);
|
|
||||||
localStorage.setItem('refresh_token', response.refresh_token);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
logout(): void {
|
|
||||||
localStorage.removeItem('token');
|
|
||||||
localStorage.removeItem('refresh_token');
|
|
||||||
}
|
|
||||||
|
|
||||||
getToken(): string | null {
|
|
||||||
return localStorage.getItem('token');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,8 +2,6 @@ import { Component } from '@angular/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dashboard',
|
selector: 'app-dashboard',
|
||||||
standalone: true,
|
|
||||||
imports: [],
|
|
||||||
templateUrl: './dashboard.component.html',
|
templateUrl: './dashboard.component.html',
|
||||||
styleUrl: './dashboard.component.css'
|
styleUrl: './dashboard.component.css'
|
||||||
})
|
})
|
||||||
|
|
|
@ -3,4 +3,3 @@
|
||||||
<router-outlet></router-outlet>
|
<router-outlet></router-outlet>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -8,7 +8,7 @@ describe('AuthLayoutComponent', () => {
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
imports: [AuthLayoutComponent]
|
declarations: [AuthLayoutComponent]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
import { HttpClientModule } from '@angular/common/http';
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { RouterOutlet } from '@angular/router';
|
import { RouterOutlet } from '@angular/router';
|
||||||
|
import { FormsModule } from '@angular/forms';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-auth-layout',
|
selector: 'app-auth-layout',
|
||||||
standalone: true,
|
|
||||||
imports: [RouterOutlet, HttpClientModule],
|
|
||||||
templateUrl: './auth-layout.component.html',
|
templateUrl: './auth-layout.component.html',
|
||||||
styleUrl: './auth-layout.component.css'
|
styleUrl: './auth-layout.component.css'
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,8 +2,6 @@ import { Component } from '@angular/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-footer',
|
selector: 'app-footer',
|
||||||
standalone: true,
|
|
||||||
imports: [],
|
|
||||||
templateUrl: './footer.component.html',
|
templateUrl: './footer.component.html',
|
||||||
styleUrl: './footer.component.css'
|
styleUrl: './footer.component.css'
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,8 +2,6 @@ import { Component } from '@angular/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-header',
|
selector: 'app-header',
|
||||||
standalone: true,
|
|
||||||
imports: [],
|
|
||||||
templateUrl: './header.component.html',
|
templateUrl: './header.component.html',
|
||||||
styleUrl: './header.component.css'
|
styleUrl: './header.component.css'
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
:host{
|
|
||||||
width: 100%;
|
|
||||||
display: grid;
|
|
||||||
grid-template-areas:
|
|
||||||
"sidebar header"
|
|
||||||
"sidebar content"
|
|
||||||
"sidebar footer";
|
|
||||||
grid-template-columns: 120px 1fr;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
.content-wrapper{
|
|
||||||
display: block;
|
|
||||||
background-color: gold;
|
|
||||||
grid-area: content;
|
|
||||||
}
|
|
|
@ -1,7 +1 @@
|
||||||
<app-sidebar></app-sidebar>
|
<p>main-layout works!</p>
|
||||||
<app-header></app-header>
|
|
||||||
<app-footer></app-footer>
|
|
||||||
<div class="content-wrapper">
|
|
||||||
<div class="content">
|
|
||||||
<router-outlet />
|
|
||||||
</div>
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ describe('MainLayoutComponent', () => {
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
imports: [MainLayoutComponent]
|
declarations: [MainLayoutComponent]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,7 @@
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { SidebarComponent } from '../sidebar/sidebar.component';
|
|
||||||
import { FooterComponent } from '../footer/footer.component';
|
|
||||||
import { HeaderComponent } from '../header/header.component';
|
|
||||||
import { RouterOutlet } from '@angular/router';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-main-layout',
|
selector: 'app-main-layout',
|
||||||
standalone: true,
|
|
||||||
imports: [SidebarComponent, FooterComponent, HeaderComponent, RouterOutlet],
|
|
||||||
templateUrl: './main-layout.component.html',
|
templateUrl: './main-layout.component.html',
|
||||||
styleUrl: './main-layout.component.css'
|
styleUrl: './main-layout.component.css'
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,8 +2,6 @@ import { Component } from '@angular/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-sidebar',
|
selector: 'app-sidebar',
|
||||||
standalone: true,
|
|
||||||
imports: [],
|
|
||||||
templateUrl: './sidebar.component.html',
|
templateUrl: './sidebar.component.html',
|
||||||
styleUrl: './sidebar.component.css'
|
styleUrl: './sidebar.component.css'
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
<div>
|
<div>
|
||||||
<h2>Login</h2>
|
<h2>Login</h2>
|
||||||
<form (ngSubmit)="login()">
|
<form>
|
||||||
<div>
|
<div>
|
||||||
<label for="username">Username:</label>
|
<label for="username">Username:</label>
|
||||||
<input (ngModel)="username" type="text" id="username" name="username" required>
|
<input [(ngModel)]="loginObj.EmailId" type="text" id="username" name="EmailId" required>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label for="password">Password:</label>
|
<label for="password">Password:</label>
|
||||||
<input (ngModel)="password" type="password" id="password" name="password" required>
|
<input (ngModel)="loginObj.Password" type="password" id="password" name="Password" required>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit">Login</button>
|
<button (click)="onLogin()">Login</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
|
@ -1,5 +1,6 @@
|
||||||
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { AuthService } from '../../auth.service';
|
import { FormsModule } from '@angular/forms';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,20 +10,12 @@ import { Router } from '@angular/router';
|
||||||
styleUrls: ['./login.component.css'],
|
styleUrls: ['./login.component.css'],
|
||||||
})
|
})
|
||||||
export class LoginComponent {
|
export class LoginComponent {
|
||||||
username: string = '';
|
loginObj: any = {
|
||||||
password: string = '';
|
"EmailId": "",
|
||||||
|
"Password": ""
|
||||||
constructor(private authService: AuthService, private router: Router) { }
|
};
|
||||||
|
constructor(private http: HttpClient) { }
|
||||||
login(): void {
|
onLogin() {
|
||||||
this.authService.login(this.username, this.password).subscribe(
|
this.http.post('https://freeapi.gerasim.in/api/User/Login', this.loginObj)
|
||||||
response => {
|
}
|
||||||
console.log('Login successful');
|
|
||||||
this.router.navigate(['/']);
|
|
||||||
},
|
|
||||||
error => {
|
|
||||||
console.error('Login failed', error);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,6 @@ import { Component } from '@angular/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-page-not-found',
|
selector: 'app-page-not-found',
|
||||||
standalone: true,
|
|
||||||
imports: [],
|
|
||||||
templateUrl: './page-not-found.component.html',
|
templateUrl: './page-not-found.component.html',
|
||||||
styleUrl: './page-not-found.component.css'
|
styleUrl: './page-not-found.component.css'
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
|
|
||||||
// Custom Theming for Angular Material
|
|
||||||
// For more information: https://material.angular.io/guide/theming
|
|
||||||
@use '@angular/material' as mat;
|
|
||||||
// Plus imports for other components in your app.
|
|
||||||
|
|
||||||
// Include the common styles for Angular Material. We include this here so that you only
|
|
||||||
// have to load a single css file for Angular Material in your app.
|
|
||||||
// Be sure that you only ever include this mixin once!
|
|
||||||
@include mat.core();
|
|
||||||
|
|
||||||
// Define the palettes for your theme using the Material Design palettes available in palette.scss
|
|
||||||
// (imported above). For each palette, you can optionally specify a default, lighter, and darker
|
|
||||||
// hue. Available color palettes: https://material.io/design/color/
|
|
||||||
$ogWebconsole-primary: mat.define-palette(mat.$indigo-palette);
|
|
||||||
$ogWebconsole-accent: mat.define-palette(mat.$pink-palette, A200, A100, A400);
|
|
||||||
|
|
||||||
// The warn palette is optional (defaults to red).
|
|
||||||
$ogWebconsole-warn: mat.define-palette(mat.$red-palette);
|
|
||||||
|
|
||||||
// Create the theme object. A theme consists of configurations for individual
|
|
||||||
// theming systems such as "color" or "typography".
|
|
||||||
$ogWebconsole-theme: mat.define-light-theme((
|
|
||||||
color: (
|
|
||||||
primary: $ogWebconsole-primary,
|
|
||||||
accent: $ogWebconsole-accent,
|
|
||||||
warn: $ogWebconsole-warn,
|
|
||||||
),
|
|
||||||
typography: mat.define-typography-config(),
|
|
||||||
density: 0
|
|
||||||
));
|
|
||||||
|
|
||||||
// Include theme styles for core and each component used in your app.
|
|
||||||
// Alternatively, you can import and @include the theme mixins for each component
|
|
||||||
// that you are using.
|
|
||||||
@include mat.all-component-themes($ogWebconsole-theme);
|
|
||||||
|
|
|
@ -6,10 +6,8 @@
|
||||||
<base href="/">
|
<base href="/">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
|
|
||||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
|
||||||
</head>
|
</head>
|
||||||
<body class="mat-typography">
|
<body>
|
||||||
<app-root></app-root>
|
<app-root></app-root>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
import { bootstrapApplication } from '@angular/platform-browser';
|
|
||||||
import { AppComponent } from './app/app.component';
|
|
||||||
import { config } from './app/app.config.server';
|
|
||||||
|
|
||||||
const bootstrap = () => bootstrapApplication(AppComponent, config);
|
|
||||||
|
|
||||||
export default bootstrap;
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { bootstrapApplication } from '@angular/platform-browser';
|
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||||
import { appConfig } from './app/app.config';
|
|
||||||
import { AppComponent } from './app/app.component';
|
|
||||||
|
|
||||||
bootstrapApplication(AppComponent, appConfig)
|
import { AppModule } from './app/app.module';
|
||||||
.catch((err) => console.error(err));
|
|
||||||
|
|
||||||
|
platformBrowserDynamic().bootstrapModule(AppModule)
|
||||||
|
.catch(err => console.error(err));
|
||||||
|
|
|
@ -1,7 +1 @@
|
||||||
/* You can add global styles to this file, and also import other style files */
|
/* You can add global styles to this file, and also import other style files */
|
||||||
|
|
||||||
html, body { height: 100%;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
font-family: 'Roboto', sans-serif;
|
|
||||||
}
|
|
||||||
|
|
|
@ -3,14 +3,10 @@
|
||||||
"extends": "./tsconfig.json",
|
"extends": "./tsconfig.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "./out-tsc/app",
|
"outDir": "./out-tsc/app",
|
||||||
"types": [
|
"types": []
|
||||||
"node"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"src/main.ts",
|
"src/main.ts"
|
||||||
"src/main.server.ts",
|
|
||||||
"server.ts"
|
|
||||||
],
|
],
|
||||||
"include": [
|
"include": [
|
||||||
"src/**/*.d.ts"
|
"src/**/*.d.ts"
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
"compileOnSave": false,
|
"compileOnSave": false,
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "./dist/out-tsc",
|
"outDir": "./dist/out-tsc",
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"noImplicitOverride": true,
|
"noImplicitOverride": true,
|
||||||
"noPropertyAccessFromIndexSignature": true,
|
"noPropertyAccessFromIndexSignature": true,
|
||||||
|
|
Loading…
Reference in New Issue