You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by tb...@apache.org on 2018/11/25 09:34:18 UTC
[1/5] brooklyn-ui git commit: install template to cache earlier
Repository: brooklyn-ui
Updated Branches:
refs/heads/master 0249a564e -> 84a6f7b36
install template to cache earlier
not really needed, but is consistent with how done elsewhere,
and allows override
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/722d2515
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/722d2515
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/722d2515
Branch: refs/heads/master
Commit: 722d2515edb9ed7c6322191cf5477d19d2b27f0a
Parents: 13c56f0
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Thu Nov 22 11:07:20 2018 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Thu Nov 22 11:07:20 2018 +0000
----------------------------------------------------------------------
.../app/components/spec-editor/spec-editor.directive.js | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/722d2515/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.directive.js
----------------------------------------------------------------------
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 ecfa249..483ca72 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
@@ -36,7 +36,10 @@ const REPLACED_DSL_ENTITYSPEC = '___brooklyn:entitySpec';
angular.module(MODULE_NAME, [onEnter, autoGrow, blurOnEnter, brooklynDslEditor, brooklynDslViewer])
.directive('specEditor', ['$rootScope', '$templateCache', '$injector', '$sanitize', '$filter', '$log', '$sce', '$timeout', '$document', '$state', '$compile', 'blueprintService', 'composerOverrides', specEditorDirective])
.filter('specEditorConfig', specEditorConfigFilter)
- .filter('specEditorType', specEditorTypeFilter);
+ .filter('specEditorType', specEditorTypeFilter)
+ .run(['$templateCache', templateCache]);
+
+const TEMPLATE_URL = 'blueprint-composer/component/spec-editor/spec-editor.template.html';
export default MODULE_NAME;
@@ -79,7 +82,7 @@ export function specEditorDirective($rootScope, $templateCache, $injector, $sani
model: '='
},
controller: ['$scope', '$element', controller],
- template: template,
+ templateUrl: TEMPLATE_URL,
link: link,
controllerAs: 'specEditor',
};
@@ -901,3 +904,7 @@ export function specEditorTypeFilter() {
});
}
}
+
+function templateCache($templateCache) {
+ $templateCache.put(TEMPLATE_URL, template);
+}
[4/5] brooklyn-ui git commit: add a 'defer-to-preexisting-id'
attribute to script tags
Posted by tb...@apache.org.
add a 'defer-to-preexisting-id' attribute to script tags
this allows scripts in templates to "opt-in" to being overridable;
our custom decorator has no effect unless this attribute is set,
so we guarantee not to change any behaviour in 3rd party libraries
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/116c50e7
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/116c50e7
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/116c50e7
Branch: refs/heads/master
Commit: 116c50e785a580818e67756cd0f82a1cdd0294fd
Parents: c2ae17f
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Fri Nov 23 12:20:16 2018 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Fri Nov 23 12:22:06 2018 +0000
----------------------------------------------------------------------
.../catalog-selector.template.html | 2 +-
.../custom-config-widget/suggestion-dropdown.html | 2 +-
.../spec-editor/spec-editor.template.html | 18 +++++++++---------
.../script-tag-non-overwrite.js | 15 +++++++++++----
4 files changed, 22 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/116c50e7/ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.template.html
----------------------------------------------------------------------
diff --git a/ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.template.html b/ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.template.html
index 79ea8e7..55dc304 100644
--- a/ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.template.html
+++ b/ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.template.html
@@ -152,7 +152,7 @@
</div>
<!-- QUICK INFO TEMPLATE :: START-->
-<script type="text/ng-template" id="blueprint-composer/component/catalog-selector/quick-info.html">
+<script type="text/ng-template" id="blueprint-composer/component/catalog-selector/quick-info.html" defer-to-preexisting-id="true">
<div class="palette-item-quick-info">
<div class="quick-info-title">{{ popover | entityName }}
<br-svg type="close" class="pull-right closer" ng-click="closePopover()"></br-svg>
http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/116c50e7/ui-modules/blueprint-composer/app/components/custom-config-widget/suggestion-dropdown.html
----------------------------------------------------------------------
diff --git a/ui-modules/blueprint-composer/app/components/custom-config-widget/suggestion-dropdown.html b/ui-modules/blueprint-composer/app/components/custom-config-widget/suggestion-dropdown.html
index 93d35ac..d938106 100644
--- a/ui-modules/blueprint-composer/app/components/custom-config-widget/suggestion-dropdown.html
+++ b/ui-modules/blueprint-composer/app/components/custom-config-widget/suggestion-dropdown.html
@@ -62,7 +62,7 @@
</div>
<!--TYPEAHEAD TEMPLATE :: START-->
-<script type="text/ng-template" id="SuggestionTemplate.html">
+<script type="text/ng-template" id="SuggestionTemplate.html" defer-to-preexisting-id="true">
<div class="dropdown-item">
<span class="dropdown-item-value" ng-bind-html="match.model.value | uibTypeaheadHighlight:query"></span>
<p class="dropdown-item-description" ng-if="match.model.description">{{ match.model.description }}</p>
http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/116c50e7/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.template.html
----------------------------------------------------------------------
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 bfd51a9..31af6f8 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
@@ -342,7 +342,7 @@
<!-- ENTITY LOCATION -->
<ng-include src="'blueprint-composer/component/spec-editor/section-locations.html'"></ng-include>
-<script type="text/ng-template" id="blueprint-composer/component/spec-editor/section-locations.html">
+<script type="text/ng-template" id="blueprint-composer/component/spec-editor/section-locations.html" defer-to-preexisting-id="true">
<br-collapsible ng-if="[FAMILIES.ENTITY, FAMILIES.SPEC].indexOf(model.family) > -1" state="state.location.open">
<heading>
Location
@@ -372,7 +372,7 @@
<!-- ENTITY POLICIES -->
<ng-include src="'blueprint-composer/component/spec-editor/section-policies.html'"></ng-include>
-<script type="text/ng-template" id="blueprint-composer/component/spec-editor/section-policies.html">
+<script type="text/ng-template" id="blueprint-composer/component/spec-editor/section-policies.html" defer-to-preexisting-id="true">
<br-collapsible ng-if="[FAMILIES.ENTITY, FAMILIES.SPEC].indexOf(model.family) > -1" state="state.policy.open">
<heading>
Policies
@@ -408,7 +408,7 @@
<!-- ENTITY ENRICHERS -->
<ng-include src="'blueprint-composer/component/spec-editor/section-enrichers.html'"></ng-include>
-<script type="text/ng-template" id="blueprint-composer/component/spec-editor/section-enrichers.html">
+<script type="text/ng-template" id="blueprint-composer/component/spec-editor/section-enrichers.html" defer-to-preexisting-id="true">
<br-collapsible ng-if="[FAMILIES.ENTITY, FAMILIES.SPEC].indexOf(model.family) > -1" state="state.enricher.open">
<heading>
Enrichers
@@ -443,12 +443,12 @@
</script>
<ng-include src="'blueprint-composer/component/spec-editor/section-others.html'"></ng-include>
-<script type="text/ng-template" id="blueprint-composer/component/spec-editor/section-others.html">
+<script type="text/ng-template" id="blueprint-composer/component/spec-editor/section-others.html" defer-to-preexisting-id="true">
</script>
<!-- CONFIG INFO TEMPLATE :: START -->
-<script type="text/ng-template" id="blueprint-composer/component/spec-editor/config-info.html">
+<script type="text/ng-template" id="blueprint-composer/component/spec-editor/config-info.html" defer-to-preexisting-id="true">
<div class="config-item-quick-info">
<div class="quick-info-metadata">
<p><i class="mini-icon fa fa-fw fa-cog"></i> <samp class="type-symbolic-name">{{item.name}}</samp>
@@ -463,7 +463,7 @@
<!-- CONFIG INFO TEMPLATE :: START-->
<!-- SEARCH POLICY TEMPLATE :: START -->
-<script type="text/ng-template" id="blueprint-composer/component/spec-editor/search-policy.html">
+<script type="text/ng-template" id="blueprint-composer/component/spec-editor/search-policy.html" defer-to-preexisting-id="true">
<div ng-click="$event.stopPropagation(); $event.preventDefault();">
<input ng-model="state.policy.search" type="text" class="form-control" placeholder="Search for a policy" auto-focus blur-on-enter />
</div>
@@ -471,7 +471,7 @@
<!--SEARCH POLICY TEMPLATE :: START-->
<!-- SEARCH ENRICHER TEMPLATE :: START -->
-<script type="text/ng-template" id="blueprint-composer/component/spec-editor/search-enricher.html">
+<script type="text/ng-template" id="blueprint-composer/component/spec-editor/search-enricher.html" defer-to-preexisting-id="true">
<div ng-click="$event.stopPropagation(); $event.preventDefault();">
<input ng-model="state.enricher.search" type="text" class="form-control" placeholder="Search for an enricher" auto-focus blur-on-enter />
</div>
@@ -479,7 +479,7 @@
<!--SEARCH ENRICHER TEMPLATE :: START-->
<!--TYPEAHEAD TEMPLATE :: START-->
-<script type="text/ng-template" id="blueprint-composer/component/spec-editor/config-item.html">
+<script type="text/ng-template" id="blueprint-composer/component/spec-editor/config-item.html" defer-to-preexisting-id="true">
<div class="dropdown-item" ng-init="item = match.model">
<div class="dropdown-row">
<span ng-bind-html="match.model.name | uibTypeaheadHighlight:query" class="config-name"></span>
@@ -494,7 +494,7 @@
<!--TYPEAHEAD TEMPLATE :: END-->
<!--ADJUNCT TEMPLATE :: START-->
-<script type="text/ng-template" id="blueprint-composer/component/spec-editor/adjunct.html">
+<script type="text/ng-template" id="blueprint-composer/component/spec-editor/adjunct.html" defer-to-preexisting-id="true">
<div class="media" ng-class="{'has-issues': adjunct.hasIssues()}">
<div class="media-left media-middle">
<img ng-src="{{adjunct.icon}}" alt="{{adjunct | entityName}} logo" class="media-object" />
http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/116c50e7/ui-modules/utils/script-tag-non-overwrite/script-tag-non-overwrite.js
----------------------------------------------------------------------
diff --git a/ui-modules/utils/script-tag-non-overwrite/script-tag-non-overwrite.js b/ui-modules/utils/script-tag-non-overwrite/script-tag-non-overwrite.js
index 387a0bf..c69996a 100644
--- a/ui-modules/utils/script-tag-non-overwrite/script-tag-non-overwrite.js
+++ b/ui-modules/utils/script-tag-non-overwrite/script-tag-non-overwrite.js
@@ -20,9 +20,16 @@
import angular from 'angular';
/**
- * If included, this decorates the default angular `<script>` tag so that it checks the
- * template cache and does _not_ put the contents of the `script` into the cache if there
- * is already an element with that ID present.
+ * If included, this decorates the default angular `<script>` tag so that it if a
+ * 'defer-to-preexisting-id' attribute is set, it will check the template cache and
+ * skip putting the contents of the `script` into the cache if there is already an
+ * element with that ID present.
+ *
+ * This allows us to include `<script type="ng-template" id="..." defer-to-preexisting-id="true">` blocks
+ * in HTML templates that work in the usual way, but with the extra "defer" attribute we can allow
+ * the template to be overridden by a `run` block (or other block) installing a custom HTML template
+ * under the same ID. (By default the `script` directive will always install the ID, on every
+ * directive processing on the template, meaning one cannot easily override the template.)
*/
const MODULE_NAME = 'brooklyn.components.script-tag-non-overwrite';
@@ -38,7 +45,7 @@ function scriptTagDirectiveDecorator($delegate, $templateCache) {
let base = $delegate[0];
return [ Object.assign({}, base, { compile: function(el, attr) {
let match = $templateCache.get(attr.id);
- if (!(match === null || typeof match === 'undefined')) {
+ if (attr.deferToPreexistingId && !(match === null || typeof match === 'undefined')) {
// no-op if this ID is already in the cache (e.g. manually overridden)
return function() {};
}
[5/5] brooklyn-ui git commit: This closes #113
Posted by tb...@apache.org.
This closes #113
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/84a6f7b3
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/84a6f7b3
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/84a6f7b3
Branch: refs/heads/master
Commit: 84a6f7b36ace5a92c3d42b91b52c1ae136c11c36
Parents: 0249a56 116c50e
Author: Thomas Bouron <th...@cloudsoftcorp.com>
Authored: Sun Nov 25 09:34:11 2018 +0000
Committer: Thomas Bouron <th...@cloudsoftcorp.com>
Committed: Sun Nov 25 09:34:11 2018 +0000
----------------------------------------------------------------------
.../catalog-selector.template.html | 2 +-
.../suggestion-dropdown.html | 2 +-
.../spec-editor/spec-editor.directive.js | 13 ++++-
.../spec-editor/spec-editor.template.html | 18 +++----
ui-modules/blueprint-composer/app/index.js | 3 +-
.../script-tag-non-overwrite.js | 55 ++++++++++++++++++++
6 files changed, 79 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
[3/5] brooklyn-ui git commit: make template url lookup consistent as
per PR comments
Posted by tb...@apache.org.
make template url lookup consistent as per PR comments
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/c2ae17f3
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/c2ae17f3
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/c2ae17f3
Branch: refs/heads/master
Commit: c2ae17f39aa2a69951f8bfe662ef05ef0aaf5612
Parents: b04423b
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Fri Nov 23 11:47:21 2018 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Fri Nov 23 11:47:21 2018 +0000
----------------------------------------------------------------------
.../app/components/spec-editor/spec-editor.directive.js | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/c2ae17f3/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.directive.js
----------------------------------------------------------------------
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 483ca72..53be4f2 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
@@ -82,7 +82,9 @@ export function specEditorDirective($rootScope, $templateCache, $injector, $sani
model: '='
},
controller: ['$scope', '$element', controller],
- templateUrl: TEMPLATE_URL,
+ templateUrl: function (tElement, tAttrs) {
+ return tAttrs.templateUrl || TEMPLATE_URL;
+ },
link: link,
controllerAs: 'specEditor',
};
[2/5] brooklyn-ui git commit: decorate `script` directive to prevent
re-overriding of templates
Posted by tb...@apache.org.
decorate `script` directive to prevent re-overriding of templates
by default `<script>` will install to template cache whenever it is processed as a directive.
this decorates it to be no-op if there is already something in the cache with that name,
allowing programmatic overrides of templates configured using `<script id="...">` notation.
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/b04423b1
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/b04423b1
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/b04423b1
Branch: refs/heads/master
Commit: b04423b169e0d9a749ace79ccd446b4c6f3bb232
Parents: 722d251
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Thu Nov 22 11:07:47 2018 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Thu Nov 22 11:07:47 2018 +0000
----------------------------------------------------------------------
ui-modules/blueprint-composer/app/index.js | 3 +-
.../script-tag-non-overwrite.js | 48 ++++++++++++++++++++
2 files changed, 50 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/b04423b1/ui-modules/blueprint-composer/app/index.js
----------------------------------------------------------------------
diff --git a/ui-modules/blueprint-composer/app/index.js b/ui-modules/blueprint-composer/app/index.js
index 34b3c5b..08019ee 100755
--- a/ui-modules/blueprint-composer/app/index.js
+++ b/ui-modules/blueprint-composer/app/index.js
@@ -69,13 +69,14 @@ import {graphicalEditDslState, dslParamLabelFilter} from "./views/main/graphical
import bottomSheet from "brooklyn-ui-utils/bottom-sheet/bottom-sheet";
import stackViewer from 'angular-java-stack-viewer';
import {EntityFamily} from "./components/util/model/entity.model";
+import scriptTagDecorator from 'brooklyn-ui-utils/script-tag-non-overwrite/script-tag-non-overwrite';
angular.module('app', [ngAnimate, ngResource, ngCookies, ngClipboard, uiRouter, 'ui.router.state.events', brCore,
brServerStatus, brAutoFocus, brIconGenerator, brInterstitialSpinner, brooklynModuleLinks, brooklynUserManagement,
brYamlEditor, brUtils, brSpecEditor, brooklynCatalogSaver, brooklynApi, bottomSheet, stackViewer, brDragndrop,
customActionDirective, customConfigSuggestionDropdown, paletteApiProvider, paletteServiceProvider, blueprintLoaderApiProvider,
breadcrumbs, catalogSelector, designer, objectCache, entityFilters, locationFilter, actionService, blueprintService,
- dslService, paletteDragAndDropService, recentlyUsedService])
+ dslService, paletteDragAndDropService, recentlyUsedService, scriptTagDecorator])
.provider('composerOverrides', composerOverridesProvider)
.filter('dslParamLabel', ['$filter', dslParamLabelFilter])
.config(['$urlRouterProvider', '$stateProvider', '$logProvider', applicationConfig])
http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/b04423b1/ui-modules/utils/script-tag-non-overwrite/script-tag-non-overwrite.js
----------------------------------------------------------------------
diff --git a/ui-modules/utils/script-tag-non-overwrite/script-tag-non-overwrite.js b/ui-modules/utils/script-tag-non-overwrite/script-tag-non-overwrite.js
new file mode 100644
index 0000000..387a0bf
--- /dev/null
+++ b/ui-modules/utils/script-tag-non-overwrite/script-tag-non-overwrite.js
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import angular from 'angular';
+
+/**
+ * If included, this decorates the default angular `<script>` tag so that it checks the
+ * template cache and does _not_ put the contents of the `script` into the cache if there
+ * is already an element with that ID present.
+ */
+
+const MODULE_NAME = 'brooklyn.components.script-tag-non-overwrite';
+
+angular.module(MODULE_NAME, [])
+ .decorator('scriptDirective', ['$delegate', '$templateCache', scriptTagDirectiveDecorator]);
+
+export default MODULE_NAME;
+
+const BROOKLYN_CONFIG = 'brooklyn.config';
+
+function scriptTagDirectiveDecorator($delegate, $templateCache) {
+ let base = $delegate[0];
+ return [ Object.assign({}, base, { compile: function(el, attr) {
+ let match = $templateCache.get(attr.id);
+ if (!(match === null || typeof match === 'undefined')) {
+ // no-op if this ID is already in the cache (e.g. manually overridden)
+ return function() {};
+ }
+ // otherwise do default behaviour
+ return base.compile(el, attr);
+ } }) ];
+}