Giter VIP home page Giter VIP logo

trefyrabe / sample-websocket-terminal Goto Github PK

View Code? Open in Web Editor NEW

This project forked from business-applications/sample-websocket-terminal

0.0 0.0 0.0 997 KB

This is a demo business application built with https://start.jbpm.org and expanded to create a process-driven websocket terminal.

Visual Basic 13.44% Java 25.51% Batchfile 7.97% Shell 12.37% CSS 5.00% HTML 15.04% JavaScript 20.66%

sample-websocket-terminal's Introduction

Business Applications by jBPM - Websocket Terminal

This is a demo business application built with https://start.jbpm.org and expanded to create a process-driven websocket terminal.

Sample of demo

In this demo we create a process driven websocket web terminal. Every command entered in the terminal starts our business process which then executes the command. We use websockets so that the results of the business process are dynamically updated on the terminal web page, without having to refresh the page at all.

Each command is evaluated by business rules which determine if the command entered is "dangerous" by comparing it to set of determined dangerous commands such as "delete", "reboot" etc, if the command is a weather command which are commands that request weather info such as "show temp for Atlanta,UNITED_STATES", or if this is a safe command to execut such as "ls -ltr", "pwd", or similar.

Demmo process

Getting Started

  1. Clone and build the needed kie server thymeleaf dialect project:
git clone https://github.com/tsurdilo/thymeleaf-kie-server-dialect.git
cd thymeleaf-kie-server-dialect
mvn clean install
  1. Clone this repository locally and start the demo app:
git clone https://github.com/business-applications/sample-websocket-terminal.git
cd sample-websocket-terminal
cd sample-websocket-terminal-service
chmod 755 launch.sh (only needed for unix environments , use launch.bat for windows)
./launch.sh (or launch.bat for windows)
  1. Setup an account for OpenWeatherMap (https://openweathermap.org/price) to get an access key for the free offer they have (Click on the "Get Api key an Start" button)

OpenWeatherMapApiKey

  1. Update the Workitem Handler with your OpenWeatherMap api key. In in sample-websocket-terminal-kjar/src/main/resources/META-INF/kie-deployment-descriptor.xml replace the YOUR_API_KEY_HERE:
    <work-item-handler>
      <resolver>mvel</resolver>
      <identifier>new org.jbpm.process.workitem.exec.ExecWorkItemHandler()</identifier>
      <parameters/>
      <name>Exec</name>
    </work-item-handler>
    <work-item-handler>
      <resolver>mvel</resolver>
      <identifier>new org.jbpm.process.workitem.owm.CurrentWeatherWorkitemHandler("YOUR_API_KEY_HERE")</identifier>
      <parameters/>
      <name>CurrentWeather</name>
    </work-item-handler>
    <work-item-handler>
      <resolver>mvel</resolver>
      <identifier>new org.jbpm.process.workitem.owm.DailyForecastWorkitemHandler("YOUR_API_KEY_HERE")</identifier>
      <parameters/>
      <name>DailyForecast</name>
    </work-item-handler>

with the real api key you get after registering on the OpenWeatherMap.

  1. go to sample-websocket-terminal-service and start the appliaction:

for Windows users:

launch.bat clean install

or for Unix/Linux users

chmod 755 launch.bat (only has to be done once)
./launch.sh clean install

Note that step 3 here is optional and if you would rather not go through the process of setting up an api key on OpenWeatherMap it is ok. In this case skip step 3 and keep "YOUR_API_KEY_HERE" as is in step 4. Your app will run fine, you just will not be able to get results for commands that start with "show temp for".

Accessing your application

Once the app has started you can access the landing page at

localhost:8090/demo

Depending on the system you are running on you can start entering commands into the Terminal and results will be dynamically posted. For example if running on Unix based systems some sample commands could be

ls -ltr
whoami
pwd

etc. For DOS users you can use the dos based commands and try them out. If running on OSX you can enter OSX commands as well, for example:

open -t
open -a firefox someFile.someFileExtension

If you have dont step 3 of the "Getting Started" section, your business app can get us the current weather information as well. For this you can enter into the terminal for example:

show temp for Atlanta,UNITED_STATES
show temp for Londin,UNITED_KINGDOM
show temp for Warshaw,POLAND
etc etc

Special thanks to Andrew Barfield (https://gist.github.com/AndrewBarfield) as this demo uses a (heavily) modified version of his HTML web terminal implementation that you can find here: https://gist.github.com/AndrewBarfield/3ee59402501422cdec47

sample-websocket-terminal's People

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.