Beispiel #1
0
    def __init__(self):
        super(LogButton, self).__init__()

        self.logsList = []

        self["class"] = ["popout-opener", "popout-anchor", "popout--sw"]

        self.logbtn = Button(icon="icons-time",
                             className="btn btn--topbar btn--log")
        self.appendChild(self.logbtn)

        popout = html5.Div()
        popout["class"] = ["popout"]
        self.popoutlist = html5.Div()
        self.popoutlist["class"] = ["list"]

        popout.appendChild(self.popoutlist)
        self.appendChild(popout)
        self.sinkEvent("onClick")

        aitem = html5.Div()
        aitem["class"] = ["item", "has-hover", "item--small item--info"]
        listentry = logEntry({"msg": translate("Das Log ist Leer")})
        aitem.appendChild(listentry)
        self.popoutlist.appendChild(aitem)

        #load old logs from idb
        idb = conf["indexeddb"]
        if "vi_log" not in idb.objectStoreNames:
            idb.dbAction("createStore", "vi_log", None,
                         {"autoIncrement": True})
        data = idb.getList("vi_log")
        data.addEventListener("dataready", self.idbdata)
Beispiel #2
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"]
Beispiel #3
0
	def _renderObject(self, obj, tableIsPrepared=False):
		"""
			Renders the object to into the table.
			Does nothing if the list of _shownFields is empty.
			:param obj: Dictionary of values for this row
			:type obj: dict
		"""
		if not self._shownFields:
			return

		rowIdx = self._model.index(obj)
		cellIdx = 0

		if not tableIsPrepared:
			self.table.prepareCol( rowIdx, len( self._shownFields ) - 1 )

		for field in self._shownFields:
			if field in self._cellRender.keys():
				lbl = self._cellRender[field].viewWidget(obj[field])
			elif field in obj.keys():
				lbl = html5.Div(obj[field])
			else:
				lbl = html5.Div("...")
			lbl.addClass("ignt-table-content")
			self.table.setCell( rowIdx, cellIdx, lbl )
			cellIdx += 1
Beispiel #4
0
    def __init__(self, *args, **kwargs):
        super(AdminScreen, self).__init__(*args, **kwargs)

        self.sinkEvent("onClick")
        self["id"] = "CoreWindow"
        conf["mainWindow"] = self

        self.topBar = TopBarWidget()
        self.appendChild(self.topBar)

        self.mainFrame = html5.Div()
        self.mainFrame["class"] = "vi-main-frame"
        self.appendChild(self.mainFrame)

        self.moduleMgr = html5.Div()
        self.moduleMgr["class"] = "vi-manager-frame"
        self.mainFrame.appendChild(self.moduleMgr)

        self.moduleViMgr = html5.Div()
        self.moduleViMgr["class"] = "vi-manager"
        self.moduleMgr.appendChild(self.moduleViMgr)

        self.moduleList = html5.Nav()
        self.moduleList["class"] = "vi-modulelist"
        self.moduleViMgr.appendChild(self.moduleList)

        self.modulePipe = html5.Div()
        self.modulePipe.addClass("vi-modulepipe")
        self.moduleMgr.appendChild(self.modulePipe)

        self.viewport = html5.Div()
        self.viewport["class"] = "vi-viewer-frame"
        self.mainFrame.appendChild(self.viewport)

        self.logWdg = None

        self.currentPane = None
        self.nextPane = None  # Which pane gains focus once the deferred call fires
        self.panes = [
        ]  # List of known panes. The ordering represents the order in which the user visited them.

        self.userLoggedOutMsg = None

        # Register the error-handling for this iframe
        try:
            html5.window.onerror = html5.window.logError
            html5.window.onerror = html5.window.logError
        except:
            print("logError is disabled")
