Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add plotlyServerUrl to baseUrl #2760

Merged
merged 4 commits into from
Jun 27, 2018
Merged

Add plotlyServerUrl to baseUrl #2760

merged 4 commits into from
Jun 27, 2018

Conversation

chriddyp
Copy link
Member

Fixes #2759 (comment)

I haven't tested this.

@etpinard
Copy link
Contributor

Ok. I'll take it from here.

Will be part of v1.39.0.

it('can be set to other base urls', function(done) {
Plotly.plot(gd, [], {}, {plotlyServerUrl: 'dummy'})
.then(function() {
expect(gd._context.plotlyServerUrl).toBe('dummy');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests aren't great, but I couldn't find an easy way to mock the form submit in

plots.sendDataToCloud = function(gd) {
gd.emit('plotly_beforeexport');
var baseUrl = (window.PLOTLYENV && window.PLOTLYENV.BASE_URL) || 'https://plot.ly';
var hiddenformDiv = d3.select(gd)
.append('div')
.attr('id', 'hiddenform')
.style('display', 'none');
var hiddenform = hiddenformDiv
.append('form')
.attr({
action: baseUrl + '/external',
method: 'post',
target: '_blank'
});
var hiddenformInput = hiddenform
.append('input')
.attr({
type: 'text',
name: 'data'
});
hiddenformInput.node().value = plots.graphJson(gd, false, 'keepdata');
hiddenform.node().submit();
hiddenformDiv.remove();
gd.emit('plotly_afterexport');
return false;
};


beforeEach(function() {
gd = createGraphDiv();
spyOn(HTMLFormElement.prototype, 'submit').and.callFake(function() {
form = this;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you @alexcjohnson for the tip!

// and the showLink/sendData on-graph link
plotlyServerUrl: 'https://plot.ly',
plotlyServerURL: 'https://plot.ly',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call, that also seems more standard in the built-in API (eg canvas.toDataURL) though we have some other internal routines that use ...Url, like Drawing.setClipUrl.

@alexcjohnson
Copy link
Collaborator

Big improvement - thanks @chriddyp, looks great @etpinard 💃

@etpinard etpinard merged commit 0673823 into master Jun 27, 2018
@etpinard etpinard deleted the chriddyp-patch-1 branch June 27, 2018 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants