powerbi-visuals-tools 4.0.4 → 4.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Changelog.md +8 -0
- package/certs/PowerBICustomVisualTest_private.key +28 -0
- package/certs/PowerBICustomVisualTest_public.crt +19 -0
- package/config.json +35 -1
- package/lib/VisualGenerator.js +0 -95
- package/package.json +3 -3
- package/spec/.jshintrc +5 -0
- package/spec/clean-tests.js +31 -0
- package/spec/e2e/pbivizCertSpec.js +56 -0
- package/spec/e2e/pbivizInfoSpec.js +82 -0
- package/spec/e2e/pbivizNewSpec.js +265 -0
- package/spec/e2e/pbivizPackageSpec.js +670 -0
- package/spec/e2e/pbivizStartSpec.js +380 -0
- package/spec/e2e/pbivizWebpackVerSpec.js +102 -0
- package/spec/e2e/utils.js +63 -0
- package/spec/helpers/FileSystem.js +173 -0
- package/spec/jasmine-runner.js +36 -0
- package/spec/support/jasmine.json +11 -0
- package/templates/visuals/default/capabilities.json +2 -7
- package/templates/visuals/default/package.json +2 -2
- package/templates/visuals/default/pbiviz.json +1 -1
- package/templates/visuals/default/src/settings.ts +54 -3
- package/templates/visuals/default/src/visual.ts +14 -17
- package/templates/visuals/rhtml/capabilities.json +2 -1
- package/templates/visuals/rhtml/package.json +2 -2
- package/templates/visuals/rhtml/pbiviz.json +1 -1
- package/templates/visuals/rhtml/src/settings.ts +28 -3
- package/templates/visuals/rhtml/src/visual.ts +29 -23
- package/templates/visuals/rvisual/capabilities.json +2 -1
- package/templates/visuals/rvisual/package.json +2 -2
- package/templates/visuals/rvisual/pbiviz.json +1 -1
- package/templates/visuals/rvisual/src/settings.ts +28 -3
- package/templates/visuals/rvisual/src/visual.ts +13 -15
- package/templates/visuals/slicer/capabilities.json +2 -1
- package/templates/visuals/slicer/package.json +2 -2
- package/templates/visuals/slicer/pbiviz.json +1 -1
- package/templates/visuals/slicer/src/settings.ts +29 -3
- package/templates/visuals/slicer/src/visual.ts +14 -17
- package/templates/visuals/table/capabilities.json +2 -1
- package/templates/visuals/table/package.json +2 -2
- package/templates/visuals/table/pbiviz.json +1 -1
- package/templates/visuals/table/src/settings.ts +23 -3
- package/templates/visuals/table/src/visual.ts +18 -16
- package/.eslintrc.json +0 -313
- package/.gitattributes +0 -4
- package/.github/workflows/build.yml +0 -32
- package/.github/workflows/codeql-analysis.yml +0 -54
- package/.snyk +0 -4
- package/.vscode/launch.json +0 -74
- package/.vscode/settings.json +0 -3
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Power BI Visual CLI
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Microsoft Corporation
|
|
5
|
+
* All rights reserved.
|
|
6
|
+
* MIT License
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the ""Software""), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in
|
|
16
|
+
* all copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
+
* THE SOFTWARE.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
"use strict";
|
|
28
|
+
|
|
29
|
+
let fs = require('fs-extra');
|
|
30
|
+
let path = require('path');
|
|
31
|
+
let childProcess = require('child_process');
|
|
32
|
+
let treeKill = require('tree-kill');
|
|
33
|
+
|
|
34
|
+
const TEMP_DIR = path.join(__dirname, '..', '.tmp');
|
|
35
|
+
const BIN_PATH = path.join(__dirname, '..', '..', 'bin', 'pbiviz.js');
|
|
36
|
+
const TEMPLATE_PATH = path.join(__dirname, '..', '..', 'templates');
|
|
37
|
+
|
|
38
|
+
class FileSystem {
|
|
39
|
+
static expectFileToExist(fileName) {
|
|
40
|
+
return new Promise((resolve, reject) => {
|
|
41
|
+
fs.exists(fileName, (exist) => {
|
|
42
|
+
if (exist) {
|
|
43
|
+
resolve();
|
|
44
|
+
} else {
|
|
45
|
+
reject(new Error(`File ${fileName} was expected to exist but not found...`));
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
static readFile(fileName) {
|
|
52
|
+
return new Promise((resolve, reject) => {
|
|
53
|
+
fs.readFile(fileName, 'utf-8', (err, data) => {
|
|
54
|
+
if (err) {
|
|
55
|
+
reject(err);
|
|
56
|
+
} else {
|
|
57
|
+
resolve(data);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
static expectFileToMatch(fileName, regEx) {
|
|
64
|
+
return FileSystem.readFile(fileName)
|
|
65
|
+
.then(content => {
|
|
66
|
+
if (typeof regEx == 'string') {
|
|
67
|
+
if (content.indexOf(regEx) == -1) {
|
|
68
|
+
throw new Error(`File "${fileName}" did not contain "${regEx}"...`);
|
|
69
|
+
}
|
|
70
|
+
} else if (!content.match(regEx)) {
|
|
71
|
+
throw new Error(`File "${fileName}" did not contain "${regEx}"...`);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
static getBinPath() {
|
|
77
|
+
return BIN_PATH;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
static getTempPath() {
|
|
81
|
+
return TEMP_DIR;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
static getTemplatePath() {
|
|
85
|
+
return TEMPLATE_PATH;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Creates the temp directory (deletes it first if it exists)
|
|
90
|
+
*/
|
|
91
|
+
static resetTempDirectory() {
|
|
92
|
+
FileSystem.deleteTempDirectory();
|
|
93
|
+
fs.ensureDirSync(TEMP_DIR);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Deletes the temporary directory if it exists
|
|
98
|
+
*/
|
|
99
|
+
static deleteTempDirectory() {
|
|
100
|
+
try {
|
|
101
|
+
fs.removeSync(TEMP_DIR);
|
|
102
|
+
} catch (e) {
|
|
103
|
+
console.log('DELETE ERROR', e);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Executes the pbiviz CLI
|
|
109
|
+
*
|
|
110
|
+
* @param {string} command - the command to be executed
|
|
111
|
+
* @param {string} [args=''] - arguments for the command
|
|
112
|
+
* @param {string} [flags=''] - command line flags
|
|
113
|
+
* @param {boolean} [verbose = false] - enables verbose output
|
|
114
|
+
*/
|
|
115
|
+
static runPbiviz(command, args, flags, verbose) {
|
|
116
|
+
let opts = verbose ? undefined : { stdio: [] }; // eslint-disable-line no-undefined
|
|
117
|
+
|
|
118
|
+
flags = flags ? ' ' + flags : '';
|
|
119
|
+
args = args ? ' ' + args : '';
|
|
120
|
+
let pbivizCmd = command + args + flags;
|
|
121
|
+
if (verbose) { console.log('run:', 'node ' + BIN_PATH + ' ' + pbivizCmd); }
|
|
122
|
+
return childProcess.execSync('node ' + BIN_PATH + ' ' + pbivizCmd, opts);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Executes console commands
|
|
127
|
+
*
|
|
128
|
+
* @param {string} command - the command to be executed
|
|
129
|
+
* @param {string} pathToExec - path where to execute command
|
|
130
|
+
* @param {string} pathToReturn - path to return after command execution
|
|
131
|
+
*/
|
|
132
|
+
static runCMDCommand(command, pathToExec, pathToReturn) {
|
|
133
|
+
process.chdir(pathToExec);
|
|
134
|
+
childProcess.execSync('npm i --silent');
|
|
135
|
+
if (pathToReturn) {
|
|
136
|
+
process.chdir(pathToReturn);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Executes the pbiviz CLI
|
|
142
|
+
*
|
|
143
|
+
* @param {string} command - the command to be executed
|
|
144
|
+
* @param {array} [args = []] - arguments for the command
|
|
145
|
+
* @param {boolean} [verbose = false] - enables verbose output
|
|
146
|
+
*/
|
|
147
|
+
static runPbivizAsync(command, args, verbose) {
|
|
148
|
+
if (verbose) { console.log('run:', 'node ' + BIN_PATH + ' ' + command, args || ''); }
|
|
149
|
+
|
|
150
|
+
let spawnCmd = [BIN_PATH, command];
|
|
151
|
+
if (args) { spawnCmd = spawnCmd.concat(args); }
|
|
152
|
+
return childProcess.spawn('node', spawnCmd);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Kills a process on any platform
|
|
157
|
+
*
|
|
158
|
+
* @param {object} childProcess - child process to kill
|
|
159
|
+
* @param {string} [signal] - signal to send ot the process
|
|
160
|
+
* @param {function} [callback] - callback called after all processes are terminated
|
|
161
|
+
*/
|
|
162
|
+
static killProcess(childProcess, signal, callback) {
|
|
163
|
+
let pid = childProcess.pid || childProcess.PID;
|
|
164
|
+
treeKill(pid, signal, (error) => {
|
|
165
|
+
if (callback) {
|
|
166
|
+
callback(error || null);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
module.exports = FileSystem;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Power BI Visual CLI
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Microsoft Corporation
|
|
5
|
+
* All rights reserved.
|
|
6
|
+
* MIT License
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the ""Software""), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in
|
|
16
|
+
* all copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
+
* THE SOFTWARE.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
"use strict";
|
|
28
|
+
|
|
29
|
+
let Jasmine = require('jasmine');
|
|
30
|
+
let SpecReporter = require('jasmine-spec-reporter').SpecReporter;
|
|
31
|
+
|
|
32
|
+
let jrunner = new Jasmine();
|
|
33
|
+
jrunner.configureDefaultReporter({ print: () => {} }); // eslint-disable-line no-empty-function
|
|
34
|
+
jasmine.getEnv().addReporter(new SpecReporter());
|
|
35
|
+
jrunner.loadConfigFile();
|
|
36
|
+
jrunner.execute();
|
|
@@ -13,10 +13,8 @@
|
|
|
13
13
|
],
|
|
14
14
|
"objects": {
|
|
15
15
|
"dataPoint": {
|
|
16
|
-
"displayName": "Data colors",
|
|
17
16
|
"properties": {
|
|
18
17
|
"defaultColor": {
|
|
19
|
-
"displayName": "Default color",
|
|
20
18
|
"type": {
|
|
21
19
|
"fill": {
|
|
22
20
|
"solid": {
|
|
@@ -26,13 +24,11 @@
|
|
|
26
24
|
}
|
|
27
25
|
},
|
|
28
26
|
"showAllDataPoints": {
|
|
29
|
-
"displayName": "Show all",
|
|
30
27
|
"type": {
|
|
31
28
|
"bool": true
|
|
32
29
|
}
|
|
33
30
|
},
|
|
34
31
|
"fill": {
|
|
35
|
-
"displayName": "Fill",
|
|
36
32
|
"type": {
|
|
37
33
|
"fill": {
|
|
38
34
|
"solid": {
|
|
@@ -42,13 +38,11 @@
|
|
|
42
38
|
}
|
|
43
39
|
},
|
|
44
40
|
"fillRule": {
|
|
45
|
-
"displayName": "Color saturation",
|
|
46
41
|
"type": {
|
|
47
42
|
"fill": {}
|
|
48
43
|
}
|
|
49
44
|
},
|
|
50
45
|
"fontSize": {
|
|
51
|
-
"displayName": "Text Size",
|
|
52
46
|
"type": {
|
|
53
47
|
"formatting": {
|
|
54
48
|
"fontSize": true
|
|
@@ -80,5 +74,6 @@
|
|
|
80
74
|
}
|
|
81
75
|
}
|
|
82
76
|
}
|
|
83
|
-
]
|
|
77
|
+
],
|
|
78
|
+
"privileges": []
|
|
84
79
|
}
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@types/d3": "5.7.2",
|
|
17
17
|
"d3": "5.12.0",
|
|
18
|
-
"powerbi-visuals-
|
|
19
|
-
"powerbi-visuals-
|
|
18
|
+
"powerbi-visuals-api": "5.1.0",
|
|
19
|
+
"powerbi-visuals-utils-formattingmodel": "5.0.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"ts-loader": "6.1.0",
|
|
@@ -26,7 +26,58 @@
|
|
|
26
26
|
|
|
27
27
|
"use strict";
|
|
28
28
|
|
|
29
|
-
import {
|
|
30
|
-
import DataViewObjectsParser = dataViewObjectsParser.DataViewObjectsParser;
|
|
29
|
+
import { formattingSettings } from "powerbi-visuals-utils-formattingmodel";
|
|
31
30
|
|
|
32
|
-
|
|
31
|
+
import FormattingSettingsCard = formattingSettings.Card;
|
|
32
|
+
import FormattingSettingsSlice = formattingSettings.Slice;
|
|
33
|
+
import FormattingSettingsModel = formattingSettings.Model;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Data Point Formatting Card
|
|
37
|
+
*/
|
|
38
|
+
class DataPointCardSettings extends FormattingSettingsCard {
|
|
39
|
+
defaultColor = new formattingSettings.ColorPicker({
|
|
40
|
+
name: "defaultColor",
|
|
41
|
+
displayName: "Default color",
|
|
42
|
+
value: { value: "" }
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
showAllDataPoints = new formattingSettings.ToggleSwitch({
|
|
46
|
+
name: "showAllDataPoints",
|
|
47
|
+
displayName: "Show all",
|
|
48
|
+
value: true
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
fill = new formattingSettings.ColorPicker({
|
|
52
|
+
name: "fill",
|
|
53
|
+
displayName: "Fill",
|
|
54
|
+
value: { value: "" }
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
fillRule = new formattingSettings.ColorPicker({
|
|
58
|
+
name: "fillRule",
|
|
59
|
+
displayName: "Color saturation",
|
|
60
|
+
value: { value: "" }
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
fontSize = new formattingSettings.NumUpDown({
|
|
64
|
+
name: "fontSize",
|
|
65
|
+
displayName: "Text Size",
|
|
66
|
+
value: 12
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
name: string = "dataPoint";
|
|
70
|
+
displayName: string = "Data colors";
|
|
71
|
+
slices: Array<FormattingSettingsSlice> = [this.defaultColor, this.showAllDataPoints, this.fill, this.fillRule, this.fontSize];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* visual settings model class
|
|
76
|
+
*
|
|
77
|
+
*/
|
|
78
|
+
export class VisualFormattingSettingsModel extends FormattingSettingsModel {
|
|
79
|
+
// Create formatting settings model formatting cards
|
|
80
|
+
dataPointCard = new DataPointCardSettings();
|
|
81
|
+
|
|
82
|
+
cards = [this.dataPointCard];
|
|
83
|
+
}
|
|
@@ -25,25 +25,26 @@
|
|
|
25
25
|
*/
|
|
26
26
|
"use strict";
|
|
27
27
|
|
|
28
|
-
import "./../style/visual.less";
|
|
29
28
|
import powerbi from "powerbi-visuals-api";
|
|
29
|
+
import { FormattingSettingsService } from "powerbi-visuals-utils-formattingmodel";
|
|
30
|
+
import "./../style/visual.less";
|
|
31
|
+
|
|
30
32
|
import VisualConstructorOptions = powerbi.extensibility.visual.VisualConstructorOptions;
|
|
31
33
|
import VisualUpdateOptions = powerbi.extensibility.visual.VisualUpdateOptions;
|
|
32
34
|
import IVisual = powerbi.extensibility.visual.IVisual;
|
|
33
|
-
import EnumerateVisualObjectInstancesOptions = powerbi.EnumerateVisualObjectInstancesOptions;
|
|
34
|
-
import VisualObjectInstance = powerbi.VisualObjectInstance;
|
|
35
|
-
import DataView = powerbi.DataView;
|
|
36
|
-
import VisualObjectInstanceEnumerationObject = powerbi.VisualObjectInstanceEnumerationObject;
|
|
37
35
|
|
|
38
|
-
import {
|
|
36
|
+
import { VisualFormattingSettingsModel } from "./settings";
|
|
37
|
+
|
|
39
38
|
export class Visual implements IVisual {
|
|
40
39
|
private target: HTMLElement;
|
|
41
40
|
private updateCount: number;
|
|
42
|
-
private settings: VisualSettings;
|
|
43
41
|
private textNode: Text;
|
|
42
|
+
private formattingSettings: VisualFormattingSettingsModel;
|
|
43
|
+
private formattingSettingsService: FormattingSettingsService;
|
|
44
44
|
|
|
45
45
|
constructor(options: VisualConstructorOptions) {
|
|
46
46
|
console.log('Visual constructor', options);
|
|
47
|
+
this.formattingSettingsService = new FormattingSettingsService();
|
|
47
48
|
this.target = options.element;
|
|
48
49
|
this.updateCount = 0;
|
|
49
50
|
if (document) {
|
|
@@ -58,23 +59,19 @@ export class Visual implements IVisual {
|
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
public update(options: VisualUpdateOptions) {
|
|
61
|
-
this.
|
|
62
|
+
this.formattingSettings = this.formattingSettingsService.populateFormattingSettingsModel(VisualFormattingSettingsModel, options.dataViews);
|
|
63
|
+
|
|
62
64
|
console.log('Visual update', options);
|
|
63
65
|
if (this.textNode) {
|
|
64
66
|
this.textNode.textContent = (this.updateCount++).toString();
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
69
|
|
|
68
|
-
private static parseSettings(dataView: DataView): VisualSettings {
|
|
69
|
-
return <VisualSettings>VisualSettings.parse(dataView);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
70
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
71
|
+
* Returns properties pane formatting model content hierarchies, properties and latest formatting values, Then populate properties pane.
|
|
72
|
+
* This method is called once every time we open properties pane or when the user edit any format property.
|
|
76
73
|
*/
|
|
77
|
-
public
|
|
78
|
-
return
|
|
74
|
+
public getFormattingModel(): powerbi.visuals.FormattingModel {
|
|
75
|
+
return this.formattingSettingsService.buildFormattingModel(this.formattingSettings);
|
|
79
76
|
}
|
|
80
77
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "visual",
|
|
3
3
|
"dependencies": {
|
|
4
|
-
"powerbi-visuals-utils-
|
|
4
|
+
"powerbi-visuals-utils-formattingmodel": "5.0.0"
|
|
5
5
|
},
|
|
6
6
|
"devDependencies": {
|
|
7
|
-
"powerbi-visuals-api": "
|
|
7
|
+
"powerbi-visuals-api": "5.1.0",
|
|
8
8
|
"ts-loader": "6.1.0",
|
|
9
9
|
"tslint": "^5.18.0",
|
|
10
10
|
"tslint-microsoft-contrib": "^6.2.0",
|
|
@@ -26,7 +26,32 @@
|
|
|
26
26
|
|
|
27
27
|
"use strict";
|
|
28
28
|
|
|
29
|
-
import {
|
|
30
|
-
import DataViewObjectsParser = dataViewObjectsParser.DataViewObjectsParser;
|
|
29
|
+
import { formattingSettings } from "powerbi-visuals-utils-formattingmodel";
|
|
31
30
|
|
|
32
|
-
|
|
31
|
+
import FormattingSettingsCard = formattingSettings.Card;
|
|
32
|
+
import FormattingSettingsSlice = formattingSettings.Slice;
|
|
33
|
+
import FormattingSettingsModel = formattingSettings.Model;
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* RCV Script Formatting Card
|
|
38
|
+
*/
|
|
39
|
+
class rcvScriptCardSettings extends FormattingSettingsCard {
|
|
40
|
+
provider: FormattingSettingsSlice = undefined;
|
|
41
|
+
source: FormattingSettingsSlice = undefined;
|
|
42
|
+
|
|
43
|
+
name: string = "rcv_script";
|
|
44
|
+
displayName: string = "rcv_script";
|
|
45
|
+
slices: Array<FormattingSettingsSlice> = [this.provider, this.source];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* visual settings model class
|
|
50
|
+
*
|
|
51
|
+
*/
|
|
52
|
+
export class VisualFormattingSettingsModel extends FormattingSettingsModel {
|
|
53
|
+
// Create formatting settings model formatting cards
|
|
54
|
+
rcvScriptCard = new rcvScriptCardSettings();
|
|
55
|
+
|
|
56
|
+
cards = [this.rcvScriptCard];
|
|
57
|
+
}
|
|
@@ -25,17 +25,16 @@
|
|
|
25
25
|
*/
|
|
26
26
|
"use strict";
|
|
27
27
|
import powerbi from "powerbi-visuals-api";
|
|
28
|
+
import { formattingSettings, FormattingSettingsService } from "powerbi-visuals-utils-formattingmodel";
|
|
29
|
+
|
|
28
30
|
import VisualConstructorOptions = powerbi.extensibility.visual.VisualConstructorOptions;
|
|
29
31
|
import VisualUpdateOptions = powerbi.extensibility.visual.VisualUpdateOptions;
|
|
30
32
|
import IVisual = powerbi.extensibility.visual.IVisual;
|
|
31
|
-
import EnumerateVisualObjectInstancesOptions = powerbi.EnumerateVisualObjectInstancesOptions;
|
|
32
|
-
import VisualObjectInstance = powerbi.VisualObjectInstance;
|
|
33
33
|
import DataView = powerbi.DataView;
|
|
34
34
|
import IViewport = powerbi.IViewport;
|
|
35
|
-
import VisualObjectInstanceEnumerationObject = powerbi.VisualObjectInstanceEnumerationObject;
|
|
36
35
|
|
|
37
|
-
import { VisualSettings } from "./settings";
|
|
38
36
|
import { parseElement, resetInjector, runHTMLWidgetRenderer } from "./htmlInjectionUtility";
|
|
37
|
+
import { VisualFormattingSettingsModel } from "./settings";
|
|
39
38
|
|
|
40
39
|
enum VisualUpdateType {
|
|
41
40
|
Data = 2,
|
|
@@ -47,19 +46,30 @@ enum VisualUpdateType {
|
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
// below is a snippet of a definition for an object which will contain the property values
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
/*class settingsCardSettings extends FormattingSettingsCard {
|
|
50
|
+
lineColor: FormattingSettingsSlice = new formattingSettings.ColorPicker({
|
|
51
|
+
name: "lineColor",
|
|
52
|
+
displayName: "Line Color",
|
|
53
|
+
value: { value: "#000000" }
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
name: string = "settings";
|
|
57
|
+
displayName: string = "Visual Settings";
|
|
58
|
+
description: string = "Visual Settings Tooltip";
|
|
59
|
+
slices: Array<FormattingSettingsSlice> = [this.lineColor];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export class VisualFormattingSettingsModel extends FormattingSettingsModel {
|
|
63
|
+
settingsCard = new settingsCardSettings();
|
|
64
|
+
|
|
65
|
+
cards = [this.settingsCard];
|
|
53
66
|
}*/
|
|
54
67
|
|
|
55
68
|
// to allow this scenario you should first the following JSON definition to the capabilities.json file
|
|
56
69
|
// under the "objects" property:
|
|
57
70
|
// "settings": {
|
|
58
|
-
// "displayName": "Visual Settings",
|
|
59
|
-
// "description": "Visual Settings Tooltip",
|
|
60
71
|
// "properties": {
|
|
61
72
|
// "lineColor": {
|
|
62
|
-
// "displayName": "Line Color",
|
|
63
73
|
// "type": { "fill": { "solid": { "color": true }}}
|
|
64
74
|
// }
|
|
65
75
|
// }
|
|
@@ -78,9 +88,11 @@ export class Visual implements IVisual {
|
|
|
78
88
|
private rootElement: HTMLElement;
|
|
79
89
|
private headNodes: Node[];
|
|
80
90
|
private bodyNodes: Node[];
|
|
81
|
-
private
|
|
91
|
+
private formattingSettings: VisualFormattingSettingsModel;
|
|
92
|
+
private formattingSettingsService: FormattingSettingsService;
|
|
82
93
|
|
|
83
94
|
public constructor(options: VisualConstructorOptions) {
|
|
95
|
+
this.formattingSettingsService = new FormattingSettingsService();
|
|
84
96
|
if (options && options.element) {
|
|
85
97
|
this.rootElement = options.element;
|
|
86
98
|
}
|
|
@@ -89,7 +101,6 @@ export class Visual implements IVisual {
|
|
|
89
101
|
}
|
|
90
102
|
|
|
91
103
|
public update(options: VisualUpdateOptions): void {
|
|
92
|
-
|
|
93
104
|
if (!options ||
|
|
94
105
|
!options.type ||
|
|
95
106
|
!options.viewport ||
|
|
@@ -98,8 +109,9 @@ export class Visual implements IVisual {
|
|
|
98
109
|
!options.dataViews[0]) {
|
|
99
110
|
return;
|
|
100
111
|
}
|
|
112
|
+
|
|
101
113
|
const dataView: DataView = options.dataViews[0];
|
|
102
|
-
this.
|
|
114
|
+
this.formattingSettings = this.formattingSettingsService.populateFormattingSettingsModel(VisualFormattingSettingsModel, options.dataViews);
|
|
103
115
|
|
|
104
116
|
let payloadBase64: string = null;
|
|
105
117
|
if (dataView.scriptResult && dataView.scriptResult.payloadBase64) {
|
|
@@ -168,17 +180,11 @@ export class Visual implements IVisual {
|
|
|
168
180
|
runHTMLWidgetRenderer();
|
|
169
181
|
}
|
|
170
182
|
|
|
171
|
-
private static parseSettings(dataView: DataView): VisualSettings {
|
|
172
|
-
return <VisualSettings>VisualSettings.parse(dataView);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
183
|
/**
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
184
|
+
* Returns properties pane formatting model content hierarchies, properties and latest formatting values, Then populate properties pane.
|
|
185
|
+
* This method is called once every time we open properties pane or when the user edit any format property.
|
|
179
186
|
*/
|
|
180
|
-
public
|
|
181
|
-
|
|
182
|
-
return VisualSettings.enumerateObjectInstances(this.settings || VisualSettings.getDefault(), options);
|
|
187
|
+
public getFormattingModel(): powerbi.visuals.FormattingModel {
|
|
188
|
+
return this.formattingSettingsService.buildFormattingModel(this.formattingSettings);
|
|
183
189
|
}
|
|
184
190
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "visual",
|
|
3
3
|
"dependencies": {
|
|
4
|
-
"powerbi-visuals-utils-
|
|
4
|
+
"powerbi-visuals-utils-formattingmodel": "5.0.0"
|
|
5
5
|
},
|
|
6
6
|
"devDependencies": {
|
|
7
|
-
"powerbi-visuals-api": "
|
|
7
|
+
"powerbi-visuals-api": "5.1.0",
|
|
8
8
|
"tslint": "^5.18.0",
|
|
9
9
|
"tslint-microsoft-contrib": "^6.2.0",
|
|
10
10
|
"typescript": "3.6.3"
|
|
@@ -26,7 +26,32 @@
|
|
|
26
26
|
|
|
27
27
|
"use strict";
|
|
28
28
|
|
|
29
|
-
import {
|
|
30
|
-
import DataViewObjectsParser = dataViewObjectsParser.DataViewObjectsParser;
|
|
29
|
+
import { formattingSettings } from "powerbi-visuals-utils-formattingmodel";
|
|
31
30
|
|
|
32
|
-
|
|
31
|
+
import FormattingSettingsCard = formattingSettings.Card;
|
|
32
|
+
import FormattingSettingsSlice = formattingSettings.Slice;
|
|
33
|
+
import FormattingSettingsModel = formattingSettings.Model;
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* RCV Script Formatting Card
|
|
38
|
+
*/
|
|
39
|
+
class rcvScriptCardSettings extends FormattingSettingsCard {
|
|
40
|
+
provider: FormattingSettingsSlice = undefined;
|
|
41
|
+
source: FormattingSettingsSlice = undefined;
|
|
42
|
+
|
|
43
|
+
name: string = "rcv_script";
|
|
44
|
+
displayName: string = "rcv_script";
|
|
45
|
+
slices: Array<FormattingSettingsSlice> = [this.provider, this.source];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* visual settings model class
|
|
50
|
+
*
|
|
51
|
+
*/
|
|
52
|
+
export class VisualFormattingSettingsModel extends FormattingSettingsModel {
|
|
53
|
+
// Create formatting settings model formatting cards
|
|
54
|
+
rcvScriptCard = new rcvScriptCardSettings();
|
|
55
|
+
|
|
56
|
+
cards = [this.rcvScriptCard];
|
|
57
|
+
}
|