diff options
author | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-11-24 01:14:30 +0100 |
---|---|---|
committer | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-11-24 01:37:24 +0100 |
commit | 4d843d2bde236ec23810d0904dfb8aebbc53a37b (patch) | |
tree | 84c01452f01620cedb7bf6bcb608a0eade82161b /lib/agent/project-pathmap.go | |
parent | 38c0c21a969e621c725245ce91c78e77076c5ce7 (diff) |
New dashboard improvements.
- add build buttons
- add build settings support and backup into project clientData
- improved async alert
- fixed project dropdown
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'lib/agent/project-pathmap.go')
-rw-r--r-- | lib/agent/project-pathmap.go | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/agent/project-pathmap.go b/lib/agent/project-pathmap.go index 7a96e6e..3c87770 100644 --- a/lib/agent/project-pathmap.go +++ b/lib/agent/project-pathmap.go @@ -69,7 +69,7 @@ func (p *PathMap) Add(cfg apiv1.ProjectConfig) (*apiv1.ProjectConfig, error) { // Send request to create folder on XDS server side err = p.server.FolderAdd(fld, p.folder) if err != nil { - return nil, fmt.Errorf("Folders mapping verification failure.\n%v", err) + return nil, err } // 2nd part of sanity checker @@ -98,16 +98,30 @@ func (p *PathMap) GetProject() *apiv1.ProjectConfig { return &prj } -// UpdateProject Set project config -func (p *PathMap) UpdateProject(prj apiv1.ProjectConfig) (*apiv1.ProjectConfig, error) { +// Setup Setup local project config +func (p *PathMap) Setup(prj apiv1.ProjectConfig) (*apiv1.ProjectConfig, error) { p.folder = p.server.ProjectToFolder(prj) np := p.GetProject() - if err := p.events.Emit(apiv1.EVTProjectChange, np); err != nil { + if err := p.events.Emit(apiv1.EVTProjectChange, np, ""); err != nil { return np, err } return np, nil } +// Update Update some field of a project +func (p *PathMap) Update(prj apiv1.ProjectConfig) (*apiv1.ProjectConfig, error) { + if p.folder.ID != prj.ID { + return nil, fmt.Errorf("Invalid id") + } + + err := p.server.FolderUpdate(p.server.ProjectToFolder(prj), p.folder) + if err != nil { + return nil, err + } + + return p.GetProject(), nil +} + // GetServer Get the XdsServer that holds this project func (p *PathMap) GetServer() *XdsServer { return p.server |