Compare commits
4 Commits
login-dev
...
routing-fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72c1fe7f0b | ||
|
|
4e6d96432a | ||
|
|
c2ecfd9dee | ||
|
|
ba0f313770 |
@@ -33,7 +33,7 @@
|
|||||||
"src/assets/scss/black-dashboard.scss",
|
"src/assets/scss/black-dashboard.scss",
|
||||||
"src/assets/css/nucleo-icons.css"
|
"src/assets/css/nucleo-icons.css"
|
||||||
],
|
],
|
||||||
"scripts": [],
|
"scripts": []
|
||||||
},
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"production": {
|
"production": {
|
||||||
|
|||||||
17119
package-lock.json
generated
17119
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
54
src/app/app-routing.module copy.ts
Normal file
54
src/app/app-routing.module copy.ts
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import { NgModule } from "@angular/core";
|
||||||
|
import { CommonModule } from "@angular/common";
|
||||||
|
import { BrowserModule } from "@angular/platform-browser";
|
||||||
|
import { Routes, RouterModule } from "@angular/router";
|
||||||
|
import { LoginComponent } from "./pages/login/login.component";
|
||||||
|
import { AdminLayoutComponent } from "./layouts/admin-layout/admin-layout.component";
|
||||||
|
import { AuthLayoutComponent } from './layouts/auth-layout/auth-layout.component';
|
||||||
|
|
||||||
|
const routes: Routes = [
|
||||||
|
{
|
||||||
|
path: "login",
|
||||||
|
component: LoginComponent
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "",
|
||||||
|
redirectTo: "login",
|
||||||
|
pathMatch: "full"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "",
|
||||||
|
component: AdminLayoutComponent,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: "",
|
||||||
|
loadChildren: () => import ("./layouts/admin-layout/admin-layout.module").then(m => m.AdminLayoutModule)
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}, {
|
||||||
|
path: "",
|
||||||
|
component: AuthLayoutComponent,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: "",
|
||||||
|
loadChildren: () => import ("./layouts/auth-layout/auth-layout.module").then(m => m.AuthLayoutModule)
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "**",
|
||||||
|
redirectTo: "login"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
CommonModule,
|
||||||
|
BrowserModule,
|
||||||
|
RouterModule.forRoot(routes, {
|
||||||
|
useHash: true
|
||||||
|
})
|
||||||
|
],
|
||||||
|
exports: [RouterModule]
|
||||||
|
})
|
||||||
|
export class AppRoutingModule {}
|
||||||
@@ -1,20 +1,21 @@
|
|||||||
import { NgModule } from "@angular/core";
|
import { NgModule } from "@angular/core";
|
||||||
import { CommonModule } from "@angular/common";
|
import { CommonModule } from "@angular/common";
|
||||||
import { BrowserModule } from "@angular/platform-browser";
|
import { BrowserModule } from "@angular/platform-browser";
|
||||||
import { Routes, RouterModule } from "@angular/router";
|
import { Routes, RouterModule, Router } from "@angular/router";
|
||||||
import { LoginComponent } from "./pages/login/login.component";
|
import { LoginComponent } from "./pages/login/login.component";
|
||||||
import { AdminLayoutComponent } from "./layouts/admin-layout/admin-layout.component";
|
import { AdminLayoutComponent } from "./layouts/admin-layout/admin-layout.component";
|
||||||
import { AuthLayoutComponent } from './layouts/auth-layout/auth-layout.component';
|
import { AuthLayoutComponent } from "./layouts/auth-layout/auth-layout.component";
|
||||||
|
import { AuthService } from "./services/auth.service";
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{
|
{
|
||||||
path: "login",
|
path: "login",
|
||||||
component: LoginComponent
|
component: LoginComponent,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "",
|
path: "",
|
||||||
redirectTo: "company-information",
|
redirectTo: "login",
|
||||||
pathMatch: "full"
|
pathMatch: "full",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "",
|
path: "",
|
||||||
@@ -22,23 +23,30 @@ const routes: Routes = [
|
|||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: "",
|
path: "",
|
||||||
loadChildren: () => import ("./layouts/admin-layout/admin-layout.module").then(m => m.AdminLayoutModule)
|
loadChildren: () =>
|
||||||
}
|
import("./layouts/admin-layout/admin-layout.module").then(
|
||||||
]
|
(m) => m.AdminLayoutModule
|
||||||
}, {
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
path: "",
|
path: "",
|
||||||
component: AuthLayoutComponent,
|
component: AuthLayoutComponent,
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: "",
|
path: "",
|
||||||
loadChildren: () => import ("./layouts/auth-layout/auth-layout.module").then(m => m.AuthLayoutModule)
|
loadChildren: () =>
|
||||||
}
|
import("./layouts/auth-layout/auth-layout.module").then(
|
||||||
]
|
(m) => m.AuthLayoutModule
|
||||||
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "**",
|
path: "**",
|
||||||
redirectTo: "company-information"
|
redirectTo: "login",
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
@@ -46,9 +54,23 @@ const routes: Routes = [
|
|||||||
CommonModule,
|
CommonModule,
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
RouterModule.forRoot(routes, {
|
RouterModule.forRoot(routes, {
|
||||||
useHash: true
|
useHash: true,
|
||||||
})
|
}),
|
||||||
],
|
],
|
||||||
exports: [RouterModule]
|
exports: [RouterModule],
|
||||||
})
|
})
|
||||||
export class AppRoutingModule {}
|
export class AppRoutingModule {
|
||||||
|
companyLocalStorage: any;
|
||||||
|
|
||||||
|
constructor(private router: Router, private authService: AuthService) {
|
||||||
|
this.companyLocalStorage = localStorage.getItem("companyData");
|
||||||
|
|
||||||
|
console.log("this.companyLocalStorage, ", this.companyLocalStorage);
|
||||||
|
|
||||||
|
if (this.companyLocalStorage !== null) {
|
||||||
|
this.router.navigate(["company-information"]);
|
||||||
|
} else {
|
||||||
|
this.router.navigate(["login"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,10 +1,24 @@
|
|||||||
import { Component } from "@angular/core";
|
import { Component, OnInit } from "@angular/core";
|
||||||
|
import { Router } from "@angular/router";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-root",
|
selector: "app-root",
|
||||||
templateUrl: "./app.component.html",
|
templateUrl: "./app.component.html",
|
||||||
styleUrls: ["./app.component.scss"]
|
styleUrls: ["./app.component.scss"],
|
||||||
})
|
})
|
||||||
export class AppComponent {
|
export class AppComponent implements OnInit {
|
||||||
title = "black-dashboard-angular";
|
title = "Talenttic Tech Hub CRM";
|
||||||
|
companyLocalStorage: any;
|
||||||
|
|
||||||
|
constructor(private router: Router) {
|
||||||
|
this.companyLocalStorage = localStorage.getItem("companyData");
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
if (this.companyLocalStorage !== null) {
|
||||||
|
this.router.navigate(["company-information"]);
|
||||||
|
} else {
|
||||||
|
this.router.navigate(["login"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ export class NavbarComponent implements OnInit, OnDestroy {
|
|||||||
this.toastr.success("Logout Successfully");
|
this.toastr.success("Logout Successfully");
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.router.navigate(["login"]);
|
this.router.navigate(["/login"]);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Component, OnInit } from "@angular/core";
|
import { Component, OnInit } from "@angular/core";
|
||||||
|
import { Router } from "@angular/router";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-admin-layout",
|
selector: "app-admin-layout",
|
||||||
@@ -7,8 +8,9 @@ import { Component, OnInit } from "@angular/core";
|
|||||||
})
|
})
|
||||||
export class AdminLayoutComponent implements OnInit {
|
export class AdminLayoutComponent implements OnInit {
|
||||||
public sidebarColor: string = "red";
|
public sidebarColor: string = "red";
|
||||||
|
companyLocalStorage: any;
|
||||||
|
|
||||||
constructor() {}
|
constructor(private router: Router) {}
|
||||||
changeSidebarColor(color){
|
changeSidebarColor(color){
|
||||||
var sidebar = document.getElementsByClassName('sidebar')[0];
|
var sidebar = document.getElementsByClassName('sidebar')[0];
|
||||||
var mainPanel = document.getElementsByClassName('main-panel')[0];
|
var mainPanel = document.getElementsByClassName('main-panel')[0];
|
||||||
@@ -31,5 +33,13 @@ export class AdminLayoutComponent implements OnInit {
|
|||||||
body.classList.remove('white-content');
|
body.classList.remove('white-content');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ngOnInit() {}
|
ngOnInit() {
|
||||||
|
this.companyLocalStorage = JSON.parse(localStorage.getItem('companyData') || "{}")
|
||||||
|
|
||||||
|
if(this.companyLocalStorage) {
|
||||||
|
this.router.navigate(['/company-information'])
|
||||||
|
} else {
|
||||||
|
this.router.navigate(['/login'])
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,10 +8,8 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="text-align: center; margin-bottom: 3rem;">
|
<div style="text-align: center; margin-bottom: 3rem">
|
||||||
<h1>
|
<h1>TALENTTIC TECH HUB CRM</h1>
|
||||||
TALENTTIC TECH HUB CRM
|
|
||||||
</h1>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ng-container *ngIf="loginSuccess">
|
<ng-container *ngIf="loginSuccess">
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { Component, OnInit } from "@angular/core";
|
|||||||
import { FormGroup, FormBuilder, Validators } from "@angular/forms";
|
import { FormGroup, FormBuilder, Validators } from "@angular/forms";
|
||||||
import { ActivatedRoute, Router } from "@angular/router";
|
import { ActivatedRoute, Router } from "@angular/router";
|
||||||
import { CompanyService } from "../../services/company.service";
|
import { CompanyService } from "../../services/company.service";
|
||||||
|
import { AuthService } from "../../services/auth.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-login",
|
selector: "app-login",
|
||||||
@@ -21,6 +22,7 @@ export class LoginComponent implements OnInit {
|
|||||||
constructor(
|
constructor(
|
||||||
private fb: FormBuilder,
|
private fb: FormBuilder,
|
||||||
private companyService: CompanyService,
|
private companyService: CompanyService,
|
||||||
|
private authService: AuthService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private route: ActivatedRoute
|
private route: ActivatedRoute
|
||||||
) {
|
) {
|
||||||
@@ -32,13 +34,9 @@ export class LoginComponent implements OnInit {
|
|||||||
password: ["", [Validators.required, Validators.minLength(6)]],
|
password: ["", [Validators.required, Validators.minLength(6)]],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.companyService.getCompanyById(1).subscribe((company) => {
|
||||||
|
this.company = company;
|
||||||
this.companyService
|
});
|
||||||
.getCompanyById(1)
|
|
||||||
.subscribe((company) => {
|
|
||||||
this.company = company;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get formControls() {
|
get formControls() {
|
||||||
@@ -53,14 +51,14 @@ export class LoginComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
signin() {
|
signin() {
|
||||||
const email = this.company.email;
|
|
||||||
const password = this.company.password;
|
|
||||||
|
|
||||||
if (this.loginForm.invalid) {
|
if (this.loginForm.invalid) {
|
||||||
console.log("Form error");
|
console.log("Form error");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const email = this.company.email;
|
||||||
|
const password = this.company.password;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.loginForm.value.companyEmail !== email ||
|
this.loginForm.value.companyEmail !== email ||
|
||||||
this.loginForm.value.password !== password
|
this.loginForm.value.password !== password
|
||||||
@@ -78,10 +76,19 @@ export class LoginComponent implements OnInit {
|
|||||||
localStorage.getItem("companyData") || "{}"
|
localStorage.getItem("companyData") || "{}"
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.companyLocalStorage) {
|
const isLoggedIn = this.authService.login(
|
||||||
|
this.loginForm.value.companyEmail,
|
||||||
|
this.loginForm.value.password
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isLoggedIn) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.router.navigate(["/company-information"]);
|
this.router.navigate(["company-information"]);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
|
console.log(true);
|
||||||
|
} else {
|
||||||
|
this.router.navigate(["/login"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loginForm.reset();
|
this.loginForm.reset();
|
||||||
|
|||||||
40
src/app/services/auth.service.ts
Normal file
40
src/app/services/auth.service.ts
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import { Injectable } from "@angular/core";
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: "root",
|
||||||
|
})
|
||||||
|
export class AuthService {
|
||||||
|
private isLoggedIn: boolean = false;
|
||||||
|
companyLocalStorage: any;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.companyLocalStorage = JSON.parse(
|
||||||
|
localStorage.getItem("companyData") || "{}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
login(email: string, password: string): boolean {
|
||||||
|
// Implement login logic here
|
||||||
|
// Sets isLoggedIn to true if email and password satisfy conditions
|
||||||
|
if (email.length > 6 && email.includes("@") && password.length > 4) {
|
||||||
|
this.isLoggedIn = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
logout(): void {
|
||||||
|
// Implement your logout logic here
|
||||||
|
this.isLoggedIn = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
isLoggedInMethod(): boolean {
|
||||||
|
if (this.companyLocalStorage) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// return this.isLoggedIn;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -163,7 +163,7 @@
|
|||||||
}
|
}
|
||||||
.form-control[disabled], .form-control[readonly], fieldset[disabled] .form-control {
|
.form-control[disabled], .form-control[readonly], fieldset[disabled] .form-control {
|
||||||
background-color: $black-states;
|
background-color: $black-states;
|
||||||
color: $default;
|
color: #999;
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user