How do define custom displayNameGetter in PowerBI? - visualization

I'm developing a new visual in PowerBI and first defining visual capabilities.
Even, the samples show me that, for example, gauge.capabilities.ts file like this.
export var gaugeCapabilities: VisualCapabilities = {
dataRoles: [
{
name: gaugeRoleNames.y,
kind: VisualDataRoleKind.Measure,
displayName: data.createDisplayNameGetter('Role_DisplayName_Value'),
}, {
name: gaugeRoleNames.minValue,
kind: VisualDataRoleKind.Measure,
displayName: data.createDisplayNameGetter('Role_DisplayName_MinValue'),
}, {
name: gaugeRoleNames.maxValue,
kind: VisualDataRoleKind.Measure,
displayName: data.createDisplayNameGetter('Role_DisplayName_MaxValue'),
}, {
name: gaugeRoleNames.targetValue,
kind: VisualDataRoleKind.Measure,
displayName: data.createDisplayNameGetter('Role_DisplayName_TargetValue'),
}
],
I want to define custom display names like "From", "To". And when I trying to input it as "raw" in the dataRoles like:
dataRoles: [
{
name: gaugeRoleNames.y,
kind: VisualDataRoleKind.Measure,
displayName: 'From',
}, { ...
And it works.
But I think this is out of coding requirements. Is there any way to define custom display name getter like:
displayName: data.createDisplayNameGetter('Role_DisplayName_From')
I tried. But it doesn't work.
Does anyone have same issue and solve this problem?

Defining a function for displayName allows a visual to fetch a localized string.
The data.createDisplayNameGetter function returns a lambda that does a resource string lookup in our PowerBI.resx resources.
The custom visuals don’t currently have a way to do extend our PowerBI.resx. So you can either hard-code (as you’ve done), or you can define your own function that does your own resource lookup.

Related

how to add arrays as azure devops variable groups variable value?

I have used azure devops variable group variables to define my appsettings properties. However, I could not use an array as a value for one of my appsettings properties.
Here is a screenshot of what i am trying to do:
But it appears on the appsettings.json as follows which results in a 500 internal server error Value cannot be null. Parameter name: collection
"AzureAd": {
"Instance": "https://login.microsoftonline.com",
"ClientId": "",
"TenantId": "",
"Audience": "[ https://api.doesnotexist.com ]"
}
The code in Startup.cs that is failing is as follows:
services.AddAuthentication(o =>
{
o.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
o.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(o =>
{
o.Authority = $"{azureADSettings.Instance}/{azureADSettings.TenantId}/";
o.TokenValidationParameters = new TokenValidationParameters
{
ValidateAudience = true,
ValidAudiences = new List<string>(azureADSettings.Audience),
};
});
Please Refer to this doc:
All variables are stored as strings and are mutable. The value of a variable can change from run to run or job to job of your pipeline.
In Azure Devops, Variables are String type by default. And we couldn'change it.
So when you define an array in variable, it will pass the array as a string to your appsettings.json file.
To solve this issue, you need to change to use Parameters. The parameter supports the value of the input array type.
Here is an example:
parameters:
- name: 'param'
type: object
default: [123,234,456]
steps:
- ${{ each p in parameters.param }}:
- script: echo ${{ p }}
Note: Parameters can only be used in YAML pipeline.
You can also set collection using the variables as explained in the microsoft documentation
By adding the index of the element in the variable name
example

add a pipeline variable of array type In ADO pipeline

Is it possible to add a pipeline variable of array type in ADO pipeline? I’m trying to add a pipeline variable of array type with these values:
[
{ name: abc, id: 123 },
{ name: def, id: 456 }
]
Pipeline variable doesnot support complex type, all variables are stored as strings. You can try below workarounds depending on how you use the variable in your pipeline.
1, If you want to reference the variable in other task. You can define the variable as runtime parameters instead of pipeline variables. You can define the parameter like below:
parameters:
- name: Ids
type: object
default:
- name: abc
value: 123
- name: efg
value: 456
Then you can refer to the parameter using syntax like this :${{parameters.Ids[0].name}}
steps:
- powershell: |
echo "${{parameters.Ids[0].name}}"
echo "${{parameters.Ids[0].value}}"
2, If you use the variable in a script task. You can save the value to json string. And convert to json object in the script. See below example:
First, Save the value to json string('[{"name":"abc", "value":111},{"name":"efg", value:222}]') to the pipeline variable:
Then, Convert to json object in the script task. See below example in powershell task:
steps:
- powershell: |
$ids = $(ids) | convertfrom-json
echo $ids[0].name
No pipeline variables are strings. There is no way at the moment to have variable of complex type. Plese check this topic on developer community - Variables in YAML pipeline are not allowing to define array
Yaml variables have always been string: string mappings. Instead of using variable, you may consider Parameters.
parameters:
- name: abc
type: string
default: 123
- name: def
type: string
default: 456
……

How to pass arguments in bulk to another step in a Github Action?

I want to pass the value set by core.setOutput to different steps at once. So I passed the outputs of the step hello-action to another step:
//index.js
const core = require("#actions/core");
core.setOutput("res1","res1");
core.setOutput("res2","res2");
core.setOutput("res3","res3");
jobs:
build:
runs-on: ubuntu-latest
name: Hello
steps:
- name: Checkout
uses: actions/checkout#master
- name: run hello action
id: hello-action
run: node index.js
- name: run hello2 action
id: hello2-action
run: node index2.js
with:
outputs: ${{ steps.hello-action.outputs }}
point is this.
outputs: ${{ steps.hello-action.outputs }}
The type of the above value is an object, but I couldn't access the key inside the object.
//index2.js
const core = require("#actions/core");
const outputs = core.getInput("outputs");
console.log("hello2 outputs:", outputs); //result is [object Object]
console.log("hello2 outputs:", outputs.res1); //result is undefined
Is there a way to pass arguments in bulk?
Objects cannot be transferred to output from action, only strings.
Therefore, when passing an object from a custom action toString() method will be called on it. As a result, you get your [object Object] already at the moment of performing this action here:
- name: run hello action
id: hello-action
run: node index.js
To transfer data structures from a custom action, cast object to JSON string using JSON.stringify() method.
first action
//index1.js
const obj = {
field1: "value1",
field2: "value2",
}
core.setOutput("outputs", JSON.stringify(obj));
And in your second step, parse the JSON string
second action
//index2.js
const core = require("#actions/core");
const outputs = JSON.parse(core.getInput("outputs"));
This should help you.

How to get v-select items inside items?

I have a dropdown with v-select
<v-select
label="Select"
v-bind:items="companies"
v-model="e11"
item-text="employee.name"
item-value="name"
max-height="auto"
>
</v-select>
Data from API like
new Vue({
el: '#app',
data () {
return {
e11: [],
companies: [
{
companyName: 'Google',
employee: [{
name: 'Sandra Adams',
name: 'Ali Connors',
name: 'Trevor Hansen',
name: 'Tucker Smith',
}]
},
{
companyName: 'Facebook',
employee: [{
name: 'Sandra Adams',
name: 'Ali Connors',
name: 'Trevor Hansen',
name: 'Tucker Smith',
}]
},
{
companyName: 'Twitter',
employee: [{
name: 'Sandra Adams',
name: 'Ali Connors',
name: 'Trevor Hansen',
name: 'Tucker Smith',
}]
},
]
}
}
})
In dropdown item getting [object object] to fixed fixed it? I want to get dropdown list with grouped by company name.
Here is what I want to do
Here is the codepen link https://codepen.io/yurenlimbu/pen/bGVKGEa?editors=1011
I had a crack at it, as ive also had some issues in the past with vuetify dropdown, i managed to get it to work, you may need to update your current data objects to make the name key unique in the list.
Added computed property to map companies and employees and inject the employees company so we have one object with the data we need
mappedNames: function() {
return this.companies.map(function(person) {
person.employee.forEach(e => e.company = person.companyName)
return person.employee
})
}
Helper function to concat the arrays from the map
item-value prop update to access entire object, and linked to e11 v-model
Here is the codepen:
https://codepen.io/mcwalshh/pen/Vwvdvve
EDIT:
I've included the slot for item and selected item, so you can change how the data is displayed inside the select:
<template v-slot:selection="data">
{{ data.item.name }} - {{ data.item.company }}
</template>
ref: https://vuetifyjs.com/en/components/selects/
Here is the updated codepen:
https://codepen.io/mcwalshh/pen/rNOKqvd
EDIT #2:
Not really sure how to go about adding titles, i suggest reading more vuetify documentation, or perhaps in my example, use the helper in the text-name instead of the items to access companyName. But following from my previous posts, i think the potential way of doing it, is to inject/unshift an object into the employees with:
{ name: person.employee.companyName, type: "title" }
For now in my example i add it straight to the object, then use template v-if's to determine what is a title:
codepen: https://codepen.io/mcwalshh/pen/NWGzeoK
Now just a matter of targeting parent to match your gif, but im in no way saying this is the best approach, like i said before i had issues with vuetify in the past, so i hope this can help get you by until you work out the best method

Dynamically Creating Resource Name from Values

My end goal is to create a policy document from a cloudformation script. I want to have one script where the parameter is selected and that value is used to in the name of the resource.
"arn:aws:dynamodb:us-east-1:12345678:table/monit-${dev}/stream/*"
where ${dev} is a parameter value
Parameters:
Environment:
Default: dev
Description: Leveraged for environment tagging.
Type: String
AllowedValues:
- dev
- tst
- qa
- stg
- prd
I want to try something like the following but don't know how to add the Ref Environment from the parameter or is there some other method?
'Fn::Sub': 'arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}'
So I don't end up have to create a bunch of different scripts
PolicyDocument:
Statement:
- Effect: Allow
Action:
- dynamodb:DescribeStream
- dynamodb:GetRecords
- dynamodb:GetShardIterator
- dynamodb:ListStreams
- dynamodb:Scan
#This will need to changed for other tables
Resource:
- "arn:aws:dynamodb:us-east-1:12345678:table/monit-dev/stream/*"
- "arn:aws:dynamodb:us-east-1:12345678:table/monit-dev"
If i understood you correctly, You can use Fn::Join to add the "Environment" value. You dont use Ref of the value it self.
The intrinsic function Ref returns the value of the specified parameter or resource.
When you specify a parameter's logical name, it returns the value of the parameter.
When you specify a resource's logical name, it returns a value that you can typically use to refer to that resource, such as a physical ID.
json example:
"CustomInstanceProfileArn": {
"Fn::Join": [
"", ["arn:aws:iam::", {
"Ref": "AWS::AccountId"
},
":instance-profile/", {
"Ref": "InstanceProfile"
}
]
]
},
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html