Skip to content

Commit

Permalink
OFRAK Projects (#360)
Browse files Browse the repository at this point in the history
* Empty ProjectManager with button to enter it

* Some arrangement

* Scrolling, unified project view

* initial adventure/project implementation

* Exclusive checkboxes with focus

* iterate a bit on adventure data structure

* Do checkbox better

* tests, rename to projects, more implementation

* Mostly focusing elemetns and css

* Use panes and some other small changes

* Move titles outside of content boxes

* Use panes and some other things

* Hookedup project creation to backend

* Missed something

* Add proper response to server routes

* Use project given from server

* Get scripts from server

* Run a project, but resource view does not open automatically

* Script runs on project start

* Run project opens resource view

* Accidentally deleted script element

* Select any project from frontend

* Can clone project from git

* Little bit of startview css

* Startview css and formatting things

* Better toolbar

* Back button, some fortmatting, css etc

* Back buttons

* Changeable project location, and some other things

* check for existence of project dir, and only slurp it up when interacting with projects

* disable project management buttons when inputs not populated

* Remove package-lock.json

* Add project metadata and save option

* add frontend/backend support to list project scripts in RunScript dropdown

* Added ability to delete files

* see/change which scripts are associated with each binary

* Hide project option if no project and add .trash when deleting

* remove leading /

* another leading slash

* postmerge cleanups

* remove unused imports

* oops

* Do mypy's bidding

* make associated script checkboxes work with script reset

* core init script functionality

* removing debug print

* refactor ProjectManagerCheckbox.svelte a bit, better styling

* add some on-hover hints for checkboxes, rename "Run" to "Launch"

* only show project options if experimental settings enabled

* correct script options to binary options

* Some tests for projects

* save project test

* test delete

* test get project script

* Test git clone

* Test open project

* linting

* remove empty test, use HTTPS instead of git URLs, fix project id to session id

* Changelog

* frontend lint from merge conflict

* update old project tests, fix minor bugs, use init script by default

* finish renaming "adventure" to "project"

* fix very dumb typo

* remove dead code, refactor for test coverage

* update changelog link and test coverage

---------

Co-authored-by: Dan Pesce <[email protected]>
Co-authored-by: edward <[email protected]>
Co-authored-by: Dan Pesce <[email protected]>
Co-authored-by: dannyp303 <[email protected]>
  • Loading branch information
5 people authored Aug 10, 2023
1 parent cdfc1a5 commit ccb6e15
Show file tree
Hide file tree
Showing 35 changed files with 2,076 additions and 30 deletions.
35 changes: 35 additions & 0 deletions frontend/public/icons/back-arrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions frontend/public/icons/binary.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions frontend/public/icons/briefcase.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions frontend/public/icons/disk.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions frontend/public/icons/reset.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions frontend/public/icons/trash.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions frontend/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@
import { keyEventToString, shortcuts } from "./keyboard.js";
import { writable } from "svelte/store";
import ProjectManagerView from "./ProjectManager/ProjectManagerView.svelte";
printConsoleArt();
let showRootResource = false,
showProjectManager = false,
dataLenPromise = Promise.resolve([]),
hexScrollY = writable({}),
useAssemblyView = false,
Expand Down Expand Up @@ -188,6 +190,8 @@ Answer by running riddle.answer('your answer here') from the console.`);
bind:bottomLeftPane="{bottomLeftPane}"
bind:resourceNodeDataMap="{resourceNodeDataMap}"
bind:modifierView="{modifierView}"
bind:showProjectManager="{showProjectManager}"
bind:showRootResource="{showRootResource}"
/>
{/if}
</Pane>
Expand Down Expand Up @@ -251,10 +255,19 @@ Answer by running riddle.answer('your answer here') from the console.`);
<AudioPlayer />
</div>
{/if}
{:else if showProjectManager}
<ProjectManagerView
bind:rootResourceLoadPromise="{rootResourceLoadPromise}"
bind:rootResource="{rootResource}"
bind:resources="{resources}"
bind:showRootResource="{showRootResource}"
bind:showProjectManager="{showProjectManager}"
/>
{:else}
<StartView
bind:rootResourceLoadPromise="{rootResourceLoadPromise}"
bind:showRootResource="{showRootResource}"
bind:showProjectManager="{showProjectManager}"
bind:resources="{resources}"
bind:rootResource="{rootResource}"
bind:resourceNodeDataMap="{resourceNodeDataMap}"
Expand Down
23 changes: 23 additions & 0 deletions frontend/src/ExclusiveCheckbox.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<script>
import Checkbox from "./Checkbox.svelte";
export let selectedValue,
ownValue,
leftbox = false,
nomargin = false;
let thisSelected;
$: if (thisSelected) {
selectedValue = ownValue;
}
</script>

