How to use xadmin - 10 common examples

To help you get started, we’ve selected a few xadmin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sshwsfc / xadmin / packages / xadmin-antd / src / layout / App.js View on Github external
render() {
    const { routes, params } = this.props
    return (
      
        
          <div>
            {_c('site.logo')}
            {_c('site.title', 'Admin')}
          </div>
          
        
        
          <header style="{{">
            
            {/*  */}
            <div style="{{">
              
                {items =&gt; <menu style="{{" mode="horizontal">{items}</menu>}
              </div></header>
github sshwsfc / xadmin / xadmin-dashboard / src / components / Cell.js View on Github external
render() {
    if(this.state.hasError) {
      return null
    }

    const { selected, params={}, data, cellKey, editMode, wrapStyle, widgetWrap,
      dispatchData, removeCell, selectCell, copyCell, onSettings, ...extraProps } = this.props

    // is should display
    if(!this.state.display || params == null) { return null }

    const animed = params.animate &amp;&amp; params.animate.active
    const Widget = app.load_dict('dashboard_widgets')[params.type] || MissWidgetType
    const style = { height: '100%', padding: 0, position: 'relative', userSelect: 'none', ...wrapStyle }
    const cellSelected = selected &amp;&amp; editMode

    if(cellSelected) {
      style['boxShadow'] = '0px 0px 1px #f00'
    }
    const widgetParams = this.state.widgetParams

    const canSelect = Widget.CanSelect || !Widget.Container
    const wrapId = 'dashboard-cell-wrap-' + cellKey.replace(/[\/\.]/g, '_')
    const cellStyle = widgetParams.style ? <style scope="{true}">{_transformSheet(widgetParams.style, wrapId)}</style> : null
    const typeClassName = 'dashboard-widget-' + params.type.replace(/[\/\.]/g, '_')
    const wrapClassName = [ 'dashboard-cell-wrap', typeClassName ].join(' ')

    const wrap = widgetWrap || ((widget) =&gt; (editMode ? (
      <div style="{style}" id="{wrapId}"></div>
github sshwsfc / xadmin / packages / xadmin-antd / src / model / components / Pages.js View on Github external
const renderActions = () =&gt; {
    const { canEdit } = use('model.permission')
    const { onEdit } = use('model.event')

    return (&lt;&gt;
      
      { canEdit ?
        (<button type="primary">onEdit(params &amp;&amp; params.id)}&gt; {_t('Edit')}</button>) : null
      }
    )
  }
github sshwsfc / xadmin / packages / xadmin-antd / src / model / actions / BatchChange.js View on Github external
const BatchChangeBtn = props =&gt; {
  const { _t } = app.context
  const [ show, setShow ] = React.useState(false)
  const { canEdit, fields, onBatchChange } = use('actons.batch_change', props)
  const { selected } = use('model.select', props)
  const { model } = use('model', props)

  const onClose = () =&gt; setShow(false)

  const renderModel = () =&gt; {
    const fs = fields.map(f =&gt; f.split('.')[0])
    return (
       _.find(model.form, f =&gt; f &amp;&amp; f.key == name) || name ) : [ '*' ]
        }, 'required')}
github sshwsfc / xadmin / demo / src / App.js View on Github external
render() {
    const { _t } = app.context
    return (
      
        
      
    );
  }
}

export default StoreWrap('test', { 
  data: ({ state }) =&gt; ({ title: state.test }),
  event: {
    mount: ({ dispatch }) =&gt; dispatch({ type: '@@xadmin/ADD_NOTICE', headline: 'Test', message: 'Test message' })
  }
})(App);
github sshwsfc / xadmin / packages / xadmin-auth / src / mappers.js View on Github external
}).then(user => {
          dispatch({ type: '@@xadmin/AUTH_SIGN_IN', payload: _.omit(user, 'password') })
          app.go(query && query.redirect || '/app/')
        }).catch(error => {
          dispatch({ type: '@@xadmin/AUTH_SIGN_IN_ERROR', error })
github sshwsfc / xadmin / packages / xadmin-antd / src / model / components / Items.js View on Github external
const ItemEditForm = props =&gt; {
  const { item, field, schema, model, onClose, saveItem } = use('model.save', props)

  const formField = _.find(model.form || [], obj =&gt; obj &amp;&amp; obj.key == field ) || { key: field }
  const required = (model.required || []).indexOf(field) &gt;= 0 ? { required: [ field ] } : {}

  return (
github sshwsfc / xadmin / packages / xadmin-antd / src / model / components / SubMenu.js View on Github external
const ColsDropdown = props =&gt; {
  const { selected, fields, changeFieldDisplay } = use('model.fields', props)

  let items = []
  const showFields = Object.keys(fields).filter(name =&gt; fields[name].showInList !== false)
  const menuShow = showFields.length &lt;= 10

  for (let name of showFields) {
    let field = fields[name]
      , fieldName = name
      , title = field.title || name
      , fieldSelected = _.indexOf(selected, name) !== -1
      , onClick = (e) =&gt; {
        changeFieldDisplay([ fieldName, e.target.checked ])
      }, onClickBtn = () =&gt; {
        changeFieldDisplay([ fieldName, !fieldSelected ])
      }
    if(menuShow) {
github sshwsfc / xadmin / packages / xadmin-antd / src / model / components / Items.js View on Github external
const useList = render =&gt; props =&gt; {
  const state = use('model.list', use('model', props))
  const { loading, items, model } = state
  const list = render(state)

  if(loading) {
    return {items.length &gt; 0 ? list : null}
  } else {
    if(items.length &gt; 0) {
      return list
    } else {
      const EmptyComponent = model.components &amp;&amp; model.components.DataEmpty
      if(EmptyComponent) {
        return 
      } else {
        return 
      }
    }
github sshwsfc / xadmin / packages / xadmin-antd / src / model / components / ChildrenModel.js View on Github external
const AddChildrenModelBtn = props =&gt; {
  const [ show, setShow ] = React.useState(false)
  const { model, getItems } = use('model.getItems')
  const { canAdd } = use('model.permission')
  const { refData, refreshTimeout } = props

  const onSuccess = () =&gt; {
    if(refreshTimeout) {
      setTimeout(getItems, refreshTimeout)
    } else {
      getItems()
    }
  }

  return canAdd ? [
    <button style="{{"> setShow(true)}&gt;{_t('Add {{object}}', { object: model.title })}</button>,
     setShow(false)} /&gt;
  ] : null
}