|
@@ -18,6 +18,7 @@ import (
|
|
|
|
|
|
// NodeActivity when nodes are processing
|
|
// NodeActivity when nodes are processing
|
|
type NodeActivity struct {
|
|
type NodeActivity struct {
|
|
|
|
+ ID string `json:"id"`
|
|
Status string `json:"status"` // nodeStatus, Running, error, result
|
|
Status string `json:"status"` // nodeStatus, Running, error, result
|
|
StartTime time.Time `json:"startTime"`
|
|
StartTime time.Time `json:"startTime"`
|
|
EndTime time.Time `json:"endTime"`
|
|
EndTime time.Time `json:"endTime"`
|
|
@@ -139,10 +140,16 @@ func (s *FlowSession) DocumentUpdate(c *websocket.Conn, data []byte) error {
|
|
}
|
|
}
|
|
|
|
|
|
// DocumentSave persist document in a file
|
|
// DocumentSave persist document in a file
|
|
-func (s *FlowSession) DocumentSave() error {
|
|
|
|
|
|
+func (s *FlowSession) DocumentSave(data []byte) error {
|
|
|
|
+ log.Println("Receiving documentSave")
|
|
s.Lock()
|
|
s.Lock()
|
|
defer s.Unlock()
|
|
defer s.Unlock()
|
|
|
|
|
|
|
|
+ log.Println("Saving..")
|
|
|
|
+
|
|
|
|
+ s.RawDoc = make([]byte, len(data))
|
|
|
|
+ copy(s.RawDoc, data)
|
|
|
|
+
|
|
fpath, err := s.manager.pathFor(s.ID)
|
|
fpath, err := s.manager.pathFor(s.ID)
|
|
if err != nil {
|
|
if err != nil {
|
|
log.Println("path error", err)
|
|
log.Println("path error", err)
|
|
@@ -155,6 +162,7 @@ func (s *FlowSession) DocumentSave() error {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ s.notify("Session saved")
|
|
return s.broadcast(nil, flowmsg.SendMessage{OP: "documentSave", Data: "saved"})
|
|
return s.broadcast(nil, flowmsg.SendMessage{OP: "documentSave", Data: "saved"})
|
|
}
|
|
}
|
|
|
|
|
|
@@ -209,15 +217,18 @@ func (s *FlowSession) NodeRun(c *websocket.Conn, data []byte) error {
|
|
|
|
|
|
act, ok := s.nodeActivity[ID]
|
|
act, ok := s.nodeActivity[ID]
|
|
if !ok {
|
|
if !ok {
|
|
- act = &NodeActivity{}
|
|
|
|
|
|
+ act = &NodeActivity{ID: ID}
|
|
s.nodeActivity[ID] = act
|
|
s.nodeActivity[ID] = act
|
|
}
|
|
}
|
|
status := ""
|
|
status := ""
|
|
switch name {
|
|
switch name {
|
|
case "Wait":
|
|
case "Wait":
|
|
status = "waiting"
|
|
status = "waiting"
|
|
|
|
+ act.StartTime = time.Time{}
|
|
|
|
+ act.EndTime = time.Time{}
|
|
case "Start":
|
|
case "Start":
|
|
status = "running"
|
|
status = "running"
|
|
|
|
+ act.EndTime = time.Time{}
|
|
act.StartTime = triggerTime
|
|
act.StartTime = triggerTime
|
|
case "Finish":
|
|
case "Finish":
|
|
status = "finish"
|
|
status = "finish"
|
|
@@ -248,7 +259,13 @@ func (s *FlowSession) NodeRun(c *websocket.Conn, data []byte) error {
|
|
|
|
|
|
// Notify broadcast a notification to clients
|
|
// Notify broadcast a notification to clients
|
|
func (s *FlowSession) Notify(v interface{}) error {
|
|
func (s *FlowSession) Notify(v interface{}) error {
|
|
- return s.Broadcast(nil, flowmsg.SendMessage{OP: "sessionNotify", Data: v})
|
|
|
|
|
|
+ s.Lock()
|
|
|
|
+ defer s.Unlock()
|
|
|
|
+ return s.notify(v)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (s *FlowSession) notify(v interface{}) error {
|
|
|
|
+ return s.broadcast(nil, flowmsg.SendMessage{OP: "sessionNotify", Data: v})
|
|
}
|
|
}
|
|
|
|
|
|
// Write io.Writer implementation to send event logging
|
|
// Write io.Writer implementation to send event logging
|