Commit e6d09e58 authored by achinta's avatar achinta

feat: exam-schedule

parent b97b9938
import { Data } from "../data-source/interface/data"; import { Data } from "./data";
import { LocalizedField } from "../data-source/interface/localizedField"; import { LocalizedField } from "./localizedField";
// ThemeDataSourceField Interface // ThemeDataSourceField Interface
......
import { Data } from "../data-source/interface/data"; import { Data } from "./data";
import { LocalizedField } from "../data-source/interface/localizedField"; import { LocalizedField } from "./localizedField";
// ThemeDataSourceField Interface // ThemeDataSourceField Interface
......
<p>exam works!</p> <div class="custom_table">
<app-custom-table
[columns]="columns"
[data]="data"
(emitEdit)="emitEditFromTable($event)"
(emitView)="emitViewFromTable($event)"
/>
</div>
<div class="add_btn">
<app-square-button
[buttonIcon]="'add'"
(emitSquareButtonClick)="addExam()"
/>
</div>
\ No newline at end of file
.add_btn{
position: fixed;
bottom: 20px;
right: 0;
padding: 0px 20px;
margin: auto;
}
\ No newline at end of file
import { CommonModule } from '@angular/common';
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { CustomTableComponent } from '../../../component-library/custom-table/custom-table.component';
import { SquareButtonComponent } from '../../../component-library/square-button/square-button.component';
import { MatDialog } from '@angular/material/dialog';
import { ManageComponent } from '../manage/manage.component';
import { ExamScheduleService } from '../../../raintree/transmission/exam-schedule.service';
import { TransmissionMapperService } from '../../../mappers/transmission-mapper.service';
import { UrlConfigService } from '../../service/url-config.service';
import { DataSourceService } from '../../service/data-source.service';
import { ExamScheduleResponse } from '../../../raintree/interface/exam-schedule-respons';
import { PrepareExamTableDataService } from '../service/prepare-exam-table-data.service';
@Component({ @Component({
selector: 'app-exam', selector: 'app-exam',
imports: [], imports: [
CommonModule,
CustomTableComponent,
SquareButtonComponent
],
templateUrl: './exam.component.html', templateUrl: './exam.component.html',
styleUrl: './exam.component.scss' styleUrl: './exam.component.scss'
}) })
export class ExamComponent { export class ExamComponent {
constructor(
private _dialog: MatDialog,
private _examSchedule:ExamScheduleService,
private _urlConfig: UrlConfigService,
private _prepareExamTableData: PrepareExamTableDataService
) { }
public columns: any = [];
public data: any = [];
ngOnInit(): void{
this.columns = this._prepareExamTableData.prepareMatTableColumn();
this._getExamSchedule();
}
public emitViewFromTable(emitData: any) {
let docLink = emitData.image.replace('BASE_URL', TransmissionMapperService.DEV_TRANSMISSION_URL);
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 addExam(): void {
let dialogRef = this._dialog.open(ManageComponent, {
data: '',
width: '98vw',
height: 'auto',
maxWidth: '70vw',
maxHeight: '70vh',
});
}
private _getExamSchedule(): void {
this._examSchedule.getExamSchedule(
TransmissionMapperService.GET_TRANSMISSION_URL + this._urlConfig.generateDatasourceConfigUrl({
aggregationOnUniqueFld: false,
datasourceId: DataSourceService.EXAM_SCHEDULE_DATA_SOURCE_ID,
dontIncludeForeignKey: false,
expand: false,
isUniqueValueRequiredForFieldToDisplay: false,
language: "en",
limit: 10,
orderBy: "ASC",
page: 1,
roleBasedFiltering: true
}),
() => { },
(response) => { },
(response: ExamScheduleResponse) => {
this.data = this._prepareExamTableData.prepareMatTableData(response.data.themeDataSourceFields);
},
(error) => {
console.log(error);
},
() => { }
)
}
} }
import { Data } from "../../data-source/interface/data";
import { LocalizedField } from "../../data-source/interface/localizedField";
// ThemeDataSourceField Interface
export interface ExamSchedules extends Data {
themeDataSourceFields: ExamSchedule[];
}
// ThemeDataSourceField Interface
export interface ExamSchedule {
id: string;
session: LocalizedField;
Term: LocalizedField;
image: LocalizedField;
details: LocalizedField;
class: LocalizedField;
session_session_name: LocalizedField;
class_details: LocalizedField;
}
<p>manage works!</p> <pre> {{data|json}} </pre>
\ No newline at end of file
import { Component } from '@angular/core'; import { CommonModule } from '@angular/common';
import { Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
@Component({ @Component({
selector: 'app-manage', selector: 'app-manage',
imports: [], imports: [
CommonModule
],
templateUrl: './manage.component.html', templateUrl: './manage.component.html',
styleUrl: './manage.component.scss' styleUrl: './manage.component.scss'
}) })
export class ManageComponent { export class ManageComponent {
constructor(
@Inject(MAT_DIALOG_DATA) public data: any,
) { }
} }
import { TestBed } from '@angular/core/testing';
import { PrepareExamTableDataService } from './prepare-exam-table-data.service';
describe('PrepareExamTableDataService', () => {
let service: PrepareExamTableDataService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(PrepareExamTableDataService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
import { Injectable } from '@angular/core';
import { ExamSchedule } from '../interface/exam-schedule';
@Injectable({
providedIn: 'root'
})
export class PrepareExamTableDataService {
constructor() { }
public prepareMatTableData(data: ExamSchedule[]): any {
let dataArray = data.map((schedule: ExamSchedule) => {
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']
}
})
return dataArray;
}
public prepareMatTableColumn(): any[] {
let columnArray = [
{ key: 'Term', label: 'Term' },
{ key: 'details', label: 'Details' },
{ key: 'class_details', label: 'Class' },
{ key: 'action', label: 'Action' },
];
return columnArray;
}
}
...@@ -8,14 +8,14 @@ import { classResponse } from '../../../raintree/interface/class-respons'; ...@@ -8,14 +8,14 @@ import { classResponse } from '../../../raintree/interface/class-respons';
import { UrlConfigService } from '../../service/url-config.service'; import { UrlConfigService } from '../../service/url-config.service';
import { DropDownComponent } from "../../../component-library/dropdown/drop-down/drop-down.component"; import { DropDownComponent } from "../../../component-library/dropdown/drop-down/drop-down.component";
import { Dropdown } from '../../../component-library/dropdown/interface/dropdown'; import { Dropdown } from '../../../component-library/dropdown/interface/dropdown';
import { StudentClass } from '../../interface/class'; import { StudentClass } from '../../data-source/interface/class';
import { FormControl, FormControlName, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms'; import { FormControl, FormControlName, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
import { MatFormFieldModule } from '@angular/material/form-field'; import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input'; import { MatInputModule } from '@angular/material/input';
import { MatIconModule } from "@angular/material/icon"; import { MatIconModule } from "@angular/material/icon";
import { SquareButtonComponent } from '../../../component-library/square-button/square-button.component'; import { SquareButtonComponent } from '../../../component-library/square-button/square-button.component';
import { SectionResponse } from '../../../raintree/interface/section-respons'; import { SectionResponse } from '../../../raintree/interface/section-respons';
import { StudentSection } from '../../interface/section'; import { StudentSection } from '../../data-source/interface/section';
import { RoutineTransmissionService } from '../../../raintree/transmission/routine-transmission.service'; import { RoutineTransmissionService } from '../../../raintree/transmission/routine-transmission.service';
import { AuthService } from '../../../auth/service/auth.service'; import { AuthService } from '../../../auth/service/auth.service';
import { RaintreeResponse } from '../../../raintree/interface/raintree-response'; import { RaintreeResponse } from '../../../raintree/interface/raintree-response';
......
...@@ -51,15 +51,11 @@ export class RoutineComponent { ...@@ -51,15 +51,11 @@ export class RoutineComponent {
} }
public emitViewFromTable(emitData: any) { public emitViewFromTable(emitData: any) {
// alert("Have to view the doc in another page");
// console.log();
let docLink = emitData.schedule.replace('BASE_URL', TransmissionMapperService.DEV_TRANSMISSION_URL); let docLink = emitData.schedule.replace('BASE_URL', TransmissionMapperService.DEV_TRANSMISSION_URL);
window.open(docLink, '_blank'); window.open(docLink, '_blank');
} }
public emitEditFromTable(emitData: string): void { public emitEditFromTable(emitData: string): void {
let dialogRef = this._dialog.open(ManageComponent, { let dialogRef = this._dialog.open(ManageComponent, {
data: emitData, data: emitData,
width: '98vw', width: '98vw',
......
...@@ -11,5 +11,6 @@ export class DataSourceService { ...@@ -11,5 +11,6 @@ export class DataSourceService {
public static readonly ROUTINE_DATA_SOURCE_ID: number = 3021; public static readonly ROUTINE_DATA_SOURCE_ID: number = 3021;
public static readonly CLASS_DATA_SOURCE_ID: number = 3008; public static readonly CLASS_DATA_SOURCE_ID: number = 3008;
public static readonly SECTION_DATA_SOURCE_ID: number = 3013; public static readonly SECTION_DATA_SOURCE_ID: number = 3013;
public static readonly EXAM_SCHEDULE_DATA_SOURCE_ID: number = 3018;
} }
import { Classes } from "../../portal/interface/class"; import { Classes } from "../../portal/data-source/interface/class";
import { RaintreeResponse } from "./raintree-response"; import { RaintreeResponse } from "./raintree-response";
......
import { ExamSchedules } from "../../portal/exam/interface/exam-schedule";
import { RaintreeResponse } from "./raintree-response";
export interface ExamScheduleResponse extends RaintreeResponse{
data: ExamSchedules
}
\ No newline at end of file
import { Sections } from "../../portal/interface/section"; import { Sections } from "../../portal/data-source/interface/section";
import { RaintreeResponse } from "./raintree-response"; import { RaintreeResponse } from "./raintree-response";
......
import { TestBed } from '@angular/core/testing';
import { ExamScheduleService } from './exam-schedule.service';
describe('ExamScheduleService', () => {
let service: ExamScheduleService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(ExamScheduleService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
import { Injectable } from '@angular/core';
import { TransmissionService } from './transmission.service';
@Injectable({
providedIn: 'root'
})
export class ExamScheduleService extends TransmissionService {
public getExamSchedule(
url: string,
onPreExecute: () => void,
onPostExecute: (response: any) => void,
onSuccess: (response: any) => void,
onFailure: (error: string) => void,
onComplete: () => void
): void {
this.executePostPayload(
url,
{},
onPreExecute,
onPostExecute,
onSuccess,
onFailure,
onComplete,
true
);
}
}
...@@ -8,7 +8,6 @@ export class RoutineTransmissionService extends TransmissionService{ ...@@ -8,7 +8,6 @@ export class RoutineTransmissionService extends TransmissionService{
public getRoutine( public getRoutine(
url: string, url: string,
payload:string,
onPreExecute: () => void, onPreExecute: () => void,
onPostExecute: (response: any) => void, onPostExecute: (response: any) => void,
onSuccess: (response: any) => void, onSuccess: (response: any) => void,
......
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