Skip to content

Commit d68a8da

Browse files
authored
Merge pull request #1411 from jumpserver/dev
merge: v4.10.4-lts
2 parents 04e3695 + 04c1d51 commit d68a8da

78 files changed

Lines changed: 2098 additions & 3559 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/release-drafter.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ jobs:
4242
run: |
4343
mkdir -p build
4444
rm -rf build/*
45-
cp -R src/assets/i18n luna/
46-
mv luna luna-${{ steps.get_version.outputs.TAG }}
45+
cp -R src/assets/i18n dist/luna/
46+
mv dist/luna luna-${{ steps.get_version.outputs.TAG }}
4747
tar -czf luna-${{ steps.get_version.outputs.TAG }}.tar.gz luna-${{ steps.get_version.outputs.TAG }}
4848
echo $(md5sum luna-${{ steps.get_version.outputs.TAG }}.tar.gz | awk '{print $1}') > build/luna-${{ steps.get_version.outputs.TAG }}.tar.gz.md5
4949
mv luna-${{ steps.get_version.outputs.TAG }}.tar.gz build/
@@ -57,5 +57,3 @@ jobs:
5757
build/luna-${{ steps.get_version.outputs.TAG }}.tar.gz.md5
5858
env:
5959
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60-
61-

angular.json

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,19 @@
4949
"scripts": [
5050
"jquery/dist/jquery.min.js",
5151
"@ztree/ztree_v3/js/jquery.ztree.all.min.js",
52-
"@ztree/ztree_v3/js/jquery.ztree.exhide.min.js",
53-
"asciinema-player/dist/bundle/asciinema-player.min.js"
52+
"@ztree/ztree_v3/js/jquery.ztree.exhide.min.js"
5453
]
5554
},
5655
"configurations": {
5756
"production": {
58-
"optimization": true,
57+
"optimization": {
58+
"scripts": true,
59+
"styles": {
60+
"minify": true,
61+
"inlineCritical": false
62+
},
63+
"fonts": true
64+
},
5965
"outputHashing": "all",
6066
"baseHref": "/luna/",
6167
"outputPath": {
@@ -68,8 +74,13 @@
6874
"budgets": [
6975
{
7076
"type": "initial",
71-
"maximumWarning": "5mb",
77+
"maximumWarning": "4mb",
7278
"maximumError": "6mb"
79+
},
80+
{
81+
"type": "anyComponentStyle",
82+
"maximumWarning": "200kb",
83+
"maximumError": "300kb"
7384
}
7485
],
7586
"fileReplacements": [

src/app/app.module.ts

Lines changed: 36 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,47 @@
1-
import {BrowserModule} from '@angular/platform-browser';
2-
import {NgModule} from '@angular/core';
3-
import {HttpClient, provideHttpClient} from '@angular/common/http';
4-
import {APP_BASE_HREF, CommonModule} from '@angular/common';
5-
import {FormsModule, ReactiveFormsModule} from '@angular/forms'; // <-- NgModel lives here
6-
import {NGXLogger} from 'ngx-logger';
7-
import {CookieService} from 'ngx-cookie-service';
8-
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
9-
import {TranslateLoader, TranslateModule} from '@ngx-translate/core';
10-
import {DragDropModule} from '@angular/cdk/drag-drop';
11-
import {CodeEditorModule} from '@acrodata/code-editor';
1+
import { BrowserModule } from '@angular/platform-browser';
2+
import { NgModule } from '@angular/core';
3+
import { HttpClient, provideHttpClient } from '@angular/common/http';
4+
import { APP_BASE_HREF, CommonModule } from '@angular/common';
5+
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; // <-- NgModel lives here
6+
import { NGXLogger } from 'ngx-logger';
7+
import { CookieService } from 'ngx-cookie-service';
8+
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
9+
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
10+
import { DragDropModule } from '@angular/cdk/drag-drop';
11+
import { CodeEditorModule } from '@acrodata/code-editor';
1212

1313
// service
14-
import {AllServices} from '@app/services';
14+
import { AllServices } from '@app/services';
1515

1616
// Angular split
17-
import {AppRouterModule} from './router.module';
18-
import {SharedPipeModule} from './pipes/pipes';
19-
import {AppComponent} from './pages/app.component';
20-
import {ElementComponents} from './elements/elements.component';
21-
import {PluginModules} from './plugins/plugins';
22-
import {ClipboardService} from 'ngx-clipboard';
23-
import {version} from '../environments/environment';
24-
import {BehaviorSubject, forkJoin, Observable, of} from 'rxjs';
25-
import {FileInputAccessorModule} from 'file-input-accessor';
26-
import {catchError, mergeMap} from 'rxjs/operators';
27-
import {PagesComponents} from './pages/pages.component';
28-
17+
import { AppRouterModule } from './router.module';
18+
import { SharedPipeModule } from './pipes/pipes';
19+
import { AppComponent } from './pages/app.component';
20+
import { ElementComponents } from './elements/elements.component';
21+
import { PluginModules } from './plugins/plugins';
22+
import { ClipboardService } from 'ngx-clipboard';
23+
import { environment, version } from '../environments/environment';
24+
import { BehaviorSubject, forkJoin, Observable, of } from 'rxjs';
25+
import { FileInputAccessorModule } from 'file-input-accessor';
26+
import { catchError, mergeMap } from 'rxjs/operators';
27+
import { PagesComponents } from './pages/pages.component';
2928

3029
export class CustomLoader implements TranslateLoader {
31-
32-
constructor(private http: HttpClient) {
33-
}
30+
constructor(private http: HttpClient) {}
3431

3532
public getTranslation(lang: String): Observable<any> {
3633
const remote = '/api/v1/settings/i18n/luna/?lang=' + lang + '&v=' + version;
37-
const local = '/luna/assets/i18n/' + lang + '.json';
34+
let local = '/assets/i18n/' + lang + '.json';
35+
const isProd = environment.production;
36+
if (isProd) {
37+
local = '/luna' + local;
38+
}
3839

3940
return forkJoin([
40-
this.http.get(remote).pipe(
41-
catchError(() => of({}))
42-
),
43-
this.http.get(local).pipe(
44-
catchError(() => of({}))
45-
)
41+
this.http.get(remote).pipe(catchError(() => of({}))),
42+
this.http.get(local).pipe(catchError(() => of({})))
4643
]).pipe(
47-
mergeMap((res) => {
44+
mergeMap(res => {
4845
const finalRes = Object.assign({}, res[1], res[0]);
4946
return new BehaviorSubject(finalRes);
5047
})
@@ -71,22 +68,17 @@ export class CustomLoader implements TranslateLoader {
7168
deps: [HttpClient]
7269
}
7370
}),
74-
...PluginModules,
71+
...PluginModules
7572
],
76-
declarations: [
77-
AppComponent,
78-
...ElementComponents,
79-
...PagesComponents
80-
] as any[],
73+
declarations: [AppComponent, ...ElementComponents, ...PagesComponents] as any[],
8174
bootstrap: [AppComponent],
8275
providers: [
8376
...AllServices,
84-
{provide: APP_BASE_HREF, useValue: '/luna/'},
77+
{ provide: APP_BASE_HREF, useValue: '/luna/' },
8578
CookieService,
8679
NGXLogger,
8780
ClipboardService,
8881
provideHttpClient()
8982
]
9083
})
91-
export class AppModule {
92-
}
84+
export class AppModule {}

src/app/elements/asset-tree/asset-tree.component.scss

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
.tree-type-banner {
2424
position: relative;
2525
display: flex;
26-
height: 31px;
27-
line-height: 31px;
26+
height: 30px;
27+
line-height: 30px;
2828
padding-right: 11px;
2929
padding-left: 15px;
3030
overflow: hidden;
@@ -42,15 +42,15 @@
4242
.tree-icon-rotate {
4343
@include flex(center);
4444
height: 30px;
45-
padding-top: 3px;
46-
padding-right: 3px;
45+
// padding-top: 3px;
46+
// padding-right: 3px;
4747
font-size: 16px;
4848
color: var(--el-text-color-light);
4949
}
5050

5151
.tree-type-banner-label {
5252
margin-left: 7px;
53-
padding-top: 2px;
53+
// padding-top: 2px;
5454
font-size: 13px;
5555
cursor: pointer;
5656
@include overflowText;
@@ -69,16 +69,16 @@
6969
// 刷新按钮不需要 padding-right
7070
.fa-refresh.tree-banner-icon {
7171
padding-right: 0;
72-
margin-top: 2px;
72+
// margin-top: 2px;
7373
}
7474

7575
// 批量操作按钮需要给一些 padding-top 使得看上去垂直居中
7676
.fa-square-o.tree-banner-icon {
77-
padding-top: 2px;
77+
// padding-top: 2px;
7878
}
7979

8080
.fa-check-square.tree-banner-icon {
81-
padding-top: 2px;
81+
// padding-top: 2px;
8282
}
8383

8484
.tree-banner-icon {
@@ -143,9 +143,14 @@
143143
position: relative;
144144
padding: 5px 10px;
145145
min-height: 40px;
146-
overflow-x: auto;
147146
height: calc(100% - 31px);
148147
background-color: var(--el-asset-tree-bg-color);
148+
overflow: hidden;
149+
scrollbar-gutter: stable both-edges;
150+
151+
&:hover {
152+
overflow: auto;
153+
}
149154

150155
.tree-type-loading {
151156
position: absolute;

src/app/elements/asset-tree/asset-tree.component.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ export class ElementAssetTreeComponent implements OnInit {
118118
const treeChecked = tree.setting && tree.setting.check && tree.setting.check.enable;
119119
const viewList = this._viewSrv.viewList;
120120

121+
const isK8s = cnode.meta.data.platform_type === 'k8s';
122+
121123
return [
122124
{
123125
id: 'batch-connect',
@@ -130,7 +132,7 @@ export class ElementAssetTreeComponent implements OnInit {
130132
id: 'connect',
131133
name: 'Connect',
132134
fa: 'fa-terminal',
133-
hide: cnode.isParent,
135+
hide: cnode.isParent || isK8s,
134136
click: this.onMenuConnect.bind(this)
135137
},
136138
{
@@ -144,7 +146,7 @@ export class ElementAssetTreeComponent implements OnInit {
144146
id: 'split-connect',
145147
name: 'Split connect',
146148
fa: 'fa-columns',
147-
hide: viewList.length <= 0 || cnode.isParent,
149+
hide: viewList.length <= 0 || cnode.isParent || isK8s,
148150
click: this.onMenuConnect.bind(this, true)
149151
},
150152
{
@@ -221,21 +223,27 @@ export class ElementAssetTreeComponent implements OnInit {
221223
}
222224

223225
handleMenuClick(menu: any) {
224-
console.log('menu', menu);
225226
menu.click();
226227
this.hideRMenu();
227228
}
228229

229230
onNodeClick(event, treeId, treeNode, clickFlag) {
230231
const ztree = this.trees.find(t => t.name === treeId).ztree;
232+
231233
if (treeNode.isParent) {
232234
ztree.expandNode(treeNode);
233235
return;
234236
}
237+
235238
if (treeNode.chkDisabled) {
236239
this._message.warning(this._i18n.instant('DisabledAsset'));
237240
return;
238241
}
242+
243+
if (treeNode.meta.data.platform_type === 'k8s') {
244+
return connectOnNewPage(treeNode, 'auto');
245+
}
246+
239247
if (this.isOpenNewWindow) {
240248
connectOnNewPage(treeNode, 'auto');
241249
} else {
@@ -574,13 +582,13 @@ export class ElementAssetTreeComponent implements OnInit {
574582
const i = this.favoriteAssets.indexOf(assetId);
575583
this.favoriteAssets.splice(i, 1);
576584
const msg = this._i18n.instant('Disfavor') + ' ' + this._i18n.instant('success');
577-
this._toastr.success(msg, '');
585+
this._toastr.success(msg, '', { nzClass: 'custom-success-notification' });
578586
});
579587
} else {
580588
this._http.favoriteAsset(assetId, true).subscribe(() => {
581589
this.favoriteAssets.push(assetId);
582590
const msg = this._i18n.instant('Favorite') + ' ' + this._i18n.instant('success');
583-
this._toastr.success(msg, '');
591+
this._toastr.success(msg, '', { nzClass: 'custom-success-notification' });
584592
});
585593
}
586594
}

src/app/elements/chat/chat.component.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
</div>
2626
</div>
2727
</div>
28-
<elements-drawer [view]="currentView"></elements-drawer>
2928

3029
<!-- <div [hidden]="!showBtn || chatAIShown || !isShowSetting" id="dragBox"> -->
3130
<!-- <div -->

src/app/elements/chat/chat.component.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ nz-float-button {
99
position: fixed;
1010
bottom: 200px;
1111
right: 5px;
12-
z-index: 1000;
12+
z-index: 99999;
1313
cursor: move;
1414
user-select: none;
1515
overflow: visible;

src/app/elements/chat/chat.component.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ export class ElementChatComponent implements OnInit, OnDestroy, AfterViewInit {
5454

5555
get isShowSetting() {
5656
const connectMethods = ['koko', 'lion', 'tinker', 'panda'];
57+
58+
// sftp 或 k8s 不展示设置按钮
59+
if (this.currentView.protocol === 'sftp' || this.currentView.protocol === 'k8s') {
60+
return false;
61+
}
62+
5763
return (
5864
this.currentView.hasOwnProperty('connectMethod') &&
5965
this.currentView.connected &&
@@ -209,14 +215,7 @@ export class ElementChatComponent implements OnInit, OnDestroy, AfterViewInit {
209215

210216
handleShowDrawer() {
211217
if (this.currentView.iframeElement) {
212-
switch (this.currentView.connectMethod.component) {
213-
case 'koko':
214-
this._drawerStateService.sendComponentMessage({ name: 'OPEN_SETTING' });
215-
break;
216-
default:
217-
this.currentView.iframeElement.postMessage({ name: 'OPEN' }, '*');
218-
break;
219-
}
218+
this.currentView.iframeElement.postMessage({ name: 'OPEN' }, '*');
220219
}
221220
}
222221

0 commit comments

Comments
 (0)