penambahan logic pada cctv
This commit is contained in:
parent
873e24a6ac
commit
e27493171e
|
@ -16,6 +16,7 @@ export class ModalAddActualComponent {
|
||||||
dateCurrent: any;
|
dateCurrent: any;
|
||||||
dataCost: any;
|
dataCost: any;
|
||||||
formattedDate: any;
|
formattedDate: any;
|
||||||
|
formattedDate2: any;
|
||||||
buildingName: any;
|
buildingName: any;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -29,16 +30,14 @@ export class ModalAddActualComponent {
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
const currentDate = new Date();
|
const currentDate = new Date();
|
||||||
this.dateCurrent = currentDate.toISOString().slice(0, 7);
|
this.dateCurrent = currentDate.toISOString().slice(0, 7);
|
||||||
this.datalistcost();
|
|
||||||
this.dateFormat();
|
this.dateFormat();
|
||||||
this.getBuildingById();
|
this.getBuildingById();
|
||||||
|
this.datalistcost();
|
||||||
}
|
}
|
||||||
|
|
||||||
dateFormat() {
|
dateFormat() {
|
||||||
let year = this.periode.slice(0, 4);
|
let year = this.periode.slice(0, 4);
|
||||||
let month = this.periode.slice(5);
|
let month = this.periode.slice(5, 7);
|
||||||
|
|
||||||
// Ubah format bulan ke bahasa Indonesia (opsional)
|
|
||||||
let monthNames = [
|
let monthNames = [
|
||||||
"Januari",
|
"Januari",
|
||||||
"Februari",
|
"Februari",
|
||||||
|
@ -53,10 +52,11 @@ export class ModalAddActualComponent {
|
||||||
"November",
|
"November",
|
||||||
"Desember",
|
"Desember",
|
||||||
];
|
];
|
||||||
let monthName = monthNames[parseInt(month) - 1]; // Menggunakan parseInt karena month dalam format string
|
let monthName = monthNames[parseInt(month) - 1];
|
||||||
|
|
||||||
// Gabungkan kembali untuk mendapatkan format "Juni 2024"
|
|
||||||
this.formattedDate = `${monthName} ${year}`;
|
this.formattedDate = `${monthName} ${year}`;
|
||||||
|
this.formattedDate2 = `${year}-${month}`;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
createForm() {
|
createForm() {
|
||||||
|
@ -73,7 +73,7 @@ export class ModalAddActualComponent {
|
||||||
|
|
||||||
datalistcost() {
|
datalistcost() {
|
||||||
this.costService
|
this.costService
|
||||||
.getRealCostByBuildingId(this.buildingId, this.dateCurrent)
|
.getRealCostByBuildingId(this.buildingId, this.formattedDate2)
|
||||||
.subscribe((data) => {
|
.subscribe((data) => {
|
||||||
this.dataCost = data.data[0];
|
this.dataCost = data.data[0];
|
||||||
this.myForm.patchValue({
|
this.myForm.patchValue({
|
||||||
|
|
|
@ -27,6 +27,8 @@ import { SurveillanceComponent } from './surveillance/surveillance.component';
|
||||||
import { WaterComponent } from './water/water.component';
|
import { WaterComponent } from './water/water.component';
|
||||||
import { NgSelectModule } from '@ng-select/ng-select';
|
import { NgSelectModule } from '@ng-select/ng-select';
|
||||||
import { ControlDeviceSeemoreComponent } from './control-device-seemore/control-device-seemore.component';
|
import { ControlDeviceSeemoreComponent } from './control-device-seemore/control-device-seemore.component';
|
||||||
|
import { HTTP_INTERCEPTORS } from '@angular/common/http';
|
||||||
|
import { HttpErrorInterceptorService } from 'src/app/interceptors/http-error-interceptor.service';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
|
@ -101,6 +103,9 @@ import { ControlDeviceSeemoreComponent } from './control-device-seemore/control-
|
||||||
data: { mode: 'room' }
|
data: { mode: 'room' }
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
{ provide: HTTP_INTERCEPTORS, useClass: HttpErrorInterceptorService, multi: true }
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class MonitoringModule { }
|
export class MonitoringModule { }
|
||||||
|
|
|
@ -214,15 +214,14 @@
|
||||||
style="height: 500px !important"
|
style="height: 500px !important"
|
||||||
></iframe> -->
|
></iframe> -->
|
||||||
|
|
||||||
|
<video id="streamplayer" class="video-js vjs-big-play-centered" style="width: 100% !important; height: 500px !important" autoplay>
|
||||||
<video id="streamplayer" class="video-js vjs-big-play-centered" style="width: 100% !important; height: 500px !important">
|
<source src="" type="application/x-mpegurl">
|
||||||
<source src="#" type="application/x-mpegurl">
|
|
||||||
</video>
|
</video>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-3 col-md-6 col-12" *ngFor="let item of cameras">
|
<div class="col-lg-3 col-md-6 col-12" *ngFor="let item of filteredRows">
|
||||||
<div class="card" style="background-color: #252525 !important">
|
<div class="card" style="background-color: #252525 !important">
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<label style="color: #ffffff">{{ item.name }}</label>
|
<label style="color: #ffffff">{{ item.name }}</label>
|
||||||
|
@ -230,7 +229,7 @@
|
||||||
class="card-img-top img-fluid"
|
class="card-img-top img-fluid"
|
||||||
src="../../../../../assets/images/cctv.jpg"
|
src="../../../../../assets/images/cctv.jpg"
|
||||||
alt="Image 1"
|
alt="Image 1"
|
||||||
(click)="loadStream(item.videoUrl)"
|
(click)="loadStream(item.device_id)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -26,19 +26,21 @@ export class SurveillanceComponent {
|
||||||
public breadcrumb: any;
|
public breadcrumb: any;
|
||||||
showIframe = false;
|
showIframe = false;
|
||||||
clicktrue = false;
|
clicktrue = false;
|
||||||
|
|
||||||
|
bufferingTimeout: any;
|
||||||
|
|
||||||
cameras = [
|
cameras = [
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: "Pengadilan Agama Padang Cam 1",
|
name: "Pengadilan Agama Padang Cam 1",
|
||||||
videoUrl:
|
videoUrl:
|
||||||
"https://wework-7-us.stream.iot-11.com:8080/hls/eb48441e886701e55bbk52/cprg5g0d9fpsg3dvh27gSD1XjuVVd8h8oWqjoFJ6.m3u8?signInfo=C6fuX1l4syLFPeCPQ476iYDjNU_WZC24E6oGVwBvK3k6iIhqjvzzQIAAO5rUJjWLfeqY6YpDPsRB9JGEQTL_ZpxUOJB_L0VfgPX45SAecU_6_6ybAVcK-m0xxUrcGr3_EvzF_d1czqOHplNUMYodotvkWWQ9yP0NOEYJhtMemSw",
|
"https://wework-1-us.stream.iot-11.com:8080/hls/eb48441e886701e55bbk52/cpsgbti59barred964v0pXFm2hujw6pfrksNebnJ.m3u8?signInfo=1nOzF8oTGaesUDaWKWwVvm48YUWzA1giepIfLDeyEYHizShw3V4xT0zp9YI7NBbpOiPBfg1zDalVkjzpVQL_6l9z6Q3TptY5lOW3FkZFb7U3lbqHzHiLCh89GKPH6DvUzYXymA4X2hsKU89jJ9y9UwVZwUxs0jHq19rk3CrZ0cE",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
name: "Pengadilan Agama Padang Cam 2",
|
name: "Pengadilan Agama Padang Cam 2",
|
||||||
videoUrl:
|
videoUrl:
|
||||||
"https://pdg2.cctvbadilag.my.id:5443/401900PTAPADANG/play.html?name=671014455048381705129283",
|
"https://wework-4-us.stream.iot-11.com:8080/hls/eb48441e886701e55bbk52/cpsgq28n0asmj2buiihgh0ssY0CuqMVC9LCVeEQH.m3u8?signInfo=0j00FMq5E3kn3oIImQU1laHoYvbLKZuQ8f_IPgKZjRPysw_xbZGfXpbqqP05DnRlsyG40oPuYr2dSylrSppO4vkr0YtJqeTTy0FELIv4nrLAv2vcMyD6So4NJev-nmHpS3GPOIuTiy879xuADEtnYMIt5BqU68L3s9yKaJx5AAE",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 3,
|
id: 3,
|
||||||
|
@ -53,7 +55,7 @@ export class SurveillanceComponent {
|
||||||
"https://bdg2.cctvbadilag.my.id:5443/400854PAPURWAKARTA/play.html?name=113658520181242556385273",
|
"https://bdg2.cctvbadilag.my.id:5443/400854PAPURWAKARTA/play.html?name=113658520181242556385273",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
private intervalId: any;
|
||||||
player: any;
|
player: any;
|
||||||
constructor(
|
constructor(
|
||||||
private router: Router,
|
private router: Router,
|
||||||
|
@ -88,35 +90,112 @@ export class SurveillanceComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
const options = {
|
const deviceid = localStorage.getItem("deviceId");
|
||||||
controls: true,
|
const parsedData = JSON.parse(deviceid);
|
||||||
preload: "none",
|
console.log(parsedData, "parsedData");
|
||||||
techOrder: ["html5"],
|
|
||||||
html5: {
|
|
||||||
hls: {
|
|
||||||
overrideNative: !videojs.browser.IS_SAFARI,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
this.player = videojs("streamplayer", options);
|
this.deviceService
|
||||||
|
.getStreamUrl(parsedData.device_id)
|
||||||
|
.subscribe((data) => {
|
||||||
|
console.log("hit ini");
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
controls: true,
|
||||||
|
autoplay: true,
|
||||||
|
preload: "none",
|
||||||
|
techOrder: ["html5"],
|
||||||
|
html5: {
|
||||||
|
hls: {
|
||||||
|
overrideNative: !videojs.browser.IS_SAFARI,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
this.player = videojs("streamplayer", options);
|
||||||
|
this.player.src({
|
||||||
|
type: "application/x-mpegURL",
|
||||||
|
src: data.result.data.result.url,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Event listener for errors
|
||||||
|
this.player.on("error", () => {
|
||||||
|
const error = this.player.error();
|
||||||
|
console.error("Video error:", error);
|
||||||
|
// Handle the error
|
||||||
|
});
|
||||||
|
|
||||||
|
// Event listener for stalled
|
||||||
|
this.player.on("stalled", () => {
|
||||||
|
console.warn("Video playback stalled");
|
||||||
|
// Handle the stall
|
||||||
|
});
|
||||||
|
|
||||||
|
this.player.on("waiting", () => {
|
||||||
|
console.warn("Video playback buffer");
|
||||||
|
this.clearBufferingTimeout();
|
||||||
|
this.bufferingTimeout = setTimeout(() => {
|
||||||
|
const savedData = localStorage.getItem("deviceId");
|
||||||
|
const parsedData = JSON.parse(savedData);
|
||||||
|
console.log('masuk timeout buffer');
|
||||||
|
this.loadStream(parsedData.device_id);
|
||||||
|
}, 60000);
|
||||||
|
});
|
||||||
|
this.player.on("playing", () => {
|
||||||
|
this.clearBufferingTimeout();
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
loadStream(streamUrl) {
|
loadStream(device_id) {
|
||||||
this.player.src({
|
localStorage.setItem("deviceId", JSON.stringify({ device_id: device_id }));
|
||||||
type: "application/x-mpegURL",
|
this.deviceService.getStreamUrl(device_id).subscribe((data) => {
|
||||||
src: streamUrl,
|
this.player.src({
|
||||||
|
type: "application/x-mpegURL",
|
||||||
|
src: data.result.data.result.url,
|
||||||
|
});
|
||||||
|
this.player.controls(true);
|
||||||
|
this.player.play();
|
||||||
});
|
});
|
||||||
this.player.controls(true);
|
}
|
||||||
this.player.play();
|
|
||||||
|
clearBufferingTimeout() {
|
||||||
|
if (this.bufferingTimeout) {
|
||||||
|
clearTimeout(this.bufferingTimeout);
|
||||||
|
this.bufferingTimeout = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchData(buildingSelected, categorySelected, statusSelected) {
|
fetchData(buildingSelected, categorySelected, statusSelected) {
|
||||||
this.deviceService
|
this.deviceService
|
||||||
.getDeviceData(buildingSelected, categorySelected, statusSelected)
|
.getDeviceData(buildingSelected, categorySelected, statusSelected)
|
||||||
.subscribe((res) => {
|
.subscribe((res) => {
|
||||||
this.filteredRows = res.results.data;
|
this.filteredRows = res.results.data.filter(
|
||||||
console.log(this.filteredRows);
|
(item) => item.category_id === 30
|
||||||
|
);
|
||||||
|
localStorage.setItem(
|
||||||
|
"deviceId",
|
||||||
|
JSON.stringify({ device_id: this.filteredRows[0].device_id })
|
||||||
|
);
|
||||||
|
this.deviceService
|
||||||
|
.getStreamUrl(this.filteredRows[0].device_id)
|
||||||
|
.subscribe((data) => {
|
||||||
|
const options = {
|
||||||
|
controls: true,
|
||||||
|
autoplay: true,
|
||||||
|
preload: "none",
|
||||||
|
techOrder: ["html5"],
|
||||||
|
html5: {
|
||||||
|
hls: {
|
||||||
|
overrideNative: !videojs.browser.IS_SAFARI,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
this.player = videojs("streamplayer", options);
|
||||||
|
this.player.src({
|
||||||
|
type: "application/x-mpegURL",
|
||||||
|
src: data.result.data.result.url,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
console.log(this.filteredRows, "filteredrow");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,6 +220,12 @@ export class SurveillanceComponent {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dataListDevice() {
|
||||||
|
this.monitoringApiService.getBuildingList().subscribe((data) => {
|
||||||
|
this.dataBuildingList = data.data.filter((item) => item.statusId === 2);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
doFilter() {
|
doFilter() {
|
||||||
this.spinnerFilterActive = true;
|
this.spinnerFilterActive = true;
|
||||||
this.fetchData(
|
this.fetchData(
|
||||||
|
@ -153,6 +238,14 @@ export class SurveillanceComponent {
|
||||||
}, 3000);
|
}, 3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnDestroy() {
|
||||||
|
localStorage.removeItem("deviceId");
|
||||||
|
this.clearBufferingTimeout();
|
||||||
|
if (this.player) {
|
||||||
|
this.player.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// onClick(videoUrl: string) {
|
// onClick(videoUrl: string) {
|
||||||
// const iframe = this.videoIframe.nativeElement;
|
// const iframe = this.videoIframe.nativeElement;
|
||||||
// iframe.src = videoUrl;
|
// iframe.src = videoUrl;
|
||||||
|
|
|
@ -60,4 +60,14 @@ export class DeviceService {
|
||||||
});
|
});
|
||||||
return this.http.post<any>(url, data, { headers });
|
return this.http.post<any>(url, data, { headers });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getStreamUrl(id): Observable<any> {
|
||||||
|
const endpoint = `/devices`;
|
||||||
|
const url = `${BASE_URL}${endpoint}/live-stream?device_id=${id}`;
|
||||||
|
const headers = new HttpHeaders({
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'x-api-key': 'j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT'
|
||||||
|
});
|
||||||
|
return this.http.get<any>(url, { headers });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue