Skip to content

Commit 70989b0

Browse files
committed
feat(lesy-pilot-ui): add workspace screen
1 parent 4b75655 commit 70989b0

22 files changed

+248
-30
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { AddLog, ReverseLogs } from "../../store/actions/logs.actions";
99
templateUrl: "./console.template.html",
1010
})
1111
export class ConsoleComponent implements OnInit {
12-
@Select(state => state.logs.logs)
13-
logs$: Observable<string[]>;
12+
@Select((state) => state.logs.logs)
13+
logs$: Observable<Array<Array<string | number>>>;
1414

1515
constructor(private store: Store, private actions$: Actions) {}
1616

@@ -31,4 +31,8 @@ export class ConsoleComponent implements OnInit {
3131
});
3232
});
3333
}
34+
35+
formatTime(ts: number) {
36+
return new Date(ts).toLocaleTimeString();
37+
}
3438
}

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,18 @@
2222
<p class="text-center text-sm">Console panel</p>
2323
</div>
2424
</div>
25-
<div class="pt-6 h-auto text-green-200 font-mono " id="console">
26-
<pre class="bg-console-bg p-4 h-auto text-white" #consoleEl>
27-
<span *ngFor="let log of (logs$|async)" [innerHTML]="log|safeHtml"></span>
28-
</pre>
25+
<div class="pt-6 h-auto text-green-200 font-mono" id="console">
26+
<div class="bg-console-bg p-4 h-auto text-white" #consoleEl>
27+
<ng-container *ngFor="let log of (logs$|async)">
28+
<div class="flex">
29+
<div
30+
class="w-24 mr-2 opacity-50"
31+
[innerHTML]="formatTime(log[0])"
32+
></div>
33+
<pre [innerHTML]="log[1]|safeHtml"></pre>
34+
</div>
35+
</ng-container>
36+
</div>
2937
</div>
3038
</div>
3139
</div>

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { Component } from "@angular/core";
22
import { Store, Select } from "@ngxs/store";
3-
import { ToggleConsolePanel } from "../../store/actions/common.actions";
3+
import {
4+
ToggleConsolePanel,
5+
SetConsolePanelFullScreen,
6+
} from "../../store/actions/common.actions";
47
import { Observable } from "rxjs";
58
import { ClearLogs, ReverseLogs } from "../../store/actions/logs.actions";
69
import { Hotkeys } from "../../services/hotkeys.service";
@@ -13,14 +16,23 @@ export class FooterComponent {
1316
@Select((state) => state.command)
1417
selectedCommand$: Observable<object>;
1518

16-
@Select((state) => (state.common.consoleHeight === 0 ? "CLOSED" : "OPEN"))
17-
consoleStatus$: Observable<"CLOSED" | "OPEN">;
19+
@Select((state) => {
20+
const height = state.common.consoleHeight;
21+
if (height === 0) return "CLOSED";
22+
if (height === 100) return "FULLSCREEN";
23+
return "OPEN";
24+
})
25+
consoleStatus$: Observable<"CLOSED" | "OPEN" | "FULLSCREEN">;
1826

1927
constructor(private store: Store, private hotkeys: Hotkeys) {}
2028

2129
toggleConsole() {
2230
this.store.dispatch(new ToggleConsolePanel());
2331
}
32+
33+
setConsoleFullScreen() {
34+
this.store.dispatch(new SetConsolePanelFullScreen());
35+
}
2436
clearLogs() {
2537
this.store.dispatch(new ClearLogs());
2638
}

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55
<ng-container *ngIf="consoleStatus$|async as consoleStatus">
66
<li
77
(click)="toggleConsole()"
8-
class="flex items-center p-3 cursor-pointer text-gray-600 hover:text-vio-500"
9-
[class.hidden]="consoleStatus=='OPEN'"
10-
tooltip="open console"
8+
class="flex items-center p-3 cursor-pointer text-gray-600 hover:text-vio-500"
9+
[class.hidden]="consoleStatus=='OPEN' || consoleStatus=='FULLSCREEN'"
10+
tooltip="show console"
1111
>
1212
<i class="ri-eye-line leading-none text-xl"></i>
1313
</li>
1414
<li
1515
(click)="toggleConsole()"
1616
class="flex items-center p-3 cursor-pointer text-gray-600 hover:text-vio-500"
1717
[class.hidden]="consoleStatus=='CLOSED'"
18-
tooltip="close console"
18+
tooltip="hide console"
1919
>
20-
<i class="ri-eye-off-line leading-none text-xl "></i>
20+
<i class="ri-eye-off-line leading-none text-xl"></i>
2121
</li>
2222
<li
2323
(click)="clearLogs()"
@@ -36,6 +36,14 @@
3636
>
3737
<i class="ri-exchange-box-line rotate-90 leading-none text-xl"></i>
3838
</li>
39+
<li
40+
(click)="setConsoleFullScreen()"
41+
tooltip="Full screen"
42+
class="flex items-center p-3 cursor-pointer text-gray-600 hover:text-vio-500"
43+
[class.hidden]="consoleStatus=='CLOSED' || consoleStatus=='FULLSCREEN'"
44+
>
45+
<i class="ri-fullscreen-fill leading-none text-xl"></i>
46+
</li>
3947
</ng-container>
4048
<li class="flex items-center ml-auto">
4149
<a
@@ -74,7 +82,7 @@
7482
>
7583
<span
7684
class="font-bold text-yellow-900 bg-yellow-500 text-xs rounded px-2 py-1 mr-2 uppercase"
77-
style="line-height: 14px"
85+
style="line-height: 14px;"
7886
>{{keys[0]}}{{keys[1]}}
7987
</span>
8088
<span class="text-gray-500 text-base"> {{keys[2]}}</span>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ import { Observable } from "rxjs";
88
})
99
export class HeaderComponent {
1010
menuItems = [];
11-
@Select(state => state.common.config)
11+
@Select((state) => state.common.config)
1212
webConfig$: Observable<object>;
1313

1414
ngOnInit() {
1515
this.menuItems = [
1616
{ name: "Home", path: "/", icon: "ri-home-4-line" },
17+
{ name: "Projects", path: "/projects", icon: "ri-folder-line" },
1718
{ name: "Run", path: "/run", icon: "ri-terminal-line" },
1819
{ name: "Config", path: "/config", icon: "ri-settings-5-line" },
1920
{ name: "Help", path: "/help", icon: "ri-questionnaire-line" },

packages/misc/pilot-ui/src/app/modules/query/components/form/form.template.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@
55
id="pilotForm"
66
>
77
<div
8-
class=" bg-white rounded-xl border border-gray-400 mt-5 p-6 highlight:border-transparent highlight:mt-0"
8+
class="bg-white rounded-xl border border-gray-400 mt-5 p-6 highlight:border-transparent highlight:mt-0"
99
*ngIf="questions.length > 0"
1010
>
11-
<h5
12-
class="mb-6 text-lg text-gray-800 font-display font-medium highlight:hidden"
13-
>
11+
<h5 class="mb-6 text-lg text-gray-800 font-medium highlight:hidden">
1412
Arguments
1513
</h5>
1614

@@ -27,7 +25,7 @@
2725

2826
<button
2927
type="submit"
30-
class="flex mx-auto bg-green-500 py-4 px-6 mt-6 rounded text-white font-semibold shadow-lg focus:shadow-none disabled:opacity-50 focus:outline-none highlight:mt-0"
28+
class="flex mx-auto bg-green-500 py-4 px-6 mt-6 rounded text-white font-semibold shadow-lg focus:shadow-none disabled:opacity-50 focus:outline-none highlight:mt-0"
3129
[disabled]="!form.valid"
3230
>
3331
<i class="ri-send-plane-2-line mr-2"></i> Run command

packages/misc/pilot-ui/src/app/modules/query/components/input/input.template.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
>
1010
<div [ngSwitch]="question.controlType">
1111
<div
12-
class="flex flex-wrap items-stretch w-full mb-4 relative focus-within:border-vio-500 border border-gray-500 rounded-sm bg-gray-100"
12+
class="flex flex-wrap items-stretch w-full mb-4 relative focus-within:border-vio-500 border border-gray-500 bg-gray-100 rounded-md"
1313
*ngSwitchCase="'textbox'"
1414
>
1515
<div class="flex">
1616
<span
17-
class="flex items-center leading-normal bg-gray-lighter rounded rounded-r-none px-2 whitespace-no-wrap text-grey-dark text-sm"
17+
class="flex items-center leading-normal bg-gray-lighter rounded rounded-r-none px-2 whitespace-no-wrap text-grey-dark text-sm"
1818
><i class="ri-keyboard-box-fill text-2xl text-gray-500"></i
1919
></span>
2020
</div>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { Component, OnInit } from "@angular/core";
2+
import { CommandsService } from "../../services/commands.service";
3+
import { map } from "rxjs/operators";
4+
import { Observable, combineLatest } from "rxjs";
5+
import { ActivatedRoute } from "@angular/router";
6+
import { Select, Store } from "@ngxs/store";
7+
import { ProjectsService } from "../../services/projects.service";
8+
import { LoadProjects } from "../../store/actions/projects.actions";
9+
import { SelectedProject } from "../../store/actions/project.actions";
10+
import { LoadConfig } from "../../store/actions/common.actions";
11+
12+
@Component({
13+
selector: "pilot-projects-page",
14+
templateUrl: "./projects.template.html",
15+
})
16+
export class ProjectsPage implements OnInit {
17+
config: object;
18+
projects: any[];
19+
selectedProject;
20+
21+
@Select((state) => state.projects)
22+
projects$: Observable<string[]>;
23+
24+
@Select((state) => state.common.config)
25+
config$: Observable<object>;
26+
27+
constructor(
28+
private store: Store,
29+
private route: ActivatedRoute,
30+
private ps: ProjectsService,
31+
) {
32+
this.store.dispatch(new LoadProjects());
33+
}
34+
35+
ngOnInit() {}
36+
switchProject(name) {
37+
this.store.dispatch(new SelectedProject(name));
38+
this.store.dispatch(new LoadConfig());
39+
}
40+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<div class="w-full sm:w-2/3 mx-auto px-6 sm:px-0">
2+
<div
3+
*ngFor="let project of (projects$|async)"
4+
class="p-3"
5+
(click)="switchProject(project)"
6+
>
7+
{{project.name}}
8+
</div>
9+
</div>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { ToppyControl, Toppy, GlobalPosition, InsidePlacement } from "toppy";
1818
import { NotificationModel } from "./pilot.models";
1919
import { ToastComponent } from "./components";
2020
import { Hotkeys } from "./services/hotkeys.service";
21+
import { FetchDefaultProject } from "./store/actions/project.actions";
2122

2223
const HOTKEY = "`";
2324

@@ -48,6 +49,7 @@ export class PilotMain implements OnInit {
4849
this.store.dispatch(new LoadLogs());
4950
this.store.dispatch(new LoadConfig());
5051
this.store.dispatch(new ListenForNotification());
52+
this.store.dispatch(new FetchDefaultProject());
5153

5254
this.notification$.subscribe((n) => {
5355
if (!n.message) {

0 commit comments

Comments
 (0)