settings.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package pages
  2. import (
  3. "log"
  4. "github.com/qor5/ui/cropper"
  5. . "github.com/qor5/ui/vuetify"
  6. "github.com/qor5/web"
  7. "github.com/qor5/admin/media"
  8. "github.com/qor5/admin/media/media_library"
  9. media_view "github.com/qor5/admin/media/views"
  10. "github.com/qor5/admin/richeditor"
  11. h "github.com/theplant/htmlgo"
  12. "gorm.io/gorm"
  13. )
  14. func Settings(db *gorm.DB) web.PageFunc {
  15. return func(ctx *web.EventContext) (r web.PageResponse, err error) {
  16. r.PageTitle = "Settings"
  17. r.Body = h.Div(
  18. VContainer(
  19. VRow(
  20. VCol(
  21. h.H1("Example of use QMediaBox in any page").Class("text-h5 pt-4 pl-2"),
  22. media_view.QMediaBox(db).
  23. FieldName("test").
  24. Value(&media_library.MediaBox{}).
  25. Config(&media_library.MediaBoxConfig{
  26. AllowType: "image",
  27. Sizes: map[string]*media.Size{
  28. "thumb": {
  29. Width: 400,
  30. Height: 300,
  31. },
  32. "main": {
  33. Width: 800,
  34. Height: 500,
  35. },
  36. },
  37. }),
  38. ).Cols(6),
  39. ),
  40. VRow(
  41. VCol(
  42. richeditor.RichEditor(db, "Body").Plugins([]string{"alignment", "video", "table", "imageinsert"}).Value(`<p>Could you do an actual logo instead of a font I cant pay you? Can we try some other colors maybe? I cant pay you. You might wanna give it another shot, so make it pop and this is just a 5 minutes job the target audience makes and families aged zero and up will royalties in the company do instead of cash.</p>
  43. <p>Jazz it up a little I was wondering if my cat could be placed over the logo in the flyer I have printed it out, but the animated gif is not moving I have printed it out, but the animated gif is not moving make it original. Can you make it stand out more? Make it original.</p>`).Label("Body").Placeholder("Place Holder"),
  44. ),
  45. ),
  46. VRow(
  47. cropper.Cropper().
  48. Src("https://agontuk.github.io/assets/images/berserk.jpg").
  49. Value(cropper.Value{X: 1141, Y: 540, Width: 713, Height: 466}).
  50. AspectRatio(713, 466).
  51. Attr("@input", web.Plaid().
  52. FieldValue("CropperEvent", web.Var("JSON.stringify($event)")).EventFunc(LogInfoEvent).Go()),
  53. ),
  54. ).Fluid(true),
  55. )
  56. return
  57. }
  58. }
  59. const LogInfoEvent = "logInfo"
  60. func LogInfo(ctx *web.EventContext) (r web.EventResponse, err error) {
  61. log.Println("CropperEvent", ctx.R.FormValue("CropperEvent"))
  62. return
  63. }