def languagespage_render(): items = [] for item in sorted(this.state.data, key=lambda x: x['name'].lower()): items.append( e(ui.Card, e(ui.Card.Content, e(ui.Card.Description, item['name'])), centered=True, link=True, className="default-card", key=item.id)) return e( SimpleLayout, e(TitleChange, title=tr(this, "ui.mi-dir-languages", "Languages")), e( ui.Card.Group, items, itemsPerRow=1, doubling=True, stackable=True, as_=ui.Transition.Group, animation="scale", duration=500, ), loading=this.state.data_loading, )
def datelbl_render(): if this.props.timestamp: full = utils.moment.unix(this.props.timestamp).format(this.props.format or "LL") relative = utils.moment.unix(this.props.timestamp).fromNow() if this.props.full: date = full + " ({})".format(relative) elif this.state.toggled: date = full else: date = relative else: date = tr(this, "ui.t-unknown", "Unknown") items = [] if this.props.children: items.append(this.props.children) items.append(e(ui.Label.Detail, date)) else: items.append(date) return e(ui.Label, *items, onClick=this.toggle, as_="a")
def parodylbl_render(): name = "" data = this.props.data or this.state.data if data: if data.preferred_name: name = data.preferred_name.js_name lbl_args = {'content': name} return e(ui.Popup, e(parodypropsview.ParodyProps, data=data), trigger=e( ui.Label, basic=True, color="violet", as_="a", **lbl_args, ), hoverable=True, wide="very", on="click", hideOnScroll=True, position="top center")
def createpage_render(): item_type = { 'gallery': ItemType.Gallery, 'collection': ItemType.Collection }.get(this.props.match.params.item_type.lower(), ItemType.Gallery) if item_type == ItemType.Gallery: el = e(CreateGallery, config=this.state.config, set_config=this.set_config) elif item_type == ItemType.Collection: el = e(CreateCollection, config=this.state.config, set_config=this.set_config) return e( ui.Container, e(ui.Container, e( ui.Button.Group, e( ui.Button, tr(this, "general.db-item-gallery", "Gallery"), value=ItemType.Gallery, active=item_type == ItemType.Gallery, primary=item_type == ItemType.Gallery, as_=Link, to="/manage/new/gallery", ), e(ui.Button.Or, text=tr(this, "ui.t-or", "Or")), e( ui.Button, tr(this, "general.db-item-collection", "Collection"), disabled=True, value=ItemType.Collection, active=item_type == ItemType.Collection, primary=item_type == ItemType.Collection, as_=Link, to="/manage/new/collection", ), toggle=True, ), textAlign="center"), e(ui.Divider, hidden=True), el)
def grouping_render(): title = "" item_id = this.state.id if this.state.data: title = this.state.data.js_name if not item_id: item_id = this.state.data.id artists = [] for a in this.state.artists: if len(a.names) > 0: artists.append(a.names[0].js_name) artist_el = [h("span", x) for x in artists] return e(ui.Segment, e(ui.Card, h("div", e(thumbitem.Thumbnail, item_id=item_id, item_type=this.state.item_type, size_type=ImageSize.Medium), #e(ui.Label, e(ui.Icon, js_name="star half empty"), avg_rating, className="card-item bottom left", circular=True, size="large", color="orange"), e(ui.Icon, js_name="ellipsis vertical", bordered=True, className="card-item bottom right", link=True, inverted=True), e(ui.Label, e(ui.Icon, js_name="block layout"), len( this.state.galleries), className="card-item top right",), className="card-content", ), e(ui.Popup, trigger=e(ui.Card.Content, e(ui.Card.Header, title, className="text-ellipsis card-header"), e(ui.Card.Meta, *artist_el, className="text-ellipsis"),), header=title, content=h("div", *artist_el), hideOnScroll=True, position="bottom center" ), link=True), stacked=True, className="no-padding-segment", )
def page_render(): #fav = 0 title = "" item_id = this.state.id gallery_id = 0 number = 0 if this.state.data: title = str(this.state.data.number) number = this.state.data.number # if this.state.data.metatags.favorite: # fav = 1 if not item_id: item_id = this.state.data.id gallery_id = this.state.data.gallery_id add_cls = this.props.className or "" page_url = '/item/gallery/{}/page/{}'.format(gallery_id, number) link = True if not this.props.link == js_undefined: link = this.props.link thumb_kwargs = {} if this.props.onClick: thumb_kwargs['onClick'] = this.on_click if this.props.external_viewer: thumb_kwargs['onClick'] = this.open_external thumb = e(thumbitem.Thumbnail, item_id=item_id, item_type=this.state.item_type, size_type=this.props.size_type if this.props.size_type else ImageSize.Medium, centered=True, blur=this.props.blur, size=this.props.size, kwargs=thumb_kwargs, ) if link: if not this.props.external_viewer: thumb = e(Link, thumb, to={'pathname': page_url, }) return e(ui.Card, h("div", thumb, e(ui.Icon, js_name="ellipsis vertical", bordered=True, className="card-item bottom right", link=True, inverted=True), className="card-content", ), e(ui.Card.Content, e(ui.Card.Header, e(ui.Label, title, circular=True), className="text-ellipsis card-header")), className=add_cls, centered=this.props.centered, link=True)
def edittext_render(): el = None if this.state.edit_mode and this.props.edit_mode: el = e(this.props.as_ or ui.Input, defaultValue=this.state.data or this.props.data, onChange=this.on_change, onKeyPress=this.on_key if not this.props.as_ == ui.TextArea else js_undefined, size=this.props.size or "tiny", fluid=this.props.fluid) el = h('div', el, e(ui.Button, tr(this, "ui.t-submit", "submit"), onClick=this.on_submit, positive=True, size="mini", floated="right") if this.props.as_ == ui.TextArea else None, ) else: edit_el = [] if this.props.edit_mode: edit_el.append(h("span", e(ui.Icon, js_name="pencil alternate", link=True, onClick=this.on_click))) el = h("div", this.state.data, *edit_el, className="editable" if this.props.edit_mode else "") return el
def language_render(): data = this.props.data or this.state.data el = None if data.id and not data.js_name: data = utils.lodash_find(this.state.all_data, lambda v, i, c: v['id'] == data.id) or data lang_name = data.js_name or tr(this, "ui.t-unknown", "Unknown") if this.state.edit_mode: options = [] for i in this.state.all_data: options.append({'key': i.id or i.js_name, 'value': i.id or i.js_name, 'text': i.js_name}) el = e(ui.Select, options=options, placeholder=tr(this, "ui.t-language", "Language"), defaultValue=data.id, size=this.props.size, basic=this.props.basic, compact=this.props.compact, as_=this.props.as_, onChange=this.on_update, loading=this.state.loading, onBlur=this.on_blur, allowAdditions=True, search=True, additionLabel=tr(this, "ui.t-add", "add") + ' ' ) elif data: el = e(ui.Label, lang_name, size=this.props.size, basic=this.props.basic, className=this.props.className, onClick=this.on_click if this.props.edit_mode else js_undefined, onRemove=this.on_remove if this.props.edit_mode else js_undefined, as_=this.props.as_ if utils.defined(this.props.as_) else "a" if this.props.edit_mode else js_undefined) return el
def viewdropdown_render(): item_options = [ { 'text': tr(this, "ui.mi-all", "All"), 'value': ViewType.All, }, { 'text': tr(this, "ui.mi-library", "Library"), 'value': ViewType.Library, }, { 'text': tr(this, "ui.mi-inbox", "Inbox"), 'value': ViewType.Inbox, }, ] if this.props.view_type == ViewType.Favorite: item_options = [ { 'text': tr(this, "ui.mi-favorites", "Favorites"), 'value': this.props.view_type, }, ] elif this.props.view_type != None: # noqa: E711 for x in item_options: if x['value'] == this.props.view_type: item_options = [x] break return e( ui.Dropdown, options=item_options, value=this.props.value, defaultValue=this.props.defaultValue, onChange=this.item_change, selectOnBlur=False, pointing=this.props.pointing, labeled=this.props.labeled, inline=this.props.inline, compact=this.props.compact, button=this.props.button, item=this.props.item, selection=this.props.selection, basic=this.props.basic, className=this.props.className, disabled=True if this.props.view_type != None else js_undefined, # noqa: E711 icon=None if this.props.view_type else js_undefined)
def itemviewpage_render(): return e( itemview.ItemView, history=this.props.history, location=this.props.location, item_type=this.state.item_type, view_filter=this.state.view_type, search_query=this.state.search_query, filter_id=this.state.filter_id, search_options=this.state.search_options, sort_by=this.state.sort_idx, sort_desc=this.state.sort_desc, toggle_config=this.toggle_config, visible_config=this.state.visible_config, config_suffix=this.config_suffix, ),
def Notif(props): return h( "div", h( "div", e( ui.Message, header=props.customFields.header, content=props.customFields.content, onDismiss=props.handleClose, **props.customFields.mskwargs, ), className="s-alert-box-inner", ), className=props.classNames, id=props.id, style=props.styles, )
def urls_render(): data = this.props.data or this.state.data els = [] if data: for n, u in enumerate(data): if this.props.edit_mode: u_el = e(EditText, defaultValue=u.js_name, defaultOpen=not bool(u.js_name), edit_mode=this.props.edit_mode, update_data=this.on_update, data_id=n, fluid=True) else: u_el = h("a", u.js_name, href=u.js_name, target="_blank") els.append(e(ui.List.Item, e(ui.List.Icon, js_name="external share") if not this.props.edit_mode else e(ui.List.Icon, js_name="remove", onClick=this.on_remove, link=True, **{'data-id': n}), e(ui.List.Content, u_el, className="fullwidth", ), key=n + u.js_name) ) if this.props.edit_mode: els.append(e(ui.List.Item, e(ui.List.Icon, js_name="plus", onClick=this.on_create_item, color="green", link=True), key="new") ) return e(ui.List, this.props.children if this.props.children else els, size=this.props.size, relaxed=this.props.relaxed, className=this.props.className, as_=this.props.as_)
'componentDidMount': lambda: all((this.get_config(cfg={ 'gallery.add_to_inbox': True, }), )), 'render': createpage_render }) Page = createReactClass({ 'displayName': 'ManagePage', 'componentWillMount': lambda: this.props.menu([ e(ui.Menu.Item, js_name=tr(this, "ui.b-new", "New"), as_=NavLink, to="/manage/new", activeClassName="active"), e(ui.Menu.Item, js_name=tr(this, "ui.mi-scan", "Scan"), as_=NavLink, to="/manage/scan", activeClassName="active"), ], pointing=True), 'getInitialState': lambda: {}, 'render': lambda: e( ui.Segment, e(
def page_render(): return [e(TitleChange, title=tr(this, "ui.mi-browse", "Browse"), key=1), e(pages.ItemViewPage, history=this.props.history, location=this.props.location, key=2)]
def app_render(): if this.state.logged_in: sidebar_args = { 'location': this.props.location, 'toggler': this.toggle_sidebar, 'toggled': this.state["sidebar_toggled"], } menu_args = { 'location': this.props.location, 'toggler': this.toggle_sidebar, 'contents': this.state["menu_nav_contents"], 'menu_args': this.state["menu_nav_args"] } server_push_close = this.server_push_close server_push_actions_el = [] if dict(this.state.server_push_msg).get("actions", False): server_push_actions = [] push_id = this.state.server_push_msg['id'] for a in this.state.server_push_msg['actions']: a_id = a['id'] if a['type'] == 'button': server_push_actions.append( e(ui.Button, a['text'], value=a_id, onClick=lambda ev, da: all(( server_notifications_reply(msg_id=push_id, values={da.value: da.value}), server_push_close())))) server_push_actions_el.append(e(ui.Modal.Actions, *server_push_actions)) modal_els = [] server_push_msg = dict(this.state.server_push_msg) push_body = server_push_msg.get("body", '') if server_push_msg['id'] in (PushID.Update,): push_body = tr(None, "ui.t-changelog-location", "About -> Changelog") + '\n' + push_body modal_els.append(e(ui.Modal, e(ui.Modal.Header, server_push_msg.get("title", '')), e(ui.Modal.Content, push_body, style={"whiteSpace": "pre-wrap"}), *server_push_actions_el, onClose=this.server_push_close, open=this.state.server_push, dimmer="inverted", closeIcon=True) ) api_route = [] if this.state.debug: api_route.append(e(Route, path="/api", component=this.api_page)) el = h("div", e(ui.Responsive, #e(ConnectStatus, context=this.state.root_ref), e(sidebar.SideBar, **sidebar_args), minWidth=767), e(ui.Responsive, e(sidebar.SideBar, mobile=True, **sidebar_args), maxWidth=768), e(Route, component=PathChange), e(ui.Ref, e(ui.Sidebar.Pusher, e(ui.Visibility, e(ui.Responsive, e(menu.Menu, **menu_args), minWidth=767), e(ui.Responsive, e(menu.Menu, mobile=True, **menu_args), maxWidth=768), onBottomPassed=this.toggle_scroll_up, once=False, ), e(Switch, *api_route, e(Route, path="/manage", component=this.manage_page), e(Route, path="/dashboard", component=this.dashboard_page), e(Route, path="/library", component=this.library_page), e(Route, path="/favorite", component=this.favorites_page), e(Route, path="/directory", component=this.directory_page), e(Route, path="/activity", component=this.activity_page), e(Route, path="/item/gallery/:gallery_id(\d+)/page/:page_number(\d+)", component=this.page_page), e(Route, path="/item/gallery/:item_id(\d+)", component=this.gallery_page), e(Route, path="/item/collection/:item_id(\d+)", component=this.collection_page), e(Redirect, js_from="/", exact=True, to={'pathname': "/library"}), ), # e(ui.Sticky, # e(ui.Button, icon="chevron up", size="large", floated="right"), # bottomOffset=55, # context=this.state.container_ref, # className="foreground-sticky"), e(ui.Dimmer, simple=True, onClickOutside=this.toggle_sidebar), *modal_els, dimmed=this.state.sidebar_toggled, as_=ui.Dimmer.Dimmable, className="min-fullheight", ), innerRef=this.get_context_ref, ), key="1", ), elif not utils.defined(this.state.logged_in): el = e(ui.Segment, e(ui.Dimmer, e(ui.Loader), active=True), basic=True, className="fullheight", key="1", ) else: el = e(login.Page, on_login=this.on_login, key="1"), alert_el = e(Alert, contentTemplate=Notif, stack={'limit': 6, 'spacing': 20}, position="top-right", effect="slide", offset=50, preserveContext=True, key="2", ) return [e(TitleChange), el, ReactDOM.createPortal(alert_el, this.state.portal_el)]
'close_preview_msg': lambda: all((this.setState({'preview_msg': False}), utils.storage.set("preview_msg", False))), 'server_notifications': server_notifications, 'server_push_close': lambda: this.setState({'server_push': False}), 'on_login': lambda s: this.setState({'logged_in': s}), 'toggle_sidebar': lambda: (this.setState({'sidebar_toggled': not this.state['sidebar_toggled']})), 'set_menu_contents': app_menu_contents, 'get_context_ref': get_container_ref, 'get_root_ref': lambda c: this.setState({'root_ref': c}), 'api_page': lambda p: e(api.Page, menu=this.set_menu_contents, **p), 'dashboard_page': lambda p: e(dashboard.Page, menu=this.set_menu_contents, **p), 'library_page': lambda p: e(library.Page, menu=this.set_menu_contents, **p), 'favorites_page': lambda p: e(favorites.Page, menu=this.set_menu_contents, **p), 'page_page': lambda p: e(page.Page, menu=this.set_menu_contents, **p), 'gallery_page': lambda p: e(gallery.Page, menu=this.set_menu_contents, **p), 'collection_page': lambda p: e(collection.Page, menu=this.set_menu_contents, **p), 'directory_page': lambda p: e(directory.Page, menu=this.set_menu_contents, **p), 'activity_page': lambda p: e(activity.Page, menu=this.set_menu_contents, **p), 'manage_page': lambda p: e(manage.Page, menu=this.set_menu_contents, **p), 'render': app_render, }) vkeys = utils.visibility_keys()
def sidebar_nav_render(): if this.props.mobile: nav_width = "very thin" else: nav_width = "thin" icon = False if nav_width == "very thin": icon = True def nav_toggle_handler(e, props): print(props) items = [] items.append( MenuItem("", position="left", handler=this.props["toggler"], content=e(ui.Icon, className="hpx-alternative huge left"))) items.append( MenuItem("Manage", "ui.mi-manage", icon="plus square outline", url="/manage", position="left", handler=this.props["toggler"])) #items.append(MenuItem("Dashboard", "ui.mi-dashboard", icon="home", url="/dashboard", handler=this.props["toggler"])) items.append( MenuItem("Favorites", "ui.mi-favorites", icon="heart", url="/favorite", handler=this.props["toggler"])) items.append( MenuItem("Library", "ui.mi-browse", icon="grid layout", url="/library", handler=this.props["toggler"])) items.append( MenuItem("directory", "ui.mi-directory", icon="cubes", url="/directory", handler=this.props["toggler"])) # Note: Artists, Tags, Etc. Able to favorite artists and tags items.append( MenuItem("Activity", "ui.mi-activity", icon="tasks", url="/activity", handler=this.props["toggler"])) pref_item = MenuItem("Preferences", "ui.mi-preferences", modal=[ e( ui.Modal.Content, e(ui.Header, icon="settings", content=tr(this, "ui.mi-preferences", "Preferences")), e(preferences.PrefTab), ), ], icon="settings", position="right", handler=this.props["toggler"]) items.append(pref_item) about_item = MenuItem("About", "ui.mi-about", modal=[ e( ui.Modal.Content, e(ui.Header, icon="info", content=tr(this, "ui.mi-about", "About")), e(about.AboutTab), ) ], icon="info", position="right", handler=this.props["toggler"]) items.append(about_item) elements = [] elements_left = [] elements_right = [] for n, x in enumerate(items, 1): menu_name = x.name menu_icon = x.icon icon_size = "large" if icon: menu_name = "" if x.position == "right": container = elements_right elif x.position == "left": container = elements_left else: container = elements content = tr(this, x.t_id, menu_name) if x.content is None else x.content item_children = [] if menu_icon: item_children.append( e(ui.Icon, js_name=menu_icon, className="left", size=icon_size)) item_children.append(content if not icon else "") as_link = {} if x.url: as_link = {"as": NavLink, "to": x.url, "activeClassName": "active"} menu_el = e(ui.Menu.Item, *item_children, js_name=menu_name, header=x.header, onClick=x.handler, index=n, icon=not menu_name, **as_link) if x.modal: menu_el = e(ui.Modal, *x.modal, trigger=menu_el, dimmer="inverted", closeIcon=True, onClose=x.on_modal_close, onOpen=x.on_modal_open, centered=False, className="min-400-h") container.append(menu_el) cnt_el = h("div", h("div", *elements_left, className="top-aligned"), h("div", *elements, className="middle-aligned"), h("div", *elements_right, className="bottom-aligned"), className="flex-container") el_args = { 'as': ui.Menu, 'animation': "overlay", 'width': nav_width, 'vertical': True, 'visible': this.props.toggled, 'icon': icon, 'defaultActiveIndex': 3, 'size': "small", 'className': "window-height", 'inverted': True } if this.props.mobile: el_args['direction'] = "right" return e(ui.Sidebar, cnt_el, **el_args)
{ 'displayName': 'ToggleIcon', 'getInitialState': lambda: { 'toggled': this.props.toggled }, 'toggle': lambda: all((this.setState({'toggled': not this.state.toggled}), this.props.on_toggle(not this.state.toggled) if this.props.on_toggle else None)), 'render': lambda: e( ui.Icon, this.props.children, js_name=this.props.icons[int(this.state.toggled) if this.props.icons else ""], onClick=this.toggle, link=True, ) }, pure=True) def connectstatus_render(): return e(ui.Sticky, e(ui.Icon, js_name="circle notched", loading=True, size="big", color="grey", circular=True,
def createcollection_render(): return e( "div", e(TitleChange, title=tr(this, "ui.t-create-collection", "Create a collection")), )
def menu_nav_render(): icon_size = "large" items = [] items.append(MenuItem("", position="left", header=True, handler=this.props["toggler"], content=e(ui.Icon, className="hpx-standard huge"))) elements = [] elements_left = [] elements_right = [] for n, x in enumerate(items, 1): menu_name = x.name menu_icon = x.icon if x.position == "right": container = elements_right elif x.position == "left": container = elements_left else: container = elements children = [] for c in x.children: children.append(e(ui.Dropdown.Item, c.name)) content = menu_name if x.content is None else x.content icon_el = [] if menu_icon: icon_el.append(e(ui.Icon, js_name=menu_icon, size=icon_size)) container.append(e(ui.Menu.Item, *icon_el, content, js_name=menu_name if x.content is None else None, header=x.header, onClick=x.handler, index=n, icon=not menu_name, ) ) menu_contents = this.props.contents if not isinstance(menu_contents, list): menu_contents = [menu_contents] if defined(this.props.menu_args): menu_args = this.props.menu_args else: menu_args = {} el = e(ui.Menu, *elements_left, *elements, *menu_contents, *elements_right, secondary=True, borderless=True, stackable=True, size="tiny", **menu_args ) return el
def selector_render(): data = this.props.data or this.state.data selected = this.state.selected on_remove = this.on_item_remove top_el = e( ui.Grid, e( ui.Grid.Row, e( ui.Grid.Column, e(ui.Button, tr(this, "ui.t-select", "select"), onClick=this.on_submit, floated="right", size="small", primary=True) if len(selected) else None, e(ui.Input, label={ 'as': 'a', 'basic': True, 'content': tr(this, "ui.b-new", "New"), 'onClick': this.on_new_item } if this.state.search_query else js_undefined, size="mini", value=this.state.search_query, icon='search', fluid=True, onChange=this.update_search), ), ), e( ui.Grid.Row, e( ui.Grid.Column, e(ui.Label.Group, [ e(circleitem.CircleLabel, data=a, key=a.id or utils.get_object_value('name', a) or utils.get_object_value('name', a), showRemove=True, onRemove=on_remove) for a in selected ])))) selected_ids = [a.id for a in selected] if this.props.defaultSelected: defaultSelected = this.props.defaultSelected selected_ids.extend([a.id for a in defaultSelected]) a_els = [] if data: for a in data: a_els.append( e( circleitem.CircleItem, data=a, active=a.id in selected_ids, key=a.id, selection=True, onClick=this.on_item, )) if len(a_els): a_els.append( e( ui.Segment, e( ui.Visibility, context=this.state.context_el, onTopVisible=this.get_more, once=False, fireOnMount=True, ), key="inf", basic=True, loading=this.state.loading_more, )) els = e(ui.List, a_els, divided=True, relaxed=True, selection=True, link=True, size=this.props.size if this.props.size else "small", className="max-400-h min-300-h " + this.props.className if this.props.className else "max-600-h min-500-h", verticalAlign="middle") return e( ui.Segment, top_el, e( ui.Ref, els, innerRef=this.get_context_el, ), basic=True, loading=this.state.loading, )
def get_item(data=None, error=None): if data is not None and not error: this.setState({"data": data, "loading": False, }) if data.metatags.favorite: this.setState({"fav": 1}) if data.category_id: client.call_func("get_item", this.get_category, item_type=ItemType.Category, item_id=data.category_id) if data.id: client.call_func("get_related_count", this.get_gallery_count, related_type=ItemType.Gallery, item_type=this.state.item_type, item_id=data.id) if data.id: inbox = data.metatags.inbox trash = data.metatags.trash menu_items = [] menu_left = [] min_width = 768 if inbox: menu_left.append(e(ui.Responsive, e(ui.Button, e(ui.Icon, js_name="grid layout"), tr(this, "ui.b-send-library", "Send to Library"), color="green", basic=True), as_=ui.Menu.Item, minWidth=min_width, )) menu_items.append(e(ui.Menu.Menu, *menu_left)) menu_right = [] menu_right.append( e(ui.Responsive, e(ui.Button, e(ui.Icon, js_name="trash" if not trash else "reply"), tr(this, "ui.b-send-trash", "Send to Trash") if not trash else tr(this, "ui.b-restore", "Restore"), color="red" if not trash else "teal", basic=True), as_=ui.Menu.Item, minWidth=min_width, )) if trash: menu_right.append( e(ui.Responsive, e(ui.Button.Group, e(ui.Button, e(ui.Icon, js_name="close"), tr(this, "ui.b-delete", "Delete"), color="red"), e(ui.Button, icon="remove circle outline", toggle=True, active=this.state.delete_files, title=tr(this, "ui.t-delete-files", "Delete files")), e(ui.Button, icon="recycle", toggle=True, active=this.state.send_to_recycle, title=tr(this, "ui.t-send-recycle-bin", "Send files to Recycle Bin")), basic=True, ), as_=ui.Menu.Item, minWidth=min_width, )) menu_right.append(e(ui.Responsive, e(ui.Button, e(ui.Icon, js_name="edit"), tr(this, "ui.b-edit", "Edit"), basic=True), as_=ui.Menu.Item, minWidth=min_width, )) menu_items.append(e(ui.Menu.Menu, *menu_right, position="right")) if len(menu_items): this.props.menu(menu_items) elif error: state.app.notif("Failed to fetch item ({})".format(this.state.id), level="error") else: if utils.defined(this.props.location): if this.props.location.state and this.props.location.state.collection: if int(this.props.match.params.item_id) == this.props.location.state.collection.id: this.get_item(this.props.location.state.collection) return item = this.state.item_type item_id = this.state.id if item and item_id: client.call_func("get_item", this.get_item, item_type=item, item_id=item_id) this.setState({'loading': True})
def pagination_render(): limit = this.props.limit if not limit: limit = 6 pages = this.props.pages if not pages or pages < 1: pages = 1 current_page = this.props.current_page or this.state.current_page if this.props.history and this.props.query and not current_page: current_page = utils.get_query("page", this.state.current_page) if not current_page: current_page = 1 current_page = int(current_page) pages = math.ceil(pages) page_list = range(1, pages + 1) ellipsis_pos = 2 if limit > 2 else 1 nav_back = True nav_next = True first_ellipses = False second_ellipses = False if current_page - 1 == 0: nav_back = False if current_page == len(page_list): nav_next = False if limit and current_page > limit and current_page > ellipsis_pos: first_ellipses = True if (pages - current_page) > limit and pages > ellipsis_pos: second_ellipses = True go_next = this.go_next go_prev = this.go_prev go_page = this.go_page half_limit = int(limit / 2) l_index = current_page - (half_limit if half_limit else 1) r_index = current_page + half_limit + 1 if r_index > len(page_list): r_index = len(page_list) l_index = len(page_list) - (limit + 1) if l_index < 0: l_index = 0 r_index = limit current_pages = page_list[l_index:r_index] if this.props.query: def make_items(i): return [ e( ui.Menu.Item, js_name=str(x), active=current_page == x, onClick=go_page, # noqa: E704 as_=QueryLink, query={'page': x}) for x in i ] # noqa: E704 else: def make_items(i): return [ e( ui.Menu.Item, js_name=str( # noqa: E704 x), active=current_page == x, onClick=go_page) for x in i ] # noqa: E704 items = make_items(current_pages) query_args = {} if this.props.query: query_args = { 'as': QueryLink, 'query': { 'page': this.state.go_to_page } } go_el = e(ui.Popup, e(ui.Form, e( ui.Form.Field, e(ui.Input, onChange=this.go_to_change, size="mini", js_type="number", placeholder=current_page, action=e(ui.Button, js_type="submit", compact=True, icon="share", onClick=this.go_to_page, **query_args), min=0, max=pages), ), onSubmit=this.go_to_page), on="click", hoverable=True, position="top center", trigger=e(ui.Menu.Item, "...")) if first_ellipses: ellip_items = make_items(page_list[:ellipsis_pos]) ellip_items.append(go_el) ellip_items.extend(items) items = ellip_items if second_ellipses: items.append(go_el) items.extend(make_items(page_list[-ellipsis_pos:])) if nav_back: if this.props.query: items.insert( 0, e(ui.Menu.Item, icon="angle left", onClick=go_prev, as_=QueryLink, query={'page': current_page - 1})) else: items.insert(0, e(ui.Menu.Item, icon="angle left", onClick=go_prev)) if nav_next: if this.props.query: items.append( e(ui.Menu.Item, icon="angle right", onClick=go_next, as_=QueryLink, query={'page': current_page + 1})) else: items.append(e(ui.Menu.Item, icon="angle right", onClick=go_next)) return e( ui.Menu, *items, pagination=True, borderless=True, size=this.props.size if utils.defined(this.props.size) else "small", as_=ui.Transition.Group, duration=1000, )
def Error(props): return e(ui.Message, header=props.header, content=props.content, error=True)
def scanpage_render(): view_data = this.state.view_data progress_text = "" title = "" percent = 0 if this.state.progress_data: p = this.state.progress_data progress_text = p.text title = p.title percent = p.percent pages_el = [] count_el = [] if not this.state.loading and view_data: if view_data['count'] > this.state.limit: pages_el.append( e(ui.Grid.Row, e( ui.Responsive, e(Pagination, limit=1, pages=view_data['count'] / this.state.limit, current_page=this.state.page, on_change=this.set_page, query=True, scroll_top=True, size="tiny"), maxWidth=578, ), e( ui.Responsive, e(Pagination, pages=view_data['count'] / this.state.limit, current_page=this.state.page, on_change=this.set_page, query=True, scroll_top=True), minWidth=579, ), centered=True), ) count_el.append( e( ui.Grid.Row, e(ui.Grid.Column, e( ui.Header, e(ui.Header.Subheader, tr(this, "ui.t-showing-count", "Showing {}".format(view_data['count']), placeholder={ 'from': (this.state.page - 1) * this.state.limit + 1, 'to': (this.state.page - 1) * this.state.limit + len(view_data['items']), 'all': view_data['count'] }), as_="h6"), ), textAlign="center", width=16))) items = [] view_progress_data = this.state.view_progress_data view_progress_el = [] submitted_view_data = view_progress_data if submitted_view_data: p_kwargs = {} p_kwargs['progress'] = 'value' if view_progress_data['max']: p_kwargs['value'] = view_progress_data['value'] p_kwargs['total'] = view_progress_data['max'] p_kwargs['autoSuccess'] = True else: p_kwargs['percent'] = 1 p_kwargs['autoSuccess'] = False view_progress_el.append( e(ui.Segment, e(ui.Progress, precision=2, indicating=True, active=True, **p_kwargs), basic=True)) if not this.state.loading and view_data: for t in this.state.view_data['items']: all_circles = [] [all_circles.extend(a.circles) for a in t.gallery.artists] circles = [] circle_names = [] for c in all_circles: if c.js_name not in circle_names: circles.append(c) circle_names.append(c.js_name) items.append( e( ui.List.Item, e( ui.List.Content, *(e(ui.Header, x, className="sub-text", as_="h5") for x in t.sources), e( ui.List.Description, e(ui.List, [ e( ui.List.Item, e(ui.Header, x.js_name, size="tiny"), ) for x in t.gallery.titles ], size="tiny", relaxed=True, bulleted=True), e(ui.Divider, hidden=True), e( ui.List, e( ui.List.Item, h("span", tr(this, "ui.t-artist", "Artist") + ':', size="tiny", className="sub-text"), *(e(artistitem.ArtistLabel, data=x) for x in t.gallery.artists)), e( ui.List.Item, h("span", tr(this, "ui.t-circle", "Circle") + ':', size="tiny", className="sub-text"), *((e(circleitem.CircleLabel, data=x) for x in circles)) if circles else []), e( ui.List.Item, h("span", tr(this, "general.db-item-collection", "Collection") + ':', size="tiny", className="sub-text"), *(e(ui.Label, x.js_name) for x in t.gallery.collections)), e( ui.List.Item, h("span", tr(this, "ui.t-language", "Language") + ':', size="tiny", className="sub-text"), *([ e(ui.Label, t.gallery.language.js_name) ] if t.gallery.language else [])), e( ui.List.Item, h("span", tr(this, "ui.t-pages", "Pages") + ': ', size="tiny", className="sub-text"), t.page_count), horizontal=True, relaxed=True, divided=True, ), *((e(ui.Label, e(ui.Icon, js_name="checkmark"), tr(this, "ui.t-metadata-file", "Metadata file"), title=tr(this, "ui.t-metadata-from-file", "Metadata was retrieved from file"), color="green", basic=True, className="right", size="small"), ) if t.metadata_from_file else []), e(ui.Divider, hidden=True, clearing=True), )), ), ) options_el = e( ui.Segment, e( ui.Form, e( ui.Form.Group, e( ui.Form.Checkbox, toggle=True, label=tr(this, "ui.t-add-to-inbox", "Add to inbox"), checked=this.state['gallery.add_to_inbox'] if utils.defined(this.state['gallery.add_to_inbox']) else this.state.config['gallery.add_to_inbox'] if utils.defined( this.state.config['gallery.add_to_inbox']) else False, onChange=this.on_add_to_inbox, ), e( ui.Form.Checkbox, toggle=True, label=tr(this, "ui.t-scan-for-new-galleries", "Only show new"), checked=not ( this.state['scan.skip_existing_galleries'] if utils.defined( this.state['scan.skip_existing_galleries']) else not this.state.config['scan.skip_existing_galleries'] if utils.defined( this.state.config['scan.skip_existing_galleries']) else False), onChange=this.on_only_new, ), inline=True, ), ), secondary=True) return h( "div", e(TitleChange, title=tr(this, "ui.mi-scan", "Scan")), e( ui.Container, e( ui.Message, e("div", dangerouslySetInnerHTML={ '__html': utils.marked(tr(this, "ui.de-scan-info", "")) })), e(ui.Divider, hidden=True), e( ui.Form, e( ui.Form.Group, e( ui.Form.Input, width=16, fluid=True, action=tr(this, "ui.mi-scan", "Scan"), placeholder=tr(this, "", "Directory"), onChange=this.set_path, ), ), onSubmit=this.on_scan_submit, ), options_el, e( ui.Form, *([ e(ui.Divider, e(ui.Button, tr(this, "ui.t-submit", "Submit"), disabled=submitted_view_data, primary=True, js_type="submit"), horizontal=True) ] if view_data and view_data['items'] else []), *view_progress_el, e( ui.Grid, *([e(ui.Label, title, attached="top")] if title else []), e( ui.Dimmer, e( ui.Loader, e(ui.Statistic, e(ui.Statistic.Value, "{}%".format(int(percent))), e(ui.Statistic.Label, progress_text), inverted=True, size="mini"), ), active=this.state.loading, ), e(ui.Divider, hidden=True), *count_el, *pages_el, e( ui.Grid.Row, e( ui.Grid.Column, e(ui.List, *items, relaxed=True, divided=True, animated=True), ), ), *pages_el, *count_el, as_=ui.Segment, loading=this.state.view_loading, secondary=True, className="min-300-h", ), *([ e(ui.Divider, e(ui.Button, tr(this, "ui.t-submit", "Submit"), disabled=submitted_view_data, primary=True, js_type="submit"), horizontal=True) ] if view_data and view_data['items'] else []), onSubmit=this.on_view_submit, ), ))
def collection_render(): title = "" item_id = this.state.id fav = 0 data = this.props.data or this.state.data if this.state.data: title = this.state.data.js_name if not item_id: item_id = this.state.data.id if this.state.data.metatags.favorite: fav = 1 cls_name = "segment piled" if this.props.className: cls_name += ' ' + this.props.className collection_url = '/item/collection/' + str(item_id) link = True if not this.props.link == js_undefined: link = this.props.link thumb = e( thumbitem.Thumbnail, item_id=item_id, centered=True, blur=this.props.blur, item_type=this.state.item_type, size_type=this.props.size_type if this.props.size_type else ImageSize.Medium, ) if link: thumb = e(Link, thumb, to={ 'pathname': collection_url, 'state': { 'collection': data }, }) return e( ui.Card, h( "div", thumb, e(ui.Rating, icon="heart", size="massive", className="card-item top left above-dimmer", rating=fav), e( ui.Popup, e(ui.List, [], selection=True, relaxed=True), trigger=e(ui.Icon, js_name="ellipsis vertical", bordered=True, link=True, className="card-item bottom right above-dimmer", inverted=True), hoverable=True, hideOnScroll=True, on="click", position="right center", ), className="card-content", ), e( ui.Card.Content, e(ui.Card.Header, title, className="text-ellipsis card-header"), ), centered=this.props.centered, # color="purple", className=cls_name, link=True)
def creategallery_render(): gallery_data = this.state.data.gallery options_el = e( ui.Segment, e( ui.Form, e(ui.Form.Group, e( ui.Form.Checkbox, toggle=True, label=tr(this, "ui.t-add-to-inbox", "Add to inbox"), checked=this.state.options['gallery.add_to_inbox'], onChange=this.on_add_to_inbox, ), inline=True), ), secondary=True) ginfo_el = e( ui.Segment, *((e(ui.Label, e(ui.Icon, js_name="checkmark"), tr(this, "ui.t-metadata-file", "Metadata file"), title=tr(this, "ui.t-metadata-from-file", "Metadata was retrieved from file"), color="green", basic=True, className="right"), ) if this.state.data.metadata_from_file else []), *((e(ui.Label, e(ui.Icon, js_name="warning circle"), tr(this, "ui.t-already-exists", "Exists"), color="orange", basic=True, className="right"), ) if this.state.data.exists else []), e(gallerypropsview.NewGalleryProps, data=this.state.data.gallery, sources=this.state.data.sources, on_data_update=this.on_gallery_update), loading=this.state.submitting, ) pages_el = [] if this.state.data.gallery and this.state.data.gallery.pages: for p in this.state.data.gallery.pages: pages_el.append( e( ui.Item, e( ui.Item.Content, e(ui.Item.Meta, e(ui.Label, p.number, color="blue"), e(ui.Label, p.js_name)), e(ui.Item.Extra, p.path), onDismiss=lambda: None, as_=ui.Message, color="red", ), ), ) gpages_el = e( ui.Segment, e(ui.Label, tr(this, "ui.t-pages", "Pages"), e(ui.Label.Detail, this.state.data.page_count), attached="top"), e(ui.Item.Group, *pages_el, divided=True, relaxed=True, className="max-800-h"), loading=this.state.submitting, ) return e( "div", e(TitleChange, title=tr(this, "ui.t-create-gallery", "Create a gallery")), e(Prompt, when=bool(this.state.data), message=tr(this, "ui.t-page-changes-prompt", "Are you sure?")), e( ui.Container, e( ui.Form, e( ui.Form.Group, e( ui.Form.Input, width=16, fluid=True, action={ 'color': 'yellow' if this.state.load_gallery_loading else 'teal', 'icon': e(ui.Icon, js_name='sync alternate', loading=this.state.load_gallery_loading) }, onChange=this.set_path, placeholder=tr(this, "ui.t-load-gallery", "Load gallery"), ), ), onSubmit=this.on_load_gallery_submit, ), options_el, e( ui.Form, *((e(ui.Divider, e(ui.Button, tr(this, "ui.t-submit", "Submit"), disabled=this.state.submitting, primary=True, js_type="submit"), horizontal=True), ) if gallery_data else []), ginfo_el, gpages_el, *((e(ui.Divider, e(ui.Button, tr(this, "ui.t-submit", "Submit"), disabled=this.state.submitting, primary=True, js_type="submit"), horizontal=True), ) if gallery_data else []), onSubmit=this.on_gallery_submit, )), )
def collectionprops_render(): title = "" info = "" date_pub = None date_upd = None date_added = None #category = this.props.category or this.state.category_data if this.props.data: if this.props.data.pub_date: date_pub = this.props.data.pub_date if this.props.data.last_updated: date_upd = this.props.data.last_updated if this.props.data.timestamp: date_added = this.props.data.timestamp info = this.props.data.info title = this.props.data.js_name rows = [] if this.props.compact: rows.append( e( ui.Table.Row, e(ui.Table.Cell, e(ui.Header, title, size="small"), colSpan="2", textAlign="center", verticalAlign="middle"))) if info: rows.append( e( ui.Table.Row, e(ui.Table.Cell, e(ui.Header, info, size="tiny", className="sub-text"), colSpan="2"))) rows.append( e( ui.Table.Row, e(ui.Table.Cell, e(ui.Header, tr(this, "ui.t-published", "Published") + ':', size="tiny", className="sub-text"), collapsing=True), e(ui.Table.Cell, e(DateLabel, timestamp=date_pub, full=True)))) if this.props.compact: rows.append( e( ui.Table.Row, e(ui.Table.Cell, e(ui.Header, tr(this, "ui.t-date-added", "Date added") + ':', size="tiny", className="sub-text"), collapsing=True), e(ui.Table.Cell, e(DateLabel, timestamp=date_added, format="LLL")))) rows.append( e( ui.Table.Row, e(ui.Table.Cell, e(ui.Header, tr(this, "ui.t-last-updated", "Last updated") + ':', size="tiny", className="sub-text"), collapsing=True), e(ui.Table.Cell, e(DateLabel, timestamp=date_upd, format="LLL")))) return e( ui.Table, e(ui.Table.Body, *rows), basic="very", size=this.props.size, compact="very" if utils.defined(this.props.compact) else False, )
def Slider(props): children = props.data or React.Children.toArray(props.children) items = [ e(ui.Segment, x, basic=True, size=props.size, className="slide-segment") for x in children ] add_el = [] if props.label: add_el.append( e(ui.Label, props.label, e(ui.Label.Detail, len(items)), color=props.color, attached="top")) base_size = props.sildesToShow if props.sildesToShow else 5 if items: add_el.append( e(slick, *items, dots=True, dotsClass="slick-dots", draggable=True, variableWidth=True, infinite=False if not utils.defined(props.infinite) else props.infinite, centerMode=False, accessibility=True, lazyLoad=False, adaptiveHeight=props.adaptiveHeight if utils.defined(props.adaptiveHeight) else False, slidesToShow=base_size, slidesToScroll=base_size - 1, nextArrow=e(SliderNav, direction="right"), prevArrow=e(SliderNav, direction="left"), responsive=[ { 'breakpoint': 425, 'settings': { 'slidesToShow': base_size - 3, 'slidesToScroll': base_size - 3 } }, { 'breakpoint': 610, 'settings': { 'slidesToShow': base_size - 2, 'slidesToScroll': base_size - 2 } }, { 'breakpoint': 768, 'settings': { 'slidesToShow': base_size - 1, 'slidesToScroll': base_size - 1 } }, { 'breakpoint': 1024, 'settings': { 'slidesToShow': base_size } }, { 'breakpoint': 1280, 'settings': { 'slidesToShow': base_size + 1 } }, { 'breakpoint': 1440, 'settings': { 'slidesToShow': base_size + 2 } }, { 'breakpoint': 1860, 'settings': { 'slidesToShow': base_size + 3 } }, { 'breakpoint': 100000, 'settings': { 'slidesToShow': base_size + 3 } }, ])) return e(ui.Segment, *add_el, basic=props.basic if utils.defined(props.basic) else True, loading=props.loading, secondary=props.secondary, tertiary=props.tertiary, className="no-padding-segment")
"key": "", "value": "", }, 'set_key': set_key, 'set_value': set_value, 'render': lambda: e( ui.Form.Group, e(ui.Form.Input, js_name="param", label=tr(this, "ui.t-parameter", "Parameter"), onChange=this.set_key, inline=True, width="6"), e(ui.Form.Input, js_name="value", label=tr(this, "ui.t-value", "Value"), onChange=this.set_value, inline=True, width="10"), ) }) def handle_submit(ev): ev.preventDefault() this.setState({'calling': True}) serv_data = {'fname': this.state['func_name']}