Skip to content

Commit 3bc9833

Browse files
committed
Initial checkin of everything from Perforce
Simple copy over of up-to-date perforce code. Only addition has been a .gitignore file
1 parent 28b4d35 commit 3bc9833

24 files changed

+1044
-1
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*~
2+
node_modules
3+
.DS_Store
4+
*.log

DevUtils/BuildAndCopy.js

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
const execSync = require('child_process').execSync;
2+
var BuildNumber = require('./BuildNumber.js');
3+
var path = require('path');
4+
var fs = require('fs.extra');
5+
6+
console.log("Running build");
7+
execSync('npm run-script build');
8+
9+
console.log("Running build minify");
10+
execSync('npm run-script build_min');
11+
12+
console.log("Done runing build processes");
13+
14+
// Get the build number so we know what to call this file
15+
var buildNumber = BuildNumber.getBuildNumber(true);
16+
17+
// Build up the names for the regular and minified versions of the file
18+
var newFullFileName = BuildNumber.WDC_LIB_PREFIX + buildNumber.toString() + ".js";
19+
var newMinFileName = BuildNumber.WDC_LIB_PREFIX + buildNumber.toString() + ".min.js";
20+
21+
// Build up the names for the latest versions of the file
22+
var latestBuildName = buildNumber.major + "." + buildNumber.minor + ".latest";
23+
var newLatestFullFileName = BuildNumber.WDC_LIB_PREFIX + latestBuildName + ".js";
24+
var newLatestMinFileName = BuildNumber.WDC_LIB_PREFIX + latestBuildName + ".min.js";
25+
26+
var copyPairs = [
27+
{src: "bundle.js", dest: newFullFileName},
28+
{src: "bundle.min.js", dest: newMinFileName},
29+
{src: "bundle.js", dest: newLatestFullFileName},
30+
{src: "bundle.min.js", dest: newLatestMinFileName},
31+
];
32+
33+
for(var pair of copyPairs) {
34+
(function() {
35+
var srcPath = path.join(__dirname, "..", "dist", pair.src);
36+
var dstPath = path.join(BuildNumber.getJsSdkDir(), pair.dest);
37+
38+
// Check if this file exists and not checked out. Try catch it because statSync can throw if file doesn't exist
39+
try {
40+
if (fs.statSync(dstPath).isFile() && !BuildNumber.isFileCheckedOut(dstPath)) {
41+
// We need to edit the file if it exists and isn't checked out
42+
var cmd = 'p4 edit "' + dstPath + '"';
43+
var result = execSync(cmd).toString();
44+
console.log(result);
45+
}
46+
} catch(e) {
47+
// Nothing
48+
}
49+
50+
fs.copy(srcPath, dstPath, {replace: true}, function(err) {
51+
if (err) {
52+
console.log("Error copying " + srcPath + " to " + dstPath);
53+
throw err.toString();
54+
}
55+
56+
console.log("Finished copying " + srcPath + " to " + dstPath);
57+
58+
// check to see if this file was checked out already. If not, p4 add it
59+
if (!BuildNumber.isFileCheckedOut(dstPath)) {
60+
var cmd = 'p4 add "' + dstPath + '"';
61+
var result = execSync(cmd).toString();
62+
console.log(result);
63+
}
64+
});
65+
})();
66+
}

