@@ -1545,4 +1545,97 @@ module openflow {
15451545 document . getElementById ( 'visual' ) . innerHTML = jsondiffpatch . formatters . html . format ( model . delta , model . item ) ;
15461546 }
15471547 }
1548+
1549+ export class NoderedCtrl {
1550+ public static $inject = [
1551+ "$scope" ,
1552+ "$location" ,
1553+ "$routeParams" ,
1554+ "WebSocketClient" ,
1555+ "api"
1556+ ] ;
1557+ public messages : string = "" ;
1558+ public queuename : string = "webtest" ;
1559+ public message : string = "Hi mom" ;
1560+ public noderedurl : string = "" ;
1561+ constructor (
1562+ public $scope : ng . IScope ,
1563+ public $location : ng . ILocationService ,
1564+ public $routeParams : ng . route . IRouteParamsService ,
1565+ public WebSocketClient : WebSocketClient ,
1566+ public api : api
1567+ ) {
1568+ console . debug ( "NoderedCtrl" ) ;
1569+ WebSocketClient . onSignedin ( async ( user : TokenUser ) => {
1570+ await api . RegisterQueue ( ) ;
1571+ this . noderedurl = WebSocketClient . nodered_domain_schema . replace ( "$nodered_id$" , WebSocketClient . user . username ) ;
1572+ } ) ;
1573+ }
1574+
1575+ async EnsureNoderedInstance ( ) {
1576+ try {
1577+ await this . api . EnsureNoderedInstance ( ) ;
1578+ this . messages += "EnsureNoderedInstance completed" + "\n" ;
1579+ } catch ( error ) {
1580+ this . messages += error + "\n" ;
1581+ console . error ( error ) ;
1582+ }
1583+ if ( ! this . $scope . $$phase ) { this . $scope . $apply ( ) ; }
1584+ }
1585+ async DeleteNoderedInstance ( ) {
1586+ try {
1587+ await this . api . DeleteNoderedInstance ( ) ;
1588+ this . messages += "DeleteNoderedInstance completed" + "\n" ;
1589+ } catch ( error ) {
1590+ this . messages += error + "\n" ;
1591+ console . error ( error ) ;
1592+ }
1593+ if ( ! this . $scope . $$phase ) { this . $scope . $apply ( ) ; }
1594+ }
1595+ async RestartNoderedInstance ( ) {
1596+ try {
1597+ await this . api . RestartNoderedInstance ( ) ;
1598+ this . messages += "RestartNoderedInstance completed" + "\n" ;
1599+ } catch ( error ) {
1600+ this . messages += error + "\n" ;
1601+ console . error ( error ) ;
1602+ }
1603+ if ( ! this . $scope . $$phase ) { this . $scope . $apply ( ) ; }
1604+ }
1605+ async StartNoderedInstance ( ) {
1606+ try {
1607+ await this . api . StartNoderedInstance ( ) ;
1608+ this . messages += "StartNoderedInstance completed" + "\n" ;
1609+ } catch ( error ) {
1610+ this . messages += error + "\n" ;
1611+ console . error ( error ) ;
1612+ }
1613+ if ( ! this . $scope . $$phase ) { this . $scope . $apply ( ) ; }
1614+ }
1615+ async StopNoderedInstance ( ) {
1616+ try {
1617+ await this . api . StopNoderedInstance ( ) ;
1618+ this . messages += "StopNoderedInstance completed" + "\n" ;
1619+ } catch ( error ) {
1620+ this . messages += error + "\n" ;
1621+ console . error ( error ) ;
1622+ }
1623+ if ( ! this . $scope . $$phase ) { this . $scope . $apply ( ) ; }
1624+ }
1625+
1626+ async submit ( ) {
1627+ await this . SendOne ( this . queuename , this . message ) ;
1628+ }
1629+ async SendOne ( queuename : string , message : any ) : Promise < void > {
1630+ var result : any = await this . api . QueueMessage ( queuename , message ) ;
1631+ try {
1632+ // result = JSON.parse(result);
1633+ } catch ( error ) {
1634+ }
1635+ this . messages += result + "\n" ;
1636+ if ( ! this . $scope . $$phase ) { this . $scope . $apply ( ) ; }
1637+ }
1638+ }
1639+
1640+
15481641}
0 commit comments