https://github.com/intersystems-community/webterminal
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.
https://github.com/intersystems-community/webterminal
cacheobjectscript-udl intersystems intersystems-cache intersystems-ensemble intersystems-iris terminal terminal-emulators
Last synced: 5 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/intersystems-community/webterminal
- Owner: intersystems-community
- License: mit
- Created: 2013-07-11T11:10:04.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2024-04-24T21:27:43.000Z (about 2 years ago)
- Last Synced: 2024-04-24T22:30:00.357Z (about 2 years ago)
- Topics: cacheobjectscript-udl, intersystems, intersystems-cache, intersystems-ensemble, intersystems-iris, terminal, terminal-emulators
- Language: ObjectScript
- Homepage: https://intersystems-community.github.io/webterminal
- Size: 4.93 MB
- Stars: 78
- Watchers: 36
- Forks: 33
- Open Issues: 24
-
Metadata Files:
- Readme: readme.md
- Contributing: contributing.md
- License: license
Awesome Lists containing this project
README
# Web Terminal
[](https://t.me/joinchat/FoZ4M0jbeW8PVp2l5tqrgg)
Web-based terminal for InterSystems products. Access your database from everywhere!
+ Visit the [project's page](http://intersystems-community.github.io/webterminal) for more details.
+ **Download** the latest version from [here](http://intersystems-community.github.io/webterminal/#downloads).
+ Read more and discuss WebTerminal on [InterSystems Developer Community](https://community.intersystems.com/post/cach%C3%A9-webterminal-v4-release).
+ Read [complete documentation](http://intersystems-community.github.io/webterminal/#docs) about WebTerminal.
### Preview
Syntax highlighting & intelligent autocomplete!

Embedded SQL mode!

Even more features!

### 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 `` tag. Example:
```html
```
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.
```js
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:
```js
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](http://intersystems-community.github.io/webterminal/#docs.5).
To be short, the "hot start" is extremely easy. Having latest [Git](https://git-scm.com/) and
[NodeJS](https://nodejs.org/en/) installed (tested on NodeJS v4-8), execute the following:
```sh
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.