Matteo Scandolo | ba678a9 | 2016-06-20 17:16:15 -0700 | [diff] [blame] | 1 | /** |
| 2 | * © OpenCORD |
| 3 | * |
| 4 | * Visit http://guide.xosproject.org/devguide/addview/ for more information |
| 5 | * |
| 6 | * Created by teone on 6/22/16. |
| 7 | */ |
| 8 | |
| 9 | (function () { |
| 10 | 'use strict'; |
| 11 | |
| 12 | /** |
| 13 | * @ngdoc service |
| 14 | * @name xos.NetworkTemplateEncoder.serviceGrid |
| 15 | **/ |
| 16 | |
| 17 | // TODO write tests |
| 18 | angular.module('xos.serviceGrid') |
| 19 | .service('NetworkTemplateEncoder', function($q, Networkstemplates){ |
| 20 | |
| 21 | this.buildTosca = (templateId, toscaSpec) => { |
| 22 | const d = $q.defer(); |
| 23 | Networkstemplates.get({id: templateId}).$promise |
| 24 | .then(template => { |
| 25 | const toscaObj = {}; |
| 26 | toscaObj[`network_template#${template.name}`] = { |
| 27 | type: 'tosca.nodes.NetworkTemplate' |
| 28 | }; |
| 29 | angular.extend(toscaSpec.topology_template.node_templates, toscaObj); |
| 30 | d.resolve([toscaSpec, template]); |
| 31 | }) |
| 32 | .catch(e => { |
| 33 | d.reject(e); |
| 34 | }); |
| 35 | |
| 36 | return d.promise; |
| 37 | }; |
| 38 | }); |
| 39 | })(); |
| 40 | |