Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into dev
  • Loading branch information
PierpaoloSpadafora committed Dec 6, 2024
2 parents b531f63 + 24f87aa commit f63d0c0
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</td>
<td>{{ getMachineTypeName(job.idMachineType) }}</td>
<td class="actions-cell">
<button class="action-button" title="Export">
<button class="action-button" title="Export" (click)="exportJob(job)">
<i class="fas fa-file-export"></i>
</button>
<button class="action-button edit" title="Edit" (click)="openEditDialog(job)">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,20 @@ export class ViewExportDeleteJobsComponent implements OnInit {
return 'status-unknown';
}
}

exportJob(job: JobDTO): void {
const enrichedJob = {
...job,
machineTypeName: this.getMachineTypeName(job.idMachineType)
};
const jsonContent = JSON.stringify(enrichedJob, null, 2);
const blob = new Blob([jsonContent], { type: 'application/json' });
const url = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = `job_${job.id}_export.json`;
link.click();
window.URL.revokeObjectURL(url);
this.showMessage(`Job ${job.id} exported successfully`);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<td>{{ type.name }}</td>
<td>{{ type.description }}</td>
<td class="actions-cell">
<button class="action-button" title="Export">
<button class="action-button" title="Export" (click)="exportMachineType(type)">
<i class="fas fa-file-export"></i>
</button>
<button class="action-button edit" title="Edit" (click)="openEditDialog(type)">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,16 @@ export class ViewExportDeleteMachineTypesComponent implements OnInit {
}
});
}

exportMachineType(machineType: MachineType): void {
const jsonContent = JSON.stringify(machineType, null, 2);
const blob = new Blob([jsonContent], { type: 'application/json' });
const url = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = `machine_type_${machineType.id}_export.json`;
link.click();
window.URL.revokeObjectURL(url);
this.showMessage(`Machine Type ${machineType.id} exported successfully`);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</td>
<td>{{ getMachineTypeName(machine.typeId) }}</td>
<td class="actions-cell">
<button class="action-button" title="Export">
<button class="action-button" title="Export" (click)="exportMachine(machine)">
<i class="fas fa-file-export"></i>
</button>
<button class="action-button edit" title="Edit" (click)="openEditDialog(machine)">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,20 @@ export class ViewExportDeleteMachinesComponent implements OnInit {
verticalPosition: 'top'
});
}

exportMachine(machine: Machine): void {
const enrichedMachine = {
...machine,
machineTypeName: this.getMachineTypeName(machine.typeId)
};
const jsonContent = JSON.stringify(enrichedMachine, null, 2);
const blob = new Blob([jsonContent], { type: 'application/json' });
const url = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = `machine_${machine.id}_export.json`;
link.click();
window.URL.revokeObjectURL(url);
this.showMessage(`Machine ${machine.id} exported successfully`);
}
}

0 comments on commit f63d0c0

Please sign in to comment.