Steven Burrows | 57e24e9 | 2016-08-04 18:38:24 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | /* |
| 18 | ONOS GUI -- Topology Hosts Module. |
| 19 | Module that holds the hosts for a region |
| 20 | */ |
| 21 | |
| 22 | (function () { |
| 23 | 'use strict'; |
| 24 | |
Steven Burrows | dfa52b0 | 2016-09-02 13:50:43 +0100 | [diff] [blame^] | 25 | var Collection, Model; |
Steven Burrows | 57e24e9 | 2016-08-04 18:38:24 +0100 | [diff] [blame] | 26 | |
| 27 | function createHostCollection(data, region) { |
| 28 | |
| 29 | var HostCollection = Collection.extend({ |
| 30 | model: Model |
| 31 | }); |
| 32 | |
| 33 | var hosts = []; |
| 34 | data.forEach(function (hostsLayer) { |
| 35 | hostsLayer.forEach(function (host) { |
| 36 | hosts.push(host); |
| 37 | }); |
| 38 | }); |
| 39 | |
| 40 | return new HostCollection(hosts); |
| 41 | } |
| 42 | |
| 43 | angular.module('ovTopo2') |
Steven Burrows | dfa52b0 | 2016-09-02 13:50:43 +0100 | [diff] [blame^] | 44 | .factory('Topo2HostService', [ |
Steven Burrows | ec1f45c | 2016-08-08 16:14:41 +0100 | [diff] [blame] | 45 | 'Topo2Collection', 'Topo2NodeModel', 'Topo2ViewService', |
| 46 | function (_Collection_, _NodeModel_, classnames, _t2vs_) { |
Steven Burrows | 57e24e9 | 2016-08-04 18:38:24 +0100 | [diff] [blame] | 47 | |
Steven Burrows | ec1f45c | 2016-08-08 16:14:41 +0100 | [diff] [blame] | 48 | Collection = _Collection_; |
Steven Burrows | 57e24e9 | 2016-08-04 18:38:24 +0100 | [diff] [blame] | 49 | |
Steven Burrows | ec1f45c | 2016-08-08 16:14:41 +0100 | [diff] [blame] | 50 | Model = _NodeModel_.extend({ |
| 51 | nodeType: 'host' |
| 52 | }); |
Steven Burrows | 57e24e9 | 2016-08-04 18:38:24 +0100 | [diff] [blame] | 53 | |
Steven Burrows | ec1f45c | 2016-08-08 16:14:41 +0100 | [diff] [blame] | 54 | return { |
| 55 | createHostCollection: createHostCollection |
| 56 | }; |
| 57 | } |
| 58 | ]); |
Steven Burrows | 57e24e9 | 2016-08-04 18:38:24 +0100 | [diff] [blame] | 59 | |
| 60 | })(); |