Example #1
0
 return function(dispatch){
   dispatch({type: "BOARD_SET", payload: undefined })
   if (uuid)
     rpc.call("dashboard.get", {uuid}).then( d => {
       dispatch({type: "BOARD_SET", payload: d})
     })
 }
Example #2
0
 return function(dispatch, store){
   rpc.call("project.create",
       [ data.shortname, {name: data.name, tags: data.tags, description: data.description}]
     ).then(function(){
       dispatch( push({pathname: `/project/${data.shortname}/`}) )
       Flash.info(i18n("Added project *{shortname}*", {shortname: data.shortname}))
     })
 }
Example #3
0
function board_remove({uuid, name}){
  return rpc
    .call("dashboard.delete", {uuid})
    .then( () => {
      Flash.info(i18n(`Removed dashboard *{name}*`, {name}))
      return {type: "BOARD_REMOVED", payload: uuid}
    })
}
Example #4
0
function board_update(data){
  return rpc
    .call("dashboard.update", data)
    .then( () => {
      Flash.info(i18n(`Updated dashboard *{name}*`, data))
      return {type: "BOARD_UPDATE", payload: data}
    })
}
Example #5
0
export function install(giturl){
  console.log("Install plugin from %s", giturl)
  return rpc.call("plugin.install", [giturl])
    .then(res => {
      cache.invalidate_all()
      return res
    })
}
Example #6
0
function dashboard_list(project){
  console.log("Get dashboard list ", project)
  return rpc
    .call("dashboard.list", {project})
    .then( list => ({
      type: "DASHBOARD_LIST",
      payload: {list, project}
    }))
}
Example #7
0
 return function(dispatch){
   dispatch({type:"UPDATE_PROJECT_INFO", project, info: undefined})
   if (project){
     rpc.call("project.get", [project]).then( (info) => {
       dispatch({type:"UPDATE_PROJECT_INFO", project, info})
       dispatch( project_get_dashboard(map_get(info.dashboards, [0, "uuid"])))
     })
   }
 }
Example #8
0
 updateActive: (uuid, is_active) => {
   // console.log("Update active?", uuid, is_active)
   rpc.call("rules_v2.update", [uuid, {is_active}])
     .then( () => Flash.success(
       is_active ?
         i18n("Rule activated succesfully.") :
         i18n("Rule deactivated successfully"))
     )
     .catch( () => Flash.error(i18n("Error activating rule")) )
 },
Example #9
0
 call(method, params={}){
   if (!this.uuid){
     return this.start().then(() => this.call(method, params))
   }
   return rpc.call("plugin.call", [this.uuid, method, params]).catch( (e) => {
     console.log(e, e == 'exit')
     if (e=='unknown_method' || e=="exit" || e == "timeout") // try again... maybe
       return this.maybe_reconnect(e).then( () => this.call(method, params) )
     throw(e)
   })
 }
Example #10
0
 maybe_reconnect(e){
   if (!this.options.restart)
     throw(e)
   return rpc.call("plugin.is_running", [this.uuid]).then( (is_running) => {
     if (is_running)
       throw(e)
     else{
       return this.start()
     }
   })
 }
 handleCreateDashboard(){
   const props = this.props
   let name = this.refs.name.value
   rpc.call("dashboard.create", {
     project: props.project,
     name: name
   }).then( () => props.onClose() )
   .catch( e => {
     console.error(e)
     Flash.error("Could not create the dashboard. Check the logs.")
   })
 }
Example #12
0
 cache.project(shortname).then( p => {
   if (p)
     Flash.error(i18n("Project shortname {shortname} already exist. Try another project name.",{shortname}))
   else{
     return rpc
       .call("project.create", {shortname, name })
       .then((uuid) => {
         this.setState({project: shortname})
         store.dispatch( projects_set_current(shortname) )
       })
       .then( () =>
         this.funcs.nextStep()
       )
   }
 })
  changePassword(){
    console.log("Change password %o", this.refs)
    let $form=$(this.refs.form)
    let is_valid = $form.form("validate form")
    if (is_valid){
      const current=$form.find('input[name=current]').val()
      const newpassword=$form.find('input[name=new_password]').val()

      rpc.call("auth.set_password", [current, newpassword]).then(() => {
        Flash.info(i18n("Password changed properly"))
        this.props.onClose()
      }).catch((e) => {
        Flash.error(i18n("Error changing password: {e}", {e}))
      })
    }
  }
Example #14
0
 handleSubmit(){
   //console.log(this.refs)
   var all_updates=[]
   for(let section of this.props.settings){
     section=section.id
     let data=this.state[section]
     if (!data)
       continue
     all_updates.push(
       rpc.call("settings.update", [section, data])
     )
   }
   Promise.all(all_updates).then(function(){
     Flash.success(i18n("Updated settings!"))
   }).then( () => store.dispatch(settings_all()) )
 }
Example #15
0
 return function(dispatch){
   console.log("Loading plugin list i18n")
   rpc.call("plugin.catalog",[]).then( (pluginsd) => {
     let promises = []
     for (let k in pluginsd){
       if (pluginsd[k].extra.i18n){
         let p = i18n.load({lang, plugin: k}).catch( () => {})
         promises.push(p)
       }
     }
     return Promise.all(promises)
   }).then( (p) => {
     console.log("Loaded all plugin translations", p.length)
     // Force reload because of lang change
     dispatch({type: "AUTH_SET_LANG", lang})
   })
 }
