Skip to content

Commit 3d28e92

Browse files
committed
updates on nodered billing
1 parent 0e2a8f6 commit 3d28e92

7 files changed

Lines changed: 23 additions & 18 deletions

File tree

OpenFlow/src/Messages/Message.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,6 @@ export class Message {
771771
} catch (error) {
772772
this.data = "";
773773
cli._logger.error(error);
774-
console.log(JSON.stringify(error, null, 2));
775774
//msg.error = JSON.stringify(error, null, 2);
776775
if (msg !== null && msg !== undefined) msg.error = "Request failed!"
777776
}
@@ -1115,23 +1114,30 @@ export class Message {
11151114
for (var i = 0; i < list.body.items.length; i++) {
11161115
if (!Util.IsNullEmpty(Config.stripe_api_secret)) {
11171116
var item = list.body.items[i];
1117+
var name = item.metadata.name;
11181118
var create = item.metadata.creationTimestamp;
11191119
var billed = item.metadata.labels.billed;
11201120
var image = item.spec.containers[0].image
11211121
var userid = item.metadata.labels.userid;
1122+
var date = new Date();
1123+
var a: number = (date as any) - (create as any);
1124+
// var diffminutes = a / (1000 * 60);
1125+
var diffhours = a / (1000 * 60 * 60);
11221126
if (image.indexOf("openflownodered") > 0 && !Util.IsNullEmpty(userid)) {
11231127
try {
1124-
var date = new Date();
1125-
var a: number = (date as any) - (create as any);
1126-
// var diffminutes = a / (1000 * 60);
1127-
var diffhours = a / (1000 * 60 * 60);
11281128
if (billed != "true" && diffhours > 24) {
1129-
cli._logger.debug("[" + cli.user.username + "] Remove un billed nodered instance " + item.metadata.name + " that has been running for " + diffhours + " hours");
1130-
await this._DeleteNoderedInstance(userid, cli.user._id, cli.user.username, rootjwt);
1129+
cli._logger.debug("[" + cli.user.username + "] Remove un billed nodered instance " + name + " that has been running for " + diffhours + " hours");
1130+
// await this._DeleteNoderedInstance(userid, cli.user._id, cli.user.username, rootjwt);
11311131
}
1132-
// console.log(item.metadata.name + " " + diffminutes + " min / " + diffhours + " hours");
1132+
// console.log(name + " " + diffminutes + " min / " + diffhours + " hours");
11331133
} catch (error) {
11341134
}
1135+
} else if (image.indexOf("openflownodered") > 0) {
1136+
if (billed != "true" && diffhours > 24) {
1137+
console.log("unbilled " + name + " with no userid, should be removed, it has been running for " + diffhours + " hours");
1138+
} else {
1139+
console.log("unbilled " + name + " with no userid, has been running for " + diffhours + " hours");
1140+
}
11351141
}
11361142
}
11371143

@@ -1822,7 +1828,6 @@ export class Message {
18221828
customer = await this.Stripe<stripe_customer>("GET", "customers", null, null, billing.stripeid);
18231829
}
18241830
}
1825-
console.log(JSON.stringify(customer.discount, null, 2))
18261831
if (customer != null && Util.IsNullEmpty(billing.coupon) && customer.discount != null) {
18271832
var payload: any = { coupon: "" };
18281833
customer = await this.Stripe<stripe_customer>("POST", "customers", billing.stripeid, payload, null);

OpenFlow/src/public/Controllers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3223,7 +3223,7 @@ module openflow {
32233223
}
32243224
//if (this.allowopenflowsignup || this.allowsupportsignup) {
32253225
this.model.taxrate = "";
3226-
if (this.openflowplans.length == 0) {
3226+
if (this.openflowplans.length == 0 && this.supportplans.length == 0) {
32273227
this.stripe_plans = (await this.api.Stripe("GET", "plans", null, null, null) as any);
32283228
for (var x = 0; x < this.stripe_plans.data.length; x++) {
32293229
var stripeplan = this.stripe_plans.data[x];

OpenFlow/src/public/Payment.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@
336336
<div class="col">
337337
<label class="control-label" translate lib="web">Coupon</label>
338338
<div class="col-sm-8">
339-
<input type="text" class='form-control' ng-model="ctrl.model.coupon"></input>
339+
<input type="password" class='form-control' ng-model="ctrl.model.coupon"></input>
340340
</div>
341341
</div>
342342
</div>

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.564
1+
0.0.565

docker-compose-toolbox.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ services:
4545
- "traefik.http.routers.web.rule=Host(`toolbox.openrpa.dk`)"
4646
- "traefik.http.routers.web.entrypoints=web"
4747
- "traefik.frontend.passHostHeader=true"
48-
image: "cloudhack/openflow:0.0.563"
48+
image: "cloudhack/openflow:0.0.565"
4949
container_name: "web"
5050
environment:
5151
- update_acl_based_on_groups=true
@@ -82,7 +82,7 @@ services:
8282
- "traefik.http.routers.nodered.rule=Host(`nodered1.toolbox.openrpa.dk`)"
8383
- "traefik.http.routers.nodered.entrypoints=web"
8484
- "traefik.http.services.nodered.loadbalancer.server.port=1880"
85-
image: "cloudhack/openflownodered:0.0.563"
85+
image: "cloudhack/openflownodered:0.0.565"
8686
container_name: "nodered"
8787
environment:
8888
# - nodered_id=1

docker-compose-traefik.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ services:
4545
- "traefik.http.routers.web.rule=Host(`localhost.openrpa.dk`)"
4646
- "traefik.http.routers.web.entrypoints=web"
4747
- "traefik.frontend.passHostHeader=true"
48-
image: "cloudhack/openflow:0.0.563"
48+
image: "cloudhack/openflow:0.0.565"
4949
container_name: "web"
5050
environment:
5151
- update_acl_based_on_groups=true
@@ -82,7 +82,7 @@ services:
8282
- "traefik.http.routers.nodered.rule=Host(`nodered1.localhost.openrpa.dk`)"
8383
- "traefik.http.routers.nodered.entrypoints=web"
8484
- "traefik.http.services.nodered.loadbalancer.server.port=1880"
85-
image: "cloudhack/openflownodered:0.0.563"
85+
image: "cloudhack/openflownodered:0.0.565"
8686
container_name: "nodered"
8787
environment:
8888
# - nodered_id=1

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ services:
1818
- "5672:5672"
1919
- "15672:15672"
2020
web:
21-
image: "cloudhack/openflow:0.0.563"
21+
image: "cloudhack/openflow:0.0.565"
2222
environment:
2323
- update_acl_based_on_groups=true
2424
- multi_tenant=false
@@ -52,7 +52,7 @@ services:
5252
- "80:80"
5353
- "5858:5858"
5454
nodered:
55-
image: "cloudhack/openflownodered:0.0.563"
55+
image: "cloudhack/openflownodered:0.0.565"
5656
environment:
5757
# - nodered_id=1
5858
- nodered_sa=nodered1

0 commit comments

Comments
 (0)