Beispiel #5
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)
Beispiel #6
0
	def __init__(self, descr=None, iconURL=None, iconClasses=None,
				 	closeable=False, collapseable=True, focusable=True,
				 		path=None):

		super(Pane, self).__init__()

		self.addClass("vi-pane", "is-active")

		self.parentPane = None
		self.sinkEvent("onClick")
		self.groupPrefix = None

		self.item = html5.Div()
		self.item.addClass("item has-hover")
		self.appendChild(self.item)

		self.descr = descr
		self.iconURL = iconURL
		self.iconClasses = iconClasses
		self.collapseable = collapseable
		self.focusable = focusable
		self.path = path

		self.childPanes = []

		self.widgetsDomElm = html5.Div()
		self.widgetsDomElm.addClass("vi-viewer-pane", "has-no-child")
		self.childDomElem = None

		self.img = None
		self.label = html5.Div()
		self.label.addClass("item-link")
		self.item.appendChild(self.label)

		self.defaultIconURL = self.iconURL
		self.itemImage = None
		self.setText(descr, iconURL)

		self.closeBtn = html5.ext.Button(u"×", self.onBtnCloseReleased)
		self.closeBtn["class"] = "item-action"
		self.item.appendChild(self.closeBtn)

		if not closeable:
			self.closeBtn.hide()

		self.closeable = closeable
		self.isExpanded = False

		DeferredCall(self.setText, _delay=250)
Beispiel #7
0
	def __init__(self, loginScreen, *args, **kwargs):
		super(UserPasswordLoginHandler, self).__init__(loginScreen, *args, **kwargs)

		# Standard Login Form
		self.pwform = html5.Form()
		self.mask.appendChild(self.pwform)

		self.username = LoginInputField(self)
		self.username["type"] = "text"
		self.username["name"] = "username"
		self.username["placeholder"] = translate("Username")
		self.pwform.appendChild(self.username)

		self.password = LoginInputField(self)
		self.password["type"] = "password"
		self.password["name"] = "password"
		self.password["placeholder"] = translate("Password")
		self.pwform.appendChild(self.password)

		self.loginBtn = html5.ext.Button(translate("Login"), callback=self.onLoginClick)
		self.loginBtn.addClass("vi-login-btn btn--viur")
		self.pwform.appendChild(self.loginBtn)

		# One Time Password
		self.otpform = html5.Form()
		self.otpform.hide()
		self.mask.appendChild(self.otpform)

		self.otp = LoginInputField(self)
		self.otp["name"] = "otp"
		self.otp["placeholder"] = translate("One Time Password")
		self.otpform.appendChild(self.otp)

		self.verifyBtn = html5.ext.Button(translate("Verify"), callback=self.onVerifyClick)
		self.otpform.appendChild(self.verifyBtn)

		# Universal edit widget
		self.editform = html5.Div()
		self.editform.hide()
		self.mask.appendChild(self.editform)

		self.edit = html5.Div()
		self.editform.appendChild(self.edit)

		self.editskey = self.editaction = self.editwidget = None

		self.sendBtn = html5.ext.Button(translate("Send"), callback=self.onSendClick)
		self.editform.appendChild(self.sendBtn)
Beispiel #8
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")
Beispiel #9
0
	def addChildPane(self, pane):
		"""
			Stack a pane under this one.
			It gets displayed as a subpane.
			:param pane: Another pane
			:type pane: pane
		"""
		assert pane != self, "A pane cannot be a child of itself"

		self.childPanes.append(pane)
		pane.parentPane = self

		if not self.childDomElem:
			self.childDomElem = html5.Div()
			self.childDomElem.addClass("list list--sub")

			if self.collapseable and not pane.closeable:
				self.childDomElem.removeClass("is-active")
			else:
				self.childDomElem.addClass("is-active")

			self.appendChild(self.childDomElem)

			if self.closeable:
				self.closeBtn.hide()

		if (pane.closeable and "is-active" not in self.childDomElem["class"]):
			self.childDomElem.addClass("is-active")

		self.childDomElem.appendChild(pane)
