blob: dbccf97fc7c7879bee8daf6d8a8ae1d65f9d1dfd [file] [log] [blame]
Steven Burrows86af4352016-11-16 18:19:12 -06001/*
2 * Copyright 2015-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 -- Widget -- List Service
19 */
20
21(function () {
22 'use strict';
23
24 function addProp(el, label, value) {
25 var tr = el.append('tr'),
26 lab;
27 if (typeof label === 'string') {
28 lab = label.replace(/_/g, ' ');
29 } else {
30 lab = label;
31 }
32
33 function addCell(cls, txt) {
34 tr.append('td').attr('class', cls).html(txt);
35 }
36
37 addCell('label', lab + ' :');
38 addCell('value', value);
39 }
40
41 function addSep(el) {
42 el.append('tr').append('td').attr('colspan', 2).append('hr');
43 }
44
45 function listProps(el, data) {
46 data.propOrder.forEach(function (p) {
47 if (p === '-') {
48 addSep(el);
49 } else {
50 addProp(el, p, data.props[p]);
51 }
52 });
53 }
54
55 angular.module('onosWidget')
56 .factory('ListService', [
57 function () {
Steven Burrowsaf96a212016-12-28 12:57:02 +000058 return {
59 listProps: listProps
60 };
Steven Burrows86af4352016-11-16 18:19:12 -060061 }]);
62}());