diff --git a/ui/web/core/label/LabelDisplay.js b/ui/web/core/label/LabelDisplay.js new file mode 100644 index 0000000000000000000000000000000000000000..86372ab9416d67a40c280db948e679c5d253e4f7 --- /dev/null +++ b/ui/web/core/label/LabelDisplay.js @@ -0,0 +1,49 @@ +//--------------------------------------------------------------------- +// NOC.core.label.LabelDisplay - +// Label Field +//--------------------------------------------------------------------- +// Copyright (C) 2007-2021 The NOC Project +// See LICENSE for details +//--------------------------------------------------------------------- +console.debug("Defining NOC.core.label.LabelDisplay"); + +Ext.define("NOC.core.label.LabelDisplay", { + extend: "Ext.form.field.Display", + alias: "widget.labeldisplay", + + fieldSubTpl: [ + '
style="{fieldStyle}"', + ' class="{fieldCls} {fieldCls}-{ui} label-display">{value}
', + { + compiled: true, + disableFormats: true + } + ], + + getDisplayValue: function() { + var me = this, + value = this.getRawValue(), + display, + chip = new Ext.XTemplate([ + '', + '
', + '
', + '{scope}', + '{value}', + '
', + '
', + { + compiled: true, + disableFormats: true + } + ]); + if (me.renderer) { + display = me.renderer.call(me.scope || me, value, me); + } else { + display = me.htmlEncode ? Ext.util.Format.htmlEncode(value) : value; + } + return chip.apply(display); + }, +}); diff --git a/ui/web/core/label/LabelField.js b/ui/web/core/label/LabelField.js index f0ea6bef1ed7b3cb37a4e8fb27437105bb148ed8..c86597ccba04991f79b60ad3a3c081f2c3050d98 100644 --- a/ui/web/core/label/LabelField.js +++ b/ui/web/core/label/LabelField.js @@ -380,6 +380,7 @@ Ext.define("NOC.core.label.LabelField", { Ext.form.field.Tag.prototype.onTriggerClick.apply(this, arguments); } }, + onCloseTreePicker: function() { this.treePicker.hide(); this.validate(); diff --git a/ui/web/sa/managedobject/Application.js b/ui/web/sa/managedobject/Application.js index 3df533e34cf5adb67dd202a3aa020ffa637d5430..81eec3663ac5163ce452caecd0e3b613233273f4 100644 --- a/ui/web/sa/managedobject/Application.js +++ b/ui/web/sa/managedobject/Application.js @@ -14,12 +14,14 @@ Ext.define("NOC.sa.managedobject.Application", { "NOC.core.TagsField", "NOC.core.tagfield.Tagfield", "NOC.core.label.LabelField", + "NOC.core.label.LabelDisplay", "NOC.core.PasswordField", "NOC.sa.administrativedomain.TreeCombo", "NOC.sa.administrativedomain.LookupField", "NOC.sa.authprofile.LookupField", "NOC.sa.managedobject.Model", "NOC.sa.managedobject.AttributesModel", + "NOC.sa.managedobject.CapabilitiesModel", "NOC.sa.managedobject.LookupField", "NOC.sa.managedobject.SchemeLookupField", "NOC.sa.profile.LookupField", @@ -435,6 +437,28 @@ Ext.define("NOC.sa.managedobject.Application", { } ] }, + { + xtype: "fieldset", + title: __("Effective Labels"), + minWidth: me.formMinWidth, + maxWidth: me.formMaxWidth, + defaults: fieldSetDefaults, + collapsible: true, + collapsed: true, + items: [ + { + xtype: "container", + items: [ + { + name: "effective_labels", + xtype: "labeldisplay", + fieldLabel: __("Effective"), + allowBlank: true, + } + ] + } + ] + }, { xtype: "fieldset", title: __("Role"), @@ -1653,25 +1677,61 @@ Ext.define("NOC.sa.managedobject.Application", { } ], inlines: - [{ - title: __("Attributes"), - collapsed: true, - model: "NOC.sa.managedobject.AttributesModel", - columns: [ - { - text: __("Key"), - dataIndex: "key", - width: 100, - editor: "textfield" - }, - { - text: __("Value"), - dataIndex: "value", - editor: "textfield", - flex: 1 - } - ] - }], + [ + { + title: __("Attributes"), + collapsed: true, + model: "NOC.sa.managedobject.AttributesModel", + columns: [ + { + text: __("Key"), + dataIndex: "key", + width: 100, + editor: "textfield" + }, + { + text: __("Value"), + dataIndex: "value", + editor: "textfield", + flex: 1 + } + ] + }, + { + title: __("Capabilities"), + collapsed: false, + model: "NOC.sa.managedobject.CapabilitiesModel", + columns: [ + { + text: __("Capability"), + dataIndex: "capability", + width: 300 + }, + { + text: __("Value"), + dataIndex: "value", + width: 100, + renderer: function(v) { + if((v === true) || (v === false)) { + return NOC.render.Bool(v); + } else { + return v; + } + } + }, + { + text: __("Source"), + dataIndex: "source", + width: 100 + }, + { + text: __("Description"), + dataIndex: "description", + flex: 1 + } + ] + } + ], // onCard: function() { var me = this; diff --git a/ui/web/sa/managedobject/CapabilitiesModel.js b/ui/web/sa/managedobject/CapabilitiesModel.js new file mode 100644 index 0000000000000000000000000000000000000000..5d81656c0f73f46c953e54e3fc646dc9dba4638b --- /dev/null +++ b/ui/web/sa/managedobject/CapabilitiesModel.js @@ -0,0 +1,33 @@ +//--------------------------------------------------------------------- +// sa.managedobject CapabilitiesModel +//--------------------------------------------------------------------- +// Copyright (C) 2007-2021 The NOC Project +// See LICENSE for details +//--------------------------------------------------------------------- +console.debug("Defining NOC.sa.managedobject.CapabilitiesModel"); + +Ext.define("NOC.sa.managedobject.CapabilitiesModel", { + extend: "Ext.data.Model", + rest_url: "/sa/managedobject/{{parent}}/caps/", + parentField: "managed_object_id", + + fields: [ + { + name: "capability", + type: "string" + }, + { + name: "description", + type: "string" + }, + { + name: "source", + type: "string" + }, + { + name: "value", + type: "auto" + } + ] +}); +