Beispiel #10
0
    def onAttach(self):
        super(FilterSelector, self).onAttach()

        activeFilter = self.parent().parent().filterID
        isSearchDisabled = False

        if self.module in conf["modules"].keys():
            modulConfig = conf["modules"][self.module]
            if "views" in modulConfig.keys() and modulConfig["views"]:
                for view in modulConfig["views"]:
                    self.appendChild(CompoundFilter(view, self.module))
            if "disabledFunctions" in modulConfig.keys() and modulConfig["disabledFunctions"] and "fulltext-search" in \
              modulConfig["disabledFunctions"]:
                isSearchDisabled = True

        if not isSearchDisabled:
            self.search = Search()
            self.search.addClass("item", "has-hover", "is-collapsed")
            self.appendChild(self.search)
            self.search.startSearchEvent.register(self)

            filterImage = html5.Div()
            filterImage.addClass("item-image")
            self.search.prependChild(filterImage)

            self.filterIcon = html5.I()
            self.filterIcon.addClass("i")
            filterImage.appendChild(self.filterIcon)

            self.search.searchLbl.addClass("item-content")

            embedSvg = embedsvg.get("icons-search")
            if embedSvg:
                self.filterIcon.element.innerHTML = embedSvg + self.filterIcon.element.innerHTML
Beispiel #11
0
	def setText(self, descr = None, iconURL = None,loading=False):
		try:
			# It might already be gone...
			self.label.removeAllChildren()
		except:
			return

		if descr is None:
			descr = self.descr
		else:
			self.descr = descr

		self.setImage(loading=loading)

		if self.iconClasses is not None:
			for cls in self.iconClasses:
				self.label.addClass(cls)

		self.itemContent = html5.Div()
		self.itemContent.addClass("item-content")
		self.label.appendChild(self.itemContent)

		if descr is not None:
			h = html5.H3()
			h.appendChild(descr)
			h.addClass("item-headline")
			self.itemContent.appendChild(h)
Beispiel #12
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)
Beispiel #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)
Beispiel #14
0
	def searchWidget( self ):
		searchBox = html5.Div()
		searchBox.addClass( "vi-search-wrap" )
		self.appendChild( searchBox )

		self.search = Search()
		self.search.addClass( "input-group" )
		searchBox.appendChild( self.search )
		self.search.searchLbl.addClass( "label" )
		self.search.startSearchEvent.register( self )
Beispiel #15
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)
Beispiel #16
0
    def __init__(self, logList):
        super(logWidget, self).__init__()
        self["class"] = "vi-widget"
        self["style"]["overflow"] = "auto"  #here we need a class?
        self.logList = logList
        header = html5.Div()
        header["class"] = ["vi-actionbar", "bar"]
        self.appendChild(header)

        DeferredCall(self.builDataTable)
Beispiel #17
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))
Beispiel #18
0
    def __init__(self, *args, **kwargs):
        super(UserState, self).__init__(*args, **kwargs)

        self["class"] = ["popout-opener", "popout-anchor", "popout--sw"]

        self.btn = Button(icon="icons-user",
                          className="btn btn--topbar btn--user")
        self.appendChild(self.btn)

        self.sinkEvent("onClick")

        popout = html5.Div()
        popout["class"] = ["popout"]
        self.popoutlist = html5.Div()
        self.popoutlist["class"] = ["list"]

        popout.appendChild(self.popoutlist)
        self.appendChild(popout)

        self.update()
Beispiel #19
0
    def renderPopOut(self):
        self.popoutlist.removeAllChildren()

        for entry in self.logsList[:10]:
            aitem = html5.Div()
            aitem["class"] = [
                "item", "has-hover", "item--small",
                "item--%s" % (entry["type"])
            ]
            listentry = logEntry(entry)
            aitem.appendChild(listentry)
            self.popoutlist.appendChild(aitem)
