Commit df9761a5 authored by achinta's avatar achinta

feat: add routine with file uploaded

parent 04bae104
......@@ -8,8 +8,12 @@
padding: 20px;
}
.logo_section {
display: flex;
justify-content: center;
}
}
.login_wrapper {
display: flex;
justify-content: center;
......
......@@ -54,7 +54,7 @@ export class AuthService {
public getUserRole(): string {
return this.localStorageGetItemByKey('role');
return this.localStorageGetItemByKey('role_name');
}
}
......@@ -16,11 +16,17 @@
</button>
</ng-container>
<ng-container *ngIf="item =='edit' && authService.getUserRole() !== 'student'">
<ng-container *ngIf="item =='edit' && authService.getUserRole() != 'Student'">
<button class="view_button d_inline_block width_auto " (click)="edit(element)">
<span class="material-symbols-outlined">edit</span>
</button>
</ng-container>
<ng-container *ngIf="item =='delete' && authService.getUserRole() != 'Student'">
<button class="view_button d_inline_block width_auto " (click)="delete(element)">
<span class="material-symbols-outlined">delete</span>
</button>
</ng-container>
}
}
</td>
......
......@@ -29,15 +29,18 @@ export class CustomTableComponent {
@Output() emitEdit: EventEmitter<string> = new EventEmitter<string>();
@Output() emitDelete: EventEmitter<string> = new EventEmitter<string>();
public authService = inject(AuthService);
// 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);
......@@ -53,6 +56,10 @@ export class CustomTableComponent {
this.emitEdit.emit(data);
}
public delete(data:any): void {
this.emitDelete.emit(data);
}
onPageChanged(event: any): void {
console.log("event");
console.log(event);
......
<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-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-form-field style="width: 100%;" appearance="fill">
<mat-label>{{ label }}</mat-label>
<button mat-icon-button matPrefix (click)="fileInput.click()">
<mat-icon>attach_file</mat-icon>
</button>
<input type="file" multiple #fileInput (change)="onFileSelected($event)" style="display: none;" />
<mat-hint *ngIf="selectedFiles().length">
Selected: {{ selectedFiles().length }} file(s)
</mat-hint>
<mat-error *ngIf="!selectedFiles().length">This field is required</mat-error>
</mat-form-field> -->
<mat-form-field style="width: 100%;">
<mat-label>{{ label }}</mat-label>
......@@ -20,10 +6,8 @@
<mat-icon>attach_file</mat-icon>
</button>
<input type="text" readonly matInput />
<input type="file" multiple #f_input (change)="onFileSelected($event)" />
<mat-hint *ngIf="selectedFiles().length">
Selected: {{ selectedFiles().length }} file(s)
</mat-hint>
<input type="text" readonly matInput [value]="fileName" />
<input type="file" multiple #f_input (change)="onFileSelected($event)" hidden />
<mat-error *ngIf="!selectedFiles().length">This field is required</mat-error>
</mat-form-field>
\ No newline at end of file
......@@ -19,12 +19,17 @@ export class FileInputComponent {
@Input() label: string = 'Upload Files';
@Output() filesChange = new EventEmitter<File[]>();
public fileName:string = '';
// Triggered when files are selected
onFileSelected(event: Event): void {
const input = event.target as HTMLInputElement;
if (input.files) {
this.selectedFiles.set(Array.from(input.files)); // Update the signal
this.filesChange.emit(this.selectedFiles()); // Emit the event
console.log(input.files[0].name);
this.fileName = input.files[0].name
}
}
}
......@@ -23,6 +23,9 @@ export class TransmissionMapperService {
public static readonly SAVE_TRANSMISSION_URL: string =
TransmissionMapperService.DEV_TRANSMISSION_URL + '/webomagic/saveWebDataSourceFieldsBasedOnDataSourceType?';
public static readonly FILE_UPLOAD_TRANSMISSION_URL: string =
TransmissionMapperService.DEV_TRANSMISSION_URL + '/webomagic/uploadFile?';
// aggregationOnUniqueFld=false&datasourceId=3188&dontIncludeForeignKey=false&expand=false&isUniqueValueRequiredForFieldToDisplay=false&language=en&limit=10&orderBy=ASC&page=1&user_id=206&roleBasedFiltering=true
// public static readonly SCHEDULE_OF_RATES_TRANSMISSION_URL: string =
// TransmissionMapperService.DEV_TRANSMISSION_URL +
......
<h3> Assignments </h3>
<div class="custom_table">
<app-custom-table
[columns]="columns"
[data]="data"
(emitEdit)="emitEditFromTable($event)"
(emitDelete)="emitDeleteFromTable($event)"
(emitView)="emitViewFromTable($event)"
/>
</div>
<div class="add_btn" *ngIf="authService.getUserRole() !== 'student'">
<div class="add_btn" *ngIf="authService.getUserRole() !== 'Student'">
<app-square-button
[buttonIcon]="'add'"
(emitSquareButtonClick)="addAssignment()"
......
......@@ -33,12 +33,7 @@ export class AssignmentComponent implements OnInit {
public authService: AuthService
) { }
public columns = [
{ key: 'class_subject_subject_txt', label: 'Class' },
{ key: 'subject', label: 'Subject' },
{ key: 'section', label: 'Section' },
{ key: 'action', label: 'Action' },
];
public columns:any[] = [];
public data: any[] = [];
......@@ -83,26 +78,23 @@ export class AssignmentComponent implements OnInit {
}
public emitEditFromTable(emitData: string): void {
public emitDeleteFromTable(emitData: string): void {
// rate ? rate.is_edit_enable = true : '';
let dialogRef = this._dialog.open(ManageComponent, {
data: emitData,
width: '98vw',
height: 'auto',
maxWidth: '70vw',
maxHeight: '70vh',
});
// dialogRef.afterClosed().subscribe(data => {
// if (data)
// this._getScheduleOfRates();
// this._dialog.open(ManageComponent, {
// data: emitData,
// width: '98vw',
// height: 'auto',
// maxWidth: '70vw',
// maxHeight: '70vh',
// });
alert("Have to Delete ");
}
public addAssignment(): void {
let dialogRef = this._dialog.open(ManageComponent, {
this._dialog.open(ManageComponent, {
data: '',
width: '98vw',
height: 'auto',
......
......@@ -13,29 +13,28 @@ export class PrepareAssignmentTableDataService {
let dataArray = data.map((assignment: Assignment) => {
return {
['id']: assignment.id,
['subject']: assignment.class_subject_subject_txt['en'],
['section_details']: assignment.section_details['en'],
['session_name']: assignment.session_session_name['en'],
['id']: assignment.id,
['action']: ['view', 'edit']
['assigned_on']: assignment.assigned_on['en'],
['action']: ['view', 'delete']
}
})
return dataArray;
// return [];
}
public prepareMatTableColumn(): any[] {
let columnArray = [
{ key: 'section_details', label: 'Class' },
{ key: 'subject', label: 'Subject' },
{ key: 'section_details', label: 'Subject Details' },
{ key: 'session_name', label: 'Session Name' },
{ key: 'assigned_on', label: 'Date' },
{ key: 'action', label: 'Action' },
];
console.log(columnArray);
return columnArray;
}
......
......@@ -5,15 +5,15 @@ export interface Data {
count: number;
id: number | string;
dataSourceName: string;
websiteId: number;
websiteId?: number;
type: string;
foreignKeyMapping: any;
foreignKeyMap: ForeignKeyMap;
requiredPresentationField: string;
foreignKeyMapping?: any;
foreignKeyMap?: ForeignKeyMap;
requiredPresentationField?: string;
favourite: boolean;
icon: string;
dependentFields: any;
dsType: any;
icon?: string;
dependentFields?: any;
dsType?: any;
[index:string]: any;
}
\ No newline at end of file
<h3> Exam schedules </h3>
<div class="custom_table">
<app-custom-table
[columns]="columns"
[data]="data"
(emitEdit)="emitEditFromTable($event)"
(emitDelete)="emitDeleteFromTable($event)"
(emitView)="emitViewFromTable($event)"
/>
</div>
<div class="add_btn">
<div class="add_btn" *ngIf="authService.getUserRole() !== 'Student'">
<app-square-button
[buttonIcon]="'add'"
(emitSquareButtonClick)="addExam()"
......
......@@ -10,6 +10,8 @@ import { UrlConfigService } from '../../service/url-config.service';
import { DataSourceService } from '../../service/data-source.service';
import { PrepareExamTableDataService } from '../service/prepare-exam-table-data.service';
import { RaintreeResponse } from '../../../raintree/interface/raintree-response';
import { AuthService } from '../../../auth/service/auth.service';
import { MatDialogConfigService } from '../../service/mat-dialog-config.service';
@Component({
selector: 'app-exam',
......@@ -27,7 +29,9 @@ export class ExamComponent {
private _dialog: MatDialog,
private _examSchedule:ExamScheduleService,
private _urlConfig: UrlConfigService,
private _prepareExamTableData: PrepareExamTableDataService
private _prepareExamTableData: PrepareExamTableDataService,
private _matDialogConfig: MatDialogConfigService,
public authService:AuthService
) { }
public columns: any = [];
......@@ -46,19 +50,9 @@ export class ExamComponent {
window.open(docLink, '_blank');
}
private matModalConfig = {
width: '98vw',
height: 'auto',
maxWidth: '70vw',
maxHeight: '70vh',
}
public emitEditFromTable(emitData: string): void {
public emitDeleteFromTable(emitData: string): void {
this._dialog.open(ManageComponent, {
data: emitData,
...this.matModalConfig
});
alert("Should delete !!")
}
......@@ -66,7 +60,7 @@ export class ExamComponent {
this._dialog.open(ManageComponent, {
data: '',
...this.matModalConfig
...this._matDialogConfig.matModalConfig()
});
}
......@@ -83,7 +77,7 @@ export class ExamComponent {
expand: false,
isUniqueValueRequiredForFieldToDisplay: false,
language: "en",
limit: 10,
limit: 100,
orderBy: "ASC",
page: 1,
roleBasedFiltering: true
......
......@@ -14,11 +14,11 @@ export class PrepareExamTableDataService {
return {
['id']: schedule.id,
['Term']: schedule.Term['en'],
['image']: schedule.image['en'],
['details']: schedule.details['en'],
['class_details']: schedule.class_details['en'],
['action']: ['view', 'edit']
['details']: schedule.details['en'],
['term']: schedule.Term['en'],
['image']: schedule.image['en'],
['action']: ['view', 'delete']
}
})
......@@ -29,9 +29,9 @@ export class PrepareExamTableDataService {
public prepareMatTableColumn(): any[] {
let columnArray = [
{ key: 'Term', label: 'Term' },
{ key: 'details', label: 'Details' },
{ key: 'class_details', label: 'Class' },
{ key: 'term', label: 'Term' },
{ key: 'details', label: 'Details' },
{ key: 'action', label: 'Action' },
];
......
<!-- <h1> Hi Manage </h1> -->
<form class="login_form" [formGroup]="routineForm">
<div class="mat_input_container">
<div class="class_dropdown">
<app-drop-down
[dropDownData] ="classDropDownData"
(emitDropDownData)="classOnChange($event)"
/>
</div>
<div class="section_dropdown">
<app-drop-down
[dropDownData] ="sectionDropDownData"
(emitDropDownData)="sectionOnChange($event)"
/>
<div class="container">
<form class="routine_form" [formGroup]="routineForm">
<div class="mat_input_container">
<div class="class_dropdown mat_input">
<mat-form-field class="full_width">
<mat-label>Select Class</mat-label>
<mat-select formControlName="class">
@for (class of classDropDownData; track class) {
<mat-option [value]="class.value">{{class.name}}</mat-option>
}
</mat-select>
<mat-error>This field is required</mat-error>
</mat-form-field>
</div>
<div class="section_dropdown mat_input">
<mat-form-field class="full_width">
<mat-label>Select Section</mat-label>
<mat-select formControlName="section">
@for (section of sectionDropDownData; track section) {
<mat-option [value]="section.value">{{section.name}}</mat-option>
}
</mat-select>
<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>Select Type</mat-label>
<mat-select formControlName="routineType">
<mat-option value="class_routine">Class Routine</mat-option>
<mat-option value="exam_routine">Exam Routine</mat-option>
</mat-select>
<mat-error>This field is required</mat-error>
</mat-form-field>
</div>
<div class="file_upload mat_input">
<app-file-input [label]="'Upload Document'" (filesChange)="onFilesChanged($event)" />
<mat-error *ngIf="!routineForm.value.schedule" >This field is required</mat-error>
</div>
</div>
<div class="details_field">
<mat-form-field class="full_width">
<span class="material-symbols-outlined" matPrefix>
person
</span>
<input
matInput
placeholder="{{ 'Enter details' }}"
#input
formControlName="details"
/>
<mat-error>This field is required</mat-error>
</mat-form-field>
<div class="add_btn">
<app-square-button [buttonIcon]="''" [buttonText]="'submit'" (emitSquareButtonClick)="submitRoutine()" />
</div>
<mat-form-field style="width: 100%;">
<mat-label>Schedule</mat-label>
<button mat-icon-button matPrefix (click)="f_input.click()">
<mat-icon>attach_file</mat-icon>
</button>
<input type="text" readonly matInput />
<input
type="file"
multiple
hidden
#f_input
/>
<mat-error>This field is required</mat-error>
</mat-form-field>
</div>
<div class="add_btn">
<app-square-button
[buttonIcon]="''"
[buttonText]="'submit'"
(emitSquareButtonClick)="submitRoutine()"
/>
</div>
</form>
\ No newline at end of file
</form>
</div>
\ No newline at end of file
.container{
padding: 10px;
}
.add_btn{
float: right;
}
.mat_input{
margin-bottom: 5px;
}
<h3> Routines </h3>
<div class="custom_table">
<app-custom-table
[columns]="columns"
[data]="data"
(emitEdit)="emitEditFromTable($event)"
(emitDelete)="emitDeleteFromTable($event)"
(emitView)="emitViewFromTable($event)"
/>
</div>
<div class="add_btn">
<div class="add_btn" *ngIf="authService.getUserRole() !== 'Student'">
<app-square-button
[buttonIcon]="'add'"
(emitSquareButtonClick)="addRoutine()"
......
......@@ -9,13 +9,17 @@ import { SquareButtonComponent } from '../../../component-library/square-button/
import { MatDialog } from '@angular/material/dialog';
import { ManageComponent } from '../manage/manage.component';
import { PrepareRoutineTableDataService } from '../service/prepare-routine-table-data.service';
import { CommonModule } from '@angular/common';
import { AuthService } from '../../../auth/service/auth.service';
import { MatDialogConfigService } from '../../service/mat-dialog-config.service';
@Component({
selector: 'app-routine',
standalone: true,
imports: [
CustomTableComponent,
SquareButtonComponent
SquareButtonComponent,
CommonModule
],
templateUrl: './routine.component.html',
styleUrl: './routine.component.scss'
......@@ -26,7 +30,9 @@ export class RoutineComponent {
private _routineTransmission: RoutineTransmissionService,
private _urlConfig: UrlConfigService,
private _dialog: MatDialog,
private _prepareRoutineTableData: PrepareRoutineTableDataService
private _prepareRoutineTableData: PrepareRoutineTableDataService,
private _matDialogConfig: MatDialogConfigService,
public authService: AuthService
) { }
public columns: any[] = [];
......@@ -41,12 +47,9 @@ export class RoutineComponent {
}
public addRoutine(): void {
let dialogRef = this._dialog.open(ManageComponent, {
this._dialog.open(ManageComponent, {
data: '',
width: '98vw',
height: 'auto',
maxWidth: '70vw',
maxHeight: '70vh',
...this._matDialogConfig.matModalConfig()
});
}
......@@ -55,15 +58,8 @@ export class RoutineComponent {
window.open(docLink, '_blank');
}
public emitEditFromTable(emitData: string): void {
let dialogRef = this._dialog.open(ManageComponent, {
data: emitData,
width: '98vw',
height: 'auto',
maxWidth: '70vw',
maxHeight: '70vh',
});
public emitDeleteFromTable(emitData: string): void {
alert("Should delete the data");
}
......
......@@ -15,11 +15,12 @@ export class PrepareRoutineTableDataService {
return {
['id']: routine.id,
['session_session_name']: routine.session_session_name?['en']:'',
['class_details']: routine.class_details?['en']:'',
['section_details']: routine.section_details?['en']:'',
['schedule']: routine.schedule['en'],
['action']: ['view', 'edit']
['session_session_name']: routine.session_session_name?.en,
['class_details']: routine.class_details?.en,
['section_details']: routine.section_details?.en,
['routine_type']: routine.routine_type.en,
['schedule']: routine.schedule?.en,
['action']: ['view', 'delete',]
}
})
......@@ -30,9 +31,9 @@ export class PrepareRoutineTableDataService {
public prepareMatTableColumn(): any[] {
let columnArray = [
{ key: 'session_session_name', label: 'Session' },
{ key: 'class_details', label: 'Class' },
{ key: 'section_details', label: 'Section' },
{ key: 'routine_type', label: 'Type' },
{ key: 'action', label: 'Action' },
];
......
......@@ -8,9 +8,16 @@ export class DataSourceService {
constructor() { }
public static readonly ASSIGNMENT_DATA_SOURCE_ID: number = 3188;
// FOR ROUTINE:
public static readonly ROUTINE_DATA_SOURCE_ID: number = 3021;
public static readonly ROUTINE_DATA_SOURCE_NAME: string = 'Routine';
public static readonly ROUTINE_DATA_SOURCE_TYPE: number = 1327;
public static readonly CLASS_DATA_SOURCE_ID: number = 3008;
public static readonly SECTION_DATA_SOURCE_ID: number = 3013;
public static readonly EXAM_SCHEDULE_DATA_SOURCE_ID: number = 3018;
}
export interface RaintreeResponse {
status_code: number;
status: boolean;
message: string;
[index: string]: any;
}
......@@ -7,7 +7,6 @@ import { RaintreeResponse } from "../interface/raintree-response";
export class TransmissionMessageHandlerService {
public hasError(response: RaintreeResponse): boolean {
console.log(response);
let hasError: boolean = false;
let successStatusCode:number[] = [200,201]
......
......@@ -16,7 +16,7 @@ export class FileUploadTransmissionService extends TransmissionService {
onFailure: (error: string) => void,
onComplete: () => void
): void {
this.executePostPayload(
this.executeFormPostPayload(
url,
payload,
onPreExecute,
......
......@@ -10,19 +10,23 @@ export class JWTService {
private _auth:AuthService
) {}
private _jwtToken: string | null = null;
private _expirationDate: Date | null = null;
private _isExpired: boolean | null = null;
private _userId:string = this._auth.localStorageGetItemByKey('user_id');
private _authorizationToken: string = localStorage.getItem('Bearer') || '';
public injectToken(token: string): HttpHeaders {
let authorizationToken: string = localStorage.getItem('Bearer') || '';
let userId = this._auth.localStorageGetItemByKey('user_id');
// TODO: check if token exist in Local storage and handle accordingly
public injectToken(url: string): HttpHeaders {
return new HttpHeaders({
"user-id": userId,
"apikey": authorizationToken,
"user-id": this._userId,
"apikey": this._authorizationToken,
'Content-Type': 'application/json',
});
}
public injectTokenForFormGroupPost(url: string): HttpHeaders {
return new HttpHeaders({
"user-id": this._userId,
"apikey": this._authorizationToken,
});
}
}
......@@ -46,4 +46,5 @@ export class RoutineTransmissionService extends TransmissionService{
true
);
}
}
......@@ -93,11 +93,13 @@ export class TransmissionService {
onPreExecute();
this._http
.post<RaintreeResponse>(url, payload, {
headers: requiresAuthentication
? this._jwt.injectToken(url)
: undefined,
})
.post<RaintreeResponse>(
url,
payload,
{
headers: requiresAuthentication ? this._jwt.injectToken(url) : undefined,
}
)
.pipe(catchError(this._httpErrorHandler.intercept))
.subscribe(
(response: RaintreeResponse) => {
......@@ -199,7 +201,7 @@ export class TransmissionService {
this._http
.post<RaintreeResponse>(url, payload, {
headers: requiresAuthentication
? this._jwt.injectToken(url)
? this._jwt.injectTokenForFormGroupPost(url)
: undefined,
})
.pipe(catchError(this._httpErrorHandler.intercept))
......
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