Skip to content

Commit 68467ef

Browse files
committed
do prober replace, update modified doing updatedoc
1 parent 3b17744 commit 68467ef

3 files changed

Lines changed: 20 additions & 13 deletions

File tree

OpenFlow/src/DatabaseConnection.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ export class DatabaseConnection {
276276
* @returns Promise<T>
277277
*/
278278
async UpdateOne<T extends Base>(query: any, item: T, collectionname: string, w: number, j: boolean, jwt: string): Promise<T> {
279-
var itemUpdate: boolean = true;
279+
var itemReplace: boolean = true;
280280
if (item === null || item === undefined) { throw Error("Cannot update null item"); }
281281
await this.connect();
282282
var user: TokenUser = Crypt.verityToken(jwt);
@@ -322,7 +322,7 @@ export class DatabaseConnection {
322322
item.addRight(user._id, user.name, [Rights.full_control]);
323323
}
324324
} else {
325-
itemUpdate = false;
325+
itemReplace = false;
326326
}
327327

328328
if (collectionname === "users" && item._type === "user" && item.hasOwnProperty("newpassword")) {
@@ -357,9 +357,13 @@ export class DatabaseConnection {
357357
// var options: CollectionInsertOneOptions = {};
358358
var res: UpdateWriteOpResult = null;
359359
try {
360-
if (itemUpdate) {
361-
res = await this.db.collection(collectionname).updateOne(_query, { $set: item }, options);
360+
if (itemReplace) {
361+
res = await this.db.collection(collectionname).replaceOne(_query, item, options);
362362
} else {
363+
if ((item["$set"]) === undefined) { (item["$set"]) = {} };
364+
(item["$set"])._modifiedby = user.name;
365+
(item["$set"])._modifiedbyid = user._id;
366+
(item["$set"])._modified = new Date(new Date().toISOString());
363367
res = await this.db.collection(collectionname).updateOne(_query, item, options);
364368
}
365369
// var res: ReplaceOneWriteOpResult = await this.db.collection(collectionname).replaceOne(_query, item, options);

OpenFlow/src/public/Controllers.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ module openflow {
184184
workflowids.push(workflow._id);
185185
});
186186
var q = { WorkflowId: { $in: workflowids } }
187-
console.log(q);
188187
var instances = await this.api.Query("openrpa_instances", q, null, null);
189188

190189

@@ -196,13 +195,16 @@ module openflow {
196195
chart.data = [[], [], []];
197196
for (var x = 0; x < stats.length; x++) {
198197
var model = stats[x].value;
199-
chart.data[0].push(model.minrun);
200-
chart.data[1].push(model.run);
201-
chart.data[2].push(model.maxrun);
202-
var id = stats[x]._id;
203-
var workflow = workflows.filter(x => x._id == id)[0];
204-
if (workflow == undefined) { chart.labels.push("unknown"); } else { chart.labels.push(workflow.name); }
205-
198+
var _id = stats[x]._id;
199+
var workflow = workflows.filter(y => y._id == _id)[0];
200+
if (workflow !== undefined) {
201+
chart.data[0].push(model.minrun);
202+
chart.data[1].push(model.run);
203+
chart.data[2].push(model.maxrun);
204+
var id = stats[x]._id;
205+
var workflow = workflows.filter(x => x._id == id)[0];
206+
if (workflow == undefined) { chart.labels.push("unknown"); } else { chart.labels.push(workflow.name); }
207+
}
206208
}
207209
this.charts.push(chart);
208210

@@ -886,6 +888,7 @@ module openflow {
886888
if (!this.$scope.$$phase) { this.$scope.$apply(); }
887889
}
888890
async submit(): Promise<void> {
891+
console.log(this.model);
889892
if (this.showjson) {
890893
this.model = JSON.parse(this.jsonmodel);
891894
}

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.119
1+
0.0.120

0 commit comments

Comments
 (0)