I'm trying to add new menu to the upper menu in WSO2 emm (like device management, reports, etc.).
Currently, I managed to add an item to the menu, but i can't make it to run the code i want (actually, at the first stage, i want to open the same page as the Apps Management item).
Is there any documentation or any good example or advice?
Thanks.
You can change the values in
wso2emm-1.1.0/repository/deployment/server/jaggeryapps/emm/controller/app.js file
Menus are defined as follows
if(currentUser){
if(role == 'admin'){
topNavigation = [
{name : "Dashboard" , link: appInfo().server_url + "console/dashboard", displayPage: "dashboard", icon: "icon-th-large"},
{name : "Configurations", link: appInfo().server_url + "users/configuration", displayPage: "configuration", icon:"icon-wrench"},
{name : "Device Management" , link: appInfo().server_url + "devices/management", displayPage: "management", icon:"icon-mobile-phone"},
{name : "App Management" , link: appInfo().server_url + "apps/management", displayPage: "appmanagement", icon:"icon-qrcode"},
{name : "Reports" , link: appInfo().server_url + "reports/", displayPage: "reports", icon:"icon-bar-chart"}
];
var configNavigation = [
{name : "Users", link: appInfo().server_url + "users/configuration", displayPage: "users", icon:"icon-user"},
{name : "Roles", link: appInfo().server_url + "roles/configuration", displayPage: "roles", icon:"icon-group"},
{name : "Policies", link: appInfo().server_url + "policies/configuration", displayPage: "policies", icon:"icon-lock"},
{name : "Settings", link: appInfo().server_url + "tenant/configuration", displayPage: "tenant", icon:"icon-gear"},
];
}else if(role == 'emmadmin'){
topNavigation = [
{name : "Dashboard" , link: appInfo().server_url + "console/dashboard", displayPage: "dashboard", icon: "icon-th-large"},
{name : "Configurations", link: appInfo().server_url + "users/configuration", displayPage: "configuration", icon:"icon-wrench"},
{name : "Device Management" , link: appInfo().server_url + "devices/management", displayPage: "management", icon:"icon-mobile-phone"},
{name : "App Management" , link: appInfo().server_url + "apps/management", displayPage: "appmanagement", icon:"icon-qrcode"},
{name : "Reports" , link: appInfo().server_url + "reports/", displayPage: "reports", icon:"icon-bar-chart"}
];
var configNavigation = [
{name : "Users", link: appInfo().server_url + "users/configuration", displayPage: "users", icon:"icon-user"},
{name : "Roles", link: appInfo().server_url + "roles/configuration", displayPage: "roles", icon:"icon-group"},
{name : "Policies", link: appInfo().server_url + "policies/configuration", displayPage: "policies", icon:"icon-lock"},
];
}else{
topNavigation = [
{name : "My Devices" , link: appInfo().server_url + "users/devices", displayPage: "management", icon:"icon-briefcase"}
];
}
}
You can add another entry there
Related
I'm trying to filter a query with term and range along with query-string. filter(range) and query string works but not filter(term). am i doing something wrong?
es = Elasticsearch([{'host': '192.168.121.121', 'port': 9200}])
index = Index("filebeat-*",using=es)
search = index.search()
searchStr = "OutOfMemoryError"
search = search.query("query_string", query=searchStr)
search = search.filter('range' , **{'#timestamp': {'gte': 1589399137000 , 'lt': 1589399377000, 'format' : 'epoch_millis'}})
search = search.filter('term' , **{'can.deployment': 'can-*' })
response = search.execute(ignore_cache=True)
print(response.hits.total)
print(response.hits.hits._source.can.deployment)
json:
filter-term - ['hits']['hits']['_source']['can']['deployment']
filter-range- ['hits']['hits']['_source']['#timestamp']
{
"hits" : {
"total" : 138351328,
"max_score" : 6.5700893,
"hits" : [
{
"_index" : "filebeat-6.1.2-2020.05.13",
"_type" : "doc",
"_score" : 2.0166037,
"_source" : {
"#timestamp" : "2020-05-13T01:14:03.354Z",
"source" : "/var/log/gw_rest/gw_rest.log",
"message" : "[2020-05-13 01:14:03.354] WARN can_gw_rest [EventLoopGroup-3-2]: An exceptionCaught() event was fired.OutOfMemoryError,
"fileset" : {...},
"can" : {
"level" : "WARN",
>>>>>>>> "message" : "An exceptionCaught() event was fired- OutOfMemoryError,
"timestamp" : "2020-05-13 01:14:03.354",
>>>>>>>> "deployment" : "can-6b721b93965b-w3we4-4074-9903"
}
}
}
]
}
}
I actually didn't need a filter(term). this worked:
dIds=response['hits']['hits'][1]['_source']['can']['deployment']
print(dIds)
#loop through the response
for i in response['hits']['hits']:
id = i['_source']['can']['deployment']
print(id)
I have data in a table like below
{
"_id" : ObjectId("5a9d1b70b826170df4365489"),
"userId" : "5a93e0b76d32cd0e6c1b99aa",
"mediaId" : "5a99330af218d30c981cda2f",
"comment" : "Hi this is a video",
"**replies**" : [
{
"comment" : "this is a reply 1",
"**userId**" : "5a93e0b76d32cd0e6c1b99aa"
},
{
"comment" : "this is a reply 2",
"**userId**" : "5a93e0b76d32cd0e6c1b99aa"
},
{
"comment" : "this is a reply 3",
"**userId**" : "5a93e0b76d32cd0e6c1b99aa"
}
],
"createdAt" : "",
"updatedAt" : ""
}
My question:
How to set a relation and include data from User table for userId in every object of replies array in loopback?
My expected Output:
{
"_id" : ObjectId("5a9d1b70b826170df4365489"),
"userId" : "5a93e0b76d32cd0e6c1b99aa",
"mediaId" : "5a99330af218d30c981cda2f",
"comment" : "Hi this is a video",
"**replies**" : [
{
"comment" : "this is a reply 1",
"**userId**" : "5a93e0b76d32cd0e6c1b99aa",
"userDetails":{
"name":"xxxxxxxxx",
"address":"xxxxxxxx"
}
},
{
"comment" : "this is a reply 2",
"**userId**" : "5a93e0b76d32cd0e6c1b99aa",
"userDetails":{
"name":"xxxxxxxxx",
"address":"xxxxxxxx"
}
},
{
"comment" : "this is a reply 3",
"**userId**" : "5a93e0b76d32cd0e6c1b99aa",
"userDetails":{
"name":"xxxxxxxxx",
"address":"xxxxxxxx"
}
}
],
"createdAt" : "",
"updatedAt" : ""
}
I am getting stuck up here.Kindly share some solutions
Do the following
create 3 models: yourModel, user, reply
set these relations in model definition json or using node api:
yourModel embedsMany Replies, Reply belongsTo user, user
hasMany Replies
query data using a stringified json as include filter
https://loopback.io/doc/en/lb3/Querying-data.html#using-stringified-json-in-rest-queries
{include: {relatedModel1: [{relatedModel2: 'relationName'} , 'relatedModel']}}
something like this maybe
/api/your_model/?filter={"include":{"replies":{"userDetails":true}}}
///sample Data
{
"_id" : "CUST1234",
"Phone Number" : "9585290750",
"First Name" : "jeff",
"Last Name" : "ayan",
"Email ID" : "",
"createddate" : 1462559400000.0,
"services" : [
{
"type" : "Enquiry",
"timeSpent" : "0:00",
"trxID" : "TRXE20160881",
"CustomerQuery" : "Enquiry about travell agent numbers in basaveshwara nagara",
"ServiceProvided" : "provided info through whatsapp",
"Category" : "Tours/Travels",
"callTime" : "2016-05-06T18:30:00.000Z",
"ActualAmount" : 0,
"FinalAmount" : 0,
"DiscountRuppes" : 0,
"DiscountPerctange" : 0
},
{
"type" : "Enquiry",
"timeSpent" : "0:00",
"trxID" : "TRXE20160882",
"CustomerQuery" : "Enquiry about Electric bill payment of house",
"ServiceProvided" : "Service provided",
"Category" : "Utility Services",
"callTime" : "2016-05-10T18:30:00.000Z",
"ActualAmount" : 0,
"FinalAmount" : 0,
"DiscountRuppes" : 0,
"DiscountPerctange" : 0
},
{
"type" : "Enquiry",
"timeSpent" : "0:00",
"trxID" : "TRXE20160883",
"CustomerQuery" : "Enquiry about KPSC office number",
"ServiceProvided" : "provided info through whatsapp",
"Category" : "Govt Offices/Enquiries",
"callTime" : "2016-05-13T18:30:00.000Z",
"ActualAmount" : 0,
"FinalAmount" : 0,
"DiscountRuppes" : 0,
"DiscountPerctange" : 0
},
{
"type" : "Enquiry",
"timeSpent" : "0:00",
"trxID" : "TRXE20160884",
"CustomerQuery" : "Enquiry about Sagara appolo hospital contact number",
"ServiceProvided" : "provided the information through call",
"Category" : "Hospitals/Equipments",
"callTime" : "2016-05-14T18:30:00.000Z",
"ActualAmount" : 0,
"FinalAmount" : 0,
"DiscountRuppes" : 0,
"DiscountPerctange" : 0
},
]
}
Expected Output : entire data that matches particular string in search box from "services" field.
db.collection.aggregate([
{
$match: {
"Phone Number": "9585290750",
"services": { $regex: "/^t/", $options: "s i" }
}
},
{
$project: {
"Services": "services"
}
}
]);
I am facing an issue in regex portion in the above Collection, services is an array field. Please help me to filter the data.
Guys since i am new to Mongodb it took me a day to find a proper solution to my task. I have a solution to my issue. If you guys have better query than this, just post it or modify it....
db.collections.aggregate([
{"$match":{"Corporate_ID":"id"}},
{"$unwind":"$services"},
{"$match":{"$or":[
{"services.type":{$regex:'TRXF2016088142',"$options": "i"}},
{"services.timeSpent":{$regex:'TRXF2016088142',"$options": "i"}},
{"services.trxID":{$regex:'TRXF2016088142',"$options": "i"}},
{"services.CustomerQuery":{$regex:'F',"$options": "i"}},
{"services.ServiceProvided":{$regex:'F',"$options": "i"}},
{"services.Category":{$regex:'F',"$options": "i"}},
{"services.callTime":{$regex:'TRXF2016088142',"$options": "i"}},
{"services.ActualAmount":{$regex:'TRXF2016088142',"$options": "i"}},
{"services.FinalAmount":{$regex:'TRXF2016088142',"$options": "i"}},
{"services.DiscountRuppes":{$regex:'TRXF2016088142',"$options": "i"}},
{"services.DiscountPerctange":{$regex:'TRXF2016088142',"$options": "i"}}
]}},
{"$unwind":"$services"},
{"$project":{
"service":"$services"}
}
])
This is because you are passing in a string of JavaScript regular expression object to $regex. Change your regex to one of the following.
"service": { "$regex": /^t/, "$options": "si" }
or
"service": { "$regex": "^t", "$options": "si" }
The post seems long but is is only because of data (samples and errors).
I am trying to make a bucket mocking the buildFailed sample in cep 2.1.0. (This sample works).
I have created my own stream and my own sample data.
Yet it seams that the input handler of cep his having trouble with my events.
So far I have not found the issue.
The stream def :
{
"name":"eu.ima.event.stream",
"version": "1.2.0",
"nickName": "poc sample",
"description": "poc sample stream",
"metaData":[
{
"name":"host",
"type":"string"
}
],
"correlationData":[
{
"name":"processus",
"type":"string"
},
{
"name":"flux",
"type":"string"
},
{
"name":"reference",
"type":"string"
}
],
"payloadData":[
{
"name":"timestamp",
"type":"string"
},
{ "name":"code",
"type":"string"
},
{
"name":"category",
"type":"string"
},
{
"name":"msg",
"type":"string"
}
]
}
The events data :
[
{
"metaData" : ["192.168.1.2"] ,
"correlationData" : ["PSOR", "Appli2", "Ref-1"] ,
"payloadData" : ["1363700128138496600", "6", "BIZ", "6"]
}
,
{
"metaData" : ["192.168.1.2"] ,
"correlationData" : ["PSOR", "Appli2", "Ref-0"] ,
"payloadData" : ["1363700126353394500", "6", "BIZ", "6"]
}
,
{
"metaData" : ["192.168.1.2"] ,
"correlationData" : ["PSOR", "Appli2", "Ref-3"] ,
"payloadData" : ["1363700131731702100", "6", "BIZ", "6"]
}
,
{
"metaData" : ["192.168.1.2"] ,
"correlationData" : ["PSOR", "Appli2", "Ref-2"] ,
"payloadData" : ["1363700129894597000", "6", "BIZ", "6"]
}
,
{
"metaData" : ["192.168.1.2"] ,
"correlationData" : ["PSOR", "Appli2", "Ref-4"] ,
"payloadData" : ["1363700133472801700", "6", "BIZ", "6"]
}
]
When I send the streamdef, no error and no log except the admin connected
We might need more feedback here. I use the curl post command.
When I send the events I have errors :
[2013-03-19 14:58:00,586] ERROR {org.wso2.carbon.databridge.core.internal.queue.QueueWorker} - Error in passing event eventList [
Event{
streamId='eu.ima.event.stream:1.2.0',
timeStamp=0,
metaData=[192.168.1.2],
correlationData=[PSOR, Appli2, Ref-1],
payloadData=[1363700128138496600, 6, BIZ, 6],
arbitraryDataMap=null,
}
,
Event{
streamId='eu.ima.event.stream:1.2.0',
timeStamp=0,
metaData=[192.168.1.2],
correlationData=[PSOR, Appli2, Ref-0],
payloadData=[1363700126353394500, 6, BIZ, 6],
arbitraryDataMap=null,
}
,
Event{
streamId='eu.ima.event.stream:1.2.0',
timeStamp=0,
metaData=[192.168.1.2],
correlationData=[PSOR, Appli2, Ref-3],
payloadData=[1363700131731702100, 6, BIZ, 6],
arbitraryDataMap=null,
}
,
Event{
streamId='eu.ima.event.stream:1.2.0',
timeStamp=0,
metaData=[192.168.1.2],
correlationData=[PSOR, Appli2, Ref-2],
payloadData=[1363700129894597000, 6, BIZ, 6],
arbitraryDataMap=null,
}
,
Event{
streamId='eu.ima.event.stream:1.2.0',
timeStamp=0,
metaData=[192.168.1.2],
correlationData=[PSOR, Appli2, Ref-4],
payloadData=[1363700133472801700, 6, BIZ, 6],
arbitraryDataMap=null,
}
] to subscriber org.wso2.carbon.broker.core.internal.brokers.agent.AgentBrokerType$AgentBrokerCallback#2d7fbbd6
java.lang.NullPointerException
at org.wso2.carbon.cep.core.mapping.input.mapping.TupleInputMapping.getValue(TupleInputMapping.java:126)
at org.wso2.carbon.cep.core.mapping.input.mapping.TupleInputMapping.convertToEventTuple(TupleInputMapping.java:97)
at org.wso2.carbon.cep.core.mapping.input.mapping.InputMapping.convert(InputMapping.java:42)
at org.wso2.carbon.cep.core.listener.TopicEventListener.onEvent(TopicEventListener.java:50)
at org.wso2.carbon.cep.core.listener.BrokerEventListener.onEvent(BrokerEventListener.java:58)
at org.wso2.carbon.broker.core.internal.brokers.agent.AgentBrokerType$AgentBrokerCallback.receive(AgentBrokerType.java:176)
at org.wso2.carbon.databridge.core.internal.queue.QueueWorker.run(QueueWorker.java:80)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Please anyone, do you have any hints ?
I really need this to keep on with my Proof of concept CEP Project.
Best regards,
Cyril
I have gone through the details that you given above... But without the bucket configuration and complete error log it is hard to say what went wrong... But I have checked the stream definition and events that you have given above... It is working perfectly without any issue... I hope that you might made simple mistake when creating the bucket... Here I am sharing the bucket xml that I have created (note: change the email address in the output topic)
events json : link [1]
stream json : link [2]
bucket xml : link [3]
curl command for Stream :
curl -k --user admin:admin https://localhost:9443/datareceiver/1.0.0/streams/ --data #streamdefn2.json -H "Accept: application/json" -H "Content-type: application/json" -X POST
curl command for events :
curl -k --user admin:admin https://localhost:9443/datareceiver/1.0.0/stream/eu.ima.event.stream/1.2.0/ --data #events2.json -H "Accept: application/json" -H "Content-type: application/json" -X POST
(Please follow the doc [4] thoroughly for more details]
[1] https://docs.google.com/file/d/0B056dKd2JQGJa0pFaU1BTDlEbFk/edit?usp=sharing
[2] https://docs.google.com/file/d/0B056dKd2JQGJUFdUN21GRGpzY0k/edit?usp=sharing
[3] https://docs.google.com/file/d/0B056dKd2JQGJa0pFaU1BTDlEbFk/edit?usp=sharing
[4] http://docs.wso2.org/wiki/display/CEP210/Build+Analyzer
Hope this will help you...
Regards,
Mohan
I got these documents:
id
name
friendList
id
name
I need to search in php (mongodb) for a friend, so name in friendList. How can I do this?
In the shell you'd do it like this:
> db.people.find({ "friendList.name" : /Joe/})
UPDATE: a proof:
> db.person.insert({name : 'scatman', friendList : [ {name: 'joe'}, {name: 'nick'} ]});
> db.person.findOne()
{
"_id" : ObjectId("4f155cafef7b8b0317a8ad17"),
"name" : "scatman",
"friendList" : [
{
"name" : "joe"
},
{
"name" : "nick"
}
]
}
> db.person.findOne({"friendList.name" : /jo/})
{
"_id" : ObjectId("4f155cafef7b8b0317a8ad17"),
"name" : "scatman",
"friendList" : [
{
"name" : "joe"
},
{
"name" : "nick"
}
]
}
>