<Checkbox
leftbox="{leftbox}"
nomargin="{nomargin}"
checked="{selectedValue === ownValue}"
bind:value="{thisSelected}"
>
<slot />
</Checkbox>
1 change: 0 additions & 1 deletion frontend/src/FileBrowser.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
.filelabel span {
width: 100%;
margin-left: 2ch;
background: inherit;
color: inherit;
/* border-bottom: 1px solid var(--main-fg-color); */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<style>
.add-file {
display: flex;
flex-direction: row;
justify-content: space-around;
}
button {
margin: 1em, 0;
padding-top: 0.5em;
padding-bottom: 0.5em;
padding-left: 1em;
padding-right: 1em;
background-color: var(--main-bg-color);
color: var(--main-fg-color);
border: 1px solid var(--main-fg-color);
border-radius: 0;
font-size: smaller;
overflow: hidden;
box-shadow: none;
}
button:hover,
button:focus {
outline: none;
box-shadow: inset 1px 1px 0 var(--main-fg-color),
inset -1px -1px 0 var(--main-fg-color);
}
button:active {
box-shadow: inset 2px 2px 0 var(--main-fg-color),
inset -2px -2px 0 var(--main-fg-color);
}
</style>

<script>
import FileBrowser from "../FileBrowser.svelte";
import Icon from "../Icon.svelte";
import { selectedProject, settings } from "../stores";
let files, f;
$: if (files) {
f = files[0];
files = null;
}
async function addBinaryToProject() {
await fetch(
`${$settings.backendUrl}/add_binary_to_project?id=${$selectedProject.session_id}&name=${f.name}`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: await f.arrayBuffer(),
}
).then(async (r) => {
if (!r.ok) {
throw Error(JSON.stringify(await r.json(), undefined, 2));
}
$selectedProject = await fetch(
`${$settings.backendUrl}/get_project_by_id?id=${$selectedProject.session_id}`
).then((r) => {
if (!r.ok) {
throw Error(r.statusText);
}
return r.json();
});
return await r.json();
});
}
</script>

<div class="add-file">
<FileBrowser bind:files="{files}" />
{#if f}
<button on:click="{addBinaryToProject}"
><Icon url="/icons/binary.svg" /> Add Binary to Project</button
>
{/if}
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<style>
.add-file {
display: flex;
flex-direction: row;
justify-content: space-around;
}
button {
margin: 1em, 0;
padding-top: 0.5em;
padding-bottom: 0.5em;
padding-left: 1em;
padding-right: 1em;
background-color: var(--main-bg-color);
color: var(--main-fg-color);
border: 1px solid var(--main-fg-color);
border-radius: 0;
font-size: smaller;
overflow: hidden;
box-shadow: none;
}
</style>

<script>
import FileBrowser from "../FileBrowser.svelte";
import Icon from "../Icon.svelte";
import { selectedProject, settings } from "../stores";
let files, f;
$: if (files) {
f = files[0];
files = null;
}
async function addScriptToProject() {
return await fetch(
`${$settings.backendUrl}/add_script_to_project?id=${$selectedProject.session_id}&name=${f.name}`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: await f.arrayBuffer(),
}
).then(async (r) => {
if (!r.ok) {
throw Error(JSON.stringify(await r.json(), undefined, 2));
}
$selectedProject = await fetch(
`${$settings.backendUrl}/get_project_by_id?id=${$selectedProject.session_id}`
).then((r) => {
if (!r.ok) {
throw Error(r.statusText);
}
return r.json();
});
return await r.json();
});
}
</script>

<div class="add-file">
<FileBrowser bind:files="{files}" />
{#if f}
<button on:click="{addScriptToProject}"
><Icon url="/icons/document.svg" /> Add Script to Project</button
>
{/if}
</div>
68 changes: 68 additions & 0 deletions frontend/src/ProjectManager/ProjectManagerBinaryOptions.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<style>
button {
margin-bottom: 1em;
margin-left: 1em;
padding-top: 0.5em;
padding-bottom: 0.5em;
padding-left: 1em;
padding-right: 1em;
background-color: var(--main-bg-color);
color: var(--main-fg-color);
border: 1px solid var(--main-fg-color);
border-radius: 0;
font-size: smaller;
overflow: hidden;
box-shadow: none;
}
button:hover,
button:focus {
outline: none;
box-shadow: inset 1px 1px 0 var(--main-fg-color),
inset -1px -1px 0 var(--main-fg-color);
}
button:active {
box-shadow: inset 2px 2px 0 var(--main-fg-color),
inset -2px -2px 0 var(--main-fg-color);
}
</style>

<script>
import { selectedProject, settings, selected } from "../stores";
import Icon from "../Icon.svelte";
export let name;
async function deleteBinary() {
await fetch(`${$settings.backendUrl}/delete_binary_from_project`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
id: $selectedProject.session_id,
binary: name,
}),
}).then(async (r) => {
if (!r.ok) {
throw Error(JSON.stringify(await r.json(), undefined, 2));
}
$selectedProject = await fetch(
`${$settings.backendUrl}/get_project_by_id?id=${$selectedProject.session_id}`
).then((r) => {
if (!r.ok) {
throw Error(r.statusText);
}
return r.json();
});
return await r.json();
});
}
</script>

<div>
<button on:click|stopPropagation="{deleteBinary}"
><Icon url="/icons/trash.svg" />Delete {name} from project.</button
>
</div>
Loading

0 comments on commit ccb6e15

Please sign in to comment.