2024-02-01 11:37:15 +08:00
|
|
|
@{
|
|
|
|
string script = "@";
|
|
|
|
Layout = "~/Views/Shared/_Layout_Engineering.cshtml";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
<h1>WEBCAM參數</h1>
|
|
|
|
<div>
|
|
|
|
<button class="btn btn-primary" onclick="add_webcam_view.showModal()" id="add_webcam_id">新增攝像頭</button>
|
|
|
|
<table class="table">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>
|
|
|
|
停車場位置
|
|
|
|
</th>
|
|
|
|
<th>
|
|
|
|
攝像頭帳號
|
|
|
|
</th>
|
|
|
|
<th>
|
|
|
|
攝像頭密碼
|
|
|
|
</th>
|
|
|
|
<th>
|
|
|
|
IP位置
|
|
|
|
</th>
|
|
|
|
<th>
|
|
|
|
使用Port
|
|
|
|
</th>
|
|
|
|
<th>
|
|
|
|
攝像頭使用模式
|
|
|
|
</th>
|
|
|
|
<th>
|
|
|
|
|
|
|
|
</th>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
|
|
|
|
<tbody id="demo">
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!--彈跳視窗-->
|
|
|
|
<div>
|
|
|
|
<dialog id="add_webcam_view" style="width:80%;">
|
|
|
|
<div>
|
|
|
|
<button class="btn btn-danger" style="float:right" onclick="add_webcam_view.close();"> 關閉</button>
|
|
|
|
停車場位置 :
|
|
|
|
<select style="width:30%;" id="select_parking_spaces_name_id">
|
|
|
|
</select></br></br>
|
|
|
|
攝像頭帳號 : <input type="text" id="add_user_name_text_id" /></br></br>
|
|
|
|
攝像頭密碼 : <input type="text" id="add_password_text_id" /></br></br>
|
|
|
|
IP位置 : <input type="text" id="add_ip_text_id" /></br></br>
|
|
|
|
RTSP使用Port(串流) : <input type="text" id="add_rtsp_port_text_id" /></br></br>
|
|
|
|
HTTP使用Port(控制) : <input type="text" id="add_http_port_text_id" /></br></br>
|
|
|
|
攝像頭使用模式 :
|
|
|
|
<select size="1" id="select_mode_id">
|
|
|
|
<option value="pass">停車場進出</option>
|
|
|
|
<option value="violation">判斷違規左右轉 </option>
|
|
|
|
<option value="car_num_check">數量確認 </option>
|
|
|
|
</select></br></br>
|
|
|
|
<button class="btn btn-success" onclick="add_webcam()">上傳</button>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</dialog>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!--獲取資料-->
|
|
|
|
<script>
|
|
|
|
var token = localStorage.getItem('token_park_space');
|
|
|
|
var token_ckeck //= document.getElementById("token_ckeck_id").value
|
|
|
|
var position //職位
|
|
|
|
function get_data() {
|
|
|
|
//token_check = document.getElementById("token_check_id").value
|
|
|
|
console.log(token_check)
|
|
|
|
$.ajax({
|
|
|
|
type: "GET",
|
2024-09-13 23:32:32 +08:00
|
|
|
url: "http://localhost:7700/api/Parking_spaces_cam",
|
2024-02-01 11:37:15 +08:00
|
|
|
data: {},
|
|
|
|
headers: {
|
|
|
|
'Authorization': token
|
|
|
|
},
|
|
|
|
contentType: "application/json",
|
2024-02-14 21:39:44 +08:00
|
|
|
headers: {
|
|
|
|
'Authorization': token
|
|
|
|
},
|
2024-02-01 11:37:15 +08:00
|
|
|
success: function (Model) {
|
|
|
|
console.log(Model)
|
|
|
|
set_data(Model)
|
|
|
|
get_data_2()
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
function get_data_2() {
|
|
|
|
//token_check = document.getElementById("token_check_id").value
|
|
|
|
console.log(token_check)
|
|
|
|
$.ajax({
|
|
|
|
type: "GET",
|
2024-09-13 23:32:32 +08:00
|
|
|
url: "http://localhost:7700/api/Parking_spaces_total_table",
|
2024-02-01 11:37:15 +08:00
|
|
|
data: {},
|
|
|
|
headers: {
|
|
|
|
'Authorization': token
|
|
|
|
},
|
|
|
|
contentType: "application/json",
|
2024-02-14 21:39:44 +08:00
|
|
|
headers: {
|
|
|
|
'Authorization': token
|
|
|
|
},
|
2024-02-01 11:37:15 +08:00
|
|
|
success: function (Model) {
|
|
|
|
console.log(Model)
|
|
|
|
set_data_2(Model)
|
|
|
|
get_data_3()
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_data_3() {
|
|
|
|
//token_check = document.getElementById("token_check_id").value
|
|
|
|
console.log(token_check)
|
|
|
|
$.ajax({
|
|
|
|
type: "GET",
|
2024-09-13 23:32:32 +08:00
|
|
|
url: "http://localhost:7700/api/Parking_spaces_violation_total_table",
|
2024-02-01 11:37:15 +08:00
|
|
|
data: {},
|
|
|
|
headers: {
|
|
|
|
'Authorization': token
|
|
|
|
},
|
|
|
|
contentType: "application/json",
|
2024-02-14 21:39:44 +08:00
|
|
|
headers: {
|
|
|
|
'Authorization': token
|
|
|
|
},
|
2024-02-01 11:37:15 +08:00
|
|
|
success: function (Model) {
|
|
|
|
console.log(Model)
|
|
|
|
set_data_3(Model)
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<!--放置資料-->
|
|
|
|
<script>
|
|
|
|
function set_data(Model) {
|
|
|
|
table = "<tr>";
|
|
|
|
console.log(Model.length)
|
|
|
|
if (Model.length > 0) {
|
|
|
|
for (var i = 0; i < Model.length; i++) {
|
|
|
|
if (Model[i].parking_spaces_name != null) {
|
|
|
|
if (parseInt(Model[i].port) > 400) {
|
|
|
|
table += "<td>" + Model[i].parking_spaces_name + "</td>"
|
|
|
|
table += "<td>" + Model[i].user_name + "</td>"
|
|
|
|
table += "<td>" + Model[i].password + "</td>"
|
|
|
|
table += "<td>" + Model[i].ip + "</td>"
|
|
|
|
table += "<td>" + Model[i].port + "</td>"
|
|
|
|
if (Model[i].mode == "pass") { mode = "停車場進出" }
|
|
|
|
if (Model[i].mode == "violation") { mode = "判斷違規左右轉" }
|
|
|
|
if (Model[i].mode == "car_num_check") { mode = "數量確認" }
|
|
|
|
table += "<td>" +mode + "</td>"
|
|
|
|
table += "<td>" + '<button class="btn btn-outline-success " onclick="CAM_detail(' + "'" + Model[i].parking_spaces_name + ":" + Model[i].ip + ":" + Model[i].port + "'" + ')">詳細</button>'
|
|
|
|
}
|
|
|
|
table += "</tr>"
|
|
|
|
table += "<tr>"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
document.getElementById("demo").innerHTML = table
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_data_2(Model) {
|
|
|
|
var obj = document.getElementById("select_parking_spaces_name_id");
|
|
|
|
if (Model.length > 0) {
|
|
|
|
for (var i = 0; i < Model.length; i++) {
|
|
|
|
if (Model[i].parking_spaces_name != null) {
|
|
|
|
obj.options.add(new Option(Model[i].parking_spaces_name));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_data_3(Model) {
|
|
|
|
var obj = document.getElementById("select_parking_spaces_name_id");
|
|
|
|
if (Model.length > 0) {
|
|
|
|
for (var i = 0; i < Model.length; i++) {
|
|
|
|
if (Model[i].parking_spaces_violation_name != null) {
|
|
|
|
obj.options.add(new Option(Model[i].parking_spaces_violation_name));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<!--上傳資料-->
|
|
|
|
<script>
|
|
|
|
function add_webcam() {
|
|
|
|
var parking_spaces_name = document.getElementById("select_parking_spaces_name_id").value
|
|
|
|
var user_name = document.getElementById("add_user_name_text_id").value
|
|
|
|
var password = document.getElementById("add_password_text_id").value
|
|
|
|
var ip = document.getElementById("add_ip_text_id").value
|
|
|
|
var port = document.getElementById("add_rtsp_port_text_id").value
|
|
|
|
var http_port = document.getElementById("add_http_port_text_id").value
|
|
|
|
var mode = document.getElementById("select_mode_id").value
|
|
|
|
if (parseInt(port) > 400) {
|
|
|
|
var url = `rtsp://${user_name}:${password}@script${ip}:${port}/stream1`
|
|
|
|
console.log(url)
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var url = `http://${user_name}:${password}@script${ip}:${port}`
|
|
|
|
console.log(url)
|
|
|
|
}
|
|
|
|
var obj = {
|
|
|
|
parking_spaces_name: parking_spaces_name,
|
|
|
|
user_name: user_name,
|
|
|
|
password: password,
|
|
|
|
ip: ip,
|
|
|
|
port: port,
|
|
|
|
http_port: http_port,
|
|
|
|
mode: mode,
|
|
|
|
url: url,
|
|
|
|
}
|
|
|
|
|
|
|
|
var stringify_obj = JSON.stringify(obj);
|
|
|
|
$.ajax({
|
|
|
|
type: "Post",
|
2024-09-13 23:32:32 +08:00
|
|
|
url: "http://localhost:7700/api/Parking_spaces_cam",
|
2024-02-01 11:37:15 +08:00
|
|
|
//data: {test_id: test_id, test_date: test_date, test_time: test_time, test_analyst: test_analyst, img: img, data_creat_time: "2022-10-04T18:47:40.887014" },
|
|
|
|
data: stringify_obj,
|
|
|
|
contentType: "application/json",
|
|
|
|
headers: {
|
|
|
|
'Authorization': token
|
|
|
|
},
|
|
|
|
success: function (msg) {
|
|
|
|
console.log(msg)
|
|
|
|
add_roi()
|
|
|
|
add_webcam_view.close()
|
|
|
|
get_data()
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<!--上傳ROI資料-->
|
|
|
|
<script>
|
|
|
|
function add_roi(){
|
|
|
|
var parking_spaces_name = document.getElementById("select_parking_spaces_name_id").value
|
|
|
|
var user_name = document.getElementById("add_user_name_text_id").value
|
|
|
|
var password = document.getElementById("add_password_text_id").value
|
|
|
|
var ip = document.getElementById("add_ip_text_id").value
|
|
|
|
var port = document.getElementById("add_rtsp_port_text_id").value
|
|
|
|
var http_port = document.getElementById("add_http_port_text_id").value
|
|
|
|
var mode = document.getElementById("select_mode_id").value
|
|
|
|
if (parseInt(port) > 400) {
|
|
|
|
var url = `rtsp://${user_name}:${password}@script${ip}:${port}/stream1`
|
|
|
|
console.log(url)
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var url = `http://${user_name}:${password}@script${ip}:${port}`
|
|
|
|
console.log(url)
|
|
|
|
}
|
|
|
|
if (mode == "pass") {
|
|
|
|
var obj = {
|
|
|
|
parking_spaces_name: parking_spaces_name,
|
|
|
|
cam_ip: url,
|
|
|
|
roi_x1: "0",
|
|
|
|
roi_x2: "100",
|
|
|
|
roi_y1: "0",
|
|
|
|
roi_y2: "100",
|
|
|
|
roi_function: "CAR_ROI_license_plate",
|
|
|
|
mode: mode,
|
|
|
|
}
|
|
|
|
|
|
|
|
var stringify_obj = JSON.stringify(obj);
|
|
|
|
$.ajax({
|
|
|
|
type: "Post",
|
2024-09-13 23:32:32 +08:00
|
|
|
url: "http://localhost:7700/api/Parking_spaces_roi_pass",
|
2024-02-01 11:37:15 +08:00
|
|
|
//data: {test_id: test_id, test_date: test_date, test_time: test_time, test_analyst: test_analyst, img: img, data_creat_time: "2022-10-04T18:47:40.887014" },
|
|
|
|
data: stringify_obj,
|
|
|
|
contentType: "application/json",
|
|
|
|
headers: {
|
|
|
|
'Authorization': token
|
|
|
|
},
|
|
|
|
success: function (msg) {
|
|
|
|
console.log(msg)
|
|
|
|
add_ptz()
|
|
|
|
add_webcam_view.close()
|
|
|
|
get_data()
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mode == "violation") {
|
|
|
|
add_ptz()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<!--上傳PTZ資料-->
|
|
|
|
<script>
|
|
|
|
function add_ptz() {
|
|
|
|
var parking_spaces_name = document.getElementById("select_parking_spaces_name_id").value
|
|
|
|
var user_name = document.getElementById("add_user_name_text_id").value
|
|
|
|
var password = document.getElementById("add_password_text_id").value
|
|
|
|
var ip = document.getElementById("add_ip_text_id").value
|
|
|
|
var port = document.getElementById("add_rtsp_port_text_id").value
|
|
|
|
var http_port = document.getElementById("add_http_port_text_id").value
|
|
|
|
var mode = document.getElementById("select_mode_id").value
|
|
|
|
if (parseInt(port) > 400) {
|
|
|
|
var url = `rtsp://${user_name}:${password}@script${ip}:${port}/stream1`
|
|
|
|
console.log(url)
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var url = `http://${user_name}:${password}@script${ip}:${port}`
|
|
|
|
console.log(url)
|
|
|
|
}
|
|
|
|
if (mode == "pass") {
|
|
|
|
var obj = {
|
|
|
|
parking_spaces_name: parking_spaces_name,
|
|
|
|
rtsp_url: url,
|
|
|
|
rtsp_port: port,
|
|
|
|
http_port: http_port,
|
|
|
|
mode: mode,
|
|
|
|
img: "",
|
|
|
|
pan: "0",
|
|
|
|
titl: "0",
|
|
|
|
zoom: "0",
|
|
|
|
create_data_time: "1"
|
|
|
|
}
|
|
|
|
|
|
|
|
var stringify_obj = JSON.stringify(obj);
|
|
|
|
$.ajax({
|
|
|
|
type: "Post",
|
2024-09-13 23:32:32 +08:00
|
|
|
url: "http://localhost:7700/api/Parking_spaces_cam_ptz_pass",
|
2024-02-01 11:37:15 +08:00
|
|
|
//data: {test_id: test_id, test_date: test_date, test_time: test_time, test_analyst: test_analyst, img: img, data_creat_time: "2022-10-04T18:47:40.887014" },
|
|
|
|
data: stringify_obj,
|
|
|
|
contentType: "application/json",
|
|
|
|
headers: {
|
|
|
|
'Authorization': token
|
|
|
|
},
|
|
|
|
success: function (msg) {
|
|
|
|
console.log(msg)
|
|
|
|
add_webcam_view.close()
|
|
|
|
get_data()
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mode == "violation") {
|
|
|
|
var obj = {
|
|
|
|
parking_spaces_name: parking_spaces_name,
|
|
|
|
rtsp_url: url,
|
|
|
|
rtsp_port: port,
|
|
|
|
http_port: http_port,
|
|
|
|
mode: mode,
|
|
|
|
img: "",
|
|
|
|
pan: "0",
|
|
|
|
titl: "0",
|
|
|
|
zoom: "0",
|
|
|
|
create_data_time: "1"
|
|
|
|
}
|
|
|
|
|
|
|
|
var stringify_obj = JSON.stringify(obj);
|
|
|
|
$.ajax({
|
|
|
|
type: "Post",
|
2024-09-13 23:32:32 +08:00
|
|
|
url: "http://localhost:7700/api/Parking_spaces_cam_ptz_violation",
|
2024-02-01 11:37:15 +08:00
|
|
|
//data: {test_id: test_id, test_date: test_date, test_time: test_time, test_analyst: test_analyst, img: img, data_creat_time: "2022-10-04T18:47:40.887014" },
|
|
|
|
data: stringify_obj,
|
|
|
|
contentType: "application/json",
|
|
|
|
headers: {
|
|
|
|
'Authorization': token
|
|
|
|
},
|
|
|
|
success: function (msg) {
|
|
|
|
console.log(msg)
|
|
|
|
add_webcam_view.close()
|
|
|
|
get_data()
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!--跳轉頁面-->
|
|
|
|
<script>
|
|
|
|
function CAM_detail(name) {
|
|
|
|
window.location = "/Engineering/Engineering_CAM_detail/" + name;
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!--檢查token-->
|
|
|
|
<script>
|
2024-02-14 21:39:44 +08:00
|
|
|
var token
|
2024-02-01 11:37:15 +08:00
|
|
|
function token_check() {
|
|
|
|
// 检查本地存储中是否存在JWT令牌
|
2024-02-14 21:39:44 +08:00
|
|
|
token = localStorage.getItem('token_park_space');
|
2024-02-01 11:37:15 +08:00
|
|
|
console.log(token)
|
|
|
|
$.ajax({
|
|
|
|
type: "GET",
|
2024-09-13 23:32:32 +08:00
|
|
|
url: 'http://localhost:7700/Users/token_check',
|
2024-02-01 11:37:15 +08:00
|
|
|
headers: {
|
|
|
|
'Authorization': token
|
|
|
|
},
|
|
|
|
success: function (response) {
|
|
|
|
console.log(response)
|
|
|
|
token_check = "true"
|
|
|
|
from_token_import_id()
|
|
|
|
},
|
|
|
|
error: function (xhr) {
|
|
|
|
console.log("1")
|
|
|
|
token_check = "false"
|
|
|
|
window.location.href = '/';
|
|
|
|
//get_data()
|
|
|
|
// 处理错误响应,例如跳转到未授权页面
|
|
|
|
//window.location.href = 'https://example.com/unauthorized_page';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function from_token_import_id() {
|
|
|
|
var token = localStorage.getItem('token_park_space');
|
|
|
|
$.ajax({
|
|
|
|
type: "GET",
|
2024-09-13 23:32:32 +08:00
|
|
|
url: 'http://localhost:7700/Users/token-' + token,
|
2024-02-01 11:37:15 +08:00
|
|
|
headers: {
|
|
|
|
'Authorization': token
|
|
|
|
},
|
|
|
|
success: function (response) {
|
|
|
|
console.log(response)
|
|
|
|
from_id_import_user_data(response)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
function from_id_import_user_data(id) {
|
|
|
|
var token = localStorage.getItem('token_park_space');
|
|
|
|
$.ajax({
|
|
|
|
type: "GET",
|
2024-09-13 23:32:32 +08:00
|
|
|
url: 'http://localhost:7700/Users/user_id-' + id,
|
2024-02-01 11:37:15 +08:00
|
|
|
headers: {
|
|
|
|
'Authorization': token
|
|
|
|
},
|
|
|
|
success: function (model) {
|
|
|
|
model = model.result
|
|
|
|
position = model.lastname
|
|
|
|
console.log(position)
|
|
|
|
if (position == "engineer"){
|
|
|
|
get_data()
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
window.location.href = '/';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<!--開機自啟-->
|
|
|
|
<script>
|
|
|
|
window.onload = token_check;
|
|
|
|
</script>
|