门户定制概述

从iTop 2.3.0开始,门户带有完全可定制的品牌新版本。这使您可以对其进行整形,使其以接近零的编码完全适合您的终端用户需求。

目标听众

您是一名开发人员,顾问。您已经熟悉以下方面的基本知识iTop XML设计.

门户可以做什么?

  • 访问权利,菜单,表格:这些均以XML定义,因此可以轻松更改
  • 定制:从配置到外观
  • 扩展的:通过开发模块(如扩展)来添加(和重用)新的职能型功能,并在XML中对其进行配置
  • 个实例:设置多个实例配置,以使其能够访问仅需要的内容,以适合您的各种终端用户需求。

这个怎么运作

对象安全

数据安全基于数据模型安全布局,实例无法访问的内容超出了控制台允许的范围。另外,必须明确允许在实例上用于可视化和版本化的对象,这有助于您使安全保持用户可以访问的范围。

实例功能

门户的每个实例都有自己的配置,使它们彼此完全独立。

一个实例由几个“砖”组成,每个砖都具有自己的职能型功能,例如创建对象,浏览对象集合等。Bricks拥有自己的配置,但依赖于实例配置,并且无法覆盖它。

共有6种类型的积木:

  • CreateBrick:显示对象创建表单
  • BrowseBrick:浏览对象的分层并为每个级别指定操作活动(查看或编辑对象,从该级别创建另一个对象)。可以从多个视图(例如常规列表或树)中进行导航。用例可能是浏览对象目录,以查找用于创建您的请求的目录。
  • ManageBrick:允许通过在2轴上对对象进行分组和编辑来管理对象。通常用于管理正在进行的请求或一组配置项。
  • FilterBrick:预过滤另一块砖
  • AggregatePageBrick:具有一对多砖瓦的页面。
  • UserProfileBrick:显示带有当前用户信息的表单,以便他可以编辑其中的一些信息。

可以将具有相同配置的多个相同类型的块添加到同一实例,只要它们具有不同的ID。此外,可以开发更多的砖块以适合其他需求(显示图片,嵌入iframe或视频等)。

配置实例

配置是在 /itop_design/module_designs/module_design[@=“<PORTAL_ID>”]节点下的数据模型中制成的。

对于默认的配置,它的配置已拆分为几个模块,因此可以适应各种设置,但是主要部分位于/itop_design/module_designs/module_design[@=“itop-portal”].下的/datamodels/2.x/itop-tickets/datamodel.itop-tickets.xml中. .

依赖在您的设置选择上,可以在itop-request-mgmt, itop-request-mgmt-itil, itop-incident-mgmt-itil, itop-full-itil, itop-knownerror-mgmt and itop-portal中找到其他部分。

对象范围

配置实例时,您应该做的第一件事就是为门户中应访问的所有对象设置范围。这将是所有积木逻辑的基石。不启用对象类可能会因积木而导致意外行为。

一旦确定了您希望用户查看和编辑的内容,范围就很容易定义。

  1. 选择对象类
  2. 为用户可以查看的对象指定OQL查询
  3. (可选)为用户可以编辑的对象指定OQL查询。该查询将应用于“查看”查询中的对象子集。如果未指定,则用户将无法编辑此类的对象。
  4. (可选)为此范围指定允许的用户简档(角色)。这意味着您可以在用户的简档(角色)上允许不同的作用域依赖。

如果未定义类,则门户会尝试找到定义最接近的父来检索其范围。如果没有,访问将被拒绝。

范围适用于对象表单中的外部键,但不适用于请求模板的OQL字段。

对象表格

现在定义了作用域,您需要定义如何通过门户显示那些对象。默认情况下,将显示一个基本表单,其中包含“详细信息” z列表中的所有属性,但是您可以根据优化的layout和dor adddhide属性对其进行自定义。

表单是为一种或多种模式(查看,创建,编辑)的特定类(及其子类)定义的。如果没有定义的与类模式匹配的表单,它将回退到默认模式。

