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")
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")
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)
def __init__(self, file=None, size=150, *args, **kwargs): super(FilePreviewImage, self).__init__(*args, **kwargs) self.addClass("previewimg") self.sinkEvent("onClick") self.size = size self.downloadA = html5.A() self.downloadA.hide() self.appendChild(self.downloadA) self.isImage = False self.downloadOnly = False self.currentFile = None self.setFile(file)
def __init__(self, cat, title = None): super(EditWidgetFieldset, self).__init__() self.sinkEvent("onClick") self.addClass("inactive") self["name"] = cat legend = html5.Legend() self.appendChild(legend) self.title = html5.A() self.title.appendChild(html5.TextNode(title or cat)) legend.appendChild(self.title) section = html5.Section() self.appendChild(section) self._section = section
def __init__(self): super(Tasks, self).__init__() self.sinkEvent("onClick") self.hide() a = html5.A() a["class"].append("icon tasks") a.appendChild(html5.TextNode(translate("Tasks"))) self.appendChild(a) if not conf["tasks"]["server"]: NetworkService.request(None, "/vi/_tasks/list", successHandler=self.onTaskListAvailable, cacheable=False) self.update()
def __init__(self, descr=None, iconURL=None, iconClasses=None, closeable=False, collapseable=True, focusable=True, path=None): super(Pane, self).__init__() self.parentPane = None self.sinkEvent("onClick") self.groupPrefix = None 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["class"].append("has_no_child") self.childDomElem = None self.img = None self.label = html5.A() self.label["class"].append("button") self.appendChild(self.label) self.closeBtn = html5.ext.Button(translate("Close"), self.onBtnCloseReleased) self.closeBtn.addClass("closebtn") self.appendChild(self.closeBtn) if not closeable: self.closeBtn.hide() self.closeable = closeable self.isExpanded = False self.defaultImgSrc = self.iconURL DeferredCall(self.setText, _delay=250)
def getViewElement(self, labelstr, datafield): # check if rendering of EmailBones is wanted as String if ("params" in self.skelStructure[self.boneName].keys() and isinstance(self.skelStructure[self.boneName]["params"], dict) and self.skelStructure[self.boneName]["params"].get( "renderAsString")): return super(EmailViewBoneDelegate, self).getViewElement(labelstr, datafield) aa = html5.A() aa["href"] = "mailto:" + labelstr aa["target"] = "_Blank" aa.appendChild(html5.TextNode(labelstr)) if not datafield: aa["title"] = "open mailclient" else: aa["title"] = "open mailclient" + str(datafield) return (aa)
def exportToFile(self): if not self.data: self.replaceWithMessage(translate("No datasets to export."), logClass="info") return assert self.structure defaultLanguage = conf["currentlanguage"] conf["currentlanguage"] = self.lang # Visualize progress self["max"] = len(self.data) self["value"] = 0 cellRenderer = {} struct = {k: v for k, v in self.structure} fields = {} titles = [] print("H1") idx = 0 for key, bone in self.structure: print(key, bone) #if bone["visible"] and ("params" not in bone or bone["params"] is None or "ignoreForCsvExport" not in bone[ # "params"] or not bone["params"]["ignoreForCsvExport"]): if bone["visible"]: cellRenderer[key] = extractorDelegateSelector.select( self.module, key, struct) if cellRenderer[key]: cellRenderer[key] = cellRenderer[key](self.module, key, struct) fields[key] = idx idx += 1 titles.append(bone.get("descr", key) or key) print("H2") # Export content = self.separator.join(titles) + self.lineSeparator for entry in self.data: row = [None for _ in range(len(fields.keys()))] for key, value in entry.items(): print(key, value) if key not in fields or value is None or str( value).lower() == "none": continue try: if cellRenderer[key] is not None: row[fields[key]] = cellRenderer[key].render(entry, key) else: row[fields[key]] = str(value) except ValueError: pass content += self.separator.join(row) + self.lineSeparator self["value"] += 1 # Virtual File conf["currentlanguage"] = defaultLanguage a = html5.A() a.hide() self.appendChild(a) if self.encoding == "utf-8": encodeURIComponent = eval("encodeURIComponent") a["href"] = "data:text/csv;charset=utf-8," + encodeURIComponent( content) elif self.encoding == "iso-8859-15": escape = eval("escape") a["href"] = "data:text/csv;charset=ISO-8859-15," + escape(content) else: raise ValueError("unknown encoding: %s" % self.encoding) filename = "export-%s-%s-%s-%s.csv" % ( self.module, self.lang, self.encoding, datetime.datetime.now().strftime("%Y-%m-%d")) a["download"] = filename a.element.click() self.replaceWithMessage( translate("{count} datasets exported\nas {filename}", count=len(self.data), filename=filename)) self.data = None self.structure = None
def doDownload(self, fileData): a = html5.A() a["href"] = "/file/download/%s/%s?download=1" % (fileData["dlkey"], fileData["name"]) a.element.click()