mirror of
https://gitlab.com/timvisee/send.git
synced 2024-11-10 05:02:45 +01:00
Implement wss preference url in html; Update to work with the tip of vnext branch; allow viewing the android ui from the webpack server (#918)
* Merge branch 'vnext' of https://github.com/mozilla/send into android-preferences Fix conflicts * Implement wss preference url in html; Update to work with the tip of vnext branch; allow viewing the android ui from the webpack server * Use a try/catch in case localStorage isn't available, which it isn't in a ServiceWorker
This commit is contained in:
parent
690a705be9
commit
71ea4e74f6
@ -1,6 +1,21 @@
|
||||
/* global window */
|
||||
|
||||
window.MAXFILESIZE = 1024 * 1024 * 1024 * 2;
|
||||
window.LIMITS = {
|
||||
ANON: {
|
||||
MAX_FILE_SIZE: 1024 * 1024 * 1024 * 2,
|
||||
MAX_DOWNLOADS: 32,
|
||||
MAX_EXPIRE_SECONDS: 604800
|
||||
},
|
||||
MAX_FILE_SIZE: 1024 * 1024 * 1024 * 2,
|
||||
MAX_DOWNLOADS: 32,
|
||||
MAX_EXPIRE_SECONDS: 604800,
|
||||
MAX_FILES_PER_ARCHIVE: 32,
|
||||
MAX_ARCHIVES_PER_USER: 32
|
||||
};
|
||||
|
||||
window.DEFAULTS = {
|
||||
EXPIRE_SECONDS: 3600
|
||||
};
|
||||
|
||||
const choo = require('choo');
|
||||
const app = choo();
|
||||
@ -11,4 +26,6 @@ app.use(require('./stores/intents').default);
|
||||
app.route('/', require('./pages/home').default);
|
||||
app.route('/upload', require('./pages/upload').default);
|
||||
app.route('/share/:id', require('./pages/share').default);
|
||||
app.route('/preferences', require('./pages/preferences').default);
|
||||
app.route('/android/app/src/main/assets', require('./pages/home').default);
|
||||
app.mount('body');
|
||||
|
@ -22,14 +22,13 @@
|
||||
</configuration>
|
||||
</facet>
|
||||
<facet type="kotlin-language" name="Kotlin">
|
||||
<configuration version="3" platform="JVM 1.8" useProjectSettings="false">
|
||||
<configuration version="3" platform="JVM 1.6" useProjectSettings="false">
|
||||
<compilerSettings />
|
||||
<compilerArguments>
|
||||
<option name="destination" value="$MODULE_DIR$/build/tmp/kotlin-classes/debug" />
|
||||
<option name="noStdlib" value="true" />
|
||||
<option name="noReflect" value="true" />
|
||||
<option name="moduleName" value="app_debug" />
|
||||
<option name="jvmTarget" value="1.8" />
|
||||
<option name="addCompilerBuiltIns" value="true" />
|
||||
<option name="loadBuiltInsFromDependencies" value="true" />
|
||||
<option name="languageVersion" value="1.2" />
|
||||
@ -126,7 +125,6 @@
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-main-apk-res" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaPrecompile" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifest-checker" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/prebuild" />
|
||||
|
@ -102,3 +102,7 @@ body {
|
||||
.cancel {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
#preferences {
|
||||
text-align: left;
|
||||
}
|
||||
|
@ -1,6 +1,15 @@
|
||||
const html = require('choo/html');
|
||||
|
||||
export default function mainPage(state, emit) {
|
||||
if (window.location.pathname === '/android/app/src/main/assets/') {
|
||||
// Hack: For debugging the android app in a web browser from
|
||||
// http://0.0.0.0:8080/android/app/src/main/assets/ after running webpack
|
||||
state.prefix = '/android/app/src/main/assets';
|
||||
}
|
||||
function clickPreferences(event) {
|
||||
event.preventDefault();
|
||||
emit('pushState', '/preferences');
|
||||
}
|
||||
function uploadFile(event) {
|
||||
event.preventDefault();
|
||||
const target = event.target;
|
||||
@ -16,6 +25,9 @@ export default function mainPage(state, emit) {
|
||||
return html`<body>
|
||||
<div id="white">
|
||||
<div id="centering">
|
||||
<a href="#" onclick=${clickPreferences}>
|
||||
preferenes
|
||||
</a>
|
||||
<img src=${state.getAsset('encrypted-envelope.png')} />
|
||||
<h4>Private, Encrypted File Sharing</h4>
|
||||
<div>
|
||||
|
36
android/pages/preferences.js
Normal file
36
android/pages/preferences.js
Normal file
@ -0,0 +1,36 @@
|
||||
const html = require('choo/html');
|
||||
|
||||
import { setFileProtocolWssUrl, getFileProtocolWssUrl } from '../../app/api';
|
||||
|
||||
export default function preferences(state, emit) {
|
||||
const wssURL = getFileProtocolWssUrl();
|
||||
|
||||
function updateWssUrl(event) {
|
||||
state.wssURL = event.target.value;
|
||||
setFileProtocolWssUrl(state.wssURL);
|
||||
emit('render');
|
||||
}
|
||||
|
||||
function clickDone(event) {
|
||||
event.preventDefault();
|
||||
emit('pushState', '/');
|
||||
}
|
||||
|
||||
return html`<body>
|
||||
<div id="white">
|
||||
<div id="preferences">
|
||||
<a onclick=${clickDone} href="#">
|
||||
done
|
||||
</a>
|
||||
<dl>
|
||||
<dt>
|
||||
wss url:
|
||||
</dt>
|
||||
<dd>
|
||||
<input type="text" onchange=${updateWssUrl} value=${wssURL} />
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</body>`;
|
||||
}
|
@ -1,11 +1,16 @@
|
||||
/* eslint-disable no-console */
|
||||
|
||||
import User from '../../app/user';
|
||||
import storage from '../../app/storage';
|
||||
|
||||
export default function initialState(state, emitter) {
|
||||
const files = [];
|
||||
|
||||
Object.assign(state, {
|
||||
prefix: '/android_asset',
|
||||
user: new User(undefined, storage),
|
||||
getAsset(name) {
|
||||
return `/android_asset/${name}`;
|
||||
return `${state.prefix}/${name}`;
|
||||
},
|
||||
translate: (...toTranslate) => {
|
||||
return toTranslate.map(o => JSON.stringify(o)).toString();
|
||||
|
21
app/api.js
21
app/api.js
@ -1,6 +1,25 @@
|
||||
import { arrayToB64, b64ToArray, delay } from './utils';
|
||||
import { ECE_RECORD_SIZE } from './ece';
|
||||
|
||||
let fileProtocolWssUrl = null;
|
||||
try {
|
||||
fileProtocolWssUrl = localStorage.getItem('wssURL');
|
||||
} catch (e) {
|
||||
// NOOP
|
||||
}
|
||||
if (!fileProtocolWssUrl) {
|
||||
fileProtocolWssUrl = 'wss://send2.dev.lcip.org/api/ws';
|
||||
}
|
||||
|
||||
export function setFileProtocolWssUrl(url) {
|
||||
localStorage && localStorage.setItem('wssURL', url);
|
||||
fileProtocolWssUrl = url;
|
||||
}
|
||||
|
||||
export function getFileProtocolWssUrl() {
|
||||
return fileProtocolWssUrl;
|
||||
}
|
||||
|
||||
function post(obj, bearerToken) {
|
||||
const h = {
|
||||
'Content-Type': 'application/json'
|
||||
@ -147,7 +166,7 @@ async function upload(
|
||||
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||
const endpoint =
|
||||
window.location.protocol === 'file:'
|
||||
? 'wss://send2.dev.lcip.org/api/ws'
|
||||
? fileProtocolWssUrl
|
||||
: `${protocol}//${host}${port ? ':' : ''}${port}/api/ws`;
|
||||
|
||||
const ws = await asyncInitWebSocket(endpoint);
|
||||
|
Loading…
Reference in New Issue
Block a user