您可以选择指定要显示的属性列表,在这种情况下,它们会像默认的表单一样依次显示。或者,您可以给出一个HTML布局,门户将用正确的标记填充。 Bootstrap类和Twig运算符都可以使用。

您还可以在属性上设置标志,它们将与数据模型生命周期中的标志合并。

在这两种情况下,如果未指定门户,它们都会自动将当前状态的必需属性附加到表单。这是将对象保持一致状态的故障保护。

功能规则

功能规则是在某些情况下应用于砖块的行为,例如在对象上预设值或定义提交取消表单时定义要打开的页面。它与语法中的ObjectCopier相似,但没有某些限制。

功能规则可以在多个砖中使用,但并非所有砖都支持它们。从今天起,它们只能在BrowseBrick和CreateBrick中使用。

砖块

配置实例块应该是您配置实例的最后一步,因为它依赖于之前的所有实例。请记住,它们基于数据模型的安全和实例的范围。

每个积木都有其自己的配置和规格,请查看引用指南以获取详细信息。

定制化的外观

新的门户基于知名的框架,例如Twig用于HTML布局,Boostrap用于样式,您还可以使用字体库,因为Font awesome和Glyphicons也被嵌入。这使您可以找到许多在线资源和示例。

更改Bootsrap主题

通过更改引导主题,您可以轻松地变更的门户的全局外观。在线提供了许多免费主题,如果您愿意,您甚至可以构建。

检查一下www.bootswatch.com 或操作方法中的“ sample-门户-new-theme”示例模块。

改变布局

如果您必须全部编写HTML标记,则更改布局会稍微复杂一点,但是它将使您能够自由调整所需的形状。

您可以覆盖多个级别的布局:

  • 门户的整体结构
  • 主页
  • 通用砖页面
  • 每个砖块内容布局

有关示例,请检查“sample-portal-alter-twig示例模块。

Twig模板被缓存到改进性能。如果要在开发期间跳过树枝渲染缓存,只需将调试参数添加到url并将其设置为true。

localhost/pages/exec.php?exec_module=itop-portal&exec_page=index.php&debug=true

资源资源

看到客户门户XML引用指南

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


Portal customization overview

Since iTop 2.3.0 the portal comes with a brand new version that is fully customizable. This allows you to shape it so it fits perfectly your end-users needs with close to zero coding.

Intended audience

You are a developper, consultant. You are already familiar with the fundamentals of iTop XML design.

What's possible with the Portal ?

  • Access rights, menus, forms: this is all defined in XML, so can easily be changed

  • Customizable : from the configuration, to the look and feel

  • Extensible : Add (and reuse) new functional features by developing bricks (as extensions) and configure them in the XML

  • Multiple instances : Set multiple instances / configurations to fit your various end-users needs by giving them access to what they need only

How it works

Objects security

Data security is based on the datamodel security layout, an instance cannot access more than the console allows to. Also, objects available for visualization and edition on the instance must be explicitly allowed, this helps you keep control over what the users can access.

Instance features

Each instance of the portal has its own configuration, making them completely independents from one another.

An instance is made of several “bricks”, each enabling its own functional features like creating an object, browsing through a collection of objects, etc. Bricks have their own configuration but rely on the instance configuration and cannot override it.

There are 6 types of bricks available :

  • CreateBrick : Displays an object creation form

  • BrowseBrick : Navigate through an hierarchy of objects and specify actions for each levels (view or edit the object, create another object from this one). Navigation can be done from multiple views such as a regular list or a tree. An use case could be to browse the service catalog to find the one to create your request from.

  • ManageBrick : Allows to manage objects by grouping them on 2 axis and edit them. Typically to manage the ongoing requests or a group of CIs.

  • FilterBrick : Pre-filters another brick

  • AggregatePageBrick : A page with one to many brick tiles.

  • UserProfileBrick : Displays a form with the current user information so he can edit some of them.

