新建增加使用者資料頁面

This commit is contained in:
leo890808 2024-05-21 16:10:07 +08:00
parent a3f8be283e
commit 68d7119856
3 changed files with 134 additions and 0 deletions

View File

@ -76,6 +76,10 @@ namespace Parking_spaces.Controllers
{
return View();
}
public IActionResult Engineering_parking_user_list_index()
{
return View();
}
public IActionResult Engineering_RTSP()
{

View File

@ -0,0 +1,129 @@

@{
ViewData["Title"] = "Engineering_parking_user_list_index";
Layout = "~/Views/Shared/_Layout_Engineering.cshtml";
}
<h1>校內停車場使用者名單</h1>
<script>
function set_data(Model) {
console.log(Model)
}
</script>
<!--Get_data-->
<script>
function get_data() {
$.ajax({
type: "GET",
url: "http://140.125.20.183:7700/api/Yuntech_parking_user_list" ,
data: {},
headers: {
'Authorization': token
},
contentType: "application/json",
headers: {
'Authorization': token
},
success: function (Model) {
//console.log(Model)
set_data(Model)
}
});
}
</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>

View File

@ -80,6 +80,7 @@
<a class="collapse-item" asp-controller="Engineering" asp-action="Engineering_Violation"> 違規區域</a>
<a class="collapse-item" asp-controller="Engineering" asp-action="Yuntech_in_car"> 進入車輛</a>
<a class="collapse-item" asp-controller="Engineering" asp-action="Map_RTSP"> 即時影像</a>
<a class="collapse-item" asp-controller="Engineering" asp-action="Engineering_parking_user_list_index"> 名單 </a>
</div>
</div>
</li>