Programmatic connection in jsplumb - jsplumb

How can I recreate/redraw a connection in jsplumb that has two different image endpoints?
For example:
instance.connect({source:"source", target:"target", anchors:["Bottom", "Top"],
endpoint:[ "Image" , {url:"nameofpicture.jpg"} ], connector: "Flowchart"});
this works for one image(the image is the same on the source and target element)
instance.connect({source:"source", target:"target", anchors:["Bottom", "Top"],
endpoints:["Dot","Rectangle"], connector: "Flowchart"});
this works and connects two elements with different endpoints (not of the same scope)
instance.connect({source:"source", target:"target", anchors:["Bottom", "Top"],
endpoints:["Image",{url:"nameofpicture1.jpg"},"Image", {url:"nameofpicture2.jpg"}], connector: "Flowchart"});
so the conclusion would be that something like this would work, but it doesn't..
Is there a way to access the source's and target's Image endpoint (parameter) url?
Maybe something like this:
connectionname.endpoints[0].endpoint.type('url')??

Try it like this:
endpoints: [ ['Image', {src:'nameofpicture1.png'}], ['Image', {src:'nameofpicture2.png'}] ]

Related

How can I pass REDIS_URI for NestJS cache manager?

In the official documentation this is the correct way to use the cache manager with Redis:
import * as redisStore from 'cache-manager-redis-store';
import { CacheModule, Module } from '#nestjs/common';
import { AppController } from './app.controller';
#Module({
imports: [
CacheModule.register({
store: redisStore,
host: 'localhost',
port: 6379,
}),
],
controllers: [AppController],
})
export class AppModule {}
Source: https://docs.nestjs.com/techniques/caching#different-stores
However, I did not find any documentation on how to pass Redis instance data using REDIS_URI. I need to use it with Heroku and I believe this is a common use case.
EDIT:
now they are type-safe: https://github.com/nestjs/nest/pull/8592
I've exploring a bit about how the redis client is instantiated. Due to this line I think that the options that you've passed to CacheModule.register will be forwarded to Redis#createClient (from redis package). Therefore, you can pass the URI like:
CacheModule.register({
store: redisStore,
url: 'redis://localhost:6379'
})
try this and let me know if it works.
edit:
Explaining how I got that:
Taking { store: redisStore, url: '...' } as options.
Here in CacheModule.register I found that your options will live under CACHE_MODULE_OPTIONS token (as a Nest provider)
Then I search for places in where this token will be used. Then I found here that those options were passed to cacheManager.caching. Where cacheManager is the module cache-manager
Looking into to the cacheManager.caching's code here, you'll see that your options is now their args parameter
Since options.store (redisStore) is the module exported by cache-manager-redis-store package, args.store.create method is the same function as in redisStore.create
Thus args.store.create(args) is the same as doing redisStore.create(options) which, in the end, will call Redis.createClient passing this options

Next.js rewrites - access original request parameters

I am building a navigation system for a Next.js app that would have routes like
http://localhost:3000/docs/section1/pageName
http://localhost:3000/docs/section2/pageName
etc
Under the hood these routes will point to a page /docs/:slug which is achievable with rewrites:
async rewrites() {
return [
{
source: '/docs/section1/:slug',
destination: '/docs/:slug'
},
{
source: '/docs/section2/:slug',
destination: '/docs/:slug'
}
];
}
But I'd like to pass the sectionN as a context variable to the destination path. So that the slug page could know which section was referred to originally. The purpose is to minimize the amount of underlying pages but to keep the pages navigation meaningful to user or search bot.
I understand that rewrites support/api can be limited. Checking the context in getInitialProps - original artificats are not available. Is there a way maybe to approach this differently in Next.js?
#felixmosh suggested in a comment to simply go with next.js dynamic routing that allows to use multiple slugs in the paths, no need to use rewrites.
That works!
Here goes the link to the official manual - https://nextjs.org/docs/routing/dynamic-routes.
Found solition:
async rewrites() {
return [
{
source: '/work/:slug/:path*',
destination: '/work/:slug',
},
]
},

How to configure rest client in quarkus microprofile case

When using Quarkus microprofile as a rest client, how can I configure underlying HttpClient?
Like number of retries, connection pool size per host and so on?
Also is it possible to force client restart somehow (so connections pool will be restarted)?
https://download.eclipse.org/microprofile/microprofile-rest-client-2.0-RC2/microprofile-rest-client-2.0-RC2.html#_configuration_keys outlines the full set of configuration keys that can be used.
The ones you're looking for are:
{packageName}.{interfaceName}/mp-rest/connectTimeout
{packageName}.{interfaceName}/mp-rest/readTimeout
The RestClientBuilder also has methods for setting those properties if you're using the programmatic API instead of the CDI approach.
I'm not aware of any means of restarting the underlying HTTP client connection pool. What would be the use case for such a situation that doesn't require the whole application to be restarted?
So... After a lot of digging, here is a solution I've found so far. It is not obvious apparently:
To make it work in pure Java (no native)
Under resources/META-INF/services directory add file named org.eclipse.microprofile.rest.client.spi.RestClientBuilderListener containing class name of your implementation of RestClientBuilderListener interface. For example my.test.MyBuilderListener. This will allow ServiceLocator to execute your listener
Refer a property you want to modify from ResteasyClientBuilder, for example to set your custom value to connectionTTL code will looks like this:
public void onNewBuilder(RestClientBuilder builder) {
log.info("Changing TTL for connections");
builder.property("resteasy.connectionTTL", List.of(2L, TimeUnit.SECONDS));
}
Ie. add a resteasy. prefix to a property name
Profit
Now native support:
After steps above:
Set both MyBuildListener and ResteasyClientBuilder available for reflection by creating a file reflection-config.json:
[
{
"name": "org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder",
"allDeclaredConstructors": true,
"allPublicConstructors": true,
"allDeclaredMethods": true,
"allPublicMethods": true,
"allDeclaredFields": true,
"allPublicFields": true
}, {
"name": "my.test.MyBuilderListener",
"allDeclaredConstructors": true,
"allPublicConstructors": true,
"allDeclaredMethods": true,
"allPublicMethods": true,
"allDeclaredFields": true,
"allPublicFields": true
}
]
Add service registration file to resources. Create a file named resources-config.json with content
{
"resources": [
{
"pattern": "META-INF/services/org\\.eclipse\\.microprofile\\.rest\\.client\\.spi\\.RestClientBuilderListener$"
}
]
}
register both files in application.yaml:
quarkus:
native:
additional-build-args: -H:ResourceConfigurationFiles=resources-config.json, -H:ReflectionConfigurationFiles=reflection-config.json
Native profit
Have fun

PCEP-SR draft version 6, SR Explicit Route Object/Record Route Object subobjects

I am setting up Segment routing via Pathman-SR with ODL Nitrogen Controller and vMX Juniper routers. To allow this, I have to change IANA subojbects code points, but I am unable to do it...
Followed this documenntations, but still no result:
https://docs.opendaylight.org/en/stable-carbon/user-guide/pcep-user-guide.html#segment-routing
https://test-odl-docs.readthedocs.io/en/latest/user-guide/pcep-user-guide.html
I tried to update configuration via REST API, but when I send PUT request:
/restconf/config/pcep-segment-routing-app-config:pcep-segment-routing-app-config
with the body:
<pcep-segment-routing-config xmlns="urn:opendaylight:params:xml:ns:yang:controller:pcep:segment-routing-app-config">
<iana-sr-subobjects-type>true</iana-sr-subobjects-type>
</pcep-segment-routing-config>
I get the following error:
{
"errors": {
"error": [
{
"error-type": "protocol",
"error-tag": "invalid-value",
"error-message": "URI has bad format. Possible reasons:\n 1. \"pcep-segment-routing-app-config:pcep-segment-routing-app-config\" was not found in parent data node.\n 2. \"pcep-segment-routing-app-config:pcep-segment-routing-app-config\" is behind mount point. Then it should be in format \"/yang-ext:mount/pcep-segment-routing-app-config:pcep-segment-routing-app-config\"."
}
]
}
}
I think there is a typo in the URL in the doc, you have to use /restconf/config/pcep-segment-routing-app-config:pcep-segment-routing-config
You can check this guide for reference:
https://docs.opendaylight.org/projects/bgpcep/en/stable-neon/pcep/pcep-user-guide-active-stateful-pce.html#iana-code-points

Create highstock using AJAX/JSON

I build a highstock using AngularJs,
This is the code currently look like http://jsfiddle.net/j06ivy/r88yszk0/
My question is how can I returns JSON data (http link) instead of put these data below in javascript code?
$scope.chartConfig.series.push({
id: 1,
data: [
[1147651200000, 23.15],
[1147737600000, 23.01],
[1147824000000, 22.73],
[1147910400000, 22.83],
[1147996800000, 22.56],
[1148256000000, 22.88],
[1148342400000, 22.79],
[1148428800000, 23.50],
[1148515200000, 23.74],
[1148601600000, 23.72],
[1148947200000, 23.15],
[1149033600000, 22.65]
]
},   {
id: 2,
data: [
[1147651200000, 25.15],
[1147737600000, 25.01],
[1147824000000, 25.73],
[1147910400000, 25.83],
[1147996800000, 25.56],
[1148256000000, 25.88],
[1148342400000, 25.79],
[1148428800000, 25.50],
[1148515200000, 26.74],
[1148601600000, 26.72],
[1148947200000, 26.15],
[1149033600000, 26.65]
]
}
);
I try to build on my webserver
http://52.74.94.173/ivy-demo-project/highstock-json.html
I think if something wrong in here?
$scope.chartConfig.series.push({
data: jsonData
});
you can use the $http service, here are the docs: $http
place your data in a json file, then you can access you file locally like so
$http.get("../relativePathTolocalJSON/mydata.json");
your file needs to be in a legal JSON format
Your fiddle doesn't work because of several js errors - at least $http is not injected, missing parenthesis and your json file is not available from a domain other than yours.
Check this one and make sure that your json file is available and contains an array with two data series for the chart.
$http.get('http://j06ivy.tw/public/chart-data.json').success(function (jsonData) {
$scope.chartConfig.series.push({
data: jsonData
});
});

Resources