DodoApp: Improve UI

Change-Id: Ia374b600c9b61e7543a1c7dffb2ade9b58c7d49f
diff --git a/core/installer/welcome/dodo-app-tmpl/app_status.html b/core/installer/welcome/dodo-app-tmpl/app_status.html
index 179ad10..efe74a1 100644
--- a/core/installer/welcome/dodo-app-tmpl/app_status.html
+++ b/core/installer/welcome/dodo-app-tmpl/app_status.html
@@ -2,9 +2,10 @@
 dodo app: {{ .Name }}
 {{ end }}
 {{- define "content" -}}
+<a href="/">Home</a><br/><br/>
 {{ .GitCloneCommand }}
 <hr class="divider">
 {{- range .Commits -}}
-{{ .Hash }} {{ .Message }}<br/>
+{{if eq .Status "OK" }}<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="black" d="M21 7L9 19l-5.5-5.5l1.41-1.41L9 16.17L19.59 5.59z"/></svg>{{ else }}<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 48 48"><path fill="black" fill-rule="evenodd" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="4" d="M6 11L11 6L24 19L37 6L42 11L29 24L42 37L37 42L24 29L11 42L6 37L19 24L6 11Z" clip-rule="evenodd"/></svg>{{ end }} {{ .Hash }} {{ .Message }}<br/>
 {{- end -}}
 {{- end -}}
diff --git a/core/installer/welcome/dodo_app.go b/core/installer/welcome/dodo_app.go
index b11e3a7..7153f20 100644
--- a/core/installer/welcome/dodo_app.go
+++ b/core/installer/welcome/dodo_app.go
@@ -459,7 +459,11 @@
 	Repository struct {
 		Name string `json:"name"`
 	} `json:"repository"`
-	After string `json:"after"`
+	After   string `json:"after"`
+	Commits []struct {
+		Id      string `json:"id"`
+		Message string `json:"message"`
+	} `json:"commits"`
 }
 
 func (s *DodoAppServer) handleAPIUpdate(w http.ResponseWriter, r *http.Request) {
@@ -491,13 +495,26 @@
 		if err != nil {
 			return
 		}
-		if err := s.updateDodoApp(instanceAppStatus, req.Repository.Name, s.appConfigs[req.Repository.Name].Namespace, networks); err != nil {
-			if err := s.st.CreateCommit(req.Repository.Name, req.After, err.Error()); err != nil {
-				fmt.Printf("Error: %s\n", err.Error())
-				return
+		found := false
+		commitMsg := ""
+		for _, c := range req.Commits {
+			if c.Id == req.After {
+				found = true
+				commitMsg = c.Message
+				break
 			}
 		}
-		if err := s.st.CreateCommit(req.Repository.Name, req.After, "OK"); err != nil {
+		if !found {
+			fmt.Printf("Error: could not find commit message")
+			return
+		}
+		if err := s.updateDodoApp(instanceAppStatus, req.Repository.Name, s.appConfigs[req.Repository.Name].Namespace, networks); err != nil {
+			if err := s.st.CreateCommit(req.Repository.Name, req.After, commitMsg, err.Error()); err != nil {
+				fmt.Printf("Error: %s\n", err.Error())
+			}
+			return
+		}
+		if err := s.st.CreateCommit(req.Repository.Name, req.After, commitMsg, "OK"); err != nil {
 			fmt.Printf("Error: %s\n", err.Error())
 		}
 		for addr, _ := range s.workers[req.Repository.Name] {
diff --git a/core/installer/welcome/store.go b/core/installer/welcome/store.go
index 8ea0860..031cdff 100644
--- a/core/installer/welcome/store.go
+++ b/core/installer/welcome/store.go
@@ -19,6 +19,7 @@
 
 type Commit struct {
 	Hash    string
+	Status  string
 	Message string
 }
 
@@ -30,7 +31,7 @@
 	GetUserApps(username string) ([]string, error)
 	CreateApp(name, username string) error
 	GetAppOwner(name string) (string, error)
-	CreateCommit(name, hash, message string) error
+	CreateCommit(name, hash, message, status string) error
 	GetCommitHistory(name string) ([]Commit, error)
 }
 
@@ -61,7 +62,8 @@
 		CREATE TABLE IF NOT EXISTS commits (
 			app_name TEXT,
             hash TEXT,
-            message TEXT
+            message TEXT,
+            status TEXT
 		);
 	`)
 	return err
@@ -172,14 +174,14 @@
 	return ret, nil
 }
 
-func (s *storeImpl) CreateCommit(name, hash, message string) error {
-	query := `INSERT INTO commits (app_name, hash, message) VALUES (?, ?, ?)`
-	_, err := s.db.Exec(query, name, hash, message)
+func (s *storeImpl) CreateCommit(name, hash, message, status string) error {
+	query := `INSERT INTO commits (app_name, hash, message, status) VALUES (?, ?, ?, ?)`
+	_, err := s.db.Exec(query, name, hash, message, status)
 	return err
 }
 
 func (s *storeImpl) GetCommitHistory(name string) ([]Commit, error) {
-	query := `SELECT hash, message FROM commits WHERE app_name = ?`
+	query := `SELECT hash, message, status FROM commits WHERE app_name = ?`
 	rows, err := s.db.Query(query, name)
 	if err != nil {
 		return nil, err
@@ -191,7 +193,7 @@
 			return nil, err
 		}
 		var c Commit
-		if err := rows.Scan(&c.Hash, &c.Message); err != nil {
+		if err := rows.Scan(&c.Hash, &c.Message, &c.Status); err != nil {
 			return nil, err
 		}
 		ret = append(ret, c)