Example #16
0
export function trigger_action(action, service){
  if (action.extra.call){
    const params = service.config

    let missing_params = (action.extra.call.params || []).filter((p) => !(p.name in params))
    if (missing_params.length==0){
      rpc.call("action.trigger",
        [action.id, params]).then(function(){
        })
    }
    else{
      set_modal("service.action",{ action, params, missing_params })
    }
  }
  else if (action.extra.screen){
    this.context.router.push({
      pathname: `/s/${action.id}`,
      state: { service: service }
    })
  }
  else {
    Flash.error(i18n("Dont know how to trigger this action"))
  }
}
Example #17
0
import React from 'react'
import connect from 'app/containers/connect'
import View from 'app/components/rules_v2/addtemplate'
import Flash from 'app/flash'
import {goto} from 'app/utils/store'
import rpc from 'app/rpc'
import i18n from 'app/utils/i18n'

const Model = connect({
  handlers(props){
    return {
      addTemplate(rule){
        return rpc.call("rules_v2.create", rule).then((uuid) => {
          console.log("Created with UUID %o", uuid)
          Flash.success(i18n("Created rule *{name}*", {name: rule.name}))
          goto(`/project/${rule.project}/rules_v2/`)
        })
      },
      updateTemplate(uuid, rule){
        return rpc.call("rules_v2.update", [uuid, rule]).then(() => {
          Flash.success(i18n("Updated rule *{name}*", {name: rule.name}))
          goto(`/project/${rule.project}/rules_v2/`)
        })
      }

    }
  }
})(View)

export default Model
Example #18
0
export default connect({
  state(state, props){
    return {
      rules: state.rules_v2.rules,
      updateActive: (uuid, is_active) => {
        // console.log("Update active?", uuid, is_active)
        rpc.call("rules_v2.update", [uuid, {is_active}])
          .then( () => Flash.success(
            is_active ?
              i18n("Rule activated succesfully.") :
              i18n("Rule deactivated successfully"))
          )
          .catch( () => Flash.error(i18n("Error activating rule")) )
      },
      onRemoveRule(uuid){
        rpc.call("rules_v2.delete", [uuid])
          .then(() => Flash.success(i18n("Rule removed")))
          .catch(Flash.error)
      }
    }
  },
  store_enter(state, props){
    return [
      () => rules_v2_list(state.project.current)
    ]
  },
  store_exit(){
    return [
      rules_v2_list_clear
    ]
  },
Example #19
0
export function call(pl, method, args){
  return rpc.call("plugin.call", [pl, method, args])
}
Example #20
0
 },
 projects: cache_builder({
   store_get: () => store.getState().project.projects,
   store_update: require('app/actions/project').project_update_all(),
   subscriptions: ["project.updated"]
 }),
 project(shortname){
   return cache.projects().then( projects => projects.find( p => p.shortname==shortname) )
 },
 plugins(){
   var data = cache_data["plugins"]
   if (!data){
     const waiting = wait_list["plugins"]
     if (!waiting){
       wait_list["plugins"] = []
       return rpc
         .call("plugin.catalog",[])
         .then( data => {
           cache_data["plugins"] = data
           for (const  accept of wait_list["plugins"]){
             accept(data)
           }
           delete wait_list["plugins"]
           return data
         })
     }
     const  p = new Promise( (accept, reject) => {
       wait_list["plugins"] = waiting.concat(accept)
     })
     return p
   }
   return Promise.resolve(data)
Example #21
0
 stop(){
   return rpc.call("plugin.stop", [this.uuid])
 }
Example #22
0
 return function(dispatch){
   rpc.call("plugin.component.catalog", {type: "widget"}).then( (catalog) => {
     const payload = to_mapf(catalog, c => c.id)
     dispatch({type:"UPDATE_WIDGET_CATALOG", payload: payload})
   })
 }
Example #23
0
 return function(dispatch){
   rpc.call("project.update", [shortname, changes]).then(function(){
     Flash.info(i18n("Updated project *{shortname}*", {shortname}))
   })
 }
Example #24
0
 start(){
   return rpc.call("plugin.start", [this.pluginid]).then( (uuid_) => {
     this.uuid = uuid_
     return this
   })
 }
Example #25
0
 return function(dispatch){
   rpc.call('action.ps',[]).then(function(list){
     dispatch({type: "ACTION_PS", actions: list})
   })
 }
Example #26
0
 return function(dispatch){
   rpc.call('plugin.component.catalog',{type: "action"}).then(function(catalog_list){
     const payload = to_mapf(catalog_list, c => c.id)
     dispatch({type: "ACTION_CATALOG", payload})
   }).catch(console.error)
 }
Example #27
0
 return Promise.all( (vars || []).map( (v) => {
   return rpc.call("plugin.call", [v.command, v.call, {...args, ...(v.extra||{})}])
      .then((content) => [v.id, content])
 })).then( (varlist) => {
Example #28
0
 return function(dispatch){
   rpc.call("project.list",[]).then(function(data){
     dispatch({type: "UPDATE_ALL_PROJECTS", projects: data})
   })
 }
Example #29
0
 return function(dispatch){
   rpc.call("project.delete", [shortname]).then(function(){
     Flash.info(i18n("Removed project *{shortname}*", {shortname: data.shortname}))
   })
 }
Example #30
0
 return function(dispatch){
   rpc.call("service.attach",[project_shortname, service_uuid]).then(function(){
     Flash.info(i18n("Added service to project"))
   })
 }