parking-html/Parking_spaces/Views/Engineering/Engineering_Index_.cshtml
2024-02-04 11:58:46 +08:00

183 lines
5.0 KiB
Plaintext

@{
ViewData["Title"] = "Engineering_Index";
Layout = "~/Views/Shared/_Layout_Engineering.cshtml";
}
<h1>工程模式</h1>
<div class="col-xl-8 col-lg-8">
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">每日車流量</h6>
</div>
<div class="card-body">
<div class="chart-bar">
<canvas id="day_car_Bar"></canvas>
</div>
<hr>
</div>
</div>
<div class="card shadow mb-8">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">每日違規數量</h6>
</div>
<div class="card-body">
<div class="chart-bar">
<canvas id="violation_car_Bar"></canvas>
</div>
<hr>
</div>
</div>
</div>
<script src="/bootstrap_1/vendor/chart.js/Chart.min.js"></script>
<!--設定數據圖數據-每日車流量-->
<script>
// 假設你有一些資料,例如每日車流量
var dailyTrafficData = [100, 150, 120, 200, 180, 250, 621,0];
// 取得 canvas 元素
var ctx = document.getElementById('day_car_Bar')
// 使用 Chart.js 繪製長條圖
var myBarChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ['01/01', '01/02', '01/03', '01/04', '01/05', '01/06', '01/07'],
datasets: [{
label: '車流量',
data: dailyTrafficData,
backgroundColor: 'rgba(75, 192, 192, 0.2)', // 設定背景色
borderColor: 'rgba(75, 192, 192, 1)', // 設定邊框色
borderWidth: 1
}]
},
options: {
responsive: true, // 啟用 responsive 設置
maintainAspectRatio: false, // 保持長寬比例
scales: {
y: {
beginAtZero: true
}
}
}
});
</script>
<!--設定數據圖數據-每日違規數量-->
<script>
// 假設你有一些資料,例如每日違規數量
var dailyTrafficData = [10, 15, 20, 20, 18, 25, 62,0];
// 取得 canvas 元素
var ctx = document.getElementById('violation_car_Bar')
// 使用 Chart.js 繪製長條圖
var myBarChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ['01/01', '01/02', '01/03', '01/04', '01/05', '01/06', '01/07'],
datasets: [{
label: '違規數量',
data: dailyTrafficData,
backgroundColor: 'rgba(255, 0, 0, 0.5)', // 設定半透明的紅色背景
borderColor: 'rgba(255, 0, 0, 1)', // 設定不透明的紅色邊框
borderWidth: 1
}]
},
options: {
responsive: true, // 啟用 responsive 設置
maintainAspectRatio: false, // 保持長寬比例
scales: {
y: {
beginAtZero: true
}
}
}
});
</script>
<!--檢查token-->
<script>
function token_check() {
// 检查本地存储中是否存在JWT令牌
var 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>