Giter Club home page Giter Club logo

intersystems-community / webterminal Goto Github PK

View Code? Open in Web Editor NEW
78.0 36.0 33.0 5.05 MB

The first and the most powerful web-based terminal for InterSystems IRIS®, InterSystems Caché®, Ensemble®, HealthShare®, TrakCare® and other products built on top of InterSystems Data Platforms.

Home Page: https://intersystems-community.github.io/webterminal

License: MIT License

JavaScript 33.39% HTML 0.15% Batchfile 0.20% ObjectScript 64.88% SCSS 1.32% Dockerfile 0.06%
intersystems intersystems-cache intersystems-ensemble terminal-emulators terminal cacheobjectscript-udl intersystems-iris

webterminal's Introduction

Web Terminal

Gitter

Web-based terminal for InterSystems products. Access your database from everywhere!

Preview

Syntax highlighting & intelligent autocomplete!

2016-09-18_212035

Embedded SQL mode!

2016-09-18_212244

Even more features!

2016-09-18_212325

Key Features

Native browser application Allows to access Caché terminal both from desktop and mobile devices.
Autocompletion Type faster. Autocomplete is available for class names, variable and global names, methods, properties, etc.
Tracing Monitor any changes in globals or files.
SQL mode A convenient way to execute SQL queries.
Syntax highlighting Intelligently highlighted input both for ObjectScript and SQL.
Favorites Save commands you execute frequently.
Security All you need is to protect /terminal/ web application, and all sessions are guaranteed to be secure.
Self-updating WebTerminal of version 4 and higher prompts to update automatically when new version is available, so you will never miss the important update.
Explore! Enjoy using WebTerminal!

Installation

Download the latest version from the project page and import downloaded XML file into any namespace. Compile imported items and the WebTerminal is ready!

Usage

After installation, you will be able to access application at http://[host]:[port]/terminal/ (slash at the end is required). Type /help there to get more information.

Integration and WebTerminal's API

To embed WebTerminal to any other web application, you can use <iframe> tag. Example:

<iframe id="terminal" src="http://127.0.0.1:57772/terminal/?ns=SAMPLES&clean=1"></iframe>

Note that terminal URL may include optional GET parameters, which are the next:

  • ns=USER Namespace to open terminal in. If the logged user has no access to this namespace, the error message will appear and no namespace changes will occur.
  • clean Start the WebTerminal without any additional information printed. It is not recommended to use this option if you are using terminal as a stand-alone tool (for everyday use), as you can miss important updates.

To use WebTerminal's API, you need to get WebTerminal instance first. Use iframe's onTerminalInit function to get it.

document.querySelector("#terminal").contentWindow.onTerminalInit(function (terminal) {
    // now work with terminal object here!
});

This function is triggered after WebTerminal establish an authorized connection.
The next table demonstrates available API. Left column are terminal object properties.

Function Description
execute(command, [options], [callback]) Executes the ObjectScript command right as if it is entered to the terminal. However, options provide an additional flags setup.
options.echo (false by default) - prints the command on the screen.
options.prompt (false by default) - prompts the user after execution (prints "NAMESPACE > " as well). If callback is passed, the output buffer will come as a first argument of the callback function.
onOutput([options], callback) By default, callback(strings) will be called before the user is prompted for input, and strings array will always contain an array of chunks of all the text printed between the prompts. For example, if user writes write 123 and presses "Enter", the strings will contain this array: ["\r\n", "123", "\r\n"]. However, when user enters write 1, 2, 3, strings will result with ["\r\n", "1", "2", "3", "\r\n"]. You can join this array with join("") array method to get the full output.
Optional options object may include stream property, which is false by default. When set to true, callback will be fired every time something is printed to the terminal simultaneously.
onUserInput(callback) callback(text, mode) is fired right after user presses enter. Argument text is a String of user input, and mode is a Number, which can be compared with one of the terminal mode constants, such as MODE_PROMPT.
removeCallback(callback) Remove any previously assigned callback. Any function which accepts callback returns it, and you can pass the callback here once you no longer need it to stop it from firing.
print(text) Prints text which can include special characters and escape sequences. This function is input-safe, and you can print event when terminal is requesting for input without disrupting input. In this case the input will reappear right after text printed.
Constant Description
MODE_PROMPTRegular input (ObjectScript command)
MODE_SQLInput in SQL mode (SQL command)
MODE_READPrompt issued by ObjectScript read c command
MODE_READ_CHARPrompt issued by ObjectScript read *c command
MODE_SPECIALSpecial CWT's input (commands like /help, /config etc)

