fix (console): wss issue

This commit is contained in:
Mickael Kerjean 2019-05-17 04:03:44 +10:00
parent 810f84c3e3
commit fea7050b1e
2 changed files with 9 additions and 5 deletions

View file

@ -47,9 +47,9 @@ steps:
from_secret: GIT_PASSWORD from_secret: GIT_PASSWORD
commands: commands:
- apk add git > /dev/null - apk add git > /dev/null
- chmod -R o+r+w+x ./dist/data
- cd ../ && git clone "https://readonly:$PASSWORD@git.kerjean.me/filestash/test.git" - cd ../ && git clone "https://readonly:$PASSWORD@git.kerjean.me/filestash/test.git"
- chmod -R 777 ./test/ - chmod -R 777 ./test/
- chmod -R 777 ./filestash/dist/data
- name: test_frontend - name: test_frontend
image: node:8-alpine image: node:8-alpine
@ -91,7 +91,8 @@ steps:
GPG_PASSPHRASE: GPG_PASSPHRASE:
from_secret: GPG_PASSPHRASE from_secret: GPG_PASSPHRASE
commands: commands:
- cp -R config/* dist/data/state/config/ - cp -R config/* ./dist/data/state/config/
- chmod -R o-r-w-x- ./dist/
- apt-get update > /dev/null && apt-get install -y gnupg1 curl > /dev/null - apt-get update > /dev/null && apt-get install -y gnupg1 curl > /dev/null
- mv dist filestash - mv dist filestash
- tar -cf filestash_linux-amd64.tar ./filestash - tar -cf filestash_linux-amd64.tar ./filestash

View file

@ -273,6 +273,7 @@ func htmlIndex(pathPrefix string) []byte {
func AppScript(pathPrefix string) string { func AppScript(pathPrefix string) string {
return ` return `
(function() { (function() {
Terminal.applyAddon(fit); Terminal.applyAddon(fit);
var term; var term;
@ -302,7 +303,7 @@ func AppScript(pathPrefix string) string {
}); });
var websocket = new WebSocket( var websocket = new WebSocket(
(location.protocol === "https:") ? "wss://" : "ws://" + (location.protocol === "https:" ? "wss://" : "ws://") +
location.hostname + ((location.port) ? (":" + location.port) : "") + location.hostname + ((location.port) ? (":" + location.port) : "") +
"`+ pathPrefix +`socket" "`+ pathPrefix +`socket"
); );
@ -343,7 +344,9 @@ func AppScript(pathPrefix string) string {
} }
websocket.onerror = function(e){ websocket.onerror = function(e){
term.destroy(); var $term = document.getElementById("terminal");
if($term) $term.remove();
document.getElementById("terminal").remove()
document.getElementById("error-message").innerText = "Websocket Error"; document.getElementById("error-message").innerText = "Websocket Error";
} }
} }