DevUtils/BuildNumber.js

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
var fs = require('fs');
2+
var path = require('path');
3+
const execSync = require('child_process').execSync;
4+
5+
var WDC_LIB_PREFIX = "tableauwdc-";
6+
7+
function VersionNumber(versionString) {
8+
var components = versionString.split(".");
9+
if (components.length < 3) {
10+
console.log()
11+
throw "Invalid number of components. versionString was '" + versionString + "'";
12+
}
13+
14+
this.major = parseInt(components[0]).toString();
15+
this.minor = parseInt(components[1]).toString();
16+
this.fix = parseInt(components[2]).toString();
17+
}
18+
19+
VersionNumber.prototype.toString = function() {
20+
return this.major + "." + this.minor + "." + this.fix;
21+
}
22+
23+
VersionNumber.prototype.compare = function(other) {
24+
var majorDiff = this.major - other.major;
25+
var minorDiff = this.minor - other.minor;
26+
var fixDiff = this.fix - other.fix;
27+
28+
if (majorDiff != 0) return majorDiff;
29+
if (minorDiff != 0) return minorDiff;
30+
if (fixDiff != 0) return fixDiff;
31+
32+
return 0;
33+
}
34+
35+
function isFileCheckedOut(filePath) {
36+
var cmd = 'p4 opened "' + filePath + '"';
37+
var result = execSync(cmd).toString();
38+
if (result.indexOf("- edit") >= 0 || result.indexOf("- add") >= 0) {
39+
return true;
40+
} else {
41+
return false;
42+
}
43+
}
44+
45+
function getJsSdkDir() {
46+
var jsPath = path.join(__dirname, "..", "..", "js");
47+
return jsPath;
48+
}
49+
50+
function getBuildNumber(checkPerforce) {
51+
var destinationPath = getJsSdkDir();
52+
var existingFiles = fs.readdirSync(destinationPath);
53+
var existingBuildNumbers = [];
54+
for(var jsFile of existingFiles) {
55+
if (jsFile.substr(0, WDC_LIB_PREFIX.length) === WDC_LIB_PREFIX) {
56+
var numberString = jsFile.substr(WDC_LIB_PREFIX.length);
57+
numberString = numberString.substr(0, numberString.length - ".js".length);
58+
existingBuildNumbers.push(new VersionNumber(numberString));
59+
}
60+
}
61+
62+
var newest = new VersionNumber("0.0.0");
63+
for (var versionNumber of existingBuildNumbers) {
64+
if (versionNumber.compare(newest) > 0) {
65+
newest = versionNumber;
66+
}
67+
}
68+
69+
console.log("Most recent build is " + newest.toString());
70+
71+
var doIncrement = true;
72+
if (checkPerforce) {
73+
var newFileName = WDC_LIB_PREFIX + newest.toString() + ".js";
74+
var existingFilePath = path.join(getJsSdkDir(), newFileName);
75+
doIncrement = !isFileCheckedOut(existingFilePath);
76+
}
77+
78+
var nextBuildNumber = newest;
79+
if (doIncrement) {
80+
nextBuildNumber.fix++;
81+
}
82+
83+
console.log("Next number is " + nextBuildNumber.toString());
84+
return nextBuildNumber;
85+
}
86+
87+
module.exports.getBuildNumber = getBuildNumber;
88+
module.exports.WDC_LIB_PREFIX = WDC_LIB_PREFIX;
89+
module.exports.isFileCheckedOut = isFileCheckedOut;
90+
module.exports.getJsSdkDir = getJsSdkDir;

DevUtils/TestPage.html

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Test Page</title>
5+
</head>
6+
<body>
7+
<div id="root">
8+
</div>
9+
<script src="../dist/bundle.js"></script>
10+
</body>
11+
</html>

Enums.js

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/** This file lists all of the enums which should available for the WDC */
2+
var allEnums = {
3+
phaseEnum : {
4+
interactivePhase: "interactive",
5+
authPhase: "auth",
6+
gatherDataPhase: "gatherData"
7+
},
8+
9+
authPurposeEnum : {
10+
ephemeral: "ephemeral",
11+
enduring: "enduring"
12+
},
13+
14+
authTypeEnum : {
15+
none: "none",
16+
basic: "basic",
17+
custom: "custom"
18+
},
19+
20+
dataTypeEnum : {
21+
bool: "bool",
22+
date: "date",
23+
datetime: "datetime",
24+
float: "float",
25+
int: "int",
26+
string: "string"
27+
},
28+
29+
columnRoleEnum : {
30+
dimension: "dimension",
31+
measure: "measure"
32+
},
33+
34+
columnTypeEnum : {
35+
continuous: "continuous",
36+
discrete: "discrete"
37+
},
38+
39+
aggTypeEnum : {
40+
sum: "sum",
41+
avg: "avg",
42+
median: "median",
43+
count: "count",
44+
countd: "count_dist"
45+
},
46+
47+
geographicRoleEnum : {
48+
area_code: "area_code",
49+
cbsa_msa: "cbsa_msa",
50+
city: "city",
51+
congressional_district: "congressional_district",
52+
country_region: "country_region",
53+
county: "county",
54+
state_province: "state_province",
55+
zip_code_postcode: "zip_code_postcode",
56+
latitude: "latitude",
57+
longitude: "longitude"
58+
},
59+
60+
unitsFormatEnum : {
61+
thousands: "thousands",
62+
millions: "millions",
63+
billions_english: "billions_english",
64+
billions_standard: "billions_standard"
65+
},
66+
67+
numberFormatEnum : {
68+
number: "number",
69+
currency: "currency",
70+
scientific: "scientific",
71+
percentage: "percentage"
72+
},
73+
74+
localeEnum : {
75+
america: "en-us",
76+
brazil: "pt-br",
77+
china: "zh-cn",
78+
france: "fr-fr",
79+
germany: "de-de",
80+
japan: "ja-jp",
81+
korea: "ko-kr",
82+
spain: "es-es"
83+
},
84+
85+
joinEnum : {
86+
inner: "inner",
87+
left: "left"
88+
}
89+
}
90+
91+
// Applies the enums as properties of the target object
92+
function apply(target) {
93+
for(var key in allEnums) {
94+
target[key] = allEnums[key];
95+
}
96+
}
97+
98+
module.exports.apply = apply;

