       xtype: "displayfield"
       fieldLabel: "Graph"
       name: "graphName"
-    ,
   ]
 
   formHashFromArray: (arr, base = {}) ->

    base

  load: (curKey, curRet, alertsArr) ->
    data = {
      graphName: "#{curKey};#{curRet}"
    }
    data = @formHashFromArray(Muleview.Settings.alerts, data )
    data = @formHashFromArray(alertsArr, data) if alertsArr
    @getForm().setValues(data)

  createField: (alert) ->
    ans =

    ans

  initComponent: ->
    # Fields:
    fields = []
    for alert in Muleview.Settings.alerts
      fields.push @createField(alert)

    # Field container
    @fieldsContainer = Ext.create "Ext.container.Container",
      layout:
        type: "vbox"
        align: "stretch"
        pack: "start"

      items: fields
      border: false
      hidden: true

    @items.push @fieldsContainer

    # Buttons:
    @buttonsContainer = Ext.create "Ext.container.Container",
      border: false
      layout:
        type: "hbox"
        pack: "start"
      defaults:
        xtype: "button"
        margin: "0px 5px 0px 0px"
        hidden: true
      items: [
            text: "Save"
            handler: => @doUpdate()
            showInMode: ["edit", "creating"]
        ,
            text: "Delete"
            handler: => @doDelete()
            showInMode: ["edit"]
        ,
            text: "Set Alerts"
            handler: => @doCreate()
            showInMode: ["create"]
        ,
            text: "Cancel"
            handler: => @doCancel()
            showInMode: ["creating"]
      ]
    @items.push @buttonsContainer
    @callParent()

  updateButtons: (mode) ->
    @buttonsContainer.items.each (btn) ->
      btn.setVisible(Ext.Array.contains(btn.showInMode, mode))

  doUpdate: ->
    url = Muleview.Mule.getAlertCommandUrl(Muleview.currentKey, Muleview.currentRetention)
    @submit(
      url: url
      method: "PUT"
      success: ->
        Muleview.Graphs.createGraphs()
      )

  doDelete: ->
    console.log("MuleChart.coffee\\ 148: <HERE>");

  doCreate: ->
    @getForm().clearInvalid()
    @fieldsContainer.show()
    @updateButtons("creating")

  doCancel: ->
    @fieldsContainer.hide()
    @updateButtons("create")