The next example demonstrates a way to intercept terminal's input:

let iFrame = document.querySelector("#terminal");

function myInitHandler (terminal) {
    terminal.execute("set hiddenVariable = 7", {
        echo: false // the default is false, this is just a demo
    });
    terminal.onUserInput((text, mode) => {
        if (mode !== terminal.MODE_PROMPT)
            return;
        terminal.print("\r\nYou've just entered the next command: " + text);
    });
    terminal.onOutput((chunks) => {
        // If you "write 12", chunks are ["\r\n", "12", "\r\n"].
        // If you "write 1, 2", chunks are ["\r\n", "1", "2", "\r\n"].
        if (chunks.slice(1, -1).join("") === "duck") { // if the user enters: write "duck"
            alert(`You've found a secret phrase!`);
        }
    });
}

// At first, handle iFrame load event. Note that the load handler won't work
// if this code is executed at the moment when iFrame is already initialized.
iFrame.addEventListener("load", function () {
    iFrame.contentWindow.onTerminalInit(myInitHandler); // handle terminal initialization
});

WebTerminal Project Development

We are glad to see anyone who want to contribute to Web Terminal development! Check our developer's guide.

To be short, the "hot start" is extremely easy. Having latest Git and NodeJS installed (tested on NodeJS v4-8), execute the following:

git clone https://github.com/intersystems-community/webterminal
cd webterminal # enter repository directory
import         # build & import the project. YOU NEED TO EDIT CONSTANTS IN THIS FILE FIRST

Now, in build folder you will find WebTerminal-v*.xml file. Every time your changes are ready to be tested, just run import again.

webterminal's People

Contributors

daimor avatar eduard93 avatar evshvarov avatar gevorg95 avatar gjsjohnmurray avatar logist avatar makarovs96 avatar natalietrykush avatar nikitaeverywhere avatar scottbeeson avatar sergeymi37 avatar suitcaser avatar tsafin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

webterminal's Issues

Problems With Importing XML

I'm running:
Cache for Windows (x86-64) 2014.1.2 (Build 753U) Tue Jul 22 2014 11:14:30 EDT

After creating the '/csp/sys/webterminal/' application and mounting CACHELIB RW, I try to import the XML file WebTerminal-2.0.0-beta.2.xml and I get the following:

------------''Load started on 09/29/2014 07:34:09
Loading file \vmware-host\Shared Folders\Desktop\WebTerminal-2.0.0-beta.2.xml as xml
Imported class: %WebTerminal.Engine
Imported CSP/CSR or file: csp/sys/webterminal/css/base.css
Imported CSP/CSR or file: csp/sys/webterminal/css/terminal-theme-cache.css
Imported CSP/CSR or file: csp/sys/webterminal/css/terminal.css
ERROR #6301 Line: 1468 Offset: 67 ERROR #5912: Page '/csp/sys/webterminal/favicon.ico' does not exist Will skip this item.
ERROR #6301 Line: 1493 Offset: 59 ERROR #5912: Page '/csp/sys/webterminal/index.CSP' does not exist Will skip this item.
Imported CSP/CSR or file: csp/sys/webterminal/js/terminal.js
Detected 2 errors during load.


Anybody know how to fix this?

Unexpected redirect from 80 port

I'm opening the following page:http://ip/terminal/
And receive the following output:

