Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/app/elements/asset-tree/asset-tree.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export class ElementAssetTreeComponent implements OnInit {
}

if (treeNode.meta.data.platform_type === 'k8s') {
return connectOnNewPage(treeNode, 'auto');
return connectOnNewPage(treeNode, 'new');
}

if (this.isOpenNewWindow) {
Expand Down Expand Up @@ -465,6 +465,7 @@ export class ElementAssetTreeComponent implements OnInit {
}

async connectAsset(node: TreeNode) {
await this._appSvc.getConnectMethods();
const action = 'asset';
const evt = new ConnectEvt(node, action);
connectEvt.next(evt);
Expand Down Expand Up @@ -565,6 +566,7 @@ export class ElementAssetTreeComponent implements OnInit {
return;
}
const node = this.rightClickSelectNode;
await this._appSvc.getConnectMethods();
const action = 'connect';
const evt = splitConnect ? new ConnectEvt(node, action, true) : new ConnectEvt(node, action);
connectEvt.next(evt);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { User } from '@app/globals';
import { FormControl } from '@angular/forms';
import { AppService, I18nService } from '@app/services';
import { AppService, I18nService, SettingService } from '@app/services';
import { BehaviorSubject, ReplaySubject, Subject } from 'rxjs';
import { Account, AccountGroup, Asset, AuthInfo, Protocol } from '@app/model';

Expand Down Expand Up @@ -36,7 +36,7 @@ export class ElementSelectAccountComponent implements OnInit, OnDestroy {
@ViewChild('password', { static: false }) passwordRef: ElementRef;

public hidePassword = true;
public rememberAuthDisabled = false;
public rememberAuthDisabled = null;
usernameControl = new FormControl();
localAuthItems: AuthInfo[];
filteredOptions: AuthInfo[];
Expand All @@ -51,11 +51,13 @@ export class ElementSelectAccountComponent implements OnInit, OnDestroy {
private userManuallySelected = false; // 标记用户是否手动选择了账号

constructor(
private _settingSvc: SettingService,
private _appSvc: AppService,
private _i18n: I18nService,
private _cdRef: ChangeDetectorRef
) {
this.usernamePlaceholder = this._i18n.instant('Username');
this.rememberAuthDisabled = !this._settingSvc.globalSetting.SECURITY_LUNA_REMEMBER_AUTH;
}

get noSecretAccounts() {
Expand Down
5 changes: 5 additions & 0 deletions src/app/elements/connect/connect.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,20 @@ export class ElementConnectComponent implements OnInit, OnDestroy {

async callLocalClient(connToken: ConnectionToken) {
this._logger.debug('Call local client');

if (connToken.connect_options.token_reusable) {
await this._connectTokenSvc.setReusable(connToken, true).toPromise();
}

const response = await firstValueFrom(
this._http.getLocalClientUrl(connToken, this._settingSvc.setting)
);

const url = response['url'];

launchLocalApp(url, () => {
const downLoadStatus = localStorage.getItem('hasDownLoadApp');

if (downLoadStatus !== '1') {
this._dialog.create({
nzTitle: this._i18n.instant('DownloadClient'),
Expand Down
6 changes: 2 additions & 4 deletions src/app/elements/replay/asciicast/asciicast.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ export class ElementReplayAsciicastComponent implements OnInit, AfterViewInit {
/**
* 重置播放器并保持当前播放位置和状态
*/
private resetPlayerWithCurrentTime() {
private async resetPlayerWithCurrentTime() {
if (!this.player) return;

this.currentTime = this.player.getCurrentTime();
this.currentTime = await this.player.getCurrentTime();

if (isNaN(this.currentTime) || this.currentTime < 0) {
this.currentTime = 0;
Expand Down Expand Up @@ -204,8 +204,6 @@ export class ElementReplayAsciicastComponent implements OnInit, AfterViewInit {
speed: this.speed,
preload: true,
autoPlay: this.isPlaying ? 1 : 0,
rows: this.rows,
cols: 100,
fit: false,
terminalFontSize: '12px'
};
Expand Down
75 changes: 40 additions & 35 deletions src/app/elements/replay/mp4/mp4.component.html
Original file line number Diff line number Diff line change
@@ -1,53 +1,58 @@
<div class="replay-container">
<!-- 信息头部 -->
<div class="info-header">
<div class="info-item" *ngIf="replay.user">
<span class="label">{{ "user" | translate }}:</span>
<span class="value">{{ replay.user }}</span>
</div>
<div class="info-item" *ngIf="replay.asset">
<span class="label">{{ "asset" | translate }}:</span>
<span class="value">{{ replay.asset }}</span>
</div>
<div class="info-item" *ngIf="replay.system_user">
<span class="label">{{ "system user" | translate }}:</span>
<span class="value">{{ replay.system_user }}</span>
</div>
<div class="info-item" *ngIf="replay.date_start">
<span class="label">{{ "start time" | translate }}:</span>
<span class="value">{{ startTime }}</span>
</div>
<div class="info-actions">
<a *ngIf="replay.download_url" [href]="replay.download_url" class="download-link">
{{ "download" | translate }}
</a>
@if (!type) {
<div class="info-header">
<div class="info-item" *ngIf="replay.user">
<span class="label">{{ 'user' | translate }}:</span>
<span class="value">{{ replay.user }}</span>
</div>
<div class="info-item" *ngIf="replay.asset">
<span class="label">{{ 'asset' | translate }}:</span>
<span class="value">{{ replay.asset }}</span>
</div>
<div class="info-item" *ngIf="replay.system_user">
<span class="label">{{ 'system user' | translate }}:</span>
<span class="value">{{ replay.system_user }}</span>
</div>
<div class="info-item" *ngIf="replay.date_start">
<span class="label">{{ 'start time' | translate }}:</span>
<span class="value">{{ startTime }}</span>
</div>
<div class="info-actions">
<a *ngIf="replay.download_url" [href]="replay.download_url" class="download-link">
{{ 'download' | translate }}
</a>
</div>
</div>
</div>
}

<!-- 主体内容 -->
<div class="main-content">
<!-- 视频播放区 -->
<div class="video-area">
<video controls>
<source [src]="replay.src" type="video/mp4">
<source [src]="replay.src" type="video/mp4" />
</video>
</div>

<!-- 命令列表 -->
<div class="commands-area" *ngIf="commands.length > 0">
<div class="commands-header">
<span>{{ "Commands" | translate }} ({{ commands.length }})</span>
<span>{{ 'Commands' | translate }} ({{ commands.length }})</span>
</div>
<div class="commands-list"
infiniteScroll
[infiniteScrollDistance]="2"
[infiniteScrollThrottle]="50"
(scrolled)="onScroll()"
[scrollWindow]="false">
<div class="command-item"
*ngFor="let item of commands"
(click)="commandClick(item)"
[title]="item.input">
<div
class="commands-list"
infiniteScroll
[infiniteScrollDistance]="2"
[infiniteScrollThrottle]="50"
(scrolled)="onScroll()"
[scrollWindow]="false"
>
<div
class="command-item"
*ngFor="let item of commands"
(click)="commandClick(item)"
[title]="item.input"
>
<div class="command-text">{{ item.input }}</div>
<div class="command-time">{{ item.atime }}</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/app/elements/replay/mp4/mp4.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ video {
// 主内容区
.main-content {
display: flex;
flex: 1;
// flex: 1;
min-height: 0;

// 视频区域
Expand All @@ -217,8 +217,8 @@ video {
justify-content: center;

video {
width: 100%;
height: 100%;
// width: 100%;
// height: 100%;
max-width: 100%;
max-height: 100%;
object-fit: contain;
Expand Down
7 changes: 6 additions & 1 deletion src/app/elements/replay/mp4/mp4.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Component, Input, OnInit} from '@angular/core';
import {Component, Input, OnInit, Output,
EventEmitter} from '@angular/core';
import {Command, Replay} from '@app/model';
import {HttpService} from '@app/services';
import {TranslateService} from '@ngx-translate/core';
Expand All @@ -12,6 +13,9 @@ import {formatTime} from '@app/utils/common';
})
export class ElementsReplayMp4Component implements OnInit {
@Input() replay: Replay;
@Input() type: string | undefined;
@Output() ready = new EventEmitter<void>();

startTime = null;
startTimeStamp = null;
commands: Command[];
Expand All @@ -30,6 +34,7 @@ export class ElementsReplayMp4Component implements OnInit {
this.getCommands(this.page);
this.height = window.innerHeight - 100;
this.width = window.innerWidth - 100;
this.ready.emit();
}

toSafeLocalDateStr(d) {
Expand Down
9 changes: 7 additions & 2 deletions src/app/elements/replay/parts/parts.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
</div>
</div>

<!-- 主体内容 -->
<div class="main-content">
<!-- 视频播放区 -->
<div class="video-area" [class.playlist-hidden]="playlistCollapsed">
Expand All @@ -39,12 +38,18 @@
<i nz-icon nzType="menu" nzTheme="outline"></i>
{{ 'Playlist' | translate }}
</button>
<elements-replay-guacamole

@if(this.replayType === 'mp4') {
<elements-replay-mp4 *ngIf="currentVideo && currentVideo.src" (ready)="videoLoading = false"
[replay]="currentVideo" type="parts" class="video-player"></elements-replay-mp4>
} @else {
<elements-replay-guacamole
*ngIf="currentVideo && currentVideo.src"
[replay]="currentVideo"
(ready)="videoLoading = false"
class="video-player">
</elements-replay-guacamole>
}
</div>

<!-- 播放列表 -->
Expand Down
18 changes: 13 additions & 5 deletions src/app/services/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,19 @@ export class AppService {
return null;
}

getConnectMethods() {
getConnectMethods(): Promise<void> {
const url = '/api/v1/terminal/components/connect-methods/';
this._http.get(url).subscribe(response => {
this.protocolConnectTypesMap = response;
});

// 当用户先打开 luna 并进行操作时如果后在 lina 中去设置连接方式的 ACL 此时并不生效,因此修改为在 toPromise 后直接赋值
return this._http
.get(url)
.toPromise()
.then(response => {
this.protocolConnectTypesMap = response;
})
.catch(error => {
this._logger.error('Get connect methods error:', error);
});
}

getProtocolConnectMethods(protocol: string) {
Expand Down Expand Up @@ -338,7 +346,7 @@ export class AppService {
newAuth.alias = account.alias;
}

if (!auth.secret || !auth.rememberAuth) {
if (!auth.secret || !auth.rememberAuth || !this._settingSvc.globalSetting.SECURITY_LUNA_REMEMBER_AUTH) {
newAuth.secret = '';
} else {
newAuth.secret = this.encrypt(auth.secret);
Expand Down
10 changes: 10 additions & 0 deletions src/app/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,24 +341,34 @@ export function launchLocalApp(url, fail) {
export function connectOnNewPage(node: TreeNode, newWindowMode?: string) {
const url = `/luna/connect?login_to=${node.id}&type=${node.meta.type}`;
let params = 'toolbar=yes,scrollbars=yes,resizable=yes';

// auto 模式:尺寸为屏幕的三分之一并根据会话内的计数在屏幕上“级联/平铺”位置
if (newWindowMode === 'auto') {
let count: number;
let top = 50;

count = parseInt(window.sessionStorage.getItem('newWindowCount'), 10);

if (isNaN(count)) {
count = 0;
}

let left = 100 + count * 100;
top = 50 + count * 50;

if (left + screen.width / 3 > screen.width) {
// 支持两排足以
top = screen.height / 3;
count = 1;
left = 100;
}

params = params + `,top=${top},left=${left},width=${screen.width / 3},height=${screen.height / 3}`;
window.sessionStorage.setItem('newWindowCount', `${count + 1}`);

window.open(url, '_blank', params);

// auto 模式:尺寸为当前窗口的 innerWidth x innerHeight;位置固定在 top=50,left=100
} else if (newWindowMode === 'new') {
params = params + `,top=50,left=100,width=${window.innerWidth},height=${window.innerHeight}`;
window.open(url, '_blank', params);
Expand Down
Loading