Exemplo n.º 1
0
    def builDataTable(self):
        tablehead = ["Datum", "Status", "Nachricht", "Key"]  # ,"Daten"
        tablefields = ["date", "type", "msg", "key"]  # ,"data"
        table = tablewdgt.SelectTable(indexes=True)
        table.setHeader(tablehead)

        for eidx, entry in enumerate(self.logList):
            for fidx in range(0, len(tablehead)):
                table.prepareCol(eidx, fidx + 1)
                currentDatafield = tablefields[fidx]

                if currentDatafield == "msg":

                    if isinstance(entry[currentDatafield], html5.Widget):
                        table["cell"][eidx][fidx + 1] = entry[currentDatafield]
                    else:
                        table["cell"][eidx][fidx + 1] = html5.TextNode(
                            html5.utils.unescape(entry[currentDatafield]))
                elif currentDatafield == "key":
                    table["cell"][eidx][fidx + 1] = logA(entry)
                else:
                    table["cell"][eidx][fidx + 1] = html5.TextNode(
                        entry[currentDatafield])

        self.appendChild(table)
Exemplo n.º 2
0
    def log(self, type, msg, icon=None, date=None):
        """
			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"]

        msgWrap = html5.Li()
        msgWrap.addClass("msg--" + type, "msg", "is-active")
        msgWrap.addClass("is-new popup popup--s")

        if icon:
            svg = embedsvg.get(icon)
        else:
            svg = embedsvg.get("icons-%s" % type)

        if not svg:
            svg = embedsvg.get("icons-message-news")

        if svg:
            msgWrap.element.innerHTML = svg + msgWrap.element.innerHTML

        msgContent = html5.Div()
        msgContent.addClass("msg-content")
        msgWrap.appendChild(msgContent)
        if not date:
            adate = datetime.now().strftime("%d. %b. %Y, %H:%M:%S")
        else:
            adate = date
        msgDate = html5.Span()
        msgDate.appendChild(html5.TextNode(adate))
        msgDate.addClass("msg-date")
        msgContent.appendChild(msgDate)

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

        else:
            #Create a span element for that message
            msgDescr = html5.Span()
            msgDescr.appendChild(html5.TextNode(html5.utils.unescape(msg)))
            msgDescr.addClass("msg-descr")
            msgContent.appendChild(msgDescr)

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

        if len(self.logUL._children) > 1:
            self.logUL.element.removeChild(msgWrap.element)
            self.logUL.element.insertBefore(
                msgWrap.element, self.logUL.element.children.item(0))
Exemplo n.º 3
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["limit"] = 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, icon="icons-download-file")
        self.parent().addClass("is-new")
        self.parent().addClass("log-progress")
        self.appendChild(html5.TextNode(translate("CSV-Export")))

        DeferredCall(self.nextChunk)
Exemplo n.º 4
0
    def update(self):
        user = conf.get("currentUser")
        if not user:
            NetworkService.request("user",
                                   "view/self",
                                   successHandler=self.onCurrentUserAvailable,
                                   cacheable=False)
            return

        aitem = html5.Div()
        aitem["class"] = ["item", "has-hover", "item--small"]
        # userinfo
        usrinfo = html5.Div()
        usermail = html5.Span()
        usermail.appendChild(html5.TextNode(user["name"]))
        aitem.appendChild(usermail)
        self.popoutlist.appendChild(aitem)

        self["title"] = user["name"]
        self.currentUser = user["key"] or None
        self.addClass("vi-tb-accountmgnt")
        try:
            self.btn["text"] = "%s. %s" % (user["firstname"][0],
                                           user["lastname"])
        except:
            self.btn["text"] = user["name"]
Exemplo n.º 5
0
	def setHeader(self, headers):
		"""
			Sets the table-headers to 'headers'
			:param headers: list of strings
			:type headers: list
		"""

		tr = html5.Tr()
		tr.addClass("vi-table-head-row","ignt-table-head-row")

		# Extra column for Index#s
		if self.indexes:
			th = html5.Th()
			th.addClass("vi-table-head-index", "vi-table-head-cell", "ignt-table-head-cell")
			tr.appendChild( th )

		# Extra column for checkboxes
		if self.checkboxes:
			th = html5.Th() # fixme..
			th.addClass("vi-table-head-check", "vi-table-head-cell", "ignt-table-head-cell")
			tr.appendChild( th )

		# Now every title column
		for head in headers:
			th = html5.Th()
			th.addClass("vi-table-head-cell", "ignt-table-head-cell")
			th.appendChild( html5.TextNode( head ) )
			tr.appendChild( th )

		self.head.removeAllChildren()
		self.head.appendChild( tr )
Exemplo n.º 6
0
    def __init__(self, ident, title=None):
        super(AccordionSegment, self).__init__()
        self.sinkEvent("onClick")

        self.addClass("vi-accordion-segment")
        self["name"] = ident

        legend = html5.Legend()
        legend.addClass("vi-accordion-legend")
        self.appendChild(legend)

        self.title = html5.Span()
        embedSvg = embedsvg.get("icons-arrow-right")
        if embedSvg:
            self.title.element.innerHTML = embedSvg
        self.title.appendChild(html5.TextNode(title or ident))
        self.title.addClass("vi-accordion-title")
        self.title["role"] = "button"
        legend.appendChild(self.title)

        # icon = html5.Div()
        # icon.addClass("vi-accordion-icon")
        # self.title.appendChild()

        self._section = html5.Section()
        self._section.addClass("vi-accordion-section")
        self.appendChild(self._section)
Exemplo n.º 7
0
 def __init__(self, urls, entry, modul, *args, **kwargs):
     super(Preview, self).__init__(*args, **kwargs)
     self.addClass("vi-widget vi-widget--preview")
     self.urls = urls
     self.entry = entry
     self.module = modul
     containerDiv = html5.Div()
     containerDiv.addClass("vi-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.addClass("btn--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.addClass("preview")
Exemplo n.º 8
0
    def additionalDropAreas(self):
        '''
			Drag and Drop areas
		'''
        self.afterDiv = html5.Div()
        self.afterDiv["class"] = ["after-element"]
        self.afterDiv.hide()
        aftertxt = html5.TextNode(translate(u"Nach dem Element einfügen"))
        self.afterDiv.appendChild(aftertxt)
        self.nodeWrapper.appendChild(self.afterDiv)

        self.beforeDiv = html5.Div()
        self.beforeDiv["class"] = ["before-element"]
        self.beforeDiv.hide()
        beforetxt = html5.TextNode(translate(u"Vor dem Element einfügen"))
        self.beforeDiv.appendChild(beforetxt)
        self.nodeWrapper.prependChild(self.beforeDiv)
Exemplo n.º 9
0
    def __init__(self, logObj=None):
        super(logEntry, self).__init__()
        if isinstance(logObj["msg"], html5.Widget):
            msg = logObj["msg"]
        else:
            msg = html5.TextNode(html5.utils.unescape(logObj["msg"]))

        self.appendChild(msg)
Exemplo n.º 10
0
	def setActiveTask(self):
		task = self.getSelectedTask()
		if not task:
			return 0
		self.descr.removeAllChildren()
		self.descr.appendChild(
			html5.TextNode(
				task.get( "descr" ) or translate( "vi.tasks.no-description" ) ) )
Exemplo n.º 11
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)))
Exemplo n.º 12
0
    def unserialize(self, value=None):
        self.value = value

        if value is None:
            value = conf["emptyValue"]
        else:
            value = self.setValue(value)

        self.appendChild(html5.TextNode(value), replace=True)
Exemplo n.º 13
0
    def __init__(self, module, structure, item, *args, **kwargs):
        super(InternalPreview, self).__init__(*args, **kwargs)

        self.addClass("vi-sb-intprev box-body box--content")

        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.ipli = html5.Li()
            self.ipli["class"] = [
                "vi-sb-intprev-item", "vi-sb-intprev--" + module,
                "vi-sb-intprev--" + bone["type"], "vi-sb-intprev--" + key
            ]

            self.ipdl = html5.Dl()
            self.ipdl.addClass("vi-sb-intprev-content")

            self.ipdt = html5.Dt()
            self.ipdt.addClass("vi-sb-intprev-title")
            self.ipdt.appendChild(
                html5.TextNode(
                    key if conf["showBoneNames"] else bone.get("descr", key)))

            self.ipdd = html5.Dd()
            self.ipdd.addClass("vi-sb-intprev-descr")
            boneFactory = boneSelector.select(module, key,
                                              tmpDict)(module, key, tmpDict)

            if key == "key":
                keydiv = html5.Div()
                keydiv["style"]["display"] = "inline-block"
                copybtn = Button("Copy", self.onCopyKey)

                keyvaluediv = boneFactory.viewWidget(item[key])

                keyfield = html5.Input()
                keyfield["value"] = item[key]
                keyfield["style"]["opacity"] = 0
                keyfield["style"]["position"] = "absolute"
                keyfield["id"] = "keyfield"

                keydiv.appendChild(keyfield, keyvaluediv, copybtn)
                self.ipdd.appendChild(keydiv)
            else:
                self.ipdd.appendChild(boneFactory.viewWidget(item[key]))

            self.ipdl.appendChild(self.ipdt)
            self.ipdl.appendChild(self.ipdd)
            self.ipli.appendChild(self.ipdl)

            self.appendChild(self.ipli)
Exemplo n.º 14
0
    def msgOverlay(self, logObj):
        assert logObj["type"] in [
            "success", "error", "warning", "info", "progress"
        ]

        msgwrap = html5.Div()
        msgwrap["class"] = [
            "msg", "is-active", "popup", "popup--se",
            "msg--%s" % logObj["type"]
        ]

        msgcontent = html5.Div()
        msgcontent["class"] = ["msg-content"]
        msgwrap.appendChild(msgcontent)

        date = html5.Span()
        date["class"] = ["msg-date"]
        date.appendChild(html5.TextNode(logObj["date"]))
        msgcontent.appendChild(date)

        msgdescr = html5.Div()
        msgdescr["class"] = ["msg-descr"]
        msgcontent.appendChild(msgdescr)

        if isinstance(logObj["msg"], html5.Widget):
            msgdescr.appendChild(logObj["msg"])
        else:
            msgdescr.appendChild(
                html5.TextNode(html5.utils.unescape(logObj["msg"])))

        if logObj["icon"]:
            svg = embedsvg.get(logObj["icon"])
        else:
            svg = embedsvg.get("icons-%s" % logObj["type"])

        if not svg:
            svg = embedsvg.get("icons-message-news")

        if svg:
            msgwrap.element.innerHTML = svg + msgwrap.element.innerHTML

        self.appendChild(msgwrap)
        DeferredCall(self.removeInfo, msgwrap, _delay=2500)
Exemplo n.º 15
0
	def replaceWithMessage(self, message, isSuccess):
		self.parent().removeClass("is-uploading")
		self.parent().removeClass("log-progress")
		if isSuccess:
			self.parent().addClass("log-success")
		else:
			self.parent().addClass("log-failed")
		msg = html5.Span()
		msg.appendChild(html5.TextNode(message))
		self.parent().appendChild(msg)
		self.parent().removeChild(self)
Exemplo n.º 16
0
    def onTableChanged(self, table, rowCount):
        if "elementSpan" in dir(self):
            self.removeChild(self.elementSpan)

        pages = self.currentModule.loadedPages
        currentpage = self.currentModule.currentPage
        #print(table._model)
        if table._dataProvider:
            #self.elementSpan = html5.Span(html5.TextNode(translate("current Page {cpg}, loaded elements: {amt}, pages: {pg}",amt=rowCount, pg=pages, cpg=currentpage )))
            self.elementSpan = html5.Span(
                html5.TextNode(
                    translate("loaded elements: {amt}, pages: {pg}",
                              amt=len(table._model),
                              pg=pages)))
        else:
            #self.elementSpan = html5.Span(html5.TextNode(translate("current Page {cpg}, all elements loaded: {amt}, pages: {pg}",amt=rowCount, pg=pages, cpg=currentpage)))
            self.elementSpan = html5.Span(
                html5.TextNode(
                    translate("all elements loaded: {amt}, pages: {pg}",
                              amt=len(table._model),
                              pg=pages)))
        self.appendChild(self.elementSpan)
Exemplo n.º 17
0
	def onStartSearch(self, searchStr, *args, **kwargs):
		if not searchStr:
			self.setRootNode(self.rootNode)
		else:
			for c in self.entryFrame._children[ : ]:
				self.entryFrame.removeChild( c )

			for c in self.pathList._children[:]:
				self.pathList.removeChild(c)
			s = html5.Span()
			s.appendChild(html5.TextNode("Search"))
			self.pathList.appendChild(s)
			self.loadNode(node = self.rootNode ,overrideParams = {"search": searchStr})
Exemplo n.º 18
0
    def __init__(self, *args, **kwargs):
        super(Tasks, self).__init__(icon="icons-settings", *args, **kwargs)
        self.sinkEvent("onClick")
        self.hide()
        self.addClass("btn vi-tb-tasks")
        self.appendChild(html5.TextNode(translate("System")))

        if not conf["tasks"]["server"]:
            NetworkService.request(None,
                                   "/vi/_tasks/list",
                                   successHandler=self.onTaskListAvailable,
                                   cacheable=False)

        self.update()
Exemplo n.º 19
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:
            self.show()
        else:
            self.hide()
Exemplo n.º 20
0
    def unserialize(self, value=None):
        self.value = value

        if value:
            txt = utils.formatString(self.bone.boneStructure["format"],
                                     value,
                                     self.bone.boneStructure["using"],
                                     language=self.language)

        else:
            txt = None

        self.appendChild(html5.TextNode(txt or conf["emptyValue"]),
                         replace=True)
Exemplo n.º 21
0
    def buildDescription(self):
        """
			Creates the visual representation of our entry
		"""
        # Find any bones in the structure having "frontend_default_visible" set.
        hasDescr = False

        for boneName, boneInfo in self.structure:
            if "params" in boneInfo.keys() and isinstance(
                    boneInfo["params"], dict):
                params = boneInfo["params"]
                if "frontend_default_visible" in params and params[
                        "frontend_default_visible"]:
                    structure = {k: v for k, v in self.structure}
                    wdg = boneSelector.select(self.module, boneName, structure)

                    if wdg is not None:
                        self.nodeHeadline.appendChild(
                            wdg(self.module, boneName,
                                structure).viewWidget(self.data[boneName]))
                        hasDescr = True

        # In case there is no bone configured for visualization, use a format-string
        if not hasDescr:
            format = "$(name)"  # default fallback

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

            self.nodeHeadline.appendChild(
                utils.formatString(format,
                                   self.data,
                                   self.structure,
                                   language=conf["currentLanguage"]))

            if self.data and "size" in self.data and self.data["size"]:

                def convert_bytes(num):
                    step_unit = 1000.0  # 1024 size

                    for x in ['bytes', 'KB', 'MB', 'GB', 'TB']:
                        if num < step_unit:
                            return "%3.1f %s" % (num, x)
                        num /= step_unit

                size = convert_bytes(int(self.data["size"]))
                self.nodeSubline.appendChild(html5.TextNode(size))
Exemplo n.º 22
0
	def __init__(self, loginScreen, *args, **kwargs):
		assert isinstance(loginScreen, LoginScreen)
		super(BaseLoginHandler, self).__init__(*args, **kwargs)

		self.loginScreen = loginScreen

		if not "cssname" in dir(self):
			self.cssname = self.__class__.__name__.lower()

		self.addClass("vi-login-handler btn btn--small ")
		self.addClass("vi-login-handler-%s" % self.cssname)
		self.sinkEvent("onClick")

		self.loginScreen.loginMethodSelector.appendChild(self)

		self.appendChild(html5.TextNode(translate("vi.login.handler.%s" % self.cssname)))

		# --- Surrounding Dialog ---
		self.loginDialog = html5.Div()
		self.loginDialog.addClass("vi-login-dialog popup popup--center")
		self.loginDialog.addClass("vi-login-dialog-%s" % self.cssname)
		self.loginScreen.appendChild(self.loginDialog)

		# --- Dialog ---
		self.loginBox = html5.Div()
		self.loginBox.addClass("box box--content-wide")
		self.loginDialog.appendChild(self.loginBox)

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

		self.mask = html5.Div()
		self.mask.addClass("vi-login-mask")
		self.mask.addClass("vi-login-mask-%s" % self.cssname)
		self.loginBox.appendChild(self.mask)

		# 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"] = "public/images/vi-login-logo.svg"
		self.loginHeader.appendChild(img)
Exemplo n.º 23
0
    def showErrorMsg(self, req=None, code=None):
        """
			Removes all currently visible elements and displayes an error message
		"""
        self.actionbar["style"]["display"] = "none"
        self.form["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)
Exemplo n.º 24
0
    def setCurrentModulDescr(self,
                             descr="",
                             iconURL=None,
                             iconClasses=None,
                             path=None):
        self.moduleName.removeAllChildren()
        descr = html5.utils.unescape(descr)
        self.moduleName.appendChild(html5.TextNode(descr))

        self.modulImg.removeAllChildren()
        self.modulImg.appendChild(Icon(descr, iconURL))

        conf["theApp"].setTitle(descr)

        if path:
            conf["theApp"].setPath(path)
Exemplo n.º 25
0
	def unserialize(self, value=None):
		if value:
			serverToClient = []

			if self.bone.boneStructure.get("date", True):
				serverToClient.append("%d.%m.%Y") # fixme: Again german format??

			if self.bone.boneStructure.get("time", True):
				serverToClient.append("%H:%M:%S")

			try:
				self.value = datetime.datetime.strptime(value or "", " ".join(serverToClient))
				value = self.value.strftime(translate("vi.bone.date.at").join(serverToClient)) #fixme: hmm...
			except:
				value = "Invalid Datetime Format"

		self.appendChild(html5.TextNode(value or conf["emptyValue"]), replace=True)
Exemplo n.º 26
0
    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.addClass(
            "popup popup--center popup--local msg msg--error is-active error_msg"
        )
        if code and (code == 401 or code == 403):
            txt = translate("Access denied!")
        else:
            txt = translate("An unknown error occurred!")
        errorDiv.addClass("error_code_%s" % (code or 0))
        errorDiv.appendChild(html5.TextNode(txt))
        self.appendChild(errorDiv)
Exemplo n.º 27
0
    def rebuildCB(self, *args, **kwargs):
        self.urlCb.removeAllChildren()

        if isinstance(self.urls, list):
            self.urls = {x: x for x in self.urls}

        if not isinstance(self.urls, dict) or len(self.urls.keys()) == 1:
            self.urlCb.addClass("is-hidden")
            return

        for name, url in self.urls.items():
            o = html5.Option()
            o["value"] = url
            o.appendChild(html5.TextNode(name))
            self.urlCb.appendChild(o)

        self.urlCb.removeClass("is-hidden")
Exemplo n.º 28
0
 def __init__(self, *args, **kwargs):
     super(Search, self).__init__(*args, **kwargs)
     self.startSearchEvent = EventDispatcher("startSearch")
     self.addClass("vi-search")
     self.searchLbl = html5.H2()
     self.searchLbl.appendChild(html5.TextNode(
         translate("Fulltext search")))
     self.searchLbl.addClass("vi-search-label")
     self.appendChild(self.searchLbl)
     self.searchInput = html5.ignite.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 = ""
Exemplo n.º 29
0
    def showErrorMsg(self, req=None, code=None):
        """
			Removes all currently visible elements and displayes an error message
		"""
        self.actionBar.hide()
        self.entryFrame.hide()

        errorDiv = html5.Div()
        errorDiv.addClass(
            "popup popup--center popup--local msg msg--error is-active error_msg"
        )
        if code and (code == 401 or code == 403):
            txt = translate("Access denied!")
        else:
            txt = translate("Error {code} occurred!", code=code)

        errorDiv.addClass("error_code_%s" %
                          (code or 0))  # fixme: not an ignite style?
        errorDiv.appendChild(html5.TextNode(txt))
        self.appendChild(errorDiv)
Exemplo n.º 30
0
    def __init__(self, module, key):
        super(RepeatDatePopup, self).__init__()
        self.module = module
        self.editIdx = RepeatDatePopup.__editIdx_  #Iternal counter to ensure unique ids
        RepeatDatePopup.__editIdx_ += 1
        self.key = key
        self._lastData = {}  #Dict of structure and values received
        self.closeOnSuccess = False

        h3 = html5.H3()
        h3["class"].append("modul_%s" % self.module)
        h3["class"].append("apptype_list")

        h3.appendChild(html5.TextNode(translate("create recurrent dates")))

        self.wasInitialRequest = True
        self.actionbar = ActionBar(self.module, "list", "repeatdate")
        self.appendChild(self.actionbar)
        self.form = html5.Form()
        self.appendChild(self.form)
        self.actionbar.setActions(["create.recurrent"], widget=self)
        self.reloadData()