Skip to content

Commit bed6de1

Browse files
committed
.
1 parent 7b9a025 commit bed6de1

3 files changed

Lines changed: 22 additions & 1 deletion

File tree

OpenFlow/src/public/Controllers.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,8 @@ module openflow {
818818
) {
819819
super($scope, $location, $routeParams, WebSocketClient, api);
820820
console.debug("jslogCtrl");
821+
this.collection = "jslog";
822+
this.basequery = {};
821823
WebSocketClient.onSignedin((user: TokenUser) => {
822824
this.loadData();
823825
});
@@ -832,6 +834,24 @@ module openflow {
832834
this.loading = false;
833835
if (!this.$scope.$$phase) { this.$scope.$apply(); }
834836
}
837+
async DeleteMany(): Promise<void> {
838+
this.loading = true;
839+
var Promises: Promise<DeleteOneMessage>[] = [];
840+
var q: DeleteOneMessage = new DeleteOneMessage();
841+
this.models.forEach(model => {
842+
q.collectionname = this.collection; q._id = (model as any)._id;
843+
var msg: Message = new Message(); msg.command = "deleteone"; msg.data = JSON.stringify(q);
844+
Promises.push(this.WebSocketClient.Send(msg));
845+
});
846+
const results: any = await Promise.all(Promises.map(p => p.catch(e => e)));
847+
const values: DeleteOneMessage[] = results.filter(result => !(result instanceof Error));
848+
var ids: string[] = [];
849+
values.forEach((x: DeleteOneMessage) => ids.push(x._id));
850+
this.models = this.models.filter(function (m: any): boolean { return ids.indexOf(m._id) === -1; });
851+
this.loading = false;
852+
if (!this.$scope.$$phase) { this.$scope.$apply(); }
853+
}
854+
835855
}
836856

837857

OpenFlow/src/public/jslog.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<h1 translate lib="web">entities</h1>
33
</div>
44
<button type="button" ng-click="ctrl.loadData()" ng-disabled="ctrl.loading" translate lib="web">reload</button>
5+
<button type="button" ng-click="ctrl.DeleteMany()" ng-disabled="ctrl.loading" translate lib="web">empty</button>
56
<div class="row">
67
<table id="table1" class="table table-striped" when-scrolled="ctrl.more()" style="width: 100%;">
78
<thead class="thead-dark">

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.134
1+
0.0.135

0 commit comments

Comments
 (0)