Skip to content

Commit

Permalink
Show flash message on object save and delete
Browse files Browse the repository at this point in the history
  • Loading branch information
diamondap committed Dec 7, 2023
1 parent afb8db9 commit 88f85eb
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
- [ ] Implement upload-only jobs.
- [ ] Context-sensitive help
- [x] Autofill other properties on job package page (e.g. if profile only allows tar, autoselect tar as serialization format)
- [ ] Show flash confirmation message on successful save and delete
- [x] Show flash confirmation message on successful save and delete
- [ ] BUG - Job Metadata page won't load if packaging format is not BagIt

## Later
Expand Down
3 changes: 3 additions & 0 deletions server/controllers/app_settings_controller.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package controllers

import (
"fmt"
"net/http"

"github.com/APTrust/dart-runner/core"
Expand All @@ -20,6 +21,7 @@ func AppSettingDelete(c *gin.Context) {
AbortWithErrorHTML(c, http.StatusInternalServerError, err)
return
}
SetFlashCookie(c, fmt.Sprintf("Deleted app setting %s", request.QueryResult.AppSetting()))
c.Redirect(http.StatusFound, "/app_settings")
}

Expand Down Expand Up @@ -74,5 +76,6 @@ func AppSettingSave(c *gin.Context) {
c.HTML(http.StatusBadRequest, "app_setting/form.html", data)
return
}
SetFlashCookie(c, fmt.Sprintf("Saved setting %s", setting.Name))
c.Redirect(http.StatusFound, "/app_settings")
}
1 change: 1 addition & 0 deletions server/controllers/bagit_profiles_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func BagItProfileDelete(c *gin.Context) {
"status": "OK",
"location": "/profiles",
}
SetFlashCookie(c, fmt.Sprintf("Deleted BagIt Profile %s", result.BagItProfile().Name))
c.JSON(http.StatusOK, data)
}

Expand Down
2 changes: 1 addition & 1 deletion server/controllers/cookies.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

func SetFlashCookie(c *gin.Context, message string) {
c.SetCookie(constants.FlashCookieName, message, 5, "/", "localhost", false, false)
c.SetCookie(constants.FlashCookieName, message, 2, "/", "localhost", false, false)
}

func GetFlashCookie(c *gin.Context) string {
Expand Down
2 changes: 1 addition & 1 deletion server/controllers/jobs_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func JobDelete(c *gin.Context) {
AbortWithErrorHTML(c, http.StatusInternalServerError, deletionErr)
return
}
SetFlashCookie(c, fmt.Sprintf("Job %s was deleted.", result.Job().Name()))
SetFlashCookie(c, fmt.Sprintf("Deleted job %s.", result.Job().Name()))
c.Redirect(http.StatusFound, "/jobs")
}

Expand Down
3 changes: 2 additions & 1 deletion server/controllers/remote_repositories_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ func RemoteRepositoryDelete(c *gin.Context) {
AbortWithErrorHTML(c, http.StatusInternalServerError, err)
return
}
SetFlashCookie(c, fmt.Sprintf("Deleted remote repo %s", request.QueryResult.RemoteRepository().Name))
c.Redirect(http.StatusFound, "/remote_repositories")

}

// GET /remote_repositories/edit/:id
Expand Down Expand Up @@ -78,6 +78,7 @@ func RemoteRepositorySave(c *gin.Context) {
c.HTML(http.StatusBadRequest, "remote_repository/form.html", data)
return
}
SetFlashCookie(c, "Remote repo settings saved.")
c.Redirect(http.StatusFound, "/remote_repositories")
}

Expand Down
1 change: 1 addition & 0 deletions server/controllers/settings_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func SettingsExportDelete(c *gin.Context) {
AbortWithErrorHTML(c, http.StatusInternalServerError, err)
return
}
SetFlashCookie(c, fmt.Sprintf("Deleted settings %s", exportSettings.Name))
c.Redirect(http.StatusFound, "/settings/export")
}

Expand Down
4 changes: 3 additions & 1 deletion server/controllers/storage_services_controller.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package controllers

import (
"fmt"
"net/http"

"github.com/APTrust/dart-runner/core"
Expand All @@ -20,8 +21,8 @@ func StorageServiceDelete(c *gin.Context) {
AbortWithErrorHTML(c, http.StatusInternalServerError, err)
return
}
SetFlashCookie(c, fmt.Sprintf("Deleted storage service %s", request.QueryResult.StorageService().Name))
c.Redirect(http.StatusFound, "/storage_services")

}

// GET /storage_services/edit/:id
Expand Down Expand Up @@ -77,6 +78,7 @@ func StorageServiceSave(c *gin.Context) {
c.HTML(http.StatusBadRequest, "storage_service/form.html", data)
return
}
SetFlashCookie(c, fmt.Sprintf("Saved storage service %s", ss.Name))
c.Redirect(http.StatusFound, "/storage_services")
}

Expand Down
3 changes: 2 additions & 1 deletion server/controllers/workflows_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func WorkflowDelete(c *gin.Context) {
AbortWithErrorHTML(c, http.StatusNotFound, err)
return
}
SetFlashCookie(c, fmt.Sprintf("Deleted workflow %s", result.Workflow().Name))
c.Redirect(http.StatusFound, "/workflows")
}

Expand Down Expand Up @@ -126,8 +127,8 @@ func WorkflowSave(c *gin.Context) {
c.HTML(http.StatusBadRequest, "workflow/form.html", data)
return
}
SetFlashCookie(c, fmt.Sprintf("Saved workflow %s", workflow.Name))
c.Redirect(http.StatusFound, "/workflows")

}

// GET /workflows/export/:id
Expand Down

0 comments on commit 88f85eb

Please sign in to comment.