diff options
author | Koren Lev <korenlev@gmail.com> | 2017-07-27 16:42:15 +0300 |
---|---|---|
committer | Koren Lev <korenlev@gmail.com> | 2017-07-27 16:42:15 +0300 |
commit | b88c78e3cf2bef22aa2f1c4d0bf305e303bc15f0 (patch) | |
tree | ffa30a6e1511d72562d8772b8700cda52b2752a1 /ui/imports/ui/components/scheduled-scans-list | |
parent | b70483739d1f6f4f0d31987ed2e4d1e30d71d579 (diff) |
adding calipso ui
Change-Id: Ifa6f63daebb07f45580f747341960e898fdb00c4
Signed-off-by: Koren Lev <korenlev@gmail.com>
Diffstat (limited to 'ui/imports/ui/components/scheduled-scans-list')
3 files changed, 259 insertions, 0 deletions
diff --git a/ui/imports/ui/components/scheduled-scans-list/scheduled-scans-list.html b/ui/imports/ui/components/scheduled-scans-list/scheduled-scans-list.html new file mode 100644 index 0000000..4b141e7 --- /dev/null +++ b/ui/imports/ui/components/scheduled-scans-list/scheduled-scans-list.html @@ -0,0 +1,66 @@ +<!-- +######################################################################################## +# 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="ScheduledScansList"> +<div class="os-scheduled-scans-list cards white"> + <div class="sm-table-section"> + <h3>Scheduled Scans</h3> + <table class="sm-scheduled-scans-table table"> + <thead> + <tr> + <th>Log Level</th> + <th>Clear</th> + <th>Scan Only Iventory</th> + <th>Scan Only Links</th> + <th>Scan Only Cliques</th> + <th>Environment</th> + <th>Inventory</th> + <th>Object ID</th> + <th>Frequency</th> + <th>Submit Timestamp</th> + <th>Action</th> + </tr> </thead> + <tbody> + {{#each scan in scheduledScans }} + <tr> + <td>{{ scan.log_level }}</td> + <td>{{ scan.clear }}</td> + <td>{{ scan.scan_only_inventory }}</td> + <td>{{ scan.scan_only_links }}</td> + <td>{{ scan.scan_only_cliques }}</td> + <td>{{ scan.environment }}</td> + <td>{{ scan.inventory }}</td> + <td>{{ scan.object_id }}</td> + <td>{{ scan.frequency }}</td> + <td>{{ scan.submit_timestamp }}</td> + <td> + <a href="{{pathFor route='scheduled-scan' + query=(asHash _id=(idToStr scan._id) action='view') }}" + ><i class="cl-action-icon fa fa-eye" area-hidden="true"></i></a> + <a href="{{pathFor route='scheduled-scan' + query=(asHash _id=(idToStr scan._id) action='update') }}" + ><i class="cl-action-icon fa fa-pencil" area-hidden="true"></i></a> + + <a href="{{pathFor route='scheduled-scan' + query=(asHash _id=(idToStr scan._id) action='remove') }}" + ><i class="cl-action-icon fa fa-trash-o" area-hidden="true"></i></a> + </td> + </tr> + {{/each }} + </tbody> + </table> + </div> + + <div class="sm-pager-section"> + {{> Pager (argsPager currentPage amountPerPage totalItems) }} + </div> + +</div> +</template> diff --git a/ui/imports/ui/components/scheduled-scans-list/scheduled-scans-list.js b/ui/imports/ui/components/scheduled-scans-list/scheduled-scans-list.js new file mode 100644 index 0000000..7aa76e9 --- /dev/null +++ b/ui/imports/ui/components/scheduled-scans-list/scheduled-scans-list.js @@ -0,0 +1,160 @@ +///////////////////////////////////////////////////////////////////////////////////////// +// 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: ScheduledScansList + */ + +//import { Meteor } from 'meteor/meteor'; +import * as R from 'ramda'; +import { Counts } from 'meteor/tmeasday:publish-counts'; +import { Template } from 'meteor/templating'; +import { ReactiveDict } from 'meteor/reactive-dict'; +import { SimpleSchema } from 'meteor/aldeed:simple-schema'; +import { ScheduledScans, + subsScheduledScansPageAmountSorted, + subsScheduledScansPageAmountSortedCounter, +} from '/imports/api/scheduled-scans/scheduled-scans'; + +import '/imports/ui/components/pager/pager'; + +import './scheduled-scans-list.html'; + +/* + * Lifecycles + */ + +Template.ScheduledScansList.onCreated(function() { + var instance = this; + + instance.state = new ReactiveDict(); + instance.state.setDefault({ + env: null, + page: 1, + amountPerPage: 10, + sortField: null, + sortDirection: -1, + }); + + instance.autorun(function () { + let data = Template.currentData(); + + new SimpleSchema({ + }).validate(data); + }); + + instance.autorun(function () { + let amountPerPage = instance.state.get('amountPerPage'); + let page = instance.state.get('page'); + let sortField = instance.state.get('sortField'); + let sortDirection = instance.state.get('sortDirection'); + + instance.subscribe(subsScheduledScansPageAmountSorted, + page, amountPerPage, sortField, sortDirection); + }); +}); + +/* +Template.ScheduledScansList.rendered = function() { +}; +*/ + +/* + * Events + */ + +Template.ScheduledScansList.events({ +}); + +/* + * Helpers + */ + +Template.ScheduledScansList.helpers({ + scheduledScans: function () { + let instance = Template.instance(); + let page = instance.state.get('page'); + let amountPerPage = instance.state.get('amountPerPage'); + let sortField = instance.state.get('sortField'); + let sortDirection = instance.state.get('sortDirection'); + + let skip = (page - 1) * amountPerPage; + let sortParams = {}; + sortParams = R.ifElse(R.isNil, R.always(sortParams), + R.assoc(R.__, sortDirection, sortParams))(sortField); + + let qParams = { + limit: amountPerPage, + skip: skip, + sort: sortParams, + }; + + return ScheduledScans.find({}, qParams); + }, + + currentPage: function () { + let instance = Template.instance(); + return instance.state.get('page'); + }, + + amountPerPage: function () { + let instance = Template.instance(); + return instance.state.get('amountPerPage'); + }, + + totalItems: function () { + let counterName = subsScheduledScansPageAmountSortedCounter; + + return Counts.get(counterName); + }, + + argsPager: function (currentPage, amountPerPage, totalItems) { + let instance = Template.instance(); + let totalPages = Math.ceil(totalItems / amountPerPage); + + return { + disableNext: currentPage * amountPerPage > totalItems, + disablePrev: currentPage == 1, + totalPages: totalPages, + currentPage: currentPage, + onReqNext: function () { + console.log('next'); + let page = (currentPage * amountPerPage > totalItems) ? currentPage : currentPage + 1; + instance.state.set('page', page); + }, + onReqPrev: function () { + console.log('prev'); + let page = (currentPage == 1) ? currentPage : currentPage - 1; + instance.state.set('page', page); + }, + onReqFirst: function () { + console.log('req first'); + instance.state.set('page', 1); + }, + onReqLast: function () { + console.log('req last'); + instance.state.set('page', totalPages); + }, + onReqPage: function (pageNumber) { + console.log('req page'); + let page; + if (pageNumber <= 1) { + page = 1; + } else if (pageNumber > Math.ceil(totalItems / amountPerPage)) { + page = totalPages; + } else { + page = pageNumber; + } + + instance.state.set('page', page); + }, + }; + }, +}); // end: helpers + + diff --git a/ui/imports/ui/components/scheduled-scans-list/scheduled-scans-list.styl b/ui/imports/ui/components/scheduled-scans-list/scheduled-scans-list.styl new file mode 100644 index 0000000..bd2f7c0 --- /dev/null +++ b/ui/imports/ui/components/scheduled-scans-list/scheduled-scans-list.styl @@ -0,0 +1,33 @@ +.os-scheduled-scans-list + display: flex; + flex-flow: column nowrap; + margin: 20px; + + .cl-action-icon, + .card.fa.cl-action-icon + font-size: 16px !important; + + .sm-scheduled-scans-table + th + color: spark-blue + + a + color: spark-blue; + cursor: pointer; + i.fa + padding: 0px 3px; + font-size: small; + + .sm-action-bar + display: flex; + + a + margin: 0px 5px; + + .cl-action-icon + color: gray + + .sm-pager-section + display: flex; + justify-content: center; + |