#RobotDaemon #ШаблонизаторHandlebars #Генерация таблицы из JSON #MonitorПрототип

dev-linux
Ivan Maslov 6 years ago
parent 09b464d12a
commit 3b5dfcc405

File diff suppressed because one or more lines are too long

@ -8,6 +8,7 @@
src="3rdParty/jQuery/jquery-3.1.1.min.js"
crossorigin="anonymous"></script>
<script src="3rdParty/Semantic-UI-CSS-master/semantic.min.js"></script>
<script src="3rdParty/Handlebars/handlebars-v4.1.2.js"></script>
<script>
var mGlobal={}
$(document)
@ -35,6 +36,15 @@
String.prototype.replaceAll = function(search, replace){
return this.split(search).join(replace);
}
mGlobal.GeneralGenerateHTMLCodeHandlebars=function(inInnerTemplateSelector,inData) {
lHTMLTemplate=$(inInnerTemplateSelector)[0].innerHTML
console.log(lHTMLTemplate)
//Компиляция
var template = Handlebars.compile(lHTMLTemplate);
//Вставка данных
var lHTMLResult = template(inData);
return lHTMLResult
}
mGlobal.GeneralGenerateHTMLCode=function(inTemplateHTMLSelector,inItemDictionary,inKeywordPrefix="::",inKeywordPostfix="::") {
///Получить заготовку
lTemplateHTMLCode=$(inTemplateHTMLSelector)[0].outerHTML
@ -70,6 +80,28 @@
mGlobal.Monitor.ScreenshotModal.Close=function() {
clearInterval(mGlobal.Monitor.ScreenshotModal.timerId);
}
///Monitor
mGlobal.Monitor.DaemonList={}
mGlobal.Monitor.DaemonList.fRefreshTable=function() {
///Загрузка данных
$.ajax({
type: "GET",
url: 'Monitor/JSONDaemonListGet',
data: '',
success:
function(lData,l2,l3)
{
var lResponseJSON=JSON.parse(lData)
///Сформировать HTML код новой таблицы
lHTMLCode=mGlobal.GeneralGenerateHTMLCodeHandlebars(".openrpa-hidden-monitor-table-general",lResponseJSON)
///Очистить дерево
//mGlobal.ElementTree.fClear();
///Прогрузить новую таблицу
$(".openrpa-monitor").html(lHTMLCode)
},
dataType: "text"
});
}
})
;
</script>
@ -156,43 +188,25 @@
</div>
</div>
<div class="row">
<div class="openrpa-hidden-monitor-table-general" style="display:none">
<script class="openrpa-hidden-monitor-table-general" style="display:none" type="text/x-handlebars-template">
<table class="ui celled table">
<thead>
<tr>
<th>Daemon name</th>
<th>Machine name</th>
<th>Machihe host</th>
<th>Status</th>
<th>Actions</th>
<th>Actions,length: {{childs.length}}</th>
</tr>
</thead>
<tbody>
<tr>
<td>No Name Specified</td>
<td>Unknown</td>
<td class="negative">None</td>
</tr>
<tr class="positive">
<td>Jimmy</td>
<td><i class="icon checkmark"></i> Approved</td>
<td>None</td>
</tr>
<tr>
<td>Jamie</td>
<td>Unknown</td>
<td class="positive"><i class="icon close"></i> Requires call</td>
</tr>
<tr class="negative">
<td>Jill</td>
<td>Unknown</td>
<td>None</td>
</tr>
{{#webServerMonitorList}}
<tr><td>{{daemonName}}</td><td>{{daemonURI}}</td><td class="negative">None</td></tr>
{{/webServerMonitorList}}
</tbody>
</table>
</div>
</script>
<div class="row openrpa-monitor">
<a onclick="mGlobal.Monitor.ScreenshotModal.Show();" class="item" target="_blank">GetScreenshot</a>
</div>
<div class="row black">

@ -8,9 +8,7 @@ import signal
import pdb
import robotDaemonServer
#Инициализация сервера
lThreadServer = robotDaemonServer.RobotDaemonServer("ServerThread")
lThreadServer.start()
#Чтение конфигурации
lDaemonConfigurationFile = codecs.open("robotDaemonConfiguration.json", "r","utf_8_sig")
@ -24,6 +22,10 @@ lDaemonConfigurationObject=json.loads(lDaemonConfigurationJSONString)
lDaemonLoopSeconds=lDaemonConfigurationObject["loopSeconds"]
lDaemonActivityLogDict={} #Словарь отработанных активностей, ключ - кортеж (<activityType>, <datetime>, <processPath || processName>, <processArgs>)
lDaemonStartDateTime=datetime.datetime.now()
#Инициализация сервера
lThreadServer = robotDaemonServer.RobotDaemonServer("ServerThread",lDaemonConfigurationObject)
lThreadServer.start()
#Вечный цикл
while True:
lCurrentDateTime=datetime.datetime.now()

@ -14,13 +14,13 @@ def SaveScreenshot(inFilePath):
lScreenshot = ImageGrab.grab()
# save image file
lScreenshot.save('screenshot.png')
mJSONConfigurationDict={}
class RobotDaemonServer(Thread):
self.mJSONConfigurationDict={};
def __init__(self,name,inJSONConfigurationDict):
Thread.__init__(self)
self.name = name
self.mJSONConfigurationDict=inJSONConfigurationDict
global mJSONConfigurationDict
mJSONConfigurationDict=inJSONConfigurationDict
def run(self,inServerAddress="127.0.0.1",inPort=8081):
print('starting server...')
# Server settings
@ -34,6 +34,9 @@ class RobotDaemonServer(Thread):
# HTTPRequestHandler class
class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):
#ResponseContentTypeFile
def Config(self,inJSONConfigurationDict):
self.mJSONConfigurationDict=inJSONConfigurationDict
#ResponseContentTypeFile
def SendResponseContentTypeFile(self,inContentType,inFilePath):
# Send response status code
self.send_response(200)
@ -68,33 +71,27 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):
#Мост между файлом и http запросом (новый формат)
if self.path == '/favicon.ico':
self.SendResponseContentTypeFile('image/x-icon',"..\\..\\favicon.ico")
#Мост между файлом и http запросом (новый формат)
if self.path == '/3rdParty/Handlebars/handlebars-v4.1.2.js':
self.SendResponseContentTypeFile('application/javascript',"..\\..\\3rdParty\\Handlebars\\handlebars-v4.1.2.js")
#Получить скриншот
if self.path.split("?")[0] == '/GetScreenshot':
#Сохранить файл на диск
SaveScreenshot("Screenshot.png")
self.SendResponseContentTypeFile('image/png',"Screenshot.png")
#Action ObjectInspector GetObjectList
if self.path == '/ObjectDetector/JSONGetWindowList':
#ReadRequest
#lInputByteArray=self.rfile.read()
#print(str(len(os.stat(self.rfile).st_size)))
#Monitor
if self.path == '/Monitor/JSONDaemonListGet':
# Send response status code
self.send_response(200)
# Send headers
self.send_header('Content-type','application/json')
self.end_headers()
# Send message back to client
#{'functionName':'', 'argsArray':[]}
lRequestObject={'functionName':'ElementGetChildElementList','argsArray':[]}
#Отправить запрос в дочерний процесс, который отвечает за работу с Windows окнами
#ProcessChildSendObject(p,lRequestObject)
#Получить ответ от дочернего процесса
#lResponseObject=ProcessChildReadWaitObject(p)
message = json.dumps(lResponseObject)
message = json.dumps(mJSONConfigurationDict)
# Write content as utf-8 data
self.wfile.write(bytes(message, "utf8"))
# POST
def do_POST(self):
#Action ObjectInspector GetObjectList

@ -1,3 +1,4 @@
cd %~dp0
copy /Y ..\..\WPy32-3720\python-3.7.2\python.exe ..\..\WPy32-3720\python-3.7.2\OpenRPARobotDaemon.exe
.\..\..\WPy32-3720\python-3.7.2\OpenRPARobotDaemon.exe robotDaemon.py
pause >nul

@ -7,6 +7,7 @@ Dependencies
* Python 3 x64
* pywinauto (Windows GUI automation)
* Semantic UI CSS framework
* JsRender by https://www.jsviews.com
* JsRender by https://www.jsviews.com (switch to Handlebars)
* Handlebars
Created by Unicode Labs (Ivan Maslov)
Loading…
Cancel
Save