Skip to content

Commit

Permalink
Merge pull request #7 from BuildFire/A-H
Browse files Browse the repository at this point in the history
Updated code performance, and history feature.
  • Loading branch information
ahabeb authored Nov 20, 2020
2 parents 22e73e9 + 92f1d6d commit 86abd1a
Show file tree
Hide file tree
Showing 15 changed files with 364 additions and 373 deletions.
5 changes: 3 additions & 2 deletions control/content/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ const initIconComponent = (imageUrl = "") => {
imageUrl: imageUrl,
title: "Icon",
dimensionsLabel: "400x400",
multiSelection: false
});

let thumbElement = document
Expand Down Expand Up @@ -399,7 +400,7 @@ const renderInit = () => {

// Filter Metrics before rendering
helpers
.filterCustomerMetrics(metrics, clientProfile)
.filterClientMetrics(metrics, clientProfile)
.then((filteredMetrics) => {
metrics.metrics = filteredMetrics;

Expand Down Expand Up @@ -637,7 +638,7 @@ const updateDescription = (description) => {

// Filter Metrics on data change
helpers
.filterCustomerMetrics(metrics, clientProfile)
.filterClientMetrics(metrics, clientProfile)
.then((filteredMetrics) => {
metrics.metrics = filteredMetrics;
});
Expand Down
46 changes: 0 additions & 46 deletions control/content/js/classes/histories.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,50 +33,4 @@ class Histories {
);
});
}

// // 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);
// }
// }
// );
// });
// }
}
4 changes: 1 addition & 3 deletions control/content/js/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ const helpers = {
// Create a GUID ID
uuidv4: (m = Math, d = Date, h = 16, s = (s) => m.floor(s).toString(h)) =>
s(d.now() / 1000) + " ".repeat(h).replace(/./g, () => s(m.random() * h)),
// Return absolute date
getAbsoluteDate: () => new Date(new Date().setHours(0, 0, 0, 0)),
// Extract the children of a specific metric from the big object via the node selector
nodeSplitter: (nodeSelector, metrics) => {
let splittedNode = nodeSelector.split(".");
Expand Down Expand Up @@ -112,7 +110,7 @@ const helpers = {
});
},
// Filter Metrics based on the provided customer
filterCustomerMetrics(metrics, clientProfile) {
filterClientMetrics(metrics, clientProfile) {
return new Promise((resolve, reject) => {
// Get client history data;
Histories.getHistories(clientProfile).then((result) => {
Expand Down
12 changes: 12 additions & 0 deletions control/settings/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,24 @@ Settings.load().then(() => {
initMaterialComponents();
// Use element id and assign the new data to it's value
showSummary.checked = Settings.showSummary;
if (Settings.dataPolicyType === "public") {
document.getElementById("dataPublicType").checked = true;
document.getElementById("dataPrivateType").checked = false;
}
if (Settings.dataPolicyType === "private") {
document.getElementById("dataPrivateType").checked = true;
document.getElementById("dataPublicType").checked = false;
}
renderTags();
});

const onFieldChange = (field) => {
if (field === "showSummary") {
Settings[field] = document.getElementById(field).checked;
} else if (field === "dataPolicyType") {
let publicRadio = document.getElementById("dataPublicType").checked;
if (publicRadio) Settings[field] = "public";
else Settings[field] = "private";
}
updateSettings();
};
Expand Down
178 changes: 112 additions & 66 deletions control/settings/index.html
Original file line number Diff line number Diff line change
@@ -1,79 +1,125 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="buildfire" content="enableMDTheme" />

<!-- build:bundleControlBFMinJS -->
<script src="../../../../scripts/buildfire.js"></script>
<!-- endbuild -->
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="buildfire" content="enableMDTheme" />

<!-- Material Design css & js -->
<link
href="../../../../styles/materialDesign/[email protected]"
rel="stylesheet"
/>
<!-- build:bundleControlBFMinJS -->
<script src="../../../../scripts/buildfire.js"></script>
<!-- endbuild -->

<script
src="../../../../scripts/materialDesign/[email protected]"
type="text/javascript"
></script>
<!-- Material Icons -->
<link
href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet"
/>
<!-- build:bundleCSSFiles -->
<link rel="stylesheet" href="style.css" />
<!-- endbuild -->
</head>
<!-- Material Design css & js -->
<link href="../../../../styles/materialDesign/[email protected]" rel="stylesheet" />

<body>
<label for="showSummary" class="show-summary-lable"
>Show Summary
<div class="mdc-touch-target-wrapper show-summary-input">
<div class="mdc-checkbox mdc-checkbox--touch">
<input
type="checkbox"
class="mdc-checkbox__native-control"
id="showSummary"
onchange="onFieldChange('showSummary')"
/>
<div class="mdc-checkbox__background">
<svg class="mdc-checkbox__checkmark" viewBox="0 0 24 24">
<path
class="mdc-checkbox__checkmark-path"
fill="none"
d="M1.73,12.91 8.1,19.28 22.79,4.59"
/>
</svg>
<div class="mdc-checkbox__mixedmark"></div>
<script src="../../../../scripts/materialDesign/[email protected]" type="text/javascript"></script>
<!-- Material Icons -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
<!-- build:bundleCSSFiles -->
<link rel="stylesheet" href="style.css" />
<!-- endbuild -->
</head>

<body>
<div class="mdc-layout-grid">
<div class="mdc-layout-grid__inner block">
<span class="mdc-layout-grid__cell--span-2 text-body-light">Show Summary</span>
<span class="mdc-layout-grid__cell--span-4 text-body">
<div class="mdc-touch-target-wrapper show-summary-input">
<div class="mdc-checkbox mdc-checkbox--touch">
<input type="checkbox" class="mdc-checkbox__native-control" id="showSummary"
onchange="onFieldChange('showSummary')" />
<div class="mdc-checkbox__background">
<svg class="mdc-checkbox__checkmark" viewBox="0 0 24 24">
<path class="mdc-checkbox__checkmark-path" fill="none" d="M1.73,12.91 8.1,19.28 22.79,4.59" />
</svg>
<div class="mdc-checkbox__mixedmark"></div>
</div>
<div class="mdc-checkbox__ripple"></div>
</div>
</div>
</span>
</div>

<div class="mdc-layout-grid__inner block">
<span class="mdc-layout-grid__cell--span-2 text-body-light">Data Policy Type</span>
<span class="mdc-layout-grid__inner mdc-layout-grid__cell--span-6">
<div class="mdc-layout-grid__cell--span-3">
<div class="mdc-form-field demo-radio-form-field">
<div class="mdc-radio mdc-ripple-upgraded mdc-ripple-upgraded--unbounded" style="
--mdc-ripple-fg-size: 24px;
--mdc-ripple-fg-scale: 1.66667;
--mdc-ripple-left: 8px;
--mdc-ripple-top: 8px;
">
<input class="mdc-radio__native-control" type="radio" id="dataPublicType" name="data-policy-radio-set"
checked="true" onclick="onFieldChange('dataPolicyType')" />
<div class="mdc-radio__background">
<div class="mdc-radio__outer-circle"></div>
<div class="mdc-radio__inner-circle"></div>
</div>
<div class="mdc-radio__ripple"></div>
</div>
<label for="publicType">Public</label>
</div>
</div>
<div class="mdc-layout-grid__cell--span-3">
<div class="mdc-form-field demo-radio-form-field">
<div class="mdc-radio mdc-ripple-upgraded mdc-ripple-upgraded--unbounded" style="
--mdc-ripple-fg-size: 24px;
--mdc-ripple-fg-scale: 1.66667;
--mdc-ripple-left: 8px;
--mdc-ripple-top: 8px;
">
<input class="mdc-radio__native-control" type="radio" id="dataPrivateType" name="data-policy-radio-set"
onclick="onFieldChange('dataPolicyType')" />
<div class="mdc-radio__background">
<div class="mdc-radio__outer-circle"></div>
<div class="mdc-radio__inner-circle"></div>
</div>
<div class="mdc-radio__ripple"></div>
</div>
<label for="privateType">Private</label>
</div>
<div class="mdc-checkbox__ripple"></div>
</div>
</div>
</label>
<br />
</span>
<div class="mdc-layout-grid__cell--span-10">
<ul class="text-body-light">
<li>Public: Anyone on app can see and update the data (Update if user have access).</li>
<li>Private: Each user can only access his data.</li>
</ul>
</div>
</div>

<div class="form-group select-tags">
<label>User tags: </label>
<div class="mdc-chip-set mdc-chip-set--choice" id="tag-chips" role="grid">
<p class="info">No tags are selected</p>
</div>
<div class="mdc-layout-grid__inner block">
<span class="mdc-layout-grid__cell--span-2 text-body-light">User tags
</span>
<span class="mdc-layout-grid__cell--span-6">
<div class="mdc-chip-set mdc-chip-set--choice" id="tag-chips" role="grid">
<p class="info">No tags are selected</p>
</div>
</span>
</div>

<div class="form-group">
<button class="mdc-button mdc-button--raised" onclick="setTags()">
<div class="mdc-button__ripple"></div>
<i class="material-icons mdc-button__icon" aria-hidden="true">add</i>
<span class="mdc-button__label">Select Tags</span>
</button>
<div class="mdc-layout-grid__inner block">
<span class="mdc-layout-grid__cell--span-4 text-body-light">
<div class="form-group">
<button class="mdc-button mdc-button--raised" onclick="setTags()">
<div class="mdc-button__ripple"></div>
<i class="material-icons mdc-button__icon" aria-hidden="true">add</i>
<span class="mdc-button__label">Select Tags</span>
</button>
</div>
</div>
</div>



<!-- build:bundleJSFiles -->
<script src="js/authManager.js"></script>
<script src="js/classes/settings.js"></script>
<script src="app.js"></script>
<!-- endbuild -->
</body>

<!-- build:bundleJSFiles -->
<script src="js/authManager.js"></script>
<script src="js/classes/settings.js"></script>
<script src="app.js"></script>
<!-- endbuild -->
</body>
</html>
</html>
3 changes: 3 additions & 0 deletions control/settings/js/classes/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class Settings {
constructor() {
this.showSummary;
this.tags;
this.dataPolicyType;
}

static load() {
Expand All @@ -11,6 +12,7 @@ class Settings {
else {
this.tags = result.data.tags || [];
this.showSummary = result.data.showSummary === false ? false : true;
this.dataPolicyType = result.data.dataPolicyType || "public";
resolve(result);
}
});
Expand All @@ -21,6 +23,7 @@ class Settings {
let settings = {
tags: this.tags,
showSummary: this.showSummary,
dataPolicyType: this.dataPolicyType,
lastUpdatedBy: username,
};

Expand Down
20 changes: 18 additions & 2 deletions control/settings/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,24 @@
margin-bottom: 10px;
}

.block {
margin-bottom: 1.5rem;
}

.text-body {
margin-top: 0.5rem;
font-size: 0.9rem;
}

.text-body-light {
font-size: 0.91rem;
margin-top: 0.5rem;
color: #777777;
}

.show-summary-input {
position: relative;
top: 13px;
top: -13px;
}

.select-tags {
Expand All @@ -32,5 +47,6 @@ p.info {
padding: 8px 15px;
float: left;
width: 100%;
margin-bottom: 0;
margin: 0;
margin-top: -4px;
}
Loading

0 comments on commit 86abd1a

Please sign in to comment.