2016-05-13 13:22:29 -07:00
|
|
|
import {ApplicationRef} from '@angular/core';
|
2016-05-19 14:31:21 -07:00
|
|
|
import {bootstrapRender, UiArguments, FnArg, PRIMITIVE, ClientMessageBrokerFactory} from '@angular/platform-browser';
|
2015-09-01 10:55:11 -07:00
|
|
|
|
2016-04-12 09:40:37 -07:00
|
|
|
const ECHO_CHANNEL = "ECHO";
|
2015-09-01 10:55:11 -07:00
|
|
|
|
2016-05-13 13:22:29 -07:00
|
|
|
export function main() {
|
|
|
|
bootstrapRender("loader.js").then((ref) => afterBootstrap(ref));
|
|
|
|
}
|
2015-09-01 10:55:11 -07:00
|
|
|
|
2016-04-14 14:52:35 -07:00
|
|
|
function afterBootstrap(ref: ApplicationRef) {
|
|
|
|
let brokerFactory: ClientMessageBrokerFactory = ref.injector.get(ClientMessageBrokerFactory);
|
|
|
|
var broker = brokerFactory.createMessageBroker(ECHO_CHANNEL, false);
|
2015-09-01 10:55:11 -07:00
|
|
|
|
2016-04-14 14:52:35 -07:00
|
|
|
document.getElementById("send_echo")
|
|
|
|
.addEventListener("click", (e) => {
|
|
|
|
var val = (<HTMLInputElement>document.getElementById("echo_input")).value;
|
|
|
|
// TODO(jteplitz602): Replace default constructors with real constructors
|
|
|
|
// once they're in the .d.ts file (#3926)
|
|
|
|
var args = new UiArguments("echo");
|
|
|
|
args.method = "echo";
|
|
|
|
var fnArg = new FnArg(val, PRIMITIVE);
|
|
|
|
fnArg.value = val;
|
|
|
|
fnArg.type = PRIMITIVE;
|
|
|
|
args.args = [fnArg];
|
|
|
|
|
|
|
|
broker.runOnService(args, PRIMITIVE)
|
|
|
|
.then((echo_result: string) => {
|
|
|
|
document.getElementById("echo_result").innerHTML =
|
|
|
|
`<span class='response'>${echo_result}</span>`;
|
|
|
|
});
|
|
|
|
});
|
2016-04-28 17:50:03 -07:00
|
|
|
}
|