Skip to content

Commit

Permalink
Fixed a bug where the approach option ID was being shown in the appro…
Browse files Browse the repository at this point in the history
…ach selection box. Added Cape Air as a possible company.
  • Loading branch information
knicholson32 committed Apr 19, 2024
1 parent 94cef27 commit a88bd30
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/lib/components/entry/InstrumentApproach.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
class="w-full xs:w-auto sm:max-w-md text-sm border-0 rounded-md text-gray-900 dark:text-gray-100 dark:bg-transparent shadow-sm ring-1 placeholder:text-gray-400 disabled:cursor-not-allowed select:disabled:text-red-500 disabled:bg-gray-50 dark:disabled:bg-zinc-900 disabled:text-gray-500 dark:disabled:text-gray-600 disabled:ring-gray-200 ring-gray-300 dark:ring-zinc-500 focus:border-gray-900 focus-within:ring-2 focus-within:ring-sky-600 focus-within:border-0">
<option disabled value={null}>Unset</option>
{#each approachOptions as option}
<option selected={false} value={option.id}>{option.composite} {option.id}</option>
<option selected={false} value={option.id}>{option.composite}</option>
{/each}
<option value={-1}>Custom</option>
</select>
Expand Down
3 changes: 3 additions & 0 deletions src/lib/server/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const TypeNames = {
'tour.defaultStartApt': 'KPDK',
// System --------------------------------
'system.debug': 0,
'system.lastSeenCommit': '',
// Data ----------------------------------
'data.approaches.lastSync': -1,
'data.approaches.source': '',
Expand All @@ -43,6 +44,7 @@ export type ObjectType<T extends TypeName> =
T extends 'entry.defaultStartApt' ? string : // String
T extends 'entry.entryMXMode' ? boolean : // Boolean
T extends 'system.debug' ? number : // Integer
T extends 'system.lastSeenCommit' ? string : // String
T extends 'data.approaches.lastSync' ? number : // Integer
T extends 'data.approaches.source' ? string : // String
T extends 'general.encKey' ? string : // String
Expand Down Expand Up @@ -102,6 +104,7 @@ export const get = async <T extends TypeName>(setting: T, settingVal?: SettingPa
case 'entry.flight_id.last':
case 'tour.defaultStartApt':
case 'data.approaches.source':
case 'system.lastSeenCommit':
case 'general.encKey':
case 'general.email':
case 'general.name':
Expand Down
26 changes: 22 additions & 4 deletions src/routes/+layout.server.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
import type { GitCommit } from '$lib/server/api/git/schema';
import * as settings from '$lib/server/settings';

const MAX_MB = 10;

export const load = async ({ }) => {
export const load = async ({ fetch }) => {

const commit = process.env.GIT_COMMIT ?? '';

const set = await settings.getMany('system.debug', 'system.lastSeenCommit', 'entry.tour.current', 'general.gravatar.hash', 'general.name', 'general.email', 'general.timezone');

let contourUpdates = false

if (set['system.lastSeenCommit'] !== commit || true) contourUpdates = true;

return {
entrySettings: await settings.getSet('entry'),
generalSettings: await settings.getSet('general'),
debug: await settings.get('system.debug'),
settings: set,
MAX_MB,
contourUpdates
};
};


// let newItems: GitCommit[] | null = null;

// if (set['system.lastSeenCommit'] !== commit || true) {
// const res = await fetch(`https://api.github.com/repos/knicholson32/Contour/commits?per_page=100&sha=${set['system.lastSeenCommit']}`);
// if (res.ok === true) {
// getCommits = await res.json() as GitCommit[];
// }
// }
49 changes: 42 additions & 7 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import { icons } from "$lib/components";
import * as Popover from "$lib/components/ui/popover";
import { ModeWatcher } from "mode-watcher";
import { Briefcase, ChevronRight, Link, Plane, Send, Tag } from "lucide-svelte";
import { Briefcase, ChevronRight, GitCommitVertical, Link, Plane, Send, Tag } from "lucide-svelte";
import WhatsNew from "$lib/components/routeSpecific/WhatsNew.svelte";
export let data: import('./$types').PageData;
Expand Down Expand Up @@ -118,9 +119,9 @@
</div>
{/if}

{#if data.entrySettings["entry.tour.current"] !== -1}
{#if data.settings["entry.tour.current"] !== -1}
<div class="m-3 flex items-center">
<a href="/entry/day?tour={data.entrySettings["entry.tour.current"]}" class="uppercase select-none border border-sky-400 text-sky-400 rounded-md py-2 px-3 whitespace-nowrap">
<a href="/entry/day?tour={data.settings["entry.tour.current"]}" class="uppercase select-none border border-sky-400 text-sky-400 rounded-md py-2 px-3 whitespace-nowrap">
On Tour
</a>
</div>
Expand Down Expand Up @@ -190,7 +191,13 @@
<button type="button" on:click={toggleAccountDropdown} class="touch-manipulation relative flex max-w-xs items-center rounded-full bg-white text-sm focus:outline-none focus:ring-2 focus:ring-sky-500 focus:ring-offset-2" id="user-menu-button" aria-expanded="false" aria-haspopup="true">
<span class="absolute -inset-1.5"></span>
<span class="sr-only">Open user menu</span>
<img class="h-8 w-8 rounded-full" src="https://www.gravatar.com/avatar/{data.generalSettings["general.gravatar.hash"]}?s=300&d=identicon" alt="">
<img class="h-8 w-8 rounded-full" src="https://www.gravatar.com/avatar/{data.settings["general.gravatar.hash"]}?s=300&d=identicon" alt="">
{#if data.contourUpdates}
<span class="absolute -top-0.5 -right-0.5 flex h-3 w-3">
<span class="animate-ping absolute inline-flex h-full w-full rounded-full bg-sky-400 opacity-75"></span>
<span class="relative inline-flex rounded-full h-3 w-3 bg-sky-500"></span>
</span>
{/if}
</button>
</div>

Expand All @@ -216,6 +223,20 @@
<a href="{m.href}" on:click={closeAccountDropdown} class="hover:bg-gray-50 dark:hover:bg-zinc-800 block px-4 py-2 text-sm text-gray-700 dark:text-gray-100 dark:hover:text-white" role="menuitem" tabindex="-1" id="user-menu-item-1">{m.title}</a>
{/if}
{/each}
{#if data.contourUpdates}
<div class="w-full border-t"></div>
<Popover.Root>
<Popover.Trigger class="w-full text-left inline-flex items-center relative hover:bg-gray-50 dark:hover:bg-zinc-800 px-4 py-2 text-sm text-gray-700 dark:text-gray-100 dark:hover:text-white">
<div class="absolute -left-0">
<GitCommitVertical class="w-4 h-4 text-sky-500" />
</div>
See What's New
</Popover.Trigger>
<Popover.Content>
<WhatsNew />
</Popover.Content>
</Popover.Root>
{/if}
</div>
</div>
</div>
Expand Down Expand Up @@ -267,11 +288,11 @@
<div class="border-t bg-white dark:bg-zinc-900 border-gray-200 dark:border-zinc-800 pb-3 pt-4">
<div class="flex items-center px-4">
<div class="flex-shrink-0">
<img class="h-10 w-10 rounded-full" src="https://www.gravatar.com/avatar/{data.generalSettings["general.gravatar.hash"]}?s=300&d=identicon" alt="">
<img class="h-10 w-10 rounded-full" src="https://www.gravatar.com/avatar/{data.settings["general.gravatar.hash"]}?s=300&d=identicon" alt="">
</div>
<div class="ml-3">
<div class="text-base font-medium text-gray-800 dark:text-gray-200">{data.generalSettings["general.name"]}</div>
<div class="text-sm font-medium text-gray-500">{data.generalSettings["general.email"]}</div>
<div class="text-base font-medium text-gray-800 dark:text-gray-200">{data.settings["general.name"]}</div>
<div class="text-sm font-medium text-gray-500">{data.settings["general.email"]}</div>
</div>
<!-- <button type="button" class="relative ml-auto flex-shrink-0 rounded-full p-1 text-gray-400 hover:text-gray-500 dark:hover:text-gray-300 focus:outline-none focus:ring-2 focus:ring-sky-500 focus:ring-offset-2">
<span class="absolute -inset-1.5"></span>
Expand All @@ -289,6 +310,20 @@
<a href="{m.href}" on:click={closeMobileMenu} class="block px-4 py-2 text-base font-medium text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-zinc-800 hover:text-gray-800 dark:hover:text-gray-200">{m.title}</a>
{/if}
{/each}
{#if data.contourUpdates}
<div class="w-full border-t"></div>
<Popover.Root>
<Popover.Trigger class="inline-flex w-full items-center px-4 py-2 text-base font-medium text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-zinc-800 hover:text-gray-800 dark:hover:text-gray-200">
<div class="absolute -left-0">
<GitCommitVertical class="w-4 h-4 text-sky-500" />
</div>
See What's New
</Popover.Trigger>
<Popover.Content>
<WhatsNew />
</Popover.Content>
</Popover.Root>
{/if}
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/routes/entry/tour/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
{/if}

<Section title="Details">
<Entry.Select required={true} title="Company" options={['NetJets']} placeholder="Unset" name="company" defaultValue={'NetJets'} />
<Entry.Select required={true} title="Company" options={['NetJets', 'Cape Air']} placeholder="Unset" name="company" defaultValue={data.currentTour?.companyId ?? 'NetJets'} />
<Entry.Switch required={true} title="Line Check" name="line-check" defaultValue={data.currentTour?.lineCheck ?? false} />
</Section>
<Section title="Notes">
Expand Down
2 changes: 1 addition & 1 deletion src/routes/entry/tour/[id]/end/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
</Section>

<Section title="Details">
<Entry.Select required={true} title="Company" options={['NetJets']} placeholder="Unset" name="company" defaultValue={'NetJets'} />
<Entry.Select required={true} title="Company" options={['NetJets', 'Cape Air']} placeholder="Unset" name="company" defaultValue={data.currentTour?.companyId ?? 'NetJets'} />
<Entry.Switch required={true} title="Line Check" name="line-check" defaultValue={false} />
</Section>
<Section title="Notes">
Expand Down
2 changes: 1 addition & 1 deletion src/routes/settings/data/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
? 'Never'
: intlFormatDistance(new Date(data.settingValues['data.approaches.lastSync'] * 1000), new Date());
const lastSyncTime =
data.settingValues['data.approaches.lastSync'] === -1 ? 'Never' : toISOStringTZ(data.settingValues['data.approaches.lastSync'] * 1000, data.generalSettings['general.timezone']);
data.settingValues['data.approaches.lastSync'] === -1 ? 'Never' : toISOStringTZ(data.settingValues['data.approaches.lastSync'] * 1000, data.settings['general.timezone']);
</script>

Expand Down

0 comments on commit a88bd30

Please sign in to comment.