Skip to content

Commit 8be7b36

Browse files
committed
feat(lesy-pilot-ui): support to change console position
1 parent a0fe70d commit 8be7b36

File tree

10 files changed

+59
-10
lines changed

10 files changed

+59
-10
lines changed

packages/misc/pilot-ui/package-lock.json

Lines changed: 15 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/misc/pilot-ui/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"@angular/platform-browser-dynamic": "~10.0.11",
2323
"@angular/router": "~10.0.11",
2424
"@ngxs/devtools-plugin": "^3.6.2",
25+
"@ngxs/storage-plugin": "^3.7.0",
2526
"@ngxs/store": "^3.6.2",
2627
"angular-split": "^4.0.0",
2728
"autoprefixer": "^9.8.6",

packages/misc/pilot-ui/src/app/components/footer/footer.component.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Store, Select } from "@ngxs/store";
33
import {
44
ToggleConsolePanel,
55
SetConsolePanelFullScreen,
6+
ToggleConsolePosition,
67
} from "../../store/actions/common.actions";
78
import { Observable } from "rxjs";
89
import { ClearLogs, ReverseLogs } from "../../store/actions/logs.actions";
@@ -24,6 +25,13 @@ export class FooterComponent {
2425
})
2526
consoleStatus$: Observable<"CLOSED" | "OPEN" | "FULLSCREEN">;
2627

28+
@Select((state) => {
29+
const position = state.common.consolePosition;
30+
if (position === "vertical") return "ri-layout-bottom-line";
31+
else return "ri-layout-right-line";
32+
})
33+
consolePositionClassName$: Observable<any>;
34+
2735
constructor(private store: Store, private hotkeys: Hotkeys) {}
2836

2937
toggleConsole() {
@@ -33,6 +41,11 @@ export class FooterComponent {
3341
setConsoleFullScreen() {
3442
this.store.dispatch(new SetConsolePanelFullScreen());
3543
}
44+
45+
toggleConsolePosition() {
46+
this.store.dispatch(new ToggleConsolePosition());
47+
}
48+
3649
clearLogs() {
3750
this.store.dispatch(new ClearLogs());
3851
}

packages/misc/pilot-ui/src/app/components/footer/footer.template.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@
4444
>
4545
<i class="ri-fullscreen-fill leading-none text-xl"></i>
4646
</li>
47+
<li
48+
*ngIf="consolePositionClassName$ | async as consolePosClassName"
49+
(click)="toggleConsolePosition()"
50+
tooltip="Toggle position"
51+
class="flex items-center p-3 cursor-pointer text-gray-600 hover:text-vio-500"
52+
>
53+
<i class="{{consolePosClassName}} leading-none text-xl"></i>
54+
</li>
4755
</ng-container>
4856
<li class="flex items-center ml-auto">
4957
<a

packages/misc/pilot-ui/src/app/pilot.main.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ export class PilotMain implements OnInit {
3333
@Select(CommonState.consolePanelsHeight())
3434
panelHeights$: Observable<number[]>;
3535

36+
@Select((state) => state.common.consolePosition)
37+
consolePosition$: Observable<string>;
38+
3639
@Select((state) => state.notification)
3740
notification$: Observable<NotificationModel>;
3841

packages/misc/pilot-ui/src/app/pilot.models.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export interface NotificationModel {
4444

4545
export interface CommonModel {
4646
consoleHeight: number;
47+
consolePosition: "vertical" | "horizontal";
4748
config: { [key: string]: any };
4849
}
4950

packages/misc/pilot-ui/src/app/pilot.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { BrowserModule } from "@angular/platform-browser";
33
import { ToppyModule } from "toppy";
44
import { NgxsModule } from "@ngxs/store";
55
import { NgxsReduxDevtoolsPluginModule } from "@ngxs/devtools-plugin";
6+
import { NgxsStoragePluginModule } from "@ngxs/storage-plugin";
67
import { AngularSplitModule } from "angular-split";
78

89
/* Components */
@@ -93,6 +94,7 @@ import { environment } from "../environments/environment.prod";
9394
NgxsReduxDevtoolsPluginModule.forRoot({
9495
disabled: !environment.production,
9596
}),
97+
NgxsStoragePluginModule.forRoot(),
9698
AngularSplitModule.forRoot(),
9799
],
98100
bootstrap: [PilotMain],

packages/misc/pilot-ui/src/app/pilot.template.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<div style="height: 100vh;padding-bottom:42px">
1+
<div style="height: 100vh; padding-bottom: 42px;">
22
<as-split
3-
direction="vertical"
3+
[direction]="consolePosition$ | async"
44
*ngIf="panelHeights$ | async as heights"
55
(dragEnd)="onDragEnd($event)"
66
>

packages/misc/pilot-ui/src/app/store/actions/common.actions.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ export class SetConsolePanelFullScreen {
77
static readonly type = "[Console Panel] full screen";
88
}
99

10+
export class ToggleConsolePosition {
11+
static readonly type = "[Console Panel] toggle position";
12+
}
13+
1014
export class ToggleConsolePanel {
1115
static readonly type = "[Console Panel] toggle panel";
1216
}

packages/misc/pilot-ui/src/app/store/states/common.state.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
SetConfig,
1010
LoadConfig,
1111
SetConsolePanelFullScreen,
12+
ToggleConsolePosition,
1213
} from "../actions/common.actions";
1314
import { CommonService } from "../../services/common.service";
1415
import { mergeMap } from "rxjs/operators";
@@ -17,6 +18,7 @@ import { mergeMap } from "rxjs/operators";
1718
name: "common",
1819
defaults: {
1920
consoleHeight: 0,
21+
consolePosition: "vertical",
2022
config: {},
2123
},
2224
})
@@ -53,6 +55,14 @@ export class CommonState {
5355
ctx.setState({ ...state, consoleHeight });
5456
}
5557

58+
@Action(ToggleConsolePosition)
59+
toggleConsolePosition(ctx: StateContext<CommonModel>) {
60+
const state = ctx.getState();
61+
const consolePosition =
62+
state.consolePosition === "vertical" ? "horizontal" : "vertical";
63+
ctx.setState({ ...state, consolePosition });
64+
}
65+
5666
@Action(LoadConfig)
5767
loadConfig(ctx: StateContext<CommonModel>) {
5868
this.commonService.requestConfig();

0 commit comments

Comments
 (0)