在团队中添加仪表板

决条件:您必须熟悉教程中使用的语法 并且已经创建了一个扩展.
我们还假定您熟悉iTop中的仪表板设计和Q.

学习:在类上添加仪表板属性

水平:初学者

域:XMLdashboardpresentation

最低版本:2.6.0

您想在每个团队上显示一个新的标签,其中显示了仪表板以及该团队的特定信息:

  • 分配给该团队的待售票清单
  • 仅限活跃成员的成员列表
  • 至少一名团队成员所在的位置列表

这些只是可以定义的Dashlet的示例,此教程的目的不是解释如何创建仪表盘。

可以用于上述示例的OQL查询

分配给该团队的待售票清单:

SELECT UserRequest WHERE STATUS IN ('assigned') AND team_id=:this->id
UNION SELECT Incident WHERE STATUS IN ('assigned') AND team_id=:this->id
UNION SELECT Problem WHERE STATUS IN ('assigned') AND team_id=:this->id

仅限活跃成员的成员列表:

SELECT Person AS p
   JOIN lnkPersonToTeam AS l ON l.person_id = p.id
   WHERE l.team_id = :this->id AND STATUS='active'

至少一名团队成员所在的位置列表:

SELECT Location AS L
   JOIN Person AS P ON P.location_id=L.id
   JOIN lnkPersonToTeam AS l1 ON l1.person_id=P.id
   JOIN Team AS T ON l1.team_id=T.id
   WHERE T.id=:this->id

创建一个仪表板属性

为此,您将需要为Team类创建一个新的AttributeDashboard字段,并将其添加到详细信息显示中。

itop_design / classes
 
    <class id="Team" _delta="must_exist">
      <fields>
        <field id="dashboard" xsi:type="AttributeDashboard" _delta="define">
          <is_user_editable>true</is_user_editable>
          <!-- Use this default definition for creating a new dashboard -->
          <definition>
            <!-- Later replace the whole definition with the XML export -->
            <layout>DashboardLayoutOneCol</layout>
            <title/>
            <auto_reload>
              <enabled>false</enabled>
              <interval>300</interval>
            </auto_reload>
            <cells>
              <cell id="0">
                <rank>0</rank>
                <dashlets>
                  <dashlet id="0" xsi:type="DashletEmptyCell">
                    <rank>0</rank>
                  </dashlet>
                </dashlets>
              </cell>
            </cells>
          </definition>
        </field>
      </fields>
      <presentation>
        <!-- Dashboard can only be displayed in the details -->
        <details>
          <items>
            <!-- Dashboard can be displayed neither in a fieldset, nor in a column -->
            <item id="dashboard" _delta="define">
              <rank>100</rank>
            </item>
          </items>
        </details>
      </presentation>
    </class>

对仪表板使用较高的等级,将其放在末尾(“历史记录”之前),否则,当切换到仪表板之后的关系选项卡上的修改模式时,最终将修改错误的关系选项卡。由于仪表板不可编辑,因此将其从编辑视图中删除,对标签进行了重新编号,并从读取切换为编辑,并保留在相同的标签号上

添加一个字典条目  class:Team/Attribute:dashboard.

设计您的仪表板

部署扩展的第一个版本,它将提供一个空的仪表板。在iTop中重新设计此仪表板

在团队仪表板中编写OQL查询时,可以使用诸如:this-> att_code的占位符,其中att_code可以是团队的任何字段

使用团队ID的示例:

SELECT Person AS p JOIN lnkPersonToTeam AS lnk ON lnk.person_id = p.id WHERE lnk.team_id=:this->id

如果对设计感到满意,请将其导出为 XML,然后用导出<definition>替换初始<dashboard>内容:

<?xml version="1.0"?>
<dashboard xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <layout>DashboardLayoutOneCol</layout>
  <title/>
  <auto_reload>
    <enabled>false</enabled>
    <interval>300</interval>
  </auto_reload>
  <cells>
    <cell id="0">
      <rank>0</rank>
      <dashlets>
        <dashlet id="1" xsi:type="DashletObjectList">
          <rank>0</rank>
          <title>Members</title>
          <query>SELECT Person AS p 
                 JOIN lnkPersonToTeam AS lnk ON lnk.person_id = p.id 
                 WHERE lnk.team_id=:this-&gt;id
          </query>
          <menu>true</menu>
        </dashlet>
      </dashlets>
    </cell>
    <cell id="1">
      <rank>1</rank>
      <dashlets>
        <dashlet id="0" xsi:type="DashletEmptyCell">
          <rank>0</rank>
        </dashlet>
      </dashlets>
    </cell>
  </cells>
</dashboard>

当对您的设计满意时,导出以XML格式保存,并用导出的<仪表板>标签内容替换初始<definition>的内容:

itop_design / classes / class@Team / fields
 
        <field id="dashboard" xsi:type="AttributeDashboard" _delta="define">
          ...
          <definition>
            <!-- Paste here the XML export of your Dashboard designed directly in iTop -->
          </definition>
          ...

并再次运行安装程序。

  • 每个人都会在所有Team对象上看到仪表板。
  • 用户还可以将其扭曲为仪表板团队自己的构建,
  • 但是它们都共享您在iTop上设计并推送的通用版本。

如果您推送该仪表板的新版本:

  • 每个人都会得到它
  • 仪表板的定制版本,也就是以前的通用仪表板的构建,将保持不变。

原贴链接:https://www.itophub.io/wiki/page?id=2_7_0%3Acustomization%3Aadd-dashboard-attribute


