コード例 #1
0
    def render(self, data, field):
        if field in data.keys():
            result = html5.Ul()
            options = {k: v for k, v in self.skelStructure[field]["values"]}

            for i, fieldKey in enumerate(data[field]):
                if conf["maxMultiBoneEntries"] and i + 1 > conf[
                        "maxMultiBoneEntries"]:
                    ali = html5.Li()
                    ali.appendChild(
                        html5.TextNode(
                            translate("and {count} more",
                                      count=len(data[field]) -
                                      conf["maxMultiBoneEntries"])))
                    ali["class"].append("selectmulti_more_li")

                    result.appendChild(ali)
                    break

                ali = html5.Li()
                ali.appendChild(html5.TextNode(options.get(fieldKey,
                                                           fieldKey)))
                ali["Title"] = fieldKey

                result.appendChild(ali)

            return result

        return html5.Label(conf["empty_value"])
コード例 #2
0
    def __init__(self):
        super(Log, self).__init__()

        self["class"].append("vi_messenger")
        openLink = html5.ext.Button(translate("Open message center"),
                                    self.toggleMsgCenter)
        self.appendChild(openLink)

        self.logUL = html5.Ul()
        self.logUL["id"] = "statuslist"
        self.logUL["class"].append("statuslist")
        self.appendChild(self.logUL)

        versionDiv = html5.Div()
        versionDiv["class"].append("versiondiv")

        # Server name and version number
        name = conf["vi.viur"]
        if name:
            versionspan = html5.Span()
            versionspan.appendChild(
                "%s v%s" %
                (name, ".".join([str(x) for x in conf["server.version"]])))
            versionspan["class"].append("serverspan")
            versionDiv.appendChild(versionspan)

        # Vi name and version number
        name = conf["vi.name"]
        if name:
            versionspan = html5.Span()
            versionspan.appendChild(
                "%s v%s%s" %
                (name, ".".join([str(x) for x in conf["vi.version"]]),
                 ("-" + conf["vi.version.appendix"])
                 if conf["vi.version.appendix"] else ""))

            versionspan["class"].append("versionspan")
            versionDiv.appendChild(versionspan)

            #Try loading the revision and build date
            try:
                from version import builddate, revision

                revspan = html5.Span()
                revspan.appendChild(html5.TextNode("Rev %s" % revision))
                revspan["class"].append("revisionspan")

                datespan = html5.Span()
                datespan.appendChild(html5.TextNode("Built %s" % builddate))
                datespan["class"].append("datespan")

                versionDiv.appendChild(revspan)
                versionDiv.appendChild(datespan)

            except:
                pass

        if versionDiv.children():
            self.appendChild(versionDiv)
コード例 #3
0
 def __init__(self, extension, view, module, *args, **kwargs):
     super(RelationalSearch, self).__init__(*args, **kwargs)
     self.view = view
     self.extension = extension
     self.module = module
     self.currentSelection = None
     self.filterChangedEvent = EventDispatcher("filterChanged")
     self.appendChild(html5.TextNode("RELATIONAL SEARCH"))
     self.appendChild(html5.TextNode(extension["name"]))
     self.currentEntry = html5.Span()
     self.appendChild(self.currentEntry)
     btn = html5.ext.Button("Select", self.openSelector)
     self.appendChild(btn)
     btn = html5.ext.Button("Clear", self.clearSelection)
     self.appendChild(btn)
コード例 #4
0
ファイル: topbar.py プロジェクト: Xeon2003/vi
 def __init__(self):
     super(Logout, self).__init__()
     aa = html5.A()
     aa["class"].append("icon logout")
     aa.appendChild(html5.TextNode(translate("Logout")))
     self.appendChild(aa)
     self.sinkEvent("onClick")
