You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2021/08/03 15:52:08 UTC
[brooklyn-ui] branch master updated (195de92 -> de2a364)
This is an automated email from the ASF dual-hosted git repository.
heneveld pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-ui.git.
from 195de92 This closes #256
new 759ef1f Duplicate parameters fix
new 6d38e6a syntax refactoring
new de2a364 This closes #257
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../app/components/dsl-editor/dsl-editor.js | 113 +++++++++++----------
1 file changed, 62 insertions(+), 51 deletions(-)
[brooklyn-ui] 01/03: Duplicate parameters fix
Posted by he...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-ui.git
commit 759ef1f5abc8ef852c90541315e76052acc0f5b2
Author: John Athanasiou <ja...@users.noreply.github.com>
AuthorDate: Tue Aug 3 13:34:34 2021 +0100
Duplicate parameters fix
---
.../app/components/dsl-editor/dsl-editor.js | 59 +++++++++++++---------
1 file changed, 34 insertions(+), 25 deletions(-)
diff --git a/ui-modules/blueprint-composer/app/components/dsl-editor/dsl-editor.js b/ui-modules/blueprint-composer/app/components/dsl-editor/dsl-editor.js
index c7b9e16..9e4812d 100644
--- a/ui-modules/blueprint-composer/app/components/dsl-editor/dsl-editor.js
+++ b/ui-modules/blueprint-composer/app/components/dsl-editor/dsl-editor.js
@@ -280,36 +280,45 @@ export function dslEditorDirective($rootScope, $filter, $log, brUtilsGeneral, bl
}
}
- function getConfigItems(entity, definition) {
- let config = entity.miscData.get('config').filter(config => config !== definition).map(config => {
- return {
- id: config.name,
+ function getEntityConfigPropertyItems (entity, definition, propertyName) {
+ return entity.miscData.get(propertyName)
+ .filter(item => item !== definition)
+ .map(({ name, description }) => ({
+ id: name,
type: DSL_KINDS.CONFIG,
- entity: entity,
- name: config.name,
- description: config.description
- };
- });
+ entity,
+ name,
+ description,
+ }));
+ };
- let params = entity.miscData.get('parameters').filter(param => param !== definition).map(param => {
- return {
- id: param.name,
- type: DSL_KINDS.CONFIG,
- entity: entity,
- name: param.name,
- description: param.description
- };
+ function uniqueConfigItems(items) {
+ const IDs = new Set();
+
+ return items.filter(({ id }) => {
+ if (IDs.has(id)) return false;
+ IDs.add(id);
+ return true;
+ })
+ }
+
+ function getConfigItems(entity, definition, nested=false) {
+ const result = [
+ ...getEntityConfigPropertyItems(entity, definition, 'config'),
+ ...getEntityConfigPropertyItems(entity, definition, 'parameters'),
+ ];
+
+ Object.values(entity.getClusterMemberspecEntities() || {}).forEach(member => {
+ result.push(...getConfigItems(member, definition, true));
});
-
- config = config.concat(params);
- config = Object.values(entity.getClusterMemberspecEntities()).reduce((acc, spec) => {
- return acc.concat(getConfigItems(spec, definition));
- }, config);
+ (entity.children || []).forEach(child => {
+ result.push(...getConfigItems(child, definition, true));
+ });
- return entity.children.reduce((acc, child) => {
- return acc.concat(getConfigItems(child, definition));
- }, config);
+ return nested
+ ? result
+ : uniqueConfigItems(result); // only need to check distinct items once, not in every recursion
}
function getSensorItems(entity) {
[brooklyn-ui] 02/03: syntax refactoring
Posted by he...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-ui.git
commit 6d38e6aa2c4728685cca0d22fc613a5992065dc8
Author: John Athanasiou <ja...@users.noreply.github.com>
AuthorDate: Tue Aug 3 14:13:25 2021 +0100
syntax refactoring
---
.../app/components/dsl-editor/dsl-editor.js | 70 +++++++++++-----------
1 file changed, 36 insertions(+), 34 deletions(-)
diff --git a/ui-modules/blueprint-composer/app/components/dsl-editor/dsl-editor.js b/ui-modules/blueprint-composer/app/components/dsl-editor/dsl-editor.js
index 9e4812d..cd1bdf4 100644
--- a/ui-modules/blueprint-composer/app/components/dsl-editor/dsl-editor.js
+++ b/ui-modules/blueprint-composer/app/components/dsl-editor/dsl-editor.js
@@ -280,19 +280,19 @@ export function dslEditorDirective($rootScope, $filter, $log, brUtilsGeneral, bl
}
}
- function getEntityConfigPropertyItems (entity, definition, propertyName) {
- return entity.miscData.get(propertyName)
- .filter(item => item !== definition)
+ function entityPropertyParserFor(type, filterFunc=()=>true) {
+ return (entity, propertyName) => entity.miscData.get(propertyName)
+ .filter(filterFunc)
.map(({ name, description }) => ({
id: name,
- type: DSL_KINDS.CONFIG,
+ type,
entity,
name,
description,
}));
- };
+ }
- function uniqueConfigItems(items) {
+ function uniqueItems(items) {
const IDs = new Set();
return items.filter(({ id }) => {
@@ -303,9 +303,11 @@ export function dslEditorDirective($rootScope, $filter, $log, brUtilsGeneral, bl
}
function getConfigItems(entity, definition, nested=false) {
+ const parseAsConfig = entityPropertyParserFor(DSL_KINDS.CONFIG, item=>item !== definition);
+
const result = [
- ...getEntityConfigPropertyItems(entity, definition, 'config'),
- ...getEntityConfigPropertyItems(entity, definition, 'parameters'),
+ ...parseAsConfig(entity, 'config'),
+ ...parseAsConfig(entity, 'parameters'),
];
Object.values(entity.getClusterMemberspecEntities() || {}).forEach(member => {
@@ -318,47 +320,47 @@ export function dslEditorDirective($rootScope, $filter, $log, brUtilsGeneral, bl
return nested
? result
- : uniqueConfigItems(result); // only need to check distinct items once, not in every recursion
+ : uniqueItems(result); // only need to check distinct items once, not in every recursion
}
- function getSensorItems(entity) {
- let sensors = entity.miscData.get('sensors').map(sensor => {
- return {
- id: sensor.name,
- type: DSL_KINDS.SENSOR,
- entity: entity,
- name: sensor.name,
- description: sensor.description
- };
+ function getSensorItems(entity, nested=false) {
+ const parseAsSensors = entityPropertyParserFor(DSL_KINDS.SENSOR);
+
+ const result = parseAsSensors(entity, 'sensors');
+
+ Object.values(entity.getClusterMemberspecEntities() || {}).forEach(member => {
+ result.push(...getSensorItems(member, true));
});
- sensors = Object.values(entity.getClusterMemberspecEntities()).reduce((acc, spec) => {
- return acc.concat(getSensorItems(spec));
- }, sensors);
+ (entity.children || []).forEach(child => {
+ result.push(...getSensorItems(child, true));
+ });
- return entity.children.reduce((acc, child) => {
- return acc.concat(getSensorItems(child));
- }, sensors);
+ return nested
+ ? result
+ : uniqueItems(result);
}
- function getEntityItems(entity, type) {
- let entities = [];
-
- entities.push({
+ function getEntityItems(entity, nested=false) {
+ const result = [{
id: entity._id,
type: DSL_KINDS.ENTITY,
entity: entity,
name: entity.miscData.get('typeName') || $filter('entityName')(entity) || 'New application',
description: entity.description
+ }];
+
+ Object.values(entity.getClusterMemberspecEntities() || {}).forEach(member => {
+ result.push(...getEntityItems(member, true));
});
- entities = Object.values(entity.getClusterMemberspecEntities()).reduce((acc, spec) => {
- return acc.concat(getEntityItems(spec, type));
- }, entities);
+ (entity.children || []).forEach(child => {
+ result.push(...getEntityItems(child, true));
+ });
- return entity.children.reduce((acc, child) => {
- return acc.concat(getEntityItems(child, type));
- }, entities);
+ return nested
+ ? result
+ : uniqueItems(result);
}
function getScopedDsl(entity, targetEntity, state) {
[brooklyn-ui] 03/03: This closes #257
Posted by he...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-ui.git
commit de2a364074905ec74ffa6b870d47baf7b5899b11
Merge: 195de92 6d38e6a
Author: Alex Heneveld <al...@cloudsoftcorp.com>
AuthorDate: Tue Aug 3 16:52:02 2021 +0100
This closes #257
.../app/components/dsl-editor/dsl-editor.js | 113 +++++++++++----------
1 file changed, 62 insertions(+), 51 deletions(-)