Skip to content

Commit 278654d

Browse files
committed
add nodered page
1 parent 1e840a9 commit 278654d

4 files changed

Lines changed: 116 additions & 0 deletions

File tree

OpenFlow/src/public/Controllers.ts

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

OpenFlow/src/public/Nodered.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<div class="starter-template">
2+
<h1 translate lib="web">sockets</h1>
3+
</div>
4+
5+
<a ng-href="ctrl.noderedurl" target="nodered">Open Nodered</a>
6+
<form ng-submit="ctrl.submit()" class="form-horizontal" role="form" autocomplete="off" ng-hide="ctrl.showjson==true">
7+
<section>
8+
<div class="form-group">
9+
<div class="col-sm-offset-2 col-sm-10">
10+
<button type="button" class="btn btn-secondary" ng-click="ctrl.EnsureNoderedInstance()">Create Nodered</button>
11+
<button type="button" class="btn btn-secondary" ng-click="ctrl.RestartNoderedInstance()">Restart
12+
Nodered</button>
13+
<button type="button" class="btn btn-secondary" ng-click="ctrl.DeleteNoderedInstance()">Delete Nodered</button>
14+
</div>
15+
</div>
16+
</section>
17+
</form>
18+
19+
<pre>{{ ctrl.messages }}</pre>

OpenFlow/src/public/app.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ module openflow {
5050
.when('/History/:collection/:id', { templateUrl: 'History.html', controller: HistoryCtrl, controllerAs: 'ctrl' })
5151

5252
.when('/Socket', { templateUrl: 'Socket.html', controller: SocketCtrl, controllerAs: 'ctrl' })
53+
.when('/Nodered', { templateUrl: 'Nodered.html', controller: NoderedCtrl, controllerAs: 'ctrl' })
5354

5455
.otherwise({ redirectTo: '/main' });
5556
}

OpenFlow/src/public/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
<li class="nav-item">
4040
<a class="nav-link" href="#/Reports"><span translate lib="web">reports</span></a>
4141
</li>
42+
<li class="nav-item">
43+
<a class="nav-link" href="#/Nodered"><span translate lib="web">nodered</span></a>
44+
</li>
4245
<li class="nav-item dropdown">
4346
<a class="nav-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"
4447
translate lib="web">admin</a>

0 commit comments

Comments
 (0)