diff --git a/export/template.xml b/export/template.xml index 72f6318..243c74a 100644 --- a/export/template.xml +++ b/export/template.xml @@ -2,8 +2,8 @@ -Cache WEB Terminal vX.X.X/*build.replace:pkg.version*/ -This class is the core of web terminal application. +Cache WEB Terminal version X.X.X/*build.replace:pkg.version*/ core. +This class is the server-side core of the terminal application. %CSP.WebSocket,%Library.Routine 63891,56786.028532 @@ -835,9 +835,8 @@ This method transforms error set httprequest = ##class(%Net.HttpRequest).%New() set httprequest.Server = "intersystems-ru.github.io" do ..SendData("34", ..#ConstClientOutputLocalized) - do ..SendData(" http://intersystems-ru.github.io/webterminal/files/WebTerminal-" - _ version _ ".xml ") - do httprequest.Get("/webterminal/files/WebTerminal-" _ version _ ".xml") + do ..SendData(" http://intersystems-ru.github.io/webterminal/files/" _ version _ ".xml ") + do httprequest.Get("/webterminal/files/" _ version _ ".xml") if (httprequest.HttpResponse.StatusCode '= 200) { do ..SendData($C(27)_"[31mFAIL" _ $C(27) _ "[0m (status code " _ httprequest.HttpResponse.StatusCode _ ")" _ $C(13,10)) @@ -848,14 +847,32 @@ This method transforms error do ..SendData($C(13,10)) do ..SendData("35", ..#ConstClientOutputLocalized) do ..SendData($C(13,10)) - set stload = $System.OBJ.LoadStream(httprequest.HttpResponse.Data,"",.error,.items) - if $$$ISERR(stload) { do ..SendData($System.Status.GetErrorText(stload)) quit $$$NOTOK } - set st2 = $System.OBJ.CompileList(.items) - if $$$ISERR(st2) { do ..SendData($System.Status.GetErrorText(st2)) quit $$$NOTOK } - if $$$ISERR(error) { - do ..SendData($C(27)_"[31mFAILED" _ $C(27) _ "[0m" _ $C(13,10)) + do ..SendData("Moving back to terminal's home namespace " _ ..InitialZNamespace _ "...") + zn ..InitialZNamespace + do ..StartClearIO() + set stload = $System.OBJ.LoadStream(httprequest.HttpResponse.Data, "", .error, .items) + if $$$ISERR(stload) { + w $C(27)_"[31mFAILED" _ $C(27) _ "[0m " _ $System.Status.GetErrorText(stload) quit $$$NOTOK } + set logFileName = ##class(%File).SubDirectoryName(##class(%File).ManagerDirectory(),"CWTUpdateLog.txt") + open logFileName:("NRW"):5 + set io = $IO + use logFileName + set st2 = $System.OBJ.CompileList(.items, "cuk /checkuptodate=none") + close logFileName + use io + if $$$ISERR(st2) { write $System.Status.GetErrorText(st2) quit $$$NOTOK } + do ..EndClearIO() + if ##class(%File).Exists(logFileName) { + set stream = ##class(%Stream.FileCharacter).%New() + set sc = stream.LinkToFile(logFileName) + while 'stream.AtEnd { + set line = stream.Read() + do ..SendData(line) + } + do ##class(%File).Delete(logFileName) + } } quit $$$OK ]]> @@ -1056,12 +1073,17 @@ Main method for every new client. } elseif (action = ..#ConstServerActionCheckUpdate) { - do ..CheckUpdate() + if ('$$$ISOK(..CheckUpdate())) { + do ..SendData($NAMESPACE, ..#ConstClientPrompt) + } } elseif (action = ..#ConstServerActionUpdate) { - do ..Update(data) - do ..SendData("39", ..#ConstClientOutputLocalized) + if $$$ISOK(..Update(data)) { + do ..SendData("39", ..#ConstClientOutputLocalized) + } else { + do ..SendData($NAMESPACE, ..#ConstClientPrompt) + } } else { // something scary @@ -1171,9 +1193,11 @@ This method is invoked when a class is compiled. } w !, "Mapping %WebTerminal package into all namespaces:" set mapTo = $LISTBUILD("%All", "SAMPLES", "DOCBOOK") - set Properties("Database") = "CACHETEMP" + do ##Class(Config.Namespaces).Get("USER", .InstallNSProps) + set Properties("Database") = $get(InstallNSProps("Routines")) set ptr = 0 while $LISTNEXT(mapTo, ptr, value) { + continue:(ns = value) w " ", value set status = ##Class(Config.MapPackages).Create(value, "WebTerminal", .Properties) if ($$$ISERR(status)) { @@ -1212,6 +1236,7 @@ This method is invoked when a class is 'uncompiled'. set mapTo = $LISTBUILD("%All", "SAMPLES", "DOCBOOK") set ptr = 0 while $LISTNEXT(mapTo, ptr, value) { + continue:(ns = value) w " ", value set status = ##Class(Config.MapPackages).Delete(value, "WebTerminal") if ($$$ISERR(status)) { @@ -1230,6 +1255,7 @@ This method is invoked when a class is 'uncompiled'. The REST interface: class that routes HTTP requests +StaticContent %CSP.REST 63890,69646.001045 diff --git a/package.json b/package.json index b84ee7e..14c7431 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,8 @@ "title": "Cache WEB Terminal", "description": "Web-based terminal emulator for Caché administering.", "author": "ZitRo", - "version": "3.1.1", - "releaseNumber": 13, + "version": "3.1.4", + "releaseNumber": 15, "repository": { "type": "git", "url": "https://github.com/intersystems-ru/webterminal.git" diff --git a/readme.md b/readme.md index 2ed22d2..518c3ac 100644 --- a/readme.md +++ b/readme.md @@ -4,7 +4,8 @@ Web-based terminal application for InterSystems Caché database. Access your dat Visit [project page](http://intersystems-ru.github.io/webterminal) for more details. ### Installation -Download latest version from project page and import XML file into %SYS namespace. Make sure that you have enabled write access to CACHELIB database during installation process. Later you can update application by typing "/update" command. +Download the latest version from project page +and import XML file into %SYS namespace. Later you can update application only by typing `/update` command. ### Usage After installation, you will be able to access application at `http://[host]:[port]/terminal/` (slash at the end is required). @@ -50,7 +51,7 @@ Type "/help" there to get more information. Self-update - Second version of terminal can be automatically updated by one command. + Terminal v3.1.4 can be automatically updated by `/update` command. Explore! @@ -62,15 +63,15 @@ Type "/help" there to get more information. We are glad to see anyone who want to contribute to Caché WEB Terminal development! Check the [developer's](https://github.com/intersystems-ru/webterminal/blob/master/DEVELOPMENT.md) guide. -In short, the "hot start" is extremely easy. Having latest [NodeJS](https://nodejs.org/en/) installed, +In short, the "hot start" is extremely easy. Having latest [Git](https://git-scm.com/) and [NodeJS](https://nodejs.org/en/) installed, execute the following: ```sh -git clone -cd -npm install -g gulp -npm install -gulp +git clone # clone this repository into new directory +cd # enter just created directory +npm install -g gulp # install the global module "gulp" to build the project +npm install # install all project's dependencies +gulp # build the project ``` Now, in `build` folder you will find `CacheWebTerminal-v*.xml` file ready to import. Every time you diff --git a/webSource/js/TerminalController.js b/webSource/js/TerminalController.js index c7bec0c..67d5fb4 100644 --- a/webSource/js/TerminalController.js +++ b/webSource/js/TerminalController.js @@ -533,11 +533,10 @@ TerminalController.prototype.clientAction = { PROMPT_UPDATE: function (data) { var _this = this, - version, - releaseNumber = data.split("#"); - - version = releaseNumber[1]; - releaseNumber = parseInt(releaseNumber[0]); + parts = data.split("#"), + version = parts[1], + releaseNumber = parseInt(parts[0]), + comment = parts[2] || ""; if (!version || !releaseNumber) { console.error("Unable to parse version data: ", data); @@ -547,8 +546,9 @@ TerminalController.prototype.clientAction = { if (releaseNumber > this.TERMINAL.RELEASE_NUMBER) { this.TERMINAL.output.print(this._lc.get(23) + "\r\n"); this.TERMINAL.input.prompt("", 1, function (string) { - if (string.toLowerCase() === "y") { + if (string === "" || string.toLowerCase() === "y") { _this.TERMINAL.output.print(" " + _this._lc.get(24) + "\r\n"); + if (comment) _this.TERMINAL.output.print("\r\n" + comment + "\r\n\r\n"); _this.server.send(_this.SERVER_ACTION.UPDATE + version); } else { _this.clientAction["PROMPT"].call(_this, _this.NAMESPACE); diff --git a/webSource/js/TerminalLocalization.js b/webSource/js/TerminalLocalization.js index 6c8a5c1..59fac79 100644 --- a/webSource/js/TerminalLocalization.js +++ b/webSource/js/TerminalLocalization.js @@ -202,12 +202,10 @@ var TerminalLocalization = function (TERMINAL) { ru: "Авторизация не удалась." }, 23: { - en: "A new version of Caché WEB Terminal available. Would you" + - "like to install it? (Make sure that user has write permission to CACHELIB " + - "database) (Y/N)", + en: "A new version of Caché WEB Terminal available. Would you " + + "like to install it? (Y/n)", ru: "Новая версия Caché WEB Terminal доступна. Хотите ли вы " + - "установить её? (Убедитесь, что пользователь имеет права на запись в базу " + - "данных CACHELIB) (Y/N)" + "установить её? (Y/n)" }, 24: { en: "Updating...",