-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from BuildFire/A-H
Final release.
- Loading branch information
Showing
24 changed files
with
891 additions
and
294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
class Histories { | ||
constructor() {} | ||
|
||
// Get the big Object (history object) | ||
static getHistories(clientProfile) { | ||
return new Promise((resolve, reject) => { | ||
buildfire.publicData.get( | ||
`history${clientProfile}`, | ||
(err, result) => { | ||
if (err) reject(err); | ||
else { | ||
// Check if there is already objects in the database | ||
if (!result.data.metrics) { | ||
// If there is no object, then create the parent object | ||
buildfire.publicData.save( | ||
{ metrics: {} }, | ||
`history${clientProfile}`, | ||
(err, result) => { | ||
if (err) reject(err); | ||
else { | ||
this.getHistories().then((result) => { | ||
resolve(result); | ||
}); | ||
} | ||
} | ||
); | ||
} else { | ||
result.data.id = result.id; | ||
resolve(result.data); | ||
} | ||
} | ||
} | ||
); | ||
}); | ||
} | ||
|
||
// // Add new history in the big object (Control Panel Only) | ||
// static insert({ clientProfile, nodeSelector, historyId }, history) { | ||
// return new Promise((resolve, reject) => { | ||
// if (!nodeSelector) reject("nodeSelector not provided"); | ||
// if (!historyId) reject("historyId not provided"); | ||
|
||
// buildfire.publicData.update( | ||
// historyId, | ||
// { $set: { [`${nodeSelector}.${history.id}`]: history } }, | ||
// `history${clientProfile}`, | ||
// (err, result) => { | ||
// if (err) reject(err); | ||
// else { | ||
// result.data.id = historyId; | ||
// resolve(result.data); | ||
// } | ||
// } | ||
// ); | ||
// }); | ||
// } | ||
|
||
// // To delete any history (Control Panel Only) | ||
// static delete({ clientProfile, nodeSelector, historyId }, id) { | ||
// return new Promise((resolve, reject) => { | ||
// if (!nodeSelector) reject("nodeSelector not provided"); | ||
// if (!historyId) reject("historyId not provided"); | ||
|
||
// buildfire.publicData.update( | ||
// historyId, | ||
// { | ||
// $unset: { | ||
// [`${nodeSelector}.${id}`]: "", | ||
// }, | ||
// }, | ||
// `history${clientProfile}`, | ||
// (err, result) => { | ||
// if (err) reject(err); | ||
// else { | ||
// result.data.id = historyId; | ||
// resolve(result.data); | ||
// } | ||
// } | ||
// ); | ||
// }); | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class ClientHistory { | ||
constructor(data = {}) { | ||
this.id = data.id || ""; | ||
this.history = data.history || []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.