diff options
Diffstat (limited to 'ui/imports/ui/components/network-info-box')
3 files changed, 109 insertions, 0 deletions
diff --git a/ui/imports/ui/components/network-info-box/network-info-box.html b/ui/imports/ui/components/network-info-box/network-info-box.html new file mode 100644 index 0000000..b9e07f2 --- /dev/null +++ b/ui/imports/ui/components/network-info-box/network-info-box.html @@ -0,0 +1,38 @@ +<!-- +######################################################################################## +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +######################################################################################## + --> +<template name="NetworkInfoBox"> + <div class="cards-450 white flex-box-1"> + <div class="flex-box "> + <div class="flex-box-1"> + <i class="material-icons">device_hub</i> + </div> + <div class="flex-box-2"> + <h3>Network name:<br> {{ network.name }}</h3> + <table class="table table-striped"> + <tbody> + <tr> + <th>Last Scanning</th> + <td></td> + </tr> + <tr> + <th>Ports count</th> + <td>{{ portsCount }}</td> + </tr> + <tr> + <th>Instaces</th> + <td></td> + </tr> + </tbody> + </table> + </div> + </div> + </div> +</template> diff --git a/ui/imports/ui/components/network-info-box/network-info-box.js b/ui/imports/ui/components/network-info-box/network-info-box.js new file mode 100644 index 0000000..8843c5c --- /dev/null +++ b/ui/imports/ui/components/network-info-box/network-info-box.js @@ -0,0 +1,69 @@ +///////////////////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) and others / +// / +// All rights reserved. This program and the accompanying materials / +// are made available under the terms of the Apache License, Version 2.0 / +// which accompanies this distribution, and is available at / +// http://www.apache.org/licenses/LICENSE-2.0 / +///////////////////////////////////////////////////////////////////////////////////////// +/* + * Template Component: NetworkInfoBox + */ + +//import { Meteor } from 'meteor/meteor'; +import { Template } from 'meteor/templating'; +import { ReactiveDict } from 'meteor/reactive-dict'; +import { regexEscape } from '/imports/lib/regex-utils'; +import { Inventory } from '/imports/api/inventories/inventories'; + +import './network-info-box.html'; + +/* + * Lifecycles + */ + +Template.NetworkInfoBox.onCreated(function() { + var instance = this; + + instance.state = new ReactiveDict(); + instance.state.setDefault({ + portsCount: 0 + }); + + instance.autorun(function () { + let network = instance.data.network; + instance.subscribe('inventory?id_path_like&type', network.id_path, 'port'); + + let idPathExp = new RegExp(regexEscape(network.id)); + instance.state.set('portsCount', Inventory.find({ + id_path: idPathExp, + type: 'port' + }).count()); + }); + +}); + +/* +Template.NetworkInfoBox.rendered = function() { +}; +*/ + +/* + * Events + */ + +Template.NetworkInfoBox.events({ +}); + +/* + * Helpers + */ + +Template.NetworkInfoBox.helpers({ + portsCount: function () { + let instance = Template.instance(); + return instance.state.get('portsCount'); + } +}); + + diff --git a/ui/imports/ui/components/network-info-box/network-info-box.styl b/ui/imports/ui/components/network-info-box/network-info-box.styl new file mode 100644 index 0000000..5228d20 --- /dev/null +++ b/ui/imports/ui/components/network-info-box/network-info-box.styl @@ -0,0 +1,2 @@ +/* Set the component style here */ +// "NetworkInfoBox" |