Skip to content

Commit 37afb19

Browse files
Merge pull request #83 from sebastiankrll/enhance/search
Enhance/search
2 parents 1ede9c5 + d686e46 commit 37afb19

13 files changed

Lines changed: 444 additions & 194 deletions

File tree

apps/api/src/services/db.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ async function searchPilots(where: Prisma.PilotWhereInput) {
5555
select: {
5656
id: true,
5757
callsign: true,
58+
cid: true,
59+
name: true,
5860
flight_plan: true,
5961
aircraft: true,
6062
live: true,
@@ -75,6 +77,8 @@ async function searchPilots(where: Prisma.PilotWhereInput) {
7577
distinct: ["callsign"],
7678
select: {
7779
id: true,
80+
cid: true,
81+
name: true,
7882
callsign: true,
7983
flight_plan: true,
8084
aircraft: true,
@@ -94,8 +98,8 @@ export async function searchPilotsByAll(query: string) {
9498
const where: Prisma.PilotWhereInput = {
9599
OR: [
96100
{ callsign: { contains: query.toUpperCase() } },
97-
{ dep_icao: { contains: query.toUpperCase() } },
98-
{ arr_icao: { contains: query.toUpperCase() } },
101+
{ dep_icao: { startsWith: query.toUpperCase() } },
102+
{ arr_icao: { startsWith: query.toUpperCase() } },
99103
{ cid: { contains: query } },
100104
{ name: { contains: query, mode: "insensitive" } },
101105
],
@@ -105,7 +109,7 @@ export async function searchPilotsByAll(query: string) {
105109

106110
export async function searchPilotsByAirline(query: string) {
107111
const where: Prisma.PilotWhereInput = {
108-
callsign: { contains: query.toUpperCase() },
112+
callsign: { startsWith: query.toUpperCase() },
109113
};
110114
return await searchPilots(where);
111115
}
@@ -120,7 +124,7 @@ export async function searchPilotsByRoute(dep: string, arr: string) {
120124
export async function getFlightsByCallsign(callsign: string, limit?: string, cursor?: string) {
121125
return await prisma.pilot.findMany({
122126
where: {
123-
callsign,
127+
callsign: { startsWith: callsign.toUpperCase() },
124128
},
125129
orderBy: {
126130
sched_off_block: "desc",

apps/web/app/(map)/components/Panels/Dashboard/DashboardPanel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ import { fetchApi } from "@/utils/api";
1515
function storeOpenSections(sections: string[]) {
1616
if (typeof window === "undefined") return;
1717
try {
18-
localStorage.setItem("simradar21_dashboard", JSON.stringify(sections));
18+
localStorage.setItem("simradar21-dashboard", JSON.stringify(sections));
1919
} catch {}
2020
}
2121

2222
function getStoredOpenSections(): string[] {
2323
if (typeof window === "undefined") return [];
2424
try {
25-
const stored = localStorage.getItem("simradar21_dashboard");
25+
const stored = localStorage.getItem("simradar21-dashboard");
2626
if (!stored) return [];
2727
const parsed = JSON.parse(stored);
2828
if (Array.isArray(parsed) && parsed.every((s) => typeof s === "string")) {

apps/web/app/(map)/lib/controllerFeatures.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export async function initControllerFeatures(data: InitialData): Promise<void> {
7777
const controllerLabelFeatures: Feature<Point>[] = [];
7878
const airportLabelFeatures: Feature<Point>[] = [];
7979

80-
console.log(data)
80+
console.log(data);
8181

8282
await Promise.all(
8383
data.controllers.map(async (c) => {

apps/web/components/Header/Header.css

Lines changed: 0 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -98,132 +98,3 @@ header {
9898
#header-nav:hover use {
9999
color: var(--color-green);
100100
}
101-
102-
#header-search-wrapper {
103-
background-color: var(--color-bg);
104-
height: 2rem;
105-
display: flex;
106-
justify-content: center;
107-
align-items: center;
108-
padding: 0rem 10px;
109-
border: 1px solid var(--color-border);
110-
margin-left: auto;
111-
width: 18rem;
112-
position: relative;
113-
}
114-
115-
#header-search {
116-
border: none;
117-
height: 100%;
118-
box-sizing: border-box;
119-
background-color: transparent;
120-
color: var(--color-light-text);
121-
outline: none;
122-
width: 100%;
123-
font-size: var(--font-size-normal);
124-
transform: translateY(1px);
125-
}
126-
127-
#header-search::placeholder {
128-
color: var(--color-light-text);
129-
}
130-
131-
#header-search-results {
132-
position: absolute;
133-
top: 36px;
134-
max-height: 500px;
135-
overflow-y: auto;
136-
background-color: var(--color-bg);
137-
border: 1px solid var(--color-border);
138-
box-shadow: var(--box-shadow);
139-
z-index: 9999;
140-
width: 100%;
141-
}
142-
143-
#header-search-placeholder {
144-
display: flex;
145-
flex-flow: column;
146-
gap: 10px;
147-
padding: 4px;
148-
font-size: var(--font-size-normal);
149-
}
150-
151-
.header-search-separator {
152-
background-color: var(--color-dark-grey);
153-
padding: 4px;
154-
font-size: var(--font-size-small);
155-
line-height: var(--font-size-small);
156-
text-transform: uppercase;
157-
}
158-
159-
.search-item {
160-
display: flex;
161-
gap: 6px;
162-
padding: 4px;
163-
box-sizing: border-box;
164-
width: 100%;
165-
overflow: hidden;
166-
}
167-
168-
.search-item:hover {
169-
background-color: var(--color-hover);
170-
}
171-
172-
.search-icon {
173-
display: flex;
174-
align-items: center;
175-
justify-content: center;
176-
height: 40px;
177-
aspect-ratio: 1 / 1;
178-
background-color: var(--color-bg);
179-
border: 1px solid var(--color-border);
180-
box-sizing: border-box;
181-
}
182-
183-
.search-icon p,
184-
.search-icon span {
185-
font-weight: var(--font-weight-bold);
186-
font-size: 1.2rem;
187-
}
188-
189-
.search-info {
190-
display: flex;
191-
flex-direction: column;
192-
justify-content: space-between;
193-
align-items: start;
194-
padding: 2px 0;
195-
flex: 1 1 0%;
196-
overflow: hidden;
197-
}
198-
199-
.search-info.pilot {
200-
display: grid;
201-
grid-template-columns: 1fr auto;
202-
align-items: center;
203-
gap: 4px;
204-
}
205-
206-
.search-title {
207-
font-size: var(--font-size-normal);
208-
font-weight: var(--font-weight-bold);
209-
text-overflow: ellipsis;
210-
white-space: nowrap;
211-
overflow: hidden;
212-
max-width: 100%;
213-
text-align: left;
214-
}
215-
216-
.search-tags {
217-
display: flex;
218-
gap: 6px;
219-
font-size: var(--font-size-small);
220-
align-items: center;
221-
}
222-
223-
.search-tags span {
224-
color: white;
225-
}
226-
227-
.search-tags span.bg {
228-
padding: 0px 2px;
229-
}

apps/web/components/Header/Header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import Search from "./Search";
3+
import Search from "../Search/Search";
44
import "./Header.css";
55
import Image from "next/image";
66
import { useSession } from "next-auth/react";
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
#header-search-wrapper {
2+
background-color: var(--color-bg);
3+
height: 2rem;
4+
display: flex;
5+
justify-content: center;
6+
align-items: center;
7+
padding: 0rem 10px;
8+
border: 1px solid var(--color-border);
9+
margin-left: auto;
10+
width: 18rem;
11+
position: relative;
12+
gap: 10px;
13+
}
14+
15+
#header-search {
16+
border: none;
17+
height: 100%;
18+
box-sizing: border-box;
19+
background-color: transparent;
20+
color: var(--color-light-text);
21+
outline: none;
22+
width: 100%;
23+
font-size: var(--font-size-normal);
24+
transform: translateY(1px);
25+
}
26+
27+
#header-search::placeholder {
28+
color: var(--color-light-text);
29+
}
30+
31+
#header-search-clear {
32+
height: 16px;
33+
width: 16px;
34+
}
35+
36+
#header-search-clear:hover use {
37+
color: var(--color-red);
38+
}
39+
40+
#header-search-results {
41+
position: absolute;
42+
top: 36px;
43+
max-height: 500px;
44+
overflow-y: auto;
45+
background-color: var(--color-bg);
46+
border: 1px solid var(--color-border);
47+
box-shadow: var(--box-shadow);
48+
z-index: 9999;
49+
width: 100%;
50+
}
51+
52+
#header-search-placeholder {
53+
display: flex;
54+
flex-flow: column;
55+
gap: 10px;
56+
padding: 4px;
57+
font-size: var(--font-size-normal);
58+
}
59+
60+
.header-search-separator {
61+
background-color: var(--color-dark-grey);
62+
padding: 4px;
63+
text-transform: uppercase;
64+
display: flex;
65+
align-items: center;
66+
justify-content: space-between;
67+
font-size: var(--font-size-small);
68+
}
69+
70+
.search-history-item {
71+
display: flex;
72+
gap: 6px;
73+
padding: 4px;
74+
box-sizing: border-box;
75+
width: 100%;
76+
overflow: hidden;
77+
align-items: center;
78+
font-size: var(--font-size-normal);
79+
line-height: var(--font-size-normal);
80+
}
81+
82+
.search-item {
83+
display: grid;
84+
grid-template-columns: min-content auto;
85+
grid-template-rows: 1fr auto;
86+
gap: 0px 6px;
87+
padding: 4px;
88+
box-sizing: border-box;
89+
width: 100%;
90+
overflow: hidden;
91+
}
92+
93+
.search-item:hover,
94+
.search-history-item:hover {
95+
background-color: var(--color-hover);
96+
}
97+
98+
.search-extra {
99+
font-size: var(--font-size-small);
100+
grid-area: 2 / 1 / 3 / 3;
101+
display: flex;
102+
justify-content: start;
103+
align-items: center;
104+
gap: 4px;
105+
margin-top: 4px;
106+
}
107+
108+
.search-icon {
109+
display: flex;
110+
align-items: center;
111+
justify-content: center;
112+
height: 40px;
113+
aspect-ratio: 1 / 1;
114+
background-color: var(--color-bg);
115+
border: 1px solid var(--color-border);
116+
box-sizing: border-box;
117+
}
118+
119+
.search-icon p,
120+
.search-icon span {
121+
font-weight: var(--font-weight-bold);
122+
font-size: 1.2rem;
123+
}
124+
125+
.search-info {
126+
display: flex;
127+
flex-direction: column;
128+
justify-content: space-between;
129+
align-items: start;
130+
padding: 2px 0;
131+
flex: 1 1 0%;
132+
overflow: hidden;
133+
}
134+
135+
.search-info.pilot {
136+
display: grid;
137+
grid-template-columns: 1fr auto;
138+
align-items: center;
139+
gap: 4px;
140+
}
141+
142+
.search-title {
143+
font-size: var(--font-size-normal);
144+
text-overflow: ellipsis;
145+
white-space: nowrap;
146+
overflow: hidden;
147+
max-width: 100%;
148+
text-align: left;
149+
}
150+
151+
.search-tags {
152+
display: flex;
153+
gap: 6px;
154+
font-size: var(--font-size-small);
155+
align-items: center;
156+
}
157+
158+
.search-tags span {
159+
color: white;
160+
}
161+
162+
.search-tags span.bg {
163+
padding: 0px 2px;
164+
}

0 commit comments

Comments
 (0)