Skip to content

Commit ce5fca3

Browse files
committed
Merge branch 'master' into landscape-view
2 parents 80b7ac3 + 43c154c commit ce5fca3

21 files changed

+522
-441
lines changed

ui-modules/blueprint-composer/app/components/blueprint-data-manager/blueprint-data-manager.directive.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,27 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
import template from "./blueprint-data-manager.template.html";
20-
import {saveAs} from "file-saver/FileSaver";
21-
const VALID_FILENAME_REGEX = /^.*\.ya?ml$/
22-
const FILETYPE_TOKEN_REGEX = /^.*\.(.*)$/
19+
import angular from 'angular';
20+
import template from './blueprint-data-manager.template.html';
21+
import {saveAs} from 'file-saver/FileSaver';
22+
23+
const MODULE_NAME = 'brooklyn.components.blueprint-data-manager';
24+
const TEMPLATE_URL = 'blueprint-composer/component/blueprint-data-manager/index.html';
25+
const VALID_FILENAME_REGEX = /^.*\.ya?ml$/;
26+
const FILETYPE_TOKEN_REGEX = /^.*\.(.*)$/;
27+
28+
angular.module(MODULE_NAME, [])
29+
.directive('blueprintDataManager', blueprintDataManagerDirective)
30+
.run(['$templateCache', templateCache]);
31+
32+
export default MODULE_NAME;
2333

2434
export function blueprintDataManagerDirective() {
2535
return {
2636
restrict: 'E',
27-
template: template,
37+
templateUrl: function(tElement, tAttrs) {
38+
return tAttrs.templateUrl || TEMPLATE_URL;
39+
},
2840
controller: ['$rootScope', '$scope', '$element', '$document', 'blueprintService', 'brSnackbar', controller]
2941
};
3042

@@ -88,7 +100,7 @@ export function blueprintDataManagerDirective() {
88100
function readFile(file) {
89101
if (VALID_FILENAME_REGEX.test(file.name)) {
90102
var reader = new FileReader();
91-
reader.addEventListener("load", function () {
103+
reader.addEventListener('load', function () {
92104
try {
93105
var yaml = reader.result;
94106
blueprintService.setFromYaml(yaml, true);
@@ -118,3 +130,7 @@ export function blueprintDataManagerDirective() {
118130
});
119131
}
120132
}
133+
134+
function templateCache($templateCache) {
135+
$templateCache.put(TEMPLATE_URL, template);
136+
}

ui-modules/blueprint-composer/app/components/breacrumbs/breadcrumbs.directive.js

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,49 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19+
import angular from 'angular';
1920
import template from './breadcrumbs.template.html';
2021

22+
const MODULE_NAME = 'brooklyn.components.breadcrumbs';
23+
const TEMPLATE_URL = 'blueprint-composer/component/breadcrumbs/index.html';
24+
25+
angular.module(MODULE_NAME, [])
26+
.directive('breadcrumbs', breadcrumbsDirective)
27+
.run(['$templateCache', templateCache]);
28+
29+
export default MODULE_NAME;
30+
2131
export function breadcrumbsDirective() {
2232
return {
2333
restrict: 'E',
34+
templateUrl: function(tElement, tAttrs) {
35+
return tAttrs.templateUrl || TEMPLATE_URL;
36+
},
2437
scope: {
2538
entity: '<',
2639
current: '<'
2740
},
28-
template: template,
2941
link: link
30-
}
31-
}
42+
};
3243

33-
function link(scope) {
34-
if (scope.entity) {
35-
scope.breadcrumbs = [];
36-
if (scope.current) {
37-
scope.breadcrumbs.push(scope.current);
38-
}
44+
function link(scope) {
45+
if (scope.entity) {
46+
scope.breadcrumbs = [];
47+
if (scope.current) {
48+
scope.breadcrumbs.push(scope.current);
49+
}
3950

40-
let currentEntity = scope.entity;
41-
while (currentEntity.hasParent()) {
51+
let currentEntity = scope.entity;
52+
while (currentEntity.hasParent()) {
53+
scope.breadcrumbs.push(currentEntity);
54+
currentEntity = currentEntity.parent;
55+
}
4256
scope.breadcrumbs.push(currentEntity);
43-
currentEntity = currentEntity.parent;
57+
scope.breadcrumbs.reverse();
4458
}
45-
scope.breadcrumbs.push(currentEntity);
46-
scope.breadcrumbs.reverse();
4759
}
60+
}
61+
62+
function templateCache($templateCache) {
63+
$templateCache.put(TEMPLATE_URL, template);
4864
}

ui-modules/blueprint-composer/app/components/catalog-saver/catalog-saver.directive.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ import template from './catalog-saver.template.html';
2323
import modalTemplate from './catalog-saver.modal.template.html';
2424
import jsYaml from 'js-yaml';
2525
import brUtils from 'brooklyn-ui-utils/utils/general';
26-
import {yamlState} from "../../views/main/yaml/yaml.state";
27-
import {graphicalState} from "../../views/main/graphical/graphical.state";
2826

2927
const MODULE_NAME = 'brooklyn.components.catalog-saver';
28+
const TEMPLATE_URL = 'blueprint-composer/component/catalog-saver/index.html';
29+
const TEMPLATE_MODAL_URL = 'blueprint-composer/component/catalog-saver/modal.html';
3030

3131
const REASONS = {
3232
new: 0,
@@ -43,14 +43,17 @@ const TYPES = [
4343

4444
angular.module(MODULE_NAME, [angularAnimate, uibModal, brUtils])
4545
.directive('catalogSaver', ['$rootScope', '$uibModal', '$injector', 'composerOverrides', saveToCatalogModalDirective])
46-
.directive('catalogVersion', ['$parse', catalogVersionDirective]);
46+
.directive('catalogVersion', ['$parse', catalogVersionDirective])
47+
.run(['$templateCache', templateCache]);
4748

4849
export default MODULE_NAME;
4950

5051
export function saveToCatalogModalDirective($rootScope, $uibModal, $injector, composerOverrides) {
5152
return {
5253
restrict: 'E',
53-
template: template,
54+
templateUrl: function (tElement, tAttrs) {
55+
return tAttrs.templateUrl || TEMPLATE_URL;
56+
},
5457
scope: {
5558
config: '='
5659
},
@@ -60,14 +63,12 @@ export function saveToCatalogModalDirective($rootScope, $uibModal, $injector, co
6063
function link($scope, $element) {
6164
$scope.buttonText = $scope.config.label || ($scope.config.itemType ? `Update ${$scope.config.name || $scope.config.symbolicName}` : 'Add to catalog');
6265

63-
$injector.get('$templateCache').put('catalog-saver.modal.template.html', modalTemplate);
64-
6566
$scope.activateModal = () => {
6667
// Override callback to update catalog configuration data in other applications
6768
$scope.config = (composerOverrides.updateCatalogConfig || (($scope, $element) => $scope.config))($scope, $element);
6869

6970
let modalInstance = $uibModal.open({
70-
templateUrl: 'catalog-saver.modal.template.html',
71+
templateUrl: TEMPLATE_MODAL_URL,
7172
size: 'save',
7273
controller: ['$scope', 'blueprintService', 'paletteApi', 'brUtilsGeneral', CatalogItemModalController],
7374
scope: $scope,
@@ -162,7 +163,7 @@ export function catalogVersionDirective($parse) {
162163
link: link
163164
};
164165

165-
function link (scope, elm, attr, ctrl) {
166+
function link(scope, elm, attr, ctrl) {
166167
if (!ctrl) {
167168
return;
168169
}
@@ -188,3 +189,8 @@ export function catalogVersionDirective($parse) {
188189
};
189190
}
190191
}
192+
193+
function templateCache($templateCache) {
194+
$templateCache.put(TEMPLATE_URL, template);
195+
$templateCache.put(TEMPLATE_MODAL_URL, modalTemplate);
196+
}

0 commit comments

Comments
 (0)