[comment]: # translation:outdated

[comment]: # ({66fb9690-66fb9690})
# 更新

[comment]: # ({/66fb9690-66fb9690})

[comment]: # ({3b6e8ed1-f235159f})
### 描述

`object dashboard.update(object/array dashboards)`

此方法允许更新已有的仪表盘。

::: noteclassic
此方法对于任何用户可用。可以在用户角色设置中撤销调用该方法的权限。更多信息请查看 [用户角色](/manual/web_interface/frontend_sections/administration/user_roles)。
:::

[comment]: # ({/3b6e8ed1-f235159f})

[comment]: # ({4f361756-62947aa0})
### 参数

`(object/array)` 要更新的仪表盘属性。

必须为每个仪表盘定义 `dashboardid` 属性，其它的属性都是可选的。只有指定的属性会被更新，其它属性都将保持不变。

除了[标准仪表盘属性](object#仪表盘)以外，此方法还接受如下参数：

|属性|[类型](/manual/api/reference_commentary#数据类型)|说明|
|---------|---------------------------------------------------|-----------|
|pages|array|更新的仪表盘[页面](object#仪表盘页面) 。<br><br>仪表盘页面由`dashboard_pageid`属性更新。将为没有`dashboard_pageid`属性的对象创建新的仪表盘页面，如果不重新使用，现有仪表盘页面将被删除。仪表盘页面的顺序将与指定的顺序相同。只会更新仪表盘页面的指定属性。“pages”属性至少需要一个仪表盘页面对象。|
|users|array|更新的仪表盘[用户](object#仪表盘用户) 。|
|userGroups|array|更新的仪表盘[用户组](object#仪表盘用户组)。 |

[comment]: # ({/4f361756-62947aa0})

[comment]: # ({28e89b38-28e89b38})
### 返回值

`(object)` 返回一个对象，该对象包含 `dashboardids`属性下更新的仪表盘 ID。

[comment]: # ({/28e89b38-28e89b38})

[comment]: # ({b41637d2-b41637d2})
### 示例

[comment]: # ({/b41637d2-b41637d2})

[comment]: # ({0e4797b9-7fcf7de4})
#### 重命名一个仪表盘

重命名一个仪表盘为 "SQL server status"。

请求：

```json
{
    "jsonrpc": "2.0",
    "method": "dashboard.update",
    "params": {
        "dashboardid": "2",
        "name": "SQL server status"
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

响应：

```json
{
    "jsonrpc": "2.0",
    "result": {
        "dashboardids": [
            "2"
        ]
    },
    "id": 1
}
```

[comment]: # ({/0e4797b9-7fcf7de4})

[comment]: # ({83800bc0-b8348b8a})
#### 更新仪表盘页面

重命名第一个仪表盘页面，替换第二个仪表盘页面上的部件，并添加一个新页面作为第三个页面。删除所有其他仪表盘页面。

请求：

```json
{
    "jsonrpc": "2.0",
    "method": "dashboard.update",
    "params": {
        "dashboardid": "2",
        "pages": [
            {
                "dashboard_pageid": 1,
                "name": 'Renamed Page'
            },
            {
                "dashboard_pageid": 2,
                "widgets": [
                    {
                        "type": "clock",
                        "x": 0,
                        "y": 0,
                        "width": 4,
                        "height": 3
                    }
                ]
            },
            {
                "display_period": 60
            }
        ]
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

响应：

```json
{
    "jsonrpc": "2.0",
    "result": {
        "dashboardids": [
            "2"
        ]
    },
    "id": 2
}
```

[comment]: # ({/83800bc0-b8348b8a})

[comment]: # ({b0b71828-e4a57dd3})
#### 变更仪表盘所有者

仅适用于管理员以及超级管理员用户。

请求：

```json
{
    "jsonrpc": "2.0",
    "method": "dashboard.update",
    "params": {
        "dashboardid": "2",
        "userid": "1"
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 2
}
```

响应：

```json
{
    "jsonrpc": "2.0",
    "result": {
        "dashboardids": [
            "2"
        ]
    },
    "id": 2
}
```

[comment]: # ({/b0b71828-e4a57dd3})

[comment]: # ({299ae089-299ae089})
### 参阅

-   [仪表盘页面](object#仪表盘页面)
-   [仪表盘部件](object#仪表盘部件)
-   [仪表盘部件字段](object#仪表盘部件字段)
-   [仪表盘用户](object#仪表盘用户)
-   [仪表盘用户组](object#仪表盘用户组)

[comment]: # ({/299ae089-299ae089})

[comment]: # ({456ac32b-456ac32b})
### 来源

*ui/include/classes/api/services/CDashboard.php* 中的 CDashboard::update() 。

[comment]: # ({/456ac32b-456ac32b})
