Skip to content

Commit

Permalink
feat: Link FastTrack button to frontend server (#2020)
Browse files Browse the repository at this point in the history
  • Loading branch information
rapsealk authored Nov 8, 2023
1 parent ac510e1 commit 51078d8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
15 changes: 14 additions & 1 deletion src/components/backend-ai-login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export default class BackendAILogin extends BackendAIPage {
@property({ type: String }) connection_mode = 'SESSION' as ConnectionMode;
@property({ type: String }) systemSSHImage = '';
@property({ type: String }) fasttrackEndpoint = '';
@property({ type: Boolean }) hideSideMenuFastTrackButton = false;
@property({ type: Number }) login_attempt_limit = 500;
@property({ type: Number }) login_block_time = 180;
@property({ type: String }) user;
Expand Down Expand Up @@ -1012,8 +1013,18 @@ export default class BackendAILogin extends BackendAIPage {
this.fasttrackEndpoint = this._getConfigValueByExists(pipelineConfig, {
valueType: 'string',
defaultValue: '',
value: pipelineConfig?.endpoint,
value: pipelineConfig?.frontendEndpoint,
} as ConfigValueObject) as string;

// Enable hide button flag
this.hideSideMenuFastTrackButton = this._getConfigValueByExists(
pipelineConfig,
{
valueType: 'boolean',
defaultValue: false,
value: pipelineConfig?.hideSideMenuButton,
} as ConfigValueObject,
) as boolean;
}

/**
Expand Down Expand Up @@ -1806,6 +1817,8 @@ export default class BackendAILogin extends BackendAIPage {
globalThis.backendaiclient._config.systemSSHImage = this.systemSSHImage;
globalThis.backendaiclient._config.fasttrackEndpoint =
this.fasttrackEndpoint;
globalThis.backendaiclient._config.hideSideMenuFastTrackButton =
this.hideSideMenuFastTrackButton;
globalThis.backendaiclient._config.hideAgents = this.hideAgents;
globalThis.backendaiclient._config.enable2FA = this.enable2FA;
globalThis.backendaiclient._config.force2FA = this.force2FA;
Expand Down
14 changes: 11 additions & 3 deletions src/components/backend-ai-webui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export default class BackendAIWebUI extends connect(store)(LitElement) {
@property({ type: Array }) groups = [];
@property({ type: Object }) plugins = Object();
@property({ type: String }) fasttrackEndpoint = '';
@property({ type: Boolean }) isHideSideMenuFastTrackButton = false;
@property({ type: String }) _page = '';
@property({ type: String }) _lazyPage = '';
@property({ type: Object }) _pageParams = {};
Expand Down Expand Up @@ -481,9 +482,15 @@ export default class BackendAIWebUI extends connect(store)(LitElement) {
}
if (
typeof config.pipeline !== 'undefined' &&
'endpoint' in config.pipeline
'frontendEndpoint' in config.pipeline
) {
this.fasttrackEndpoint = config.pipeline.endpoint;
this.fasttrackEndpoint = config.pipeline.frontendEndpoint;
}
if (
typeof config.pipeline !== 'undefined' &&
'hideSideMenuButton' in config.pipeline
) {
this.isHideSideMenuFastTrackButton = config.pipeline.hideSideMenuButton;
}
if (typeof config.plugin !== 'undefined') {
// Store plugin informations
Expand Down Expand Up @@ -1236,7 +1243,7 @@ export default class BackendAIWebUI extends connect(store)(LitElement) {
_text('webui.menu.AgentSummary'),
);
}
if (this.fasttrackEndpoint !== '') {
if (!this.isHideSideMenuFastTrackButton && this.fasttrackEndpoint !== '') {
this._createPopover('fasttrack-menu-icon', _text('webui.menu.FastTrack'));
}
}
Expand Down Expand Up @@ -1530,6 +1537,7 @@ export default class BackendAIWebUI extends connect(store)(LitElement) {
<span class="full-menu">${_t('webui.menu.Statistics')}</span>
</mwc-list-item>
${
!this.isHideSideMenuFastTrackButton &&
this.fasttrackEndpoint !== ''
? html`
<a href="${this.fasttrackEndpoint}" target="_blank">
Expand Down

0 comments on commit 51078d8

Please sign in to comment.