Skip to content

Commit

Permalink
refactor: removed csv
Browse files Browse the repository at this point in the history
  • Loading branch information
TitoMoi committed Oct 4, 2023
1 parent 0e911ab commit b181632
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 66 deletions.
6 changes: 0 additions & 6 deletions src/app/assignment/assignment.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@
</div>

<ng-container *ngIf="assignmentsTable.length">
<mat-icon
class="mx-3"
svgIcon="csvSvg"
[matTooltip]="t('ICON_EXPORT_CSV')"
(click)="exportCsv()"
></mat-icon>
<mat-icon
class="mx-3"
svgIcon="search"
Expand Down
57 changes: 0 additions & 57 deletions src/app/assignment/assignment.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { SortService } from "app/services/sort.service";
import { RoomService } from "app/room/service/room.service";
import { AssignTypeService } from "app/assigntype/service/assigntype.service";
import { ParticipantService } from "app/participant/service/participant.service";
import { NoteService } from "app/note/service/note.service";
import { ParticipantPipe } from "../participant/pipe/participant.pipe";
import { RoomPipe } from "../room/pipe/room.pipe";
import { AssignTypePipe } from "../assigntype/pipe/assign-type.pipe";
Expand Down Expand Up @@ -112,12 +111,9 @@ export class AssignmentComponent implements OnInit, OnDestroy, AfterViewChecked
private roomService: RoomService,
private assignTypeService: AssignTypeService,
private participantService: ParticipantService,
private noteService: NoteService,
private lastDateService: LastDateService,
private sortService: SortService,
private assignTypeNamePipe: AssignTypeNamePipe,
private onlineService: OnlineService,
private roomNamePipe: RoomNamePipe,
private cdr: ChangeDetectorRef
) {
this.getAssignments();
Expand Down Expand Up @@ -283,57 +279,4 @@ export class AssignmentComponent implements OnInit, OnDestroy, AfterViewChecked
preventDefault(event) {
event.stopPropagation();
}

exportCsv() {
let data = "";
let headers = "";
const rows = [];
const keys = Object.keys(this.assignmentsTable[0]);
for (const key of keys) {
headers = headers + key + ";";
}
headers = headers + "\n";
rows.push(headers);

for (const assign of this.assignmentsTable) {
data = ""; //reset row
for (const key of keys) {
switch (key) {
case "room":
data =
data + this.roomNamePipe.transform(this.roomService.getRoom(assign[key])) + ";";
break;
case "assignType":
data =
data +
this.assignTypeNamePipe.transform(
this.assignTypeService.getAssignType(assign[key])
) +
";";
break;
case "principal":
data = data + this.participantService.getParticipant(assign[key]).name + ";";
break;
case "assistant":
this.participantService.getParticipant(assign[key]);
data = data + this.participantService.getParticipant(assign[key])?.name + ";";
break;
case "footerNote":
data = data + this.noteService.getNote(assign[key])?.editorHTML + ";";
break;

default:
data = data + assign[key] + ";";
break;
}
}
data = data + "\n";
rows.push(data);
}
const a: any = document.createElement("a");
const file = new Blob(rows, { type: "text/csv" });
a.href = URL.createObjectURL(file);
a.download = "assignments.csv";
a.click();
}
}
6 changes: 3 additions & 3 deletions src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@
"CONFIG_ZIP_UPLOAD": "Upload Zip file",
"CONFIG_ZIP_UPLOADED": "Zip uploaded",
"ICON_CLIPBOARD": "Copy to the clipboard",
"ICON_EXCEL": "Colorful Excel sheet",
"ICON_EXPORT_CSV": "Export all assignments into a csv file",
"ICON_FOLDER": "Generate png files (takes a while)",
"ICON_GOOGLECALENDAR": "Create a link for google calendar reminder",
"ICON_GROUP_DELETE": "Delete all assignments of certain day",
Expand Down Expand Up @@ -387,5 +385,7 @@
"CONFIG_DEFAULT_FONT_SIZE": "XXXREMOVE THISXXXX",
"ICON_PDF_BAND": "Generate a colorful pdf specially for the midweek with bands and up to two weeks per page",
"ICON_PDF_BAND_WEEKEND": "Generate a colorful pdf specially for the weekend with bands and up to five weeks per page",
"ASSIGNTYPES_CHAIRMAN": "Chairman"
"ASSIGNTYPES_CHAIRMAN": "Chairman",
"ICON_EXCEL": "XXXREMOVE THISXXX",
"ICON_EXPORT_CSV": "XXXREMOVE THISXXX"
}

0 comments on commit b181632

Please sign in to comment.