Commit 7160043b authored by achinta's avatar achinta

feat: project init

parent 706032e1
# See http://help.github.com/ignore-files/ for more about ignoring files.
# Compiled output
/dist
/tmp
/out-tsc
/bazel-out
# Node
/node_modules
npm-debug.log
yarn-error.log
# IDEs and editors
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*
# Miscellaneous
/.angular/cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
testem.log
/typings
# System files
.DS_Store
Thumbs.db
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"nkda": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:application",
"options": {
"outputPath": "dist/nkda",
"index": "src/index.html",
"browser": "src/main.ts",
"polyfills": [
"zone.js"
],
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"@angular/material/prebuilt-themes/deeppurple-amber.css",
"src/styles.scss"
],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"outputHashing": "all"
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"buildTarget": "nkda:build:production"
},
"development": {
"buildTarget": "nkda:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"buildTarget": "nkda:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"polyfills": [
"zone.js",
"zone.js/testing"
],
"tsConfig": "tsconfig.spec.json",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"@angular/material/prebuilt-themes/deeppurple-amber.css",
"src/styles.scss"
],
"scripts": []
}
}
}
}
},
"cli": {
"analytics": false
}
}
This diff is collapsed.
{
"name": "nkda",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
"private": true,
"dependencies": {
"@angular/cdk": "^19.1.3",
"@angular/common": "^19.1.4",
"@angular/compiler": "^19.1.4",
"@angular/core": "^19.1.4",
"@angular/forms": "^19.1.4",
"@angular/material": "^19.1.3",
"@angular/platform-browser": "^19.1.4",
"@angular/platform-browser-dynamic": "^19.1.4",
"@angular/router": "^19.1.4",
"@canvasjs/angular-charts": "^1.2.0",
"@canvasjs/charts": "^3.8.8",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.15.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^19.1.6",
"@angular/cli": "^19.1.6",
"@angular/compiler-cli": "^19.1.4",
"@types/jasmine": "~5.1.0",
"jasmine-core": "~5.1.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"typescript": "~5.7.3"
}
}
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AccessDeniedComponent } from './access-denied.component';
describe('AccessDeniedComponent', () => {
let component: AccessDeniedComponent;
let fixture: ComponentFixture<AccessDeniedComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [AccessDeniedComponent]
})
.compileComponents();
fixture = TestBed.createComponent(AccessDeniedComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component } from '@angular/core';
@Component({
selector: 'app-access-denied',
imports: [],
templateUrl: './access-denied.component.html',
styleUrl: './access-denied.component.scss'
})
export class AccessDeniedComponent {
}
<!-- <button (click)="login()">Login</button> <button (click)="logout()">logout</button>
<br/>
<button [routerLink]="['portal']">dashboard</button> <button [routerLink]="['ad']">access denied</button>
<button (click)="toggleTheme()">Toggle Theme</button> -->
<router-outlet />
import { TestBed } from '@angular/core/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [AppComponent],
}).compileComponents();
});
it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app).toBeTruthy();
});
it(`should have the 'nkda' title`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app.title).toEqual('nkda');
});
it('should render title', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, nkda');
});
});
import { Component, Inject, OnInit, PLATFORM_ID } from '@angular/core';
import { Router, RouterModule, RouterOutlet } from '@angular/router';
import { RequestMapperService } from './mappers/request-mapper.service';
import { InitThemeService } from './style-guide/service/initialize-theme.service';
import { isPlatformBrowser } from '@angular/common';
@Component({
selector: 'app-root',
imports: [RouterOutlet, RouterModule],
templateUrl: './app.component.html',
styleUrl: './app.component.scss'
})
export class AppComponent implements OnInit{
public isBrowser: boolean = false;
constructor(
private _themeService: InitThemeService,
@Inject(PLATFORM_ID) private _platformId: Object
) {
this.isBrowser = isPlatformBrowser(this._platformId);
this._themeService.init();
}
public ngOnInit(): void {
}
}
import { ApplicationConfig } from '@angular/core';
import { provideRouter } from '@angular/router';
import { routes } from './app.routes';
import { provideHttpClient } from '@angular/common/http';
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
export const appConfig: ApplicationConfig = {
providers: [
provideRouter(routes),
provideHttpClient(), provideAnimationsAsync()
]
};
import { Routes } from '@angular/router';
import { RequestMapperService } from './mappers/request-mapper.service';
import { verifyRoleGuard } from './auth/guard/verify-role.guard';
import { authGuard } from './auth/guard/auth.guard';
import { Submenu } from './portal/navigation/model/sidebar/submenu';
import { RoleMapperService } from './mappers/role-mapper.service';
export const routes: Routes = [
{
path: RequestMapperService.STYLE_GUIDE,
loadComponent: () =>
import('./style-guide/style-guide/style-guide.component').then((m) => m.StyleGuideComponent),
data: { roles: [] },
children: [
{
path: RequestMapperService.BASE_RELATIVE_URL,
loadChildren: () =>
import('./style-guide/style-guide.routes')
.then(r => r.STYLE_GUIDE_ROTES)
},
]
},
{
path: RequestMapperService.LOGIN_URL,
loadComponent: () =>
import('./auth/login/login.component').then((m) => m.LoginComponent),
data: { roles: [] },
},
{
path: RequestMapperService.ACCESS_DENIED_URL,
loadComponent: () =>
import(
'./access-denied-preview/access-denied/access-denied.component'
).then((m) => m.AccessDeniedComponent),
data: { roles: [] },
},
{
path: RequestMapperService.BASE_RELATIVE_URL,
redirectTo: RequestMapperService.PORTAL_URL,
pathMatch: 'full',
},
{
path: RequestMapperService.PORTAL_URL,
loadComponent: () =>
import('./portal/portal/portal.component').then(
(m) => m.PortalComponent
),
canActivate: [authGuard],
data: { roles: RoleMapperService.getAllRole },
children: [
{
path: RequestMapperService.BASE_RELATIVE_URL,
redirectTo: RequestMapperService.DASHBOARD_URL,
pathMatch: 'full',
},
{
path: RequestMapperService.DASHBOARD_URL,
loadComponent: () =>
import('./portal/portal-dashboard/portal-dashboard.component').then(
(m) => m.PortalDashboardComponent
),
data: { roles: [RoleMapperService.TEACHER_ROLE, RoleMapperService.STUDENT_ROLE] },
canActivate: [verifyRoleGuard],
},
],
},
];
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();
});
});
import { inject } from '@angular/core';
import { ActivatedRouteSnapshot, CanActivateFn, Router, RouterStateSnapshot } from '@angular/router';
import { RequestMapperService } from '../../mappers/request-mapper.service';
export const authGuard: CanActivateFn = (
route: ActivatedRouteSnapshot, state: RouterStateSnapshot
) => {
const router: Router = inject(Router);
const isLoggedIn: string | null = localStorage.getItem('Bearer');
// return true;
if(isLoggedIn) return true;
else{
router.navigate([RequestMapperService.LOGIN_URL]);
return false;
}
};
import { TestBed } from '@angular/core/testing';
import { CanActivateFn } from '@angular/router';
import { verifyRoleGuard } from './verify-role.guard';
describe('verifyRoleGuard', () => {
const executeGuard: CanActivateFn = (...guardParameters) =>
TestBed.runInInjectionContext(() => verifyRoleGuard(...guardParameters));
beforeEach(() => {
TestBed.configureTestingModule({});
});
it('should be created', () => {
expect(executeGuard).toBeTruthy();
});
});
import { inject } from '@angular/core';
import { ActivatedRouteSnapshot, CanActivateFn, Router, RouterStateSnapshot } from '@angular/router';
import { AuthService } from '../service/auth.service';
import { RequestMapperService } from '../../mappers/request-mapper.service';
export const verifyRoleGuard: CanActivateFn = (
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot
) => {
const router: Router = inject(Router);
const requiredRoles: string[] = route.data['roles'] as string[];
const userRole: string = localStorage.getItem('role')||'';
console.log('requiredRoles=>',requiredRoles);
console.log('userRole=>',userRole);
// return true;
if( userRole && isRoleValid(requiredRoles, userRole) ) return true;
else {
router.navigate([
// RequestMapperService.PORTAL_URL+ '/' +RequestMapperService.DASHBOARD_URL
RequestMapperService.LOGIN_URL
]);
return false;
}
};
const isRoleValid = ( requiredRoles: string[], userRole: string ): boolean => {
let isUserRoleValid = false;
let roles: string[] = userRole.split(',');
if(requiredRoles.length === 0) return isUserRoleValid = true;
else {
for(let m = 0; m < roles.length; m++) {
let roleMatched: boolean = false;
for(let i = 0; i < requiredRoles.length; i++) {
if(roles[m].toLocaleLowerCase().trim() === requiredRoles[i].toLocaleLowerCase()) {
isUserRoleValid = true;
roleMatched = true;
break;
}
else roleMatched = false;
}
if(roleMatched) break
}
}
return isUserRoleValid;
}
export interface Auth {
email: string;
password: string;
}
export interface UserProfile {
apiKey: string;
name: string;
project_id: number;
role_name: string;
user_id: number;
user_type: string;
username: string;
}
<div class="login_outer">
<div class="phone_section">
<img class="login_logo"
[ngSrc]="'./assets/image/login_logo.png'"
alt="Logo"
width="100"
height="100"
/>
<h5>Welcome</h5>
<p>Enter your mobile number to recieve a one time passcode</p>
<form class="login_form" [formGroup]="loginForm">
<div class="mat_input_container">
<mat-form-field class="full_width">
<span class="material-symbols-outlined" matPrefix>
person
</span>
<input
matInput
placeholder="{{ 'Enter user name' }}"
#input
formControlName="email"
/>
</mat-form-field>
<ng-container *ngIf="loginForm.controls.email.invalid && loginForm.controls.email.dirty || loginForm.controls.email.invalid && loginForm.controls.email.touched">
<span class="error_text" *ngIf="loginForm.controls.email.hasError('required')">This field is required
</span>
</ng-container>
</div>
<div class="mat_input_container">
<mat-form-field class="full_width">
<span class="material-symbols-outlined" matPrefix> lock </span>
<input
matInput
placeholder="{{ 'Enter password' }}"
[type]="hidePassword ? 'password' : 'text'"
formControlName="password"
/>
<span class="material-symbols-outlined pointer" matSuffix (click)="hidePassword = !hidePassword">
{{ hidePassword ? "visibility_off" : "visibility" }}
</span>
<!-- <mat-hint *ngIf="!passwordInput.value">Enter your password</mat-hint> -->
</mat-form-field>
<ng-container *ngIf="loginForm.controls.password.invalid && loginForm.controls.password.dirty || loginForm.controls.password.invalid && loginForm.controls.password.touched">
<span class="error_text" *ngIf="loginForm.controls.password.hasError('required')">Password is required
</span>
</ng-container>
</div>
<app-rounded-button-full-width
[buttonText]="'Sign in'"
[buttonIconName]="'login'"
[enableThrottling]="true"
(onClickEventEmitter)="authenticate()"
/>
</form>
<div class="error_txt" *ngIf="errorMessage">
<!-- <span class="api_error_message">{{errorMessage}}</span> -->
<span class="api_error_message">fdgsgs</span>
</div>
</div>
</div>
.login_outer {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
.phone_section{
padding: 20px;
}
}
.login_wrapper {
display: flex;
justify-content: center;
align-items: center;
height: 550px;
.main_content {
width: 50%;
}
.img_section {
width: 50%;
align-self: stretch;
}
.img_content {
background-image: url("/assets/image/login_img.png");
height: 100%;
width: 100%;
background-repeat: no-repeat;
border-radius: 30px;
background-position: center;
background-size: cover;
}
}
.login_wrapper::ng-deep {
.mat-mdc-form-field-icon-prefix {
padding-right: 10px;
}
.mdc-text-field--filled:not(.mdc-text-field--disabled) .mdc-line-ripple::before {
border-bottom-color: rgb(179 171 171 / 42%);
}
.mdc-text-field--filled:not(.mdc-text-field--disabled) .mdc-line-ripple::after {
background: var(--accent-color);
}
.mat-mdc-text-field-wrapper {
background: var(--secondary-bg-color);
color: var(--primary-color);
padding-left: 16px;
padding-right: 10px;
input {
color: var(--primary-color);
&::placeholder {
color: var(--primary-color);
}
}
}
}
.api_error_message {
text-align: center;
display: block;
}
.mat_input_container {
position: relative;
margin-bottom: 10px;
.error_text {
position: absolute;
width: 100%;
margin-top: -10px;
margin-bottom: 10px;
left: 0;
bottom: -7px;
}
}
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { LoginComponent } from './login.component';
describe('LoginComponent', () => {
let component: LoginComponent;
let fixture: ComponentFixture<LoginComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [LoginComponent]
})
.compileComponents();
fixture = TestBed.createComponent(LoginComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { CommonModule, NgOptimizedImage, isPlatformBrowser } from '@angular/common';
import { Component, Inject, PLATFORM_ID } from '@angular/core';
import { Router, RouterModule } from '@angular/router';
import { RequestMapperService } from '../../mappers/request-mapper.service';
import { RoundedButtonComponent } from '../../component-library/rounded-button/rounded-button.component';
import { RoundedButtonFullWidthComponent } from '../../component-library/rounded-button-full-width/rounded-button-full-width.component';
import { AuthTransmissionService } from '../../raintree/transmission/auth-transmission.service';
import { TransmissionMapperService } from '../../mappers/transmission-mapper.service';
import { RaintreeResponse } from '../../raintree/interface/raintree-response';
import { Auth } from '../interface/auth';
import { AuthService } from '../service/auth.service';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { AbstractControl, FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
import { TransmissionMessageHandlerService } from '../../raintree/transmission-message-handler/transmission-message-handler';
import { UserProfileResponse } from '../../raintree/interface/user-profile-response';
import { UserProfile } from '../interface/user-profile';
import { ToasterService } from '../../component-library/toaster/toaster.service';
@Component({
selector: 'app-login',
imports: [
NgOptimizedImage,
RouterModule,
// RoundedButtonComponent,
RoundedButtonFullWidthComponent,
MatFormFieldModule,
MatInputModule,
CommonModule,
ReactiveFormsModule
],
templateUrl: './login.component.html',
styleUrl: './login.component.scss'
})
export class LoginComponent {
public errorMessage: string = '';
constructor(
private _toaster:ToasterService,
private _authService: AuthService,
private _authTransmissionService: AuthTransmissionService,
private _transmissionMessageHandler: TransmissionMessageHandlerService) {
}
public hidePassword: boolean = true;
public loginForm = new FormGroup({
email: new FormControl('', [Validators.required]),
password: new FormControl('', [Validators.required]),
});
public authenticate(): void {
if (this.loginForm.invalid) return;
let loginFormPayload: Auth = this.loginForm.value as Auth;
this._authTransmissionService.getAuthToken(
TransmissionMapperService.LOGIN_TRANSMISSION_URL,
loginFormPayload,
() => { },
() => { },
(response: RaintreeResponse) => {
if (this._transmissionMessageHandler.hasError(response)) {
this.errorMessage = response['message'];
console.log(this.errorMessage);
return;
};
this._authService.storeJwtTokenInLocalStorage(response['data'].apiKey);
// this._getUserProfile();
this._authService.prepareLoginProcess(response['data']);
this._toaster.success('Successfully Logged in','Done')
},
() => {
// localStorage.setItem('Bearer', '');
this._authService.prepareLoginProcess({} as UserProfile);
},
() => { }
);
}
private _getUserProfile(): void {
this._authTransmissionService.getUserProfile(
TransmissionMapperService.USER_PROFILE_TRANSMISSION_URL,
() => { },
(response) => { },
(response: UserProfile) => {
if (!response) {
this.errorMessage = 'something went wrong';
return;
};
this._authService.prepareLoginProcess(response);
},
() => { }, () => { }
)
}
}
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { OtpVerificationComponent } from './otp-verification.component';
describe('OtpVerificationComponent', () => {
let component: OtpVerificationComponent;
let fixture: ComponentFixture<OtpVerificationComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [OtpVerificationComponent]
})
.compileComponents();
fixture = TestBed.createComponent(OtpVerificationComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component } from '@angular/core';
@Component({
selector: 'app-otp-verification',
imports: [],
templateUrl: './otp-verification.component.html',
styleUrl: './otp-verification.component.scss'
})
export class OtpVerificationComponent {
}
import { Inject, Injectable, PLATFORM_ID } from '@angular/core';
import { UserProfile } from '../interface/user-profile';
import { isPlatformBrowser } from '@angular/common';
import { Router } from '@angular/router';
import { RequestMapperService } from '../../mappers/request-mapper.service';
@Injectable({
providedIn: 'root'
})
export class AuthService {
public isBrowser: boolean = false;
constructor(
private _router: Router,
@Inject(PLATFORM_ID) private _platformId: Object) {
this.isBrowser = isPlatformBrowser(this._platformId);
}
public storeJwtTokenInLocalStorage(jwtToken: string): void {
localStorage.setItem('Bearer', jwtToken);
}
public prepareLoginProcess(userProfileData: UserProfile): void {
console.log(userProfileData);
this._setProfileInformationInLocalStorage(userProfileData);
if (this.isBrowser) {
localStorage.setItem('isLoggedIn', 'true');
localStorage.setItem('role', userProfileData.role_name);
// localStorage.setItem('role','FO,accountant'); //TODO: for testing
this._router.navigate([RequestMapperService.PORTAL_URL]);
}
}
private _setProfileInformationInLocalStorage(userProfileData: UserProfile): void {
// console.log(jwtToken);
localStorage.setItem('userProfile', JSON.stringify(userProfileData));
}
}
<div class="log_viewer_component">
<div class="log_col full_width">
<app-page-heading [title]="'Audit Log Details'"/>
</div>
<div class="log_col">
<h3>ID</h3>
<p>{{data.id}}</p>
</div>
<div class="log_col">
<h3>User Id</h3>
<p>{{data.user_id}}</p>
</div>
<div class="log_col">
<h3>User Name</h3>
<p>{{data.user_name}}</p>
</div>
<div class="log_col">
<h3>Created At</h3>
<p>{{data.created_at}}</p>
</div>
<div class="log_col">
<h3>IP Address</h3>
<p>{{data.ip_address}}</p>
</div>
<div class="log_col full_width">
<h3>endpoint</h3>
<p>{{temp(data.request_payload)}}</p>
</div>
<div class="log_col full_width">
<h3>Notes</h3>
<p>{{temp(data.request_payload) }}</p>
</div>
</div>
.log_viewer_component {
display: flex;
flex-wrap: wrap;
padding: 20px;
background-color: var(--primary-bg-color);
color: var(--primary-color);
.log_col {
width: 20%;
h3 {
font-size: 14px;
}
&.full_width {
width: 100%;
}
}
}
.mat-mdc-dialog-surface::ng-deep {
background: var(--secondary-bg-color) !important;
}
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AuditLogDetailsComponent } from './audit-log-details.component';
describe('AuditLogDetailsComponent', () => {
let component: AuditLogDetailsComponent;
let fixture: ComponentFixture<AuditLogDetailsComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [AuditLogDetailsComponent]
})
.compileComponents();
fixture = TestBed.createComponent(AuditLogDetailsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA, MatDialogActions, MatDialogClose, MatDialogContent, MatDialogTitle } from '@angular/material/dialog';
import { AuditLog } from '../interface/audit-log';
import { PageHeadingComponent } from '../../page-heading/page-heading.component';
@Component({
selector: 'app-audit-log-details',
imports: [
// MatDialogTitle,
// MatDialogContent,
// MatDialogActions,
// MatDialogClose,
PageHeadingComponent
],
templateUrl: './audit-log-details.component.html',
styleUrl: './audit-log-details.component.scss'
})
export class AuditLogDetailsComponent {
constructor(
private _dialogRef: MatDialogRef<AuditLogDetailsComponent>,
@Inject(MAT_DIALOG_DATA) public data: AuditLog,
) {}
public onNoClick(): void {
this._dialogRef.close(this.data);
}
public ngOnInit(): void {
console.log(this.data)
}
public temp(request_payload: any): any {
return JSON.stringify(request_payload, null, 2);
}
}
<app-page-heading [title]="'Audit Log'" />
<app-filter-with-export-and-print
[placeholder]="'Ex: User ID, User Name'"
(inputData)="applyFilter($event)"
[dropDownData]="endPoints"
(emitDropDownData)="selectDropdownFromFilter($event)"
></app-filter-with-export-and-print>
<table mat-table [dataSource]="dataSource">
<!-- ID Column -->
<ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef>ID</th>
<td mat-cell *matCellDef="let log" data-label="id">
{{ log.id }}
</td>
</ng-container>
<!-- User ID Column -->
<ng-container matColumnDef="user_id">
<th mat-header-cell *matHeaderCellDef>User ID</th>
<td mat-cell *matCellDef="let log">{{ log.user_id }}</td>
</ng-container>
<!-- User Name Column -->
<ng-container matColumnDef="user_name">
<th mat-header-cell *matHeaderCellDef>User Name</th>
<td mat-cell *matCellDef="let log">{{ log.user_name }}</td>
</ng-container>
<!-- IP Address Column -->
<ng-container matColumnDef="ip_address">
<th mat-header-cell *matHeaderCellDef>IP Address</th>
<td mat-cell *matCellDef="let log">{{ log.ip_address }}</td>
</ng-container>
<!-- Method Column -->
<ng-container matColumnDef="method">
<th mat-header-cell *matHeaderCellDef>Method</th>
<td mat-cell *matCellDef="let log">{{ log.method }}</td>
</ng-container>
<!-- Created Column -->
<ng-container matColumnDef="created_at">
<th mat-header-cell *matHeaderCellDef>Created</th>
<td mat-cell *matCellDef="let log">{{ log.created_at }}</td>
</ng-container>
<!-- CTA Column -->
<ng-container matColumnDef="action">
<th mat-header-cell *matHeaderCellDef>Action</th>
<td mat-cell *matCellDef="let log">
<button (click)="openDialog(log)" class="view_button">
<span class="material-symbols-outlined"> visibility </span>
</button>
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
</table>
<mat-paginator
[length]="totalItems"
[pageSize]="pageSize"
showFirstLastButtons
[pageSizeOptions]="[5, 10, 20]"
(page)="pageChanged($event)"
*ngIf="dataSource && dataSource.data.length"
#paginator
></mat-paginator>
// .mat-mdc-table::ng-deep {
// background: var(--secondary-bg-color);
// box-shadow: var(--box-shadow-small);
// font-family: var(--font-light);
// .mat-mdc-header-row {
// background: var(--accent-color);
// border: none;
// color: white;
// }
// .mdc-data-table__content{
// td {
// color: var(--primary-color);
// border-bottom: 1px solid var(--border-color);
// }
// .mdc-data-table__row:last-child .mat-mdc-cell {
// border-bottom: none;
// }
// }
// }
// .view_button {
// all: unset;
// display: block;
// text-align: center;
// width: 100%;
// cursor: pointer;
// }
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AuditLogComponent } from './audit-log.component';
describe('AuditLogComponent', () => {
let component: AuditLogComponent;
let fixture: ComponentFixture<AuditLogComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [AuditLogComponent]
})
.compileComponents();
fixture = TestBed.createComponent(AuditLogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { AfterViewInit, Component, Input, OnInit, ViewChild } from '@angular/core';
import { MatTableDataSource, MatTableModule } from '@angular/material/table';
import { AuditLog } from '../interface/audit-log';
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
import { AuditLogDetailsComponent } from '../audit-log-details/audit-log-details.component';
import { MatPaginator, MatPaginatorModule, PageEvent } from '@angular/material/paginator';
import { PipeModule } from '../../../pipe/pipe.module';
import { FilterWithExportAndPrintComponent } from '../../filter-with-export-and-print/filter-with-export-and-print.component';
import { PageHeadingComponent } from '../../page-heading/page-heading.component';
import { MatModalConfig } from '../model/mat-modal-config';
import { AuditLogTransmissionService } from '../../../raintree/transmission/audit-log-transmission.service';
import { TransmissionMapperService } from '../../../mappers/transmission-mapper.service';
import { CommonModule } from '@angular/common';
import { Dropdown } from '../../dropdown/interface/dropdown';
import { PaginationComponent } from '../../pagination/pagination/pagination.component';
@Component({
selector: 'app-audit-log',
imports: [
MatTableModule,
PageHeadingComponent,
PipeModule,
MatDialogModule,
MatPaginatorModule,
FilterWithExportAndPrintComponent,
CommonModule,
// PaginationComponent
],
templateUrl: './audit-log.component.html',
styleUrls: [
'../../../style-guide/css/table-theme.scss'
]
})
export class AuditLogComponent implements AfterViewInit, OnInit{
@ViewChild(MatPaginator) private paginator!: MatPaginator;
@Input() public logs: AuditLog[] = [];
@Input() public endPoints: Dropdown[] = [];
public displayedColumns: string[] = ['id', 'user_id', 'user_name', 'ip_address', 'method', 'created_at', 'action'];
public dataSource: MatTableDataSource<AuditLog> = {} as MatTableDataSource<AuditLog>;
public pageSize: number = 5;
public pageNumber: number = 1;
public totalItems = 0;
constructor(
private _dialog: MatDialog,
private _auditLogTransmission: AuditLogTransmissionService
) {
this.dataSource = new MatTableDataSource(this.logs);
}
public openDialog(log: AuditLog): void {
this._dialog.open(AuditLogDetailsComponent, {
data: log,
...MatModalConfig.getLogConfig
});
}
public ngOnInit(): void {
this._getLogCount(this.endPoints[0].value, this.pageNumber, this.pageSize);
}
public ngAfterViewInit(): void {
this.dataSource.paginator = this.paginator;
}
public applyFilter(filterString: string): void {
this.dataSource.filter = filterString.trim().toLowerCase();
if (this.dataSource.paginator) {
this.dataSource.paginator.firstPage();
}
}
private _getLogs(endPoint: string, pageNumber: number, pageSize: number): void {
this._auditLogTransmission.getLogs(
TransmissionMapperService.AUDIT_LOG_TRANSMISSION_URL+`?endpoint=${endPoint}&page=${pageNumber?pageNumber:1}&page_size=${pageSize}`,
()=> {},
()=> {},
(response)=> { //success
this.logs = response;
this.dataSource = new MatTableDataSource(this.logs);
},
()=> {}, //failure
()=> {},
);
}
private _getLogCount(endPoint: string, pageNumber: number, pageSize: number): void {
this._auditLogTransmission.getLogCount(
TransmissionMapperService.AUDIT_LOG_COUNT_TRANSMISSION_URL+`?endpoint=${endPoint}&page=${pageNumber?pageNumber:1}&page_size=${pageSize}`,
()=> {},
()=> {},
(response)=> { //success
this.totalItems = response.count;
this._getLogs(endPoint, pageNumber, pageSize);
},
()=> {}, //failure
()=> {},
);
}
public selectDropdownFromFilter(selectedData: string): void {
let endpoint: string = encodeURIComponent(selectedData);
// this.paginator.firstPage();
this._getLogCount(endpoint, 1, this.pageSize);
}
public pageChanged(event: PageEvent) : void {
this.pageSize = event.pageSize;
this.pageNumber = event.pageIndex + 1;
this._getLogCount(this.endPoints[0].value, this.pageNumber, this.pageSize);
}
}
export interface AuditLogConfig {
width: string,
height: string,
maxWidth: string,
maxHeight: string,
}
export interface AuditLog {
id: number,
user_id: number,
user_name: string,
ip_address: string,
endpoint: string,
method: string,
request_payload: any,
query_params: any,
created_at: string
}
export interface ResponseCount {
count: number
}
import { ChartsOfAccountLog } from './charts-of-account-log';
describe('ChartsOfAccountLog', () => {
it('should create an instance', () => {
expect(new ChartsOfAccountLog()).toBeTruthy();
});
});
import { AuditLog } from "../interface/audit-log";
export class ChartsOfAccountLog {
private static readonly _log1: AuditLog = {
id: 1,
user_id: 123,
user_name: 'Deep Dey',
ip_address: '103.220.209.138',
endpoint: '/nkda/v1/user/get',
method: 'POST',
request_payload: {
key1: 'value1',
key2: 'value2',
key3: 'value3',
key4: 'value4',
},
query_params: {
key1: 'value1',
key2: 'value2',
key3: 'value3',
key4: 'value4',
},
created_at: '20-5-2024'
}
private static readonly _logItems : AuditLog[] = [
ChartsOfAccountLog._log1,
ChartsOfAccountLog._log1,
ChartsOfAccountLog._log1,
ChartsOfAccountLog._log1,
ChartsOfAccountLog._log1,
ChartsOfAccountLog._log1,
];
public static get getLogItems(): AuditLog[] {
return ChartsOfAccountLog._logItems;
}
}
import { AuditLogConfig } from "../interface/audit-log-config";
export class MatModalConfig {
private static readonly _config: AuditLogConfig = {
width: '98vw',
height: 'auto',
maxWidth: '70vw',
maxHeight: '70vh',
}
public static get getLogConfig(): AuditLogConfig {
return MatModalConfig._config;
}
}
<div class="for_export_and_print_button_cont">
<ng-container *ngFor="let tab of tabList; let i = index">
<app-square-button
[buttonText]="tab"
[buttonIcon]="'export_notes'"
(emitSquareButtonClick)="tabClick(tab)"
/>
</ng-container>
</div>
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CoaTabsComponent } from './coa-tabs.component';
describe('CoaTabsComponent', () => {
let component: CoaTabsComponent;
let fixture: ComponentFixture<CoaTabsComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [CoaTabsComponent]
})
.compileComponents();
fixture = TestBed.createComponent(CoaTabsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component } from '@angular/core';
import { SquareButtonComponent } from '../square-button/square-button.component';
import { CommonModule } from '@angular/common';
@Component({
selector: 'app-coa-tabs',
imports: [SquareButtonComponent, CommonModule],
templateUrl: './coa-tabs.component.html',
styleUrl: './coa-tabs.component.scss'
})
export class CoaTabsComponent {
public tabList: string[] = [
'Income',
'Expense',
'Assets',
'Liabilities',
'Equity',
];
tabClick(eachTab: string) {
alert(eachTab);
}
}
<div class="colored_card">
<p class="cardTextOneHeading">{{cardTextOneHeading}}</p>
<p class="cardTextOne">{{cardTextOne}}</p>
<p class="cardTextTwoHeading">{{cardTextTwoHeading}}</p>
<p class="cardTextTwo">{{cardTextTwo}}</p>
<img [ngSrc]="CardImage" width="100" height="100"/>
</div>
.colored_card{
background: var(--accent-gradient);
border-radius: 16px;
position: relative;
padding: 20px 30px;
overflow: hidden;
box-shadow: var(--box-shadow-small);
p {
color: white;
margin: 0;
}
.cardTextOneHeading {
}
.cardTextOne {
font-size: 33px;
font-family: "hlv_bold", sans-serif;
margin-top: 6px;
margin-bottom: 14px;
}
.cardTextTwoHeading {
}
.cardTextTwo {
font-size: 33px;
font-family: "hlv_bold", sans-serif;
margin-top: 6px;
margin-bottom: 14px;
}
img {
position: absolute;
bottom: -43px;
right: -34px;
width: 54%;
height: auto;
}
}
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ColoredCardComponent } from './colored-card.component';
describe('ColoredCardComponent', () => {
let component: ColoredCardComponent;
let fixture: ComponentFixture<ColoredCardComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [ColoredCardComponent]
})
.compileComponents();
fixture = TestBed.createComponent(ColoredCardComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { NgOptimizedImage } from '@angular/common';
import { Component, Input } from '@angular/core';
@Component({
selector: 'app-colored-card',
imports: [
NgOptimizedImage
],
templateUrl: './colored-card.component.html',
styleUrl: './colored-card.component.scss'
})
export class ColoredCardComponent {
@Input() cardTextOneHeading: string = '';
@Input() cardTextOne: string = '';
@Input() cardTextTwoHeading: string = '';
@Input() cardTextTwo: string = '';
@Input() CardImage: string = '';
}
<table mat-table [dataSource]="data" class="mat-elevation-z8">
<!-- Dynamic Column Headers -->
<ng-container *ngFor="let column of columns; let i = index" [matColumnDef]="column.key">
<th mat-header-cell *matHeaderCellDef> {{ column.label }}
</th>
<td mat-cell *matCellDef="let element">
@if (column.key !== 'action' ) {
{{ element[column.key] }}
<input type="text" value={{column.label}}/>
<button (click)="editField(i)">edit</button>
} @else {
@for (item of element[column.key]; track item) {
<ng-container *ngIf="item =='view'">
<button class="view_button d_inline_block width_auto ml_1" (click)="view(element)">
<span class="material-symbols-outlined"> visibility </span> &nbsp;
</button>
</ng-container>
<ng-container *ngIf="item =='edit'">
<button class="view_button d_inline_block width_auto ml_1">
<span class="material-symbols-outlined">edit</span>
</button>
</ng-container>
}
}
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
<mat-paginator [length]="count" [pageSize]="pageSize" (page)="onPageChanged($event)">
</mat-paginator>
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CustomTableComponent } from './custom-table.component';
describe('CustomTableComponent', () => {
let component: CustomTableComponent;
let fixture: ComponentFixture<CustomTableComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [CustomTableComponent]
})
.compileComponents();
fixture = TestBed.createComponent(CustomTableComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { CommonModule } from '@angular/common';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { MatTableModule } from '@angular/material/table';
import { MatPaginator } from '@angular/material/paginator';
@Component({
selector: 'app-custom-table',
imports: [
CommonModule,
MatTableModule,
MatPaginator
],
templateUrl: './custom-table.component.html',
// styleUrl: './custom-table.component.scss'
styleUrls: [
'./custom-table.component.scss',
'../../style-guide/css/table-theme.scss'
]
})
export class CustomTableComponent {
@Input() columns: { key: string; label: string; isVisible?: boolean }[] = []; // Define columns dynamically
@Input() data: any[] = []; // Table data
@Input() count: number = 0; // Table data
@Input() pageSize: number = 0; // Table data
@Output() emitView: EventEmitter<string> = new EventEmitter<string>();
// totalRecords: number = 3400;
// pageSize: number = 50;
public ngOnInit(): void {
// console.log(this.data);
}
get displayedColumns(): string[] {
// console.log(this.data);
return this.columns.map(col => col.key);
}
public view(data:any): void {
this.emitView.emit(data);
}
onPageChanged(event: any): void {
console.log("event");
console.log(event);
}
public editField(index: number) :void {
this.columns[index].isVisible != true;
}
// columns = [
// { key: 'id', label: 'ID' },
// { key: 'name', label: 'Name' },
// { key: 'age', label: 'Age' }
// ];
// data = [
// { id: 1, name: 'John Doe', age: 30 },
// { id: 2, name: 'Jane Doe', age: 28 },
// { id: 3, name: 'Alice', age: 25 }
// ];
}
<mat-form-field >
<mat-label> {{searchInputLabel}} </mat-label>
<input type="text"
placeholder="Pick one"
matInput
[formControl]="searchData"
[matAutocomplete]="auto">
<mat-autocomplete autoActiveFirstOption #auto="matAutocomplete" (optionSelected)="optionSelected($event)"
>
@for (option of filteredOptions | async; track option) {
<mat-option [value]="option">{{option}}</mat-option>
}
</mat-autocomplete>
</mat-form-field>
<!-- (optionSelected)="selectAutoComplete($event.option)" -->
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { DropdownWithSearchComponent } from './dropdown-with-search.component';
describe('DropdownWithSearchComponent', () => {
let component: DropdownWithSearchComponent;
let fixture: ComponentFixture<DropdownWithSearchComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [DropdownWithSearchComponent]
})
.compileComponents();
fixture = TestBed.createComponent(DropdownWithSearchComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MatFormFieldModule } from '@angular/material/form-field';
import {MatAutocompleteModule, MatAutocompleteSelectedEvent} from '@angular/material/autocomplete';
import { Observable, map, startWith } from 'rxjs';
import { AsyncPipe } from '@angular/common';
import { MatInputModule } from '@angular/material/input';
@Component({
selector: 'app-dropdown-with-search',
imports: [
FormsModule,
MatFormFieldModule,
MatInputModule,
MatAutocompleteModule,
ReactiveFormsModule,
AsyncPipe,
],
templateUrl: './dropdown-with-search.component.html',
styleUrl: './dropdown-with-search.component.scss'
})
export class DropdownWithSearchComponent {
@Input() public searchInputLabel: string = '';
@Input() public options: string[] = [];
@Input() public selectedValue: string = '';
@Output() public autoCompleteEventEmit = new EventEmitter<number>();
// @Input() public response: any[] = ['One', 'Two', 'Three'];
public searchData = new FormControl('');
// this.options = ['One', 'Two', 'Three'];
public filteredOptions: Observable<string[]> | undefined;
public selected = '';
public ngOnInit(): void {
this.filteredOptions = this.searchData.valueChanges.pipe(
startWith(''),
map(value => this._filter(value || '')),
);
if(this.selectedValue) this.searchData.setValue(this.selectedValue);
}
private _filter(value: string): string[] {
const filterValue = value.toLowerCase();
return this.options.filter(option => option.toLowerCase().includes(filterValue));
}
public optionSelected(event: MatAutocompleteSelectedEvent) {
const selectedIndex = this.options.findIndex(option => option === event.option.value);
this.autoCompleteEventEmit.emit(selectedIndex);
}
}
<mat-form-field class="full_width">
<mat-label>Choose Log Type</mat-label>
<mat-select (selectionChange)="changeDropdown($event)" [(value)]="defaultSelectedOption">
@for (option of dropDownData; track option.name) {
<mat-option [value]="option.value">{{option.name}}</mat-option>
}
</mat-select>
</mat-form-field>
\ No newline at end of file
.mat-mdc-form-field::ng-deep {
.mdc-text-field--filled:not(.mdc-text-field--disabled){
background: var(--secondary-bg-color);
color: var(--primary-color);
}
.mdc-floating-label {
color: var(--accent-color);
}
.mdc-text-field--filled:not(.mdc-text-field--disabled):not(.mdc-text-field--focused):hover .mdc-floating-label, .mdc-text-field--filled:not(.mdc-text-field--disabled):not(.mdc-text-field--focused):hover .mdc-floating-label--float-above{
color: var(--accent-color);
opacity: .5;
}
.mdc-text-field--filled:not(.mdc-text-field--disabled) .mdc-line-ripple::before {
border-bottom-color: rgba(179, 171, 171, 0.42);
}
.mat-mdc-select-value-text {
color: var(--primary-color);
}
.mat-mdc-select-arrow svg {
fill: var(--primary-color);
}
}
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { DropDownComponent } from './drop-down.component';
describe('DropDownComponent', () => {
let component: DropDownComponent;
let fixture: ComponentFixture<DropDownComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [DropDownComponent]
})
.compileComponents();
fixture = TestBed.createComponent(DropDownComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { CommonModule } from '@angular/common';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { MatSelectChange, MatSelectModule } from '@angular/material/select';
import { Dropdown } from '../interface/dropdown';
@Component({
selector: 'app-drop-down',
imports: [
MatFormFieldModule,
MatSelectModule,
MatInputModule,
CommonModule
],
templateUrl: './drop-down.component.html',
styleUrl: './drop-down.component.scss'
})
export class DropDownComponent {
@Input() dropDownData: Dropdown[] = [];
@Output() emitDropDownData: EventEmitter<string> = new EventEmitter<string>();
public defaultSelectedOption: string = '';
ngOnInit(): void {
this.defaultSelectedOption = this.dropDownData[0].value;
}
public changeDropdown(selectedOption: MatSelectChange): void {
this.emitDropDownData.emit(selectedOption.value);
this.defaultSelectedOption = selectedOption.value;
}
}
export interface Dropdown {
name: string;
value: string;
}
\ No newline at end of file
<div class="for_export_and_print_button_cont">
<app-square-button
[buttonText]="'Export'"
[buttonIcon]="'export_notes'"
(emitSquareButtonClick)="export()"
/>
<app-square-button
[buttonText]="'Print'"
[buttonIcon]="'print'"
(emitSquareButtonClick)="print()"
/>
</div>
.for_export_and_print_button_cont {
display: flex;
width: 100%;
gap:10px;
}
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ExportAndPrintComponent } from './export-and-print.component';
describe('ExportAndPrintComponent', () => {
let component: ExportAndPrintComponent;
let fixture: ComponentFixture<ExportAndPrintComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [ExportAndPrintComponent]
})
.compileComponents();
fixture = TestBed.createComponent(ExportAndPrintComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, EventEmitter, Output } from '@angular/core';
import { SquareButtonComponent } from '../../square-button/square-button.component';
@Component({
selector: 'app-export-and-print',
imports: [
SquareButtonComponent
],
templateUrl: './export-and-print.component.html',
styleUrl: './export-and-print.component.scss'
})
export class ExportAndPrintComponent {
public export(): void {
alert('//TODO export'); //TODO export
}
public print(): void {
alert('//TODO print'); //TODO print
}
}
<mat-form-field>
<!-- <mat-label>Filter</mat-label> -->
<span class="material-symbols-outlined" matPrefix> search </span>
<input
matInput
(keyup)="applyFilter($event)"
placeholder="{{ placeholder }}"
#input
/>
</mat-form-field>
// .mat-mdc-form-field-has-icon-prefix::ng-deep {
// .mat-mdc-text-field-wrapper {
// background: red !important;
// }
// }
::ng-deep.for_filter_cont .mat-mdc-form-field-has-icon-prefix {
.mdc-text-field--no-label:not(.mdc-text-field--textarea)
.mat-mdc-form-field-input-control.mdc-text-field__input,
.mat-mdc-text-field-wrapper .mat-mdc-form-field-input-control {
font-size: 15px;
}
.mat-mdc-form-field-icon-prefix {
padding-right: 10px;
}
.mdc-text-field--filled:not(.mdc-text-field--disabled)
.mdc-line-ripple::before {
border-bottom-color: rgb(179 171 171 / 42%);
}
.mdc-text-field--filled:not(.mdc-text-field--disabled)
.mdc-line-ripple::after {
background: var(--accent-color);
}
.mat-mdc-text-field-wrapper {
background: var(--secondary-bg-color);
color: var(--primary-color);
padding-left: 16px;
input {
color: var(--primary-color);
&::placeholder {
color: var(--primary-color);
}
}
}
}
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FilterInputComponent } from './filter-input.component';
describe('FilterInputComponent', () => {
let component: FilterInputComponent;
let fixture: ComponentFixture<FilterInputComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [FilterInputComponent]
})
.compileComponents();
fixture = TestBed.createComponent(FilterInputComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { Observable, Subject, Subscription } from 'rxjs';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
@Component({
selector: 'app-filter-input',
imports: [
MatFormFieldModule,
MatInputModule,
],
templateUrl: './filter-input.component.html',
styleUrl: './filter-input.component.scss'
})
export class FilterInputComponent implements OnInit, OnDestroy {
@Input() placeholder: string = '';
@Output() inputData: EventEmitter<string> = new EventEmitter<string>();
private _searchSubject$ = new Subject<string>();
public searchTerm: string = '';
private _subscription: Subscription = {} as Subscription;
public ngOnInit(): void {
this._subscription = this._searchSubject$.pipe(
debounceTime(300), // Wait 300ms after the last event before emitting the last event
distinctUntilChanged() // Only emit if value is different from previous value
).subscribe((searchTerm: string) => {
this.searchTerm = searchTerm;
this.inputData.emit((this.searchTerm));
});
}
public applyFilter(event: Event) {
this._searchSubject$.next((event.target as HTMLInputElement).value);
}
public ngOnDestroy(): void {
this._subscription.unsubscribe();
}
}
<div class="filter_component">
<div class="filter_col for_filter_cont">
<app-filter-input
[placeholder]="placeholder"
(inputData)="applyFilter($event)"
/>
</div>
<div class="filter_col for_drop_down" *ngIf="dropDownData.length">
<app-drop-down
[dropDownData]="dropDownData"
(emitDropDownData)="changeDropdown($event)"
class="full_width"
/>
</div>
<div class="filter_col for_export_and_print">
<app-export-and-print />
</div>
</div>
.filter_component {
display: flex;
gap: 20px;
.filter_col {
width: auto;
}
.for_filter_cont {
display: flex;
align-items: center;
justify-content: start;
}
.for_export_and_print {
display: flex;
align-items: center;
justify-content: end;
margin-left: auto;
}
.for_drop_down {
// width: 30%;
}
}
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FilterWithExportAndPrintComponent } from './filter-with-export-and-print.component';
describe('FilterWithExportAndPrintComponent', () => {
let component: FilterWithExportAndPrintComponent;
let fixture: ComponentFixture<FilterWithExportAndPrintComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [FilterWithExportAndPrintComponent]
})
.compileComponents();
fixture = TestBed.createComponent(FilterWithExportAndPrintComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { ExportAndPrintComponent } from '../export-and-print/export-and-print/export-and-print.component';
import { FilterInputComponent } from '../filter-input/filter-input.component';
import { Dropdown } from '../dropdown/interface/dropdown';
import { CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { MatSelectModule } from '@angular/material/select';
import { DropDownComponent } from '../dropdown/drop-down/drop-down.component';
@Component({
selector: 'app-filter-with-export-and-print',
imports: [
FilterInputComponent,
ExportAndPrintComponent,
FormsModule,
ReactiveFormsModule,
MatFormFieldModule,
MatSelectModule,
MatInputModule,
CommonModule,
DropDownComponent
],
templateUrl: './filter-with-export-and-print.component.html',
styleUrl: './filter-with-export-and-print.component.scss'
})
export class FilterWithExportAndPrintComponent {
@Input() placeholder: string = '';
@Input() dropDownData: Dropdown[] = [];
@Output() inputData: EventEmitter<string> = new EventEmitter<string>();
@Output() emitDropDownData: EventEmitter<string> = new EventEmitter<string>();
public defaultSelectedOption: string = '';
public applyFilter(event: string): void {
this.inputData.emit(event);
}
public changeDropdown(selectedOption: string): void {
this.emitDropDownData.emit(selectedOption);
this.defaultSelectedOption = selectedOption;
}
}
<ng-container *ngIf="showChart">
<canvasjs-chart [options]="chartOptions"/>
</ng-container>
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { LineChartComponent } from './line-chart.component';
describe('LineChartComponent', () => {
let component: LineChartComponent;
let fixture: ComponentFixture<LineChartComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [LineChartComponent]
})
.compileComponents();
fixture = TestBed.createComponent(LineChartComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnDestroy, OnInit } from '@angular/core';
import { CanvasJSAngularChartsModule } from '@canvasjs/angular-charts';
import { InitThemeService } from '../../../style-guide/service/initialize-theme.service';
import { CommonModule } from '@angular/common';
import { Observable, Subscription } from 'rxjs';
@Component({
selector: 'app-line-chart',
imports: [
CanvasJSAngularChartsModule,
CommonModule
],
templateUrl: './line-chart.component.html',
styleUrl: './line-chart.component.scss'
})
export class LineChartComponent implements OnInit, OnDestroy {
public showChart: boolean = true;
public subscribeThemeMode: Subscription = {} as Subscription ;
public chartOptions = {
theme: this._themeService.isLightModeActive() ? "light2" : "dark2",
backgroundColor: "",
animationEnabled: true,
title: {
text: "Revenue vs Expenditure",
fontSize: 15,
fontFamily: "'hlv_mid', sans-serif",
margin: 40,
},
axisX: {
title: "Year"
},
axisY: {
title: "Amount in Rs."
},
toolTip: {
shared: true
},
legend: {
cursor: "pointer",
itemclick: function (e: any) {
if (typeof (e.dataSeries.visible) === "undefined" || e.dataSeries.visible) {
e.dataSeries.visible = false;
} else {
e.dataSeries.visible = true;
}
e.chart.render();
}
},
data: [{
axisY: {
valueFormatString: '₹#,##0k',
},
type: "spline",
yValueFormatString: '₹#,##0k',
showInLegend: true,
name: "Revenue",
dataPoints: [
{ label: "2012", y: 3.92 },
{ label: "2013", y: 3.31 },
{ label: "2014", y: 3.85 },
{ label: "2015", y: 3.60 },
{ label: "2016", y: 3.24 },
{ label: "2017", y: 3.22 },
{ label: "2018", y: 3.06 },
{ label: "2018", y: 3.37 },
{ label: "2019", y: 3.47 },
{ label: "2020", y: 3.79 },
{ label: "2021", y: 3.98 },
{ label: "2022", y: 3.73 }
]
}, {
type: "spline",
showInLegend: true,
name: "Expenditure",
yValueFormatString: '₹#,##0k',
dataPoints: [
{ label: "2012", y: 2.98 },
{ label: "2013", y: 3.11 },
{ label: "2014", y: 2.4 },
{ label: "2015", y: 0.63 },
{ label: "2016", y: 0.24 },
{ label: "2017", y: 0.08 },
{ label: "2018", y: 0.03 },
{ label: "2018", y: 0.14 },
{ label: "2019", y: 0.26 },
{ label: "2020", y: 0.36 },
{ label: "2021", y: 1.13 },
{ label: "2022", y: 1.79 }
]
}
]
}
constructor(
private _themeService: InitThemeService
) { }
public ngOnInit(): void {
this.subscribeThemeMode = this._themeService.isLightModeActive$.subscribe((isLightModeActive: boolean): void => {
this.showChart = false;
setTimeout(() => {
this.showChart = true;
this.chartOptions.theme = isLightModeActive ? "light2" : "dark2";
});
});
}
public ngOnDestroy(): void {
this.subscribeThemeMode.unsubscribe();
}
}
.heading {
font-family: var(--font-light);
font-size: 23px;
letter-spacing: 2px;
margin-bottom: 37px;
color: var(--primary-color);
}
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PageHeadingComponent } from './page-heading.component';
describe('PageHeadingComponent', () => {
let component: PageHeadingComponent;
let fixture: ComponentFixture<PageHeadingComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [PageHeadingComponent]
})
.compileComponents();
fixture = TestBed.createComponent(PageHeadingComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, Input } from '@angular/core';
@Component({
selector: 'app-page-heading',
imports: [],
templateUrl: './page-heading.component.html',
styleUrl: './page-heading.component.scss'
})
export class PageHeadingComponent {
@Input() title:string = '';
}
<mat-paginator
[length]="totalItems"
[pageSize]="pageSize"
showFirstLastButtons
[pageSizeOptions]="[5, 10, 20]"
(page)="pageChanged($event)"
></mat-paginator>
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PaginationComponent } from './pagination.component';
describe('PaginationComponent', () => {
let component: PaginationComponent;
let fixture: ComponentFixture<PaginationComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [PaginationComponent]
})
.compileComponents();
fixture = TestBed.createComponent(PaginationComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { MatPaginatorModule, PageEvent } from '@angular/material/paginator';
@Component({
selector: 'app-pagination',
imports: [
MatPaginatorModule,
],
templateUrl: './pagination.component.html',
styleUrl: './pagination.component.scss'
})
export class PaginationComponent {
@Input() public pageSizeOptions:number[] = [];
@Input() public totalItems:number = 0;
@Input() public pageSize:number = 5;
@Output() public paginationChange: EventEmitter<PageEvent> = new EventEmitter<PageEvent>();
public pageChanged(event: PageEvent) {
this.paginationChange.emit(event);
}
}
<button class="rounded_button" (click)="[clickRoundedButton(), onClickEventEmitter.emit(null)]"
[disabled]="isButtonDisabled">
<span class="material-symbols-outlined" *ngIf="buttonIconName">
{{ buttonIconName }}
</span>
<span class="button_text">{{ buttonText }}</span>
</button>
.rounded_button {
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
padding: 15px 0px;
border-radius: 100px;
background: var(--accent-gradient);
border: none;
color: white;
cursor: pointer;
width: 100%;
margin: 15px 0px;
box-shadow: var(--box-shadow-small);
span {
font-size: 15px;
}
}
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { RoundedButtonFullWidthComponent } from './rounded-button-full-width.component';
describe('RoundedButtonFullWidthComponent', () => {
let component: RoundedButtonFullWidthComponent;
let fixture: ComponentFixture<RoundedButtonFullWidthComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [RoundedButtonFullWidthComponent]
})
.compileComponents();
fixture = TestBed.createComponent(RoundedButtonFullWidthComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { CommonModule } from '@angular/common';
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
@Component({
selector: 'app-rounded-button-full-width',
imports: [
CommonModule
],
templateUrl: './rounded-button-full-width.component.html',
styleUrl: './rounded-button-full-width.component.scss'
})
export class RoundedButtonFullWidthComponent {
@Input() buttonText: string = '';
@Input() buttonIconName: string = '';
@Input() enableThrottling: boolean = false;
@Output() onClickEventEmitter : EventEmitter<null> = new EventEmitter<null>();
public isButtonDisabled: boolean = false;
public clickRoundedButton(): void {
this.isButtonDisabled = true;
if(this.enableThrottling) {
setTimeout(() => {
this.isButtonDisabled = false;
}, 2000)
}
else {
this.isButtonDisabled = false;
}
}
}
<button class="rounded_button" (click)="onClickEventEmitter.emit(null)">
<span class="material-symbols-outlined" *ngIf="buttonIconName">
{{ buttonIconName }}
</span>
<span class="button_text">{{ buttonText }}</span>
</button>
.rounded_button {
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
padding: 7px 30px;
border-radius: 100px;
background: var(--accent-gradient);
border: none;
color: white;
margin: 15px 0px;
cursor: pointer;
// margin: 15px 0px;
}
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { RoundedButtonComponent } from './rounded-button.component';
describe('RoundedButtonComponent', () => {
let component: RoundedButtonComponent;
let fixture: ComponentFixture<RoundedButtonComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [RoundedButtonComponent]
})
.compileComponents();
fixture = TestBed.createComponent(RoundedButtonComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { CommonModule } from '@angular/common';
import { Component, EventEmitter, Input, Output } from '@angular/core';
@Component({
selector: 'app-rounded-button',
imports: [
CommonModule
],
templateUrl: './rounded-button.component.html',
styleUrl: './rounded-button.component.scss'
})
export class RoundedButtonComponent {
@Input() buttonText: string = '';
@Input() buttonIconName: string = '';
@Output() onClickEventEmitter : EventEmitter<null> = new EventEmitter<null>();
constructor() { }
}
<button (click)="emitSquareButtonClick.emit(null)" class="square_button">
<span class="material-symbols-outlined" *ngIf="buttonIcon">
{{ buttonIcon }}
</span>
{{ buttonText }}
</button>
.square_button {
background: var(--accent-color);
border: none;
color: var(--color-white);
display: inline-flex;
padding: 10px 20px;
align-items: center;
justify-content: center;
gap: 10px;
border-radius: var(--border-radius-small);
cursor: pointer;
box-shadow: var(--box-shadow-small);
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment