Skip to content

Commit

Permalink
Merge branch 'master' into landscape-view
Browse files Browse the repository at this point in the history
  • Loading branch information
ahgittin committed Nov 8, 2018
2 parents 80b7ac3 + 43c154c commit ce5fca3
Show file tree
Hide file tree
Showing 21 changed files with 522 additions and 441 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,27 @@
* specific language governing permissions and limitations
* under the License.
*/
import template from "./blueprint-data-manager.template.html";
import {saveAs} from "file-saver/FileSaver";
const VALID_FILENAME_REGEX = /^.*\.ya?ml$/
const FILETYPE_TOKEN_REGEX = /^.*\.(.*)$/
import angular from 'angular';
import template from './blueprint-data-manager.template.html';
import {saveAs} from 'file-saver/FileSaver';

const MODULE_NAME = 'brooklyn.components.blueprint-data-manager';
const TEMPLATE_URL = 'blueprint-composer/component/blueprint-data-manager/index.html';
const VALID_FILENAME_REGEX = /^.*\.ya?ml$/;
const FILETYPE_TOKEN_REGEX = /^.*\.(.*)$/;

angular.module(MODULE_NAME, [])
.directive('blueprintDataManager', blueprintDataManagerDirective)
.run(['$templateCache', templateCache]);

export default MODULE_NAME;

export function blueprintDataManagerDirective() {
return {
restrict: 'E',
template: template,
templateUrl: function(tElement, tAttrs) {
return tAttrs.templateUrl || TEMPLATE_URL;
},
controller: ['$rootScope', '$scope', '$element', '$document', 'blueprintService', 'brSnackbar', controller]
};

Expand Down Expand Up @@ -88,7 +100,7 @@ export function blueprintDataManagerDirective() {
function readFile(file) {
if (VALID_FILENAME_REGEX.test(file.name)) {
var reader = new FileReader();
reader.addEventListener("load", function () {
reader.addEventListener('load', function () {
try {
var yaml = reader.result;
blueprintService.setFromYaml(yaml, true);
Expand Down Expand Up @@ -118,3 +130,7 @@ export function blueprintDataManagerDirective() {
});
}
}

function templateCache($templateCache) {
$templateCache.put(TEMPLATE_URL, template);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,49 @@
* specific language governing permissions and limitations
* under the License.
*/
import angular from 'angular';
import template from './breadcrumbs.template.html';

const MODULE_NAME = 'brooklyn.components.breadcrumbs';
const TEMPLATE_URL = 'blueprint-composer/component/breadcrumbs/index.html';

angular.module(MODULE_NAME, [])
.directive('breadcrumbs', breadcrumbsDirective)
.run(['$templateCache', templateCache]);

export default MODULE_NAME;

export function breadcrumbsDirective() {
return {
restrict: 'E',
templateUrl: function(tElement, tAttrs) {
return tAttrs.templateUrl || TEMPLATE_URL;
},
scope: {
entity: '<',
current: '<'
},
template: template,
link: link
}
}
};

function link(scope) {
if (scope.entity) {
scope.breadcrumbs = [];
if (scope.current) {
scope.breadcrumbs.push(scope.current);
}
function link(scope) {
if (scope.entity) {
scope.breadcrumbs = [];
if (scope.current) {
scope.breadcrumbs.push(scope.current);
}

let currentEntity = scope.entity;
while (currentEntity.hasParent()) {
let currentEntity = scope.entity;
while (currentEntity.hasParent()) {
scope.breadcrumbs.push(currentEntity);
currentEntity = currentEntity.parent;
}
scope.breadcrumbs.push(currentEntity);
currentEntity = currentEntity.parent;
scope.breadcrumbs.reverse();
}
scope.breadcrumbs.push(currentEntity);
scope.breadcrumbs.reverse();
}
}

function templateCache($templateCache) {
$templateCache.put(TEMPLATE_URL, template);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import template from './catalog-saver.template.html';
import modalTemplate from './catalog-saver.modal.template.html';
import jsYaml from 'js-yaml';
import brUtils from 'brooklyn-ui-utils/utils/general';
import {yamlState} from "../../views/main/yaml/yaml.state";
import {graphicalState} from "../../views/main/graphical/graphical.state";

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

const REASONS = {
new: 0,
Expand All @@ -43,14 +43,17 @@ const TYPES = [

angular.module(MODULE_NAME, [angularAnimate, uibModal, brUtils])
.directive('catalogSaver', ['$rootScope', '$uibModal', '$injector', 'composerOverrides', saveToCatalogModalDirective])
.directive('catalogVersion', ['$parse', catalogVersionDirective]);
.directive('catalogVersion', ['$parse', catalogVersionDirective])
.run(['$templateCache', templateCache]);

export default MODULE_NAME;

export function saveToCatalogModalDirective($rootScope, $uibModal, $injector, composerOverrides) {
return {
restrict: 'E',
template: template,
templateUrl: function (tElement, tAttrs) {
return tAttrs.templateUrl || TEMPLATE_URL;
},
scope: {
config: '='
},
Expand All @@ -60,14 +63,12 @@ export function saveToCatalogModalDirective($rootScope, $uibModal, $injector, co
function link($scope, $element) {
$scope.buttonText = $scope.config.label || ($scope.config.itemType ? `Update ${$scope.config.name || $scope.config.symbolicName}` : 'Add to catalog');

$injector.get('$templateCache').put('catalog-saver.modal.template.html', modalTemplate);

$scope.activateModal = () => {
// Override callback to update catalog configuration data in other applications
$scope.config = (composerOverrides.updateCatalogConfig || (($scope, $element) => $scope.config))($scope, $element);

let modalInstance = $uibModal.open({
templateUrl: 'catalog-saver.modal.template.html',
templateUrl: TEMPLATE_MODAL_URL,
size: 'save',
controller: ['$scope', 'blueprintService', 'paletteApi', 'brUtilsGeneral', CatalogItemModalController],
scope: $scope,
Expand Down Expand Up @@ -162,7 +163,7 @@ export function catalogVersionDirective($parse) {
link: link
};

function link (scope, elm, attr, ctrl) {
function link(scope, elm, attr, ctrl) {
if (!ctrl) {
return;
}
Expand All @@ -188,3 +189,8 @@ export function catalogVersionDirective($parse) {
};
}
}

function templateCache($templateCache) {
$templateCache.put(TEMPLATE_URL, template);
$templateCache.put(TEMPLATE_MODAL_URL, modalTemplate);
}
Loading

0 comments on commit ce5fca3

Please sign in to comment.