I need recommendation for structure to use Cytoscape js - javascript

We are using Cytoscape + neo4j + spring boot + REST. We've tried to use some formats pass to frontend, however didn't work that well. So looking for best structure to use Cytoscape js.
========
Added later.
For example response from neo4j apoc export json query would be like this:
{
"application": {
"type": "node",
"id": "hhj354",
"labels": [
"Application"
],
"properties": {
"appid": "A90378",
"name": "hkjgj",
"status": "In Production"
}
},
"changes": [
{
"node": {
"type": "node",
"id": "fdsf324",
"labels": [
"Change"
],
"properties": {
"type": "gjhk",
"startdate": "2019-11-21 02:11:32"
}
},
"group": "2019-11",
"relation": sfd
},
{
"node": {
"type": "node",
"id": "fdsf324",
"labels": [
"Change"
],
"properties": {
"type": "gjhk",
"startdate": "2019-11-21 02:11:32"
}
},
"group": "2019-11",
"relation": sfd
},
{
"node": {
"type": "node",
"id": "fdsf324",
"labels": [
"Change"
],
"properties": {
"type": "gjhk",
"startdate": "2019-11-21 02:11:32"
}
},
"group": "2019-11",
"relation": 453
}
]
}
I need some detailed parsing codes. Parsing in backend or front end both ok as long as short enough.
Thanks in advance.

