Skip to content

Commit

Permalink
Show default port and api
Browse files Browse the repository at this point in the history
  • Loading branch information
fortuna committed Jan 3, 2019
1 parent ce60417 commit 488cad5
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/server_manager/model/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ export interface Server {
// Returns the server's domain name or IP address.
getHostname(): string;

// Returns the server's management API port.
getManagementPort(): number;

// Returns the server's management API URL.
getManagementApiUrl(): string;

// Returns the port number for new access keys.
getDefaultAccessKeyPort(): number;
}

// Manual servers are servers which the user has independently setup to run
Expand Down
6 changes: 4 additions & 2 deletions src/server_manager/ui_components/outline-server-settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ <h3>Server Information</h3>
<paper-input id="serverNameInput" class="server-name" value="{{name}}" label="Name" always-float-label maxlength="100" on-keydown="_handleNameInputKeyDown" on-blur="_handleNameInputBlur"></paper-input>
<p class="detail">Set a new name for your server. Note that this will not be reflected on the devices of the users that you invited to connect to it.</p>
<paper-input disabled value="[[serverHostname]]" label="Hostname" hidden$="[[!serverHostname]]" always-float-label maxlength="100"></paper-input>
<paper-input disabled value="[[serverManagementPort]]" label="Management port" hidden$="[[!serverManagementPort]]" always-float-label maxlength="100"></paper-input>
<paper-input disabled value="[[serverManagementApiUrl]]" label="Management API URL" hidden$="[[!serverManagementApiUrl]]" always-float-label maxlength="100"></paper-input>
<paper-input disabled value="[[serverDefaultAccessKeyPort]]" label="Default Access Key port" hidden$="[[!serverDefaultAccessKeyPort]]" always-float-label maxlength="100"></paper-input>
<paper-input disabled value="[[serverCreationDate]]" label="Created" hidden$="[[!serverCreationDate]]" always-float-label maxlength="100"></paper-input>
<paper-input disabled value="[[serverId]]" label="Server ID" hidden$="[[!serverId]]" always-float-label maxlength="100"></paper-input>
</div>
Expand Down Expand Up @@ -161,7 +162,8 @@ <h3>Share anonymous metrics</h3>
// Initialize to null so we can use the hidden attribute, which does not work well with undefined values.
serverId: {type: String, value: null},
serverHostname: {type: String, value: null},
serverManagementPort: {type: Number, value: null},
serverManagementApiUrl: {type: String, value: null},
serverDefaultAccessKeyPort: {type: Number, value: null},
serverCreationDate: {type: String, value: null},
serverLocation: {type: String, value: null},
serverMonthlyCost: {type: String, value: null},
Expand Down
16 changes: 14 additions & 2 deletions src/server_manager/ui_components/outline-server-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,18 @@ <h3>[[accessKeyRows.length]]</h3>
</div>
</div>
<div name="settings">
<outline-server-settings id="serverSettings" server-id="[[serverId]]" server-hostname="[[serverHostname]]" server-management-port="[[serverManagementPort]]" server-creation-date="[[serverCreationDate]]" server-monthly-cost="[[monthlyCost]]" server-monthly-transfer-limit="[[_formatBytesTransferred(monthlyOutboundTransferBytes)]]" is-server-managed="[[isServerManaged]]" server-location="[[serverLocation]]"></outline-server-settings>
<outline-server-settings
id="serverSettings"
server-id="[[serverId]]"
server-hostname="[[serverHostname]]"
server-management-api-url="[[serverManagementApiUrl]]"
server-default-access-key-port="[[serverDefaultAccessKeyPort]]"
server-creation-date="[[serverCreationDate]]"
server-monthly-cost="[[monthlyCost]]"
server-monthly-transfer-limit="[[_formatBytesTransferred(monthlyOutboundTransferBytes)]]"
is-server-managed="[[isServerManaged]]"
server-location="[[serverLocation]]">
</outline-server-settings>
</div>
</iron-pages>
</div>
Expand Down Expand Up @@ -518,7 +529,8 @@ <h3>Create keys, share access</h3>
serverId: String,
serverName: String,
serverHostname: String,
serverManagementPort: Number,
serverManagementApiUrl: String,
serverDefaultAccessKeyPort: Number,
serverCreationDate: String,
serverLocation: String,
isServerManaged: Boolean,
Expand Down
6 changes: 3 additions & 3 deletions src/server_manager/web_app/app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,12 @@ class FakeServer implements server.Server {
getHostname() {
return 'fake-server';
}
getManagementPort() {
return 8080;
}
getManagementApiUrl() {
return this.apiUrl || Math.random().toString();
}
getDefaultAccessKeyPort(): number {
return undefined;
}
}

class FakeManualServer extends FakeServer implements server.ManualServer {
Expand Down
3 changes: 2 additions & 1 deletion src/server_manager/web_app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,8 @@ export class App {
view.serverId = selectedServer.getServerId();
view.serverName = selectedServer.getName();
view.serverHostname = selectedServer.getHostname();
view.serverManagementPort = selectedServer.getManagementPort();
view.serverManagementApiUrl = selectedServer.getManagementApiUrl();
view.serverDefaultAccessKeyPort = selectedServer.getDefaultAccessKeyPort();
view.serverCreationDate = selectedServer.getCreatedDate().toLocaleString(
'en-US', {year: 'numeric', month: 'long', day: 'numeric'});

Expand Down
8 changes: 6 additions & 2 deletions src/server_manager/web_app/shadowbox_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface ServerConfig {
metricsEnabled: boolean;
serverId: string;
createdTimestampMs: number;
defaultAccessKeyPort: number;
}

export class ShadowboxServer implements server.Server {
Expand Down Expand Up @@ -131,9 +132,12 @@ export class ShadowboxServer implements server.Server {
}
}

getManagementPort(): number {
getDefaultAccessKeyPort(): number {
try {
return parseInt(new URL(this.managementApiAddress).port, 10);
if (typeof this.serverConfig.defaultAccessKeyPort !== "number") {
return undefined;
}
return this.serverConfig.defaultAccessKeyPort;
} catch (e) {
return undefined;
}
Expand Down

0 comments on commit 488cad5

Please sign in to comment.