This repository has been archived by the owner on Feb 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kelp UI: Fix basepath and use pingURL to ping server in tailFile befo…
…re redirect (#404) * 1 - show error hint if base unix and native paths are different * 2 - catch cycles in initialization of kelpos.go * 3 - fix instance of calling String() on an OSPath * 4 - incorporate pingURL into tailFileHTML * 5 - keep debug mode for electron enabled * 6 - add check for kelp server to be run from root kelp directory in local mode * 7 - always execute commands from the working directory * 8 - use only binary directory as basepth in both native and unix formats, eliminating ambiguity * 9 - working directory command to OS should be specified in Native form * 10 - fix getBinaryDirectoryUnix by invoking toUnixFilepath before returning * 11 - kelpBinPath -> kelpBinName * 12 - added comments related to fix of using kelp binary name instead of absolute path
- Loading branch information
1 parent
dcd0663
commit 20a5cf4
Showing
8 changed files
with
204 additions
and
32 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -35,6 +35,7 @@ import ( | |
"github.com/stellar/kelp/support/networking" | ||
"github.com/stellar/kelp/support/prefs" | ||
"github.com/stellar/kelp/support/sdk" | ||
"github.com/stellar/kelp/support/utils" | ||
) | ||
|
||
const kelpPrefsDirectory = ".kelp" | ||
|
@@ -89,6 +90,17 @@ func init() { | |
isLocalMode := env == envDev | ||
isLocalDevMode := isLocalMode && *options.dev | ||
kos := kelpos.GetKelpOS() | ||
if isLocalMode { | ||
wd, e := os.Getwd() | ||
if e != nil { | ||
panic(errors.Wrap(e, "could not get working directory")) | ||
} | ||
if filepath.Base(wd) != "kelp" { | ||
e := fmt.Errorf("need to invoke from the root 'kelp' directory") | ||
utils.PrintErrorHintf(e.Error()) | ||
panic(e) | ||
} | ||
} | ||
|
||
var logFilepath *kelpos.OSPath | ||
if !isLocalDevMode { | ||
|
@@ -517,7 +529,7 @@ func openElectron(trayIconPath *kelpos.OSPath, url string) { | |
AppIconDefaultPath: "resources/[email protected]", | ||
AcceptTCPTimeout: time.Minute * 2, | ||
}, | ||
Debug: false, | ||
Debug: true, | ||
Windows: []*bootstrap.Window{&bootstrap.Window{ | ||
Homepage: url, | ||
Options: &astilectron.WindowOptions{ | ||
|
@@ -697,10 +709,21 @@ const tailFileHTML = `<!-- taken from http://www.davejennifer.com/computerjunk/j | |
if (ajax.status == 200 || ajax.status == 206) { | ||
if (ajax.responseText.includes("READY_STRING")) { | ||
var redirectURL = "REDIRECT_URL"; | ||
var pingURL = "PING_URL"; | ||
document.getElementById("theEnd").innerHTML = "<br/><br/><b>redirecting to " + redirectURL + " ...</b><br/><br/>"; | ||
document.getElementById("theEnd").scrollIntoView(); | ||
// sleep for 2 seconds so the user sees that we are being redirected | ||
setTimeout(() => { window.location.href = redirectURL; }, 2000) | ||
setTimeout(() => { | ||
var ajaxPing = new XMLHttpRequest(); | ||
ajaxPing.open("GET", pingURL, true); | ||
ajaxPing.onreadystatechange = function () { | ||
if ((ajaxPing.readyState == 4) && (ajaxPing.status == 200)) { | ||
window.location.href = redirectURL; | ||
} | ||
} | ||
ajaxPing.send(null); | ||
}, 2000) | ||
} | ||
} | ||
}// ready state 4 | ||
|
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
Oops, something went wrong.