As far as I'm concerned, the front-end should do the less calculations as possible.
Therefore, try to send a JSON as close as possible to the format specified in the specs of cytoscape.js
The basic idea of graph is that it's composed of nodes and edges, those elements (as cytoscape calls them) have ids that can help you select them in a easier way.
No Calculation in Back-End
If you want to use built-in format .json from CALL apoc.export.json.all("all.json",{useTypes:true})then you will have for example to do some transformation in the front-end:
responseJson => {
responseJson.map(element => {
return {
group: element.type,
data : {
id: `${element.type}${element.id}`,
myFavouriteProperty: element.property
}
}
}

Related

How to integrate cypress slack notifications using reportportal results?

I tried to integrate cypress and slack. I'm able to get simple notifications such as pipeline status, alert, push or merge request. My requirement is to get notification like this.
Also I'm not able to integrate reportportal, I need to get more detailed for slack notification.
I tried to follow these instructions
My cypress.json file look like this.
"reporterOptions": {
"configFile": "reporterOpts.json",
"reporterEnabled": "spec, mocha-junit-reporter, #reportportal/agent-js-cypress, mochawesome",
"reportportalAgentJsCypressReporterOptions": {
"endpoint": "https://reportportal.mlsdevcloud.com/api/v1/",
"token": "445151-w6djb-ae48-awd86wd",
"launch": "no launch",
"project": "demo",
"description": "UAT",
"autoMerge": true
},
"mochaJunitReporterReporterOptions": {
"mochaFile": "cypress/results/results-[hash].xml"
}
},
"reports": [
{
"targets": [
{
"name": "slack",
"inputs": {
"url": "https://hooks.slack.com/services/T/secreatToken/"
}
}
],
"results": [
{
"type": "junit",
"files": ["cypress/results/results-[hash].xml"]
}
]
}
]
And this is suggested json file.
{
"reports": [
{
"targets": [
{
"name": "teams",
"inputs": {
"url": "<teams-incoming-webhook-url>"
},
"extensions": [
{
"name": "report-portal-analysis",
"inputs": {
"url": "<report-portal-base-url>",
"api_key": "<api-key>",
"project": "<project-id>",
"launch_id": "<launch-id>"
}
}
]
}
],
"results": [
{
"type": "testng",
"files": ["path/to/testng-results.xml"]
}
]
}
]
}
how to pass
"launch_id": ""
it is generated every time when build is triggered.

How do I diagnose an error in Azure SignalR 404 with upstream and Azure Function App?

I have an Azure SignalR service setup with upstream. Negotiate is working, but I am getting a 404 error when trying to use connection.invoke('events', { ... });
In the SignalR event log, I am getting (irrelevant bits omitted):
{
"properties": {
"message": "Sending message during operation {hub}=map,{event}=events,{category}=messages got unexpected response with status code 404. Detail: ",
"type":"MessagingLogs",
"collection":"Serverless"
},
"operationName": "HttpHandlerUnexpectedResponse",
"callerIpAddress": "null"
}
What might be causing the 404?
There is a Azure Function app setup with an events function with the following bindings:
{
"disabled": false,
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "res"
},
{
"type": "signalR",
"name": "$return",
"hubName": "map",
"direction": "out"
}
]
}
I believe the function app is getting setup correctly. I have the following setup as my upstream (with info replaced in the actual call:
<function_app_server>/runtime/webhooks/signalr?code=<signalr_extension_key>
Apparently the bindings have changed for Azure when using Upstream. The following bindings worked:
{
"bindings": [
{
"type": "signalRTrigger",
"name": "invocation",
"hubName": "map",
"category": "messages",
"event": "events",
"parameterNames": [
"message"
],
"direction": "in",
},
{
"type": "signalR",
"name": "signalRMessages",
"hubName": "map",
"connectionStringSetting": "AzureSignalRConnectionString",
"direction": "out"
}
]
}
module.exports = function (context, invocation) {
context.bindings.signalRMessages = [{
"target": "newMessage", // name of the client method to invoke
"arguments": [
context.bindingData.message // arguments to pass to client method
]
}];
context.done();
};

Zapier API Code assistance - extract data from JSON

I am trying to use a JSON response in a Zapier response. The data looks like this:
I'm trying to use the Induction and Site Suitability href value in a Zap, however, when I try to use this in Zapier, Zapier gives me this:
I was going to use a find of some sorts to find Induction and Site Suitability and then return the href after that, but because of the formatting, I can't do that. Does anyone know how I can do this with Formatter or Code (Python/Javascript) or something else in Zapier?
Thank you
Luke
Here is the API result in code:
{
"competencies": [
{
"competency": {
"name": "Forklift Operator Permit",
"href": "https://link/22059"
},
"status": {
"value": "Active",
"type": "active"
},
"expiryWarning": "2021-04-15T13:59:00Z",
"expiry": "2021-04-30T13:59:00Z",
"disabled": false,
"href": "https://link/1b1594d738"
},
{
"competency": {
"name": "Induction and Site Suitability",
"href": "https://link/24033"
},
"status": {
"value": "Active",
"type": "active"
},
"expiryWarning": "2021-04-15T13:59:00Z",
"expiry": "2021-04-30T13:59:00Z",
"disabled": false,
"href": "https://link/8e26b5ea4bbc800e"
}
]
}

Blockly restrict input_value to another block

In my Blockly project, I have two 3 blocks rcm_a, rcm_b and rcm_c.
Blockly.defineBlocksWithJsonArray([{
"type": "rcm_c",
"message0": "Requirement block- rcm_a: %1 rcm_b: %2",
"args0": [
{
"type": "input_value",
"name": "rcm_a"
},
{
"type": "input_value",
"name": "rcm_b",
"check": ["rcm_b"]
}
],
"output": "Text",
"colour": "%{BKY_LOOPS_HUE}"
}]);
As you can see the above code of rcm_c, I am trying to restrict the second input to be of block rcm_b, and that apparently doesn't seem to be working. The same input will not accept any input type. Here's rcm_b's code:
Blockly.defineBlocksWithJsonArray([{
"type": "rcm_b",
"message0": "rcm_b %1",
"args0": [
{
"type": "input_value",
"name": "VALUE1",
"check": "String"
}
],
"output": "Text",
"colour": "%{BKY_LOOPS_HUE}"
}]);
I tried following this guide's Statement Stacks section (I am aware that I am trying to type check inputs and not statements) to achieve type-checking. What am I doing wrong?
Help is much appreciated!
Ah, seems like the 'output' of rcm_b needed to be rcm_b!

TypeError: Object [object Array] has no method 'getProperty'

I'm kind of new to this whole posting a question thing, so please be gentle!
I am using Breeze as part of the "Hot Towel" SPA stack and retrieving data from a custom WebApi endpoint written in PHP. It's not a full implementation, I've just written enough to give me what I need.
The metadata my endpoint is generating is as follows:
{
"shortName": "Project",
"namespace": "WebApi.ORM.Cartesius",
"autoGeneratedKeyType": "Identity",
"defaultResourceName": "Project",
"dataProperties": [
{
"name": "id",
"isPartOfKey": true,
"isNullable": false,
"dataType": "Int32"
},
{
"name": "title",
"isNullable": false,
"maxLength": 256,
"dataType": "String"
},
{
"name": "date",
"isNullable": false,
"dataType": "DateTime"
},
{
"name": "review_date",
"isNullable": true,
"dataType": "DateTime"
},
{
"name": "summary",
"isNullable": true,
"dataType": "String"
}
],
"navigationProperties": [
{
"name": "Team",
"entityTypeName": "Team:#WebApi.ORM.Cartesius",
"isScalar": true,
"associationName": "team_project_id_fkey",
"invForeignKeyNames": [
"project_id"
]
},
{
"name": "ProjectAuthor",
"entityTypeName": "ProjectAuthor:#WebApi.ORM.Cartesius",
"isScalar": true,
"associationName": "project_author_project_id_fkey",
"invForeignKeyNames": [
"project_id"
]
},
{
"name": "Itinerary",
"entityTypeName": "Itinerary:#WebApi.ORM.Cartesius",
"isScalar": true,
"associationName": "itinerary_project_id_fkey",
"invForeignKeyNames": [
"project_id"
]
},
Everything is working fine until I try and do an expand on my query:
var query = new breeze.EntityQuery()
.from("Project")
.where("id","eq",project.id)
.expand("ProjectAuthor");
This query returns the following from my endpoint:
[
{
"$id": 1,
"$type": "WebApi.ORM.Cartesius.Project",
"id": 2,
"title": "teat",
"date": "2013-11-04 14:00:00+07",
"review_date": null,
"summary": null,
"ProjectAuthor": [
{
"$id": 2,
"$type": "WebApi.ORM.Cartesius.ProjectAuthor",
"id": 1,
"account_id": 1,
"project_id": 2,
"Project": [
{
"$ref": 1
}
]
},
{
"$id": 3,
"$type": "WebApi.ORM.Cartesius.ProjectAuthor",
"id": 3,
"account_id": 2,
"project_id": 2,
"Project": [
{
"$ref": 1
}
]
}
]
}
]
Then Breeze chokes on it throwing:
TypeError: Object [object Array] has no method 'getProperty'
Debugging points to line 5059 in Breeze where it tries to getProperty on an array of entities rather than a single entity I assumed this had something to do with whether the navigation property was set to scalar or not but switching them around made no difference.
I'm sure I'm doing something massively wrong, but I can't figure out what it is and I've kind of hit a brick wall. I've read the docs from top to bottom and am implementing this as best as I can understand but it's possible I'm a little confused.
Thanks in advance for any help and apologies if I have not made myself clear or provided enough info
I think your problem is in the metadata
"name": "ProjectAuthor",
"entityTypeName": "ProjectAuthor:#WebApi.ORM.Cartesius",
"isScalar": true,
"associationName": "project_author_project_id_fkey",
"invForeignKeyNames": [
"project_id"
]
},
On that nav property Project->ProjectAuthor your telling it that its a scalar but its not in the data set..
"ProjectAuthor": [
{
..........
I've had this problem aswell .. 99% time its a metadata problem, if not there then start cutting metadata apart until you isolate the error .. though I'm sure thats the problem.. you need a hasMany there and an isScalar on the inverse navigation

Categories

Resources