コード例 #5
0
	def __init__(self, module, data, structure, *args, **kwargs):
		"""
			:param module: Name of the module we shall display data for
			:type module: str
			:param data: The data for that entry
			:type data: dict
			:param structure: Skeleton structure for that module (as received  from the server)
			:type structure: list
		"""
		super( HierarchyItem, self ).__init__( *args, **kwargs )
		self.module = module
		self.data = data
		self.structure = structure
		self.expandLink = html5.A()
		self.expandLink["class"].append("expandlink")
		self.expandLink.appendChild(html5.TextNode(translate("Expand/Collapse")))
		self.appendChild(self.expandLink)
		#self.element.innerHTML = "%s %s" % (data["name"], data["sortindex"])
		self.isLoaded = False
		self.isExpanded = False
		self.buildDescription()
		self.ol = html5.Ol()
		self.ol["class"].append("subhierarchy")
		self.appendChild(self.ol)
		self.currentMargin = None
		self.ol["style"]["display"] = "none"
		self["class"].append("hierarchyitem")
		self["class"].append("unexpaned")
		self["class"].append("supports_drag")
		self["class"].append("supports_drop")
		self["draggable"] = True
		self.sinkEvent("onDragStart", "onDrop", "onDragOver","onDragLeave")
コード例 #6
0
    def setCurrentModulDescr(self,
                             descr="",
                             iconURL=None,
                             iconClasses=None,
                             path=None):
        for c in self.modulImg._children[:]:
            self.modulImg.removeChild(c)
        for c in self.moduleName._children[:]:
            self.moduleName.removeChild(c)
        for c in self.modulImg["class"]:
            self.modulImg["class"].remove(c)

        descr = html5.utils.unescape(descr)
        self.moduleName.appendChild(html5.TextNode(descr))

        if iconURL is not None:
            img = html5.Img()
            img["src"] = iconURL
            self.modulImg.appendChild(img)

        if iconClasses is not None:
            for cls in iconClasses:
                self.modulImg["class"].append(cls)

        conf["theApp"].setTitle(descr)

        if path:
            conf["theApp"].setPath(path)
コード例 #7
0
	def __init__(self, modul, structure, item, *args, **kwargs):
		super( InternalPreview, self ).__init__( *args, **kwargs )

		self["class"].append("internalpreview")

		tmpDict = {key: bone for key, bone in structure}

		for key, bone in structure:
			if "params" in bone.keys() and bone[ "params" ] \
					and "previewBone" in bone[ "params" ].keys() \
						and bone[ "params" ][ "previewBone" ] == False:
				continue

			self.ali= html5.Li()
			self.ali["class"]=[ modul,"type_"+bone["type"],"bone_"+key]
			self.adl= html5.Dl()

			self.adt=html5.Dt()
			self.adt.appendChild(html5.TextNode(key if conf["showBoneNames"] else bone.get("descr", key)))

			self.aadd=html5.Dd()
			delegateFactory = viewDelegateSelector.select( modul, key, tmpDict )( modul, key, tmpDict )
			self.aadd.appendChild(delegateFactory.render( item, key ))

			self.adl.appendChild(self.adt)
			self.adl.appendChild(self.aadd)
			self.ali.appendChild(self.adl)

			self.appendChild(self.ali)
コード例 #8
0
    def __init__(self, *args, **kwargs):
        super(LoginScreen, self).__init__(*args, **kwargs)
        self.addClass("vi-login")

        # --- Surrounding Dialog ---
        self.dialog = html5.Div()
        self.dialog.addClass("vi-login-dialog")
        self.appendChild(self.dialog)

        # --- Header ---
        header = html5.Div()
        header.addClass("vi-login-header")
        self.dialog.appendChild(header)

        # Login
        h1 = html5.H1()
        h1.addClass("vi-login-headline")
        h1.appendChild(html5.TextNode(translate("vi.login.title")))
        header.appendChild(h1)

        # Logo
        img = html5.Img()
        img.addClass("vi-login-logo")
        img["src"] = "login-logo.png"
        header.appendChild(img)

        # --- Dialog ---

        self.loginMethodSelector = html5.Ul()
        self.loginMethodSelector.addClass("vi-login-method")
        self.dialog.appendChild(self.loginMethodSelector)

        self.haveLoginHandlers = False
