Clasroom view in dialog component

pull/5/head
Alvaro Puente Mella 2024-07-19 13:59:03 +02:00
parent 81cef1fd97
commit 6845936ac6
6 changed files with 30 additions and 10 deletions

View File

@ -67,6 +67,7 @@ import {
MatTreeNodeToggle MatTreeNodeToggle
} from "@angular/material/tree"; } from "@angular/material/tree";
import { LegendComponent } from './components/groups/legend/legend.component'; import { LegendComponent } from './components/groups/legend/legend.component';
import { ClassroomViewDialogComponent } from './components/groups/classroom-view/classroom-view-modal';
@NgModule({ @NgModule({
declarations: [ declarations: [
@ -97,7 +98,8 @@ import { LegendComponent } from './components/groups/legend/legend.component';
DeleteGroupsModalComponent, DeleteGroupsModalComponent,
ShowOrganizationalUnitComponent, ShowOrganizationalUnitComponent,
TreeViewComponent, TreeViewComponent,
LegendComponent LegendComponent,
ClassroomViewDialogComponent
], ],
bootstrap: [AppComponent], bootstrap: [AppComponent],
imports: [BrowserModule, imports: [BrowserModule,

View File

@ -2,8 +2,7 @@
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
gap: 10px; gap: 10px;
min-height: 43vh; height: 90%;
height: 1000px;
border: 3px solid black; border: 3px solid black;
} }
@ -132,3 +131,7 @@ mat-chip {
justify-content: center; justify-content: center;
margin-bottom: 25px; margin-bottom: 25px;
} }
button{
margin-bottom: 10px;
}

View File

@ -1,7 +1,7 @@
<button mat-flat-button color="primary" (click)="saveDisposition()">Guardar disposición</button> <button mat-flat-button color="primary" (click)="saveDisposition()">Guardar disposición</button>
<div class="classroom"> <div class="classroom">
<mat-card *ngFor="let group of groupedClients" class="classroom-group"> <mat-card *ngFor="let group of groupedClients" class="classroom-group">
<mat-card-title>Clientes dentro de: {{ group.organizationalUnitName }}</mat-card-title> <mat-card-title>{{ group.organizationalUnitName }}</mat-card-title>
<div class="misc-clients"> <div class="misc-clients">
<div class="classroom-board" cdkDrag cdkDragBoundary=".classroom">Pizarra digital</div> <div class="classroom-board" cdkDrag cdkDragBoundary=".classroom">Pizarra digital</div>
<img mat-card-image src="assets/images/proyector.png" alt="Proyector" class="proyector-image" cdkDrag cdkDragBoundary=".classroom"/> <img mat-card-image src="assets/images/proyector.png" alt="Proyector" class="proyector-image" cdkDrag cdkDragBoundary=".classroom"/>

View File

@ -20,6 +20,7 @@ export class ClassroomViewComponent implements OnInit, OnChanges {
groupedClients: GroupedClients[] = []; groupedClients: GroupedClients[] = [];
constructor(public dialog: MatDialog, private http: HttpClient) {} constructor(public dialog: MatDialog, private http: HttpClient) {}
ngOnInit(): void { ngOnInit(): void {
this.groupClientsByOrganizationalUnit(); this.groupClientsByOrganizationalUnit();
@ -52,12 +53,13 @@ export class ClassroomViewComponent implements OnInit, OnChanges {
this.groupedClients.forEach(group => { this.groupedClients.forEach(group => {
group.clientRows.forEach(row => { group.clientRows.forEach(row => {
row.forEach(client => { row.forEach(client => {
const position = client.position; // Ya es un objeto, no necesita JSON.parse const position = client.position || { x: 0, y: 0 };
client.dragPosition = { x: position.x, y: position.y }; client.dragPosition = { x: position.x, y: position.y };
}); });
}); });
}); });
} }
chunkArray(arr: any[], chunkSize: number): any[][] { chunkArray(arr: any[], chunkSize: number): any[][] {
const chunks = []; const chunks = [];
@ -75,10 +77,6 @@ export class ClassroomViewComponent implements OnInit, OnChanges {
const dragPosition = event.source.getFreeDragPosition() const dragPosition = event.source.getFreeDragPosition()
client.position.x = dragPosition.x; client.position.x = dragPosition.x;
client.position.y = dragPosition.y; client.position.y = dragPosition.y;
console.log("el drag", event.source.getFreeDragPosition().x)
/* console.log('Elemento movido:', event.source.element.nativeElement);
console.log('Posición actual:', event.pointerPosition);
console.log('Posición relativa:', dragPosition); */
} }
saveDisposition(): void { saveDisposition(): void {

View File

@ -3,6 +3,7 @@
<div class="groups-button-row"> <div class="groups-button-row">
<button mat-flat-button color="primary" (click)="addOU($event)">Nueva Unidad Organizativa</button> <button mat-flat-button color="primary" (click)="addOU($event)">Nueva Unidad Organizativa</button>
<button mat-flat-button color="primary" (click)="addClient($event)">Nuevo Cliente</button> <button mat-flat-button color="primary" (click)="addClient($event)">Nuevo Cliente</button>
<button mat-flat-button color="primary" (click)="roomMap()" *ngIf="selectedDetail && selectedDetail.type === 'classroom'">Plano de aula</button>
<button mat-raised-button (click)="openBottomSheet()">Leyenda</button> <button mat-raised-button (click)="openBottomSheet()">Leyenda</button>
</div> </div>
</div> </div>
@ -142,5 +143,5 @@
</mat-card-content> </mat-card-content>
</mat-card> </mat-card>
<app-classroom-view class="card classroom-view" [clients]="clientsData" [pcInTable]="5"></app-classroom-view> <!-- <app-classroom-view class="card classroom-view" [clients]="clientsData" [pcInTable]="5"></app-classroom-view> -->
</div> </div>

View File

@ -13,6 +13,8 @@ import {ToastrService} from "ngx-toastr";
import {TreeViewComponent} from "./tree-view/tree-view.component"; import {TreeViewComponent} from "./tree-view/tree-view.component";
import {MatBottomSheet} from "@angular/material/bottom-sheet"; import {MatBottomSheet} from "@angular/material/bottom-sheet";
import {LegendComponent} from "./legend/legend.component"; import {LegendComponent} from "./legend/legend.component";
import { ClassroomViewComponent } from './classroom-view/classroom-view.component';
import { ClassroomViewDialogComponent } from './classroom-view/classroom-view-modal';
@Component({ @Component({
selector: 'app-groups', selector: 'app-groups',
@ -251,4 +253,18 @@ constructor(
openBottomSheet(): void { openBottomSheet(): void {
this._bottomSheet.open(LegendComponent); this._bottomSheet.open(LegendComponent);
} }
roomMap(): void {
if (this.selectedDetail && this.selectedDetail.type === 'classroom') {
const dialogRef = this.dialog.open(ClassroomViewDialogComponent, {
width: '90vw',
height: '90vh',
data: { clients: this.clientsData }
});
dialogRef.afterClosed().subscribe(result => {
console.log('The dialog was closed');
});
}
}
} }