WebSocket connection error (ws://ip:57776/WebTerminal.Engine.cls). Trying to connect again in 10 seconds...

WebSocket connection closed. Code 1006, reason: .

So why 57776 port?
Expected behavior:

  • if port is in url, connect to the same port
  • if no port is present in url
    • if protocol is http connect to 80 port
    • if protocol is https connect to 443 port

Give the user control of how text antialiasing is made

When working with dark text on light background, grayscale antialiasing is preferred
(the text looks lighter).
On the other hand, with white text on dark background, subpixel antialiasing is better, because the text looks bolder.

Please give the control over this to the user,
or switch the antialiasing method along with the UI theme.

This gist explains which CSS properties are in charge of the desired behaviour.

Support for system methods in autocomplete

2016.1 bought us system methods.
For example:

set consumedJSON = ##class(%AbstractObject).$fromJSON(someJSONstring)

To add support for system methods we need to:

  • on a server side modify WebTerminal.Autocomplete:GenerateAutocomplete method
  • on a client side?

Do we add another category for system methods or add them to other methods?

You can check if systems methods are defined via:

w ##class(%Dictionary.PropertyDefinition).IDKEYExists("%Dictionary.ClassDefinition","SystemMethods")

Another question - why do we parse %Dictionary.ClassDefinition for properties/methods instead of %Dictionary.CompiledClass

Problem with installation not from Studio

Tried to install from class Explorer in Management Portal.
Imported file and then there were some errors during compilation.

System is Cache 2015.1 on Linux.
Then I tried to do 'normal' installation through Studio and compilation went with no problems though app doesn't work. I have 401 error when go to server/terminal/

Would it be possible to support this type of installation?
What should I do now to let webterminal work?

autocomplete on win doesn't work

version 0.9.9.9.8
Autocomplete result on Win7:

Loading Caché language for %
Loading Caché language for USER
Language for% load fail.
Language forUSER load fail.

Programmer mode

You can run the %PMODE Intersystems Routine to enter programmer mode instead of executing the commands entered. Because we can't ZLOAD a Routine and PRINT it.
When we run the PRINT command it displays your Routine.
I think your next project should be a Routine Screen Editor running under your WebTerminal.

Refactoring of WebTerminal.Engine class

I propose refactoring of WebTerminal.Engine class into following classes:

  • WebTerminal.Parameters - contains parameters
  • WebTerminal.Redirects - extends %Library.Routine and contains methods working with redirects
  • WebTerminal.Actions - contains user actions (ExecuteCommand, ExecuteSQL Update, Tracking etc)
  • WebTerminal.Autocomplete - contains autocomplete logic
  • WebTerminal.Engine - extends all previous classes, contains OnMethods, Server, ClientLoop

I'm not sure about exact class structure, but that's the gist of it.
Would make for an easier reading.

Required application roles on install with Normal security settings

App: /terminalsocket in USER namespace requires %DB_CACHESYS and %DB_USER so UnknownUser can access it.

Here's an audit message without %DB_CACHESYS so we can maybe remove the dependency. Namespace routines db needs to have public RW (maybe R is enough?) resource, or if not, role given to web app.

Audit Details:
Description Attempt to access a protected resource
Timestamp 2016-02-12 16:05:09.226
UTCTimestamp 2016-02-12 21:05:09.226
Event Source %System
Event Type %Security
Event Protect
Username UnknownUser
Pid 23104
JobId 2424862
JobNumber 30
IP Address
Executable CSPap.so
System ID
Index 16384
Roles %DB_%DEFAULT,%DB_CACHE,%DB_USER
Authentication Unauthenticated
Namespace USER
Routine zRequireAuthorization+19^WebTerminal.Engine.1 |"^^/InterSystems/Cache/mgr/user/"|
User Info
O/S Username CSP Gateway
Status
Event Data zRequireAuthorization+19^WebTerminal.Engine.1 */InterSystems/Cache/mgr/

Namespace changing

After fixing read issue, namespace change command crashes connection.

Autocomplete in 2014.2

В новой версии стало дополнительно возвращать INFORMATION.SCHEMA для любой области в %ClassDefinition:ClassInfo из-за чего webterminal/autocomplete/%NameSpase%.js формируется дольше

Merged branches remove

@eduard93, are you OK to delete ConstRefactoring, Gitignore, Refactoring and ParamsBranch just to keep repository clean? All the changes were merged to master, so I think we should finish with these branches.

webterminal does not work with Cache 2016.1.0 and later

cache2016.1.0 is not released yet, but I thought you'd want to know that you get a code 1006 from websockets immediately upon entering credentials into host:port/terminal/

I love the tool, thanks for your hard work in creating it.

Rewrite autocomplete mechanism

Current autocomplete mechanism does not use a lot of useful features so it has to be rewritten:

  1. No inline autocomplete: set cls = ##class(...).%New() write cls.<Nothing here>
  2. No private/public method/classmethod classification: do ##class(...).Method - incorrect, because Method is not ClassMethod;
  3. No inherited methods/properties/etc - implementing this over current autocomplete tactics would just overlap browser storage which is limited (5MB for FF, 10 for GC, etc) and also decrease performance;
  4. Etc.

ToDo list:

  • Rewrite basic autocomplete lexical mechanism;
  • Replace static one-time generated AC with dynamic loaded AC;
  • Suggesting class names;
  • Support for class constructions: do ##class(...).<suggest>;
  • Associating variable name with class type assigned to it;
  • Support for variable constructions: set a = ##class(...).%New() -> write a.<suggest>;
  • ClassMethods support;
  • Properties/Parameters support;
  • ClassMethods differ from Methods and private methods support;
  • Routine support;
  • Support of recursive reference constructions: write a.Methods.<suggest>;

[ Subject to be updated ]

How close the session

How i can close the session in the webterminal?, with the letter "h" close the conection but when I update my page with "F5" the session is connecting again.

WebTerminal plugins

How about to let people make WEB Terminal plugins? Having WebTerminal API made, I see the good way for people to contribute their own features and applications like #32 specifically for WebTerminal.

Plugin will consist of two parts: client and server (optional) code. It can both extend client functionality by adding, f.e. new commands or GUI features, and also implement any server-side handlers.

This requires a good WebTerminal API, by the way, but I see all this quite implementable.

Caché WEB Terminal v4

Major update is coming. It should fix a lot of fails with the terminal I/O and improve user experience.

You can download an alpha version today!

Before the release there is some work in progress:

  • Refactor and prepare the repository:
    • Replace XML with UDL *.cls;
    • Improve back-end build scripts;
    • Replace ES5 JavaScript with ES6 JavaScript modules;
    • Improve JavaScript build scripts;
    • Restore favorites feature;
    • Restore tracing feature.
  • Improve back end:
    • Rewrite WebTerminal's core, implement interprocess communication via $System.Event;
    • Test EscapeSequencesDemo.mac utility.
  • Sync backend and frontend:
    • Change messaging protocol to JSON.
  • Improve front end:
    • Fix centering layout (make it not centering, as it causes inconsistent view in case when WebTerminal is a frame);
    • Fix multi-line input caret position accuracy;
    • Fix input capturing behavior;
    • Fix mobile input;
    • Rewrite output core;
    • Test escape sequences, including case #63.
  • Improve installer:
    • Complete issue #46;
    • Add installation statistics collection.
  • Improve updater:
    • Auto-update check #64;
    • Review update mechanism.
  • WebTerminal client API
    • Print;
    • Execute (#68).
  • Syntax Highlighting
    • Intelligent syntax highlighting core;
    • Basic set of rules;
    • Extended set of rules;
    • Advanced set of rules.
  • Autocomplete (#58) (acceptable for the release)

[Subject to change]

You are welcome to suggest/discuss any changes that have to be included in v4 release!

Enable custom title

Make page title configurable, so user can set arbitrary title via global.

Right now title is hardcoded to ”Caché WEB Terminal” and if working with multiple Cache' instances it's impossible to differentiate one instance's terminal from another.

Summary of the enhancement:
<title>#($g(^global,”Cach&eacute; WEB Terminal”)#</title>

We can optionally autogenerate title based on instance name, but one should be able to override it - autogenerated title based on server address or instance name would be useless in the situations like multiple identical instances (ECP App servers) in the cloud. Titles like DBSERVER, APPSERVERn would be more appropriate.

Run index.csp with namespace as parameter

Предлагаем запускать index.csp с параметром в который передаётся область для того что бы была возможность отрывать не в %SYS

Authorisation while connected to VPN

Hi, thanks for this nice project!
When connected over VPN, a successful login over the socket connection is not initiated. The following error occurs:
system > Authorisation failed.
system Connection terminated: code 1005

Enhance WebTerminal.Installer code to remove WebTerminal correctly for any case

The next cases are covered by current installer:

  1. Installing/uninstalling WebTerminal to/from particular namespace;
  2. Updating WebTerminal using /update command (terminal will jump into "home" namespace during update);
    The next has to be covered:
  • User removes packages from namespace classes are mapped to - installer won't change the namespace to the WebTerminal's "home" namespace as it should be;
  • When /update'ing terminal, new classes overwrite old classes, but do not delete any old classes. We should implement this deletion as soon as possible to avoid possible bugs and conflicts when renaming/moving classes in future releases.

Update autocomplete base for namespace only

When I add new classes in a particular namespace /autocomplete new takes for me too much time - because it loads system class definitions too.
It's not convenient if I just wanna update classes in one namespace.

Is it possible to update from server only particular namespace's classes if I call /autocomplete new in particular namespace?

Fix slow client parser

While executing command like for i=1:1:500 w i client spends too much time for parsing (because of re-parsing every time package received)

"w #" doesn't clear the screen buffer

w # should clear the screen, like in a regular terminal.
Currently it doesn't.

It looks like either even complex commands like

w 1, 2, 3, #, 4, 5, 6

need to be parsed, or, alternatively, the Web Terminal should support at least some of the ANSI escape sequences which come in the server's response. Still, this particular issue may have nothing to do with ANSI escape sequences: if you execute

echo 'w 1, 2, 3, !, 4, 5, 6 h' | /opt/intersystems/cache/2014.1.0/bin/cache -s /opt/intersystems/cache/2014.1.0/mgr

-- you'll see 123 and 456 separated with 0x0A (\n, ^J) in the server response, while in

echo 'w 1, 2, 3, #, 4, 5, 6 h' | /opt/intersystems/cache/2014.1.0/bin/cache -s /opntersystems/cache/2014.1.0/mgr

response the same tokens are separated with 0x0D0C (\r\f, ^M^L).

check updates tag

Add /checkupdate tag to check for updates on the release site and suggest update if there is new release.
Perform update as well.

Problem generating autocompletion database

When using v0.9.9 and trying to build an autocompletion database on Mac:

Cache for UNIX (Apple Mac OS X for x86-64) 2014.2 (Build 212U Experimental) Thu Feb 27 2014 00:38:53 EST

-- I receive the following error message:

%SYS
Loading Caché language for %
%SYS
�Generating language file for %SYS, pleace, wait. Language for% load fail.� Language file for %SYS generated.
%SYS
Loading Caché language for %SYS
%SYS
Language for%SYS load fail.

SeaMonkey (Gecko), Windows:
SeaMonkey (Gecko), Windows.png
SeaMonkey (Gecko), Mac OS X:
SeaMonkey (Gecko), Mac OS X.png
Chromium, Mac OS X:
Chromium, Mac OS X.png

% global rename

^%WebTerminal globals should now be called ^WebTerminal I suppose

Fix read

There are some redundant characters at start when trying to read something using, for example, read myVar command.

Terminal fails to update with /update command

This command throws different errors in Caché 2014/2015.

2014
ERROR #5809: Object to Load not found, class '%Dictionary.CompiledProperty', ID '%CSP.WebSocket||WSClassProtocolVersion'

2015
<Status OK, but loads nothing>

Probably the algorithm is wrong:

  1. Write temporary xml file to disk from WEB using do file.CopyFrom(httprequest.HttpResponse.Data);
  2. Perform do $System.OBJ.ImportDir(path, "terminal_update.temp.xml", "ckbud", .error, 1) to import new code;
  3. Remove temporary file.

Any suggestions are welcome.

Convert CSP to CLS

My suggestion is to use webterminal.cls extended from %CSP class.
As the result there will be no phisical CSP file, but all the code in CACHE clasees and js.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.