New clients room position
parent
ae57c3c8cf
commit
8769793464
|
@ -13,8 +13,8 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|||
import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
|
||||
import { CustomInterceptor } from './services/custom.interceptor';
|
||||
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
|
||||
import {MatToolbarModule} from '@angular/material/toolbar';
|
||||
import {MatIconModule} from '@angular/material/icon';
|
||||
import { MatToolbarModule } from '@angular/material/toolbar';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatSidenavModule } from '@angular/material/sidenav';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
|
@ -26,37 +26,37 @@ import { MatInputModule } from '@angular/material/input';
|
|||
import { MatListModule } from '@angular/material/list';
|
||||
import { UsersComponent } from './components/pages/admin/users/users/users.component';
|
||||
import { RolesComponent } from './components/pages/admin/roles/roles/roles.component';
|
||||
import {MatTableModule} from '@angular/material/table';
|
||||
import {MatDialogModule} from '@angular/material/dialog';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { DeleteUserModalComponent } from './components/pages/admin/users/users/delete-user-modal/delete-user-modal.component';
|
||||
import { AddUserModalComponent } from './components/pages/admin/users/users/add-user-modal/add-user-modal.component';
|
||||
import {MatSelectModule} from '@angular/material/select';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { EditUserModalComponent } from './components/pages/admin/users/users/edit-user-modal/edit-user-modal.component';
|
||||
import { AddRoleModalComponent } from './components/pages/admin/roles/roles/add-role-modal/add-role-modal.component';
|
||||
import { DeleteRoleModalComponent } from './components/pages/admin/roles/roles/delete-role-modal/delete-role-modal.component';
|
||||
import { ChangePasswordModalComponent } from './components/pages/admin/users/users/change-password-modal/change-password-modal.component';
|
||||
import { GroupsComponent } from './components/groups/groups.component';
|
||||
import {MatDividerModule} from '@angular/material/divider';
|
||||
import { MatDividerModule } from '@angular/material/divider';
|
||||
import { CreateOrganizationalUnitComponent } from './components/groups/organizational-units/create-organizational-unit/create-organizational-unit.component';
|
||||
import {MatStepperModule} from '@angular/material/stepper';
|
||||
import { MatStepperModule } from '@angular/material/stepper';
|
||||
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
|
||||
import { CreateClientComponent } from './components/groups/clients/create-client/create-client.component';
|
||||
import { DeleteModalComponent } from './components/groups/delete-modal/delete-modal.component';
|
||||
import { EditOrganizationalUnitComponent } from './components/groups/organizational-units/edit-organizational-unit/edit-organizational-unit.component';
|
||||
import { EditClientComponent } from './components/groups/clients/edit-client/edit-client.component';
|
||||
import { ClassroomViewComponent } from './components/groups/classroom-view/classroom-view.component';
|
||||
import {MatProgressSpinner} from "@angular/material/progress-spinner";
|
||||
import {MatMenu, MatMenuItem, MatMenuTrigger} from "@angular/material/menu";
|
||||
import {MatAutocomplete} from "@angular/material/autocomplete";
|
||||
import {MatChip, MatChipListbox, MatChipOption, MatChipSet, MatChipsModule} from "@angular/material/chips";
|
||||
import { MatProgressSpinner } from "@angular/material/progress-spinner";
|
||||
import { MatMenu, MatMenuItem, MatMenuTrigger } from "@angular/material/menu";
|
||||
import { MatAutocomplete } from "@angular/material/autocomplete";
|
||||
import { MatChip, MatChipListbox, MatChipOption, MatChipSet, MatChipsModule } from "@angular/material/chips";
|
||||
import { ClientViewComponent } from './components/groups/client-view/client-view.component';
|
||||
import {MatTab, MatTabGroup} from "@angular/material/tabs";
|
||||
import {MatTooltip} from "@angular/material/tooltip";
|
||||
import { MatTab, MatTabGroup } from "@angular/material/tabs";
|
||||
import { MatTooltip } from "@angular/material/tooltip";
|
||||
import { DeleteGroupsModalComponent } from './components/groups/delete-groups-modal/delete-groups-modal.component';
|
||||
|
||||
import { DragDropModule } from '@angular/cdk/drag-drop';
|
||||
import { ToastrModule } from 'ngx-toastr';
|
||||
import { ShowOrganizationalUnitComponent } from './components/groups/organizational-units/show-organizational-unit/show-organizational-unit.component';
|
||||
import {MatGridList} from "@angular/material/grid-list";
|
||||
import { MatGridList } from "@angular/material/grid-list";
|
||||
import { TreeViewComponent } from './components/groups/tree-view/tree-view.component';
|
||||
import {
|
||||
MatNestedTreeNode,
|
||||
|
@ -68,37 +68,38 @@ import {
|
|||
} from "@angular/material/tree";
|
||||
import { LegendComponent } from './components/groups/legend/legend.component';
|
||||
|
||||
@NgModule({ declarations: [
|
||||
AppComponent,
|
||||
AuthLayoutComponent,
|
||||
MainLayoutComponent,
|
||||
HeaderComponent,
|
||||
SidebarComponent,
|
||||
LoginComponent,
|
||||
AdminComponent,
|
||||
MainLayoutComponent,
|
||||
UsersComponent,
|
||||
RolesComponent,
|
||||
DeleteUserModalComponent,
|
||||
AddUserModalComponent,
|
||||
EditUserModalComponent,
|
||||
AddRoleModalComponent,
|
||||
DeleteRoleModalComponent,
|
||||
ChangePasswordModalComponent,
|
||||
GroupsComponent,
|
||||
CreateOrganizationalUnitComponent,
|
||||
CreateClientComponent,
|
||||
DeleteModalComponent,
|
||||
EditOrganizationalUnitComponent,
|
||||
EditClientComponent,
|
||||
ClassroomViewComponent,
|
||||
ClientViewComponent,
|
||||
DeleteGroupsModalComponent,
|
||||
ShowOrganizationalUnitComponent,
|
||||
TreeViewComponent,
|
||||
LegendComponent
|
||||
],
|
||||
bootstrap: [AppComponent],
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AppComponent,
|
||||
AuthLayoutComponent,
|
||||
MainLayoutComponent,
|
||||
HeaderComponent,
|
||||
SidebarComponent,
|
||||
LoginComponent,
|
||||
AdminComponent,
|
||||
MainLayoutComponent,
|
||||
UsersComponent,
|
||||
RolesComponent,
|
||||
DeleteUserModalComponent,
|
||||
AddUserModalComponent,
|
||||
EditUserModalComponent,
|
||||
AddRoleModalComponent,
|
||||
DeleteRoleModalComponent,
|
||||
ChangePasswordModalComponent,
|
||||
GroupsComponent,
|
||||
CreateOrganizationalUnitComponent,
|
||||
CreateClientComponent,
|
||||
DeleteModalComponent,
|
||||
EditOrganizationalUnitComponent,
|
||||
EditClientComponent,
|
||||
ClassroomViewComponent,
|
||||
ClientViewComponent,
|
||||
DeleteGroupsModalComponent,
|
||||
ShowOrganizationalUnitComponent,
|
||||
TreeViewComponent,
|
||||
LegendComponent
|
||||
],
|
||||
bootstrap: [AppComponent],
|
||||
imports: [BrowserModule,
|
||||
AppRoutingModule,
|
||||
FormsModule,
|
||||
|
@ -118,6 +119,7 @@ import { LegendComponent } from './components/groups/legend/legend.component';
|
|||
MatSelectModule,
|
||||
MatDividerModule,
|
||||
MatStepperModule,
|
||||
DragDropModule,
|
||||
MatSlideToggleModule, MatMenu, MatMenuTrigger, MatMenuItem, MatAutocomplete, MatChipListbox, MatChipOption, MatChipSet, MatChipsModule, MatChip, MatProgressSpinner, MatTabGroup, MatTab, MatTooltip,
|
||||
ToastrModule.forRoot(
|
||||
{
|
||||
|
@ -130,16 +132,17 @@ import { LegendComponent } from './components/groups/legend/legend.component';
|
|||
}
|
||||
), MatGridList, MatTree, MatTreeNode, MatNestedTreeNode, MatTreeNodeToggle, MatTreeNodeDef, MatTreeNodePadding, MatTreeNodeOutlet
|
||||
],
|
||||
schemas: [
|
||||
CUSTOM_ELEMENTS_SCHEMA,
|
||||
],
|
||||
providers: [
|
||||
{
|
||||
provide: HTTP_INTERCEPTORS,
|
||||
useClass: CustomInterceptor,
|
||||
multi: true
|
||||
},
|
||||
provideAnimationsAsync(),
|
||||
provideHttpClient(withInterceptorsFromDi())
|
||||
], })
|
||||
schemas: [
|
||||
CUSTOM_ELEMENTS_SCHEMA,
|
||||
],
|
||||
providers: [
|
||||
{
|
||||
provide: HTTP_INTERCEPTORS,
|
||||
useClass: CustomInterceptor,
|
||||
multi: true
|
||||
},
|
||||
provideAnimationsAsync(),
|
||||
provideHttpClient(withInterceptorsFromDi())
|
||||
],
|
||||
})
|
||||
export class AppModule { }
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
min-height: 43vh;
|
||||
height: 1000px;
|
||||
border: 3px solid black;
|
||||
}
|
||||
|
||||
.classroom-group {
|
||||
|
@ -26,7 +28,7 @@ mat-card {
|
|||
|
||||
.proyector-image {
|
||||
width: auto;
|
||||
height: 100px; /* Ajusta la altura según sea necesario */
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
.client-info {
|
||||
|
@ -37,8 +39,8 @@ mat-card {
|
|||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background-color: rgba(0, 0, 0, 0); /* Fondo semitransparente para el texto */
|
||||
color: black; /* Color del texto */
|
||||
background-color: rgba(0, 0, 0, 0);
|
||||
color: black;
|
||||
text-align: center;
|
||||
padding: 10px;
|
||||
box-sizing: border-box;
|
||||
|
@ -121,7 +123,7 @@ mat-chip {
|
|||
align-items: center;
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
margin-right: 20px; /* Espacio entre la pizarra y el proyector */
|
||||
margin-right: 20px;
|
||||
}
|
||||
|
||||
.misc-clients {
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
<mat-card *ngFor="let group of groupedClients" class="classroom-group">
|
||||
<mat-card-title>Clientes dentro de: {{ group.organizationalUnitName }}</mat-card-title>
|
||||
<div class="misc-clients">
|
||||
<div class="classroom-board">Pizarra digital</div>
|
||||
<img mat-card-image src="assets/images/proyector.png" alt="Proyector" class="proyector-image"/>
|
||||
<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"/>
|
||||
</div>
|
||||
<div *ngFor="let row of group.clientRows" class="client-row">
|
||||
<div class="client-container" *ngFor="let client of row">
|
||||
<div class="client-container" *ngFor="let client of row"
|
||||
cdkDrag [cdkDragFreeDragPosition]="client.dragPosition" (cdkDragMoved)="onDragMoved($event)" cdkDragBoundary=".classroom">
|
||||
<div class="client-box" (click)="handleClientClick(client)">
|
||||
<mat-card appearance="outlined">
|
||||
<div class="client-image-container">
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import {MatDialog} from "@angular/material/dialog";
|
||||
import {ClientViewComponent} from "../client-view/client-view.component";
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ClientViewComponent } from "../client-view/client-view.component";
|
||||
import { CdkDragEnd, CdkDragMove } from '@angular/cdk/drag-drop';
|
||||
|
||||
interface GroupedClients {
|
||||
organizationalUnitName: string;
|
||||
|
@ -21,10 +22,12 @@ export class ClassroomViewComponent implements OnInit {
|
|||
|
||||
ngOnInit(): void {
|
||||
this.groupClientsByOrganizationalUnit();
|
||||
this.initializeClientPositions();
|
||||
}
|
||||
|
||||
ngOnChanges(): void {
|
||||
this.groupClientsByOrganizationalUnit();
|
||||
this.initializeClientPositions();
|
||||
}
|
||||
|
||||
groupClientsByOrganizationalUnit(): void {
|
||||
|
@ -37,10 +40,92 @@ export class ClassroomViewComponent implements OnInit {
|
|||
return acc;
|
||||
}, {});
|
||||
|
||||
this.groupedClients = Object.keys(grouped).map(ouName => ({
|
||||
/* this.groupedClients = Object.keys(grouped).map(ouName => ({
|
||||
organizationalUnitName: ouName,
|
||||
clientRows: this.chunkArray(grouped[ouName], this.pcInTable)
|
||||
}));
|
||||
})); */
|
||||
|
||||
this.groupedClients = [{
|
||||
"organizationalUnitName": "Aula01",
|
||||
"clientRows": [
|
||||
[
|
||||
{
|
||||
"@id": "/clients/0190b603-3e40-7256-90dd-ea04b4ea0e41",
|
||||
"@type": "Client",
|
||||
"name": "PC1",
|
||||
"position": `{"x": -165, "y": -93}`,
|
||||
"type": "client",
|
||||
"ip": "127.0.0.1",
|
||||
"mac": "00:00:00:00:1",
|
||||
"serialNumber": "1",
|
||||
"netiface": "eth0",
|
||||
"netDriver": "generic",
|
||||
"organizationalUnit": {
|
||||
"@id": "/organizational-units/0190b602-35f2-7026-a42a-cc310ed07921",
|
||||
"@type": "OrganizationalUnit",
|
||||
"name": "Aula01",
|
||||
"type": "classroom",
|
||||
"networkSettings": {
|
||||
"@id": "/network-settings/0190b602-35f2-7026-a42a-cc310f5c8648",
|
||||
"@type": "NetworkSettings",
|
||||
"validation": false,
|
||||
"uuid": "0190b602-35f2-7026-a42a-cc310f5c8648",
|
||||
"id": 2
|
||||
},
|
||||
"uuid": "0190b602-35f2-7026-a42a-cc310ed07921",
|
||||
"id": 2
|
||||
},
|
||||
"partitions": [],
|
||||
"createdAt": "2024-07-15T10:49:44+00:00",
|
||||
"createdBy": "ogadmin",
|
||||
"uuid": "0190b603-3e40-7256-90dd-ea04b4ea0e41",
|
||||
"id": 1
|
||||
},
|
||||
{
|
||||
"@id": "/clients/0190b603-e73e-7033-bba1-309d4672f581",
|
||||
"@type": "Client",
|
||||
"name": "PC2",
|
||||
"position": `{"x": -65, "y": 55}`,
|
||||
"type": "client",
|
||||
"ip": "123.0.0.2",
|
||||
"mac": "00:00:00:00:2",
|
||||
"serialNumber": "2",
|
||||
"netiface": "eth0",
|
||||
"organizationalUnit": {
|
||||
"@id": "/organizational-units/0190b602-35f2-7026-a42a-cc310ed07921",
|
||||
"@type": "OrganizationalUnit",
|
||||
"name": "Aula01",
|
||||
"type": "classroom",
|
||||
"networkSettings": {
|
||||
"@id": "/network-settings/0190b602-35f2-7026-a42a-cc310f5c8648",
|
||||
"@type": "NetworkSettings",
|
||||
"validation": false,
|
||||
"uuid": "0190b602-35f2-7026-a42a-cc310f5c8648",
|
||||
"id": 2
|
||||
},
|
||||
"uuid": "0190b602-35f2-7026-a42a-cc310ed07921",
|
||||
"id": 2
|
||||
},
|
||||
"partitions": [],
|
||||
"createdAt": "2024-07-15T10:50:27+00:00",
|
||||
"createdBy": "ogadmin",
|
||||
"uuid": "0190b603-e73e-7033-bba1-309d4672f581",
|
||||
"id": 2
|
||||
},
|
||||
]
|
||||
]
|
||||
}]
|
||||
}
|
||||
|
||||
initializeClientPositions(): void {
|
||||
this.groupedClients.forEach(group => {
|
||||
group.clientRows.forEach(row => {
|
||||
row.forEach(client => {
|
||||
const position = JSON.parse(client.position);
|
||||
client.dragPosition = { x: position.x, y: position.y };
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
chunkArray(arr: any[], chunkSize: number): any[][] {
|
||||
|
@ -52,6 +137,12 @@ export class ClassroomViewComponent implements OnInit {
|
|||
}
|
||||
|
||||
handleClientClick(client: any): void {
|
||||
const dialogRef = this.dialog.open(ClientViewComponent, { data: { client }, width: '800px', height:'700px'});
|
||||
const dialogRef = this.dialog.open(ClientViewComponent, { data: { client }, width: '800px', height:'700px' });
|
||||
}
|
||||
|
||||
onDragMoved(event: CdkDragMove<any>): void {
|
||||
console.log('Elemento movido:', event.source.element.nativeElement);
|
||||
console.log('Posición actual:', event.pointerPosition);
|
||||
console.log('Posición relativa:', event.distance);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue