-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set up FLEx-lite view permissions and API features
- Loading branch information
Showing
23 changed files
with
306 additions
and
156 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
11 changes: 6 additions & 5 deletions
11
frontend/src/routes/(authenticated)/project/[project_code]/viewer/+page.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,25 @@ | ||
<script lang="ts"> | ||
import 'viewer/component'; | ||
import {type LexboxServiceProvider} from 'viewer/service-provider'; | ||
import {LexboxService} from 'viewer/service-provider'; | ||
import {LfClassicLexboxApi} from './lfClassicLexboxApi'; | ||
import type {PageData} from './$types'; | ||
export let data: PageData; | ||
$: project = data.project; | ||
const serviceProvider: LexboxServiceProvider = window.lexbox.ServiceProvider; | ||
const serviceProvider = window.lexbox.ServiceProvider; | ||
let service: LfClassicLexboxApi; | ||
$: { | ||
if (serviceProvider) { | ||
let localService = new LfClassicLexboxApi(data.code); | ||
serviceProvider.setService('LexboxApi', localService); | ||
let localService = new LfClassicLexboxApi($project.code); | ||
serviceProvider.setService(LexboxService.LexboxApi, localService); | ||
service = localService; | ||
} | ||
} | ||
</script> | ||
{#if service} | ||
{#key service} | ||
<lexbox-svelte></lexbox-svelte> | ||
<lexbox-svelte projectName={$project.name}></lexbox-svelte> | ||
{/key} | ||
{/if} |
34 changes: 31 additions & 3 deletions
34
frontend/src/routes/(authenticated)/project/[project_code]/viewer/+page.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,33 @@ | ||
import type {PageLoadEvent} from './$types'; | ||
import { getClient, graphql } from '$lib/gql'; | ||
|
||
import type {PageLoadEvent} from './$types'; | ||
import { error } from '@sveltejs/kit'; | ||
import { tryMakeNonNullable } from '$lib/util/store'; | ||
|
||
export const ssr = false; // 💖 | ||
export function load(event: PageLoadEvent) { | ||
return {code: event.params.project_code}; | ||
export async function load(event: PageLoadEvent) { | ||
const client = getClient(); | ||
const projectCode = event.params.project_code; | ||
const projectResult = await client | ||
.awaitedQueryStore(event.fetch, | ||
graphql(` | ||
query viewerProject($projectCode: String!) { | ||
projectByCode(code: $projectCode) { | ||
id | ||
name | ||
code | ||
} | ||
} | ||
`), | ||
{ projectCode } | ||
); | ||
|
||
const nonNullableProject = tryMakeNonNullable(projectResult.projectByCode); | ||
if (!nonNullableProject) { | ||
error(404); | ||
} | ||
|
||
return { | ||
project: nonNullableProject, | ||
}; | ||
} |
11 changes: 8 additions & 3 deletions
11
frontend/src/routes/(authenticated)/project/[project_code]/viewer/lfClassicLexboxApi.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
<script lang="ts"> | ||
import ProjectView from './ProjectView.svelte'; | ||
import {InMemoryApiService} from './lib/in-memory-api-service'; | ||
import {LexboxServices} from './lib/services/service-provider'; | ||
import {LexboxService} from './lib/services/service-provider'; | ||
window.lexbox.ServiceProvider.setService(LexboxServices.LexboxApi, new InMemoryApiService()); | ||
const inMemoryLexboxApi = new InMemoryApiService(); | ||
window.lexbox.ServiceProvider.setService(LexboxService.LexboxApi, inMemoryLexboxApi); | ||
</script> | ||
<ProjectView isConnected/> | ||
<ProjectView projectName={inMemoryLexboxApi.projectName} isConnected /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export { }; // for some reason this is required in order to make global changes | ||
|
||
declare global { | ||
function enableDevMode(): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.