From 9af5bd2229002293559b5272381e2df9e5b47947 Mon Sep 17 00:00:00 2001 From: Harald Wolff Date: Thu, 29 Mar 2018 13:13:56 +0200 Subject: [PATCH] WIP --- hcore/templates/browse.css | 2 + hcore/templates/style.css | 4 + hserver/api/FileObject.py | 10 ++- hserver/api/WebCallable.py | 3 + hserver/api/WebObject.py | 22 +++--- hserver/api/__init__.py | 2 + hserver/manage/RootFolder.py | 20 ++++- hserver/manage/api.js | 25 +++++- hserver/manage/edit.html | 8 +- hserver/manage/style.css | 122 +++++++++++++++++++++++++++--- hserver/manage/tree.html | 2 +- hserver/templates/Template.py | 4 +- hserver/templates/dpage.edit.html | 11 ++- hserver/types/FormApplyable.py | 9 ++- python-objectbroker | 1 - python-simplelog | 1 - 16 files changed, 205 insertions(+), 41 deletions(-) delete mode 160000 python-objectbroker delete mode 160000 python-simplelog diff --git a/hcore/templates/browse.css b/hcore/templates/browse.css index 1236399..626612e 100644 --- a/hcore/templates/browse.css +++ b/hcore/templates/browse.css @@ -38,3 +38,5 @@ border-right: 1px solid black; float: left; } + + diff --git a/hcore/templates/style.css b/hcore/templates/style.css index 750fe74..8eae955 100644 --- a/hcore/templates/style.css +++ b/hcore/templates/style.css @@ -84,5 +84,9 @@ body,p,div { min-height: 400px; } +#preview { + float: right; + right: 25px; +} diff --git a/hserver/api/FileObject.py b/hserver/api/FileObject.py index 38c50fd..ec22f74 100644 --- a/hserver/api/FileObject.py +++ b/hserver/api/FileObject.py @@ -23,10 +23,14 @@ class FileObject(WebObject): class DiskFolder(WebObject,Persistence): - def __init__(self,path): - self._path = path + def __init__(self, path, readOnly = False): + self.__path = path + self.__readOnly = readOnly + self.__files = {} def __dir__(self): - return os.listdir( self._path) + return os.listdir( self.__path ) + + diff --git a/hserver/api/WebCallable.py b/hserver/api/WebCallable.py index ca2c3b6..97c65e1 100644 --- a/hserver/api/WebCallable.py +++ b/hserver/api/WebCallable.py @@ -15,3 +15,6 @@ class WebCallable: else: request.getContentFile().write("No ContentSorry, no content here!") +class WebCallableObject(WebCallable): + pass + diff --git a/hserver/api/WebObject.py b/hserver/api/WebObject.py index 7a285bb..35e2d2a 100644 --- a/hserver/api/WebObject.py +++ b/hserver/api/WebObject.py @@ -1,12 +1,15 @@ from objectbroker import Persistence,NoPersistence,Aquisition,AquisitionProxy -from hserver.api.WebCallable import WebCallable +from hserver.api.WebCallable import WebCallable,WebCallableObject +from hserver.types.FormApplyable import FormApplyable from hserver.session.SessionHandler import SessionHandler import hserver import hserver.api -class WebObject(WebCallable,Aquisition): +from simplelog import log + +class WebObject(WebCallableObject,FormApplyable,Aquisition): WO_Accepts = None FA_Names = { "title": "title" } @@ -65,6 +68,7 @@ class WebObject(WebCallable,Aquisition): return ls def walk(self,request): + log("walk: {0}".format(self)) for shandler in self.__sessionhandlers: shandler.applySession(request) @@ -76,7 +80,9 @@ class WebObject(WebCallable,Aquisition): raise hserver.HttpException(404,"%s in /%s" % (next,request.pathwalker().walked(-1))) if (len(stack)==0) or (not isinstance(no,WebObject)): - if (isinstance(no,WebCallable)): + if (isinstance(no,WebCallableObject)): + no(request, o=no) + elif (isinstance(no,WebCallable)): no(request, o=self) else: raise hserver.HttpException(404,"%s in /%s" % (next,request.pathwalker().walked(-1))) @@ -126,18 +132,10 @@ class WebObject(WebCallable,Aquisition): elif not hasattr(self, n): setattr( self, n, t() ) -class NavWebObject(WebObject): +class NavWebObject(WebObject,Persistence): def __init__(self,title = None): WebObject.__init__(self) - self.title = title - - def title(self): - t = getattr(self,"title",None) - if t is None: - return self.__aq_name - return t - def navigation(self,levels = 1): nav = {} diff --git a/hserver/api/__init__.py b/hserver/api/__init__.py index 142cf6c..e673206 100644 --- a/hserver/api/__init__.py +++ b/hserver/api/__init__.py @@ -6,6 +6,8 @@ from hserver.api.WebObject import WebObject,NavWebObject from hserver.api.FileObject import FileObject from hserver.api.SimpleObject import SimpleObject +from hserver.types.FormApplyable import FormApplyable + from hserver.api.SessionHandlerObject import SessionHandlerObject from hserver.api.CookieSessionHandler import CookieSessionHandler diff --git a/hserver/manage/RootFolder.py b/hserver/manage/RootFolder.py index 12827fe..e848d69 100644 --- a/hserver/manage/RootFolder.py +++ b/hserver/manage/RootFolder.py @@ -8,11 +8,17 @@ from hserver.templates.Template import Template import hserver from simplelog import log +import simplelog + + +from objectbroker import Serializer,XMLStore import os import os.path import json +import xml.etree.ElementTree + class RootFolder(WebObject,Persistence): @@ -51,6 +57,8 @@ class RootFolder(WebObject,Persistence): except Exception as ex: + log("JSON-RPC: Exception") + simplelog.logException(ex) reply["result"] = None reply["exception"] = repr(ex) @@ -59,6 +67,8 @@ class RootFolder(WebObject,Persistence): log("JReply: {0}".format(jreply)) request.getContentFile().write( jreply ) + _hm_json = WebCallable( method = hm_json ) + def objCreate(self,request,objTypeName,objName,objPath): if (objTypeName == ""): raise Exception("objTypeName must contain a valid type") @@ -83,8 +93,16 @@ class RootFolder(WebObject,Persistence): return True + def objExport(self,request, objPath): + xs = XMLStore(None) + s = Serializer(xs) + + o = self.objPathWalk( request, objPath ) + + s.serialize( o._aq_object ) + + return xml.etree.ElementTree.tostring( xs.lastXml() ).decode("utf-8") - _hm_json = WebCallable( method = hm_json ) def objPathWalk(self, request, path): o = self diff --git a/hserver/manage/api.js b/hserver/manage/api.js index 53d6221..51aeee5 100644 --- a/hserver/manage/api.js +++ b/hserver/manage/api.js @@ -89,7 +89,7 @@ function editorApply(objPath){ if (hm.editor.fields.hasOwnProperty( field )){ formData.append( field, hm.editor.fields[ field ].value ); } - } + } var reply = callURL( objPath + "/_hm_apply", formData, null, "POST" ); } catch (e){ alert(e); @@ -102,6 +102,28 @@ function editorSave(){ return false; } +function editorExport(){ + var objPath = hm.editor.objPath; + var reply = callJson( "objExport", { "objPath" : pathSplit(objPath) } ) + + var a = document.createElement("a"); + a.setAttribute('href', "data:text/xml," + escape(reply.result)); + a.setAttribute('download', 'object.xml'); + + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + +} + +function editorImport(){ + var files = $("importxmlfile").files; + if (files.length == 0){ + alert("First, you need to select a file to import into this node!"); + } +} + + @@ -117,6 +139,7 @@ function objRemove( objPath ){ + function onAddObjectButton(button,objPath,parentID){ var ctlObjName = "objName-" + parentID; var objName = $(ctlObjName).value; diff --git a/hserver/manage/edit.html b/hserver/manage/edit.html index 8686ce3..741ca56 100644 --- a/hserver/manage/edit.html +++ b/hserver/manage/edit.html @@ -3,8 +3,14 @@
-
+
+ +
Importieren +
Importiere
+ als +
+
diff --git a/hserver/manage/style.css b/hserver/manage/style.css index 129ed9f..156f84d 100644 --- a/hserver/manage/style.css +++ b/hserver/manage/style.css @@ -14,11 +14,35 @@ h1,h2,h3,h4,h5 { display: inline-block; } +input { + padding: 3px; + min-width: 400px; +} + textarea { min-width: 50%; min-height: 400px; } +button, .button, input[type=button], textarea { + position: relative; + display: inline-block; + background-color: #E0E0FF; + + border: 1px solid #202040; + border-radius: 3px; + + font-size: 12px; + text-align: center; + vertical-align: middle; + height: 32px; + + width: 100px; + + padding: 4px; + margin: 0; +} + .popup { position: absolute; left: 75%; @@ -60,8 +84,76 @@ div:hover > .pulldown { z-index: 1; } +.side { + width: 110px; + min-height: 40%; + background-color: #0786BD; +} + +.side.right { + position: fixed; + right: 0px; + padding: 8px; + padding-left: 14px; + border-left: 2px solid #0786BD; + border-top: 2px solid #0786BD; + border-bottom: 2px solid #0786BD; + border-radius: 10px 0 0 10px; +} +.side.left { + padding-right: 14px; + border-right: 1px solid #0786BD; + border-top: 1px solid #0786BD; + border-bottom: 1px solid #0786BD; + border-radius: 10px; +} + +.slider { + + background-color: #61c1fe; + padding: 5px; + border-radius: 5px; + overflow: hidden; + + transition: width 0.5s; +} + +.slider:hover { + padding: 10px; + z-index: 1; +} + +.slider * { + visibility: hidden; +} +.slider:hover * { + visibility: visible; +} + +.slider.right { + float: none; + right: 0px; + width: 90px; + height: 22px; +} +.slider.right:hover { + width: 600%; + max-height: 1000%; +} + +.slider > div { + +} + +.slider > div > input { + width: 160px; + min-width: 120px; +} + + .section { display: block; + padding-bottom: 10px; } .section > div { @@ -84,22 +176,12 @@ div:hover > .pulldown { } -.button, input, textarea { - position: relative; - display: inline-block; - border: 1px solid #202040; - background-color: #E0E0FF; - border-radius: 3px; -} .button.small { width: 14px; height: 14px; } -input { - padding: 3px; - min-width: 400px; -} + input.small { min-width: 200px; } @@ -114,6 +196,24 @@ textarea { display: block; } +.side > * { + display: block; + position: relative; + width: 100px; + min-width: initial; + padding: 4px; + margin: 0; + margin-bottom: 8px; + + background-color: #61c1fe; + color: white; + + border: 1px solid #044357; + border-radius: 4px; + + font-size: 12px; +} + #menu { width: 90%; diff --git a/hserver/manage/tree.html b/hserver/manage/tree.html index 07e7804..3b0f214 100644 --- a/hserver/manage/tree.html +++ b/hserver/manage/tree.html @@ -1,4 +1,3 @@ - <%define node%>
@@ -8,6 +7,7 @@ <%end%>