567 lines
17 KiB
Go
567 lines
17 KiB
Go
// Copyright (c) 2026 Jose Cely <me@jacs.guru>
|
|
// Use of this source code is governed by MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package controllers
|
|
|
|
import (
|
|
"html/template"
|
|
|
|
"git.smarteching.com/goffee/core"
|
|
)
|
|
|
|
// TablerDemo1 renders a Tabler-themed demo page
|
|
func TablerDemo1(c *core.Context) *core.Response {
|
|
|
|
// first, include compoment
|
|
type templateData struct {
|
|
Content template.HTML
|
|
}
|
|
// Build the template data
|
|
data := templateData{
|
|
// The main page content (rendered HTML)
|
|
Content: template.HTML("<h2>Hola mundo</h2>"),
|
|
}
|
|
|
|
return c.Response.Template("tabler_demo.html", data)
|
|
}
|
|
|
|
// TablerSingle renders a page using the single layout (centered page with logo)
|
|
func TablerSingle(c *core.Context) *core.Response {
|
|
data := TablerPageData{
|
|
PageTitle: "Tabler Single",
|
|
PageDescription: "A single centered page",
|
|
Content: template.HTML("<div class=\"card card-md\"><div class=\"card-body\"><h2 class=\"card-title text-center mb-4\">Login</h2><p class=\"text-secondary mb-4\">Enter your credentials to access your account.</p></div></div>"),
|
|
}
|
|
return c.Response.Template("tabler_single.html", data)
|
|
}
|
|
|
|
// TablerDefault renders a page using the default layout (with navbar, page header, footer)
|
|
func TablerDefault(c *core.Context) *core.Response {
|
|
data := TablerPageData{
|
|
PageTitle: "Tabler Default",
|
|
PageDescription: "A default page layout",
|
|
Sidebar: false,
|
|
ShowTopbar: true,
|
|
PageHeader: "Default Page",
|
|
PagePretitle: "Overview",
|
|
UserName: "Jane Doe",
|
|
UserRole: "Administrator",
|
|
Content: template.HTML("<div class=\"card\"><div class=\"card-body\"><h3 class=\"card-title\">Content Area</h3><p>This is the main content area of the default page layout.</p></div></div>"),
|
|
}
|
|
return c.Response.Template("tabler_default.html", data)
|
|
}
|
|
|
|
// TablerNavbar renders a page using the default layout (with navbar, navbarmenu, page header, footer)
|
|
func TablerNavbar(c *core.Context) *core.Response {
|
|
data := TablerPageData{
|
|
PageTitle: "Navbar Menu Demo",
|
|
PageDescription: "Sample page with navbar menu",
|
|
ShowTopbar: true,
|
|
Sidebar: false,
|
|
PageHeader: "Navbar Menu Demo",
|
|
PagePretitle: "Components",
|
|
UserName: "Jane Doe",
|
|
UserRole: "Administrator",
|
|
NavbarMenu: SampleNavbarMenu(),
|
|
Content: template.HTML("<div class=\"card\"><div class=\"card-body\"><h3 class=\"card-title\">Navbar Menu Example</h3><p>This page demonstrates the navbar menu component migrated from the Liquid template. The menu items (Dashboards, Layout, Help) are rendered from sample data.</p></div></div>"),
|
|
}
|
|
return c.Response.Template("tabler_default.html", data)
|
|
}
|
|
|
|
// TablerComponents renders a page with alerts, breadcrumbs, and toasts.
|
|
// Uses the composition pattern: embeds TablerPageData and adds Components.
|
|
func TablerComponents(c *core.Context) *core.Response {
|
|
type componentsPageData struct {
|
|
TablerPageData
|
|
Components FormtablerComponentsPage
|
|
}
|
|
data := componentsPageData{
|
|
TablerPageData: TablerPageData{
|
|
PageTitle: "UI Components",
|
|
PageDescription: "Alerts, breadcrumbs and toasts demo",
|
|
ShowTopbar: true,
|
|
Sidebar: false,
|
|
PageHeader: "Components",
|
|
PagePretitle: "UI Elements",
|
|
UserName: "Jane Doe",
|
|
UserRole: "Administrator",
|
|
NavbarMenu: SampleNavbarMenu(),
|
|
Content: template.HTML(""),
|
|
},
|
|
Components: SampleComponents(),
|
|
}
|
|
return c.Response.Template("tabler_components.html", data)
|
|
}
|
|
|
|
// TablerCards renders a page with card component demos.
|
|
// Uses the composition pattern: embeds TablerPageData and adds Cards.
|
|
func TablerCards(c *core.Context) *core.Response {
|
|
type cardsPageData struct {
|
|
TablerPageData
|
|
Cards []FormtablerCard
|
|
}
|
|
data := cardsPageData{
|
|
TablerPageData: TablerPageData{
|
|
PageTitle: "Cards",
|
|
PageDescription: "Card component demo page",
|
|
ShowTopbar: true,
|
|
Sidebar: false,
|
|
PageHeader: "Cards",
|
|
PagePretitle: "Components",
|
|
UserName: "Jane Doe",
|
|
UserRole: "Administrator",
|
|
NavbarMenu: SampleNavbarMenu(),
|
|
Content: template.HTML(""),
|
|
},
|
|
Cards: SampleCards(),
|
|
}
|
|
return c.Response.Template("tabler_cards.html", data)
|
|
}
|
|
|
|
// TablerFormElements renders a page with all 25 formtabler form components.
|
|
// Uses the composition pattern: embeds TablerPageData and adds
|
|
// a FormElements field containing all form component data.
|
|
func TablerFormElements(c *core.Context) *core.Response {
|
|
type formelementsPageData struct {
|
|
TablerPageData
|
|
FormElements FormtablerFormElementsPage
|
|
}
|
|
data := formelementsPageData{
|
|
TablerPageData: TablerPageData{
|
|
PageTitle: "Form Elements",
|
|
PageDescription: "Form element demo page",
|
|
ShowTopbar: true,
|
|
Sidebar: false,
|
|
PageHeader: "Form Elements",
|
|
PagePretitle: "Components",
|
|
UserName: "Jane Doe",
|
|
UserRole: "Administrator",
|
|
NavbarMenu: SampleNavbarMenu(),
|
|
Content: template.HTML(""),
|
|
},
|
|
FormElements: SampleFormElements(),
|
|
}
|
|
return c.Response.Template("tabler_formelements.html", data)
|
|
}
|
|
|
|
// TablerTables renders a page with table components.
|
|
// Uses a page-specific struct that embeds TablerPageData and adds the Tables field.
|
|
// The template detects tables via hasField and renders them.
|
|
func TablerTables(c *core.Context) *core.Response {
|
|
type tablesPageData struct {
|
|
TablerPageData
|
|
Tables []TableComponent
|
|
}
|
|
data := tablesPageData{
|
|
TablerPageData: TablerPageData{
|
|
PageTitle: "Tables",
|
|
PageDescription: "Table demo page",
|
|
ShowTopbar: true,
|
|
Sidebar: false,
|
|
PageHeader: "Tables",
|
|
PagePretitle: "Components",
|
|
UserName: "Jane Doe",
|
|
UserRole: "Administrator",
|
|
NavbarMenu: SampleNavbarMenu(),
|
|
Content: template.HTML(""),
|
|
},
|
|
Tables: SampleTables(),
|
|
}
|
|
return c.Response.Template("tabler_tables.html", data)
|
|
}
|
|
|
|
// UserSignIn renders the sign-in page.
|
|
func UserSignIn(c *core.Context) *core.Response {
|
|
type authPageData struct {
|
|
TablerPageData
|
|
}
|
|
data := authPageData{
|
|
TablerPageData: TablerPageData{
|
|
PageTitle: "Sign In",
|
|
},
|
|
}
|
|
return c.Response.Template("apptabler_sign-in.html", data)
|
|
}
|
|
|
|
// UserSignUp renders the sign-up page.
|
|
func UserSignUp(c *core.Context) *core.Response {
|
|
type authPageData struct {
|
|
TablerPageData
|
|
}
|
|
data := authPageData{
|
|
TablerPageData: TablerPageData{
|
|
PageTitle: "Sign Up",
|
|
},
|
|
}
|
|
return c.Response.Template("apptabler_sign-up.html", data)
|
|
}
|
|
|
|
// UserForgot renders the forgot password page.
|
|
func UserForgot(c *core.Context) *core.Response {
|
|
type authPageData struct {
|
|
TablerPageData
|
|
}
|
|
data := authPageData{
|
|
TablerPageData: TablerPageData{
|
|
PageTitle: "Forgot Password",
|
|
},
|
|
}
|
|
return c.Response.Template("apptabler_forgot.html", data)
|
|
}
|
|
|
|
// UserLock renders the account lock page.
|
|
func UserLock(c *core.Context) *core.Response {
|
|
type authLockPageData struct {
|
|
TablerPageData
|
|
PersonName string
|
|
}
|
|
data := authLockPageData{
|
|
TablerPageData: TablerPageData{
|
|
PageTitle: "Account Locked",
|
|
},
|
|
PersonName: "Paweł Kuna",
|
|
}
|
|
return c.Response.Template("apptabler_auth-lock.html", data)
|
|
}
|
|
|
|
// AdminCustomers renders the admin customers listing page.
|
|
func AdminCustomers(c *core.Context) *core.Response {
|
|
type adminCustomersPageData struct {
|
|
TablerPageData
|
|
AdminCustomers AdminCustomersPage
|
|
}
|
|
data := adminCustomersPageData{
|
|
TablerPageData: TablerPageData{
|
|
PageTitle: "Customers",
|
|
PageDescription: "Manage customers",
|
|
ShowTopbar: true,
|
|
Sidebar: false,
|
|
PageHeader: "Customers",
|
|
PagePretitle: "Customer Management",
|
|
UserName: "Jane Doe",
|
|
UserRole: "Administrator",
|
|
NavbarMenu: SampleNavbarMenu(),
|
|
},
|
|
AdminCustomers: AdminCustomersPage{
|
|
Customers: SampleCustomersTable(),
|
|
},
|
|
}
|
|
return c.Response.Template("apptabler_admincustomers.html", data)
|
|
}
|
|
|
|
// AdminUsers renders the admin users listing page.
|
|
func AdminUsers(c *core.Context) *core.Response {
|
|
type adminUsersPageData struct {
|
|
TablerPageData
|
|
AdminUsers AdminUsersPage
|
|
}
|
|
data := adminUsersPageData{
|
|
TablerPageData: TablerPageData{
|
|
PageTitle: "Admin Users",
|
|
PageDescription: "Manage system users",
|
|
ShowTopbar: true,
|
|
Sidebar: false,
|
|
PageHeader: "Admin Users",
|
|
PagePretitle: "User Management",
|
|
UserName: "Jane Doe",
|
|
UserRole: "Administrator",
|
|
NavbarMenu: SampleNavbarMenu(),
|
|
},
|
|
AdminUsers: SampleAdminUsers(),
|
|
}
|
|
return c.Response.Template("apptabler_admin-users.html", data)
|
|
}
|
|
|
|
// UserSettings renders the user settings page.
|
|
func UserSettings(c *core.Context) *core.Response {
|
|
type userSettingsPageData struct {
|
|
TablerPageData
|
|
UserSettings FormtablerUserSettingsPage
|
|
}
|
|
data := userSettingsPageData{
|
|
TablerPageData: TablerPageData{
|
|
PageTitle: "Account Settings",
|
|
PageDescription: "User account settings",
|
|
ShowTopbar: true,
|
|
Sidebar: false,
|
|
PageHeader: "Account Settings",
|
|
PagePretitle: "User Profile",
|
|
UserName: "Jane Doe",
|
|
UserRole: "Administrator",
|
|
NavbarMenu: SampleNavbarMenu(),
|
|
},
|
|
UserSettings: SampleUserSettings(),
|
|
}
|
|
return c.Response.Template("apptabler_usersettings.html", data)
|
|
}
|
|
|
|
// TablerHome renders the homepage/dashboard layout
|
|
func TablerHome(c *core.Context) *core.Response {
|
|
data := TablerPageData{
|
|
PageTitle: "Dashboard",
|
|
PageDescription: "Dashboard home page",
|
|
PageHeader: "Dashboard",
|
|
PagePretitle: "Overview",
|
|
UserName: "Jane Doe",
|
|
UserRole: "Administrator",
|
|
ShowTopbar: true,
|
|
Sidebar: false,
|
|
}
|
|
return c.Response.Template("tabler_homepage.html", data)
|
|
}
|
|
|
|
// DemoForm1 renders the sample contact form using the form generator.
|
|
func DemoForm1(c *core.Context) *core.Response {
|
|
type demoForm1Data struct {
|
|
TablerPageData
|
|
FormDefinition FormtablerFormDefinition
|
|
}
|
|
data := demoForm1Data{
|
|
TablerPageData: TablerPageData{
|
|
PageTitle: "Demo Form 1",
|
|
PageDescription: "Sample contact form generated from JSON definition",
|
|
ShowTopbar: true,
|
|
Sidebar: false,
|
|
PageHeader: "Contact Form",
|
|
PagePretitle: "Demo Form Generator",
|
|
UserName: "Jane Doe",
|
|
UserRole: "Administrator",
|
|
NavbarMenu: SampleNavbarMenu(),
|
|
},
|
|
FormDefinition: FormtablerFormDefinition{
|
|
ID: "contact-form",
|
|
Title: "Contact us",
|
|
SuccessMessage: "Thanks! We'll get back to you soon.",
|
|
Method: "POST",
|
|
Fields: []FormtablerFormField{
|
|
{
|
|
Name: "name",
|
|
Label: "Name",
|
|
Type: "text",
|
|
Required: true,
|
|
Placeholder: "Jane Doe",
|
|
},
|
|
{
|
|
Name: "email",
|
|
Label: "Email",
|
|
Type: "email",
|
|
Required: true,
|
|
Placeholder: "jane@example.com",
|
|
},
|
|
{
|
|
Name: "phone",
|
|
Label: "Phone",
|
|
Type: "phone",
|
|
Required: false,
|
|
Placeholder: "+1 555 000 0000",
|
|
},
|
|
{
|
|
Name: "message",
|
|
Label: "Message",
|
|
Type: "textarea",
|
|
Required: true,
|
|
Placeholder: "How can we help?",
|
|
MaxLength: 1000,
|
|
},
|
|
},
|
|
},
|
|
}
|
|
return c.Response.Template("apptabler_demoform.html", data)
|
|
}
|
|
|
|
// DemoForm2 renders an advanced form using all available field types.
|
|
func DemoForm2(c *core.Context) *core.Response {
|
|
type demoForm2Data struct {
|
|
TablerPageData
|
|
FormDefinition FormtablerFormDefinition
|
|
}
|
|
data := demoForm2Data{
|
|
TablerPageData: TablerPageData{
|
|
PageTitle: "Demo Form 2",
|
|
PageDescription: "Advanced form with all field types",
|
|
ShowTopbar: true,
|
|
Sidebar: false,
|
|
PageHeader: "Advanced Registration Form",
|
|
PagePretitle: "Demo Form Generator",
|
|
UserName: "Jane Doe",
|
|
UserRole: "Administrator",
|
|
NavbarMenu: SampleNavbarMenu(),
|
|
},
|
|
FormDefinition: FormtablerFormDefinition{
|
|
ID: "advanced-registration",
|
|
Title: "User Registration",
|
|
SuccessMessage: "Registration submitted successfully! We'll review your application.",
|
|
Method: "POST",
|
|
Columns: 3,
|
|
FieldsetTitle: "Personal Information",
|
|
FieldsetDescription: "Please fill in all required fields marked with an asterisk (*).",
|
|
Fields: []FormtablerFormField{
|
|
{
|
|
Name: "first_name",
|
|
Label: "First Name",
|
|
Type: "text",
|
|
Required: true,
|
|
Placeholder: "John",
|
|
MinLength: 2,
|
|
MaxLength: 50,
|
|
Autofocus: true,
|
|
},
|
|
{
|
|
Name: "last_name",
|
|
Label: "Last Name",
|
|
Type: "text",
|
|
Required: true,
|
|
Placeholder: "Doe",
|
|
MinLength: 2,
|
|
MaxLength: 50,
|
|
},
|
|
{
|
|
Name: "email",
|
|
Label: "Email Address",
|
|
Type: "email",
|
|
Required: true,
|
|
Placeholder: "john.doe@example.com",
|
|
},
|
|
{
|
|
Name: "phone",
|
|
Label: "Phone Number",
|
|
Type: "phone",
|
|
Required: true,
|
|
Placeholder: "+1 (555) 000-0000",
|
|
HelpText: "Include country code for international numbers.",
|
|
},
|
|
{
|
|
Name: "account_type",
|
|
Label: "Account Type",
|
|
Type: "select",
|
|
Required: true,
|
|
Options: []FormtablerFormFieldOption{
|
|
{Label: "Personal", Value: "personal", Selected: true},
|
|
{Label: "Business", Value: "business"},
|
|
{Label: "Enterprise", Value: "enterprise"},
|
|
},
|
|
},
|
|
{
|
|
Name: "password",
|
|
Label: "Password",
|
|
Type: "password",
|
|
Required: true,
|
|
Placeholder: "••••••••",
|
|
MinLength: 8,
|
|
MaxLength: 128,
|
|
HelpText: "At least 8 characters with uppercase, lowercase and numbers.",
|
|
},
|
|
{
|
|
Name: "company",
|
|
Label: "Company Name",
|
|
Type: "text",
|
|
Placeholder: "Acme Inc.",
|
|
HelpText: "Only required for Business and Enterprise accounts.",
|
|
},
|
|
{
|
|
Name: "website",
|
|
Label: "Website",
|
|
Type: "url",
|
|
Placeholder: "https://example.com",
|
|
},
|
|
{
|
|
Name: "bio",
|
|
Label: "Biography",
|
|
Type: "textarea",
|
|
Placeholder: "Tell us about yourself...",
|
|
MaxLength: 500,
|
|
HelpText: "Maximum 500 characters.",
|
|
},
|
|
{
|
|
Name: "birth_date",
|
|
Label: "Date of Birth",
|
|
Type: "date",
|
|
},
|
|
{
|
|
Name: "preferred_language",
|
|
Label: "Preferred Language",
|
|
Type: "select",
|
|
Options: []FormtablerFormFieldOption{
|
|
{Label: "English", Value: "en", Selected: true},
|
|
{Label: "Spanish", Value: "es"},
|
|
{Label: "French", Value: "fr"},
|
|
{Label: "German", Value: "de"},
|
|
{Label: "Japanese", Value: "ja"},
|
|
{Label: "Chinese", Value: "zh"},
|
|
},
|
|
},
|
|
{
|
|
Name: "experience_level",
|
|
Label: "Experience Level",
|
|
Type: "radio",
|
|
Required: true,
|
|
Options: []FormtablerFormFieldOption{
|
|
{Label: "Beginner", Value: "beginner", Checked: true},
|
|
{Label: "Intermediate", Value: "intermediate"},
|
|
{Label: "Advanced", Value: "advanced"},
|
|
{Label: "Expert", Value: "expert"},
|
|
},
|
|
},
|
|
{
|
|
Name: "skills",
|
|
Label: "Skills & Technologies",
|
|
Type: "checkbox",
|
|
HelpText: "Select all that apply.",
|
|
Options: []FormtablerFormFieldOption{
|
|
{Label: "Go", Value: "go", Checked: true},
|
|
{Label: "JavaScript", Value: "javascript", Checked: true},
|
|
{Label: "Python", Value: "python"},
|
|
{Label: "Rust", Value: "rust"},
|
|
{Label: "Docker", Value: "docker"},
|
|
{Label: "Kubernetes", Value: "kubernetes"},
|
|
{Label: "PostgreSQL", Value: "postgresql"},
|
|
{Label: "Redis", Value: "redis"},
|
|
},
|
|
},
|
|
{
|
|
Name: "notifications",
|
|
Label: "Email Notifications",
|
|
Type: "toggle",
|
|
HelpText: "Receive updates about new features and security alerts.",
|
|
},
|
|
{
|
|
Name: "website_color",
|
|
Label: "Preferred Accent Color",
|
|
Type: "color",
|
|
Value: "#206bc4",
|
|
},
|
|
{
|
|
Name: "priority_level",
|
|
Label: "Priority Level",
|
|
Type: "range",
|
|
Min: 1,
|
|
Max: 10,
|
|
Step: 1,
|
|
Value: "5",
|
|
HelpText: "1 = Lowest priority, 10 = Highest priority",
|
|
},
|
|
{
|
|
Name: "agree_terms",
|
|
Label: "I agree to the Terms of Service and Privacy Policy",
|
|
Type: "checkbox",
|
|
Required: true,
|
|
},
|
|
{
|
|
Name: "marketing_consent",
|
|
Label: "I would like to receive marketing communications",
|
|
Type: "toggle",
|
|
},
|
|
{
|
|
Name: "csrf_token",
|
|
Type: "hidden",
|
|
Value: "abc123xyz",
|
|
},
|
|
},
|
|
SubmitText: "Create Account",
|
|
ShowReset: true,
|
|
ResetText: "Clear All",
|
|
},
|
|
}
|
|
return c.Response.Template("apptabler_demoform.html", data)
|
|
}
|