The angular-redhawk library is a back-end interface to the REST and socket services of Geon's fork of REST-Python. It provides minimal examples of very low-level interfaces to these services. For higher-level interfaces, see the Angular-REDHAWK UIKit (angular-redhawk-uikit).
This Angular library interfaces with the REST-Python server from Geon Technologies. It provides two modules top-level, Support and UI Kit. The former contains the high-level Components users can implement in their designs to facilitate easy access to the underlying Services. It also contains the generic REST Model definitions that are returned by those Services. The UI Kit contains re-usable UI Components that use those support module Component interfaces to view and manipulate the Models.
If you are installing Angular-REDHAWK into your application, use npm
to install it as a dependency:
npm install --save angular-redhawk
Import the AngularRedhawkModule
into your application:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { AngularRedhawkModule } from 'angular-redhawk';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AngularRedhawkModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Angular-REDHAWK connects to the REST-Python server using the RestPythonService
. The default configuration connects to whatever host is serving your web application at port 8080
, which is the default for Geon's REST-Python server. The RestPythonService
supports two methods for configuring that connection: pre- and post- Angular Dependency Injection. In either case, the interface is defined by IRestPythonConfig
.
In your application's top-level module, import the REST_PYTHON_CONFIG
from AngularRedhawkModule
and provide it to dependency injection:
import {
AngularRedhawkModule,
REST_PYTHON_CONFIG
}
@NgModule({
imports: [
AngularRedhawkModule
],
providers: [
{ provide: REST_PYTHON_CONFIG, useValue: { host: 'aa.bb.cc.dd' } }
]
})
You can configure the service connection at your application's startup by injecting the RestPythonService
into the top-level Component and then using setConfiguration
:
import { RestPythonService } from 'angular-redhawk';
// In the Component
constructor(rp: RestPythonService) {
rp.setConfiguration({ port: 9999 });
}
Important: Socket services do not support reconfiguring URLs at this time. Do not reconfigure
RestPythonService
using this method after your application is already running!
If you are developing on Angular-REDHAWK:
git clone <path to>/angular-redhawk
cd angular-redhawk
npm install
npm run build
cd dist
npm link
Then, in your application where you want to use it, link the library:
npm link angular-redhawk
Note: If you're using
@angular/cli
for your application, you may need to use--preserve-symlinks
when running tasks such asng serve
orng build
. For example, add to the app'spackage.json
:
"scripts": {
"start": "ng serve",
"start:dev": "npm run start --preserve-symlinks"
}
Use the NPM task lint
to quality check your code (it runs TSLint) and build
to ensure your code has a better chance of working in a downstream Angular application.
npm run lint
npm run build
Please correct all "errors" generated by TSlint. Some sound like nitpicks (like whitespace at the end of lines), but each is there to help transpiling, bundling, etc. in some way.