npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@premieroctet/directus-extension-sql-panel

v0.4.4

Published

A custom interface for Directus that allows you to display result of your SQL queries in a table.

Downloads

35

Readme

SQL Panel - Directus extension

This is a custom interface for Directus that allows you to display result of your SQL queries in a table.

Installation

npm install @premieroctet/directus-extension-sql-panel

or using yarn :

yarn add @premieroctet/directus-extension-sql-panel

You should be set to go, Directus will automatically detect the extension.

Usage

How to use the extension in your Directus project ?

  • Add a new SQL Panel field to a data model (or edit an existing one)
  • Fill out the field settings with your SQL query and some other options (see below)
  • Save the field settings
  • Enjoy ! 🎉

🧪 Example of usage

Let's say you're building a back-office to manage movies / actors and credits. You might want to display a list cast and crew of a movie in the movie's detail page.

Example of usage

To do so, you can create a new SQL Panel field in the movies data model, and fill out the settings with the following SQL query:

SELECT
persons.id,
persons.name,
role
FROM credits
LEFT JOIN persons ON person = persons.id
WHERE movie = $entityId;

Here we're using the $entityId variable to get the current movie's id. It's part of our API and is automatically replaced by the current entity's id.

We'll now fill out the columns settings. For each column, you can specify:

Example of settings top Example of settings bottom

We save the field settings and we're done ! 🎉

📚 Documentation

Column types

We currently support the following column types:

Text

A simple text field, value is displayed as is.

Date

A date field, value is displayed as a date (format: YYYY-MM-DD).

Date time

A date time field, value is displayed as a date time (format: YYYY-MM-DD at HH:mm PM/AM).

Ressource ID

A ressource ID field, value is displayed as a link to the ressource's detail page. When the user clicks on the row, it will be redirected to the ressource's detail page. You need to specify the ressource's name in the ressource field settings. We recommend set the width of this column to 0 so it's not displayed and the row is still clickable.

⚠️ You can only use this type once per query as it will make the entiere row clickable.

List of options

List of options settings

A list of options to be displayed according to the value. You need to specify the list of options in the list of options field settings. For each option, you need to specify:

  • The option's value
  • The option's label and optionally:
  • The option's color (hexadecimal value)

Option settings