コード例 #9
0
ファイル: preview.py プロジェクト: Xeon2003/vi
 def __init__(self, urls, entry, modul, *args, **kwargs):
     super(Preview, self).__init__(*args, **kwargs)
     self.urls = urls
     self.entry = entry
     self.module = modul
     containerDiv = html5.Div()
     containerDiv["class"].append("actionbar")
     self.appendChild(containerDiv)
     self.urlCb = html5.Select()
     containerDiv.appendChild(self.urlCb)
     self.previewFrame = html5.Iframe()
     self.appendChild(self.previewFrame)
     btnClose = html5.ext.Button("Close", callback=self.doClose)
     btnClose["class"].append("icon close")
     containerDiv.appendChild(btnClose)
     currentUrl = None
     for name, url in urls.items():
         o = html5.Option()
         o["value"] = url
         o.appendChild(html5.TextNode(name))
         self.urlCb.appendChild(o)
         if currentUrl is None:
             currentUrl = url
     self.setUrl(currentUrl)
     self.sinkEvent("onChange")
     self["class"].append("preview")
コード例 #10
0
ファイル: table.py プロジェクト: phorward/viur-vi
    def setHeader(self, headers):
        """
			Sets the table-headers to 'headers'
			:param headers: list of strings
			:type headers: list
		"""

        tr = html5.Tr()

        # Extra column for Index#s
        if self.indexes:
            th = html5.Th()
            th["class"] = "index"
            tr.appendChild(th)

        # Extra column for checkboxes
        if self.checkboxes:
            th = html5.Th()  # fixme..
            th["class"] = "check"
            tr.appendChild(th)

        # Now every title column
        for head in headers:
            th = html5.Th()
            th.appendChild(html5.TextNode(head))
            tr.appendChild(th)

        self.head.removeAllChildren()
        self.head.appendChild(tr)
コード例 #11
0
	def __init__(self, view, modul, embed=False, *args, **kwargs ):
		super( CompoundFilter, self ).__init__( *args, **kwargs)

		self["class"].append("compoundfilter")
		self.view = view
		self.module = modul
		self.embed = embed

		if embed:
			self["class"].append("embed")
			self["class"].append("expanded")
		else:
			self["class"].append("standalone")
			self["class"].append("collapsed")

		if "name" in view.keys():
			h2 = html5.H2()
			h2.appendChild( html5.TextNode( view["name"] ) )
			self.appendChild( h2 )

		self.extendedFilters = []

		for extension in (view["extendedFilters"] if "extendedFilters" in view.keys() else []):
			wdg = extendedSearchWidgetSelector.select( extension, view, modul)

			if wdg is not None:
				container = html5.Div()
				container["class"].append("extendedfilter")
				wdg = wdg( extension, view, modul )
				container.appendChild( wdg )
				self.appendChild( container )
				self.extendedFilters.append( wdg )
				wdg.filterChangedEvent.register( self )
コード例 #12
0
    def __init__(self,
                 widget,
                 selection,
                 encoding=None,
                 language=None,
                 separator=None,
                 lineSeparator=None,
                 *args,
                 **kwargs):
        super(ExportCsv, self).__init__()

        if encoding is None or encoding not in ["utf-8", "iso-8859-15"]:
            encoding = "utf-8"

        if language is None or language not in conf["server"].keys():
            language = conf["currentlanguage"]

        self.widget = widget
        self.module = widget.module
        self.params = self.widget.getFilter().copy()
        self.params["amount"] = 99
        self.data = []
        self.structure = None
        self.separator = separator or ";"
        self.lineSeparator = lineSeparator or "\n"
        self.encoding = encoding
        self.lang = language

        conf["mainWindow"].log("progress", self)
        self.parent()["class"].append("is_new")
        self.parent()["class"].append("log_progress")
        self.appendChild(html5.TextNode(translate("CSV-Export")))

        DeferredCall(self.nextChunk)