Add a Dashboard on a Team

Prerequisite: You must be familiar with the Syntax used in Tutorials and have already created an extension.
We also assume that you are familiar with dashboard design within iTop and OQL.

learning:
Add a Dashboard attribute on a class
level:
Beginner
domains:
XMLDashboardPresentation
min version:
2.6.0

You want to display on every Team, a new tab displaying a dashboard with information specific for that team:

  • The list of open Tickets assigned to that team

  • A list of members limited to the active ones

  • The list of locations where at least one team member is located

Those are just examples of dashlets which could be defined, the purpose of this tutorial isn't to explain how to create a dashlet

OQL queries which could be used for the above examples

The list of open Tickets assigned to that team :

SELECT UserRequest WHERE STATUS IN ('assigned') AND team_id=:this->id
UNION SELECT Incident WHERE STATUS IN ('assigned') AND team_id=:this->id
UNION SELECT Problem WHERE STATUS IN ('assigned') AND team_id=:this->id

A list of members limited to the active ones :

SELECT Person AS p
   JOIN lnkPersonToTeam AS l ON l.person_id = p.id
   WHERE l.team_id = :this->id AND STATUS='active'

The list of locations where at least one team member is located :

SELECT Location AS L
   JOIN Person AS P ON P.location_id=L.id
   JOIN lnkPersonToTeam AS l1 ON l1.person_id=P.id
   JOIN Team AS T ON l1.team_id=T.id
   WHERE T.id=:this->id

Create a Dashboard Attribute

For this you will need to create a new AttributeDashboard field to the Team class and add it to the details display.

itop_design / classes
 
    <class id="Team" _delta="must_exist">
      <fields>
        <field id="dashboard" xsi:type="AttributeDashboard" _delta="define">
          <is_user_editable>true</is_user_editable>
          <!-- Use this default definition for creating a new dashboard -->
          <definition>
            <!-- Later replace the whole definition with the XML export -->
            <layout>DashboardLayoutOneCol</layout>
            <title/>
            <auto_reload>
              <enabled>false</enabled>
              <interval>300</interval>
            </auto_reload>
            <cells>
              <cell id="0">
                <rank>0</rank>
                <dashlets>
                  <dashlet id="0" xsi:type="DashletEmptyCell">
                    <rank>0</rank>
                  </dashlet>
                </dashlets>
              </cell>
            </cells>
          </definition>
        </field>
      </fields>
      <presentation>
        <!-- Dashboard can only be displayed in the details -->
        <details>
          <items>
            <!-- Dashboard can be displayed neither in a fieldset, nor in a column -->
            <item id="dashboard" _delta="define">
              <rank>100</rank>
            </item>
          </items>
        </details>
      </presentation>
    </class>

Use a high rank for your dashboard, to put it at the end (just before 'History'), otherwise when switching to modify mode on a relation tab located after the dashboard, you would end-up modifying the wrong relation tab. Because Dashboard being non editable, it is removed from the edit view, the tabs are renumbered, and switching from read to edit, stays on the same tab number

Add a dictionary entry for class:Team/Attribute:dashboard.

Design your Dashboard

Deploy a first version of your extension, which will provide an empty dashboard. Redesign this dashboard within iTop

When writing your OQL queries within the Team dashboard, you can use placeholders like :this->att_code where att_code can be any field of the Team

Example using the id of the team:

SELECT Person AS p JOIN lnkPersonToTeam AS lnk ON lnk.person_id = p.id WHERE lnk.team_id=:this->id

When satisfied with your design, export it in XML and replace the content of the initial <definition> with the exported <dashboard> tag content:

<?xml version="1.0"?>
<dashboard xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <layout>DashboardLayoutOneCol</layout>
  <title/>
  <auto_reload>
    <enabled>false</enabled>
    <interval>300</interval>
  </auto_reload>
  <cells>
    <cell id="0">
      <rank>0</rank>
      <dashlets>
        <dashlet id="1" xsi:type="DashletObjectList">
          <rank>0</rank>
          <title>Members</title>
          <query>SELECT Person AS p 
                 JOIN lnkPersonToTeam AS lnk ON lnk.person_id = p.id 
                 WHERE lnk.team_id=:this-&gt;id
          </query>
          <menu>true</menu>
        </dashlet>
      </dashlets>
    </cell>
    <cell id="1">
      <rank>1</rank>
      <dashlets>
        <dashlet id="0" xsi:type="DashletEmptyCell">
          <rank>0</rank>
        </dashlet>
      </dashlets>
    </cell>
  </cells>
</dashboard>

Replace all tags under the <definition> tag by what you find in your XML export under the <dashboard> tag:

itop_design / classes / class@Team / fields
 
        <field id="dashboard" xsi:type="AttributeDashboard" _delta="define">
          ...
          <definition>
            <!-- Paste here the XML export of your Dashboard designed directly in iTop -->
          </definition>
          ...

And run the setup again.

  • Everyone will see that dashboard on all Team objects.

  • Users can also twist it to build their own version of the Team dashboard,

  • but they all share the common version that you have designed and pushed on iTop.

If you push a new version of that dashboard:

  • every one will get it

  • customized versions of the dashboard, also they were build on the previous common dashboard, will remain unchanged.

标签:
由 superadmin 在 2020/08/27, 17:15 创建
    

需要帮助?

如果您需要有关XWiki的帮助,可以联系:

深圳市艾拓先锋企业管理咨询有限公司