Several bricks of the same type can be added to a same instance with several configurations as long as they have different IDs. Also, more bricks can be developed to fit other needs (showing a picture, embedding an iframe or a video, …).

Configuring an instance

The configuration is made in the datamodel under the/itop_design/module_designs/module_design[@=“<PORTAL_ID>”] node.

For the default one, its configuration has been splited in several modules so it adapts to the setup possibilities but the main part is located in/datamodels/2.x/itop-tickets/datamodel.itop-tickets.xml under the/itop_design/module_designs/module_design[@=“itop-portal”].

Depending on your setup choices, some other parts can be found in itop-request-mgmt, itop-request-mgmt-itil, itop-incident-mgmt-itil, itop-full-itil, itop-knownerror-mgmt and itop-portal

Object scopes

The first thing you should do when configuring an instance is to set the scopes for all the objects that should be access in the portal. This will be the corner stone of all bricks logic. Not enabling an object class might end in an unexpected behavior from the bricks.

Scopes are pretty easy to defined once you have determine exactly what you want your users to view and edit.

  1. Choose the object class

  2. Specify an OQL query for the objects users can view

  3. Optionally, specify an OQL query for the objects users can edit. That query will be apply to the subset of objects from the “viewing” query. If not specify, users will not be able to edit objects of this class.

  4. Optionally, specify allowed user profiles for this scope. This means that you can allow different scopes depending on the user's profiles.

If a class is not defined, the portal will try found the closest defined parent to retrieve its scope. If there is none, access will be denied.

Scopes are applied to external key in object forms but NOT to OQL fields of request templates.

Object forms

Now that scopes are defined, you need to define how those objects will be displayed through the portal. By default a basic form containing all attributes from the “details” z-list will be displayed, but you can customize this to optimize the layout and/or add/hide attributes.

A form is defined for a specific class (and its child classes) for one or more modes (view, create, edit). If there is no defined form matching the class/mode, it will fallback to the default one.

You can either choose to specify the attribute list you want to display, in which case they will be displayed one after another like for the default form. Or you can give an HTML layout that the portal will fill with the right markup. Both Bootstrap classes and Twig operator can be used.

You can also set flags on the attributes, they will be merges with those from the datamodel's life-cycle.

In both cases, the portal will automatically append mandatory attributes for the current state to the form if they were not specified. This is a fail-safe to maintain object in a consistent state.

Action rules

Action rules are behaviors applied on a brick under certain circumstances like presetting values on a object or defining which page to open when submitting/cancelling a form. It is similar to ObjectCopier in its syntax but doesn't have some of its limitations.

An action rule can be used in several bricks but not all bricks supports them. As of today they can only be used in BrowseBrick and CreateBrick.

Bricks

Configuring the bricks should be the last step you do when configuring the instance as it relies on all the previous one. Keep in mind that they are based on the datamodel's security and instance's scopes.

Each brick has its own configuration and specifics, check the reference guide for detailed informations.

Customizing the look

The new portal is based on well known frameworks such as Twig for the HTML layout and Boostrap for the styling, you can also use font libraries as Font awesome and Glyphicons are embedded as well. This allows you to find many online resources and examples.

Changing the Bootsrap theme

By changing the bootstrap theme you can easily change the global look and feel of the portal. Lots of free themes are available online, you can even build yours if you wish.

Check www.bootswatch.com or the “sample-portal-new-theme” sample module in the how-tos.

Changing the layout

Changing the layout is a bit more complex has you will have to code the HTML markup all over but it will give you freedom to shape it has you want.

There are several levels of layouts that you can override :

  • The global portal structure

  • The home page

  • The generic brick page

  • Each brick content layout

Check the “sample-portal-alter-twig” sample module for an example.

Twig template are cached to improve performance. If you want to skip the twig rendering cache during development, just add the debug parameter to the url and set it to true.

localhost/pages/exec.php?exec_module=itop-portal&exec_page=index.php&debug=true

Resources

See the customer portal XML reference guide

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

需要帮助?

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

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