Browse Source

2.0.7.51_1022

master
ming.hong 1 year ago
parent
commit
0b7a272305
  1. 51
      Aida/python.html
  2. 4
      Aida/python_ming.html

51
Aida/python.html

@ -196,6 +196,7 @@
<input type="text" id="search-box" placeholder="Search"
style="width: 108%; height: 40px; border-radius: 5px; border: 1px solid #ccc;margin-right: 0; align-self: start; position: relative; left: -10px;">
</div>
<div id="file-results"></div>
<div style="display: flex; justify-content: space-between;">
<button id="uploadfile-button"
style="color: white; border: none; text-align: center; cursor: pointer;"
@ -273,10 +274,11 @@
</div>
<script>
var fileArray = [];
var BufferSize = 512; // Buffer 最大 Row 數
var getPythonBufferIntervalTime = 50;
var getPythonStatusIntervalTime = 50;
var receivedCountThreshold = 37500 / getPythonStatusIntervalTime
var receivedCountThreshold = 37500 / getPythonStatusIntervalTime // 約等於 15 秒
var dataReceivedCount = 0;
var getPythonBufferSize = 64;
var getBufferStatusTemp = null;
@ -325,20 +327,19 @@
},
success: function (retdata) {
var data;
if (typeof retdata === 'string') {
data = JSON.parse(retdata);
} else {
data = retdata;
}
var fileList = data.file_list;
var dataForGrid = fileList.map(function (filename) {
return {
filename: filename,
lastModified: 'Not available'
};
});
$('#file-data-grid').datagrid('loadData', dataForGrid);
fileArray = Object.values(fileList); // 儲存為全域變數
console.log("########################", fileArray);
// 更新 datagrid 顯示所有檔案
updateDataGrid(fileArray);
if (pyFileName != null) {
selectFileInDataGrid(pyFileName); // 此時 fileList 已包含新文件
}
@ -348,7 +349,24 @@
}
});
}
// 更新 Files 列表
function updateDataGrid(files) {
var dataForGrid = files.map(function (filename) {
return {
filename: filename,
lastModified: 'Not available'
};
});
$('#file-data-grid').datagrid('loadData', dataForGrid);
}
// 查看 Search box 有無輸入
document.getElementById('search-box').addEventListener('input', function () {
var searchTerm = this.value.toLowerCase(); // 將輸入的內容轉為小寫
var filteredFiles = fileArray.filter(function (file) {
return file.toLowerCase().includes(searchTerm); // 根據輸入進行過濾
});
updateDataGrid(filteredFiles);
});
// 取得文件內容
function func_FileGet(file_name) {
var reqFileNmae = file_name;
@ -478,12 +496,6 @@
json_data += '}';
func_setconfigfile(json_data);
var rows = $('#file-data-grid').datagrid('getRows'); // 取得所有行的資料
rows.forEach(function (row, index) {
var $row = $('#file-data-grid').datagrid('getPanel').find('tr[datagrid-row-index="' + index + '"]');
$row.find('td[field="filename"] img').attr('src', './images/py.png');
});
$.ajax({
url: "/stoppython",
method: "GET",
@ -687,7 +699,6 @@
});
}
function func_runPython(file_name) {
func_getPythonStatus();
g_isPythonRunning = 1;
@ -785,14 +796,14 @@
$('#console').append('&#13;&#10;'); // 換行
$('#console').append("Running...");
$('#console').append('&#13;&#10;'); // 換行
console.log("找到可執行 Python 檔案 !!!!!!!!!!!!!! ");
console.log("find enable python file !!!!!!!!!!!!!! ");
}
else
{
console.log("未找到可執行 Python 檔案 !!!!!!!!!!!!!! ");
console.log("not found enable python file !!!!!!!!!!!!!! ");
}
} else {
console.log("未找到 enable_python_file 設置");
console.log("not found enable python setting");
}
},

4
Aida/python_ming.html

@ -491,7 +491,7 @@
success: function (retdata) {
clearInterval(Status_intervalId);
// 在請求完成後重新啟用「Run」
$("#run-button").prop("disabled", false);
// $("#run-button").prop("disabled", false);
$('#console').append('&#13;&#10;'); // 換行
$('#console').append(retdata.replace(/\n/g, '<br>'));
@ -598,6 +598,7 @@
json_data += '}';
func_setconfigfile(json_data);
currentRunningFile = ''
$("#run-button").prop("disabled", false);
}
dataReceivedCount++;
},
@ -686,7 +687,6 @@
});
}
function func_runPython(file_name) {
func_getPythonStatus();
g_isPythonRunning = 1;

Loading…
Cancel
Save