コード例 #13
0
    def setTitle(self, title=None):
        self.moduleH1.removeAllChildren()

        if title is None:
            title = conf.get("vi.name")

        if title:
            self.moduleH1.appendChild(
                html5.TextNode(html5.utils.unescape(title)))
コード例 #14
0
	def __init__(self, shortText="Tooltip", longText="", *args, **kwargs):
		super( ToolTip, self ).__init__( *args, **kwargs )
		self["class"] = "tooltip"
		a = html5.ext.Button(shortText, self.toggleMsgCenter )
		a.appendChild(html5.TextNode())
		#a["href"] = "#tooltip_contents_%s" % self.toolTipIdx
		self.appendChild(a)
		span = html5.Span()
		span.element.innerHTML = longText.replace( "\n", "<br />" )
		self.appendChild( span )
コード例 #15
0
	def cloneComplete(self, request):
		logDiv = html5.Div()
		logDiv["class"].append("msg")
		spanMsg = html5.Span()
		spanMsg.appendChild( html5.TextNode( translate( u"The hierarchy will be cloned in the background." ) ) )
		spanMsg["class"].append("msgspan")
		logDiv.appendChild(spanMsg)

		conf["mainWindow"].log("success",logDiv)
		self.closeOrContinue()
コード例 #16
0
 def onStartSearch(self, searchStr, *args, **kwargs):
     if not searchStr:
         self.setRootNode(self.rootNode)
     else:
         for c in self.pathList._children[:]:
             self.pathList.removeChild(c)
         s = html5.Span()
         s.appendChild(html5.TextNode("Search"))
         self.pathList.appendChild(s)
         self.reloadData({"node": self.rootNode, "search": searchStr})
コード例 #17
0
ファイル: string.py プロジェクト: phorward/viur-vi
    def getViewElement(self, labelstr, datafield):
        labelstr = html5.utils.unescape(labelstr)

        if not datafield:
            return html5.Label(labelstr)
        else:
            aspan = html5.Span()
            aspan.appendChild(html5.TextNode(labelstr))
            aspan["title"] = str(datafield)
            return aspan
コード例 #18
0
 def __init__(self, extension, view, modul, *args, **kwargs):
     super(ExtendedSelectMultiSearch, self).__init__(*args, **kwargs)
     self.view = view
     self.extension = extension
     self.module = modul
     self.filterChangedEvent = EventDispatcher("filterChanged")
     self.appendChild(html5.TextNode(extension["name"]))
     self.selectionCb = html5.Select()
     self.appendChild(self.selectionCb)
     o = html5.Option()
     o["value"] = ""
     o.appendChild(html5.TextNode(translate("Ignore")))
     self.selectionCb.appendChild(o)
     for k, v in extension["values"].items():
         o = html5.Option()
         o["value"] = k
         o.appendChild(html5.TextNode(v))
         self.selectionCb.appendChild(o)
     self.sinkEvent("onChange")
コード例 #19
0
 def replaceWithMessage(self, message, isSuccess):
     self.parent()["class"].remove("is_uploading")
     self.parent()["class"].remove("log_progress")
     if isSuccess:
         self.parent()["class"].append("log_success")
     else:
         self.parent()["class"].append("log_failed")
     msg = html5.Span()
     msg.appendChild(html5.TextNode(message))
     self.parent().appendChild(msg)
     self.parent().removeChild(self)
コード例 #20
0
	def render( self, data, field ):
		if field in data.keys():
			if data and field and field in self.skelStructure:
				options = {k: v for k, v in self.skelStructure[field]["values"]}

				aspan = html5.Span()
				aspan.appendChild(html5.TextNode(options.get(data[field], data[field])))
				aspan["Title"]=data[field]
				return aspan

		return html5.Label(conf["empty_value"])
