仪表盘 Dashboards

Insights 模块中的仪表板将不同的面板组织成一目了然的视图。 它们可用于根据部门、目标、业务流程或您选择的任何内容对数据进行分组。

The Dashboard Object

id uuid
仪表板的主键。

name string
仪表板的名称。

icon string
仪表板的材料图标。

note string
有关仪表板的描述性文本。

date_created Date
创建仪表板时

user_created many-to-one
创建仪表板的用户。 多对一到 users

color string
仪表板的强调色。

panels one-to-many
此仪表板中的面板。 一对一到 panels

json
{
  "id": "a79bd1b2-beb2-49fc-8a26-0b3eec0e2697",
  "name": "My Dashboard",
  "icon": "dashboard",
  "note": "Test",
  "date_created": "2023-01-05T19:03:15.051Z",
  "user_created": "fd066644-c8e5-499d-947b-fe6c6e1a1473",
  "color": "#6644FF",
  "panels": ["22640672-eef0-4ee9-ab04-591f3afb2883"]
}

List Dashboards

列出 Directus 中存在的所有仪表板。

Query Parameters

支持所有全局查询参数

Returns

最多 limit 仪表板对象 的数组。 如果没有项目可用,数据将是一个空数组。

REST API

GET /dashboards
SEARCH /dashboards

Learn more about SEARCH ->

GraphQL

POST /graphql/system
graphql
type Query {
 dashboards: [directus_dashboards]
}
Example
graphql
query {
 dashboards {
  id
  name
 }
}

Retrieve a Dashboard

按主键列出现有仪表板。

Query Parameters

支持所有全局查询参数

Returns

返回请求的 仪表板对象

REST API

GET /dashboards/:id
Example
GET /dashboards/2fc325fb-299b-4d20-a9e7-a34349dee8b2

GraphQL

POST /graphql/system
graphql
type Query {
 dashboards_by_id(id: ID!): directus_dashboards
}
Example
graphql
query {
 dashboards_by_id(id: "2fc325fb-299b-4d20-a9e7-a34349dee8b2") {
  id
  name
 }
}

Create a Dashboard

创建一个新的仪表板。

Query Parameters

支持所有全局查询参数

请求体

部分仪表板对象

Returns

返回创建的仪表板的 仪表板对象

REST API

POST /dashboards
Example
json
// POST /dashboards

{
  "name": "My Dashboard",
  "icon": "dashboard"
}

GraphQL

POST /graphql/system
graphql
type Mutation {
 create_dashboards_item(data: create_directus_dashboards_input!): directus_dashboards
}
Example
graphql
mutation {
 create_dashboards_item(data: { name: "My Dashboard", icon: "dashboards" }) {
  id
  name
 }
}

Create Multiple Dashboards

创建多个新仪表板。

Query Parameters

支持所有全局查询参数

请求体

部分仪表板对象 的数组。

Returns

返回创建的仪表板的 仪表板对象

REST API

POST /dashboards
Example
json
// POST /dashboards

[
  {
    "name": "My Dashboard",
    "icon": "dashboard"
  },
  {
    "name": "Another Dashboard",
    "icon": "person"
  }
]

GraphQL

POST /graphql/system
graphql
type Mutation {
 create_dashboards_items(data: [create_directus_dashboards_input!]!): [directus_dashboards]
}
Example
graphql
mutation {
 create_dashboards_items(
  data: [
   {
    "name": "My Dashboard",
    "icon": "dashboard"
   },
   {
    "name": "Another Dashboard",
    "icon": "person"
   }
  ]
 ) {
  id
  name
 }
}

Update a Dashboard

更新现有仪表板。

Query Parameters

支持所有全局查询参数

请求体

部分仪表板对象

Returns

返回更新仪表板的 仪表板对象

REST API

PATCH /dashboards/:id
Example
json
// PATCH /dashboards/2fc325fb-299b-4d20-a9e7-a34349dee8b2

{
  "name": "My Updated Dashboard"
}

GraphQL

POST /graphql/system
graphql
type Mutation {
 update_dashboards_item(id: ID!, data: update_directus_dashboards_input): directus_dashboards
}
Example
graphql
mutation {
 update_dashboards_item(id: "2fc325fb-299b-4d20-a9e7-a34349dee8b2", data: { name: "My Updated Dashboard" }) {
  id
  name
 }
}

Update Multiple Dashboards

更新多个现有仪表板。

Query Parameters

支持所有全局查询参数

请求体

keys Required
您要更新的仪表板的主键数组。

data Required
仪表板 的任何属性。

Returns

返回更新仪表板的 仪表板对象

REST API

PATCH /dashboards
Example
json
// PATCH /dashboards

{
  "keys": ["3f2facab-7f05-4ee8-a7a3-d8b9c634a1fc", "7259bfa8-3786-45c6-8c08-cc688e7ba229"],
  "data": {
    "color": "#6644FF"
  }
}

GraphQL

POST /graphql/system
graphql
type Mutation {
 update_dashboards_items(ids: [ID!]!, data: update_directus_dashboards_input): [directus_dashboards]
}
Example
graphql
mutation {
 update_dashboards_items(
  ids: ["3f2facab-7f05-4ee8-a7a3-d8b9c634a1fc", "7259bfa8-3786-45c6-8c08-cc688e7ba229"]
  data: { "color": "#6644FF" }
 ) {
  id
  name
 }
}

Delete a Dashboard

删除现有仪表板。

Returns

空的身体。

REST API

DELETE /dashboards/:id
Example
DELETE /dashboards/12204ee2-2c82-4d9a-b044-2f4842a11dba

GraphQL

POST /graphql/system
graphql
type Mutation {
 delete_dashboards_item(id: ID!): delete_one
}
Example
graphql
mutation {
 delete_dashboards_item(id: "12204ee2-2c82-4d9a-b044-2f4842a11dba") {
  id
 }
}

Delete Multiple Dashboards

删除多个现有仪表板。

请求体

一组仪表板主键

Returns

空的身体。

REST API

DELETE /dashboards
Example
json
// DELETE /dashboards
["25821236-8c2a-4f89-8fdc-c7d01f35877d", "02b9486e-4273-4fd5-b94b-e18fd923d1ed", "7d62f1e9-a83f-407b-84f8-1c184f014501"]

GraphQL

POST /graphql/system
graphql
type Mutation {
 delete_dashboards_items(ids: [ID!]!): delete_many
}
Example
graphql
mutation {
 delete_dashboards_items(
  ids: [
   "25821236-8c2a-4f89-8fdc-c7d01f35877d"
   "02b9486e-4273-4fd5-b94b-e18fd923d1ed"
   "7d62f1e9-a83f-407b-84f8-1c184f014501"
  ]
 ) {
  ids
 }
}