Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ feature: custom applications #39

Merged
merged 1 commit into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions FlowOS/public/builtin/apps/app-wizard.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />

<link rel="stylesheet" href="/styles/style.css" />
<link rel="stylesheet" href="/styles/window.css" />
</head>

<body>
<h2>Custom Application Wizard</h2>
<div class="caw">
<h3>Load from URL</h3>
<form class="url">
<input>
<button>Import</button>
</form>
<h3>Load from JSON</h3>
<form class="json">
<textarea></textarea>
<button>Import</button>
</form>
</div>

<script src="/scripts/app.js" defer type="module"></script>
<script src="/builtin/apps/scripts/app-wizard.js" defer type="module"></script>
</body>
</html>
35 changes: 35 additions & 0 deletions FlowOS/public/builtin/apps/scripts/app-wizard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* eslint-env browser */

import { config } from '../../../scripts/managers.js';

document.querySelector('.json').onsubmit = async () => {
const res = await fetch(document.querySelector('input').value);
const data = await res.json();

const obj = {
...config.apps.get()
};
if (config.apps.get()[data.APP_ID]) {
delete obj[data.APP_ID];
} else {
obj[data.APP_ID] = data;
}
config.apps.set(obj);
parent.document.querySelector('.app-switcher .apps').innerHTML = '';
parent.Flow.apps.register();
};

document.querySelector('.json').onsubmit = () => {
const data = JSON.parse(document.querySelector('textarea').value);
const obj = {
...config.apps.get()
};
if (config.apps.get()[data.APP_ID]) {
delete obj[data.APP_ID];
} else {
obj[data.APP_ID] = data;
}
config.apps.set(obj);
parent.document.querySelector('.app-switcher .apps').innerHTML = '';
parent.Flow.apps.register();
};
2 changes: 2 additions & 0 deletions FlowOS/public/constants/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ const apps = () => {
'browser': new AppData('browser', 'Browser', '/builtin/apps/browser.html', false),
'gameboy': new AppData('gameboy', 'Emulator', '/emu/', false),
'applications-apps': new AppData('applications-apps', 'App Store', '/builtin/apps/apps.html', false),
'applications-programming': new AppData('applications-programming', 'Custom Application Wizard', '/builtin/apps/app-wizard.html', false),
...config.apps.get(),
...config.customApps.get(),
};
};

Expand Down
3 changes: 2 additions & 1 deletion FlowOS/public/flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { config } from './scripts/managers.js';
import apps from './constants/apps.js';

export default class FlowInstance {
version = 'v1.0.0-beta';
version = 'v1.0.1-beta';
init = false;
setup = false;

Expand All @@ -25,6 +25,7 @@ export default class FlowInstance {

if (!config.css.get()) config.css.set('');
if (!config.apps.get()) config.apps.set([]);
if (!config.customApps.get()) config.customApps.set([]);

_auth.onAuthStateChanged(async (user) => {
if (this.init || this.setup) parent.window.location.reload();
Expand Down
8 changes: 8 additions & 0 deletions FlowOS/public/scripts/managers.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ const config = {
return window.localStorage.setItem('apps', JSON.stringify(value));
},
},
customApps: {
get: () => {
return JSON.parse(window.localStorage.getItem('custom-apps'));
},
set: (value) => {
return window.localStorage.setItem('custom-apps', JSON.stringify(value));
},
},
settings: {
get: (item) => {
return JSON.parse(window.localStorage.getItem(item));
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flow-os",
"version": "1.0.0-beta",
"version": "1.0.1-beta",
"description": "The customizable webOS.",
"keywords": [
"tomp",
Expand Down