Skip to content

Commit

Permalink
Merge pull request #137 from jiro4989/develop
Browse files Browse the repository at this point in the history
画面に処理時間を表示できるようにした
  • Loading branch information
mergify[bot] authored Feb 3, 2020
2 parents 05ca69d + 6a47f33 commit 27fe1fb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ name: test

on:
push:
paths-ignore:
- 'LICENSE'
- 'README.*'
- '*/README.*'
- 'docs/*'
release:
types: [published]

Expand Down
7 changes: 5 additions & 2 deletions websh_front/src/index.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type
stdout: cstring
stderr: cstring
images: seq[ImageObj]
elapsed_time: cstring
ImageObj = object
image: cstring
filesize: cint
Expand All @@ -39,6 +40,7 @@ var
outputStdout = cstring""
outputStderr = cstring""
outputImages: seq[ImageObj]
outputElapsedTime = cstring"0milsec"
isProgress: bool
## シェルの実行中表示を切り替えるためのフラグ

Expand All @@ -49,6 +51,7 @@ proc respCb(httpStatus: int, response: cstring) =
outputStdout = resp.stdout
outputStderr = resp.stderr
outputImages = resp.images
outputElapsedTime = resp.elapsed_time
# シェルの実行中表示 OFF
isProgress = false

Expand Down Expand Up @@ -102,9 +105,9 @@ proc createDom(): VNode =
if isProgress:
text "Running ..."
elif outputStatus != statusOk:
text outputSystemMessage
text &"{outputSystemMessage} ({outputElapsedTime})"
else:
text "none"
text &"none ({outputElapsedTime})"

# 入力、出力スペース
tdiv(class = "columns is-desktop"):
Expand Down
7 changes: 4 additions & 3 deletions websh_server/src/websh_server.nim
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ proc runCommand(command: string, args: openArray[string], timeout: int = 3): (st

router myrouter:
post "/shellgei":
let now = now()
try:
let now = now()
let uuid = $genUUID()
var respJson = request.body().parseJson().to(ReqShellgeiJSON)
info "uuid", uuid, "json", respJson
Expand Down Expand Up @@ -163,11 +163,12 @@ router myrouter:

let elapsedTime = $(now() - now).inMilliseconds & "milsec"
info "uuid", uuid, "elapsedTime", elapsedTime, "msg", "complete"
resp %*{"status":status, "system_message":systemMsg, "stdout":stdoutStr, "stderr":stderrStr, "images":images}
resp %*{"status":status, "system_message":systemMsg, "stdout":stdoutStr, "stderr":stderrStr, "images":images, "elapsed_time":elapsedTime}
except:
let msg = getCurrentExceptionMsg()
error "msg", msg
resp %*{"status":statusSystemError, "system_message":"System error occured.", "stdout":"", "stderr":"", "images":[]}
let elapsedTime = $(now() - now).inMilliseconds & "milsec"
resp %*{"status":statusSystemError, "system_message":"System error occured.", "stdout":"", "stderr":"", "images":[], "elapsed_time":elapsedTime}
get "/ping":
resp %*{"status":"ok"}

Expand Down

0 comments on commit 27fe1fb

Please sign in to comment.