parking-html/Parking_spaces/Views/Engineering/Engineering_LED.cshtml
2024-02-14 22:02:50 +08:00

181 lines
4.5 KiB
Plaintext

@{
ViewData["Title"] = "Engineering_LED";
Layout = "~/Views/Shared/_Layout_Engineering.cshtml";
}
<h1>LED 字幕機</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>
字幕機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 //職位
function get_data(){
$.ajax({
type: "GET",
url: "http://140.125.20.183:7700/api/Parking_spaces_lcd_instand",
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 != null) {
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>" + Model[i].parking_space_amount + "</td>"
table += "<td>" + '<button class="btn btn-outline-success " onclick="LED_detail(' + "'" + Model[i].parking_spaces_name + "'" + ')">詳細</button>'
}
table += "</tr>"
table += "<tr>"
}
}
document.getElementById("demo").innerHTML = table
}
</script>
<!--跳轉頁面-->
<script>
function LED_detail(name) {
window.location = "/Engineering/Engineering_LED_detail/" + name;
}
</script>
<!--檢查token-->
<script>
var token
function token_check() {
// 检查本地存储中是否存在JWT令牌
token = localStorage.getItem('token_park_space');
console.log(token)
$.ajax({
type: "GET",
url: 'http://140.125.20.183:7700/Users/token_check',
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",
url: 'http://140.125.20.183:7700/Users/token-' + token,
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",
url: 'http://140.125.20.183:7700/Users/user_id-' + id,
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>