diff --git a/websh_front/public/index.html b/websh_front/public/index.html index 14968ff..d25f4fc 100644 --- a/websh_front/public/index.html +++ b/websh_front/public/index.html @@ -4,17 +4,62 @@ websh - diff --git a/websh_front/src/index.nim b/websh_front/src/index.nim index 91c07fc..c095659 100644 --- a/websh_front/src/index.nim +++ b/websh_front/src/index.nim @@ -22,6 +22,14 @@ type MediaObj = object name, data: cstring + ContentType = enum + ctInfo, ctHistory, ctStdout, ctStderr + + Content = object + ## 画面に表示するコンテンツ + typ: ContentType + text: string + const statusOk = cint(0) statusTimeout = cint(1) @@ -59,6 +67,11 @@ var hashTag = cstring"シェル芸" shellHistory: seq[string] + contents = @[ + Content(typ: ctInfo, text: "Welcome to websh!"), + Content(typ: ctInfo, text: "Run: `websh help`"), + ] + # localstorageにシェルの履歴が存在するときだけ取得 if localstorage.hasItem("history"): let hist = localstorage.getItem("history").`$`.parseJson.to(seq[string]) @@ -76,12 +89,14 @@ if 1 < query.len: proc respCb(httpStatus: int, response: cstring) = let resp = fromJson[ResponseResult](response) - outputStatus = resp.status - outputSystemMessage = resp.system_message - outputStdout = resp.stdout - outputStderr = resp.stderr - outputImages = resp.images - outputElapsedTime = resp.elapsed_time + contents.add(Content(typ: ctStdout, text: $resp.stdout)) + contents.add(Content(typ: ctStderr, text: $resp.stderr)) + # outputStatus = resp.status + # outputSystemMessage = resp.system_message + # outputStdout = resp.stdout + # outputStderr = resp.stderr + # outputImages = resp.images + # outputElapsedTime = resp.elapsed_time # シェルの実行中表示 OFF isProgress = false @@ -89,6 +104,7 @@ proc sendShellButtonOnClick(ev: Event, n: VNode) = # シェルの実行中表示 isProgress = true let images = inputImages.filterIt(it.name != cstring"").mapIt(it.data) let body = %*{"code": inputShell, "images": images} + contents.add(Content(typ: ctHistory, text: $inputShell)) ajaxPost(apiUrl, headers = @[ (cstring"mode", cstring"cors"), @@ -154,149 +170,196 @@ proc croppedUrl(): string = result = result[0..