admin

package module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2024 License: Apache-2.0 Imports: 1 Imported by: 2

README

Go Advanced Admin

A Highly Customizable Advanced Admin Panel for Go.

Go Report Card Go Go.Dev reference

Go Advanced Admin is a powerful and highly customizable admin panel for Go applications. It allows developers to quickly create admin interfaces with minimal configuration, supporting multiple web frameworks and ORMs.

Features

  • Framework Agnostic: Compatible with popular Go web frameworks like Gin, Echo, Chi, Fiber, and more.
  • ORM Support: Integrates seamlessly with ORMs such as GORM, XORM, SQLX, Bun, etc.
  • Customizable Templates: Override default templates or create your own for complete control over the admin UI.
  • Fine-Grained Permissions: Implement custom permission schemes (role-based, attribute-based) for robust access control.
  • Extensible: Easily extend functionality with custom modules, themes, and widgets.
  • Logging: Configurable logging system with support for custom log stores.

Installation

Add the module to your project by running:

go get github.com/go-advanced-admin/admin

Documentation

For detailed documentation, quick start guides, and advanced topics, please visit the official documentation website.

Quick Start

Here's a minimal example to get you started:

package main

import (
    "github.com/go-advanced-admin/admin"
    "github.com/go-advanced-admin/web-echo"
    "github.com/go-advanced-admin/orm-gorm"
    "github.com/labstack/echo/v4"
    "gorm.io/driver/sqlite"
    "gorm.io/gorm"
)

func main() {
    // Initialize Echo
    e := echo.New()

    // Initialize GORM
    db, err := gorm.Open(sqlite.Open("test.db"), &gorm.Config{})
    if err != nil {
        panic("failed to connect database")
    }

    // Initialize the admin panel
    webIntegrator := adminecho.NewIntegrator(e.Group("/admin"))
    ormIntegrator := admingorm.NewIntegrator(db)
    permissionFunc := func(req admin.PermissionRequest, ctx interface{}) (bool, error) {
        return true, nil // Implement your permission logic here
    }

    panel, err := admin.NewPanel(ormIntegrator, webIntegrator, permissionFunc, nil)
    if err != nil {
        panic(err)
    }

    // Register your models
    app, err := panel.RegisterApp("MainApp", "Main Application", nil)
    if err != nil {
        panic(err)
    }

    _, err = app.RegisterModel(&YourModel{}, nil)
    if err != nil {
        panic(err)
    }

    // Start the server
    e.Logger.Fatal(e.Start(":8080"))
}

For more detailed examples and configuration options, please refer to the official documentation.

Contributing

Contributions are always welcome! If you're interested in contributing to the project, please take a look at our Contributing Guidelines for guidelines on how to get started. We appreciate your help in improving the library!

Special thank you to the current maintainers:

License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

DefaultConfig provides default configuration settings for the admin panel.

NewPanel creates a new admin panel with the given ORM integrator, web integrator, permission function, and configuration.

Functions

This section is empty.

Types

type App

type App = adminpanel.App

App represents an application within the admin panel, grouping related models together.

type Config

type Config = adminpanel.AdminConfig

Config holds configuration settings for the admin panel.

type HandlerFunc

type HandlerFunc = adminpanel.HandlerFunc

HandlerFunc represents a handler function used in the admin panel routes.

type ORMIntegrator

type ORMIntegrator = adminpanel.ORMIntegrator

ORMIntegrator defines the interface for ORM integrations with the admin panel.

type Panel

type Panel = adminpanel.AdminPanel

Panel represents the admin panel, which manages apps, models, and permissions.

type PermissionFunc

type PermissionFunc = adminpanel.PermissionFunc

PermissionFunc defines a function type for checking permissions in the admin panel.

type PermissionRequest

type PermissionRequest = adminpanel.PermissionRequest

PermissionRequest represents a request for permission to perform an action in the admin panel.

type TemplateRenderer

type TemplateRenderer = adminpanel.TemplateRenderer

TemplateRenderer defines the interface for rendering templates in the admin panel.

type WebIntegrator

type WebIntegrator = adminpanel.WebIntegrator

WebIntegrator defines the interface for web framework integrations with the admin panel.

Directories

Path Synopsis
example module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL