Browse Source

fix title

pull/6/head
PhamY0601 1 year ago
parent
commit
18ace6298a
2 changed files with 73 additions and 32 deletions
  1. +1
    -1
      src/app/modules/overview/map/map.component.html
  2. +72
    -31
      src/app/modules/overview/map/map.component.ts

+ 1
- 1
src/app/modules/overview/map/map.component.html View File

<div class="map-container"> <div class="map-container">
<h2>ATMs Security Monitoring and Control</h2>
<h2>Security Monitoring and Control</h2>
<div class="map-frame"> <div class="map-frame">
<div id="map"></div> <div id="map"></div>
</div> </div>

+ 72
- 31
src/app/modules/overview/map/map.component.ts View File

}) })
export class MapComponent implements OnInit, AfterViewInit, OnDestroy { export class MapComponent implements OnInit, AfterViewInit, OnDestroy {
private map!: L.Map; private map!: L.Map;
private featureGroup!: L.FeatureGroup;
private statusSubscription?: Subscription; private statusSubscription?: Subscription;
private messageSubscription?: Subscription; private messageSubscription?: Subscription;
sensorOff = ICON.sensorOff; sensorOff = ICON.sensorOff;
iconSize: [170, 48], iconSize: [170, 48],
className: 'hidden-background' className: 'hidden-background'
}); });

sensorOffIcon = L.divIcon({
html: this.sensorOff,
iconSize: [150, 38],
className: 'hidden-background'
});

sensorOnIcon = L.divIcon({
html: this.sensorOn,
iconSize: [150, 38],
className: 'hidden-background'
});
// sensorOffIcon = L.icon({
// iconUrl: '../../../../assets/images/sensor-off.png',
// iconSize: [38, 38],
// });

// sensorOnIcon = L.icon({
// iconUrl: '../../../../assets/images/sensor-on.png',
// iconSize: [38, 38],
// });


state5 = false; state5 = false;
state6 = false; state6 = false;


attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>' attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(this.map); }).addTo(this.map);


this.featureGroup = L.featureGroup().addTo(this.map);
this.addIconToMap(); this.addIconToMap();
} else { } else {
console.error('Map container not found'); console.error('Map container not found');
this.addIconToMap(); this.addIconToMap();
} }


applyIcon(state1: boolean, state2: boolean, type:any): L.Icon | L.DivIcon {

applyIcon(state1: boolean, state2: boolean, type:any) {
if (state1 && state2) { if (state1 && state2) {
return type==='smoke' ? this.sensorSmokeIcon : this.sensorVibIcon;
return type === 'smoke' ? this.sensorSmokeIcon : this.sensorVibIcon;
} }
if (state1) {
return this.sensorOnIcon;
}
return this.sensorOffIcon;
const isOn = state1;
const systemName = type === 'smoke' ? 'Hệ thống báo động 1' : 'Hệ thống báo động 2';
const htmlContent = this.createSensorIconHTML(
systemName,
'120 Xa Lộ Hà Nội, Thành Phố, Thủ Đức, Thành phố Hồ Chí Minh',
'10.8661° N, 106.8029° E',
'01:54, 16/05/2022',
isOn
);
return L.divIcon({
html: htmlContent,
iconSize: [150, 38],
className: 'hidden-background'
});
} }


createSensorIconHTML(systemName:any, location:any, coordinates:any, time:any, isOn:any) {
const imageUrl = isOn ? 'assets/images/sensor-on.png' : 'assets/images/sensor-off.png';
return `<div style="display: flex; flex-direction: column; align-items: center">
<div style="display: flex; flex-direction: row; gap: 5px">
<div class="tooltip">
<img style="width: 30px; height: 30px;" src="${imageUrl}">
<div class="tooltiptext">
<div style="display: flex; flex-direction: row; justify-content: space-between;">
<div style="color: #F33152; padding: 5px 13px; background-color: rgba(243, 49, 82, 0.1); border-radius: 20px; text-align: center; width: 120px;">${systemName}</div>
<a href="/overview/camera-stream">
<svg width="24px" height="24px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="none">
<g stroke="currentColor" stroke-width="2">
<path d="M16 16V8a1 1 0 00-1-1H5a1 1 0 00-1 1v8a1 1 0 001 1h10a1 1 0 001-1z"/>
<path stroke-linejoin="round" d="M20 7l-4 3v4l4 3V7z"/>
</g>
</svg>
</a>
</div>
<div><strong>Địa điểm:</strong> ${location}</div>
<div><strong>Tọa độ:</strong> ${coordinates}</div>
<div><strong>Thời gian:</strong> ${time}</div>
<a href="/overview/overall-ground" target="_blank">Xem chi tiết</a>
</div>
</div>
<a href="/overview/camera-stream" target="_blank">
<img style="width: 30px; height: 30px;" src="assets/images/camera.png">
</a>
</div>
</div>
<style>
.tooltip {
position: relative;
display: inline-block;
}
.tooltip .tooltiptext {
visibility: hidden;
width: 300px;
padding: 10px;
background-color: #fff;
color: black;
border-radius: 6px;
position: absolute;
z-index: 1;
bottom: 100%;
left: 50%;
margin-left: -60px;
}
.tooltip:hover .tooltiptext {
visibility: visible;
}
</style>`;
}

} }

Loading…
Cancel
Save