Skip to content

Commit ebfde8c

Browse files
Working installer and static application
1 parent 4413475 commit ebfde8c

File tree

12 files changed

+172
-64
lines changed

12 files changed

+172
-64
lines changed

README.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# iKnow Entity Browser<sup>[development]</sup>
1+
# InterSystems iKnow Entity Browser
22

3-
A visualizer of iKnow entities.
3+
A visualizer of iKnow entities for IntersSystems iKnow on 2016.2+ platforms.
44

55
Preview
66
-------
@@ -12,6 +12,16 @@ Preview
1212
<img src="https://cloud.githubusercontent.com/assets/4989256/24322376/d1d40878-116b-11e7-98fe-f1b86ff2085a.png" width="430" align="center">
1313
</p>
1414

15+
Installation
16+
------------
17+
18+
Download the latest release and import XML file to Caché (iKnow-enabled namespace). Then, open your
19+
browser at `http://localhost:57772/EntityBrowser/` web page (change the host/port respectively to
20+
your server's addresses and always add the trailing slash `/` at the end of the URL).
21+
22+
To delete the application, simply delete the `EntityBrowser` package, the web application will be
23+
deleted automatically as well as it gets created during installation.
24+
1525
Usage
1626
-----
1727

@@ -59,7 +69,7 @@ Development
5969

6070
Requires [Node.JS](https://nodejs.org) (v4.0.0-7.5.0+) (but may work on previous versions),
6171
[Git](https://git-scm.com) and
62-
[Caché](http://www.intersystems.com/library/software-downloads/) 2017.1+
72+
[Caché](http://www.intersystems.com/library/software-downloads/) 2016.2+
6373
to be installed.
6474

6575
To install & test, open up a terminal and execute the following set of commands:
@@ -73,13 +83,12 @@ npm run gulp
7383

7484
Then, open `build/static/index.html` file.
7585

76-
To install the REST client, change the constants in the `import.bat` file and then run the
77-
following:
86+
To install application directly to Caché, modify the constants in the `import.bat` file and then run
87+
it with the following command:
7888

7989
```bash
8090
import
8191
```
8292

83-
This will put `src/cls/EntityBrowser/Router.cls` class into your Caché (change the `import.*`
84-
script), and after you set up a web application, go to configure app settings by clicking setting
85-
button in the top right corner.
93+
This will build the project and put all `src/cls/*` classes into your Caché. Also, this will
94+
export XML file that can be imported to any Caché system (2016.2+).

gulpfile.babel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const
1515
APP_NAME = `EntityBrowser`,
1616
SOURCE_DIR = `${ __dirname }/src`,
1717
BUILD_DIR = `${ __dirname }/build`,
18-
STATIC_DATA_FILE = `${ SOURCE_DIR }/cls/${ APP_NAME }/REST/StaticData.cls`,
18+
STATIC_DATA_FILE = `${ SOURCE_DIR }/cls/${ APP_NAME }/StaticData.cls`,
1919
context = {
2020
package: pkg
2121
};

import.cmd

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
11
:: This batch script makes the Caché application deployment much faster by building and importing the project.
22
:: Replace the variables below to match your Caché installation and build & import application to Caché using only one command.
3-
43
:: Caché 2016.2+ IS REQUIRED TO PROCEED
5-
@echo off
64

7-
:: CHANGE THIS PATH TO YOUR CACHÉ INSTALLATION PATH ON WINDOWS (folder that contains bin, CSP, mgr and other folders)
5+
:: Configurable variables: change them to fit your system ::
86
set CACHE_DIR=C:\Program Files\InterSystems\Ensemble
9-
:: NAMESPACE TO IMPORT PACKAGE TO
107
set NAMESPACE=SAMPLES
11-
:: Other variables
12-
set BUILD_DIR=build\cls
13-
:: set BUILD_STATIC_DIR=build\static
14-
:: set CSP_DIR=C:\Program Files\InterSystems\Ensemble\CSP\samples\EntityBrowser
15-
:: User credentials. Remove if necessary.
168
set USERNAME=_SYSTEM
179
set PASSWORD=SYS
10+
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
11+
12+
@echo off
13+
:: Pre-configured variables
14+
set BUILD_DIR=build\cls
15+
set XML_EXPORT_DIR=build
16+
set PACKAGE_NAME=EntityBrowser
1817

1918
:: Build and import application to Caché
2019
echo Importing project...
2120
call npm run gulp
22-
:: call xcopy /sy "%~dp0\%BUILD_STATIC_DIR%" "%CSP_DIR%"
2321
(
2422
echo %USERNAME%
2523
echo %PASSWORD%
26-
echo zn "%NAMESPACE%" set st = $system.Status.GetErrorText($system.OBJ.ImportDir("%~dp0%BUILD_DIR%",,"ck",,1^^^)^^^) w "IMPORT STATUS: "_$case(st="",1:"OK",:st^^^), ! halt
24+
echo zn "%NAMESPACE%" set st = $system.Status.GetErrorText($system.OBJ.ImportDir("%~dp0%BUILD_DIR%",,"ck",,1^^^)^^^) w "IMPORT STATUS: "_$case(st="",1:"OK",:st^^^), !
25+
echo s st = $system.Status.GetErrorText($system.OBJ.ExportPackage("%PACKAGE_NAME%", "%~dp0%XML_EXPORT_DIR%\%PACKAGE_NAME%-v"_##class(%PACKAGE_NAME%.Installer^^^).#VERSION_".xml"^^^)^^^) w $c(13,10^^^)_"EXPORT STATUS: "_$case(st="",1:"OK",:st^^^), ! halt
2726
) | "%CACHE_DIR%\bin\cache.exe" -s "%CACHE_DIR%\mgr" -U %NAMESPACE%
27+
28+
:: Other utilities that may be useful:
29+
::
30+
:: Copy files to CSP folder
31+
::$ set BUILD_STATIC_DIR=build\static
32+
::$ set CSP_DIR=C:\Program Files\InterSystems\Ensemble\CSP\samples\EntityBrowser
33+
::$ call xcopy /sy "%~dp0\%BUILD_STATIC_DIR%" "%CSP_DIR%"

import.sh

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
11
#!/usr/bin/env bash
22
# This batch script makes the Caché application deployment much faster by building and importing the project.
33
# Replace the variables below to match your Caché installation and build & import application to Caché using only one command.
4-
54
# Caché 2016.2+ IS REQUIRED TO PROCEED
6-
set +v
7-
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
85

9-
# CHANGE THIS PATH TO YOUR CACHÉ INSTALLATION PATH (folder that contains bin, CSP, mgr and other folders)
6+
# Configurable variables: change them to fit your system #
107
CACHE_DIR=/InterSystems/Cache
11-
# NAMESPACE TO IMPORT PACKAGE TO
128
NAMESPACE=SAMPLES
13-
# Other variables
14-
BUILD_DIR=build/cls
15-
BUILD_STATIC_DIR=build/static
16-
CSP_DIR=/InterSystems/Cache/csp/samples/EntityBrowser
17-
# Credentials
189
USERNAME=_SYSTEM
1910
PASSWORD=SYS
11+
##########################################################
12+
13+
set +v
14+
# Pre-configured variables
15+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
16+
BUILD_DIR=build/cls
17+
XML_EXPORT_DIR=build
18+
PACKAGE_NAME=EntityBrowser
2019

2120
# Build and import application to Caché
2221
echo "Importing project..."
2322
npm run gulp
24-
cp -R "$DIR/$BUILD_STATIC_DIR"* "$CSP_DIR"
25-
cat <<EOT | "$CACHE_DIR/bin/cache" -s "$CACHE_DIR/mgr" -U $NAMESPACE
26-
$USERNAME
27-
$PASSWORD
28-
zn "$NAMESPACE" set st = \$system.Status.GetErrorText(\$system.OBJ.ImportDir("$DIR/$BUILD_DIR",,"ck /checkuptodate=all",,1))
29-
write "IMPORT STATUS: "_\$case(st="",1:"OK",:st), ! halt
23+
cat <<EOT | "$CACHE_DIR/bin/cache" -s "$CACHE_DIR/mgr" -U ${NAMESPACE}
24+
${USERNAME}
25+
${PASSWORD}
26+
zn "${NAMESPACE}" set st = \$system.Status.GetErrorText(\$system.OBJ.ImportDir("${DIR}/${BUILD_DIR}",,"ck /checkuptodate=all",,1))
27+
write "IMPORT STATUS: "_\$case(st="",1:"OK",:st), \!
28+
s st = \$system.Status.GetErrorText(\$system.OBJ.ExportPackage("${PACKAGE_NAME}", "${DIR}/${XML_EXPORT_DIR}/${PACKAGE_NAME}%-v"_##class(${PACKAGE_NAME}.Installer).#VERSION_".xml")) w \$c(13,10)_"EXPORT STATUS: "_\$case(st="",1:"OK",:st), \! halt
3029
EOT

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "iknow-entity-browser",
3-
"version": "0.9.0",
3+
"version": "0.9.1",
44
"description": "Visualizer for iKnow entities",
55
"main": "gulpfile.babel.js",
66
"scripts": {

src/cls/EntityBrowser/REST/API.cls renamed to src/cls/EntityBrowser/API.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
/// items:
9898
/// type: string
9999
/// </example>
100-
Class EntityBrowser.REST.API Extends (%iKnow.REST.Base, %iKnow.REST.Utils)
100+
Class EntityBrowser.API Extends (%iKnow.REST.Base, %iKnow.REST.Utils)
101101
{
102102

103103
Parameter PAGESIZE = 0;

src/cls/EntityBrowser/Installer.cls

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Class EntityBrowser.Installer Extends %Projection.AbstractProjection [ DependsOn = Router ]
2+
{
3+
4+
Projection Reference As Installer;
5+
6+
Parameter AppName = "EntityBrowser";
7+
8+
Parameter DispatchClass = "EntityBrowser.Router";
9+
10+
Parameter VERSION = "<!-- @echo package.version -->";
11+
12+
/// This method is invoked when this class is compiling.
13+
ClassMethod CreateProjection(cls As %String, ByRef params) As %Status
14+
{
15+
write !, "Registering web application /" _ ..#AppName
16+
return ##class(WebAppManager).Register("/" _ ..#AppName, {
17+
"Description": ("A web application for Cache Entity Browser Project. You can change any "
18+
_ "properties of this application except of Dispatch Class property. To delete the "
19+
_ "application simply delete " _ ..#AppName _ " package, the web application will be "
20+
_ "deleted automatically."),
21+
"IsNameSpaceDefault": ($$$NO),
22+
"DispatchClass": (..#DispatchClass)
23+
})
24+
}
25+
26+
/// This method is invoked when a class is 'uncompiled'.
27+
ClassMethod RemoveProjection(cls As %String, ByRef params, recompile As %Boolean) As %Status
28+
{
29+
return:recompile $$$OK
30+
write !, "Removing web application /" _ ..#AppName
31+
return ##class(WebAppManager).Delete("/" _ ..#AppName, {
32+
"DispatchClass": (..#DispatchClass)
33+
})
34+
}
35+
36+
}

src/cls/EntityBrowser/REST/Router.cls

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/cls/EntityBrowser/Router.cls

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/// Application entry point.
2+
Class EntityBrowser.Router Extends (ServeXData, StaticData)
3+
{
4+
5+
XData UrlMap
6+
{
7+
<Routes>
8+
<Map Prefix="/api" Forward="EntityBrowser.API"/>
9+
<Route Url="/(.*)" Method="GET" Call="Serve"/>
10+
</Routes>
11+
}
12+
13+
}

src/cls/EntityBrowser/REST/ServeXData.cls renamed to src/cls/EntityBrowser/ServeXData.cls

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
/// Class that serves the static data encoded in Base64 and stored in this class in XData blocks.
2-
Class EntityBrowser.REST.ServeXData Extends %CSP.REST
2+
/// @author ZitRo
3+
Class EntityBrowser.ServeXData Extends %CSP.REST [ Abstract ]
34
{
45

6+
/// This is the <Routes> example. Copy this definitions to the URLMap XData of your class.
7+
XData UrlMap
8+
{
9+
<Routes>
10+
<Map Prefix="/api" Forward="YourAPI.Handler"/>
11+
<Route Url="/(.*)" Method="GET" Call="Serve"/>
12+
</Routes>
13+
}
14+
515
/// Index file name which will be served when requesting "/".
616
Parameter IndexFile = "index.html";
717

@@ -12,17 +22,10 @@ Parameter CompileTime = {"""" _ $zd($h, 11) _ ", "_ $zdt($NOW(0), 2,1) _ " GMT""
1222
/// Generated in GenerateFiles generator.
1323
Parameter Files As CONFIGVALUE;
1424

15-
/// Copy the <Route> definition to the URLMap XData of your class.
16-
XData UrlMap
17-
{
18-
<Routes>
19-
<Route Url="/(.*)" Method="GET" Call="StaticDelivery"/>
20-
</Routes>
21-
}
22-
2325
/// A generator for Files parameter.
24-
ClassMethod FillFiles() As %Status [ CodeMode = objectgenerator, ForceGenerate ]
26+
ClassMethod FillFiles() As %Status [ CodeMode = objectgenerator ]
2527
{
28+
return:%class.Name="EntityBrowser.ServeXData" $$$OK
2629
set list = $LB()
2730
set (ind, j) = 0
2831
for i=1:1:%compiledclass.XDatas.Count() {
@@ -38,7 +41,7 @@ ClassMethod FillFiles() As %Status [ CodeMode = objectgenerator, ForceGenerate ]
3841
set $LIST(list, j*2+1) = ""
3942
set $LIST(list, j*2+2) = xd.Name
4043
}
41-
do $system.OBJ.UpdateConfigParam("EntityBrowser.REST.ServeXData", "Files", list)
44+
do $system.OBJ.UpdateConfigParam("EntityBrowser.ServeXData", "Files", list)
4245
return $$$OK
4346
}
4447

@@ -53,7 +56,7 @@ ClassMethod GetXData(fileName As %String) As %Dictionary.CompiledXData
5356
return ##class(%Dictionary.CompiledXData).%OpenId($ClassName()_"||"_xdn)
5457
}
5558

56-
ClassMethod StaticDelivery(file As %String) As %Status
59+
ClassMethod Serve(file As %String) As %Status
5760
{
5861
set xdata = ..GetXData(file)
5962
return:(xdata = "") ..Http404()

0 commit comments

Comments
 (0)