summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rhimportd/main.go6
-rw-r--r--src/rhimportd/routeWeb.go (renamed from src/rhimportd/ctrlWeb.go)4
-rw-r--r--src/rhimportd/uploadWeb.go2
-rw-r--r--web-static/socket.html51
-rw-r--r--web-static/upload-form.html29
-rw-r--r--web-static/upload.html69
6 files changed, 117 insertions, 44 deletions
diff --git a/src/rhimportd/main.go b/src/rhimportd/main.go
index e94476c..72785c0 100644
--- a/src/rhimportd/main.go
+++ b/src/rhimportd/main.go
@@ -141,9 +141,9 @@ func main() {
wg.Add(1)
go func() {
defer wg.Done()
- rhl.Println("starting web-ctrl")
- StartControlWeb(webAddr.Get().(string), webStaticDir.Get().(string), conf, db.GetInterface(), sessions.GetInterface())
- rhl.Println("web-ctrl finished")
+ rhl.Println("starting web-router")
+ StartWebRouter(webAddr.Get().(string), webStaticDir.Get().(string), conf, db.GetInterface(), sessions.GetInterface())
+ rhl.Println("web-router finished")
}()
}
diff --git a/src/rhimportd/ctrlWeb.go b/src/rhimportd/routeWeb.go
index bd3d776..22db1d7 100644
--- a/src/rhimportd/ctrlWeb.go
+++ b/src/rhimportd/routeWeb.go
@@ -44,7 +44,7 @@ func (self webHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
self.H(self.Config, self.DBChan, self.SessionStoreChan, self.trusted, w, r)
}
-func StartControlWeb(addr, staticDir string, conf *rhimport.Config, db *rddb.DBChan, sessions *rhimport.SessionStoreChan) {
+func StartWebRouter(addr, staticDir string, conf *rhimport.Config, db *rddb.DBChan, sessions *rhimport.SessionStoreChan) {
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir(staticDir))))
// http.Handle("/trusted/simple", webHandler{conf, db, sessions, true, webSimpleHandler})
@@ -52,7 +52,7 @@ func StartControlWeb(addr, staticDir string, conf *rhimport.Config, db *rddb.DBC
http.Handle("/public/socket", webHandler{conf, db, sessions, false, webSocketHandler})
http.Handle("/public/upload", webHandler{conf, db, sessions, false, webUploadHandler})
- rhl.Println("web-ctrl: listening on", addr)
+ rhl.Println("web-router: listening on", addr)
server := &http.Server{Addr: addr, ReadTimeout: 2 * time.Hour, WriteTimeout: 2 * time.Hour}
server.ListenAndServe()
}
diff --git a/src/rhimportd/uploadWeb.go b/src/rhimportd/uploadWeb.go
index 7d1f460..84605e6 100644
--- a/src/rhimportd/uploadWeb.go
+++ b/src/rhimportd/uploadWeb.go
@@ -100,7 +100,7 @@ func webUploadParseForm(r *http.Request) (username, sessionid, srcfile string, s
func webUploadHandler(conf *rhimport.Config, db *rddb.DBChan, sessions *rhimport.SessionStoreChan, trusted bool, w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" {
- http.Redirect(w, r, "/static/upload-form.html", http.StatusTemporaryRedirect)
+ http.Redirect(w, r, "/static/upload.html", http.StatusTemporaryRedirect)
return
}
diff --git a/web-static/socket.html b/web-static/socket.html
index 9b118ac..9781e81 100644
--- a/web-static/socket.html
+++ b/web-static/socket.html
@@ -17,6 +17,19 @@
margin-bottom: 1em;
}
+ #progress {
+ background-color: white;
+ border: 1px solid;
+ padding: 1em;
+ font-family: monospace;
+ margin-top: 2em;
+ margin-bottom: 0em;
+ }
+
+ #progress span.caption {
+ font-weight: bold;
+ }
+
td {
text-align: right;
}
@@ -60,6 +73,9 @@
$('#sessionid').val(msg.ID);
buttonsRunning();
break;
+ case "progress":
+ repaintProgress(msg.PROGRESS_STEP_NAME, msg.PROGRESS, msg.TITLE, msg.CART_NUMBER, msg.CUT_NUMBER);
+ break;
case "done":
case "error":
this.sock.close();
@@ -110,23 +126,32 @@
}
function buttonsIdle() {
- $('#buttonrun').removeAttr('disabled')
- $('#buttonreconnect').removeAttr('disabled')
- $('#buttondetach').attr('disabled','disabled')
- $('#buttoncancel').attr('disabled','disabled')
+ $('#buttonrun').removeAttr('disabled');
+ $('#buttonreconnect').removeAttr('disabled');
+ $('#buttondetach').attr('disabled','disabled');
+ $('#buttoncancel').attr('disabled','disabled');
}
function buttonsRunning() {
- $('#buttonrun').attr('disabled','disabled')
- $('#buttonreconnect').attr('disabled','disabled')
- $('#buttondetach').removeAttr('disabled')
- $('#buttoncancel').removeAttr('disabled')
+ $('#buttonrun').attr('disabled','disabled');
+ $('#buttonreconnect').attr('disabled','disabled');
+ $('#buttondetach').removeAttr('disabled');
+ $('#buttoncancel').removeAttr('disabled');
+ }
+
+ function repaintProgress(step, value, title, cart, cut) {
+ $('#progress_step').text("'" + step + "'");
+ $('#progress_value').text(Math.round(value*100)/100 + "%");
+ $('#progress_title').text("'" + title + "'");
+ $('#progress_cart').text(cart);
+ $('#progress_cut').text(cut);
}
function init() {
$('#sessionid').val("");
buttonsIdle();
- $('#buttonlist').removeAttr('disabled','disabled')
+ repaintProgress("", 0, "", 0, 0);
+ $('#buttonlist').removeAttr('disabled','disabled');
}
</script>
</head>
@@ -154,6 +179,14 @@
<input id="sessionid" type="text" size="45">
<button id="buttonreconnect" onclick="reconnect()">reconnect</button>
<button id="buttoncancel" onclick="cancel()">cancel</button>
+ <div id="progress">
+ <span class="caption">Step/Value:</span>
+ <span id="progress_step"></span> / <span id="progress_value"></span>
+ <span class="caption">Title</span>
+ <span id="progress_title"></span>
+ <span class="caption">Cart/Cut</span>
+ <span id="progress_cart"></span> / <span id="progress_cut"></span>
+ </div>
<div id="rawmsg" class="data"></div>
</div>
</body>
diff --git a/web-static/upload-form.html b/web-static/upload-form.html
deleted file mode 100644
index 5353f95..0000000
--- a/web-static/upload-form.html
+++ /dev/null
@@ -1,29 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <title>rhimportd File Upload</title>
- <style type="text/css">
- body {
- background-color: #555;
- }
-
- td.label {
- text-align: right;
- }
- </style>
- </head>
- <body>
- <div class="container">
- <h1>rhimportd File Upload</h1>
- <form class="form-upload" method="post" action="/public/upload" enctype="multipart/form-data">
- <table>
- <tr><td class="label">Username</td><td><input type="text" name="LOGIN_NAME" size="20" value="heslinki" /></td></tr>
- <tr><td class="label">Session</td><td><input type="text" name="SESSION_ID" size="45" /></td></tr>
- <tr><td class="label">File</td><td><input type="file" name="FILENAME" /></td></tr>
- <tr><td>&nbsp;</td><td><input type="submit" name="submit" value="Submit"></td></tr>
- </table>
- </form>
- </div>
- </body>
-</html>
diff --git a/web-static/upload.html b/web-static/upload.html
new file mode 100644
index 0000000..39cfa57
--- /dev/null
+++ b/web-static/upload.html
@@ -0,0 +1,69 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <title>rhimportd File Upload</title>
+ <style type="text/css">
+ body {
+ background-color: #555;
+ }
+
+ div.data {
+ background-color: white;
+ border: 1px solid;
+ padding: 1em;
+ font-family: monospace;
+ margin-top: 1em;
+ margin-bottom: 1em;
+ }
+
+ td.label {
+ text-align: right;
+ }
+ </style>
+ <script src="jquery.min.js"></script>
+ <script type="text/javascript">
+ function upload() {
+ $('#buttonupload').attr('disabled','disabled');
+
+ var cmdData = new FormData();
+ cmdData.append("LOGIN_NAME", $('#username').val());
+ cmdData.append("SESSION_ID", $('#sessionid').val());
+ cmdData.append("FILENAME", $('#file').get(0).files[0]);
+ var command = {
+ type: "POST",
+ contentType: false,
+ processData: false,
+ data: cmdData,
+ dataType: 'json',
+ error: function(req, status, err) { result({StatusText: status, ErrorString: err}); },
+ success: function(data, status, req) { result(data); }
+ };
+ $.ajax('/public/upload', command);
+
+ }
+
+ function result(data) {
+ $('#result').text(JSON.stringify(data));
+ $('#buttonupload').removeAttr('disabled','disabled');
+ }
+
+ function init() {
+ $('#sessionid').val("");
+ result({})
+ }
+ </script>
+ </head>
+ <body onload="init()">
+ <div class="container">
+ <h1>rhimportd File Upload</h1>
+ <table>
+ <tr><td class="label">Username</td><td><input id="username" type="text" size="20" value="heslinki" /></td></tr>
+ <tr><td class="label">Session</td><td><input id="sessionid" type="text" size="45" /></td></tr>
+ <tr><td class="label">File</td><td><input id="file" type="file" /></td></tr>
+ <tr><td>&nbsp;</td><td><button id="buttonupload" onclick="upload()">upload</button></td></tr>
+ </table>
+ <div id="result" class="data"></div>
+ </div>
+ </body>
+</html>