NativeDispatcher.js

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/** @class Used for communicating between Tableau desktop/server and the WDC's
2+
* Javascript. is predominantly a pass-through to the Qt WebBridge methods
3+
* @param nativeApiRootObj {Object} - The root object where the native Api methods
4+
* are available. For WebKit, this is window.
5+
*/
6+
function NativeDispatcher (nativeApiRootObj) {
7+
this.nativeApiRootObj = nativeApiRootObj;
8+
this._initPublicInterface();
9+
this._initPrivateInterface();
10+
}
11+
12+
NativeDispatcher.prototype._initPublicInterface = function() {
13+
console.log("Initializing public interface for NativeDispatcher");
14+
this._submitCalled = false;
15+
16+
var publicInterface = {};
17+
publicInterface.abortForAuth = this._abortForAuth.bind(this);
18+
publicInterface.abortWithError = this._abortWithError.bind(this);
19+
publicInterface.addCrossOriginException = this._addCrossOriginException.bind(this);
20+
publicInterface.log = this._log.bind(this);
21+
publicInterface.submit = this._submit.bind(this);
22+
publicInterface.reportProgress = this._reportProgress.bind(this);
23+
24+
this.publicInterface = publicInterface;
25+
}
26+
27+
NativeDispatcher.prototype._abortForAuth = function(msg) {
28+
this.nativeApiRootObj.WDCBridge_Api_abortForAuth.api(msg);
29+
}
30+
31+
NativeDispatcher.prototype._abortWithError = function(msg) {
32+
this.nativeApiRootObj.WDCBridge_Api_abortWithError.api(msg);
33+
}
34+
35+
NativeDispatcher.prototype._addCrossOriginException = function(destOriginList) {
36+
this.nativeApiRootObj.WDCBridge_Api_addCrossOriginException.api(destOriginList);
37+
}
38+
39+
NativeDispatcher.prototype._log = function(msg) {
40+
this.nativeApiRootObj.WDCBridge_Api_log.api(msg);
41+
}
42+
43+
NativeDispatcher.prototype._submit = function() {
44+
if (this._submitCalled) {
45+
console.log("submit called more than once");
46+
return;
47+
}
48+
49+
this._submitCalled = true;
50+
this.nativeApiRootObj.WDCBridge_Api_submit.api();
51+
};
52+
53+
NativeDispatcher.prototype._initPrivateInterface = function() {
54+
console.log("Initializing private interface for NativeDispatcher");
55+
56+
this._initCallbackCalled = false;
57+
this._shutdownCallbackCalled = false;
58+
59+
var privateInterface = {};
60+
privateInterface._initCallback = this._initCallback.bind(this);
61+
privateInterface._shutdownCallback = this._shutdownCallback.bind(this);
62+
privateInterface._schemaCallback = this._schemaCallback.bind(this);
63+
privateInterface._tableDataCallback = this._tableDataCallback.bind(this);
64+
privateInterface._dataDoneCallback = this._dataDoneCallback.bind(this);
65+
66+
this.privateInterface = privateInterface;
67+
}
68+
69+
NativeDispatcher.prototype._initCallback = function() {
70+
if (this._initCallbackCalled) {
71+
console.log("initCallback called more than once");
72+
return;
73+
}
74+
75+
this._initCallbackCalled = true;
76+
this.nativeApiRootObj.WDCBridge_Api_initCallback.api();
77+
}
78+
79+
NativeDispatcher.prototype._shutdownCallback = function() {
80+
if (this._shutdownCallbackCalled) {
81+
console.log("shutdownCallback called more than once");
82+
return;
83+
}
84+
85+
this._shutdownCallbackCalled = true;
86+
this.nativeApiRootObj.WDCBridge_Api_shutdownCallback.api();
87+
}
88+
89+
NativeDispatcher.prototype._schemaCallback = function(schema, standardConnections) {
90+
// Check to make sure we are using a version of desktop which has the WDCBridge_Api_schemaCallbackEx defined
91+
if (!!this.nativeApiRootObj.WDCBridge_Api_schemaCallbackEx) {
92+
// Providing standardConnections is optional but we can't pass undefined back because Qt will choke
93+
this.nativeApiRootObj.WDCBridge_Api_schemaCallbackEx.api(schema, standardConnections || []);
94+
} else {
95+
this.nativeApiRootObj.WDCBridge_Api_schemaCallback.api(schema);
96+
}
97+
}
98+
99+
NativeDispatcher.prototype._tableDataCallback = function(tableName, data) {
100+
this.nativeApiRootObj.WDCBridge_Api_tableDataCallback.api(tableName, data);
101+
}
102+
103+
NativeDispatcher.prototype._reportProgress = function (progress) {
104+
this.nativeApiRootObj.WDCBridge_Api_reportProgress.api(progress);
105+
}
106+
107+
NativeDispatcher.prototype._dataDoneCallback = function() {
108+
this.nativeApiRootObj.WDCBridge_Api_dataDoneCallback.api();
109+
}
110+
111+
module.exports = NativeDispatcher;

0 commit comments

Comments
 (0)