Beispiel #20
0
    def __init__(self):
        super(Log, self).__init__()

        self.addClass("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.addClass("statuslist")
        self.appendChild(self.logUL)

        versionDiv = html5.Div()
        versionDiv.addClass("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["core.version"]])))
            versionspan.addClass("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"]))
            versionspan.addClass("versionspan")

            versionDiv.appendChild(versionspan)
            ''' fixme ... VI3.0
			revspan = html5.Span()
			revspan.appendChild(html5.TextNode("Rev %s" % revision))
			revspan.addClass("revisionspan")

			datespan = html5.Span()
			datespan.appendChild(html5.TextNode("Built %s" % builddate))
			datespan.addClass("datespan")

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

        if versionDiv.children():
            self.appendChild(versionDiv)
Beispiel #21
0
	def __init__( self ):
		super( TaskSelectWidget, self ).__init__( title = translate( "vi.tasks.headline" ) )
		self.sinkEvent( "onChange" )

		div = html5.Div()
		div[ "class" ] = [ "vi-tasks-selector" ]
		self.popupBody.appendChild( div )

		self.select = html5.ignite.Select()
		div.appendChild( self.select )

		for type in [ "server", "client" ]:
			for i, task in enumerate( conf[ "tasks" ][ type ] ):
				if type == "client":
					assert task[ "task" ], "task-Attribute must be set for client-side tasks"

				if not "type" in task.keys():
					task[ "type" ] = type

				opt = html5.Option()
				opt.task = task

				opt.appendChild( html5.TextNode( task[ "name" ] ) )

				if not self.select._children:
					opt._setSelected( True )

				self.select.appendChild( opt )

		self.descr = html5.Div()
		self.descr[ "class" ] = [ "vi-tasks-description" ]
		self.popupBody.appendChild( self.descr )

		self.popupFoot.appendChild( html5.ext.Button( translate( "Cancel" ), self.close ) )
		self.popupFoot.appendChild( html5.ext.Button( translate( "Run" ), self.invokeTask ) )

		# Init
		self.setActiveTask()
Beispiel #22
0
    def __init__(self,
                 module,
                 rootNode=None,
                 node=None,
                 context=None,
                 *args,
                 **kwargs):
        super(TreeBrowserWidget, self).__init__(module, rootNode, node,
                                                context, *args, **kwargs)

        # Breadcrumb (bröselige Bröselbrotbrösel, oder was damit sonst auch immer gemeint sein soll...)
        self.pathList = html5.Div()
        self.pathList.addClass("vi-tree-breadcrumb")
        self.insertBefore(self.pathList, self.entryFrame)
Beispiel #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)
Beispiel #24
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)
Beispiel #25
0
	def onLoginClick(self, sender = None):
		if not (self.username["value"] and self.password["value"]):
			self.loginIncompleteMsg = html5.Div()
			self.loginIncompleteMsg.addClass("msg msg--error is-active")
			self.loginIncompleteMsg
			self.loginHeader.appendChild(self.loginIncompleteMsg)
			return # fixme

		self.loginBtn["disabled"] = True
		self.lock()

		NetworkService.request("user", "auth_userpassword/login",
		                        params={"name": self.username["value"],
		                                "password": self.password["value"]},
		                        secure=True,
		                        successHandler=self.doLoginSuccess,
		                        failureHandler=self.doLoginFailure)
Beispiel #26
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)
Beispiel #27
0
    def __init__(self,
                 module,
                 filter=None,
                 columns=None,
                 filterID=None,
                 filterDescr=None,
                 batchSize=None,
                 context=None,
                 autoload=True,
                 *args,
                 **kwargs):
        """
			:param module: Name of the module we shall handle. Must be a list application!
			:type module: str
		"""

        if not module in conf["modules"].keys():
            conf["mainWindow"].log(
                "error",
                translate("The module '{module}' does not exist.",
                          module=module))
            assert module in conf["modules"].keys()

        super(ListWidget, self).__init__()
        self.addClass("vi-widget vi-widget--list")
        self._batchSize = batchSize or conf[
            "batchSize"]  # How many rows do we fetch at once?
        self.isDetaching = False  #If set, this widget is beeing about to be removed - dont issue nextBatchNeeded requests
        self.module = module
        self.context = context

        self.loadedPages = 0  # Amount of Pages which are currently loaded
        self.currentPage = self.loadedPages  # last loaded page
        self.targetPage = 1  #the page which we want to show next if we set this to currentPage +1 and call setPage next page will be loaded

        #List actions
        self.actionBar = ActionBar(module, "list", currentAction="list")
        self.appendChild(self.actionBar)

        #Entry Actions
        self.entryActionBar = ActionBar(module, "list", currentAction="list")
        self.entryActionBar["class"] = ["bar", "vi-entryactionbar"]
        self.appendChild(self.entryActionBar)

        self.sideBar = SideBar()
        self.appendChild(self.sideBar)

        self.widgetContent = html5.Div()
        self.widgetContent.addClass("vi-widget-content")
        self.appendChild(self.widgetContent)

        myView = None

        if filterID:
            if conf["modules"] and module in conf["modules"].keys():
                if "views" in conf["modules"][module].keys(
                ) and conf["modules"][module]["views"]:
                    for v in conf["modules"][module]["views"]:
                        if v["__id"] == filterID:
                            myView = v
                            break
            if myView and "extendedFilters" in myView.keys(
            ) and myView["extendedFilters"]:

                #fixme
                #self.appendChild(CompoundFilter(myView, module, embed=True))
                logging.error("#fixme CompoundFilter")

        self._checkboxes = (conf["modules"]
                            and module in conf["modules"].keys()
                            and "checkboxSelection"
                            in conf["modules"][module].keys()
                            and conf["modules"][module]["checkboxSelection"])
        self._indexes = (conf["modules"] and module in conf["modules"].keys()
                         and "indexes" in conf["modules"][module].keys()
                         and conf["modules"][module]["indexes"])

        self._currentCursor = None
        self._structure = None
        self._currentRequests = []
        self.columns = []

        self.selectionMulti = True
        self.selectionAllow = None
        self.selectionCallback = None

        self.filter = filter.copy() if isinstance(filter, dict) else {}
        self.columns = columns[:] if isinstance(columns, list) else []
        self.filterID = filterID  #Hint for the sidebarwidgets which predefined filter is currently active
        self.filterDescr = filterDescr  #Human-readable description of the current filter
        self._tableHeaderIsValid = False

        #build Table
        self.tableInitialization(*args, **kwargs)
        self.selectionActivatedEvent = EventDispatcher("selectionActivated")

        self.actionBar.setActions(self.getActions(myView), widget=self)
        self.entryActionBar.setActions(self.getDefaultEntryActions(myView),
                                       widget=self)

        self.emptyNotificationDiv = html5.Div()
        svg = embedsvg.get("icons-error-file")
        if svg:
            self.emptyNotificationDiv.element.innerHTML = svg + self.emptyNotificationDiv.element.innerHTML

        self.emptyNotificationDiv.appendChild(
            html5.TextNode(translate("Currently no entries")))
        self.emptyNotificationDiv.addClass(
            "popup popup--center popup--local msg emptynotification")
        self.widgetContent.appendChild(self.emptyNotificationDiv)
        self.emptyNotificationDiv.removeClass("is-active")

        self.setTableActionBar()

        if autoload:
            self.reloadData()

        self.sinkEvent("onClick")
Beispiel #28
0
    def __init__(self, listWdg, *args, **kwargs):
        if not listWdg._structure:
            return

        super(SelectFieldsPopup,
              self).__init__(title=translate("Select fields"), *args, **kwargs)

        self.removeClass("popup--center")
        self.addClass("popup--n popup--selectfields")
        self.listWdg = listWdg
        self.checkboxes = []

        ul = html5.Ul()
        ul.addClass("option-group")
        self.popupBody.appendChild(ul)

        for key, bone in self.listWdg._structure:
            li = html5.Li()
            li.addClass("check")

            ul.appendChild(li)

            chkBox = html5.Input()
            chkBox.addClass("check-input")
            chkBox["type"] = "checkbox"
            chkBox["value"] = key

            li.appendChild(chkBox)
            self.checkboxes.append(chkBox)

            if key in self.listWdg.getFields():
                chkBox["checked"] = True
            lbl = html5.Label(bone["descr"], forElem=chkBox)
            lbl.addClass("check-label")
            li.appendChild(lbl)

        # Functions for Selection
        div = html5.Div()
        div["class"].append("selectiontools input-group")

        self.popupBody.appendChild(div)

        self.selectAllBtn = Button(translate("Select all"),
                                   callback=self.doSelectAll)
        self.selectAllBtn["class"].append("btn--selectall")
        self.unselectAllBtn = Button(translate("Unselect all"),
                                     callback=self.doUnselectAll)
        self.unselectAllBtn["class"].append("btn--unselectall")
        self.invertSelectionBtn = Button(translate("Invert selection"),
                                         callback=self.doInvertSelection)
        self.invertSelectionBtn["class"].append("btn--selectinvert")

        div.appendChild(self.selectAllBtn)
        div.appendChild(self.unselectAllBtn)
        div.appendChild(self.invertSelectionBtn)

        # Function for Commit
        self.cancelBtn = Button(translate("Cancel"), callback=self.doCancel)
        self.cancelBtn.addClass("btn btn--danger")

        self.applyBtn = Button(translate("Apply"), callback=self.doApply)
        self.applyBtn.addClass("btn btn--primary")

        self.popupFoot.appendChild(self.cancelBtn)
        self.popupFoot.appendChild(self.applyBtn)
Beispiel #29
0
    def setData(self, request=None, data=None, ignoreMissing=False):
        """
		Rebuilds the UI according to the skeleton received from server

		:param request: A finished NetworkService request
		:type request: NetworkService
		:type data: dict
		:param data: The data received
		"""
        assert (request or data)
        if request:
            data = NetworkService.decode(request)

        try:
            skelStructure = {k: v for k, v in data["structure"]}

        except AttributeError:
            NetworkService.notifyChange(self.module)
            conf["mainWindow"].removeWidget(self)
            return

        print
        print("data", data)
        print("action", data["action"])
        if "action" in data and (data["action"]
                                 in ["addSuccess", "editSuccess"]):
            NetworkService.notifyChange(self.module)
            logDiv = html5.Div()
            logDiv["class"].append("msg")
            spanMsg = html5.Span()
            spanMsg.appendChild(html5.TextNode(translate("Entry saved!")))
            spanMsg["class"].append("msgspan")
            logDiv.appendChild(spanMsg)
            if self.module in conf["modules"].keys():
                spanMsg = html5.Span()
                spanMsg.appendChild(
                    html5.TextNode(conf["modules"][self.module]["name"]))
                spanMsg["class"].append("modulspan")
                logDiv.appendChild(spanMsg)
            if "values" in data.keys() and "name" in data["values"].keys():
                spanMsg = html5.Span()
                spanMsg.appendChild(html5.TextNode(str(
                    data["values"]["name"])))
                spanMsg["class"].append("namespan")
                logDiv.appendChild(spanMsg)
            conf["mainWindow"].log("success", logDiv)
            if self.closeOnSuccess:
                conf["mainWindow"].removeWidget(self)
                return
            self.clear()
            # self.bones = {}
            self.reloadData()
            return

        self.clear()
        self.actionbar.resetLoadingState()
        self.dataCache = data

        fieldSets = {}
        cat = "byweek"

        fieldSets[cat] = EditWidgetFieldset(cat)
        fieldSets[cat].addClass("active")

        self.dtstart = data["values"]["startdate"]
        startdateLabel = html5.Label("Termin")
        startdateLabel["class"].append("termin")
        startdateLabel["class"].append("date")
        startdate_id = "vi_%s_%s_edit_bn_%s" % (self.editIdx, self.module,
                                                "repeatdate")
        startdateLabel["for"] = startdate_id
        startdate = date.DateViewBoneDelegate("termin", "startdate",
                                              skelStructure).render(
                                                  data["values"], "startdate")
        startdate["id"] = startdate_id
        containerDiv = html5.Div()
        containerDiv.appendChild(startdateLabel)
        containerDiv.appendChild(startdate)
        containerDiv["class"].append("bone")
        containerDiv["class"].append("bone_startdate")
        containerDiv["class"].append("date")
        fieldSets[cat]._section.appendChild(containerDiv)

        countLabel = html5.Label("Wiederholungen")
        countLabel["class"].append("count")
        countLabel["class"].append("numeric")
        count_id = "vi_%s_%s_edit_bn_%s" % (self.editIdx, self.module, "count")
        countLabel["for"] = count_id

        self.count = html5.Input()
        self.count["id"] = count_id
        containerDiv2 = html5.Div()
        containerDiv2["class"].append("bone")
        containerDiv2["class"].append("bone_count")
        containerDiv2["class"].append("date")
        containerDiv2.appendChild(countLabel)
        containerDiv2.appendChild(self.count)

        # containerDiv3 = html5.Div()
        # self.byweekday = list()
        # for key, value in [["MO", "Mo"], ["TU", "Di"], ["TH", "Mi"], ["WE", "Do"], ["FR", "Fr"], ["SA", "Sa"], ["SU", "So"]]:
        # 	alabel=html5.Label()
        # 	acheckbox=html5.Input()
        # 	acheckbox["type"]="checkbox"
        # 	acheckbox["name"]=key
        # 	alabel.appendChild(acheckbox)
        # 	aspan=html5.Span()
        # 	aspan.element.innerHTML=value
        # 	alabel.appendChild(aspan)
        # 	containerDiv3.appendChild(alabel)
        # 	containerDiv2["class"].append("bone")
        # 	containerDiv2["class"].append("bone_count")
        # 	containerDiv2["class"].append("byweekday")
        # 	self.byweekday.append(acheckbox)

        fieldSets[cat]._section.appendChild(containerDiv2)
        # fieldSets[ cat ]._section.appendChild(containerDiv3)
        for (k, v) in fieldSets.items():
            if not "active" in v["class"]:
                v["class"].append("active")
        tmpList = [(k, v) for (k, v) in fieldSets.items()]
        tmpList.sort(key=lambda x: x[0])
        for k, v in tmpList:
            self.form.appendChild(v)
            v._section = None
Beispiel #30
0
    def __init__(self, widget, *args, **kwargs):
        super(ExportCsvStarter, self).__init__(title=translate("CSV Export"))

        self.widget = widget

        if "viur.defaultlangsvalues" in conf["server"].keys():
            self.langSelect = html5.Select()
            self.langSelect.addClass("select")
            self.langSelect["id"] = "lang-select"

            lbl = html5.Label(translate("Language selection"))
            lbl.addClass("label")
            lbl["for"] = "lang-select"

            div = html5.Div()
            div.appendChild(lbl)
            div.appendChild(self.langSelect)
            div.addClass("input-group")

            self.popupBody.appendChild(div)

            for key, value in conf["server"]["viur.defaultlangsvalues"].items(
            ):
                opt = html5.Option()
                opt["value"] = key
                opt.appendChild(html5.TextNode(value))

                if key == conf["currentLanguage"]:
                    opt["selected"] = True

                self.langSelect.appendChild(opt)
        else:
            self.langSelect = None

        # Encoding
        self.encodingSelect = html5.Select()
        self.encodingSelect.addClass("select")
        self.encodingSelect["id"] = "encoding-select"

        lbl = html5.Label(translate("Encoding"))
        lbl.addClass("label")
        lbl["for"] = "encoding-select"

        div = html5.Div()
        div.appendChild(lbl)
        div.appendChild(self.encodingSelect)
        div.addClass("input-group")

        self.popupBody.appendChild(div)

        for i, (k, v) in enumerate([("iso-8859-15", "ISO-8859-15"),
                                    ("utf-8", "UTF-8")]):
            opt = html5.Option()
            opt["value"] = k

            if i == 0:
                opt["selected"] = True

            opt.appendChild(html5.TextNode(v))
            self.encodingSelect.appendChild(opt)

        self.cancelBtn = Button(translate("Cancel"),
                                self.close,
                                icon="icons-cancel")
        self.popupFoot.appendChild(self.cancelBtn)

        self.exportBtn = Button(translate("Export"),
                                self.onExportBtnClick,
                                icon="icons-download-file")
        self.exportBtn.addClass("btn--edit")
        self.popupFoot.appendChild(self.exportBtn)