Commit a5877609 authored by achinta's avatar achinta

wip: change password

parent 7b70909f
This diff is collapsed.
import { Component, Inject, OnInit, PLATFORM_ID } from '@angular/core';
import { Router, RouterModule, RouterOutlet,NavigationEnd } from '@angular/router';
import { Router, RouterModule, RouterOutlet, NavigationEnd } from '@angular/router';
import { RequestMapperService } from './mappers/request-mapper.service';
import { InitThemeService } from './style-guide/service/initialize-theme.service';
import { isPlatformBrowser } from '@angular/common';
import { filter } from 'rxjs';
import { App } from '@capacitor/app';
@Component({
selector: 'app-root',
......@@ -11,7 +12,7 @@ import { filter } from 'rxjs';
templateUrl: './app.component.html',
styleUrl: './app.component.scss'
})
export class AppComponent implements OnInit{
export class AppComponent implements OnInit {
public isBrowser: boolean = false;
......@@ -34,6 +35,15 @@ export class AppComponent implements OnInit{
// console.log('Route changed:', event.url);
this.onRouteChange(event.url);
});
// Capacitor.addListener()
App.addListener('backButton', ({ canGoBack }) => {
if (!canGoBack) {
App.exitApp();
} else {
window.history.back();
}
});
}
public onRouteChange(url: string): void {
......
......@@ -4,10 +4,13 @@ import { provideRouter } from '@angular/router';
import { routes } from './app.routes';
import { provideHttpClient } from '@angular/common/http';
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
import { DatePipe } from '@angular/common';
export const appConfig: ApplicationConfig = {
providers: [
provideRouter(routes),
provideHttpClient(), provideAnimationsAsync()
provideHttpClient(),
provideAnimationsAsync(),
DatePipe
]
};
......@@ -84,6 +84,12 @@ export const routes: Routes = [
import('./portal/routine/routine.routes')
.then(r => r.ROUTINE_ROUTES)
},
{
path: RequestMapperService.PROFILE_URL,
loadChildren: () =>
import('./portal/profile/profile.routes')
.then(r => r.PROFILE_ROUTES)
},
],
},
......
......@@ -30,12 +30,16 @@
}
}
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
@if (data.length <= 0) {
<h5 class="no_record" >No records found</h5>
}
@if (count && pageSize ) {
<mat-paginator [length]="count" [pageSize]="pageSize" (page)="onPageChanged($event)">
......
......@@ -3,3 +3,7 @@
// }
// }
.no_record{
text-align: center;
}
\ No newline at end of file
......@@ -26,7 +26,7 @@ export class ToasterService {
this._snackBar.open(message, action,{
panelClass: [custom_class],
duration: 4000,
duration: 2000,
verticalPosition: "top", // Allowed values are 'top' | 'bottom'
horizontalPosition: "right" // Allowed values are 'start' | 'center' | 'end' | 'left' | 'right'
});
......
......@@ -23,4 +23,8 @@ export class RequestMapperService {
public static readonly EXAM_URL: string = 'exam';
public static readonly ROUTINE_URL: string = 'routine';
// profile urls
public static readonly PROFILE_URL: string = 'profile';
public static readonly CHANGE_PASSWORD_URL: string = 'update-password';
}
......@@ -96,7 +96,7 @@ export class AssignmentComponent implements OnInit {
isUniqueValueRequiredForFieldToDisplay: false,
language: "en",
limit: 100,
orderBy: "ASC",
orderBy: "DESC",
page: 1,
fieldName: `${this._urlConfig.getFiledNameFilter('assignment')},${dateRangeFieldname}`,
operators: `${this._urlConfig.getFieldOperatorFilter('assignment')},${dateRangeFieldOperator}`,
......
......@@ -19,7 +19,7 @@
<div class="section_dropdown mat_input">
<mat-form-field class="full_width">
<mat-label>Select Section</mat-label>
<mat-select formControlName="section">
<mat-select formControlName="section" (selectionChange)="onChangeSection($event)" >
@for (section of sectionDropDownData; track section) {
<mat-option [value]="section.value">{{section.name}}</mat-option>
}
......
......@@ -4,7 +4,7 @@ import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angula
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatIconModule } from '@angular/material/icon';
import { MatSelectModule } from '@angular/material/select';
import { MatSelectChange, MatSelectModule } from '@angular/material/select';
import { FileInputComponent } from '../../../component-library/file-input/file-input.component';
import { SquareButtonComponent } from '../../../component-library/square-button/square-button.component';
import { Dropdown } from '../../../component-library/dropdown/interface/dropdown';
......@@ -24,6 +24,7 @@ import {MatDatepickerModule} from '@angular/material/datepicker';
import {MatNativeDateModule, provideNativeDateAdapter} from '@angular/material/core';
import { MatInputModule } from '@angular/material/input';
@Component({
selector: 'app-manage',
imports: [
......@@ -68,7 +69,11 @@ export class ManageComponent {
ngOnInit(): void {
// this._getClasses();
this._getSection();
this._getSubject();
}
public onChangeSection(event: MatSelectChange){
console.log(event.value);
this._getSubject(event.value);
}
public onFilesChanged(files: File[]): void {
......@@ -160,7 +165,7 @@ export class ManageComponent {
// );
// }
private _getSubject() {
private _getSubject(sectionId:string) {
this._classTransmission.getSubject(
TransmissionMapperService.GET_TRANSMISSION_URL +
this._urlConfig.generateDatasourceConfigUrl({
......@@ -173,9 +178,9 @@ export class ManageComponent {
limit:100,
orderBy:"ASC",
page:1,
fieldName: "subject_teacher",
operators: "eq",
fieldValues: this._auth.localStorageGetItemByKey("user_id")
fieldName: "subject_teacher,section",
operators: "eq,eq",
fieldValues: `${this._auth.localStorageGetItemByKey("user_id")},${sectionId}`
}),
() => { },
(response) => { },
......@@ -224,6 +229,7 @@ export class ManageComponent {
};
}
);
},
(error) => {
console.log(error);
......
import { Injectable } from '@angular/core';
import { inject, Injectable } from '@angular/core';
import { Assignment } from '../interface/assignment';
import { AssignmentTable } from '../interface/assignment-table';
import { CustomTableColumn } from '../../../component-library/interface/custom-table-column';
import { DatePipe } from '@angular/common';
@Injectable({
providedIn: 'root'
})
export class PrepareAssignmentTableDataService {
constructor() { }
private _datePipe = inject(DatePipe);
public prepareMatTableData(data: Assignment[]): AssignmentTable[] {
return data.map((assignment: Assignment) => {
return {
id: assignment.id,
subject: assignment.subject_subject_name?.en,
section_details: assignment.section_details?.en,
session_name: assignment.session_session_name?.en,
assigned_on: assignment.assigned_on?.en,
last_date: assignment.last_submission_date['en'],
document: assignment.docs['en'],
action: ['view', 'delete']
'id': assignment.id,
'subject': assignment.subject_subject_name?.en,
'section_details': assignment.section_details?.en,
'session_name': assignment.session_session_name?.en,
'assigned_on': assignment.assigned_on?.en,
'last_date': `${this._datePipe.transform(assignment.last_submission_date['en'],'dd-MM-yyyy')}`,
'document': assignment.docs['en'],
'action': ['view', 'delete']
}
})
......
......@@ -74,12 +74,26 @@ export class Menu {
children: []
};
public static readonly ProfileItems: Sidebar = {
id: 5,
title: 'Change Password',
icon: 'key',
// route: RequestMapperService.EXAM_URL,
route: RequestMapperService.PROFILE_URL,
selected: false,
roles: [
RoleMapperService.TEACHER_ROLE,RoleMapperService.STUDENT_ROLE
],
children: []
};
private static readonly _MenuItems: Sidebar[] = [
Menu._Dashboard,
Menu.AssignmentItems,
Menu.RoutineItems,
Menu.ExamItems
Menu.ExamItems,
Menu.ProfileItems
];
......
......@@ -5,11 +5,11 @@
<br />
<ul>
<!-- @for (sidebarParent of sideBarNavigationItems; track sidebarParent.id) { -->
<li *ngFor="let sidebarParent of sideBarNavigationItems" (click)="sidebarParent.selected = !sidebarParent.selected">
<ng-container *ngFor="let sidebarParent of sideBarNavigationItems">
<li (click)="sidebarParent.selected = !sidebarParent.selected">
@if(sidebarParent.children.length > 0 ||
sidebarParent.route==='disabled') {
<span class="icon_and_text_cont" >
<span class="icon_and_text_cont">
<span class="material-symbols-outlined">
{{sidebarParent.icon}}
</span>
......@@ -18,19 +18,19 @@
</a>
</span>
<span class="material-symbols-outlined dd_trigger {{sidebarParent.selected?'dd_active':''}}" >
<span class="material-symbols-outlined dd_trigger {{sidebarParent.selected?'dd_active':''}}">
keyboard_arrow_down
</span>
<ul class="dd_outer_wrapper {{sidebarParent.selected?'dd_children_selected':''}}">
<!-- @for (sidebarChildrenLevelOne of sidebarParent.children; track
sidebarChildrenLevelOne.id) { -->
<li *ngFor="let sidebarChildrenLevelOne of sidebarParent.children">
<span class="icon_and_text_cont">
<li *ngFor="let sidebarChildrenLevelOne of sidebarParent.children" >
<span class="icon_and_text_cont" [routerLinkActive]="['is-active']">
<span class="material-symbols-outlined">
{{sidebarChildrenLevelOne.icon}}
</span>
<a [routerLink]="[sidebarChildrenLevelOne.route]" [routerLinkActive]="['is-active']">
<a [routerLink]="[sidebarChildrenLevelOne.route]" >
{{ sidebarChildrenLevelOne.title }}
</a>
</span>
......@@ -41,20 +41,21 @@
} @else {
<li>
<span class="icon_and_text_cont">
<span class="icon_and_text_cont" [routerLinkActive]="['is-active']">
<span class="material-symbols-outlined">
{{sidebarParent.icon}}
</span>
<a [routerLink]="[
sidebarParent.route === 'disabled' ? 'null' : sidebarParent.route
]" [routerLinkActive]="['is-active']">
]">
{{ sidebarParent.title }}
</a>
</span>
</li>
}
</li>
</ng-container>
<!-- } @empty {
<span>Empty list of Navigation</span>
} -->
......
......@@ -29,8 +29,15 @@
text-decoration: none;
cursor: pointer;
}
.is-active{
span,a{
color: var(--accent-color);
}
}
}
}
.icon_and_text_cont {
display: flex;
align-items: center;
......
import { Component, effect, inject, OnInit } from '@angular/core';
import { RouterModule } from '@angular/router';
import { Router, RouterModule } from '@angular/router';
import { Menu } from '../model/sidebar/menu';
import { Sidebar } from '../interface/sidebar';
import { ThemeModeChangerComponent } from '../../../component-library/theme-mode-changer/theme-mode-changer.component';
......@@ -17,14 +17,12 @@ import { InitThemeService } from '../../../style-guide/service/initialize-theme.
templateUrl: './sidebar.component.html',
styleUrl: './sidebar.component.scss'
})
export class SidebarComponent implements OnInit {
export class SidebarComponent {
public router = inject(Router);
public sideBarNavigationItems: Sidebar[] = Menu.getSideBarNavigationItems;
public isNightModeActive: boolean = false;
public ngOnInit(): void {
}
// trackById(index: number, item: any): any {
// return item.id || index; // Ensure 'item.id' is unique, otherwise fall back to index
......
......@@ -18,17 +18,17 @@
<!-- <app-theme-mode-changer /> -->
<div class="topbar_navigation_items topbar_profile_menu">
<img
<!-- <img
[ngSrc]="'./assets/image/Avatar.png'"
width="100"
height="100"
alt="user image"
class="user_image"
/>
/> -->
<div class="user_profile_info">
<p class="user_name">
{{userProfileInformation.name}}
<span class="material-symbols-outlined"> keyboard_arrow_down </span>
<!-- <span class="material-symbols-outlined"> keyboard_arrow_down </span> -->
</p>
<p class="user_role">{{userProfileInformation.role_name}}</p>
</div>
......
......@@ -82,7 +82,7 @@
justify-content: space-between;
gap: 5px;
font-family: var(--font-mid);
white-space: nowrap;
span {
font-size: 21px;
cursor: pointer;
......
......@@ -40,4 +40,8 @@ export class TopBarComponent {
private _fetchProfileDetails(): void {
this.userProfileInformation = this._getProfileInformation.getProfileInformation();
}
public createLogoUrl(){
// localStorage.
}
}
<!-- <h6> {{studentDropdown | json}} </h6> -->
<div class="portal_dashboard_container">
<div class="portal_dashboard_inner">
<div class="portal_card_container">
......
......@@ -9,7 +9,9 @@
.portal_card_colored_card {
width: 23.5%;
}
.student_dropdown{
width: 80%;
}
.portal_small_card_container {
display: flex;
gap: 2%;
......
......@@ -92,8 +92,10 @@ export class PortalDashboardComponent implements OnInit {
this._setSetStudentInfoInLocalStorage(this.students[0]);
this.studentDropdown = response['data'].themeDataSourceFields.map((student: Student, index: number) => {
return {
"name": student.name.en,
"name": `${student.name.en} (${student.section_details['en']})`,
"value": student.id
}
})
......
<form class="routine_form" [formGroup]="updatePasswordForm">
<div class="routine_type_dropdown mat_input">
<mat-form-field class="full_width">
<mat-label>Current Password</mat-label>
<input
type="text"
matInput
placeholder="Current Password"
#input
formControlName="currentPassword"
>
<mat-error>This field is required</mat-error>
</mat-form-field>
</div>
<div class="routine_type_dropdown mat_input">
<mat-form-field class="full_width">
<mat-label>New Password</mat-label>
<input
type="text"
matInput
placeholder="New Password"
#input
formControlName="newPassword"
>
<mat-error>This field is required</mat-error>
</mat-form-field>
</div>
<div class="routine_type_dropdown mat_input">
<mat-form-field class="full_width">
<mat-label>Confirm Password</mat-label>
<input
type="text"
matInput
placeholder="Confirm Password"
#input
formControlName="confirmPassword"
>
<mat-error>This field is required</mat-error>
</mat-form-field>
</div>
<div class="save_btn">
<app-square-button
class="save_btn"
[buttonText]="'Save'"
(emitSquareButtonClick)="changePassword()"
/>
</div>
</form>
\ No newline at end of file
.save_btn{
margin-top: 20px;
float: right;
}
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ChangePasswordComponent } from './change-password.component';
describe('ChangePasswordComponent', () => {
let component: ChangePasswordComponent;
let fixture: ComponentFixture<ChangePasswordComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [ChangePasswordComponent]
})
.compileComponents();
fixture = TestBed.createComponent(ChangePasswordComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { CommonModule } from '@angular/common';
import { Component, inject } from '@angular/core';
import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { MatSelectModule } from '@angular/material/select';
import { SquareButtonComponent } from "../../../component-library/square-button/square-button.component";
import { ToasterService } from '../../../component-library/toaster/toaster.service';
@Component({
selector: 'app-change-password',
imports: [
CommonModule,
MatFormFieldModule,
MatSelectModule,
ReactiveFormsModule,
MatInputModule,
SquareButtonComponent
],
templateUrl: './change-password.component.html',
styleUrl: './change-password.component.scss'
})
export class ChangePasswordComponent {
public toaster = inject(ToasterService)
public updatePasswordForm = new FormGroup({
currentPassword: new FormControl("", [Validators.required]),
newPassword: new FormControl("", [Validators.required]),
confirmPassword: new FormControl("", [Validators.required]),
});
public changePassword(): void {
if(this.updatePasswordForm.invalid) return;
if(this.updatePasswordForm.value.confirmPassword !== this.updatePasswordForm.value.newPassword) {
this.toaster.error("Confirm password does not match new password", 'Ok');
return;
}
console.log(this.updatePasswordForm.value);
// call API for change password
}
// {
// "old_password": "password",
// "new_password": "P@$$w0rd"
// }
// https://magicoweb.com/webomagic-user/v1/user/change-password
}
import { Routes } from "@angular/router";
import { verifyRoleGuard } from "../../auth/guard/verify-role.guard";
import { RequestMapperService } from "../../mappers/request-mapper.service";
import { Menu } from "../navigation/model/sidebar/menu";
import { ChangePasswordComponent } from "./change-password/change-password.component";
export const PROFILE_ROUTES: Routes = [
{
path: RequestMapperService.BASE_RELATIVE_URL,
redirectTo: RequestMapperService.CHANGE_PASSWORD_URL,
pathMatch: 'full'
},
{
path: RequestMapperService.CHANGE_PASSWORD_URL,
loadComponent: () =>
import(
'./change-password/change-password.component'
)
.then((m) => m.ChangePasswordComponent),
data: { roles: Menu.ProfileItems.roles },
canActivate: [verifyRoleGuard],
},
]
......@@ -123,7 +123,7 @@ export class RoutineComponent {
isUniqueValueRequiredForFieldToDisplay: false,
language: "en",
limit: 10,
orderBy: "ASC",
orderBy: "DESC",
page: 1,
fieldName: `${this._urlConfig.getFiledNameFilter('routine')},routine_type`,
operators: `${this._urlConfig.getFieldOperatorFilter('routine')},eq`,
......
......@@ -34,7 +34,7 @@ export class PrepareRoutineTableDataService {
public prepareMatTableColumn(): CustomTableColumn[] {
let columnArray = [
{ key: 'class_details', label: 'Class' },
// { key: 'class_details', label: 'Class' },
{ key: 'section_details', label: 'Section' },
{ key: 'details', label: 'Details' },
{ key: 'action', label: 'Action' },
......
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