GetTableAll returns all unsent jobs to be displayed as a table
()
| 750 | |
| 751 | // GetTableAll returns all unsent jobs to be displayed as a table |
| 752 | func (s *Service) GetTableAll() [][]string { |
| 753 | var agentJobs [][]string |
| 754 | |
| 755 | for id, job := range s.jobRepo.GetAll() { |
| 756 | var status string |
| 757 | switch job.Status() { |
| 758 | case infoJobs.CREATED: |
| 759 | status = "Created" |
| 760 | case infoJobs.SENT: |
| 761 | status = "Sent" |
| 762 | case infoJobs.RETURNED: |
| 763 | status = "Returned" |
| 764 | default: |
| 765 | status = fmt.Sprintf("Unknown job status: %d", job.Status()) |
| 766 | } |
| 767 | if job.Status() != infoJobs.COMPLETE && job.Status() != infoJobs.CANCELED { |
| 768 | var zeroTime time.Time |
| 769 | var sent string |
| 770 | if job.Sent() != zeroTime { |
| 771 | sent = job.Sent().Format(time.RFC3339) |
| 772 | } |
| 773 | |
| 774 | agentJobs = append(agentJobs, []string{ |
| 775 | job.AgentID().String(), |
| 776 | id, |
| 777 | job.Command(), |
| 778 | status, |
| 779 | job.Created().Format(time.RFC3339), |
| 780 | sent, |
| 781 | }) |
| 782 | } |
| 783 | } |
| 784 | return agentJobs |
| 785 | } |
| 786 | |
| 787 | // Handler evaluates a message sent in by the agent and the subsequently executes any corresponding tasks |
| 788 | func (s *Service) Handler(agentJobs []jobs.Job) error { |