diff options
Diffstat (limited to 'ui/imports/api')
-rw-r--r-- | ui/imports/api/attributes_for_hover_on_data/attributes_for_hover_on_data.js | 24 | ||||
-rw-r--r-- | ui/imports/api/clique-types/methods.js | 12 | ||||
-rw-r--r-- | ui/imports/api/configurations/configurations.js | 29 | ||||
-rw-r--r-- | ui/imports/api/configurations/methods.js | 39 | ||||
-rw-r--r-- | ui/imports/api/configurations/server/publications.js | 21 | ||||
-rw-r--r-- | ui/imports/api/environments/environments.js | 6 | ||||
-rw-r--r-- | ui/imports/api/inventories/server/methods.js | 28 | ||||
-rw-r--r-- | ui/imports/api/links/server/methods.js | 31 | ||||
-rw-r--r-- | ui/imports/api/messages/server/methods.js | 4 | ||||
-rw-r--r-- | ui/imports/api/messages/server/publications.js | 19 |
10 files changed, 176 insertions, 37 deletions
diff --git a/ui/imports/api/attributes_for_hover_on_data/attributes_for_hover_on_data.js b/ui/imports/api/attributes_for_hover_on_data/attributes_for_hover_on_data.js index ec2f6cd..13c877a 100644 --- a/ui/imports/api/attributes_for_hover_on_data/attributes_for_hover_on_data.js +++ b/ui/imports/api/attributes_for_hover_on_data/attributes_for_hover_on_data.js @@ -7,6 +7,30 @@ // http://www.apache.org/licenses/LICENSE-2.0 / ///////////////////////////////////////////////////////////////////////////////////////// import { Mongo } from 'meteor/mongo'; +import * as R from 'ramda'; export const NodeHoverAttr = new Mongo.Collection( 'attributes_for_hover_on_data', { idGeneration: 'MONGO' }); + +export const calcAttrsForItem = function (node, attrsDefsRec) { + if (R.isNil(attrsDefsRec)) { + return []; + } + + let attrsDefs = attrsDefsRec.attributes; + + return R.reduce((acc, attrDef) => { + if (R.is(Array, attrDef)) { + let value = R.path(attrDef, node); + if (R.isNil(value)) { return acc; } + let name = R.join('.', attrDef); + return R.append(R.assoc(name, value, {}), acc); + + } else { + return R.ifElse(R.isNil, + R.always(acc), + (attrVal) => R.append(R.assoc(attrDef, attrVal, {}), acc) + )(R.prop(attrDef, node)); + } + }, [], attrsDefs); +}; diff --git a/ui/imports/api/clique-types/methods.js b/ui/imports/api/clique-types/methods.js index a62c22f..4257291 100644 --- a/ui/imports/api/clique-types/methods.js +++ b/ui/imports/api/clique-types/methods.js @@ -96,12 +96,12 @@ export const update = new ValidatedMethod({ 'focal_point_type', 'link_types', 'name', ], - cliqueType), { - environment, - focal_point_type, - link_types, - name, - }); + cliqueType), { + environment, + focal_point_type, + link_types, + name, + }); CliqueTypes.update({ _id: _id }, { $set: cliqueType }); } diff --git a/ui/imports/api/configurations/configurations.js b/ui/imports/api/configurations/configurations.js new file mode 100644 index 0000000..067b69f --- /dev/null +++ b/ui/imports/api/configurations/configurations.js @@ -0,0 +1,29 @@ +///////////////////////////////////////////////////////////////////////////////////////// +// 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 / +///////////////////////////////////////////////////////////////////////////////////////// +import { Mongo } from 'meteor/mongo'; +import { SimpleSchema } from 'meteor/aldeed:simple-schema'; +//import * as R from 'ramda'; + +export const Configurations = new Mongo.Collection('configurations', { idGeneration: 'MONGO' }); + +let schema = { + _id: { type: { _str: { type: String, regEx: SimpleSchema.RegEx.Id } } }, + user_id: { + type: String, + }, + messages_view_backward_delta: { + type: Number, + minCount: 1, + defaultValue: '1209600000', // 2 weeks + } +}; + +let simpleSchema = new SimpleSchema(schema); +Configurations.schema = simpleSchema; +Configurations.attachSchema(Configurations.schema); diff --git a/ui/imports/api/configurations/methods.js b/ui/imports/api/configurations/methods.js new file mode 100644 index 0000000..7366e3e --- /dev/null +++ b/ui/imports/api/configurations/methods.js @@ -0,0 +1,39 @@ +///////////////////////////////////////////////////////////////////////////////////////// +// 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 / +///////////////////////////////////////////////////////////////////////////////////////// +import { ValidatedMethod } from 'meteor/mdg:validated-method'; +import { Configurations } from '/imports/api/configurations/configurations'; +import * as R from 'ramda'; + +export const save = new ValidatedMethod({ + name: 'configurations.save', + validate: Configurations.simpleSchema() + .pick([ + 'messages_view_backward_delta' + ]).validator({ clean: true, filter: false }), + run({ + messages_view_backward_delta + }) { + + let userId = this.userId; + let conf = Configurations.findOne({ user_id: userId }); + + if (conf) { + Configurations.update({ _id: conf._id}, { $set: { + messages_view_backward_delta: messages_view_backward_delta + }}); + } else { + let item = Configurations.schema.clean({}); + item = R.merge(item, { + user_id: userId, + messages_view_backward_delta: messages_view_backward_delta + }); + Configurations.insert(item); + } + } +}); diff --git a/ui/imports/api/configurations/server/publications.js b/ui/imports/api/configurations/server/publications.js new file mode 100644 index 0000000..fe9f6fd --- /dev/null +++ b/ui/imports/api/configurations/server/publications.js @@ -0,0 +1,21 @@ +///////////////////////////////////////////////////////////////////////////////////////// +// 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 / +///////////////////////////////////////////////////////////////////////////////////////// +import { Meteor } from 'meteor/meteor'; + +import { Configurations } from '../configurations.js'; + +Meteor.publish('configurations?user', function () { + console.log('server subscribtion: configurations?user'); + + let userId = this.userId; + + let query = { user_id: userId }; + console.log('-query: ', query); + return Configurations.find(query); +}); diff --git a/ui/imports/api/environments/environments.js b/ui/imports/api/environments/environments.js index 5e3b4b2..22e49cf 100644 --- a/ui/imports/api/environments/environments.js +++ b/ui/imports/api/environments/environments.js @@ -32,7 +32,7 @@ export const requiredConfGroups = [ ]; export const optionalConfGroups = [ - // 'NFV_provider', + // 'NFV_provider', 'AMQP', 'Monitoring', 'ACI', @@ -335,8 +335,8 @@ function getSchemaForGroupName(groupName) { return CLISchema; case 'AMQP': return AMQPSchema; -// case 'NFV_provider': -// return NfvProviderSchema; + // case 'NFV_provider': + // return NfvProviderSchema; case 'ACI': return AciSchema; case 'Monitoring': diff --git a/ui/imports/api/inventories/server/methods.js b/ui/imports/api/inventories/server/methods.js index 3daf570..d7e3648 100644 --- a/ui/imports/api/inventories/server/methods.js +++ b/ui/imports/api/inventories/server/methods.js @@ -11,7 +11,8 @@ import * as R from 'ramda'; import { Inventory } from '../inventories'; import { Environments } from '/imports/api/environments/environments'; import { regexEscape } from '/imports/lib/regex-utils'; -import { NodeHoverAttr } from '/imports/api/attributes_for_hover_on_data/attributes_for_hover_on_data'; +import { NodeHoverAttr, calcAttrsForItem } from '/imports/api/attributes_for_hover_on_data/attributes_for_hover_on_data'; + const AUTO_COMPLETE_RESULTS_LIMIT = 15; Meteor.methods({ @@ -125,7 +126,7 @@ Meteor.methods({ let query = { _id: nodeId }; let node = Inventory.findOne(query); let attrsDefs = NodeHoverAttr.findOne({ 'type': node.type }); - let attributes = calcAttrsForNode(node, attrsDefs); + let attributes = calcAttrsForItem(node, attrsDefs); return { node: node, @@ -134,26 +135,3 @@ Meteor.methods({ }; }, }); - -function calcAttrsForNode(node, attrsDefsRec) { - if (R.isNil(attrsDefsRec)) { - return []; - } - - let attrsDefs = attrsDefsRec.attributes; - - return R.reduce((acc, attrDef) => { - if (R.is(Array, attrDef)) { - let value = R.path(attrDef, node); - if (R.isNil(value)) { return acc; } - let name = R.join('.', attrDef); - return R.append(R.assoc(name, value, {}), acc); - - } else { - return R.ifElse(R.isNil, - R.always(acc), - (attrVal) => R.append(R.assoc(attrDef, attrVal, {}), acc) - )(R.prop(attrDef, node)); - } - }, [], attrsDefs); -} diff --git a/ui/imports/api/links/server/methods.js b/ui/imports/api/links/server/methods.js new file mode 100644 index 0000000..8d3454b --- /dev/null +++ b/ui/imports/api/links/server/methods.js @@ -0,0 +1,31 @@ +///////////////////////////////////////////////////////////////////////////////////////// +// 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 / +///////////////////////////////////////////////////////////////////////////////////////// + +import { Links } from '../links'; +import { NodeHoverAttr, calcAttrsForItem } from '/imports/api/attributes_for_hover_on_data/attributes_for_hover_on_data'; +import * as R from 'ramda'; + +Meteor.methods({ + 'linksFind?DataAndAttrs': function (id) { + console.log(`method server: linksFind?DataAndAttrs. ${R.toString(id)}`); + //check(nodeId, ObjectId); + this.unblock(); + + let query = { _id: id }; + let link = Links.findOne(query); + let attrsDefs = NodeHoverAttr.findOne({ 'type': 'link' }); + let attributes = calcAttrsForItem(link, attrsDefs); + + return { + link: link, + linkName: link.link_name, + attributes: attributes + }; + }, +}); diff --git a/ui/imports/api/messages/server/methods.js b/ui/imports/api/messages/server/methods.js index 119e6b0..540c0a1 100644 --- a/ui/imports/api/messages/server/methods.js +++ b/ui/imports/api/messages/server/methods.js @@ -11,7 +11,7 @@ import { Messages } from '/imports/api/messages/messages'; Meteor.methods({ 'messages/get?level&env&page&amountPerPage&sortField&sortDirection': function ( - level, env, page, amountPerPage, sortField, sortDirection) { + level, env, page, amountPerPage, sortField, sortDirection) { logMethodCall('messages/get?level&env&page&amountPerPage&sortField&sortDirection', {level, env, page, amountPerPage}); @@ -27,7 +27,7 @@ Meteor.methods({ query = R.ifElse(R.isNil, R.always(query),R.assoc('level', R.__, query))(level); sortParams = R.ifElse(R.isNil, R.always(sortParams), - R.assoc(R.__, sortDirection, sortParams))(sortField); + R.assoc(R.__, sortDirection, sortParams))(sortField); console.log('sort params:', sortParams); diff --git a/ui/imports/api/messages/server/publications.js b/ui/imports/api/messages/server/publications.js index 13c7c50..6b147f0 100644 --- a/ui/imports/api/messages/server/publications.js +++ b/ui/imports/api/messages/server/publications.js @@ -88,11 +88,28 @@ Meteor.publish('messages/count?level', function (level) { return new Counter(counterName, Messages.find({ level: level })); }); +Meteor.publish('messages/count?backDelta&level', function (backDelta, level) { + const counterName = `messages/count?backDelta=${backDelta}&level=${level}`; + console.log(`subscribe - counter: ${counterName}`); + + let begining = moment().subtract(backDelta); + let query = { + level: level, + timestamp: { $gte: begining.toDate() } + }; + + console.log(`query: ${R.toString(query)}`); + + return new Counter(counterName, Messages.find(query)); +}); + Meteor.publish('messages/count?level&env', function (level, env) { const counterName = `messages/count?level=${level}&env=${env}`; console.log(`subscribe - counter: ${counterName}`); let query = { level: level }; query = R.ifElse(R.isNil, R.always(query), R.assoc('environment', R.__, query))(env); + console.log(`query: ${R.toString(query)}`); - return new Counter(counterName, Messages.find(query)); }); + return new Counter(counterName, Messages.find(query)); +}); |