Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
valentin-stamate committed Jul 2, 2022
1 parent d8676cc commit 56a6679
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 53 deletions.
2 changes: 0 additions & 2 deletions backend/src/app/controller/admin.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ export class AdminController {
try {
const fileModel = await CoordinatorService.downloadFile(coordinatorId, fileId);

console.log(fileModel.name);

res.setHeader('Content-disposition', 'attachment; filename=' + fileModel.name);
res.setHeader('Content-type', fileModel.mimeType);
res.end(fileModel.data);
Expand Down
4 changes: 0 additions & 4 deletions backend/src/app/controller/coordinator.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,9 @@ export class CoordinatorController {

const fileModel = await CoordinatorService.downloadFile(coordinator.id, fileId);

console.log(fileModel.name);

res.setHeader('Content-disposition', 'attachment; filename=' + fileModel.name);
res.setHeader('Content-type', fileModel.mimeType);

console.log(fileModel.data);

res.end(fileModel.data);
} catch (err) {
next(err);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export class CoordinatorStudentFormsController {
const fileName = `report_${UtilService.stringDate(new Date())}.zip`;

res.setHeader('Content-disposition', 'attachment; filename=' + fileName);
console.log(ContentType.DOCX);
res.setHeader('Content-type', ContentType.DOCX);
res.end(buffer);
} catch (err) {
Expand Down
35 changes: 12 additions & 23 deletions backend/src/app/database/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,47 +62,37 @@ export async function populateDatabase() {
});

const adminModelB = AdminModel.fromObject({
username: 'valentin',
username: 'valentin.stamate',
email: 'stamatevalentin125@gmail.com',
});

const fullProfessorNameA = 'Prof. univ. dr. Buraza Costel';
const fullProfessorNameA = 'Prof.univ.dr. Lenuța Alboaie';
const [professorFunctionA, professorNameA] = UtilService.splitProfessorName(fullProfessorNameA);

const coordinatorModelA = CoordinatorModel.fromObject({
name: professorNameA,
function: professorFunctionA,
email: 'adriana.bejinariu20@gmail.com',
password: '12345!@#$%QwErT',
});

const fullProfessorNameB = 'Prof. univ. dr. Ciochina Stefan';
const [professorFunctionB, professorNameB] = UtilService.splitProfessorName(fullProfessorNameB);

const coordinatorModelB = CoordinatorModel.fromObject({
name: professorNameB,
function: professorFunctionB,
email: 'stamatevalentin125@gmail.com',
password: 'ana.are.mere.125',
password: '12345',
});

const studentModelA = StudentModel.fromObject({
identifier: 'adriana.bejinariu',
fullName: 'Adriana Bejinariu',
email: 'adriana.bejinariu20@gmail.com',
alternativeEmail: 'adriana.bejinariu@info.uaic.ro',
identifier: 'valentin.stamate',
fullName: 'STAMATE D. VALENTIN',
email: 'stamatevalentin125@gmail.com',
alternativeEmail: 'valentin.stamate@info.uaic.ro',
attendanceYear: 2019,
coordinatorName: professorNameA,
coordinatorFunction: professorFunctionA,
isActive: true,
});

const studentModelB = StudentModel.fromObject({
identifier: 'valentin',
fullName: 'Valentin Aioanei',
email: 'stamatevalentin125@gmail.com',
alternativeEmail: 'valentin.stamate@info.uaic.ro',
attendanceYear: 2019,
identifier: '31091020401RSD201007',
fullName: 'CALANCEA C. CRISTINA-GEORGIANA',
email: 'geo.calancea@gmail.com',
alternativeEmail: 'geo.calancea@gmail.com',
attendanceYear: 2020,
coordinatorName: professorNameA,
coordinatorFunction: professorFunctionA,
isActive: true,
Expand All @@ -111,7 +101,6 @@ export async function populateDatabase() {
await adminRepo.save(adminModelA);
await adminRepo.save(adminModelB);
await coordinatorRepo.save(coordinatorModelA);
await coordinatorRepo.save(coordinatorModelB);
await studentRepo.save(studentModelA);
await studentRepo.save(studentModelB);

Expand Down
10 changes: 5 additions & 5 deletions backend/src/app/service/admin.email.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ export class AdminEmailService {

const verbalProcessDataList = XLSXService.parseReportAnnouncement(file, true, startDate, endDate);


if (getEmails) {
return verbalProcessDataList.map(item => `${item.coordinatorEmail}:${item.studentEmail}`);
return verbalProcessDataList.map(item => `${item.coordinatorEmail}`);
}

const emailEndpointResponse: EmailEndpointResponse = {
Expand All @@ -92,7 +91,7 @@ export class AdminEmailService {
};

for (let data of verbalProcessDataList) {
if (!emailToList.some(item => item === `${data.coordinatorEmail}:${data.studentEmail}`)) {
if (!emailToList.some(item => item === `${data.coordinatorEmail}`)) {
continue;
}

Expand Down Expand Up @@ -155,7 +154,7 @@ export class AdminEmailService {
const verbalProcessDataList = XLSXService.parseReportAnnouncement(file, false, startDate, endDate);

if (getEmails) {
return verbalProcessDataList.map(item => `${item.studentEmail}:${item.coordinatorEmail}`);
return verbalProcessDataList.map(item => `Student:${item.studentEmail} Coordonator:${item.coordinatorEmail}`);
}

const emailEndpointResponse: EmailEndpointResponse = {
Expand All @@ -164,7 +163,8 @@ export class AdminEmailService {
};

for (const data of verbalProcessDataList) {
if (!emailToList.some(item => item === `${data.studentEmail}:${data.coordinatorEmail}`)) {
/* For some reason it works like this, without space, I don't know where dissapears */
if (!emailToList.some(item => item === `Student:${data.studentEmail}Coordonator:${data.coordinatorEmail}`)) {
continue;
}

Expand Down
31 changes: 21 additions & 10 deletions backend/src/app/service/admin.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,19 @@ export class AdminService {

await allowedStudentsRepo.clear();

await studentsRepo.createQueryBuilder()
.update()
.set({isActive: false})
.execute();
// await studentsRepo.createQueryBuilder()
// .update()
// .set({isActive: false})
// .execute();

for (let data of allowedStudentsList) {
const model = AllowedStudentModel.fromObject(data);
await allowedStudentsRepo.save(model);

await studentsRepo.createQueryBuilder()
.update()
.set({isActive: true})
.where(`identifier = :identifier`, {identifier: model.identifier});
// await studentsRepo.createQueryBuilder()
// .update()
// .set({isActive: true})
// .where(`identifier = :identifier`, {identifier: model.identifier});

rowsCreated++;
}
Expand Down Expand Up @@ -241,12 +241,23 @@ export class AdminService {
const coordinators = XLSXService.parseCoordinatorsExcel(file);

const coordinatorRepo = dbConnection.getRepository(CoordinatorModel);
await coordinatorRepo.clear();
// await coordinatorRepo.clear();

let rowsCreated = 0;
for (let item of coordinators) {
const model = CoordinatorModel.fromObject(item);
await coordinatorRepo.create(model);

const existingCoordinator = await coordinatorRepo.findOne({
where: {
name: model.name,
}
});

if (existingCoordinator != null) {
continue;
}

await coordinatorRepo.save(model);
rowsCreated++;
}

Expand Down
3 changes: 0 additions & 3 deletions backend/src/app/service/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,6 @@ export class AuthService {
const adminRepo = dbConnection.getRepository(AdminModel);
const authorizationKeyRepo = dbConnection.getRepository(AuthorizationKeyModel);

console.log(username);
console.log(email);

const existingAdmin = await adminRepo.findOne({
where: {
username: username,
Expand Down
1 change: 1 addition & 0 deletions backend/src/app/service/coordinator.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export class CoordinatorService {
where: {
coordinatorName: coordinator.name,
coordinatorFunction: coordinator.function,
isActive: true,
}
});
}
Expand Down
2 changes: 0 additions & 2 deletions backend/src/app/service/student.form.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ export class StudentFormService {

existingStudent.scientificArticleISI = existingStudent.scientificArticleISI ?? [];

console.log(existingStudent);

const report = existingStudent.scientificArticleISI.find(item => `${item.id}` === reportId);

if (report == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@
<div class="email-recipient-container">

<div class="email-recipient" *ngFor="let item of emailToList">
<div>{{item}}</div>
<div>{{item.split(' ')[0]}}</div>
<div>{{item.split(' ')[1]}}</div>
<div class="email-button" (click)="onDeleteEmail(item)">x</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</label>
</div>

<div *ngIf="filename !== ''"><small>Fișierul <b>{{filename}}</b> încărcat cu success.</small></div>
<div *ngIf="filenameCoordinatorFile !== ''"><small>Fișierul <b>{{filenameCoordinatorFile}}</b> încărcat cu success.</small></div>

<div class="field is-grouped">
<div class="control">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
a descărca un fișier dați click pe numele lui, iar pentru stergere, butonul roșu.
</div>

<div class="is-flex is-flex-wrap-wrap" style="gap: 32px">
<div class="is-flex is-flex-wrap-wrap" style="gap: 32px; margin-top: 16px">
<div *ngFor="let item of files" class="is-flex">
<button class="button is-small" (click)="onDownloadFile(item)">{{item.name}}</button>
<button class="button is-small is-danger" (click)="onDeleteFile(item)">X</button>
Expand Down

0 comments on commit 56a6679

Please sign in to comment.