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.SiteEncoder.serviceGrid |
| 15 | **/ |
| 16 | |
| 17 | angular.module('xos.serviceGrid') |
| 18 | .service('SiteEncoder', function($q, Sites){ |
| 19 | |
| 20 | this.buildTosca = (siteId, toscaSpec) => { |
| 21 | const d = $q.defer(); |
| 22 | |
| 23 | Sites.get({id: siteId}).$promise |
| 24 | .then(site => { |
| 25 | const toscaObj = {}; |
| 26 | toscaObj[`${site.name}`] = { |
| 27 | type: 'tosca.nodes.Site' |
| 28 | }; |
| 29 | angular.extend(toscaSpec.topology_template.node_templates, toscaObj); |
| 30 | d.resolve([toscaSpec, site]); |
| 31 | }) |
| 32 | .catch(d.reject); |
| 33 | |
| 34 | |
| 35 | return d.promise; |
| 36 | }; |
| 37 | }); |
| 38 | })(); |
| 39 | |