How to use the xadmin.app.load_dict function in xadmin

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 / 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 && 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 && 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 / xadmin-dashboard / src / mappers.js View on Github external
Object.keys(cells).map(key => {
          const cell = cells[key]
          const Widget = app.load_dict('dashboard_widgets')[cell.type]
          if(Widget && Widget.sampleData) {
            Widget.sampleData(cell, (key, data) => {
              dispatch({ dashboard, type: '@@x-dashboard/UPDATE_DATA', key, data  })
            })
          }
        })
      },
github sshwsfc / xadmin / xadmin-dashboard / src / editor / components / Menu.js View on Github external
render() {
    const { params: { layers, editLayer }, ...props } = this.props
    const widgets = app.load_dict('dashboard_widgets')
    return (
      <nav>
        
          {
            Object.keys(widgets).map(key =&gt; {
              const Widget = widgets[key]
              return <menuitem>this.addCell(key)}&gt;{Widget.Title}</menuitem>
            })
          }
        
        
        
          <menuitem>this.changeLayer(null)}&gt;取消编辑</menuitem>
          {
            layers &amp;&amp; layers.map((layer, i) =&gt; {
              return <menuitem>this.changeLayer(i)}&gt;{`第${i+1}层`}</menuitem></nav>
github sshwsfc / xadmin / xadmin-dashboard / src / editor / components / Menu.js View on Github external
addCell(type) {
    const Widget = app.load_dict('dashboard_widgets')[type]
    const { params: { editLayer } } = this.props
    const params = { 
      key: (Math.random() * 100).toString(), 
      params: {
        layer: editLayer,
        type,
        title: '未命名标题'
      },
      layout: { x: 0, y: 0, w: 4, h: 4 }
    }
    this.props.addCell(params)
    
    if(this.props.onAddCell) {
      this.props.onAddCell(params.key)
    }
  }
github sshwsfc / xadmin / xadmin-dashboard / src / components / Root.js View on Github external
  getWidget: () => app.load_dict('dashboard_widgets')['xadmin-dashboard/main'] || Box
}
github sshwsfc / xadmin / xadmin-dashboard / src / editor / components / ComponentTree.js View on Github external
render() {
    const { cells, selectedCell } = this.props
    const widgets = app.load_dict('dashboard_widgets')

    const Node = ( nodeName ) =&gt; {
      return (cells[nodeName] &amp;&amp; cells[nodeName].childrenCells || []).map(key =&gt;{
        const cell = cells[key]
        const children = Node(key)
        const Widget = widgets[cell.type] || {}
        const title = (cell.name ? <span>{cell.name} <span style="{{">[{Widget.Title}]</span></span> : Widget.Title)
        const cellTitle = 
        if(children &amp;&amp; children.length &gt; 0) {
          return (
            
              { children }
            
          )
        } else {
          return
github sshwsfc / xadmin / xadmin-dashboard / src / editor / fields / Array.js View on Github external
export default ({ input, label, meta, field, option, group: FieldGroup }) =&gt; {
  let renderItems = field.itemsRender || defaultItemsRender
  if(typeof renderItems === 'string') {
    renderItems = app.load_dict('array_render')[renderItems]
  }
  const { items } = field
  const fieldsBuilder = (name, index, removeBtn, itemLable) =&gt; {
    const itemFields = items.fields ? (items.fields
      .map(f =&gt; { return { ...f, 
        key: name + '.' + f.key,
        name: name + '.' + f.name
      } })) : [ { ...items, key: name, name: name, label: itemLable } ]

    return objectBuilder(itemFields, items.render, option)
  }
  return (
    
      
    
  )
github sshwsfc / xadmin / xadmin-dashboard / src / datasources / random.js View on Github external
query: ({ cell }) => {
    const Widget = app.load_dict('dashboard_widgets')[cell.type]
    return new Promise((resolve) => {
      if(Widget && Widget.sampleData) {
        Widget.sampleData(cell, resolve)
      } else {
        resolve([])
      }
    } )
  }
}
github sshwsfc / xadmin / xadmin-dashboard / src / editor / components / PropForm.js View on Github external
saveParams = (values) => {
    const { params, cellKey, parent } = this.props

    if(parent && parent.type) {
      const Container = app.load_dict('dashboard_widgets')[parent.type]
      if(Container && Container.saveChildLayout) {
        const parentParams = Container.saveChildLayout(parent, cellKey, values)
        this.props.saveLayoutParam(parentParams)
      }
    }

    this.props.onClose && this.props.onClose()
  }