DSL Viewer ignored literals; this fixes that and tidies the code a bit
diff --git a/ui-modules/blueprint-composer/app/components/dsl-viewer/dsl-viewer.js b/ui-modules/blueprint-composer/app/components/dsl-viewer/dsl-viewer.js
index e751638..8cbac42 100644
--- a/ui-modules/blueprint-composer/app/components/dsl-viewer/dsl-viewer.js
+++ b/ui-modules/blueprint-composer/app/components/dsl-viewer/dsl-viewer.js
@@ -42,18 +42,24 @@
};
function link(scope) {
- scope.isTargetDsl = (dsl) => {
- return dsl.kind === KIND.TARGET;
+
+ scope.getIcon = (dsl) => {
+ if (dsl.name === 'config') return 'fa-cog';
+ if (dsl.name === 'sensor') return 'fa-rss';
+ if (dsl.name === 'attributeWhenReady') return 'fa-pause';
+ if (dsl.name === 'literal') return 'fa-clone';
+ if (dsl.name === 'formatString') return 'fa-qrcode';
+ // catch-all
+ return 'fa-bolt';
};
- scope.isMethodDsl = (dsl) => {
- return dsl.kind === KIND.METHOD;
+
+ scope.getMode = (dsl) => {
+ if (dsl.kind === KIND.TARGET) return "target";
+ if (dsl.kind === KIND.METHOD) return "method";
+ if (dsl.kind === KIND.UTILITY) return "utility";
+ return "DSL";
};
- scope.isFormatStringDsl = (dsl) => {
- return dsl.kind === KIND.UTILITY && dsl.name === 'formatString';
- };
- scope.isLiteralDsl = (dsl) => {
- return [KIND.STRING, KIND.NUMBER].includes(dsl.kind);
- };
+
scope.getRelatedEntity = () => {
if (scope.dsl.params.length > 0) {
// If the DSL is looking at an entity ID
diff --git a/ui-modules/blueprint-composer/app/components/dsl-viewer/dsl-viewer.template.html b/ui-modules/blueprint-composer/app/components/dsl-viewer/dsl-viewer.template.html
index 49d8f9c..33ff5e6 100644
--- a/ui-modules/blueprint-composer/app/components/dsl-viewer/dsl-viewer.template.html
+++ b/ui-modules/blueprint-composer/app/components/dsl-viewer/dsl-viewer.template.html
@@ -16,28 +16,30 @@
specific language governing permissions and limitations
under the License.
-->
-<span ng-if="isTargetDsl(dsl)">
+<span ng-switch="getMode(dsl)">
+
+ <span ng-switch-when="target">
<span ng-if="dsl.getRoot().relationships.length === 0" class="label label-primary">{{dsl.params[0].name}}</span>
<a ng-if="dsl.getRoot().relationships.length > 0" ui-sref="main.graphical.edit.entity({entityId: getRelatedEntity()._id})"><span class="label label-primary">{{(getRelatedEntity() | entityName) || 'New application'}}</span></a>
<span ng-if="dsl.next">
⇒
<dsl-viewer dsl="dsl.next"></dsl-viewer>
</span>
-</span>
-
-<span ng-if="isMethodDsl(dsl) && !isFormatStringDsl(dsl)">
+ </span>
+
+ <span ng-switch-when="method">
<span class="label label-default">
- <i class="fa" ng-class="{'fa-cog': dsl.name === 'config', 'fa-rss': dsl.name === 'sensor', 'fa-pause': dsl.name === 'attributeWhenReady'}"></i>
+ <i class="fa" ng-class="getIcon(dsl)"></i>
{{dsl.name}}
</span>
→
<dsl-viewer dsl="dsl.params[0]"></dsl-viewer>
-</span>
-
-<span ng-if="isFormatStringDsl(dsl)">
+ </span>
+
+ <span ng-switch-when="utility">
<span class="label label-info">
- <i class="fa fa-qrcode"></i>
- pattern
+ <i class="fa" ng-class="getIcon(dsl)"></i>
+ {{dsl.name}}
</span>
→
{{dsl.params[0].name}}
@@ -46,6 +48,10 @@
<dsl-viewer dsl="argument"></dsl-viewer>
</li>
</ol>
-</span>
+ </span>
-<span ng-if="isLiteralDsl(dsl)">{{dsl.name}}</span>
\ No newline at end of file
+ <span ng-switch-default>
+ {{ getMode(dsl) }}: {{ dsl }}
+ </span>
+
+</span>