Exemplo n.º 1
0
function SetupWidget(props){
  const widget = {
    widget: props.widget.id,
    ui: map_get(props.widget, ["extra", "hints"], {}),
    config: {},
  }
  const {start, end} = store.getState().project.daterange
  const secs = end.diff(start, "seconds")
  const prev = moment(start).subtract(secs, "seconds")

  const vars = {
    start: start.toISOString(),
    end: end.toISOString(),
    prev: prev.toISOString()
  }

  return (
    <EditWidget
      template={props.widget}
      project={props.project}
      dashboard={props.dashboard}
      widget={widget}
      vars={vars}
      saveButtons={props.saveButtons}
      saveWidget={(w) => props.addWidget(props.widget.id, props.dashboard_uuid, w.config) }
      />
  )
}
Exemplo n.º 2
0
 Object.keys(form_data).map( (k) => {
   let ff = fields.find( f => f.name == k)
   // Only pass through the known fields
   if (ff){
     if (ff.type == "service"){
       let service_id = form_data[k]
       data[k]=store.getState().project.project.services.find( s => s.uuid == service_id )
     }
     else{
       data[k]=form_data[k]
     }
   }
 })
Exemplo n.º 3
0
  handleEditUser(ev){
    ev.preventDefault()
    const props=this.props
    const show_is_active = props.user.email != store.getState().auth.user.email
    let is_active = props.user.is_active
    if (show_is_active)
      is_active = $(this.refs.is_active).find('input').is(':checked')  ? true : false

    let $form = $(this.refs.form)
    let changes = {
      name: $form.find('[name=name]').val(),
      is_active,
    }
    if (has_perm("auth.modify_any"))
      changes.email = $form.find('[name=email]').val()

    props.onUpdateUser( props.user.email, changes )
    props.onClose()
  }
Exemplo n.º 4
0
  render(){
    const props=this.props

    // Only show if not current user
    const show_is_active = props.user.email != store.getState().auth.user.email

    return (
      <Modal onClose={props.onClose}>
        <div className="ui top secondary menu">
          <h2 className="ui header">Edit {props.user.name}</h2>
          <div className="right menu" style={{alignItems: "center"}}>
            {show_is_active ? (
              <div className="field">
                <div ref="is_active" className="ui toggle checkbox">
                  <label>Is active</label>
                  <input type="checkbox" name="is_active" defaultChecked={props.user.is_active}/>
                </div>
              </div>
            ) : []}
          </div>
        </div>
        <div className="content">
          <div ref="form" className="ui form" onSubmit={this.handleEditUser.bind(this)}>
            <div className="field">
              <label>{i18n("Email")}</label>
              <input disabled={!has_perm("auth.modify_any")} type="email" name="email" defaultValue={props.user.email} placeholder={i18n("This will be used as the user identifier")}/>
            </div>
            <div className="field">
              <label>{i18n("First Name")}</label>
              <input type="text" name="name" defaultValue={props.user.name}/>
            </div>
          </div>
          <div className="actions">
            <button className="ui accept teal button" onClick={this.handleEditUser.bind(this)}>{i18n("Update user")}</button>
          </div>
        </div>
      </Modal>
    )
  }