コード例 #21
0
    def render(self, data, field):

        if not (self.boneName in self.skelStructure and data
                and data.get(field)):
            return html5.Label(conf["empty_value"])

        structure = self.skelStructure[self.boneName]
        val = data[field]

        try:
            if structure["date"] and structure["time"]:
                try:
                    dt = datetime.strptime(val, "%d.%m.%Y %H:%M:%S")
                except:
                    return html5.TextNode(translate("Error parsing Date"))

                span = html5.Span()
                span["class"].append("datetime")
                dateSpan = html5.Span()
                dateSpan["class"].append("date")
                dateSpan.appendChild(html5.TextNode(dt.strftime("%d.%m.%Y")))
                timeSpan = html5.Span()
                timeSpan["class"].append("time")
                timeSpan.appendChild(html5.TextNode(dt.strftime("%H:%M:%S")))
                span.appendChild(dateSpan)
                span.appendChild(timeSpan)

                return span

            elif structure["date"] and not structure["time"]:
                try:
                    dt = datetime.strptime(val, "%d.%m.%Y")
                except:
                    return html5.TextNode(translate("Error parsing Date"))

                dateSpan = html5.Span()
                dateSpan["class"].append("date")
                dateSpan.appendChild(html5.TextNode(dt.strftime("%d.%m.%Y")))

                return dateSpan

            elif not structure["date"] and structure["time"]:
                try:
                    dt = datetime.strptime(val, "%H:%M:%S")
                except:
                    return html5.TextNode(translate("Error parsing Date"))

                timeSpan = html5.Span()
                timeSpan["class"].append("time")
                timeSpan.appendChild(html5.TextNode(dt.strftime("%H:%M:%S")))
                return timeSpan

        except:  #Something got wrong parsing the date
            return html5.Label(str(val))
コード例 #22
0
 def __init__(self, extension, view, module, *args, **kwargs):
     super(ExtendedBooleanSearch, self).__init__(*args, **kwargs)
     self.view = view
     self.extension = extension
     self.module = module
     self.filterChangedEvent = EventDispatcher("filterChanged")
     self.appendChild(html5.TextNode(extension["name"]))
     self.selectionCb = html5.Select()
     self.appendChild(self.selectionCb)
     o = html5.Option()
     o["value"] = ""
     o.appendChild(html5.TextNode(translate("Ignore")))
     self.selectionCb.appendChild(o)
     o = html5.Option()
     o["value"] = "0"
     o.appendChild(html5.TextNode(translate("No")))
     self.selectionCb.appendChild(o)
     o = html5.Option()
     o["value"] = "1"
     o.appendChild(html5.TextNode(translate("Yes")))
     self.selectionCb.appendChild(o)
     self.sinkEvent("onChange")
コード例 #23
0
ファイル: string.py プロジェクト: phorward/viur-vi
 def __init__(self, extension, view, module, *args, **kwargs):
     super(ExtendedStringSearch, self).__init__(*args, **kwargs)
     self.view = view
     self.extension = extension
     self.module = module
     self.opMode = extension["mode"]
     self.filterChangedEvent = EventDispatcher("filterChanged")
     assert self.opMode in ["equals", "from", "to", "prefix", "range"]
     self.appendChild(html5.TextNode(extension["name"]))
     self.sinkEvent("onKeyDown")
     if self.opMode in ["equals", "from", "to", "prefix"]:
         self.input = html5.Input()
         self.input["type"] = "text"
         self.appendChild(self.input)
     elif self.opMode == "range":
         self.input1 = html5.Input()
         self.input1["type"] = "text"
         self.appendChild(self.input1)
         self.appendChild(html5.TextNode("to"))
         self.input2 = html5.Input()
         self.input2["type"] = "text"
         self.appendChild(self.input2)
