Merge pull request #125 from ahgittin/fix-locations
Fix errors around locations in composer
diff --git a/ui-modules/blueprint-composer/app/components/custom-config-widget/suggestion-dropdown.js b/ui-modules/blueprint-composer/app/components/custom-config-widget/suggestion-dropdown.js
index d58ec88..0899c0a 100644
--- a/ui-modules/blueprint-composer/app/components/custom-config-widget/suggestion-dropdown.js
+++ b/ui-modules/blueprint-composer/app/components/custom-config-widget/suggestion-dropdown.js
@@ -46,21 +46,28 @@
};
function link(scope, element, attrs, specEditor) {
- scope.specEditor = specEditor;
- scope.defined = specEditor.defined;
- scope.getSuggestions = () => {
- var result = [];
- if (scope.params['suggestion-values']) {
- scope.params['suggestion-values'].forEach( (v) => {
- if (v["value"]) {
- result.push(v);
- } else {
- result.push({value: v});
- }
- });
- return result;
+ try {
+ scope.specEditor = specEditor;
+ scope.defined = specEditor.defined;
+ scope.getSuggestions = () => {
+ var result = [];
+ if (scope.params['suggestion-values']) {
+ scope.params['suggestion-values'].forEach( (v) => {
+ if (v["value"]) {
+ result.push(v);
+ } else {
+ result.push({value: v});
+ }
+ });
+ return result;
+ }
+ };
+ } catch (e) {
+ if ($scope.params) {
+ $scope.params.error = e;
}
- };
+ throw e;
+ }
}
}
diff --git a/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.directive.js b/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.directive.js
index 4371a0f..95c59e4 100644
--- a/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.directive.js
+++ b/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.directive.js
@@ -573,16 +573,35 @@
/** returns 'enabled' or 'disabled' if a widget is defined, or null if no special widget is defined */
specEditor.getCustomConfigWidgetMode = (item) => {
var widgetMetadata = scope.state.config.customConfigWidgetMetadata[item.name];
- if (!widgetMetadata || widgetMetadata["error"]) return null;
+ if (!widgetMetadata) return null;
+ if (widgetMetadata["error"]) {
+ return "disabled";
+ }
return widgetMetadata["enabled"] ? 'enabled' : 'disabled';
};
+ specEditor.customConfigWidgetError = (item) => {
+ var widgetMetadata = scope.state.config.customConfigWidgetMetadata[item.name];
+ if (!widgetMetadata || !widgetMetadata["error"]) return null;
+ if (widgetMetadata.manualToggleAfterError && widgetMetadata.enabled) {
+ // show the error if manually enabled
+ return widgetMetadata["error"];
+ }
+ return null;
+ };
specEditor.toggleCustomConfigWidgetMode = (item, newval) => {
var widgetMetadata = scope.state.config.customConfigWidgetMetadata[item.name];
if (!widgetMetadata) {
$log.error('Custom widget mode should not be toggled when not available: '+item.name);
return null;
}
- if (!specEditor.defined(newval)) newval = !widgetMetadata.enabled;
+ if (!specEditor.defined(newval)) {
+ if (widgetMetadata["error"] && !widgetMetadata.manualToggleAfterError) {
+ widgetMetadata.manualToggleAfterError = true;
+ newval = true;
+ } else {
+ newval = !widgetMetadata.enabled;
+ }
+ }
widgetMetadata.enabled = newval;
}
specEditor.getCustomConfigWidgetModeTitle = (item) => {
@@ -717,7 +736,7 @@
return scope.config[key];
}
} catch (ignoredError) {
- console.log("Couldn't handle entered JSON", scope.config[key], ignoredError);
+ $log.debug("Couldn't handle entered JSON", scope.config[key], ignoredError);
}
}
// otherwise pretty print it, so they get decent multiline on first load and
diff --git a/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.template.html b/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.template.html
index ad9a5d8..fe00172 100644
--- a/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.template.html
+++ b/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.template.html
@@ -127,7 +127,7 @@
<form name="formSpecConfig" novalidate class="lightweight">
<div ng-repeat="item in (filteredItems = (model.miscData.get('config') | specEditorConfig:state.config.filter.values:model | filter:{name:state.config.search} | orderBy:+priority)) track by item.name ">
- <div class="form-group" ng-class="{'has-error': (model.issues | filter:{ref: item.name}:true).length > 0, 'used': config[item.name] !== undefined}"
+ <div class="form-group" ng-class="{'has-error': ((model.issues | filter:{ref: item.name}:true).length > 0) || (specEditor.customConfigWidgetError(item)), 'used': config[item.name] !== undefined}"
ng-switch="getConfigWidgetMode(item)"
tabindex="1"
auto-focus="state.config.focus === item.name"
@@ -332,6 +332,10 @@
</div>
<small ng-repeat="issue in model.issues | filter:{ref: item.name}:true" class="help-block issue" ng-bind-html="issue.message"></small>
+ <small ng-if="specEditor.customConfigWidgetError(item)" class="help-block issue">
+ Custom widget unavailable:
+ {{ specEditor.customConfigWidgetError(item) }}
+ </small>
</div>
</div>
diff --git a/ui-modules/blueprint-composer/app/components/util/d3-blueprint.js b/ui-modules/blueprint-composer/app/components/util/d3-blueprint.js
index 5bc3057..b199ab0 100755
--- a/ui-modules/blueprint-composer/app/components/util/d3-blueprint.js
+++ b/ui-modules/blueprint-composer/app/components/util/d3-blueprint.js
@@ -173,7 +173,8 @@
relationships: [],
};
- let zoom = d3.zoom().scaleExtent([0.1, 1]).on('zoom', onSvgZoom);
+ let viewportWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
+ let zoom = d3.zoom().scaleExtent([0.1, Math.max(1, 1 + Math.log(viewportWidth/1024))]).on('zoom', onSvgZoom);
_svg
.attr('preserveAspectRatio', 'xMinYMin meet')
.attr('viewBox', () => {
diff --git a/ui-modules/location-manager/app/views/detail/detail.controller.js b/ui-modules/location-manager/app/views/detail/detail.controller.js
index 426c1a9..01c0818 100644
--- a/ui-modules/location-manager/app/views/detail/detail.controller.js
+++ b/ui-modules/location-manager/app/views/detail/detail.controller.js
@@ -86,7 +86,7 @@
$state.go('locations');
brSnackbar.create('Location "' + $filter('locationName')(vm.location) + '" deleted successfully');
}).catch(error => {
- brSnackbar.create('Could not delete this location: ' + error.message);
+ brSnackbar.create('Could not delete this location: ' + error.error.message);
});
};
vm.editLocation = function () {
diff --git a/ui-modules/location-manager/app/views/wizard/advanced/advanced.controller.js b/ui-modules/location-manager/app/views/wizard/advanced/advanced.controller.js
index 975d9c3..0107bc2 100644
--- a/ui-modules/location-manager/app/views/wizard/advanced/advanced.controller.js
+++ b/ui-modules/location-manager/app/views/wizard/advanced/advanced.controller.js
@@ -78,7 +78,7 @@
catalogApi.create(payload).then(data => {
$state.go('detail', {symbolicName: vm.id, version: vm.version});
}).catch(error => {
- brSnackbar.create('Could not save location: ' + error.data.message ? error.data.message : error.data);
+ brSnackbar.create('Could not save location: ' + error.error.message ? error.error.message : error.data);
});
};
diff --git a/ui-modules/location-manager/app/views/wizard/byon/byon.controller.js b/ui-modules/location-manager/app/views/wizard/byon/byon.controller.js
index c12c789..51ab1db 100644
--- a/ui-modules/location-manager/app/views/wizard/byon/byon.controller.js
+++ b/ui-modules/location-manager/app/views/wizard/byon/byon.controller.js
@@ -95,7 +95,7 @@
catalogApi.create(payload).then(data => {
$state.go('detail', {symbolicName: vm.id, version: vm.version});
}).catch(error => {
- brSnackbar.create('Could not save location: ' + error.data.message ? error.data.message : error.data);
+ brSnackbar.create('Could not save location: ' + error.error.message ? error.error.message : error.error);
});
};
diff --git a/ui-modules/location-manager/app/views/wizard/cloud/cloud.controller.js b/ui-modules/location-manager/app/views/wizard/cloud/cloud.controller.js
index 4e015c4..996a156 100644
--- a/ui-modules/location-manager/app/views/wizard/cloud/cloud.controller.js
+++ b/ui-modules/location-manager/app/views/wizard/cloud/cloud.controller.js
@@ -102,7 +102,7 @@
catalogApi.create(payload).then(data => {
$state.go('detail', {symbolicName: vm.id, version: vm.version});
}).catch(error => {
- brSnackbar.create('Could not save location: ' + error.data.message ? error.data.message : error.data);
+ brSnackbar.create('Could not save location: ' + error.error.message ? error.error.message : error.error);
});
};
diff --git a/ui-modules/utils/table/index.js b/ui-modules/utils/table/index.js
index 9419b4d..bf12ef2 100644
--- a/ui-modules/utils/table/index.js
+++ b/ui-modules/utils/table/index.js
@@ -103,6 +103,7 @@
link: link,
controller: ['$templateCache', 'brUtilsGeneral', controller],
controllerAs: 'ctrl',
+ scope: true,
templateUrl: function(element, attrs) {
return attrs.templateUrl || TEMPLATE_CONTAINER_URL;
}