in ui-modules/blueprint-importer/app/views/main/main.controller.js [71:153]
function bottomSheetController($log, brBrandInfo, brBottomSheetInstance, catalogApi, brSnackbar, yaml) {
this.loading = true;
this.imported = false;
this.vendors = brBrandInfo.getVendorPackages();
this.close = ()=> {
brBottomSheetInstance.close('User closed the bottom sheet');
};
this.investigate = ()=> {
brBottomSheetInstance.updateMode('inset');
};
this.onClipboardSuccess = (e)=> {
angular.element(e.trigger).triggerHandler('copied');
e.clearSelection();
};
this.onClipboardError = (e)=> {
let message = '';
let actionKey = e.action === 'cut' ? 'X' : 'C';
if(/iPhone|iPad/i.test(navigator.userAgent)) {
message = 'No support :(';
}
else if(/Mac/i.test(navigator.userAgent)) {
message = 'Press ⌘-' + actionKey + ' to ' + e.action;
}
else {
message = 'Press Ctrl-' + actionKey + ' to ' + e.action;
}
brSnackbar.create(message);
};
this.getCatalogItemUrl = (item)=> {
switch (item.itemType.toLowerCase()) {
case 'template':
case 'entity':
case 'policy':
let bundle = item.containingBundle.split(':');
return `/brooklyn-ui-catalog/#!/bundles/${bundle[0]}/${bundle[1]}/types/${item.symbolicName}/${item.version}`;
case 'location':
return `/brooklyn-ui-location-manager/#!/location?symbolicName=${item.symbolicName}&version=${item.version}`;
default:
return;
}
};
this.getDeployUrl = (item)=> {
switch (item.itemType.toLowerCase()) {
case 'template':
let bundle = item.containingBundle.split(':');
return `/#!/deploy/${bundle[0]}/${bundle[1]}/${item.symbolicName}/${item.version}`;
case 'entity':
let yaml = {
name: item.name,
services: [{
type: item.symbolicName + ':' + item.version
}]
};
if (brBrandInfo.blueprintComposerBaseUrl) {
return brBrandInfo.blueprintComposerBaseUrl + '#!/graphical?format=brooklyn-camp&yaml=' + JSON.stringify(yaml);
} else {
return;
}
default:
return;
}
};
this.canBeDeployed = (item)=> {
return ['template', 'entity'].indexOf(item.itemType.toLowerCase()) > -1;
};
catalogApi.create(yaml).then((response)=> {
$log.info('Blueprint import ... success ', response);
this.imported = true;
this.importedItems = response;
}).catch((response)=> {
$log.error('Blueprint import ... error ', response);
this.error = {
title: 'Blueprint import failed',
message: response.error.message,
details: response.error.details
};
}).finally(()=> {
this.loading = false;
});
}