refactor(ui): simplify room names and remove dead code
This commit is contained in:
@@ -12,7 +12,7 @@ const MOCK_ROOM = ROOM_LAYOUTS.find(r => r.id === 'A1')!;
|
||||
|
||||
const makeReading = (co2: number, i = 0): SensorReading => ({
|
||||
roomId: 'A1',
|
||||
roomName: 'A1 - Auditorium',
|
||||
roomName: 'A1',
|
||||
co2,
|
||||
temperature: 21.5,
|
||||
humidity: 45,
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
} from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ActivatedRoute, RouterModule } from '@angular/router';
|
||||
import { toSignal } from '@angular/core/rxjs-interop';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { RoomLayout } from '../../config/rooms-layout.config';
|
||||
import { getCO2Color, getCO2Level } from '../../config/co2-levels.config';
|
||||
@@ -31,14 +30,11 @@ export class RoomDetailsPanelComponent implements OnInit {
|
||||
private roomService = inject(RoomService);
|
||||
private sensorService = inject(SensorService);
|
||||
|
||||
roomId = toSignal(this.route.paramMap.pipe(map(params => params.get('id'))));
|
||||
|
||||
room = signal<RoomLayout | undefined>(undefined);
|
||||
latestReading = signal<SensorReading | undefined>(undefined);
|
||||
history = signal<SensorReading[]>([]);
|
||||
|
||||
currentPage = signal(0);
|
||||
readonly pageSize = PAGE_SIZE;
|
||||
|
||||
totalPages = computed(() => Math.ceil(this.history().length / PAGE_SIZE));
|
||||
pagedHistory = computed(() => {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { ChangeDetectionStrategy, Component, OnInit, inject, signal } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Router } from '@angular/router';
|
||||
import { combineLatest } from 'rxjs';
|
||||
import { RoomLayout } from '../../config/rooms-layout.config';
|
||||
@@ -18,7 +17,7 @@ export interface RoomMapEntry {
|
||||
@Component({
|
||||
selector: 'app-room-map',
|
||||
standalone: true,
|
||||
imports: [CommonModule, LegendComponent],
|
||||
imports: [LegendComponent],
|
||||
templateUrl: './room-map.component.html',
|
||||
styleUrl: './room-map.component.scss',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
|
||||
@@ -23,7 +23,7 @@ export const ROOM_LAYOUTS: RoomLayout[] = [
|
||||
// ========================================
|
||||
{
|
||||
id: 'B1',
|
||||
name: 'B1 - Meeting Room',
|
||||
name: 'B1',
|
||||
espace: 'B',
|
||||
floor: 1,
|
||||
type: 'meeting',
|
||||
@@ -36,7 +36,7 @@ export const ROOM_LAYOUTS: RoomLayout[] = [
|
||||
},
|
||||
{
|
||||
id: 'B2',
|
||||
name: 'B2 - Lab',
|
||||
name: 'B2',
|
||||
espace: 'B',
|
||||
floor: 1,
|
||||
type: 'lab',
|
||||
@@ -49,7 +49,7 @@ export const ROOM_LAYOUTS: RoomLayout[] = [
|
||||
},
|
||||
{
|
||||
id: 'B3',
|
||||
name: 'B3 - Office',
|
||||
name: 'B3',
|
||||
espace: 'B',
|
||||
floor: 1,
|
||||
type: 'office',
|
||||
@@ -62,7 +62,7 @@ export const ROOM_LAYOUTS: RoomLayout[] = [
|
||||
},
|
||||
{
|
||||
id: 'B4',
|
||||
name: 'B4 - Storage',
|
||||
name: 'B4',
|
||||
espace: 'B',
|
||||
floor: 1,
|
||||
type: 'storage',
|
||||
@@ -79,7 +79,7 @@ export const ROOM_LAYOUTS: RoomLayout[] = [
|
||||
// ========================================
|
||||
{
|
||||
id: 'A1',
|
||||
name: 'A1 - Auditorium',
|
||||
name: 'A1',
|
||||
espace: 'A',
|
||||
floor: 1,
|
||||
type: 'auditorium',
|
||||
@@ -92,7 +92,7 @@ export const ROOM_LAYOUTS: RoomLayout[] = [
|
||||
},
|
||||
{
|
||||
id: 'A2',
|
||||
name: 'A2 - Lecture Hall',
|
||||
name: 'A2',
|
||||
espace: 'A',
|
||||
floor: 1,
|
||||
type: 'classroom',
|
||||
@@ -105,7 +105,7 @@ export const ROOM_LAYOUTS: RoomLayout[] = [
|
||||
},
|
||||
{
|
||||
id: 'A3',
|
||||
name: 'A3 - Workshop',
|
||||
name: 'A3',
|
||||
espace: 'A',
|
||||
floor: 1,
|
||||
type: 'workshop',
|
||||
@@ -118,7 +118,7 @@ export const ROOM_LAYOUTS: RoomLayout[] = [
|
||||
},
|
||||
{
|
||||
id: 'A4',
|
||||
name: 'A4 - Open Space',
|
||||
name: 'A4',
|
||||
espace: 'A',
|
||||
floor: 1,
|
||||
type: 'openspace',
|
||||
@@ -131,7 +131,7 @@ export const ROOM_LAYOUTS: RoomLayout[] = [
|
||||
},
|
||||
{
|
||||
id: 'A5',
|
||||
name: 'A5 - Conference',
|
||||
name: 'A5',
|
||||
espace: 'A',
|
||||
floor: 1,
|
||||
type: 'conference',
|
||||
@@ -144,7 +144,7 @@ export const ROOM_LAYOUTS: RoomLayout[] = [
|
||||
},
|
||||
{
|
||||
id: 'A6',
|
||||
name: 'A6 - Study Room',
|
||||
name: 'A6',
|
||||
espace: 'A',
|
||||
floor: 1,
|
||||
type: 'study',
|
||||
@@ -157,7 +157,7 @@ export const ROOM_LAYOUTS: RoomLayout[] = [
|
||||
},
|
||||
{
|
||||
id: 'A7',
|
||||
name: 'A7 - Lab',
|
||||
name: 'A7',
|
||||
espace: 'A',
|
||||
floor: 1,
|
||||
type: 'lab',
|
||||
@@ -170,7 +170,7 @@ export const ROOM_LAYOUTS: RoomLayout[] = [
|
||||
},
|
||||
{
|
||||
id: 'A8',
|
||||
name: 'A8 - Classroom',
|
||||
name: 'A8',
|
||||
espace: 'A',
|
||||
floor: 1,
|
||||
type: 'classroom',
|
||||
@@ -183,7 +183,7 @@ export const ROOM_LAYOUTS: RoomLayout[] = [
|
||||
},
|
||||
{
|
||||
id: 'A9',
|
||||
name: 'A9 - Office',
|
||||
name: 'A9',
|
||||
espace: 'A',
|
||||
floor: 1,
|
||||
type: 'office',
|
||||
@@ -195,44 +195,3 @@ export const ROOM_LAYOUTS: RoomLayout[] = [
|
||||
hasSensor: true,
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* Get room layout by ID
|
||||
*/
|
||||
export function getRoomById(roomId: string): RoomLayout | undefined {
|
||||
return ROOM_LAYOUTS.find(room => room.id === roomId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rooms by espace (A or B)
|
||||
*/
|
||||
export function getRoomsByEspace(espace: 'A' | 'B'): RoomLayout[] {
|
||||
return ROOM_LAYOUTS.filter(room => room.espace === espace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all rooms with sensors
|
||||
*/
|
||||
export function getRoomsWithSensors(): RoomLayout[] {
|
||||
return ROOM_LAYOUTS.filter(room => room.hasSensor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get total number of rooms
|
||||
*/
|
||||
export function getTotalRooms(): number {
|
||||
return ROOM_LAYOUTS.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get room center point (for tooltip positioning)
|
||||
*/
|
||||
export function getRoomCenter(roomId: string): { x: number; y: number } | null {
|
||||
const room = getRoomById(roomId);
|
||||
if (!room) return null;
|
||||
|
||||
return {
|
||||
x: room.x + room.width / 2,
|
||||
y: room.y + room.height / 2,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user