Skip to content

Commit ed3c8eb

Browse files
committed
add errormessage alert to all views
1 parent 9092303 commit ed3c8eb

25 files changed

Lines changed: 130 additions & 87 deletions

OpenFlow/src/public/Auditlogs.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ <h1 translate lib="web">auditlogs</h1>
1919
border-style: solid
2020
}
2121
</style>
22+
<div ng-show="ctrl.errormessage != ''"" class=" alert alert-danger" role="alert">{{ctrl.errormessage}}</div>
2223
<table id="table1" class="table table-striped" when-scrolled="ctrl.more()" style="width: 100%;">
2324
<thead class="thead-dark">
2425
<tr>

OpenFlow/src/public/CommonControllers.ts

Lines changed: 95 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ module openflow {
170170
var msg: Message = new Message(); msg.command = "dropcollection"; msg.data = JSON.stringify(q);
171171
q = await this.WebSocketClient.Send<DropCollectionMessage>(msg);
172172
}
173-
async Query(collection: string, query: any, projection: any = null, orderby: any = { _created: -1 }, top: number = 100, skip: number = 0, queryas: string = null): Promise<any[]> {
173+
async Query(collection: string, query: any, projection: any = null, orderby: any = { _id: -1 }, top: number = 100, skip: number = 0, queryas: string = null): Promise<any[]> {
174174
var q: QueryMessage = new QueryMessage();
175175
q.collectionname = collection; q.query = query; q.queryas = queryas;
176176
q.query = JSON.stringify(query, (key, value) => {
@@ -598,7 +598,7 @@ module openflow {
598598
public baseprojection: any = {};
599599
public collection: string = "entities";
600600
public models: T[] = [];
601-
public orderby: any = { _created: -1 };
601+
public orderby: any = { _id: -1 };
602602
public autorefresh: boolean = false;
603603
public autorefreshinterval: number = 30 * 1000;
604604
public autorefreshpromise: any = null;
@@ -607,6 +607,7 @@ module openflow {
607607
public searchstring: string = "";
608608
public searchfields: string[] = ["name"];
609609
public basequeryas: string = null;
610+
public errormessage: string = "";
610611

611612
public static $inject = [
612613
"$scope",
@@ -642,52 +643,60 @@ module openflow {
642643
}
643644
}
644645
async loadData(): Promise<void> {
645-
if (this.loading == true) { console.log("allready loading data, exit"); return; }
646-
this.loading = true;
647-
if (this.preloadData != null) {
648-
this.preloadData();
649-
}
650-
var query = this.basequery;
651-
if (this.searchstring !== "") {
652-
var finalor = [];
653-
for (var i = 0; i < this.searchfields.length; i++) {
654-
var newq: any = {};
655-
// exact match case sensitive
656-
// newq[this.searchfields[i]] = this.searchstring;
657-
// exact match case insensitive
658-
newq[this.searchfields[i]] = new RegExp(["^", this.searchstring, "$"].join(""), "i");
659-
660-
// exact match string contains
661-
newq[this.searchfields[i]] = new RegExp([this.searchstring].join(""), "i");
662-
663-
finalor.push(newq);
646+
try {
647+
if (this.loading == true) { console.log("allready loading data, exit"); return; }
648+
this.errormessage = "";
649+
this.loading = true;
650+
if (this.preloadData != null) {
651+
this.preloadData();
664652
}
665-
if (Object.keys(query).length == 0) {
666-
query = { $or: finalor.concat() };
667-
} else {
668-
query = { $and: [query, { $or: finalor.concat() }] };
653+
var query = this.basequery;
654+
if (this.searchstring !== "") {
655+
var finalor = [];
656+
for (var i = 0; i < this.searchfields.length; i++) {
657+
var newq: any = {};
658+
// exact match case sensitive
659+
// newq[this.searchfields[i]] = this.searchstring;
660+
// exact match case insensitive
661+
newq[this.searchfields[i]] = new RegExp(["^", this.searchstring, "$"].join(""), "i");
662+
663+
// exact match string contains
664+
newq[this.searchfields[i]] = new RegExp([this.searchstring].join(""), "i");
665+
666+
finalor.push(newq);
667+
}
668+
if (Object.keys(query).length == 0) {
669+
query = { $or: finalor.concat() };
670+
} else {
671+
query = { $and: [query, { $or: finalor.concat() }] };
672+
}
669673
}
670-
}
671-
this.models = await this.api.Query(this.collection, query, this.baseprojection, this.orderby, 100, 0, this.basequeryas);
672-
this.loading = false;
673-
if (this.autorefresh) {
674-
if (this.models.length >= 100) {
675-
// console.warn("Disabling auto refresh, result has more than 100 entries");
676-
} else {
677-
if (this.autorefreshpromise == null && this.searchstring === "") {
678-
//if (this.autorefreshpromise == null) {
679-
this.autorefreshpromise = this.$interval(() => {
680-
this.loadData();
681-
}, this.autorefreshinterval);
682-
this.$scope.$on('$destroy', () => {
683-
this.$interval.cancel(this.autorefreshpromise);
684-
});
674+
console.log(this.orderby);
675+
this.models = await this.api.Query(this.collection, query, this.baseprojection, this.orderby, 100, 0, this.basequeryas);
676+
this.loading = false;
677+
if (this.autorefresh) {
678+
if (this.models.length >= 100) {
679+
// console.warn("Disabling auto refresh, result has more than 100 entries");
680+
} else {
681+
if (this.autorefreshpromise == null && this.searchstring === "") {
682+
//if (this.autorefreshpromise == null) {
683+
this.autorefreshpromise = this.$interval(() => {
684+
this.loadData();
685+
}, this.autorefreshinterval);
686+
this.$scope.$on('$destroy', () => {
687+
this.$interval.cancel(this.autorefreshpromise);
688+
});
689+
}
685690
}
686691
}
687-
}
688-
if (this.postloadData != null) {
689-
this.postloadData();
690-
} else {
692+
if (this.postloadData != null) {
693+
this.postloadData();
694+
} else {
695+
if (!this.$scope.$$phase) { this.$scope.$apply(); }
696+
}
697+
} catch (error) {
698+
this.loading = false;
699+
this.errormessage = JSON.stringify(error);
691700
if (!this.$scope.$$phase) { this.$scope.$apply(); }
692701
}
693702
}
@@ -745,6 +754,7 @@ module openflow {
745754
public autorefreshpromise: any = null;
746755
public preloadData: any = null;
747756
public postloadData: any = null;
757+
public errormessage: string = "";
748758

749759
public static $inject = [
750760
"$scope",
@@ -766,47 +776,54 @@ module openflow {
766776
this.basequery = { _id: this.id };
767777
}
768778
async loadData(): Promise<void> {
769-
if (this.loading == true) { console.log("allready loading data, exit"); return; }
770-
var updated: boolean = false;
771-
this.loading = true;
772-
if (this.preloadData != null) {
773-
this.preloadData();
774-
}
779+
try {
780+
if (this.loading == true) { console.log("allready loading data, exit"); return; }
781+
this.errormessage = "";
782+
var updated: boolean = false;
783+
this.loading = true;
784+
if (this.preloadData != null) {
785+
this.preloadData();
786+
}
775787

776-
var result = await this.api.Query(this.collection, this.basequery, this.baseprojection, null, 1);
777-
if (result.length > 0) {
778-
if (this.model == null) {
779-
this.model = result[0];
780-
updated = true;
781-
} else {
782-
if (!angular.equals(this.model, result[0])) {
788+
var result = await this.api.Query(this.collection, this.basequery, this.baseprojection, null, 1);
789+
if (result.length > 0) {
790+
if (this.model == null) {
783791
this.model = result[0];
784792
updated = true;
793+
} else {
794+
if (!angular.equals(this.model, result[0])) {
795+
this.model = result[0];
796+
updated = true;
797+
}
785798
}
786-
}
787799

788-
}
789-
if (updated) {
790-
this.keys = Object.keys(this.model);
791-
for (var i: number = this.keys.length - 1; i >= 0; i--) {
792-
if (this.keys[i].startsWith('_')) this.keys.splice(i, 1);
793800
}
794-
}
795-
this.loading = false;
796-
if (this.postloadData != null) {
797-
this.postloadData();
798-
} else {
799-
if (!this.$scope.$$phase) { this.$scope.$apply(); }
800-
}
801-
if (this.autorefresh) {
802-
if (this.autorefreshpromise == null) {
803-
this.autorefreshpromise = this.$interval(() => {
804-
this.loadData();
805-
}, this.autorefreshinterval);
806-
this.$scope.$on('$destroy', () => {
807-
this.$interval.cancel(this.autorefreshpromise);
808-
});
801+
if (updated) {
802+
this.keys = Object.keys(this.model);
803+
for (var i: number = this.keys.length - 1; i >= 0; i--) {
804+
if (this.keys[i].startsWith('_')) this.keys.splice(i, 1);
805+
}
809806
}
807+
this.loading = false;
808+
if (this.postloadData != null) {
809+
this.postloadData();
810+
} else {
811+
if (!this.$scope.$$phase) { this.$scope.$apply(); }
812+
}
813+
if (this.autorefresh) {
814+
if (this.autorefreshpromise == null) {
815+
this.autorefreshpromise = this.$interval(() => {
816+
this.loadData();
817+
}, this.autorefreshinterval);
818+
this.$scope.$on('$destroy', () => {
819+
this.$interval.cancel(this.autorefreshpromise);
820+
});
821+
}
822+
}
823+
} catch (error) {
824+
this.loading = false;
825+
this.errormessage = JSON.stringify(error);
826+
if (!this.$scope.$$phase) { this.$scope.$apply(); }
810827
}
811828
}
812829
}

OpenFlow/src/public/Entities.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ <h1 translate lib="web">entities</h1>
3333
</div>
3434
</div>
3535

36-
<table id="table1" class="table table-striped table-hover table-sm" when-scrolled="ctrl.more()" style="width: 100%;">
36+
<div ng-show="ctrl.errormessage != ''"" class=" alert alert-danger" role="alert">{{ctrl.errormessage}}</div>
37+
38+
<table id=" table1" class="table table-striped table-hover table-sm" when-scrolled="ctrl.more()" style="width: 100%;">
3739
<thead class="thead-dark">
3840
<tr>
3941
<th scope="col" ng-click="ctrl.ToggleOrder('name')"><b translate lib="web">name</b></th>

OpenFlow/src/public/Entity.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ <h1 class="pagetitle"><span translate lib="web">detailsfor</span> {{ctrl.model.n
9494
</section>
9595

9696

97-
<pre ng-show="ErrorMessage!=null">{{ ErrorMessage }}</pre>
97+
<pre ng-show="ErrorMessage!=null" class=" alert alert-danger" role="alert">{{ ErrorMessage }}</pre>
98+
<div ng-show="ctrl.errormessage != ''"" class=" alert alert-danger" role="alert">{{ctrl.errormessage}}</div>
9899
<pre>{{ctrl.message}}</pre>
99100
<a href="" ng-hide="ctrl.showjson==true" ng-click="ctrl.togglejson()" translate lib="web">showjson</a>
100101
<a href="" ng-hide="ctrl.showjson==false" ng-click="ctrl.togglejson()" translate lib="web">showproperties</a>

OpenFlow/src/public/Files.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ <h1 translate lib="web">files</h1>
3636
background-color: green;
3737
}
3838
</style>
39-
39+
<div ng-show="ctrl.errormessage != ''"" class=" alert alert-danger" role="alert">{{ctrl.errormessage}}</div>
4040
<form action="/upload" method="post" enctype="multipart/form-data">
4141
<table id="table1" class="table table-striped table-hover table-sm" when-scrolled="ctrl.more()" style="width: 100%;">
4242
<thead class="thead-dark">

OpenFlow/src/public/Form.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
display: none !important;
55
}
66
</style>
7+
<div ng-show="ctrl.errormessage != ''"" class=" alert alert-danger" role="alert">{{ctrl.errormessage}}</div>
78
<form id="workflowform" ng-submit="ctrl.Save()">
89
<div class="render-wrap" ng-show="ctrl.form.fbeditor==true">
910
</div>

OpenFlow/src/public/Forms.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ <h1 translate lib="web">forms</h1>
1616
<a ng-href="#/EditForm" class="btn btn-info" translate lib="web">addform</a>
1717
</div>
1818
</div>
19-
19+
<div ng-show="ctrl.errormessage != ''"" class=" alert alert-danger" role="alert">{{ctrl.errormessage}}</div>
2020
<table id="table1" class="table table-striped" when-scrolled="ctrl.more()" style="width: 100%;">
2121
<thead class="thead-dark">
2222
<tr>

OpenFlow/src/public/History.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<h1 translate lib="web">entities</h1>
33
</div>
44
<div class="row">
5-
5+
<div ng-show="ctrl.errormessage != ''"" class=" alert alert-danger" role="alert">{{ctrl.errormessage}}</div>
66
<table id="table1" class="table table-striped" when-scrolled="ctrl.more()" style="width: 100%;">
77
<thead class="thead-dark">
88
<tr>

OpenFlow/src/public/Main.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ <h1 translate lib="web">sitename</h1>
1111
</div>
1212
</div>
1313
</div>
14+
<div ng-show="ctrl.errormessage != ''"" class=" alert alert-danger" role="alert">{{ctrl.errormessage}}</div>
1415
<table id="table1" class="table table-striped" when-scrolled="ctrl.more()" style="width: 100%;">
1516
<thead class="thead-dark">
1617
<tr>

OpenFlow/src/public/Nodered.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ <h1 translate lib="web">sockets</h1>
2424
</div>
2525
</section>
2626
</form>
27+
<div ng-show="ctrl.errormessage != ''"" class=" alert alert-danger" role="alert">{{ctrl.errormessage}}</div>
2728
<section>
2829
<div class="form-group">
2930
<label class="col-sm-3 control-label"><span translate lib="web">status</span>: </label>
@@ -49,13 +50,18 @@ <h1 translate lib="web">sockets</h1>
4950
</div>
5051
</div>
5152
</section>
52-
<section ng-show="menuctrl.hasrole('admins')">
53+
<section>
5354
<div class="form-group">
5455
<label class="col-sm-3 control-label"><span translate lib="web">api_allow_anonymous</span>: </label>
5556
<div class="col-sm-9">
5657
<input type="checkbox" class='form-control' ng-model="ctrl.user.nodered.api_allow_anonymous"></input>
5758
</div>
5859
</div>
60+
<div>
61+
You need to delete and re-create your nodered instance, for this to take effect
62+
</div>
63+
</section>
64+
<section ng-show="menuctrl.hasrole('admins')">
5965
<div class="form-group">
6066
<label class="col-sm-3 control-label"><span translate lib="web">memory</span>: </label>
6167
<div class="col-sm-9">
@@ -71,6 +77,8 @@ <h1 translate lib="web">sockets</h1>
7177
</select>
7278
</div>
7379
</div>
80+
</section>
81+
<section>
7482
<div class="form-group">
7583
<div class="col-sm-offset-3 col-sm-9">
7684
<button type="button" ng-disabled="ctrl.loading==true" class="btn btn-success" translate lib="web"

0 commit comments

Comments
 (0)