OLSPanel Plugin / Module Development Guide

This guide explains how to create a new module (plugin) for OLSPanel using the Django framework. Each module can extend user and admin dashboards with its own functionality.

1. Folder Structure

All modules are stored inside the modules/ directory of OLSPanel.so you can visit you module by using url https://yorip:port/module/your_module

/usr/local/lsws/Example/html/mypanel/modules/
  your_module/
    ├── __init__.py
    ├── views.py
    ├── urls.py
    └── templates/
        └── your_module/
            ├── home.html
            ├── userlist.html
            ├── home_right.html
            └── admin_home_top.html
    
  • home_right.html — displayed on the user panel right side.
  • admin_home_top.html — displayed on the top section of the admin dashboard.

2. Django View Example

Each module can include its own Django views. Example:

from django.shortcuts import render
from django.contrib.auth.decorators import login_required

@login_required
def home(request):
    # Your module logic here
    data = {
        "title": "My Plugin",
        "message": "This is an example plugin for OLSPanel."
    }
    return render(request, "your_module/home_right.html", data)

3. home_right.html Example

This template appears on the user dashboard (right side area).

<div class="bottom-border_right">
  <div class="infotitle">Example Plugin</div>
  <div class="infovalue">Hello, {{ request.user.username }}!</div>
</div>

4. admin_home_top.html Example

This file shows module info on the admin dashboard.

<div class="admin-widget">
  <h4>My Plugin Statistics</h4>
  <p>Total Databases: {{ total_dbs }}</p>
</div>

5. URL Configuration

Each module may include its own urls.py file:

from django.urls import path
from . import views

urlpatterns = [
    path("home/", views.home, name="your_module_home"),
]

6. Loading Modules in OLSPanel

OLSPanel automatically scans all modules under modules/ that include home_right.html and admin_home_top.html.

For example, the user dashboard may use:

{% raw %}
{% for module in modules %}
  {% include module.path_home_right %}
{% endfor %}
{% endraw %}
Note: Your module templates must follow OLSPanel’s CSS naming conventions to prevent style conflicts.

🔐 Admin & User Login Decorators

In OLSPanel Django modules, access control is handled using two key decorators: @alogin_required and @login_required. These ensure that only authorized users can access specific views.

1️⃣ @alogin_required — Admin Authentication

This decorator is used when a view or page should only be accessible to administrators. It checks whether an admin user session is active. If not, it redirects the visitor to the admin login page.


from mypanel.decorators import alogin_required

@alogin_required
def admin_dashboard(request):
    # Admin-only dashboard view
    return render(request, "admin_home_top.html")
  

Example use: Admin panels, server management pages, or module settings that only the root user should modify.

2️⃣ @login_required — User Authentication

This decorator is used for regular user pages in the user panel. It ensures the user has logged in before accessing their module dashboard or account page.


from mypanel.decorators import login_required

@login_required
def user_dashboard(request):
    # Logged-in user dashboard view
    return render(request, "home_right.html")
  

Example use: User databases, backups, or app management modules.

💡 Tip: Always import decorators from mypanel.decorators to ensure compatibility with OLSPanel’s built-in session system.

7. Example Module Output

Once created, your module will appear like this in the OLSPanel interface:

  • User Panel → Right-side info widget
  • Admin Panel → Top dashboard summary

Display Links

The system automatically detects plugin links from JSON files placed inside the plugin/ directory. Each file must have a .json extension — for example, wordpress_link.json or cms_links.json.

Every JSON file can contain either:

  • Single object — one plugin link definition
  • Array of objects — multiple plugin links in one file
The system automatically handles both formats.

✅ Example JSON (multiple plugin entries)

[
  {
    "icon": "/media/icon/wordpress.png",
    "order": -1,
    "name": "Install WordPress",
    "url": "/3rdparty/olsapp/indexb.live.php?view=install&app=wordpress",
    "features": "database",
    "service": "user_panel",
    "target": "_blank"
  },
  {
    "icon": "/media/icon/joomla.png",
    "order": 1,
    "name": "Install Joomla",
    "url": "/3rdparty/olsapp/indexb.live.php?view=install&app=joomla",
    "features": "database",
    "service": "user_panel",
    "target": "_blank"
  }
]

You can also use a single plugin entry file, for example:

{
  "icon": "/media/icon/php.svg",
  "order": 10,
  "name": "PHP Info",
  "url": "/phpinfo/",
  "features": "system",
  "service": "admin_panel",
  "target": "_self"
}

The following fields are supported:

  • name — Display name of the plugin link
  • icon — Icon URL or path shown in the panel
  • url — Full or relative link target
  • order — Sort order (lower numbers appear first)
  • features — Optional feature tag (e.g. database, system)
  • service — Optional service scope (admin_panel, user_panel, or both)
  • target — Optional link target (e.g. _blank for new tab)
  • display_hide — If set to true, the plugin will be hidden

📁 Example Directory Structure


plugin/
├── cms_links.json
├── wordpress_link.json
├── custom_admin.json
  

The system automatically loads and merges all valid JSON files from this directory. Each file is read only once, and hidden entries (display_hide=true) are skipped.

Example Module of postgresql

You can download

👉 postgresql module

This help to you how build: