2024-09-12 19:15:38 -04:00
|
|
|
// Copyright 2023 Harran Ali <harran.m@gmail.com>. All rights reserved.
|
|
|
|
// Copyright (c) 2024 Zeni Kim <zenik@smarteching.com>
|
|
|
|
// Use of this source code is governed by MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2024-09-15 15:05:45 -04:00
|
|
|
package controllers
|
2024-09-12 19:15:38 -04:00
|
|
|
|
|
|
|
import (
|
2024-09-28 13:30:49 -04:00
|
|
|
"os"
|
|
|
|
"strconv"
|
|
|
|
|
2024-09-12 19:15:38 -04:00
|
|
|
"git.smarteching.com/goffee/core"
|
2024-09-28 13:30:49 -04:00
|
|
|
"git.smarteching.com/goffee/core/template/components"
|
2024-09-12 19:15:38 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// Show home page
|
|
|
|
func WelcomeHome(c *core.Context) *core.Response {
|
2024-09-28 13:30:49 -04:00
|
|
|
|
|
|
|
// check if template engine is enable
|
|
|
|
TemplateEnableStr := os.Getenv("TEMPLATE_ENABLE")
|
|
|
|
if TemplateEnableStr == "" {
|
|
|
|
TemplateEnableStr = "false"
|
|
|
|
}
|
|
|
|
TemplateEnable, _ := strconv.ParseBool(TemplateEnableStr)
|
|
|
|
|
|
|
|
if TemplateEnable {
|
|
|
|
type templateData struct {
|
|
|
|
TheTitle components.Title
|
|
|
|
}
|
|
|
|
tmplData := templateData{
|
|
|
|
TheTitle: components.Title{
|
|
|
|
Label: "Welcome to Goffee",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
return c.Response.Template("basic.html", tmplData)
|
|
|
|
} else {
|
|
|
|
message := "{\"message\": \"Welcome to Goffee\"}"
|
|
|
|
return c.Response.Json(message)
|
|
|
|
}
|
|
|
|
|
2024-09-12 19:15:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Show dashboard
|
|
|
|
func WelcomeToDashboard(c *core.Context) *core.Response {
|
|
|
|
message := "{\"message\": \"Welcome to Dashboard\"}"
|
|
|
|
return c.Response.Json(message)
|
|
|
|
}
|