Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Merge pull request #54 from CCI-Tools/544-hp-allow_proxy_config
Browse files Browse the repository at this point in the history
544 hp allow proxy config
  • Loading branch information
forman authored Apr 17, 2018
2 parents 2be4427 + 6856a16 commit 09ca614
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
* Error - Removal of Resource Causes Failure Instead of Gracefully Informing User.
[#589](https://github.com/CCI-Tools/cate/issues/589)

* Allow proxy configuration in Cate Desktop
[#544](https://github.com/CCI-Tools/cate/issues/544)


## Changes in 2.0.0-dev.8

Expand Down
6 changes: 4 additions & 2 deletions src/renderer/actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,15 @@ describe('Actions', () => {
{
dataStoresPath: '/a/b/c',
useWorkspaceImageryCache: false,
resourceNamePattern: 'var_{index}'
resourceNamePattern: 'var_{index}',
proxyUrl: 'http://user:password@host:port'
}));
expect(getState().session.backendConfig).to.deep.equal(
{
dataStoresPath: '/a/b/c',
useWorkspaceImageryCache: false,
resourceNamePattern: 'var_{index}'
resourceNamePattern: 'var_{index}',
proxyUrl: 'http://user:password@host:port'
});
});
});
Expand Down
1 change: 0 additions & 1 deletion src/renderer/components/PanelContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
// Popover
} from "@blueprintjs/core";
import {Splitter} from "./Splitter";
import ReactElement = React.ReactElement;
import {CSSProperties} from "react";

export interface PanelContainerLayout {
Expand Down
12 changes: 7 additions & 5 deletions src/renderer/components/field/Field.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react'
import {isString, isUndefinedOrNull, isDefined, isDefinedAndNotNull} from "../../../common/types";
import {isString, isUndefinedOrNull, isDefined, isDefinedAndNotNull} from '../../../common/types';

export type FieldType<T> = T | null;

Expand Down Expand Up @@ -34,7 +34,7 @@ export function toTextValue(value: AnyFieldValue | any) {
} else if (isString(value)) {
return value;
}
return isDefinedAndNotNull(value)? `${value}` : '';
return isDefinedAndNotNull(value) ? `${value}` : '';
}

export function toValue(value: any) {
Expand All @@ -53,8 +53,8 @@ export function toValue(value: any) {
*/
export class Field<P extends IFieldProps> extends React.PureComponent<P, IFieldState> {

static readonly NOMINAL_CLASS = "pt-input";
static readonly ERROR_CLASS = "pt-input pt-intent-danger";
static readonly NOMINAL_CLASS = 'pt-input';
static readonly ERROR_CLASS = 'pt-input pt-intent-danger';

protected _fieldValue: AnyFieldValue;

Expand Down Expand Up @@ -208,13 +208,15 @@ export class Field<P extends IFieldProps> extends React.PureComponent<P, IFieldS
render() {
const error = this.getError();
// console.log("Field.render: fieldValue = ", this._fieldValue);
const errorClassName = Field.ERROR_CLASS + ' ' + this.props.className;
const nominalClassName = Field.NOMINAL_CLASS + ' ' + this.props.className;
return (
<input value={this.getTextValue()}
onChange={this.handleInputChange}
onBlur={this.handleBlur}
onKeyPress={this.handleKeyPress}
type="text"
className={error ? Field.ERROR_CLASS : Field.NOMINAL_CLASS}
className={error ? errorClassName : nominalClassName}
style={this.props.style}
size={this.props.size}
placeholder={this.props.placeholder}
Expand Down
27 changes: 27 additions & 0 deletions src/renderer/containers/PreferencesDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class PreferencesDialog extends React.Component<IPreferencesDialogProps & Dispat
<Tabs2 id="preferences">
<Tab2 id="g" title="General" panel={this.renderGeneralPanel()}/>
<Tab2 id="dm" title="Data Management" panel={this.renderDataManagementPanel()}/>
<Tab2 id="pc" title="Proxy Configuration" panel={this.renderProxyConfigurationPanel()}/>
</Tabs2>
);
}
Expand All @@ -123,6 +124,14 @@ class PreferencesDialog extends React.Component<IPreferencesDialogProps & Dispat
);
}

private renderProxyConfigurationPanel() {
return (
<div style={{width: '100%', marginTop: '1em'}}>
{this.renderProxyUrlInput()}
</div>
);
}

private renderReopenLastWorkspace() {
return this.renderBooleanValue(
'reopenLastWorkspace',
Expand Down Expand Up @@ -187,6 +196,24 @@ class PreferencesDialog extends React.Component<IPreferencesDialogProps & Dispat
);
}

private renderProxyUrlInput() {
const initialValue = this.getStateValue("proxyUrl", true);
const onChange = this.getChangeHandler("proxyUrl", true);
return (
<div className="pt-control-group"
style={{width: '100%', marginBottom: '1em', display: 'flex', alignItems: 'center'}}>
<span style={{flexBasis: '100px'}}>Proxy URL:</span>
<TextField className="pt-input pt-fill"
style={{flexGrow: 0.2, marginLeft: '20px'}}
value={initialValue}
onChange={onChange}
placeholder={'http://user:password@host:port'}
nullable={true}
/>
</div>
);
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Components
// Note (forman): could make this React component later
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/containers/VariablesPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {Position, Colors} from "@blueprintjs/core";
import {Cell, Column, Table, TruncatedFormat} from "@blueprintjs/table";
import {ScrollablePanelContent} from "../components/ScrollableContent";
import {NO_VARIABLES, NO_VARIABLES_EMPTY_RESOURCE} from "../messages";
import {CSSProperties} from "react";
import {CSSProperties} from 'react';
import * as Cesium from "cesium";
import {ToolButton} from "../components/ToolButton";
import {isSpatialImageVariable, isSpatialVectorVariable} from "../state-util";
Expand Down
1 change: 1 addition & 0 deletions src/renderer/initial-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export const INITIAL_SESSION_STATE: SessionState = {
dataStoresPath: null,
useWorkspaceImageryCache: false,
resourceNamePattern: 'res_{index}',
proxyUrl: null,
},
};

Expand Down
1 change: 1 addition & 0 deletions src/renderer/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,7 @@ export interface BackendConfigState {
dataStoresPath: string;
useWorkspaceImageryCache: boolean;
resourceNamePattern: string;
proxyUrl: string;
}

export interface Placemark extends Feature<Point> {
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/webapi/apis/BackendConfigAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function fromPythonConfig(configResponse: any): BackendConfigState|null {
dataStoresPath: configResponse.data_stores_path,
useWorkspaceImageryCache: configResponse.use_workspace_imagery_cache,
resourceNamePattern: configResponse.default_res_pattern,
proxyUrl: configResponse.http_proxy
};
}

Expand All @@ -22,6 +23,7 @@ function toPythonConfig(backendConfig: BackendConfigState): any {
data_stores_path: backendConfig.dataStoresPath,
use_workspace_imagery_cache: backendConfig.useWorkspaceImageryCache,
default_res_pattern: backendConfig.resourceNamePattern,
http_proxy: backendConfig.proxyUrl
};
}

Expand Down

0 comments on commit 09ca614

Please sign in to comment.