Node opcua crawler method and ua expert results are different - opc-ua

Opcua node crawler method giving me an array of 745 items. But I can only see around 25 items when I look at ua expert.
My current code:
const client = opcua.OPCUAClient.create(connectionOption);
await client.connect(url);
const session = await client.createSession(userIdentity);
const items = [];
var crawler = new NodeCrawler(session);
crawler.on("browsed", function (element) {
if (element.nodeClass === 2) {// 2 means variable type
const nodeId = new opcua.NodeId(element.nodeId.identifierType, element.nodeId.value, element.nodeId.namespace);
const nodeIdString = nodeId.toString();
items.push(nodeIdString);
}
});
await crawler.read(nodeId);
How can I get the same result as UaExpert?
My code result:
UaExpert:
Nodes which are not shown in UaExpert but exits in crawler result:
Node details which is not shown in UaExpert
{
description: null,
nodeId: 'ns=0;i=11574',
browseName: { namespaceIndex: 0, name: 'MaxMonitoredItemsPerCall' },
references: [
{
referenceTypeId: 'ns=0;i=37',
isForward: true,
nodeId: 'ns=0;i=80',
browseName: { namespaceIndex: 0, name: 'Optional' },
displayName: { text: 'Optional' },
nodeClass: 'Object',
typeDefinition: 'ns=0;i=77',
},
{
referenceTypeId: 'ns=0;i=40',
isForward: true,
nodeId: 'ns=0;i=68',
browseName: { namespaceIndex: 0, name: 'PropertyType' },
displayName: { text: 'PropertyType' },
nodeClass: 'VariableType',
typeDefinition: 'ns=0;i=0',
},
],
nodeClass: 2,
typeDefinition: 'ns=0;i=68',
displayName: { text: 'MaxMonitoredItemsPerCall' },
parent: {
description: null,
nodeId: 'ns=0;i=11564',
browseName: { namespaceIndex: 0, name: 'OperationLimitsType' },
references: [
{
referenceTypeId: 'ns=0;i=46',
isForward: true,
nodeId: 'ns=0;i=11574',
browseName: { namespaceIndex: 0, name: 'MaxMonitoredItemsPerCall' },
displayName: { text: 'MaxMonitoredItemsPerCall' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=68',
},
{
referenceTypeId: 'ns=0;i=46',
isForward: true,
nodeId: 'ns=0;i=11570',
browseName: { namespaceIndex: 0, name: 'MaxNodesPerBrowse' },
displayName: { text: 'MaxNodesPerBrowse' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=68',
},
{
referenceTypeId: 'ns=0;i=46',
isForward: true,
nodeId: 'ns=0;i=12161',
browseName: { namespaceIndex: 0, name: 'MaxNodesPerHistoryReadData' },
displayName: { text: 'MaxNodesPerHistoryReadData' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=68',
},
{
referenceTypeId: 'ns=0;i=46',
isForward: true,
nodeId: 'ns=0;i=12162',
browseName: { namespaceIndex: 0, name: 'MaxNodesPerHistoryReadEvents' },
displayName: { text: 'MaxNodesPerHistoryReadEvents' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=68',
},
{
referenceTypeId: 'ns=0;i=46',
isForward: true,
nodeId: 'ns=0;i=12163',
browseName: { namespaceIndex: 0, name: 'MaxNodesPerHistoryUpdateData' },
displayName: { text: 'MaxNodesPerHistoryUpdateData' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=68',
},
{
referenceTypeId: 'ns=0;i=46',
isForward: true,
nodeId: 'ns=0;i=12164',
browseName: { namespaceIndex: 0, name: 'MaxNodesPerHistoryUpdateEvents' },
displayName: { text: 'MaxNodesPerHistoryUpdateEvents' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=68',
},
{
referenceTypeId: 'ns=0;i=46',
isForward: true,
nodeId: 'ns=0;i=11569',
browseName: { namespaceIndex: 0, name: 'MaxNodesPerMethodCall' },
displayName: { text: 'MaxNodesPerMethodCall' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=68',
},
{
referenceTypeId: 'ns=0;i=46',
isForward: true,
nodeId: 'ns=0;i=11573',
browseName: { namespaceIndex: 0, name: 'MaxNodesPerNodeManagement' },
displayName: { text: 'MaxNodesPerNodeManagement' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=68',
},
{
referenceTypeId: 'ns=0;i=46',
isForward: true,
nodeId: 'ns=0;i=11565',
browseName: { namespaceIndex: 0, name: 'MaxNodesPerRead' },
displayName: { text: 'MaxNodesPerRead' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=68',
},
{
referenceTypeId: 'ns=0;i=46',
isForward: true,
nodeId: 'ns=0;i=11571',
browseName: { namespaceIndex: 0, name: 'MaxNodesPerRegisterNodes' },
displayName: { text: 'MaxNodesPerRegisterNodes' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=68',
},
{
referenceTypeId: 'ns=0;i=46',
isForward: true,
nodeId: 'ns=0;i=11572',
browseName: { namespaceIndex: 0, name: 'MaxNodesPerTranslateBrowsePathsToNodeIds' },
displayName: { text: 'MaxNodesPerTranslateBrowsePathsToNodeIds' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=68',
},
{
referenceTypeId: 'ns=0;i=46',
isForward: true,
nodeId: 'ns=0;i=11567',
browseName: { namespaceIndex: 0, name: 'MaxNodesPerWrite' },
displayName: { text: 'MaxNodesPerWrite' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=68',
},
],
nodeClass: 8,
typeDefinition: 'ns=0;i=0',
displayName: { text: 'OperationLimitsType' },
parent: {
description: null,
nodeId: 'ns=0;i=61',
browseName: { namespaceIndex: 0, name: 'FolderType' },
references: [
{
referenceTypeId: 'ns=0;i=45',
isForward: true,
nodeId: 'ns=0;i=16405',
browseName: { namespaceIndex: 0, name: 'AlarmGroupType' },
displayName: { text: 'AlarmGroupType' },
nodeClass: 'ObjectType',
typeDefinition: 'ns=0;i=0',
},
{
referenceTypeId: 'ns=0;i=45',
isForward: true,
nodeId: 'ns=0;i=23456',
browseName: { namespaceIndex: 0, name: 'AliasNameCategoryType' },
displayName: { text: 'AliasNameCategoryType' },
nodeClass: 'ObjectType',
typeDefinition: 'ns=0;i=0',
},
{
referenceTypeId: 'ns=0;i=45',
isForward: true,
nodeId: 'ns=0;i=23556',
browseName: { namespaceIndex: 0, name: 'AuthorizationServicesConfigurationFolderType' },
displayName: { text: 'AuthorizationServicesConfigurationFolderType' },
nodeClass: 'ObjectType',
typeDefinition: 'ns=0;i=0',
},
{
referenceTypeId: 'ns=0;i=45',
isForward: true,
nodeId: 'ns=0;i=13813',
browseName: { namespaceIndex: 0, name: 'CertificateGroupFolderType' },
displayName: { text: 'CertificateGroupFolderType' },
nodeClass: 'ObjectType',
typeDefinition: 'ns=0;i=0',
},
{
referenceTypeId: 'ns=0;i=45',
isForward: true,
nodeId: 'ns=0;i=17591',
browseName: { namespaceIndex: 0, name: 'DictionaryFolderType' },
displayName: { text: 'DictionaryFolderType' },
nodeClass: 'ObjectType',
typeDefinition: 'ns=0;i=0',
},
{
referenceTypeId: 'ns=0;i=45',
isForward: true,
nodeId: 'ns=0;i=13353',
browseName: { namespaceIndex: 0, name: 'FileDirectoryType' },
displayName: { text: 'FileDirectoryType' },
nodeClass: 'ObjectType',
typeDefinition: 'ns=0;i=0',
},
{
referenceTypeId: 'ns=0;i=45',
isForward: true,
nodeId: 'ns=0;i=17496',
browseName: { namespaceIndex: 0, name: 'KeyCredentialConfigurationFolderType' },
displayName: { text: 'KeyCredentialConfigurationFolderType' },
nodeClass: 'ObjectType',
typeDefinition: 'ns=0;i=0',
},
{
referenceTypeId: 'ns=0;i=45',
isForward: true,
nodeId: 'ns=0;i=11564',
browseName: { namespaceIndex: 0, name: 'OperationLimitsType' },
displayName: { text: 'OperationLimitsType' },
nodeClass: 'ObjectType',
typeDefinition: 'ns=0;i=0',
},
{
referenceTypeId: 'ns=0;i=45',
isForward: true,
nodeId: 'ns=2;i=1005',
browseName: { namespaceIndex: 2, name: 'FunctionalGroupType' },
displayName: { text: 'FunctionalGroupType' },
nodeClass: 'ObjectType',
typeDefinition: 'ns=0;i=0',
},
],
typeDefinition: 'ns=0;i=0',
displayName: { text: 'FolderType' },
parent: {
description: null,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar',
browseName: { namespaceIndex: 4, name: 'Scalar' },
references: [
{
referenceTypeId: 'ns=0;i=40',
isForward: true,
nodeId: 'ns=0;i=61',
browseName: { namespaceIndex: 0, name: 'FolderType' },
displayName: { text: 'FolderType' },
nodeClass: 'ObjectType',
typeDefinition: 'ns=0;i=0',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.Boolean',
browseName: { namespaceIndex: 4, name: 'Boolean' },
displayName: { text: 'Boolean' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.Byte',
browseName: { namespaceIndex: 4, name: 'Byte' },
displayName: { text: 'Byte' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.ByteString',
browseName: { namespaceIndex: 4, name: 'ByteString' },
displayName: { text: 'ByteString' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.DateTime',
browseName: { namespaceIndex: 4, name: 'DateTime' },
displayName: { text: 'DateTime' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.Double',
browseName: { namespaceIndex: 4, name: 'Double' },
displayName: { text: 'Double' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.ExpandedNodeId',
browseName: { namespaceIndex: 4, name: 'ExpandedNodeId' },
displayName: { text: 'ExpandedNodeId' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.Float',
browseName: { namespaceIndex: 4, name: 'Float' },
displayName: { text: 'Float' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.Guid',
browseName: { namespaceIndex: 4, name: 'Guid' },
displayName: { text: 'Guid' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.ImageGIF',
browseName: { namespaceIndex: 4, name: 'ImageGIF' },
displayName: { text: 'ImageGIF' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.Int16',
browseName: { namespaceIndex: 4, name: 'Int16' },
displayName: { text: 'Int16' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.Int32',
browseName: { namespaceIndex: 4, name: 'Int32' },
displayName: { text: 'Int32' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.Int64',
browseName: { namespaceIndex: 4, name: 'Int64' },
displayName: { text: 'Int64' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.LocalizedText',
browseName: { namespaceIndex: 4, name: 'LocalizedText' },
displayName: { text: 'LocalizedText' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.NodeId',
browseName: { namespaceIndex: 4, name: 'NodeId' },
displayName: { text: 'NodeId' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.QualifiedName',
browseName: { namespaceIndex: 4, name: 'QualifiedName' },
displayName: { text: 'QualifiedName' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.Quality_DynamicValue',
browseName: { namespaceIndex: 4, name: 'Quality_DynamicValue' },
displayName: { text: 'Quality_DynamicValue' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.Quality_StaticValue',
browseName: { namespaceIndex: 4, name: 'Quality_StaticValue' },
displayName: { text: 'Quality_StaticValue' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.SByte',
browseName: { namespaceIndex: 4, name: 'SByte' },
displayName: { text: 'SByte' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.StatusCode',
browseName: { namespaceIndex: 4, name: 'StatusCode' },
displayName: { text: 'StatusCode' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.String',
browseName: { namespaceIndex: 4, name: 'String' },
displayName: { text: 'String' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.UInt16',
browseName: { namespaceIndex: 4, name: 'UInt16' },
displayName: { text: 'UInt16' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.UInt32',
browseName: { namespaceIndex: 4, name: 'UInt32' },
displayName: { text: 'UInt32' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.UInt64',
browseName: { namespaceIndex: 4, name: 'UInt64' },
displayName: { text: 'UInt64' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.XmlElement',
browseName: { namespaceIndex: 4, name: 'XmlElement' },
displayName: { text: 'XmlElement' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
],
nodeClass: 1,
typeDefinition: 'ns=0;i=61',
displayName: { text: 'Scalar' },
},
referenceToParent: {
referenceTypeId: 'ns=0;i=40',
isForward: true,
nodeId: 'ns=0;i=61',
browseName: { namespaceIndex: 0, name: 'FolderType' },
displayName: { text: 'FolderType' },
nodeClass: 'ObjectType',
typeDefinition: 'ns=0;i=0',
},
},
referenceToParent: {
referenceTypeId: 'ns=0;i=45',
isForward: true,
nodeId: 'ns=0;i=11564',
browseName: { namespaceIndex: 0, name: 'OperationLimitsType' },
displayName: { text: 'OperationLimitsType' },
nodeClass: 'ObjectType',
typeDefinition: 'ns=0;i=0',
},
},
referenceToParent: {
referenceTypeId: 'ns=0;i=46',
isForward: true,
nodeId: 'ns=0;i=11574',
browseName: { namespaceIndex: 0, name: 'MaxMonitoredItemsPerCall' },
displayName: { text: 'MaxMonitoredItemsPerCall' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=68',
},
dataType: 'ns=0;i=7',
dataValue: {
value: { dataType: 'Null', arrayType: 'Scalar' },
statusCode: { value: 0 },
sourceTimestamp: '2022-12-29T15:48:59.598Z',
sourcePicoseconds: 801300000,
serverTimestamp: '2022-12-29T15:48:59.598Z',
serverPicoseconds: 801300000,
},
valueRank: -1,
minimumSamplingInterval: 50,
accessLevel: 1,
userAccessLevel: 1,
};

If you want to filter the results, you can do it by accessLevel attribute. In my case all of the nodes I want to see in crawler result have accessLevel:3.
Simply changing this line
from (element.nodeClass === 2)
to (element.nodeClass === 2 && element.accessLevel === 3)
worked for me.

Some of the nodes in youe json are (sub-)part of the server Object.
So I think you browse the complett nodeset and not only the Scalar folder.

Related

Flutter Http response body from String to List of Object

Hi I am currently trying to fetch some data from an API, for later casting it to my Object Class.
The json answer i receive is instead of a list, directly a String.
{
"00-01": {
"date": "24-08-2022",
"hour": "00-01",
"is-cheap": false,
"is-under-avg": false,
"market": "PVPC",
"price": 617.5,
"units": "€/Mwh"
},
"01-02": {
"date": "24-08-2022",
"hour": "01-02",
"is-cheap": false,
"is-under-avg": false,
"market": "PVPC",
"price": 640.05,
"units": "€/Mwh"
},
"02-03": {
"date": "24-08-2022",
"hour": "02-03",
"is-cheap": false,
"is-under-avg": false,
"market": "PVPC",
"price": 670.26,
"units": "€/Mwh"
},
"03-04": {
"date": "24-08-2022",
"hour": "03-04",
"is-cheap": false,
"is-under-avg": false,
"market": "PVPC",
"price": 683.64,
"units": "€/Mwh"
},
"04-05": {
"date": "24-08-2022",
"hour": "04-05",
"is-cheap": false,
"is-under-avg": false,
"market": "PVPC",
"price": 692.88,
"units": "€/Mwh"
},
"05-06": {
"date": "24-08-2022",
"hour": "05-06",
"is-cheap": false,
"is-under-avg": false,
"market": "PVPC",
"price": 681.87,
"units": "€/Mwh"
},
"06-07": {
"date": "24-08-2022",
"hour": "06-07",
"is-cheap": false,
"is-under-avg": false,
"market": "PVPC",
"price": 624.35,
"units": "€/Mwh"
},
"07-08": {
"date": "24-08-2022",
"hour": "07-08",
"is-cheap": false,
"is-under-avg": false,
"market": "PVPC",
"price": 624.82,
"units": "€/Mwh"
},
"08-09": {
"date": "24-08-2022",
"hour": "08-09",
"is-cheap": false,
"is-under-avg": false,
"market": "PVPC",
"price": 623.24,
"units": "€/Mwh"
},
"09-10": {
"date": "24-08-2022",
"hour": "09-10",
"is-cheap": false,
"is-under-avg": true,
"market": "PVPC",
"price": 558.55,
"units": "€/Mwh"
},
"10-11": {
"date": "24-08-2022",
"hour": "10-11",
"is-cheap": false,
"is-under-avg": true,
"market": "PVPC",
"price": 511.3,
"units": "€/Mwh"
},
"11-12": {
"date": "24-08-2022",
"hour": "11-12",
"is-cheap": false,
"is-under-avg": true,
"market": "PVPC",
"price": 493.36,
"units": "€/Mwh"
},
"12-13": {
"date": "24-08-2022",
"hour": "12-13",
"is-cheap": true,
"is-under-avg": true,
"market": "PVPC",
"price": 484.42,
"units": "€/Mwh"
},
"13-14": {
"date": "24-08-2022",
"hour": "13-14",
"is-cheap": true,
"is-under-avg": true,
"market": "PVPC",
"price": 487.58,
"units": "€/Mwh"
},
"14-15": {
"date": "24-08-2022",
"hour": "14-15",
"is-cheap": true,
"is-under-avg": true,
"market": "PVPC",
"price": 426.72,
"units": "€/Mwh"
},
"15-16": {
"date": "24-08-2022",
"hour": "15-16",
"is-cheap": true,
"is-under-avg": true,
"market": "PVPC",
"price": 418.28,
"units": "€/Mwh"
},
"16-17": {
"date": "24-08-2022",
"hour": "16-17",
"is-cheap": true,
"is-under-avg": true,
"market": "PVPC",
"price": 422.18,
"units": "€/Mwh"
},
"17-18": {
"date": "24-08-2022",
"hour": "17-18",
"is-cheap": true,
"is-under-avg": true,
"market": "PVPC",
"price": 430.63,
"units": "€/Mwh"
},
"18-19": {
"date": "24-08-2022",
"hour": "18-19",
"is-cheap": false,
"is-under-avg": true,
"market": "PVPC",
"price": 495.26,
"units": "€/Mwh"
},
"19-20": {
"date": "24-08-2022",
"hour": "19-20",
"is-cheap": false,
"is-under-avg": false,
"market": "PVPC",
"price": 579.65,
"units": "€/Mwh"
},
"20-21": {
"date": "24-08-2022",
"hour": "20-21",
"is-cheap": false,
"is-under-avg": false,
"market": "PVPC",
"price": 614.08,
"units": "€/Mwh"
},
"21-22": {
"date": "24-08-2022",
"hour": "21-22",
"is-cheap": false,
"is-under-avg": false,
"market": "PVPC",
"price": 625.97,
"units": "€/Mwh"
},
"22-23": {
"date": "24-08-2022",
"hour": "22-23",
"is-cheap": false,
"is-under-avg": false,
"market": "PVPC",
"price": 582.99,
"units": "€/Mwh"
},
"23-24": {
"date": "24-08-2022",
"hour": "23-24",
"is-cheap": false,
"is-under-avg": false,
"market": "PVPC",
"price": 617.25,
"units": "€/Mwh"
}
}
I would like to cast that result into a LightHours, where every one would be a class Hour inside.
My main ideas was to get a List<LightHours> = {Hours,...}
Also I have tried to do the following: LightPrice lightPrice = LightPrice.fromJson(jsonDecode(response.body)); but it only gets me every field as null.
But using the json to Dart converter it doesn't allow me.
How could i convert that response into both objects classes?
Something like this maybe works:
List<LightPrice> list = (jsonDecode(response.body) as Map<String,
Map<String, dynamic>>).values.map<LightPrice>((value) =>
LightPrice.fromJson(value)).toList();
//your json string
String jsonString = json.encode(data);
//convert json string to list
List<String> newData = List<String>.from(json.decode(jsonString));
this will help to convert

Customized label and Emphasis label overlap

I try to make the pie chart show 'customized label',change label when the mouse triggered. But except blue data everything else will overlap with 'emphasis label'.
'avoidLabelOverlap' not working.
Is there way?
enter image description here
enter image description here
this is a example
var option = {
tooltip: {
trigger: 'item'
},
legend: {
top: '5%',
left: 'center'
},
series: [
{
name: 'Access From',
type: 'pie',
radius: ['40%', '70%'],
avoidLabelOverlap: false,
itemStyle: {
borderRadius: 10,
borderColor: '#fff',
borderWidth: 2
},
label: {
show: true,
position: 'center',
formatter: function (params) {
var html = 'TEST';
return html;
}
},
emphasis: {
label: {
show: true,
fontSize: '40',
fontWeight: 'bold'
}
},
labelLine: {
show: false
},
data: [
{ value: 1048, name: 'Search Engine' },
{ value: 735, name: 'Direct' },
{ value: 580, name: 'Email' },
{ value: 484, name: 'Union Ads' },
{ value: 300, name: 'Video Ads' }
]
}
]
};
Finally,I find a method.
Use mouse event to change label in center.
<!DOCTYPE html>
<html lang="Zh-TW">
<head>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/5.2.2/echarts.min.js"></script>
<meta charset="utf-8">
</head>
<body>
<div id="main" style="width:600px;height:600px;">
</div>
<script>
var myChart = echarts.init(document.getElementById('main'));
var option = {
title: {
text: 'Total',
textStyle: {
fontSize: 35,
},
x: 'center',
y: 'center'
},
tooltip: {
trigger: 'item'
},
legend: {
top: '5%',
left: 'center'
},
series: [
{
name: 'Testname',
type: 'pie',
radius: ['40%', '60%'],
center: ['50%', '50%'],
avoidLabelOverlap: true,
textAlign: 'center',
label: {
normal: {
show: true,
formatter: function (params) {
return params.name+'\n'+params.percent+'%'
},
textStyle: {
fontSize: 20
},
},
},
itemStyle: {
borderRadius: 10,
borderColor: '#fff',
borderWidth: 2
},
data: [
{ value: 1048, name: 'Search Engine' },
{ value: 735, name: 'Direct' },
{ value: 580, name: 'Email' },
{ value: 484, name: 'Union Ads' },
{ value: 300, name: 'Video Ads' }
]
},
{
name: 'Testname',
type: 'pie',
radius: ['40%', '60%'],
center: ['50%', '50%'],
avoidLabelOverlap: true,
textAlign:'center',
label: {
normal: {
show: true,
position: 'center',
formatter: '{b}\n{c}',
align: 'center',
verticalAlign: 'middle',
textStyle: {
fontSize: 0
},
},
emphasis:{
show: true,
textStyle: {
fontSize: 35,
fontWeight: 'bold'
},
formatter: '{b}\n{c}'
},
},
itemStyle: {
borderRadius: 10,
borderColor: '#fff',
borderWidth: 2
},
data: [
{ value: 1048, name: 'Search Engine' },
{ value: 735, name: 'Direct' },
{ value: 580, name: 'Email' },
{ value: 484, name: 'Union Ads' },
{ value: 300, name: 'Video Ads' }
]
},
]
};
myChart.setOption(option);
myChart.on('mouseover', { seriesName: 'Testname' }, () => {
myChart.setOption({
title: {
show: false
}
})
})
myChart.on('mouseout', { seriesName: 'Testname' }, () => {
myChart.setOption({
title: {
show: true
}
})
})
</script>
</body>
</html>
Thanks for the accepted answer,
My case was series label was showing like you mentioned in question, and my need was to solve the same problem while hovering the mouse through legend.
Here is my addition.
// series name: Access From
labelOptionAlter = {
series: [
{ label: {
show: false,
position: 'center'
},
}
]
};
labelOptionDefault={
series: [
{ label: {
show: true,
position: 'center'
},
}
]
};
//similar to mouseover.
myChart.on('highlight', { seriesName: 'Access From' }, () => {
myChart.setOption(labelOptionAlter)
})
//similar to mouseout
myChart.on('downplay', { seriesName: 'Access From' }, () => {
myChart.setOption(labelOptionDefault)
})
Future scholars can read more here
I think there's no way to solve this problem.

ion-picker can't get role of button clicked

I can’t seem to get the button role from ion-picker.
I need to know if it was ‘done’ or ‘cancel’.
Any ideas why this is?
I am just padding this out as stackoverflow is asking me to write some more details as my post is mostly code.
They data is just coming back as follows:
{data: undefined, role: undefined}
let opts: PickerOptions = {
cssClass: 'time-picker',
buttons: [
{
text: 'Cancel',
role: 'cancel'
},
{
text: 'Done',
role: 'done'
}
],
columns: [
{
name: 'hour',
options: [
{ text: '01', value: '01' },
{ text: '02', value: '02' },
{ text: '03', value: '03' },
{ text: '04', value: '04' },
{ text: '05', value: '05' },
{ text: '06', value: '06' },
{ text: '07', value: '07' },
{ text: '08', value: '08' },
{ text: '09', value: '09' },
{ text: '10', value: '10' },
{ text: '11', value: '11' },
{ text: '12', value: '12' },
{ text: '13', value: '13' },
{ text: '14', value: '14' },
{ text: '15', value: '15' },
{ text: '16', value: '16' },
{ text: '17', value: '17' },
{ text: '18', value: '18' },
{ text: '19', value: '19' },
{ text: '20', value: '20' },
{ text: '21', value: '21' },
{ text: '22', value: '22' },
{ text: '23', value: '23' },
{ text: '24', value: '24' }
]
},
{
name: 'minute',
options: [
{ text: '00', value: '00' },
{ text: '15', value: '15' },
{ text: '30', value: '30' },
{ text: '45', value: '45' }
]
}
]
};
const picker = await this.pickerCtrl.create(opts);
picker.present();
picker.onDidDismiss().then(async data => {
console.log(data);
const hour = await picker.getColumn('hour');
const minute = await picker.getColumn('minute');
this.onChangeFinishTime((hour.options[hour.selectedIndex].value) as number, minute.options[minute.selectedIndex].value as number);
this.isPickerOpen = false;
});
let pickerAction;
const opts: PickerOptions = {
cssClass: 'time-picker',
buttons: [
{
text: 'Cancel',
role: 'cancel',
handler: value => {
pickerAction = 'cancel';
}
},
{
text: 'Done',
role: 'done',
handler: value => {
pickerAction = 'done';
}
}
],
columns: [
...
const picker = await this.pickerCtrl.create(opts);
picker.present();
picker.onDidDismiss().then(async data => {
if (pickerAction === 'done') {
const hour = await picker.getColumn('hour');
const minute = await picker.getColumn('minute');
this.onChangeFinishTime((hour.options[hour.selectedIndex].value) as number, minute.options[minute.selectedIndex].value as number);
}
this.isPickerOpen = false;
});
You need to move the logic from when the event onDidDismiss() is triggered (which means that the popover has disappeared, regardless of what action made it disappear) to the actual action of clicking the Done button.
This what the handler on Done does here, telling to set the value of the selected entry in the referenced column upon the popover dismissing as a consequence of clicking the Done button.
{data: undefined, role: undefined}
let opts: PickerOptions = {
cssClass: 'time-picker',
buttons: [
{
text: 'Cancel',
role: 'cancel'
},
{
text: 'Done',
handler: () => {
picker.dismiss().then(async data => {
console.log(data);
const hour = await picker.getColumn('hour');
const minute = await picker.getColumn('minute');
this.onChangeFinishTime((hour.options[hour.selectedIndex].value) as number, minute.options[minute.selectedIndex].value as number);
this.isPickerOpen = false;
});
}
}
],
columns: [
{
name: 'hour',
options: [
{ text: '01', value: '01' },
{ text: '02', value: '02' },
{ text: '03', value: '03' },
{ text: '04', value: '04' },
{ text: '05', value: '05' },
{ text: '06', value: '06' },
{ text: '07', value: '07' },
{ text: '08', value: '08' },
{ text: '09', value: '09' },
{ text: '10', value: '10' },
{ text: '11', value: '11' },
{ text: '12', value: '12' },
{ text: '13', value: '13' },
{ text: '14', value: '14' },
{ text: '15', value: '15' },
{ text: '16', value: '16' },
{ text: '17', value: '17' },
{ text: '18', value: '18' },
{ text: '19', value: '19' },
{ text: '20', value: '20' },
{ text: '21', value: '21' },
{ text: '22', value: '22' },
{ text: '23', value: '23' },
{ text: '24', value: '24' }
]
},
{
name: 'minute',
options: [
{ text: '00', value: '00' },
{ text: '15', value: '15' },
{ text: '30', value: '30' },
{ text: '45', value: '45' }
]
}
]
};
const picker = await this.pickerCtrl.create(opts);
picker.present();

Source Providers - List Branches - What is the providerName?

Source Providers - List Branches:
https://learn.microsoft.com/en-us/rest/api/azure/devops/build/source%20providers/list%20branches?view=azure-devops-rest-5.0
"GET https://dev.azure.com/{organization}/{project}/_apis/sourceProviders/{providerName}/branches?api-version=5.0-preview.1"
Can anyone tell me what the "providerName" string is for?
It's for the name of the source provider. If you're using TFVC or Azure Devops-native Git, you don't need to use this API -- there are TFVC and Git specific APIs.
If you're using an external Git provider such as GitHub or BitBucket, this is the right place to be. You need to tell the API which external provider you're trying to query.
This is why there is a page listed directly above the "List Branches" entry for a "List" API -- it lists the available source providers for your account.
GET https://dev.azure.com/{organization}/{project}/_apis/sourceproviders?api-version=5.0-preview.1
Calling that API should return something like:
{
"count": 7,
"value": [
{
"name": "GitHubEnterprise",
"supportedTriggers": [
{
"type": "continuousIntegration",
"notificationType": "webhook",
"defaultPollingInterval": 0,
"supportedCapabilities": {
"branchFilters": "required",
"pathFilters": "supported",
"batchChanges": "supported",
"buildForks": "unsupported"
}
},
{
"type": "pullRequest",
"notificationType": "webhook",
"defaultPollingInterval": 0,
"supportedCapabilities": {
"branchFilters": "required",
"pathFilters": "supported",
"batchChanges": "unsupported",
"buildForks": "supported"
}
},
{
"type": "schedule",
"notificationType": "none",
"defaultPollingInterval": 0,
"supportedCapabilities": {
"branchFilters": "required",
"pathFilters": "unsupported",
"batchChanges": "unsupported",
"buildForks": "unsupported"
}
}
],
"supportedCapabilities": {
"createLabel": true,
"discoverExistingYamlDefinitions": false,
"queryBranches": true,
"queryFileContents": true,
"queryPathContents": true,
"queryPullRequest": false,
"queryRelatedWorkItems": false,
"queryRepositories": true,
"queryTopRepositories": false,
"queryWebhooks": true,
"sourceLinks": true,
"yamlDefinition": true
}
},
{
"name": "Svn",
"supportedTriggers": [
{
"type": "continuousIntegration",
"notificationType": "polling",
"defaultPollingInterval": 180,
"supportedCapabilities": {
"branchFilters": "unsupported",
"pathFilters": "required",
"batchChanges": "supported",
"buildForks": "unsupported"
}
},
{
"type": "schedule",
"notificationType": "none",
"defaultPollingInterval": 0,
"supportedCapabilities": {
"branchFilters": "unsupported",
"pathFilters": "unsupported",
"batchChanges": "unsupported",
"buildForks": "unsupported"
}
}
],
"supportedCapabilities": {
"createLabel": false,
"discoverExistingYamlDefinitions": false,
"queryBranches": false,
"queryFileContents": false,
"queryPathContents": false,
"queryPullRequest": false,
"queryRelatedWorkItems": false,
"queryRepositories": false,
"queryTopRepositories": false,
"queryWebhooks": false,
"sourceLinks": false,
"yamlDefinition": false
}
},
{
"name": "GitHub",
"supportedTriggers": [
{
"type": "continuousIntegration",
"notificationType": "webhook",
"defaultPollingInterval": 0,
"supportedCapabilities": {
"branchFilters": "required",
"pathFilters": "supported",
"batchChanges": "supported",
"buildForks": "unsupported"
}
},
{
"type": "pullRequest",
"notificationType": "webhook",
"defaultPollingInterval": 0,
"supportedCapabilities": {
"branchFilters": "required",
"pathFilters": "supported",
"batchChanges": "unsupported",
"buildForks": "supported"
}
},
{
"type": "schedule",
"notificationType": "none",
"defaultPollingInterval": 0,
"supportedCapabilities": {
"branchFilters": "required",
"pathFilters": "unsupported",
"batchChanges": "unsupported",
"buildForks": "unsupported"
}
}
],
"supportedCapabilities": {
"createLabel": true,
"discoverExistingYamlDefinitions": false,
"queryBranches": true,
"queryFileContents": true,
"queryPathContents": true,
"queryPullRequest": true,
"queryRelatedWorkItems": true,
"queryRepositories": true,
"queryTopRepositories": true,
"queryWebhooks": true,
"sourceLinks": true,
"yamlDefinition": true
}
},
{
"name": "Bitbucket",
"supportedTriggers": [
{
"type": "continuousIntegration",
"notificationType": "webhook",
"defaultPollingInterval": 0,
"supportedCapabilities": {
"branchFilters": "required",
"pathFilters": "unsupported",
"batchChanges": "supported",
"buildForks": "unsupported"
}
},
{
"type": "pullRequest",
"notificationType": "webhook",
"defaultPollingInterval": 0,
"supportedCapabilities": {
"branchFilters": "required",
"pathFilters": "unsupported",
"batchChanges": "unsupported",
"buildForks": "unsupported"
}
},
{
"type": "schedule",
"notificationType": "none",
"defaultPollingInterval": 0,
"supportedCapabilities": {
"branchFilters": "required",
"pathFilters": "unsupported",
"batchChanges": "unsupported",
"buildForks": "unsupported"
}
}
],
"supportedCapabilities": {
"createLabel": false,
"discoverExistingYamlDefinitions": false,
"queryBranches": true,
"queryFileContents": false,
"queryPathContents": false,
"queryRelatedWorkItems": false,
"queryPullRequest": false,
"queryRepositories": true,
"queryTopRepositories": false,
"queryWebhooks": false,
"sourceLinks": true,
"yamlDefinition": false
}
},
{
"name": "Git",
"supportedTriggers": [
{
"type": "continuousIntegration",
"notificationType": "polling",
"defaultPollingInterval": 180,
"supportedCapabilities": {
"branchFilters": "required",
"pathFilters": "unsupported",
"batchChanges": "unsupported",
"buildForks": "unsupported"
}
},
{
"type": "schedule",
"notificationType": "none",
"defaultPollingInterval": 0,
"supportedCapabilities": {
"branchFilters": "required",
"pathFilters": "unsupported",
"batchChanges": "unsupported",
"buildForks": "unsupported"
}
}
],
"supportedCapabilities": {
"createLabel": false,
"discoverExistingYamlDefinitions": false,
"queryBranches": false,
"queryFileContents": false,
"queryPathContents": false,
"queryPullRequest": false,
"queryRelatedWorkItems": false,
"queryRepositories": false,
"queryTopRepositories": false,
"queryWebhooks": false,
"sourceLinks": false,
"yamlDefinition": false
}
},
{
"name": "TfsGit",
"supportedTriggers": [
{
"type": "continuousIntegration",
"notificationType": "none",
"defaultPollingInterval": 0,
"supportedCapabilities": {
"branchFilters": "required",
"pathFilters": "supported",
"batchChanges": "supported",
"buildForks": "unsupported"
}
},
{
"type": "schedule",
"notificationType": "none",
"defaultPollingInterval": 0,
"supportedCapabilities": {
"branchFilters": "required",
"pathFilters": "supported",
"batchChanges": "unsupported",
"buildForks": "unsupported"
}
}
],
"supportedCapabilities": {
"createLabel": true,
"discoverExistingYamlDefinitions": false,
"queryBranches": false,
"queryFileContents": true,
"queryPathContents": true,
"queryPullRequest": true,
"queryRelatedWorkItems": true,
"queryRepositories": false,
"queryTopRepositories": false,
"queryWebhooks": false,
"sourceLinks": true,
"yamlDefinition": true
}
},
{
"name": "TfsVersionControl",
"supportedTriggers": [
{
"type": "continuousIntegration",
"notificationType": "none",
"defaultPollingInterval": 0,
"supportedCapabilities": {
"branchFilters": "unsupported",
"pathFilters": "required",
"batchChanges": "supported",
"buildForks": "unsupported"
}
},
{
"type": "gatedCheckIn",
"notificationType": "none",
"defaultPollingInterval": 0,
"supportedCapabilities": {
"branchFilters": "unsupported",
"pathFilters": "required",
"batchChanges": "unsupported",
"buildForks": "unsupported"
}
},
{
"type": "schedule",
"notificationType": "none",
"defaultPollingInterval": 0,
"supportedCapabilities": {
"branchFilters": "unsupported",
"pathFilters": "unsupported",
"batchChanges": "unsupported",
"buildForks": "unsupported"
}
}
],
"supportedCapabilities": {
"createLabel": true,
"discoverExistingYamlDefinitions": false,
"queryBranches": false,
"queryFileContents": true,
"queryPathContents": true,
"queryPullRequest": false,
"queryRelatedWorkItems": true,
"queryRepositories": false,
"queryTopRepositories": false,
"queryWebhooks": false,
"sourceLinks": false,
"yamlDefinition": false
}
}
]
}

Cannot search on a toggle column in a grid

When I add a toggle column to a grid with a search it does not appear to function. I have modified the Grid with Search Demo to include a toggle. But when I try to search on it the drop down just gives me an "Is" option and I cannot enter anything for the search clause.
searches: [
{ field: 'recid', caption: 'ID ', type: 'int' },
{ field: 'lname', caption: 'Last Name', type: 'text' },
{ field: 'fname', caption: 'First Name', type: 'text' },
{ field: 'email', caption: 'Email', type: 'list', options: { items: ['peter#gmail.com', 'jim#gmail.com', 'jdoe#gmail.com']} },
{ field: 'auth', caption: 'Auth', type: 'toggle' }
],
columns: [
{ field: 'recid', caption: 'ID', size: '50px', sortable: true, attr: 'align=center' },
{ field: 'lname', caption: 'Last Name', size: '30%', sortable: true },
{ field: 'fname', caption: 'First Name', size: '31%', sortable: true },
{ field: 'email', caption: 'Email', size: '40%' },
{ field: 'auth', caption: 'Auth', render: 'toggle', size: '20px' }
]
jsFiddle: https://jsfiddle.net/c9r6pk7m/4/
While toggle is a valid render value, it's not a valid searches type.
See: http://w2ui.com/web/docs/1.5/w2grid.searches
You could use list instead, though I must admit, I had to "cheat" with the false value, by mapping it to {id:"0", text: "No"}.
$(function () {
$('#grid').w2grid({
name: 'grid',
show: {
toolbar: true,
footer: true
},
multiSearch: true,
searches: [
{ field: 'recid', caption: 'ID ', type: 'int' },
{ field: 'lname', caption: 'Last Name', type: 'text' },
{ field: 'fname', caption: 'First Name', type: 'text' },
{ field: 'email', caption: 'Email', type: 'list', options: { items: ['peter#gmail.com', 'jim#gmail.com', 'jdoe#gmail.com']} },
{ field: 'auth', caption: 'Auth', type: 'list', options: { items: [{id:true, text: "Yes"}, {id:"0", text: "No"}]} }
],
columns: [
{ field: 'recid', caption: 'ID', size: '50px', sortable: true, attr: 'align=center' },
{ field: 'lname', caption: 'Last Name', size: '30%', sortable: true },
{ field: 'fname', caption: 'First Name', size: '31%', sortable: true },
{ field: 'email', caption: 'Email', size: '40%' },
{ field: 'auth', caption: 'Auth', render: 'toggle', size: '20px' }
],
records: [
{ recid: 1, fname: 'Jane', lname: 'Doe', email: 'jdoe#gmail.com', auth: true },
{ recid: 2, fname: 'Stuart', lname: 'Motzart', email: 'jdoe#gmail.com', auth: true },
{ recid: 3, fname: 'Jin', lname: 'Franson', email: 'peter#gmail.com', auth: true },
{ recid: 4, fname: 'Susan', lname: 'Ottie', email: 'jim#gmail.com', auth: true },
{ recid: 5, fname: 'Kelly', lname: 'Silver', email: 'peter#gmail.com', auth: true },
{ recid: 6, fname: 'Francis', lname: 'Gatos', email: 'jdoe#gmail.com', auth: true },
{ recid: 7, fname: 'Mark', lname: 'Welldo', email: 'jim#gmail.com', auth: false },
{ recid: 8, fname: 'Thomas', lname: 'Bahh', email: 'jdoe#gmail.com', auth: false },
{ recid: 9, fname: 'Sergei', lname: 'Rachmaninov', email: 'jdoe#gmail.com', auth: false },
{ recid: 20, fname: 'Jill', lname: 'Doe', email: 'jdoe#gmail.com', auth: false },
{ recid: 21, fname: 'Frank', lname: 'Motzart', email: 'jdoe#gmail.com', auth: false },
{ recid: 22, fname: 'Peter', lname: 'Franson', email: 'jdoe#gmail.com', auth: false },
{ recid: 23, fname: 'Andrew', lname: 'Ottie', email: 'jdoe#gmail.com', auth: false },
{ recid: 24, fname: 'Manny', lname: 'Silver', email: 'jdoe#gmail.com', auth: false },
{ recid: 25, fname: 'Ben', lname: 'Gatos', email: 'peter#gmail.com', auth: true },
{ recid: 26, fname: 'Doer', lname: 'Welldo', email: 'jdoe#gmail.com', auth: true },
{ recid: 27, fname: 'Shashi', lname: 'Bahh', email: 'jim#gmail.com', auth: true },
{ recid: 28, fname: 'Av', lname: 'Rachmaninov', email: 'jim#gmail.com', auth: true }
]
});
});
https://jsfiddle.net/c9r6pk7m/9/