def circleprops_render(): url_search_query = {'search': ''} if this.state.data: url_search_query = { 'search': 'circle:"{}"'.format(this.state.data.js_name) } return e( ui.Button.Group, e(ui.Button, icon="grid layout", title=tr(this, "ui.t-show-galleries", "Show galleries"), as_=Link, to=utils.build_url("/library", query=url_search_query, keep_query=False)), e(ui.Button, icon="heart", title=tr(this, "ui.t-show-fav-galleries", "Show favorite galleries"), as_=Link, to=utils.build_url("/favorite", query=url_search_query, keep_query=False)), className=this.props.ClassName, basic=True, size=this.props.size or "tiny", )
def update_item(data=None, error=None, new_data=None): if data is not None and not error: if data: state.app.notif(tr(None, "ui.t-updated", "Updated!"), level="success") else: state.app.notif(tr(None, "ui.t-updated-fail", "Failed!"), level="warning") if this.state.new_data: this.setState({'new_data': None}) elif error: state.app.notif("Failed to update item ({})".format(this.state.id), level="error") else: new_data = new_data or this.state.new_data if new_data and (new_data['tags'] or new_data['taggable']['tags'] if new_data['taggable'] else None): tag_data = new_data['tags'] or new_data['taggable']['tags'] del new_data['tags'] del new_data['taggable'] this.update_tags(new_data=tag_data) if new_data and new_data.id and utils.lodash_collection.size( new_data) > 1: client.call_func("update_item", this.update_item, item_type=this.state.item_type, item=new_data)
def itembuttons_render(): ch = this.props.children if not isinstance(ch, list): ch = [ch] return e( ui.Button.Group, *ch, e( ui.Button, tr(this, "general.db-item-collection", "Collection"), value=ItemType.Collection, onClick=this.item_change, primary=True, basic=this.props.value == ItemType.Collection, ), e( ui.Button, tr(this, "general.db-item-gallery", "Gallery"), value=ItemType.Gallery, onClick=this.item_change, primary=True, basic=this.props.value == ItemType.Gallery, ), toggle=True, basic=True, size=this.props.size if utils.defined(this.props.size) else "small")
def artistpage_render(): items = [] unk = tr(this, "ui.t-bracket-unknown", "<Unknown>") for artist in this.state.data: aname = unk if artist.names: aname = artist.names[0]['name'] items.append( e( ui.Modal, e( ui.Modal.Content, e(artistpropsview.ArtistProps, data=artist), ), trigger=e(ui.Card, e(ui.Card.Content, e(ui.Card.Description, aname)), centered=True, link=True, className="default-card"), dimmer="inverted", size="small", closeOnDocumentClick=True, closeIcon=True, key=artist.id, )) return e(SimpleLayout, e(TitleChange, title=tr(this, "ui.mi-dir-artists", "Artists")), e( ui.Card.Group, items, itemsPerRow=2, doubling=True, stackable=True, as_=ui.Transition.Group, animation="scale", duration=500, ), loading=this.state.data_loading, pages=True, item_count=this.state.count, limit=this.state.limit, page=this.state.page, set_page=this.set_page, search=True, search_query=this.state.search_query, search_change=this.update_search, search_placeholder=tr(this, "ui.t-search-artists-placeholder", "Search artists"), stats=[ e( ui.Statistic, e(ui.Statistic.Value, this.state.count), e(ui.Statistic.Label, tr(this, "ui.t-total-artists", "Total artists"))) ])
def preftab_render(): t_refresh = this.trigger_refresh t_restart = this.trigger_restart s_restart = this.state.restart upd_config = this.update_config set_config = this.set_config config = this.state.config u_cfg = this.state.u_config tab = this def el(x): return e( x, # noqa: E704 u_cfg=u_cfg, tab=tab, cfg=config, refresh=t_refresh, tigger_restart=t_restart, restart=s_restart, upd=upd_config, set=set_config, ) return e(ui.Tab, panes=[ { 'menuItem': tr(this, "ui.mi-pref-view", "View"), 'render': lambda: el(pref_view) }, { 'menuItem': tr(this, "ui.mi-pref-general", "General"), 'render': lambda: el(pref_general) }, { 'menuItem': tr(this, "ui.mi-pref-logins", "Logins"), }, { 'menuItem': tr(this, "ui.mi-pref-metadata", "Metadata"), }, { 'menuItem': tr(this, "ui.mi-pref-network", "Network"), }, { 'menuItem': tr(this, "ui.mi-pref-monitoring", "Monitoring"), }, { 'menuItem': tr(this, "ui.mi-pref-ignore", "Ignore"), }, { 'menuItem': tr(this, "ui.mi-pref-server", "Server"), 'render': lambda: el(pref_server) }, { 'menuItem': tr(this, "ui.mi-pref-advanced", "Advanced"), 'render': lambda: el(pref_advanced) }, ], menu=e(ui.Menu, secondary=True, pointing=True, stackable=True))
def circlespage_render(): items = [] for item in sorted(this.state.data, key=lambda x: x['name'].lower()): items.append( e( ui.Popup, e(circlepropsview.CircleProps, data=item), trigger=e(ui.Card, e( ui.Card.Content, e(ui.Card.Description, item['name']), ), centered=True, link=True, className="default-card"), hoverable=True, wide="very", on="click", hideOnScroll=True, position="top center", key=item.id, )) return e(SimpleLayout, e(TitleChange, title=tr(this, "ui.mi-dir-circles", "Circles")), e( ui.Card.Group, items, itemsPerRow=2, doubling=True, stackable=True, as_=ui.Transition.Group, animation="scale", duration=500, ), loading=this.state.data_loading, pages=True, item_count=this.state.count, limit=this.state.limit, page=this.state.page, set_page=this.set_page, search=True, search_query=this.state.search_query, search_change=this.update_search, search_placeholder=tr(this, "ui.t-search-circles-placeholder", "Search cricles"), stats=[ e( ui.Statistic, e(ui.Statistic.Value, this.state.count), e(ui.Statistic.Label, tr(this, "ui.t-total-circles", "Total circles"))) ])
def parodiespage_render(): items = [] unk = tr(this, "ui.t-bracket-unknown", "<Unknown>") for parody in this.state.data: aname = unk if parody.names: aname = parody.names[0]['name'] items.append( e(ui.Popup, e(parodypropsview.ParodyProps, data=parody), trigger=e(ui.Card, e(ui.Card.Content, e(ui.Card.Description, aname)), centered=True, link=True, className="default-card"), hoverable=True, wide="very", on="click", hideOnScroll=True, position="top center", key=parody.id)) return e(SimpleLayout, e(TitleChange, title=tr(this, "ui.mi-dir-parodies", "Parodies")), e( ui.Card.Group, items, itemsPerRow=1, doubling=True, stackable=True, as_=ui.Transition.Group, animation="scale", duration=500, ), loading=this.state.data_loading, pages=True, item_count=this.state.count, limit=this.state.limit, page=this.state.page, set_page=this.set_page, search=True, search_query=this.state.search_query, search_change=this.update_search, search_placeholder=tr(this, "ui.t-search-parodies-placeholder", "Search parodies"), stats=[ e( ui.Statistic, e(ui.Statistic.Value, this.state.count), e(ui.Statistic.Label, tr(this, "ui.t-total-parodies", "Total parodies"))) ])
def status_render(): data = this.props.data or this.state.data 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 el = None stat_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-status", "Status"), 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, stat_name, color={ "completed": "green", "ongoing": "orange", "unreleased": "red", "unknown": "grey" }.get(stat_name.lower(), "blue"), 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 categorypage_render(): items = [] for cat in sorted(this.state.data, key=lambda x: x['name'].lower()): items.append( e(ui.Card, e(ui.Card.Content, e(ui.Card.Description, cat['name'])), centered=True, link=True, className="default-card")) return e( SimpleLayout, e(TitleChange, title=tr(this, "ui.mi-dir-categories", "Categories")), 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 filterdropdown_render(): item_options = [] __pragma__("iconv") if this.state.db_items: for d in sorted(this.state.db_items): item_options.append({ 'text': d, 'value': this.state.db_items[d]['id'], 'icon': "filter" }) __pragma__("noiconv") return e(ui.Dropdown, placeholder=tr(this, "ui.t-filterdropdown-placeholder", "Filter"), options=item_options, search=True, allowAdditions=True, value=this.props.value or js_undefined, defaultValue=this.props.defaultValue, onChange=this.item_change, loading=this.state.loading, 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 if utils.defined(this.props.item) else True, selection=this.props.selection if utils.defined(this.props.selection) else True, basic=this.props.basic)
def sortdropdown_render(): item_options = [] __pragma__("iconv") if this.state.sort_items: for x in sorted(this.state.sort_items, key=lambda k: k['name']): if x['item_type'] == this.props.item_type: item_options.append({ 'value': x['index'], 'text': x['name'], 'icon': 'sort' }) __pragma__("noiconv") return e(ui.Dropdown, placeholder=tr(this, "ui.t-sortdropdown-placeholder", "Sort by"), options=item_options, value=this.props.value, defaultValue=this.props.defaultValue, onChange=this.item_change, loading=this.state.loading, 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 if utils.defined(this.props.item) else True, selection=this.props.selection if utils.defined(this.props.selection) else True, basic=this.props.basic)
def disabled_machine_msg(props): return e( ui.Message, tr( props.tab, "ui.de-pref-disabled", "Disabled because this client is connecting from a different device" ), color="yellow")
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 category_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 cat_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-category", "Category"), 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 not utils.lodash_lang.isEmpty(data) or this.props.edit_mode: el = e( ui.Label, cat_name, color="black", basic=this.props.basic, size=this.props.size, 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 search_render(): cls_name = "" if this.props.fluid: cls_name = "fullwidth" if this.props.className: cls_name += " " + this.props.className return h( "form", e(ui.Search, size=this.props.size, input=e( ui.Input, fluid=this.props.fluid, transparent=this.props.transparent if utils.defined(this.props.transparent) else True, placeholder=tr(this, "ui.t-search-main-placeholder", "Search title, artist, namespace & tags"), label=e( ui.Popup, e( SearchOptions, history=this.props.history, query=this.props.query, on_change=this.on_search_options, case_=this.state['case'], regex=this.state.regex, whole=this.state.whole, all=this.state.all, desc=this.state.desc, suggest=this.state.suggest, on_key=this.state.on_key, ), trigger=e(ui.Button, icon=e(ui.Icon.Group, e(ui.Icon, js_name="options"), e(ui.Icon, js_name="search", corner=True)), js_type="button", basic=True, size=this.props.size), hoverable=True, on="click", hideOnScroll=True, ), ), minCharacters=3, fluid=this.props.fluid, action={'icon': 'search'}, open=this.state.suggest if not this.state.suggest else js_undefined, onSearchChange=this.on_search_change, defaultValue=this.state.query), className=cls_name, onSubmit=this.on_search)
def datelbl_render(): m = None data = this.state.data or this.props.data if data: m = utils.moment.unix(data) full = m.format(this.props.format or "LL") relative = m.fromNow() if this.props.full or this.props.edit_mode: date = full + " ({})".format(relative) elif this.state.toggled: date = full else: date = relative else: date = tr(this, "ui.t-unknown", "Unknown") el = None if this.state.edit_mode and this.props.edit_mode: el = e(ui.Input, defaultValue=m.format(utils.moment.HTML5_FMT.DATE) if m else js_undefined, onChange=this.on_change, onBlur=this.on_submit, size=this.props.size or "small", js_type="date", fluid=this.props.fluid) else: items = [] if this.props.text: items.append(this.props.text) items.append(e(ui.Label.Detail, date)) else: items.append(date) clsname = "" if utils.defined_or(this.props.disabled, False): clsname += " disabled" el = e( ui.Label, * items, onClick=this.on_click if this.props.edit_mode and not this.props.disabled else this.toggle, as_="a", className=clsname) return el
def PrefSegment(props): return e( ui.Segment, e(ui.Form, props.children), e(ui.Divider, horizontal=True), e(ui.Message, h( "p", tr( props.props.tab, "ui.t-setting-restart", "One or more setting modifications require a restart to take effect" )), warning=True, size="tiny", hidden=not props.props.restart), basic=True, )
def submit_gallery(data=None, error=None): if data is not None and not error: this.submit_txt = tr(this, "ui.t-new-gallery-added", "A new gallery was added"), Command(data, daemon=False).poll_progress(interval=200, callback=this.on_submitted) elif error: state.app.notif("Failed to submit new gallery", level="error") this.setState({'submitting': False}) else: if this.state.data.gallery: this.setState({'submitting': True}) client.call_func( "new_item", this.submit_gallery, item_type=ItemType.Gallery, item=this.state.data.gallery, options=this.state.options, )
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 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 server_notifications(data=js_undefined, error=None): if data is not js_undefined and not error: if data: if data.actions: this.setState({'server_push_msg': data, 'server_push': True}) else: tmout = 20000 ic = "info" msg = data['body'] if data['id'] in (PushID.Update,): tmout = tmout * 1.5 ic = "angle double up" if state.history: utils.go_to(state.history, "/activity") this.notif(tr(None, "ui.t-changelog-location", "About -> Changelog"), data['title'], icon=ic, timeout=tmout) this.notif(msg, data['title'], icon=ic, timeout=tmout) elif error: this.notif("Failed to retrieve server notification", level="warning") else: if state['active'] and state['connected'] and state['accepted'] and utils.storage.get( "ping_for_notifications", True): pushclient.call_func("get_notification", this.server_notifications)
def createcollection_render(): return e( "div", e(TitleChange, title=tr(this, "ui.t-create-collection", "Create a collection")), )
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 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, ), ))
set_config, '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,
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)]
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)
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, )