2024-02-01 11:37:15 +08:00
|
|
|
|
|
|
|
|
|
@{
|
|
|
|
|
ViewData["Title"] = "Engineering_LED_detail";
|
|
|
|
|
Layout = "~/Views/Shared/_Layout_Engineering.cshtml";
|
|
|
|
|
string parking_spaces_name = ViewBag.parking_spaces_name;
|
|
|
|
|
}
|
|
|
|
|
<input type="hidden" id="parking_spaces_name_id" value=@parking_spaces_name />
|
|
|
|
|
|
|
|
|
|
<h1>@parking_spaces_name 字幕機</h1>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
<p>
|
|
|
|
|
設定LED字幕機參數 :</br>
|
|
|
|
|
預設密碼:26888</br>
|
|
|
|
|
網路參數高級設置:密碼需要與路由器的子網路遮罩一樣(例:255.255.255.0 , 密碼就為ffffff00)
|
|
|
|
|
</p>
|
|
|
|
|
<table class="table">
|
|
|
|
|
<thead>
|
|
|
|
|
<tr>
|
|
|
|
|
<th>
|
|
|
|
|
停車場位置
|
|
|
|
|
</th>
|
|
|
|
|
<th>
|
|
|
|
|
字幕機IP
|
|
|
|
|
</th>
|
|
|
|
|
<th>
|
|
|
|
|
字幕機 PORT
|
|
|
|
|
</th>
|
|
|
|
|
<th>
|
|
|
|
|
顯示參數
|
|
|
|
|
</th>
|
|
|
|
|
<th>
|
|
|
|
|
|
|
|
|
|
</th>
|
|
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
|
|
|
|
|
<tbody id="demo">
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!--獲取資料-->
|
|
|
|
|
<script>
|
|
|
|
|
var token = localStorage.getItem('token_park_space');
|
|
|
|
|
var token_ckeck //確認token
|
|
|
|
|
var position //職位
|
|
|
|
|
var parking_spaces_name = document.getElementById("parking_spaces_name_id").value
|
|
|
|
|
function get_data() {
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "GET",
|
2024-02-14 21:39:44 +08:00
|
|
|
|
url: "http://localhost:5174/api/Parking_spaces_lcd_instand",
|
2024-02-01 11:37:15 +08:00
|
|
|
|
data: {},
|
|
|
|
|
headers: {
|
|
|
|
|
'Authorization': token
|
|
|
|
|
},
|
|
|
|
|
contentType: "application/json",
|
|
|
|
|
success: function (Model) {
|
|
|
|
|
console.log(Model)
|
|
|
|
|
set_data(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 == parking_spaces_name) {
|
|
|
|
|
table += "<td>" + Model[i].parking_spaces_name + "</td>"
|
|
|
|
|
|
|
|
|
|
var NewArray = Model[i].lcd_ip.split(":");
|
|
|
|
|
table += "<td>" + NewArray[0] + "</td>"
|
|
|
|
|
table += "<td>" + NewArray[1] + "</td>"
|
|
|
|
|
table += "<td>" + '<input type="text" id = "parking_space_amount_id" value =' + Model[i].parking_space_amount + ' />' + "</td > "
|
|
|
|
|
table += "<td>" + '<button class="btn btn-outline-warning " onclick="Update_detail(' + "'" + Model[i].parking_spaces_name + "'" + ')">更新並上傳</button>'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
table += "</tr>"
|
|
|
|
|
table += "<tr>"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
document.getElementById("demo").innerHTML = table
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!--更新並上傳-->
|
|
|
|
|
<script>
|
|
|
|
|
function Update_detail(parking_spaces_name){
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "GET",
|
2024-02-14 21:39:44 +08:00
|
|
|
|
url: "http://localhost:5174/api/Parking_spaces_total_table/" + parking_spaces_name,
|
2024-02-01 11:37:15 +08:00
|
|
|
|
data: {},
|
|
|
|
|
headers: {
|
|
|
|
|
'Authorization': token
|
|
|
|
|
},
|
|
|
|
|
contentType: "application/json",
|
|
|
|
|
success: function (Model) {
|
|
|
|
|
console.log(Model)
|
|
|
|
|
Update_detail_1(Model)
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
function Update_detail_1(Model){
|
|
|
|
|
var parking_spaces_now_num = document.getElementById("parking_space_amount_id").value
|
|
|
|
|
Model.parking_spaces_now_num = parking_spaces_now_num
|
|
|
|
|
var stringify_obj = JSON.stringify(Model);
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "PUT",
|
2024-02-14 21:39:44 +08:00
|
|
|
|
url: "http://localhost:5174/api/Parking_spaces_total_table/" + parking_spaces_name,
|
2024-02-01 11:37:15 +08:00
|
|
|
|
data: stringify_obj,
|
|
|
|
|
headers: {
|
|
|
|
|
'Authorization': token
|
|
|
|
|
},
|
|
|
|
|
contentType: "application/json",
|
|
|
|
|
success: function (Model) {
|
|
|
|
|
console.log(Model)
|
|
|
|
|
Update_detail_2()
|
|
|
|
|
//window.location.reload();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
function Update_detail_2() {
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "GET",
|
2024-02-14 21:39:44 +08:00
|
|
|
|
url: "http://localhost:5174/api/Parking_spaces_lcd_instand/parking_space_area-" + parking_spaces_name,
|
2024-02-01 11:37:15 +08:00
|
|
|
|
data: {},
|
|
|
|
|
headers: {
|
|
|
|
|
'Authorization': token
|
|
|
|
|
},
|
|
|
|
|
contentType: "application/json",
|
|
|
|
|
success: function (Model) {
|
|
|
|
|
console.log(Model)
|
|
|
|
|
if (Model.length > 0) {
|
|
|
|
|
for (var i = 0; i < Model.length; i++) {
|
|
|
|
|
if (Model[i].parking_spaces_name == parking_spaces_name) {
|
|
|
|
|
Update_detail_3(Model[i])
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//Update_detail_1(Model)
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
function Update_detail_3(Model) {
|
|
|
|
|
var parking_spaces_now_num = document.getElementById("parking_space_amount_id").value
|
|
|
|
|
Model.parking_space_amount = parking_spaces_now_num
|
|
|
|
|
var stringify_obj = JSON.stringify(Model);
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "PUT",
|
2024-02-14 21:39:44 +08:00
|
|
|
|
url: "http://localhost:5174/api/Parking_spaces_lcd_instand/" + Model.lcd_ip,
|
2024-02-01 11:37:15 +08:00
|
|
|
|
data: stringify_obj,
|
|
|
|
|
headers: {
|
|
|
|
|
'Authorization': token
|
|
|
|
|
},
|
|
|
|
|
contentType: "application/json",
|
|
|
|
|
success: function (Model) {
|
|
|
|
|
console.log(Model)
|
|
|
|
|
//Update_detail_1(Model)
|
|
|
|
|
window.location.reload();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
</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-02-14 21:39:44 +08:00
|
|
|
|
url: 'http://localhost:5174/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) {
|
|
|
|
|
token_check = "false"
|
|
|
|
|
window.location.href = '/';
|
|
|
|
|
// 处理错误响应,例如跳转到未授权页面
|
|
|
|
|
//window.location.href = 'https://example.com/unauthorized_page';
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function from_token_import_id() {
|
|
|
|
|
var token = localStorage.getItem('token_park_space');
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "GET",
|
2024-02-14 21:39:44 +08:00
|
|
|
|
url: 'http://localhost:5174/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-02-14 21:39:44 +08:00
|
|
|
|
url: 'http://localhost:5174/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>
|