#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" src="3rdParty/jQuery/jquery-3.1.1.min.js"
crossorigin="anonymous"></script> crossorigin="anonymous"></script>
<script src="3rdParty/Semantic-UI-CSS-master/semantic.min.js"></script> <script src="3rdParty/Semantic-UI-CSS-master/semantic.min.js"></script>
<script src="3rdParty/Handlebars/handlebars-v4.1.2.js"></script>
<script> <script>
var mGlobal={} var mGlobal={}
$(document) $(document)
@ -35,6 +36,15 @@
String.prototype.replaceAll = function(search, replace){ String.prototype.replaceAll = function(search, replace){
return this.split(search).join(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="::") { mGlobal.GeneralGenerateHTMLCode=function(inTemplateHTMLSelector,inItemDictionary,inKeywordPrefix="::",inKeywordPostfix="::") {
///Получить заготовку ///Получить заготовку
lTemplateHTMLCode=$(inTemplateHTMLSelector)[0].outerHTML lTemplateHTMLCode=$(inTemplateHTMLSelector)[0].outerHTML
@ -70,6 +80,28 @@
mGlobal.Monitor.ScreenshotModal.Close=function() { mGlobal.Monitor.ScreenshotModal.Close=function() {
clearInterval(mGlobal.Monitor.ScreenshotModal.timerId); 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> </script>
@ -156,43 +188,25 @@
</div> </div>
</div> </div>
<div class="row"> <script class="openrpa-hidden-monitor-table-general" style="display:none" type="text/x-handlebars-template">
<div class="openrpa-hidden-monitor-table-general" style="display:none">
<table class="ui celled table"> <table class="ui celled table">
<thead> <thead>
<tr> <tr>
<th>Daemon name</th> <th>Machine name</th>
<th>Machihe host</th> <th>Machihe host</th>
<th>Status</th> <th>Status</th>
<th>Actions</th> <th>Actions,length: {{childs.length}}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> {{#webServerMonitorList}}
<td>No Name Specified</td> <tr><td>{{daemonName}}</td><td>{{daemonURI}}</td><td class="negative">None</td></tr>
<td>Unknown</td> {{/webServerMonitorList}}
<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>
</tbody> </tbody>
</table> </table>
</div> </script>
<div class="row openrpa-monitor">
<a onclick="mGlobal.Monitor.ScreenshotModal.Show();" class="item" target="_blank">GetScreenshot</a> <a onclick="mGlobal.Monitor.ScreenshotModal.Show();" class="item" target="_blank">GetScreenshot</a>
</div> </div>
<div class="row black"> <div class="row black">

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

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

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

@ -7,6 +7,7 @@ Dependencies
* Python 3 x64 * Python 3 x64
* pywinauto (Windows GUI automation) * pywinauto (Windows GUI automation)
* Semantic UI CSS framework * 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) Created by Unicode Labs (Ivan Maslov)
Loading…
Cancel
Save