コード例 #24
0
    def log(self, type, msg):
        """
			Adds a message to the log
			:param type: The type of the message.
			:type type: "success", "error", "warning", "info", "progress"
			:param msg: The message to append
			:type msg: str
		"""
        assert type in ["success", "error", "warning", "info", "progress"]

        liwrap = html5.Li()
        liwrap["class"].append("log_" + type)
        liwrap["class"].append("is_new")

        spanDate = html5.Span()
        spanDate.appendChild(
            html5.TextNode(datetime.now().strftime("%H:%M:%S")))
        spanDate["class"].append("date")
        liwrap.appendChild(spanDate)

        if isinstance(msg, html5.Widget):
            #Append that widget directly
            liwrap.appendChild(msg)

        else:
            #Create a span element for that message
            spanMsg = html5.Span()
            spanMsg.appendChild(html5.TextNode(html5.utils.unescape(msg)))
            spanMsg["class"].append("msg")
            liwrap.appendChild(spanMsg)

        DeferredCall(self.removeNewCls, liwrap, _delay=2500)
        self.logUL.appendChild(liwrap)

        if len(self.logUL._children) > 1:
            self.logUL.element.removeChild(liwrap.element)
            self.logUL.element.insertBefore(
                liwrap.element, self.logUL.element.children.item(0))
コード例 #25
0
def textToHtml(node, text):
	"""
	Generates html nodes from text by splitting text into content and into
	line breaks html5.Br.

	:param node: The node where the nodes are appended to.
	:param text: The text to be inserted.
	"""

	for (i, part) in enumerate(text.split("\n")):
		if i > 0:
			node.appendChild(html5.Br())

		node.appendChild(html5.TextNode(part))
コード例 #26
0
	def onRootNodesAvailable(self, req):
		res = NetworkService.decode( req )
		for node in res:
			option = html5.Option()
			option["value"] = node["key"]
			option.appendChild( html5.TextNode( node[ "name"] ) )
			if node["key"] == self.parent().parent().rootNode:
				option["selected"] = True
			self.appendChild( option )

		if len(self.children()) > 1 and not self.parent().parent().context:
			self.show()
		else:
			self.hide()
コード例 #27
0
ファイル: topbar.py プロジェクト: Xeon2003/vi
    def update(self):
        user = conf.get("currentUser")
        if not user:
            NetworkService.request("user",
                                   "view/self",
                                   successHandler=self.onCurrentUserAvailable,
                                   cacheable=False)
            return

        aa = html5.A()
        aa["title"] = user["name"]
        aa["class"].append("icon accountmgnt")
        aa.appendChild(html5.TextNode(user["name"]))
        self.appendChild(aa)
コード例 #28
0
ファイル: hierarchy.py プロジェクト: sveneberth/viur-vi
	def buildDescription(self):
		"""
			Generates the visual representation of this entry.
		"""
		format = "$(name)"

		if self.module in conf["modules"].keys():
			moduleInfo = conf["modules"][self.module]
			if "format" in moduleInfo.keys():
				format = moduleInfo["format"]

		self.appendChild(
				html5.TextNode(
						html5.utils.unescape(utils.formatString(format, self.data, self.structure,
						                                        language=conf["currentlanguage"]))))
コード例 #29
0
ファイル: list.py プロジェクト: Xeon2003/vi
    def showErrorMsg(self, req=None, code=None):
        """
			Removes all currently visible elements and displayes an error message
		"""
        self.actionBar["style"]["display"] = "none"
        self.table["style"]["display"] = "none"
        errorDiv = html5.Div()
        errorDiv["class"].append("error_msg")
        if code and (code == 401 or code == 403):
            txt = translate("Access denied!")
        else:
            txt = translate("An unknown error occurred!")
        errorDiv["class"].append("error_code_%s" % (code or 0))
        errorDiv.appendChild(html5.TextNode(txt))
        self.appendChild(errorDiv)
コード例 #30
0
 def __init__(self, *args, **kwargs):
     super(Search, self).__init__(*args, **kwargs)
     self.startSearchEvent = EventDispatcher("startSearch")
     self["class"].append("search")
     lblSearch = html5.H2()
     lblSearch.appendChild(html5.TextNode(translate("Fulltext search")))
     self.appendChild(lblSearch)
     self.searchInput = html5.Input()
     self.searchInput["type"] = "text"
     self.appendChild(self.searchInput)
     self.btn = html5.ext.Button(translate("Search"),
                                 callback=self.doSearch)
     self.appendChild(self.btn)
     self.sinkEvent("onKeyDown")
     self.last_search = ""