Lee Morgan před 6 roky
rodič
revize
b404992547

+ 0 - 119
views/dataPage/data.css

@@ -1,119 +0,0 @@
-body, html{
-    height: 100%;
-    margin: 0;
-    padding: 0;
-}
-
-#title{
-    font-size: 45px;
-    color: rgb(255, 99, 107);
-    text-align: center;
-    margin-top: 25px;
-}
-
-.checkboxDiv{
-    display: flex;
-}
-
-    .checkboxDiv > *{
-        margin: 2px;
-    }
-
-.dates{
-    display: flex;
-    justify-content: center;
-}
-
-    .dates > *{
-        margin: 10px;
-    }
-
-canvas{
-    flex-grow: 9;
-    height: 64vh;
-}
-
-/* Home Strand */
-#homeStrand{
-    flex-direction: column;
-    align-items: center;
-}
-
-    #homeStrand > *{
-        margin: 15px;
-    }
-
-    .tables{
-        display: flex;
-        justify-content: space-around;
-        width: 100%;
-    }
-
-    .dataTable{
-        display: flex;
-        flex-direction: column;
-        align-items: center;
-    }
-
-/* Ingredient Strand */
-#ingredientStrand{
-    flex-direction: column;
-    align-items: space-between;
-}
-
-    #ingredientStrand > *{
-        margin: 10px;
-    }
-
-    .canvasBox{
-        display: flex;
-        justify-content: space-between;
-    }
-
-    #ingredientOptions{
-        flex-grow: 1;
-        display: flex;
-        flex-direction: column;
-    }
-
-/* Recipe Strand */
-#recipeStrand{
-    flex-direction: column;
-    align-items: space-between;
-}
-
-    #recipeStrand > *{
-        margin: 10px;
-    }
-
-    .canvasBox{
-        display: flex;
-        justify-content: space-between;
-    }
-
-    #recipeOptions{
-        flex-grow: 1;
-        display: flex;
-        flex-direction: column;
-    }
-
-/* Purchase Strand */
-#purchaseStrand{
-    flex-direction: column;
-    align-items: space-between;
-}
-
-    #purchaseStrand > *{
-        margin: 10px;
-    }
-
-    .canvasBox{
-        display: flex;
-        justify-content: space-between;
-    }
-
-    #recipeOptions{
-        flex-grow: 1;
-        display: flex;
-        flex-direction: column;
-    }

+ 0 - 165
views/dataPage/data.ejs

@@ -1,165 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-    <head>
-        <meta charset="utf-8">
-        <title>The Subline</title>
-        <link rel="icon" type="img/png" href="/shared/images/logo.png">
-        <link rel="stylesheet" href="/shared/shared.css">
-        <link rel="stylesheet" href="/dataPage/data.css">
-    </head>
-    <body>
-        <% include ../shared/header %>
-
-        <% include ../shared/banner %>
-
-        <h1 id="title"><%=data.merchant.name%></h1>
-
-        <strand-selector></strand-selector>
-
-        <div id="homeStrand" class="strand">
-            <h2 id="month"></h2>
-
-            <div class="dates">
-                <label>From:
-                    <input id="homeFrom" type="date" onchange="window.homeObj.newDates()">
-                </label>
-                
-                <label>To:
-                    <input id="homeTo" type="date" onchange="window.homeObj.newDates()">
-                </label>
-            </div>
-
-            <div class="buttonBox">
-                <a class="button" href="/dashboard">Display Inventory</a>
-            </div>
-            
-            <div class="tables">
-                <!-- Ingredients used -->
-                <div id="ingredientsData" class="dataTable">
-                    <h3>Ingredients</h3>
-                    <table>
-                        <thead>
-                            <tr>
-                                <th>Ingredient</th>
-                                <th>Used</th>
-                                <th>Remaining</th>
-                            </tr>
-                        </thead>
-                        <tbody></tbody>
-                    </table>
-                </div>
-
-                <!-- Recipes used -->
-                <div id="recipesData" class="dataTable">
-                    <h3>Recipes</h3>
-
-                    <div>
-                        <p>Total Revenue: <span id="revenueTotal"></span></p>
-                        <p>Total sold: <span id="soldTotal"></span></p>
-                    </div>
-
-                    <table>
-                        <thead>
-                            <tr>
-                                <th>Recipe</th>
-                                <th># sold</th>
-                                <th>Revenue</th>
-                            </tr>
-                        </thead>
-                        <tbody></tbody>
-                    </table>
-                </div>
-
-                <!-- Purchases -->
-                <div id="purchasesData" class="dataTable">
-                    <h3>Purchases</h3>
-
-                    <table>
-                        <thead>
-                            <tr>
-                                <th>Ingredient</th>
-                                <th>Amount</th>
-                            </tr>
-                        </thead>
-                        <tbody></tbody>
-                    </table>
-                </div>
-            </div>
-        </div>
-
-        <div id="ingredientStrand" class="strand">
-            <div class="dates">
-                <label>From:
-                    <input id="ingredientFrom" type="date" onchange="window.ingredientObj.newDates()">
-                </label>
-                
-                <label>To:
-                    <input id="ingredientTo" type="date" onchange="window.ingredientObj.newDates()">
-                </label>
-            </div>
-
-            <div class="canvasBox">
-                <div id="ingredientOptions"></div>
-
-                <canvas></canvas>
-            </div>
-        </div>
-
-        <div id="recipeStrand" class="strand">
-            <div class="dates">
-                <label>From:
-                    <input id="recipeFrom" type="date" onchange="window.recipeObj.newDates()">
-                </label>
-                
-                <label>To:
-                    <input id="recipeTo" type="date" onchange="window.recipeObj.newDates()">
-                </label>
-            </div>
-
-            <div class="canvasBox">
-                <div id="recipeOptions"></div>
-
-                <canvas></canvas>
-            </div>
-        </div>
-
-        <div id="purchaseStrand" class="strand">
-            <div class="dates">
-                <label>From:
-                    <input id="purchaseFrom" type="date" onchange="window.purchaseObj.newDates()">
-                </label>
-                
-                <label>To:
-                    <input id="purchaseTo" type="date" onchange="window.purchaseObj.newDates()">
-                </label>
-            </div>
-
-            <div class="canvasBox">
-                <div id="purchaseOptions"></div>
-
-                <canvas></canvas>
-            </div>
-        </div>
-
-        <script>
-            let data = <%- JSON.stringify(data); %>;
-
-            for(let transaction of data.transactions){
-                transaction.date = new Date(transaction.date);
-            }
-
-            for(let purchase of data.purchases){
-                purchase.date = new Date(purchase.date);
-            }
-        </script>
-        <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
-        <script src="/shared/validation.js"></script>
-        <script src="/dataPage/home.js"></script>
-        <script src="/dataPage/ingredient.js"></script>
-        <script src="/dataPage/recipe.js"></script>
-        <script src="/dataPage/purchase.js"></script>
-        <script src="/shared/controller.js"></script>
-        <script src="/shared/graphs.js"></script>
-        <script src="/dataPage/fetchData.js"></script>
-    </body>
-</html>

+ 0 - 120
views/dataPage/fetchData.js

@@ -1,120 +0,0 @@
-window.fetchData = function(from, to, callback){
-    retrieveDates = [];
-
-    //Compares dates to dates already stored and makes a list of those needed
-    let fromCopy = new Date(from);
-    for(let i = 0; i < data.dates.length; i+=2){
-        if(to <= new Date(data.dates[0]) || fromCopy >= new Date(data.dates[data.dates.length - 1])){
-            retrieveDates.push(fromCopy);
-            retrieveDates.push(to);
-            break;
-        }
-
-        let date0 = new Date(data.dates[i]);
-        let date1 = new Date(data.dates[i+1]);
-
-        if(fromCopy < date0){
-            retrieveDates.push(fromCopy);
-            retrieveDates.push(date0);
-            fromCopy = date1;
-        }else if(fromCopy > date0 && fromCopy < date1){
-            fromCopy = date1;
-        }
-    }
-
-    if(retrieveDates.length > 0){
-        axios.post("/getData", {dates: retrieveDates})
-            .then((response)=>{
-                if(typeof(response.data) === "string"){
-                    banner.createError(response.data);
-                }else{
-                    let mergedDates = [];
-                    let oldIndex = 0;
-                    let newIndex = 0;
-
-                    while(oldIndex + newIndex < retrieveDates.length + data.dates.length){
-                        let oldDateOne = new Date(data.dates[oldIndex]);
-                        let oldDateTwo = new Date(data.dates[oldIndex+1]);
-                        if(oldDateOne < retrieveDates[newIndex] || newIndex >= retrieveDates.length){
-                            if(mergedDates.length > 0 && oldDateOne.getTime() === mergedDates[mergedDates.length-1].getTime()){
-                                mergedDates[mergedDates.length-1] = oldDateTwo;
-                            }else{
-                                mergedDates.push(oldDateOne);
-                                mergedDates.push(oldDateTwo);
-                            }
-                            oldIndex += 2;
-                        }else{
-                            if(mergedDates.length > 0 && retrieveDates[newIndex].getTime() === mergedDates[mergedDates.length-1].getTime()){
-                                mergedDates[mergedDates.length-1] = retrieveDates[newIndex+1];
-                            }else{
-                                mergedDates.push(retrieveDates[newIndex]);
-                                mergedDates.push(retrieveDates[newIndex+1]);
-                            }
-                            newIndex += 2;
-                        }
-                    }
-
-                    data.dates = mergedDates;
-
-                    for(let set of response.data){
-                        for(let transaction of set.transactions){
-                            transaction.date = new Date(transaction.date);
-                            transaction.date.setMinutes(transaction.date.getMinutes() + transaction.date.getTimezoneOffset());
-                        }
-
-                        if(set.transactions[0].date < data.transactions[0].date){
-                            data.transactions = set.transactions.concat(data.transactions);
-                        }else if(set.transactions[set.transactions.length-1].date > data.transactions[data.transactions.length-1].date){
-                            data.transactions = data.transactions.concat(set.transactions);
-                        }else{
-                            for(let i = 0; i < data.transactions.length; i++){
-                                if(set.transactions[0].date > data.transactions[i].date){
-                                    data.transactions = data.transactions.slice(0, i).concat(set.transactions).concat(data.transactions.slice(i, data.transactions.length - 1));
-                                    break;
-                                }
-                            }
-                        }
-
-                        for(let purchase of set.purchases){
-                            purchase.date = new Date();
-                            purchase.date.setMinutes(purchase.date.getMinutes() + purchase.date.getTimezoneOffset());
-                        }
-
-                        if(set.purchases.length > 0){
-                            if(data.purchases.length === 0){
-                                data.purchases = set.purchases;
-                            }else if(set.purchases[0].date < data.purchases[0].date){
-                                data.purchases = set.purchases.concat(data.purchases);
-                            }else if(set.purchases[set.purchases.length-1].date > data.purchases[data.purchases.length-1].date){
-                                data.purchases = data.purchases.concat(set.purchases);
-                            }else{
-                                for(let i = 0; i < data.purchases.length; i++){
-                                    if(set.purchases[0].date > data.purchases[i].date){
-                                        data.purchases = data.purchases.slice(0, i).concat(set.purchases).concat(data.purchases.slice(i, data.purchases.length - 1));
-                                        break;
-                                    }
-                                }
-                            }
-                        }
-                    }
-
-                    callback();
-                }
-            })
-            .catch((err)=>{});
-    }else{
-
-        callback();
-    }
-}
-
-window.getInputDates = function(name){
-    let from = document.querySelector(`#${name}From`).valueAsDate;
-    let to = document.querySelector(`#${name}To`).valueAsDate;
-
-    from.setMinutes(from.getMinutes() + from.getTimezoneOffset());
-    to.setMinutes(to.getMinutes() + to.getTimezoneOffset());
-    to.setDate(to.getDate() + 1);
-
-    return [from, to];
-}

+ 0 - 220
views/dataPage/home.js

@@ -1,220 +0,0 @@
-window.homeObj = {
-    isPopulated: false,
-    recipeTotal: 0,
-    revenueTotal: 0,
-    dateFrom: "",
-    dateTo: "",
-
-    display: function(){
-        clearScreen();
-        document.querySelector("#homeStrand").style.display = "flex";
-        
-        if(!this.isPopulated){
-            this.populate(data.transactions);
-
-            let date = new Date(new Date().getFullYear(), new Date().getMonth(), 1);
-            document.querySelector("#homeFrom").valueAsDate = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 12);
-            document.querySelector("#homeTo").valueAsDate = new Date();
-
-            this.isPopulated = true;
-        }
-    },
-
-    populate: function(transactions){
-        this.recipeTotal = 0;
-        this.revenueTotal = 0;
-        
-        //Create object to store number of recipes sold
-        let recipes = [];
-        for(let recipe of data.merchant.recipes){
-            recipes.push({
-                id: recipe._id,
-                name: recipe.name,
-                quantity: 0,
-                ingredients: recipe.ingredients,
-                price: recipe.price / 100
-            });
-        }
-
-        //Create object to store amount of ingredients sold
-        let soldIngredients = [];
-        for(let item of data.merchant.inventory){
-            soldIngredients.push({
-                id: item.ingredient._id,
-                name: item.ingredient.name,
-                quantity: 0,
-                quantityRemaining: item.quantity,
-                unit: item.ingredient.unit
-            });
-        }
-
-        //Create object for each merchant ingredient
-        let purchaseIngredients = [];
-        for(let item of data.merchant.inventory){
-            purchaseIngredients.push({
-                id: item.ingredient._id,
-                name: item.ingredient.name,
-                amount: 0,
-                unit: item.ingredient.unit
-            });
-        }
-        
-        //Populate number of recipes sold
-        let i = 0;
-        for(let transaction of transactions){
-            for(let recipe of transaction.recipes){
-                for(let newRecipe of recipes){
-                    if(recipe.recipe === newRecipe.id){
-                        newRecipe.quantity += recipe.quantity;
-                        this.recipeTotal += recipe.quantity;
-                        this.revenueTotal += (newRecipe.price * recipe.quantity);
-                        break;
-                    }
-                }
-            }
-        }
-
-        //Populate amount of ingredients sold
-        for(let recipe of recipes){
-            for(let recipeIngredient of recipe.ingredients){
-                for(let newIngredient of soldIngredients){
-                    if(newIngredient.id === recipeIngredient.ingredient){
-                        newIngredient.quantity += (recipeIngredient.quantity * recipe.quantity);
-                        break;
-                    }
-                }
-            }
-        }
-
-        //Populate amount of ingredients purchased
-        for(let purchase of data.purchases){
-            for(let newPurchaseIngredient of purchase.ingredients){
-                for(let newIngredient of purchaseIngredients){
-                    if(newIngredient.id === newPurchaseIngredient.ingredient){
-                        newIngredient.amount += newPurchaseIngredient.quantity;
-                        break;
-                    }
-                }
-            }
-        }
-
-        //Populate Ingredients table
-        let ingredientsBody = document.querySelector("#ingredientsData tbody");
-
-        while(ingredientsBody.children.length > 0){
-            ingredientsBody.removeChild(ingredientsBody.firstChild);
-        }
-        
-        for(let ingredient of soldIngredients){
-            let row = document.createElement("tr");
-            ingredientsBody.appendChild(row);
-            row.classList = "clickableRow";
-            row.onclick = ()=>{window.ingredientObj.display(ingredient)};
-            
-
-            let name = document.createElement("td");
-            name.innerText = `${ingredient.name} (${ingredient.unit})`;
-            row.appendChild(name);
-
-            let used = document.createElement("td");
-            used.innerText = ingredient.quantity;
-            row.appendChild(used);
-
-            let remaining = document.createElement("td");
-            remaining.innerText = ingredient.quantityRemaining;
-            row.appendChild(remaining);
-        }
-
-        //Populate recipes table
-        let recipesBody = document.querySelector("#recipesData tbody");
-
-        while(recipesBody.children.length > 0){
-            recipesBody.removeChild(recipesBody.firstChild);
-        }
-
-        for(let recipe of recipes){
-            let row = document.createElement("tr");
-            row.classList = "clickableRow";
-            row.onclick = ()=>{window.recipeObj.display(recipe)};
-            recipesBody.appendChild(row);
-
-            let name = document.createElement("td");
-            name.innerText = recipe.name;
-            row.appendChild(name);
-
-            let quantity = document.createElement("td");
-            quantity.innerText = recipe.quantity;
-            row.appendChild(quantity);
-
-            let revenue = document.createElement("td");
-            revenue.innerText = `$${(recipe.quantity * recipe.price).toFixed(2)}`;
-            row.appendChild(revenue);
-        }
-
-        //Populate purchases table
-        let purchasesBody = document.querySelector("#purchasesData tbody");
-
-        while(purchasesBody.children.length > 0){
-            purchasesBody.removeChild(purchasesBody.firstChild);
-        }
-        
-        for(let ingredient of purchaseIngredients){
-            let row = document.createElement("tr");
-            row.classList = "clickableRow";
-            row.onclick = ()=>{window.purchaseObj.display(ingredient)};
-            purchasesBody.appendChild(row);
-            
-            let name = document.createElement("td");
-            name.innerText = `${ingredient.name} (${ingredient.unit})`;
-            row.appendChild(name);
-
-            let amount = document.createElement("td");
-            amount.innerText = ingredient.amount;
-            row.appendChild(amount);
-        }
-
-        //Populate totals
-        document.querySelector("#revenueTotal").innerText = `$${this.revenueTotal.toFixed(2)}`;
-        document.querySelector("#soldTotal").innerText = this.recipeTotal;
-    },
-
-    newDates: function(){
-        let from = document.querySelector("#homeFrom").value;
-        let to = document.querySelector("#homeTo").value;
-
-        if(from === "" || to === ""){
-            banner.createError("Invalid date");
-            return;
-        }else{
-            from = new Date(from);
-            to = new Date(to);
-
-            from.setMinutes(from.getMinutes() + from.getTimezoneOffset());
-            to.setMinutes(to.getMinutes() + to.getTimezoneOffset());
-        }
-
-        if(validator.transaction.date(from, to)){
-            window.fetchData(from, to, ()=>{
-                let startIndex = 0;
-                let endIndex = data.transactions.length;
-
-                for(let i = 0; i < data.transactions.length; i++){
-                    if(from < data.transactions[i].date){
-                        startIndex = i;
-                        break;
-                    }
-                }
-    
-                for(let i = 0; i < data.transactions.length; i++){
-                    if(to < data.transactions[i].date){
-                        endIndex = i;
-                        break;
-                    }
-                }
-    
-                let newData = data.transactions.slice(startIndex, endIndex);
-                this.populate(newData);
-            });
-        }
-    }
-}

+ 0 - 117
views/dataPage/ingredient.js

@@ -1,117 +0,0 @@
-window.ingredientObj = {
-    isPopulated: false,
-    graph: {},
-
-    display: function(ingredient){
-        clearScreen();
-        document.querySelector("#ingredientStrand").style.display = "flex";
-        document.querySelector("strand-selector").setAttribute("strand", "ingredient");
-
-        if(!this.isPopulated){
-            let date = new Date(new Date().getFullYear(), new Date().getMonth(), 1);
-            document.querySelector("#ingredientFrom").valueAsDate = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 12);
-            document.querySelector("#ingredientTo").valueAsDate = new Date();
-
-            let ingredientsDiv = document.querySelector("#ingredientOptions");
-
-            for(let item of data.merchant.inventory){
-                let checkDiv = document.createElement("div");
-                checkDiv.classList = "checkboxDiv";
-                ingredientsDiv.appendChild(checkDiv);
-
-                let checkbox = document.createElement("input");
-                checkbox.type = "checkbox";
-                checkbox.id = `${item.ingredient.name}Checkbox`;
-                checkbox._id = item.ingredient._id;
-                checkbox.name = item.ingredient.name;
-                checkbox.onchange = ()=>{
-                    if(checkbox.checked){
-                        let from, to;
-                        [from, to] = getInputDates("ingredient");
-
-                        this.graph.addData(this.formatData(item.ingredient._id, from, to), [from, to], item.ingredient.name);
-                    }else{
-                        this.graph.removeData(item.ingredient.name);
-                    }
-                };
-                checkDiv.appendChild(checkbox);
-
-                let label = document.createElement("label");
-                label.innerText = item.ingredient.name;
-                label.setAttribute("for", `${item.ingredient.name}Checkbox`);
-                checkDiv.appendChild(label);
-            }
-
-            this.graph = new LineGraph(
-                document.querySelector("#ingredientStrand canvas"),
-                "Quantity",
-                "Date",
-            );
-
-            this.isPopulated = true;
-        }
-
-        if(ingredient){
-            this.graph.clearData();
-
-            let from, to;
-            [from, to] = getInputDates("ingredient");
-            
-            this.graph.addData(this.formatData(ingredient.id, from, to), [from, to], ingredient.name);
-
-            for(let label of document.querySelector("#ingredientOptions").children){
-                if(label.innerText === ingredient.name){
-                    label.children[0].checked = true;
-                }else{
-                    label.children[0].checked = false;
-                }
-            }
-        }
-    },
-
-    //TODO This can be made to be faster, no need to search full data list
-    formatData: function(id, startDate, endDate){
-        let dateRange = Math.floor((Date.UTC(endDate.getFullYear(), endDate.getMonth(), endDate.getDate()) - Date.UTC(startDate.getFullYear(), startDate.getMonth(), startDate.getDate())) / (1000 * 60 * 60 * 24)) + 1;
-        let dataList = new Array(Math.abs(dateRange)).fill(0);
-
-        for(let transaction of data.transactions){
-            let diff = Math.floor((Date.UTC(transaction.date.getFullYear(), transaction.date.getMonth(), transaction.date.getDate()) - Date.UTC(endDate.getFullYear(), endDate.getMonth(), endDate.getDate())) / (1000 * 60 * 60 * 24));
-
-            if(transaction.date > startDate && diff <= 0){
-                for(let recipe of transaction.recipes){
-                    for(let merchRecipe of data.merchant.recipes){
-                        if(merchRecipe._id === recipe.recipe){
-                            for(let ingredient of merchRecipe.ingredients){
-                                if(ingredient.ingredient === id){
-                                    dataList[dateRange - Math.abs(diff) - 1] += ingredient.quantity * recipe.quantity;
-                                }
-                            }
-                            break;
-                        }
-                    }
-                }
-            }
-        }
-
-        return dataList;
-    },
-
-    newDates: function(){
-        let from, to;
-        [from, to] = getInputDates("ingredient");
-
-        if(validator.transaction.date(from, to)){
-            fetchData(from, to, ()=>{
-                this.graph.clearData();
-
-                let ingredientsDiv = document.querySelector("#ingredientOptions");
-                for(let div of ingredientsDiv.children){
-                    let checkbox = div.children[0];
-                    if(checkbox.checked){
-                        this.graph.addData(this.formatData(checkbox._id, from, to), [from, to], checkbox.name);
-                    }
-                }
-            });
-        }
-    }
-}

+ 0 - 108
views/dataPage/purchase.js

@@ -1,108 +0,0 @@
-window.purchaseObj = {
-    isPopulated: false,
-    graph: {},
-
-    display: function(ingredient){
-        clearScreen();
-        document.querySelector("#purchaseStrand").style.display = "flex";
-        document.querySelector("strand-selector").setAttribute("strand", "purchase");
-
-        if(!this.isPopulated){
-            let date = new Date(new Date().getFullYear(), new Date().getMonth(), 1);
-            document.querySelector("#purchaseFrom").valueAsDate = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 12);
-            document.querySelector("#purchaseTo").valueAsDate = new Date();
-
-            let purchasesDiv = document.querySelector("#purchaseOptions");
-
-            for(let item of data.merchant.inventory){
-                let checkDiv = document.createElement("div");
-                checkDiv.classList = "checkboxDiv";
-                purchasesDiv.appendChild(checkDiv);
-
-                let checkbox = document.createElement("input");
-                checkbox.type = "checkbox";
-                checkbox.id = `${item.ingredient.name}PurchaseCheckbox`;
-                checkbox._id = item.ingredient._id;
-                checkbox.name = item.ingredient.name;
-                checkbox.onchange = ()=>{
-                    if(checkbox.checked){
-                        let from, to;
-                        [from, to] = getInputDates("purchase");
-
-                        this.graph.addData(this.formatData(item.ingredient._id, from, to), [from, to], item.ingredient.name);
-                    }else{
-                        this.graph.removeData(item.ingredient.name);
-                    }
-                };
-                checkDiv.appendChild(checkbox);
-
-                let label = document.createElement("label");
-                label.innerText = item.ingredient.name;
-                label.setAttribute("for", `${item.ingredient.name}PurchaseCheckbox`);
-                checkDiv.appendChild(label);
-            }
-
-            this.graph = new LineGraph(
-                document.querySelector("#purchaseStrand canvas"),
-                "Quantity",
-                "Date"
-            );
-
-            this.isPopulated = true;
-        }
-
-        if(ingredient){
-            this.graph.clearData();
-
-            let from, to;
-            [from, to] = getInputDates("purchase");
-
-            this.graph.addData(this.formatData(ingredient.id, from, to), [from, to], ingredient.name);
-
-            for(let label of document.querySelector("#purchaseOptions").children){
-                if(label.innerText === ingredient.name){
-                    label.children[0].checked = true;
-                }else{
-                    label.children[0].checked = false;
-                }
-            }
-        }
-    },
-
-    //TODO This can be made to be faster, no need to search full data list
-    formatData: function(id, from, to){
-        let dateRange = Math.floor((Date.UTC(to.getFullYear(), to.getMonth(), to.getDate()) - Date.UTC(from.getFullYear(), from.getMonth(), from.getDate())) / (1000 * 60 * 60 * 24)) + 1;
-        let dataList = new Array(Math.abs(dateRange)).fill(0);
-        
-        for(let purchase of data.purchases){
-            let diff = Math.floor((Date.UTC(purchase.date.getFullYear(), purchase.date.getMonth(), purchase.date.getDate()) - Date.UTC(to.getFullYear(), to.getMonth(), to.getDate())) / (1000 * 60 * 60 * 24));
-
-            for(let ingredient of purchase.ingredients){
-                if(purchase.date > from && diff <=0 && id === ingredient.ingredient){
-                    dataList[dateRange - Math.abs(diff) - 1] += ingredient.quantity;
-                }
-            }
-        }
-
-        return dataList;
-    },
-
-    newDates: function(){
-        let from, to;
-        [from, to] = getInputDates("purchase");
-
-        if(validator.transaction.date(from, to)){
-            fetchData(from, to, ()=>{
-                this.graph.clearData();
-
-                let purchaseDiv = document.querySelector("#purchaseOptions");
-                for(let div of purchaseDiv.children){
-                    let checkbox = div.children[0];
-                    if(checkbox.checked){
-                        this.graph.addData(this.formatData(checkbox._id, from, to), [from, to], checkbox.name);
-                    }
-                }
-            });
-        }
-    }
-}

+ 0 - 112
views/dataPage/recipe.js

@@ -1,112 +0,0 @@
-window.recipeObj = {
-    isPopulated: false,
-    graph: {},
-
-    display: function(recipe){
-        clearScreen();
-        document.querySelector("#recipeStrand").style.display = "flex";
-        document.querySelector("strand-selector").setAttribute("strand", "recipe");
-
-        if(!this.isPopulated){
-            let date = new Date(new Date().getFullYear(), new Date().getMonth(), 1);
-            document.querySelector("#recipeFrom").valueAsDate = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 12);
-            document.querySelector("#recipeTo").valueAsDate = new Date();
-
-            let recipesDiv = document.querySelector("#recipeOptions");
-
-            for(let recipe of data.merchant.recipes){
-                let checkDiv = document.createElement("div");
-                checkDiv.classList = "checkboxDiv";
-                recipesDiv.appendChild(checkDiv);
-
-                let checkbox = document.createElement("input");
-                checkbox.type = "checkbox";
-                checkbox.id = `${recipe.name}Checkbox`;
-                checkbox._id = recipe._id;
-                checkbox.name = recipe.name;
-                checkbox.onchange = ()=>{
-                    if(checkbox.checked){
-                        let from, to;
-                        [from, to] = getInputDates("recipe");
-
-                        this.graph.addData(this.formatData(recipe._id, from, to), [from, to], recipe.name);
-                    }else{
-                        this.graph.removeData(recipe.name);
-                    }
-                };
-                checkDiv.appendChild(checkbox);
-
-                let label = document.createElement("label");
-                label.innerText = recipe.name;
-                label.setAttribute("for", `${recipe.name}Checkbox`);
-                checkDiv.appendChild(label);
-            }
-
-            this.graph = new LineGraph(
-                document.querySelector("#recipeStrand canvas"),
-                "Quantity",
-                "Date"
-            );
-
-            this.isPopulated = true;
-        }
-
-        if(recipe){
-            this.graph.clearData();
-
-            let from, to;
-            [from, to] = getInputDates("recipe");
-
-            this.graph.addData(this.formatData(recipe.id, from, to), [from, to], recipe.name);
-
-            for(let label of document.querySelector("#recipeOptions").children){
-                if(label.innerText === recipe.name){
-                    label.children[0].checked = true;
-                }else{
-                    label.children[0].checked = false;
-                }
-            }
-        }
-    },
-
-    //TODO This can be made to be faster, no need to search full data list
-    formatData: function(id, from, to){
-        let dateRange = Math.floor((Date.UTC(to.getFullYear(), to.getMonth(), to.getDate()) - Date.UTC(from.getFullYear(), from.getMonth(), from.getDate())) / (1000 * 60 * 60 * 24)) + 1;
-        let dataList = new Array(Math.abs(dateRange)).fill(0);
-
-        for(let transaction of data.transactions){
-            let diff = Math.floor((Date.UTC(transaction.date.getFullYear(), transaction.date.getMonth(), transaction.date.getDate()) - Date.UTC(to.getFullYear(), to.getMonth(), to.getDate())) / (1000 * 60 * 60 * 24));
-
-            if(transaction.date > from && diff <= 0){
-                for(let recipe of transaction.recipes){
-                    if(recipe.recipe === id){
-                        dataList[dateRange - Math.abs(diff) - 1] += recipe.quantity;
-                    }
-                }
-            }
-        }
-
-        return dataList;
-    },
-
-    
-
-    newDates: function(){
-        let from, to;
-        [from, to] = getInputDates("recipe");
-
-        if(validator.transaction.date(from, to)){
-            window.fetchData(from, to, ()=>{
-                this.graph.clearData();
-
-                let recipesDiv = document.querySelector("#recipeOptions");
-                for(let div of recipesDiv.children){
-                    let checkbox = div.children[0];
-                    if(checkbox.checked){
-                        this.graph.addData(this.formatData(checkbox._id, from, to), [from, to], checkbox.name);
-                    }
-                }
-            })
-        }
-    }
-}

+ 0 - 96
views/oldDashboardPage/account.js

@@ -1,96 +0,0 @@
-window.accountObj = {
-    display: function(){
-        clearScreen();
-        document.querySelector("#accountStrand").style.display = "flex";
-    },
-
-    editAccount: function(){
-        event.preventDefault();
-
-        document.querySelector("#accountDisplay").style.display = "none";
-        document.querySelector("#accountEdit").style.display = "flex";
-    },
-
-    updateAccount: function(){
-        event.preventDefault();
-
-        let data = {
-            name: document.querySelector("#accountName").value,
-            email: document.querySelector("#accountEmail").value
-        }
-
-        if(validator.isSanitary(data.name) && validator.isSanitary(data.email)){
-            axios.post("/merchant/update", data)
-                .then((response)=>{
-                    if(typeof(response.data) === "string"){
-                        banner.createError(response.data);
-                    }else{
-                        document.querySelector("#title").innerText = data.name;
-
-                        merchant.name = data.name;
-                        merchant.email = data.email;
-
-                        document.querySelector("#accountDisplay").style.display = "flex";
-                        document.querySelector("#accountEdit").style.display = "none";
-
-                        let labels = document.querySelectorAll("#accountDisplay label");
-                        labels[0].children[0].innerText = merchant.name;
-                        labels[1].children[0].innerText = merchant.email;
-                    }
-                })
-                .catch((err)=>{
-                    banner.createError("Error: Your data could not be updated");
-                });
-        }
-    },
-
-    editAccountCancel: function(){
-        event.preventDefault();
-
-        document.querySelector("#accountDisplay").style.display = "flex";
-        document.querySelector("#accountEdit").style.display = "none";
-    },
-
-    editPassword: function(){
-        document.querySelector("#passwordEdit").style.display = "flex";
-        document.querySelector("#accountStrand > button").style.display = "none";
-    },
-
-    updatePassword: function(){
-        event.preventDefault();
-
-        let oldPass = document.querySelector("#oldPass").value;
-        let newPass = document.querySelector("#newPass").value;
-        let confirmNewPass = document.querySelector("#confirmNewPass").value;
-
-        if(validator.merchant.password(newPass, confirmNewPass)){
-            axios.post("/merchant/password", {oldPass: oldPass, newPass: newPass})
-                .then((response)=>{
-                    if(typeof(response.data) === "string"){
-                        banner.createError(response.data);
-                    }
-
-                    document.querySelector("#oldPass").value = "";
-                    document.querySelector("#newPass").value = "";
-                    document.querySelector("#confirmNewPass").value = "";
-
-                    document.querySelector("#passwordEdit").style.display = "none";
-                    document.querySelector("#accountStrand > button").style.display = "block";
-                })
-                .catch((err)=>{
-                    banner.createError("Error: please refresh page to check for updates");
-                });
-        }
-    },
-
-    editPasswordCancel: function(){
-        event.preventDefault();
-
-        document.querySelector("#oldPass").value = "";
-        document.querySelector("#newPass").value = "";
-        document.querySelector("#confirmNewPass").value = "";
-
-        document.querySelector("#passwordEdit").style.display = "none";
-        document.querySelector("#accountStrand > button").style.display = "block";
-    }
-}

+ 0 - 173
views/oldDashboardPage/addIngredient.js

@@ -1,173 +0,0 @@
-window.addIngredientObj = {
-    isPopulated: false,
-    rows: [],
-    currentSort: 0,
-
-    display: function(){
-        clearScreen();
-        document.querySelector("#addIngredientAction").style.display = "flex";
-
-        if(!this.isPopulated){
-            this.populate();
-            this.isPopulated = true;
-        }
-    },
-
-    populate: function(){        
-        axios.get("/ingredients")
-            .then((response)=>{
-                if(typeof(response.data) === "string"){
-                    banner.createError(response.data);
-                }else{
-                    for(let ingredient of response.data){
-                        let exists = false;
-                        for(let merchIngredient of merchant.inventory){
-                            if(ingredient._id === merchIngredient.ingredient._id){
-                                exists = true;
-                                break;
-                            }
-                        }
-
-                        let searchStr = document.querySelector("#addFilter").value;
-
-                        if(!exists && ingredient.name.includes(searchStr)){
-                            let row = document.createElement("tr");
-                            row._id = ingredient._id;
-                            this.rows.push(row);
-
-                            let checkbox = document.createElement("td");
-                            row.appendChild(checkbox);
-
-                            let checkboxInput = document.createElement("input");
-                            checkboxInput.type = "checkbox";
-                            checkbox.appendChild(checkboxInput);
-
-                            let name = document.createElement("td");
-                            name.innerText = ingredient.name;
-                            row.appendChild(name);
-
-                            let category = document.createElement("td");
-                            category.innerText = ingredient.category;
-                            row.appendChild(category);
-
-                            let unit = document.createElement("td");
-                            unit.innerText = ingredient.unit;
-                            row.appendChild(unit);
-
-                            let quantity = document.createElement("td");
-                            row.appendChild(quantity);
-
-                            let quantityInput = document.createElement("input");
-                            quantityInput.type = "number";
-                            quantityInput.step = "0.01";
-                            quantityInput.min = "0";
-                            quantity.appendChild(quantityInput);
-                        }
-                    }
-
-                    this.filterAndDisplay();
-                }
-            })
-            .catch((err)=>{
-                banner.createError("Error: Could not retrieve ingredients");
-                inventoryObj.display();
-            });
-    },
-
-    filterAndDisplay: function(){
-        let queryStr = document.querySelector("#addFilter").value;
-        let tbody = document.querySelector("#addIngredientAction tbody");
-
-        while(tbody.children.length > 0){
-            tbody.removeChild(tbody.firstChild);
-        }
-
-        for(let row of this.rows){
-            if(row.children[1].innerText.includes(queryStr)){
-                tbody.appendChild(row);
-            }
-        }
-    },
-
-    sort: function(child){
-        if(this.currentSort === child){
-            this.rows.sort((a, b) => (a.children[child].innerText > b.children[child].innerText) ? -1 : 1);
-            this.currentSort = 0;
-        }else{
-            this.rows.sort((a, b) => (a.children[child].innerText > b.children[child].innerText) ? 1 : -1);
-            this.currentSort = child;
-        }
-
-        this.filterAndDisplay();
-    },
-
-    submitAdd: function(){
-        event.preventDefault();
-
-        let addList = [];
-
-        for(let row of this.rows){
-            if(row.children[0].children[0].checked){
-                let quantity = row.children[4].children[0].value;
-                if(validator.ingredient.quantity(quantity)){
-                    addList.push({
-                        id: row._id,
-                        quantity: quantity
-                    });
-                }else{
-                    break;
-                }
-            }
-        }
-
-        axios.post("/merchant/ingredients/create", addList)
-            .then((response)=>{
-                if(typeof(response.data) === "string"){
-                    banner.createError(response.data);
-                }else{
-                    banner.createNotification("All ingredients successfully added");
-                    merchant.inventory = response.data;
-                    this.isPopulated = false;
-                    window.inventoryObj.isPopulated = false;
-                    window.inventoryObj.display();
-                }
-            })
-            .catch((err)=>{
-                banner.createError("Error: Something went wrong.  Try refreshing the page");
-            });
-    },
-
-    submitNew: function(){
-        event.preventDefault();
-
-        let ingredient = {
-            name: document.querySelector("#newIngName").value,
-            category: document.querySelector("#newCategory").value,
-            unit: document.querySelector("#newUnit").value
-        }
-
-
-        let quantity = document.querySelector("#newQuantity").value;
-
-        if(validator.ingredient.all(ingredient, quantity)){
-            axios.post("/ingredients/createone", {ingredient: ingredient, quantity: quantity})
-                .then((response)=>{
-                    if(typeof(response.data) === "string"){
-                        banner.createError(response.data);
-                    }else{
-                        merchant.inventory.push(response.data);
-
-                        inventoryObj.display();
-                        inventoryObj.filter();
-
-                        for(let input of document.querySelectorAll("#createIngredientInput input")){
-                            input.value = "";
-                        }
-                    }
-                })
-                .catch((err)=>{
-                    banner.createError("Something went wrong and the ingredient could not be created");
-                });
-        }
-    }
-}

+ 0 - 215
views/oldDashboardPage/dashboard.css

@@ -1,215 +0,0 @@
-#title{
-    font-size: 45px;
-    color: rgb(255, 99, 107);
-    text-align: center;
-    margin-top: 25px;
-}
-
-.cursor{
-    cursor: pointer;
-}
-
-/* Inventory Strand */
-#inventoryStrand{
-    flex-direction: column;
-    align-items: center;
-}
-
-    #inventoryStrand > *{
-        margin: 10px;
-    }
-
-    #inventoryStrand tbody{
-        text-transform: capitalize;
-    }
-
-    #filter{
-        max-height: 32px;
-    }
-
-/* Recipes Strand */
-#recipesStrand{
-    flex-direction: column;
-    align-items: center;
-}
-
-    #recipesStrand > *{
-        margin: 15px;
-    }
-
-    #recipeUpdate{
-        margin-bottom: 10px;
-    }
-
-    #newRecipe{
-        display: none;
-        justify-content: center;
-    }
-
-    #recipesContainer{
-        display: flex;
-        justify-content: space-around;
-        flex-wrap: wrap;
-        padding: 25px;
-    }
-
-        .recipe-card{
-            border: 2px solid rgb(255, 99, 107);
-            box-shadow: 2px 2px 2px rgb(0, 27, 45);
-            background: rgb(0, 27, 45);
-            color: rgb(255, 99, 107);
-            width: 20%;
-            min-width: 200px;
-            padding: 35px;
-            margin: 25px;
-            border-radius: 10px;
-            cursor: pointer;
-        }
-
-            .recipe-card:hover{
-                transform: translateY(-3px);
-            }
-
-            .empty-recipe{
-                background: rgb(255, 99, 107);
-                border: 2px solid rgb(0, 27, 45);
-                color: rgb(0, 27, 45);
-            }
-
-/* Account Strand */
-#accountStrand{
-    flex-direction: column;
-    align-items: center;
-}
-
-    #accountStrand > *{
-        margin: 15px;
-    }
-
-    #accountStrand label{
-        display: flex;
-    }
-
-    #accountEdit{
-        display: none;
-    }
-
-    #passwordEdit{
-        display: none;
-    }
-
-/* Add Ingredient Action */
-#addIngredientAction{
-    flex-direction: column;
-    align-items: center;
-}
-
-    #addIngredientAction > *{
-        margin: 25px;
-    }
-
-    .container{
-        display: flex;
-        justify-content: space-around;
-        align-items: center;
-    }
-
-        .container > *{
-            margin: 50px;
-        }
-
-        .container > div{
-            display: flex;
-            flex-direction: column;
-            align-items: center;
-        }
-
-            .container > div > *{
-                margin: 10px;
-            }
-
-/* Enter Transactions Action */
-#enterTransactionsAction{
-    flex-direction: column;
-    align-items: center;
-}
-    #enterTransactionsAction > *{
-        margin: 10px;
-    }
-
-/* Enter Purchase Action */
-#enterPurchaseAction{
-    flex-direction: column;
-    align-items: center;
-}
-
-    #enterPurchaseAction > *{
-        margin: 10px;
-    }
-
-/* Single Recipe Action */
-#singleRecipeAction{
-    display: none;
-    flex-direction: column;
-    margin: auto;
-    align-items: center;
-}
-
-    #singleRecipeAction > *{
-        margin: 15px;
-    }
-
-    #delRecipe{
-        display: "none"
-    }
-
-@media screen and (max-width: 1000px){
-    /* General use */
-    body{
-        text-align: center;
-    }
-
-    /* Single Recipe Action */
-    #singleRecipeAction .buttonsDiv{
-        font-size: 15px;
-    }
-
-    #singleRecipeAction input{
-        max-width: 100px;
-    }
-}
-
-@media screen and (max-width: 600px){
-    /* Inventory Strand */
-    #inventoryStrand h1{
-        font-size: 20px;
-        text-align: center;
-        margin: 5px;
-    }
-
-    .options{
-        flex-direction: column;
-    }
-
-    .options > *{
-        margin: 5px;
-    }
-
-    #inventoryStrand .button-small{
-        font-size: 12px;
-    }
-
-    #inventoryStrand td, #inventoryStrand th{
-        padding: 3px;
-        font-size: 12px;
-    }
-
-    /* addIngredientStrand */
-    .container{
-        flex-direction: column;
-    }
-
-    #addIngredientAction > *{
-        margin: 10px;
-    }
-}

+ 0 - 256
views/oldDashboardPage/dashboard.ejs

@@ -1,256 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-    <head>
-        <meta charset="UTF-8">
-        <title>The Subline</title>
-        <link rel="icon" type="img/png" href="/shared/images/logo.png">
-        <link rel="stylesheet" href="/dashboardPage/dashboard.css">
-        <link rel="stylesheet" href="/shared/shared.css">
-    </head>
-    <body>
-        <% include ../shared/header %>
-
-        <% include ../shared/banner %>
-
-        <h1 id="title"><%=merchant.name%></h1>
-
-        <strand-selector></strand-selector>
-
-        <div id="inventoryStrand" class="strand">
-            <div class="buttonBox">
-                <button class="button" onclick="addIngredientObj.display()">Add Ingredient</button>
-
-                <button class="button" onclick="enterPurchaseObj.display()">Enter Purchases</button>
-
-                <% if(merchant.pos === "none"){ %>
-                    <button class="button" onclick="enterTransactionsObj.display()">Enter Transactions</button>
-                <% } %>
-
-                <a class="button" href="/data">Analyze data</a>
-            </div>
-
-            <input id="filter" onkeyup="inventoryObj.filter()" type="text" placeholder="FILTER INGREDIENTS">
-
-            <table>
-                <thead>
-                    <tr>
-                        <th class="cursor" onclick="inventoryObj.sortIngredients('name')">Item</th>
-                        <th class="cursor" onclick="inventoryObj.sortIngredients('category')">Category</th>
-                        <th class="cursor" onclick="inventoryObj.sortIngredients('quantity')">Quantity</th>
-                        <th class="cursor" onclick="inventoryObj.sortIngredients('unit')">Unit</th>
-                        <th>Actions</th>
-                    </tr>
-                    <tbody></tbody>
-                </thead>
-            </table>
-        </div>
-
-        <div id="recipesStrand" class="strand">
-            <div>
-                <% if(merchant.pos === "none"){ %>
-                    <button class="button" onclick="window.recipesObj.showInput()">Add a Recipe</button>
-                <% }else{%>
-                    <button class="button" id="recipeUpdate" onclick="recipesObj.updateRecipes()">Update Recipes</button>
-                <% } %>
-            </div>
-
-            <div id="newRecipe">
-                <label>Name:
-                    <input id="newName" type="text">
-                </label>
-
-                <label>Price:
-                    <input id="newPrice" type="number" step="0.01">
-                </label>
-
-                <button class="button-small" onclick="window.recipesObj.submitNew()">Create</button>
-
-                <button class="button-small" onclick="window.recipesObj.cancelAdd()">Cancel</button>
-            </div>
-            
-            <div id="recipesContainer"></div>
-        </div>
-
-        <div id="accountStrand" class="strand">
-            <form id="accountDisplay" onsubmit="accountObj.editAccount()">
-                <label>Name:&nbsp;&nbsp;
-                    <p><%=merchant.name%></p>
-                </label>
-
-                <label>Email:&nbsp;&nbsp;
-                    <p><%=merchant.email%></p>
-                </label>
-
-                <button class="button" onclick="accountObj.editAccount()">Edit</button>
-            </form>
-
-            <form id="accountEdit">
-                <label>Name:&nbsp;&nbsp;
-                    <input id="accountName" type="text" value="<%=merchant.name%>">
-                </label>
-
-                <label>Email:&nbsp;&nbsp;
-                    <input id="accountEmail" type="email" value="<%=merchant.email%>">
-                </label>
-
-                <div class="buttonBox">
-                    <button class="button" onclick="accountObj.updateAccount()">Save</button>
-
-                    <button class="button" onclick="accountObj.editAccountCancel()">Cancel</button>
-                </div>
-            </form>
-
-            <form id="passwordEdit" onsubmit="accountObj.updatePassword()">
-                <label>Old password:
-                    <input id="oldPass" type="password" required>
-                </label>
-
-                <label>New password:
-                    <input id="newPass" type="password" required>
-                </label>
-
-                <label>Confirm new password:
-                    <input id="confirmNewPass" type="password" required>
-                </label>
-
-
-                <div class="buttonBox">
-                    <input class="button" type="submit" value="Submit">
-
-                    <button class="button" onclick="accountObj.editPasswordCancel()">Cancel</button>
-                </div>
-            </form>
-
-            <button class="button" onclick="accountObj.editPassword()">Change password</button>
-        </div>
-
-
-        <div id="addIngredientAction" class="action">
-            <div class="container">
-                <div>
-                    <h2>Choose Ingredients</h2>
-
-                    <input id="addFilter" type="text" placeholder="FILTER INGREDIENTS" onkeyup="window.addIngredientObj.filterAndDisplay()">
-
-                    <table>
-                        <thead>
-                            <tr>
-                                <th>Add</th>
-                                <th class="cursor" onclick="window.addIngredientObj.sort(1)">Ingredient</th>
-                                <th class="cursor" onclick="window.addIngredientObj.sort(2)">Category</th>
-                                <th class="cursor" onclick="window.addIngredientObj.sort(3)">Unit</th>
-                                <th>Quantity</th>
-                            </tr>
-                        </thead>
-                        <tbody></tbody>
-                    </table>
-
-                    <button class="button" onclick="addIngredientObj.submitAdd()">Submit</button>
-                </div>
-
-                <h1>Or</h1>
-
-                <form id="createIngredientInput" onsubmit="addIngredientObj.submitNew()">
-                    <h2>Create New Ingredient</h2>
-
-                    <label>Name
-                        <input id="newIngName" type="text" required>
-                    </label>
-
-                    <label>Category
-                        <input id="newCategory" type="text" required>
-                    </label>
-
-                    <label>Unit
-                        <input id="newUnit" type="text" required>
-                    </label>
-
-                    <label>Quantity
-                        <input id="newQuantity" type="number" step="0.01" required>
-                    </label>
-
-                    <button class="button">Create Ingredient</button>
-                </form>
-            </div>
-        </div>
-
-
-        <div id="enterTransactionsAction" class="action">
-            <h1>Enter all sales</h1>
-            <h3>Last updated: <span id="updated"></span></h3>
-            
-            <table>
-                <thead>
-                    <tr>
-                        <th>Recipe</th>
-                        <th>Number sold</th>
-                    </tr>
-                </thead>
-                <tbody></tbody>
-            </table>
-
-            <button class="button" onclick="enterTransactionsObj.submit()">Submit</button>
-        </div>
-
-
-        <div id="enterPurchaseAction" class="action">
-            <h1>Enter Purchases</h1>
-            
-            <table>
-                <thead>
-                    <tr>
-                        <th>Ingredient</th>
-                        <th>Amount</th>
-                    </tr>
-                </thead>
-                <tbody></tbody>
-            </table>
-
-            <button class="button" onclick="enterPurchaseObj.submit()">Submit</button>
-        </div>
-
-
-        <div id="singleRecipeAction" class="action">
-            <h2 id="recipeName"></h2>
-
-            <div class="buttonBox">
-                <button class="button" id="addButton">Add Ingredient</button>
-                <% if(merchant.pos === "none"){ %>
-                    <button class="button" id="removeButton">Remove</button>
-                <% } %>
-            </div>
-
-            <table>
-                <thead>
-                    <tr>
-                        <th>Name</th>
-                        <th>Quantity</th>
-                        <th>Actions</th>
-                    </tr>
-                </thead>
-                <tbody></tbody>
-            </table>
-        </div>
-
-        <%- include ../shared/footer %>
-
-        <script>
-                <% if(locals.error){ %>
-                    let error = <%- JSON.stringify(error) %>;
-                <% }else{ %>
-                    let error = undefined;
-                <% } %>
-        </script>
-        <script>let merchant = <%- JSON.stringify(merchant) %>;</script>
-        <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
-        <script src="../shared/validation.js"></script>
-        <script src="/dashboardPage/inventory.js"></script>
-        <script src="/dashboardPage/recipes.js"></script>
-        <script src="/dashboardPage/account.js"></script>
-        <script src="/dashboardPage/addIngredient.js"></script>
-        <script src="/dashboardPage/enterTransactions.js"></script>
-        <script src="/dashboardPage/enterPurchase.js"></script>
-        <script src="/dashboardPage/singleRecipe.js"></script>
-        <script src="/shared/controller.js"></script>
-    </body>
-</html>

+ 0 - 83
views/oldDashboardPage/enterPurchase.js

@@ -1,83 +0,0 @@
-window.enterPurchaseObj = {
-    isPopulated: false,
-
-    display: function(){
-        clearScreen();
-        document.querySelector("#enterPurchaseAction").style.display = "flex";
-
-        if(!this.isPopulated){
-            this.populateTable();
-        }
-    },
-
-    populateTable: function(){
-        let tbody = document.querySelector("#enterPurchaseAction tbody");
-
-        while(tbody.children.length > 0){
-            tbody.removeChild(tbody.firstChild);
-        }
-
-        for(let item of merchant.inventory){
-            let row = document.createElement("tr");
-            row._id = item.ingredient._id;
-            tbody.appendChild(row);
-
-            let nameTd = document.createElement("td");
-            nameTd.innerText = item.ingredient.name;
-            row.appendChild(nameTd);
-
-            let quantityTd = document.createElement("td");
-            row.appendChild(quantityTd);
-
-            let quantityInput = document.createElement("input");
-            quantityInput.type = "number";
-            quantityInput.step = "1";
-            quantityInput.value = 0;
-            quantityTd.appendChild(quantityInput);
-        }
-    },
-
-    submit: function(){
-        let tbody = document.querySelector("#enterPurchaseAction tbody");
-
-        let purchases = [];
-
-        for(let row of tbody.children){
-            let quantity = row.children[1].children[0].value;
-            if(validator.ingredient.quantity(quantity)){
-                if(quantity > 0){
-                    let purchase = {
-                        ingredient: row._id,
-                        quantity: row.children[1].children[0].value
-                    }
-
-                    purchases.push(purchase);
-                }else if(quantity < 0){
-                    banner.createError("Cannot contain negative numbers");
-                    return;
-                }
-            }else{
-                return;
-            }
-        }
-
-        axios.post("/purchases/create", purchases)
-            .then((response)=>{
-                if(typeof(response.data) === "string"){
-                    banner.createError(response.data);
-                }else{
-                    for(let purchase of purchases){
-                        let merchantIngredient = merchant.inventory.find(i => i.ingredient._id === purchase.ingredient);
-                        merchantIngredient.quantity = Number(merchantIngredient.quantity) + Number(purchase.quantity);
-                    }
-
-                    inventoryObj.isPopulated = false;
-                    this.isPopulated = false;
-                    inventoryObj.display();
-                }
-            })
-            .catch((err)=>{
-                banner.createError("Something went wrong and changes could not be made");
-            });
-    }
-}

+ 0 - 87
views/oldDashboardPage/enterTransactions.js

@@ -1,87 +0,0 @@
-window.enterTransactionsObj = {
-    isPopulated: false,
-
-    display: function(){
-        clearScreen();
-        document.querySelector("#enterTransactionsAction").style.display = "flex";
-
-        document.querySelector("#updated").innerText = new Date(Number(merchant.lastUpdatedTime)).toDateString();
-
-        if(!this.isPopulated){
-            this.populateRecipes();
-            this.isPopulated = true;
-        }
-    },
-
-    populateRecipes: function(){
-        let tbody = document.querySelector("#enterTransactionsAction tbody");
-
-        while(tbody.children.length > 0){
-            tbody.removeChild(tbody.firstChild);
-        }
-
-        for(let recipe of merchant.recipes){
-            let row = document.createElement("tr");
-            row._id = recipe._id;
-            tbody.appendChild(row);
-
-            let name = document.createElement("td");
-            name.innerText = recipe.name;
-            row.appendChild(name);
-
-            let quantity = document.createElement("td");
-            row.appendChild(quantity);
-
-            let input = document.createElement("input");
-            input.type = "number";
-            input.step = "1";
-            input.value = "0";
-            quantity.appendChild(input);
-        }
-    },
-
-    submit: function(){
-        let tbody = document.querySelector("#enterTransactionsAction tbody");
-
-        let recipes = [];
-
-        for(let row of tbody.children){
-            let quantity = row.children[1].children[0].value;
-            
-            if(quantity > 0){
-                let recipe = {
-                    id: row._id,
-                    quantity: quantity
-                }
-                recipes.push(recipe);
-            }else if(quantity < 0){
-                banner.createError("Cannot have negative quantities");
-                return;
-            }
-        }
-
-        if(recipes.length > 0){
-            axios.post("/transactions/create", recipes)
-                .then((response)=>{
-                    if(typeof(response.data) === "string"){
-                        banner.createError(response.data);
-                    }else{
-                        for(let recipe of recipes){
-                            let merchRecipe = merchant.recipes.find(r => r._id === recipe.id);
-                            for(let recipeIngredient of merchRecipe.ingredients){
-                                let merchInvIngredient = merchant.inventory.find(i => i.ingredient._id === recipeIngredient.ingredient._id);
-                                merchInvIngredient.quantity -= recipeIngredient.quantity * recipe.quantity;
-                            }
-                        }
-
-                        inventoryObj.isPopulated = false;
-                        inventoryObj.display();
-                        banner.createNotification("Your sales have been logged");
-                    }
-                })
-                .catch((err)=>{
-                    banner.createError("Something went wrong and your sales could not be logged");
-                });
-        }
-    }
-}

+ 0 - 205
views/oldDashboardPage/inventory.js

@@ -1,205 +0,0 @@
-window.inventoryObj = {
-    items: [],
-    currentSort: "",
-    isPopulated: false,
-
-    display: function(){
-        clearScreen();
-        document.querySelector("#inventoryStrand").style.display = "flex";
-
-        if(!this.isPopulated){
-            this.filter();
-            this.isPopulated = true;
-        }
-    },
-
-    populateIngredients: function(){
-        let tbody = document.querySelector("#inventoryStrand tbody");
-
-        while(tbody.children.length > 0){
-            tbody.removeChild(tbody.firstChild);
-        }
-
-        for(let item of this.items){
-            let row = document.createElement("tr");
-            tbody.appendChild(row);
-
-            let name = document.createElement("td");
-            name.innerText = item.name;
-            name.classList = "truncateLong";
-            row.appendChild(name);
-
-            let category = document.createElement("td");
-            category.innerText = item.category;
-            row.appendChild(category);
-
-            let quantity = document.createElement("td");
-            quantity.innerText = item.quantity;
-            row.appendChild(quantity);
-
-            let unit = document.createElement("td");
-            unit.innerText = item.unit;
-            row.appendChild(unit);
-
-            let action = document.createElement("td");
-            row.appendChild(action);
-
-            let editBtn = document.createElement("button");
-            editBtn.onclick = ()=>{this.editIngredient(item.id, row)};
-            editBtn.innerText = "Edit";
-            editBtn.className = "button-small"
-            action.appendChild(editBtn);
-
-            let removeBtn = document.createElement("button");
-            removeBtn.onclick = ()=>{this.removeIngredient(item.id, row)};
-            removeBtn.innerText = "Remove";
-            removeBtn.className = "button-small";
-            action.appendChild(removeBtn);
-        }
-    },
-
-    //sorts this.items by specified property
-    sortIngredients: function(property){
-        if(this.currentSort === property){
-            this.items.sort((a, b) => (a[property] > b[property]) ? -1 : 1);
-            this.currentSort = "";
-        }else{
-            this.items.sort((a, b) => (a[property] > b[property]) ? 1 : -1);
-            this.currentSort = property;
-        }
-
-        this.populateIngredients();
-    },
-
-    //Empty this.items list
-    //Add ingredients back to this.items list based on this.filter input
-    filter: function(){
-        this.items = [];
-        let searchString = document.querySelector("#filter").value.toLowerCase();
-        for(let item of merchant.inventory){
-            if(item.ingredient.name.toLowerCase().includes(searchString)){
-                this.items.push({
-                    id: item.ingredient._id,
-                    name: item.ingredient.name.toLowerCase(),
-                    category: item.ingredient.category.toLowerCase(),
-                    quantity: item.quantity,
-                    unit: item.ingredient.unit.toLowerCase()
-                });
-            }
-        }
-
-        this.sortIngredients("name");
-    },
-
-    //Create input allowing for user edit of ingredient
-    editIngredient: function(id, row){
-        let quantity = row.children[2];
-        let editButton = row.children[4].children[0];
-        let removeButton = row.children[4].children[1];
-        let originalQuantity = quantity.innerText;
-
-        let quantityInput = document.createElement("input");
-        quantityInput.type = "number";
-        quantityInput.step = "0.01";
-        quantityInput.onkeypress = (event)=>{if(event.keyCode===13) this.updateOne(id, row, originalQuantity)};
-        quantityInput.value = quantity.innerText;
-
-        quantity.innerText = "";
-        quantity.appendChild(quantityInput);
-
-        editButton.innerText = "Save";
-        editButton.onclick = ()=>{this.updateOne(id, row, originalQuantity)};
-
-        removeButton.innerText = "Cancel";
-        removeButton.onclick = ()=>{this.cancelEdit(id, row, originalQuantity)};
-
-        quantityInput.focus();
-    },
-
-    cancelEdit: function(id, row, amount){
-        let quantityField = row.children[2];
-        quantityField.removeChild(quantityField.firstChild);
-        quantityField.innerText = amount;
-
-        let saveButton = row.children[4].children[0];
-        saveButton.innerText = "Edit";
-        saveButton.onclick = ()=>{this.editIngredient(id, row)};
-
-        let cancelButton = row.children[4].children[1];
-        cancelButton.innerText = "Remove";
-        cancelButton.onclick = ()=>{this.removeIngredient(id, row)};
-    },
-
-    //Save user input of ingredient
-    //Update both page and database
-    updateOne: function(id, row, originalQuantity){
-        let quantityField = row.children[2];
-        let quantity = quantityField.children[0].value;
-        let saveButton = row.children[4].children[0];
-        let cancelButton = row.children[4].children[1];
-
-        quantityField.removeChild(quantityField.firstChild);
-
-        if(validator.ingredient.quantity(quantity)){
-            let updateIngredient = merchant.inventory.find(i => i.ingredient._id === id);
-            updateIngredient.quantity = quantity;
-            axios.post("/merchant/ingredients/update", {ingredientId: id, quantityChange: quantity - originalQuantity})
-                .then((response)=>{
-                    if(typeof(response.data) === "string"){
-                        banner.createError(response.data);
-                    }else{
-                        banner.createNotification("The ingredient has been successfully updated");
-                        quantityField.innerText = quantity;
-                    }
-                })
-                .catch((err)=>{
-                    banner.createError("Error: The ingredient could not be updated");
-                });
-        }else{
-            quantityField.innerText = originalQuantity;
-        }
-
-        saveButton.innerText = "Edit";
-        saveButton.onclick = ()=>{this.editIngredient(id, row)};
-
-        cancelButton.innerText = "Remove";
-        cancelButton.onclick = ()=>{this.removeIngredient(id, row)};
-    },
-
-    //Delete an ingredient from both the page and the database
-    removeIngredient: function(id, row){
-        let canRemove = true;
-        for(let recipe of merchant.recipes){
-            for(let ingredient of recipe.ingredients){
-                if(ingredient.ingredient._id === id){
-                    canRemove = false;
-                    break;
-                }
-            }
-        }
-        if(canRemove){
-            axios.post("/merchant/ingredients/remove", {ingredientId: id})
-                .then((result)=>{
-                    if(typeof(result.data) === "string"){
-                        banner.createError(result.data);
-                    }else{
-                        for(let i = 0; i < merchant.inventory.length; i++){
-                            if(id === merchant.inventory[i].ingredient._id){
-                                merchant.inventory.splice(i, 1);
-                                break;
-                            }
-                        }
-
-                        this.filter();
-
-                        banner.createNotification("The ingredient has been removed from your inventory");
-                    }
-                })
-                .catch((err)=>{
-                    banner.createError("There was an error and the ingredient has not been removed from your inventory");
-                });
-        }else{
-            banner.createError("You must remove this ingredient from all recipes before you can remove it from your inventory");
-        }
-    },
-}

+ 0 - 111
views/oldDashboardPage/recipes.js

@@ -1,111 +0,0 @@
-window.recipesObj = {
-    isPopulated: false,
-
-    display: function(){
-        clearScreen();
-        document.querySelector("#recipesStrand").style.display = "flex";
-
-        if(!this.isPopulated){
-            this.populateRecipes();
-            this.isPopulated = true;
-        }
-    },
-
-    populateRecipes: function(){
-        let body = document.querySelector("#recipesContainer");
-        let blankRecipes = 0;
-
-        while(body.children.length > 0){
-            body.removeChild(body.firstChild);
-        }
-
-        merchant.recipes.sort((a, b) => (a.name > b.name)? 1 : -1);
-        
-        for(let recipe of merchant.recipes){
-            let recipeDiv = document.createElement("div");
-            recipeDiv.classList = "recipe-card";
-            recipeDiv.onclick = ()=>{singleRecipeObj.display(recipe)};
-            body.appendChild(recipeDiv);
-
-            if(recipe.ingredients.length === 0){
-                recipeDiv.classList = "recipe-card empty-recipe";
-                blankRecipes++;
-            }else{
-                recipeDiv.classList = "recipe-card";
-            }
-
-            let title = document.createElement("h2");
-            title.innerText = recipe.name;
-            recipeDiv.appendChild(title);
-
-            let ingredientList = document.createElement("ul");
-            recipeDiv.appendChild(ingredientList);
-
-            for(let ingredient of recipe.ingredients){
-                let ul = document.createElement("li");
-                ul.innerText = ingredient.ingredient.name;
-                ingredientList.appendChild(ul);
-            }
-        }
-
-        if(blankRecipes > 0){
-            banner.createError(`You have ${blankRecipes} recipes without ingredients, please add ingredients to all recipes`);
-        }
-    },
-
-    updateRecipes: function(){
-        axios.get("/merchant/recipes/update")
-            .then((result)=>{
-                if(typeof(result.data) === "string"){
-                    banner.createError(result.data);
-                }else{
-                    merchant = result.data;
-                    this.populateRecipes();
-                    banner.createNotification("Your recipes have been updated successfully");
-                }
-            })
-            .catch((err)=>{
-                banner.createError("There was an error and your recipes could not be updated");
-            });
-    },
-
-    showInput: function(){
-        document.querySelector("#newRecipe").style.display = "block";
-    },
-
-    cancelAdd: function(){
-        document.querySelector("#newName").value = "";
-        document.querySelector("#newPrice").value = 0;
-        document.querySelector("#newRecipe").style.display = "none";
-    },
-
-    submitNew: function(){
-        let inputDiv = document.querySelector("#newRecipe");
-        let nameInput = document.querySelector("#newName");
-        let priceInput = document.querySelector("#newPrice");
-
-        let data = {
-            name: nameInput.value,
-            price: priceInput.value
-        };
-
-        nameInput.value = "";
-        priceInput.value = 0;
-        inputDiv.style.display = "none";
-
-        axios.post("/recipe/create", data)
-            .then((response)=>{
-                if(typeof(response.data) === "string"){
-                    banner.createError(response.data);
-                }else{
-                    merchant.recipes.push(response.data);
-
-                    window.enterTransactionsObj.isPopulated = false;
-                    this.populateRecipes();
-                }
-            })
-            .catch((err)=>{
-                banner.createError("Error: Unable to display new data");
-            });
-    }
-}

+ 0 - 285
views/oldDashboardPage/singleRecipe.js

@@ -1,285 +0,0 @@
-window.singleRecipeObj = {
-    display: function(recipe){
-        clearScreen();
-        document.querySelector("#singleRecipeAction").style.display = "flex";
-
-        let tbody = document.querySelector("#singleRecipeAction tbody");
-
-        while(tbody.children.length > 0){
-            tbody.removeChild(tbody.firstChild);
-        }
-
-        document.querySelector("#recipeName").innerText = recipe.name;
-        document.querySelector("#addButton").onclick = ()=>{this.displayAdd(recipe)};
-        document.querySelector("#removeButton").onclick = ()=>{this.removeRecipe(recipe)};
-
-        for(let ingredient of recipe.ingredients){
-            let row = document.createElement("tr");
-            tbody.appendChild(row);
-
-            let name = document.createElement("td");
-            name.innerText = ingredient.ingredient.name;
-            name.classList = "truncateLong";
-            row.appendChild(name);
-
-            let quantity = document.createElement("td");
-            quantity.innerText = `${ingredient.quantity} ${ingredient.ingredient.unit}`;
-            row.appendChild(quantity);
-
-            let actions = document.createElement("td");
-            row.appendChild(actions);
-
-            let editButton = document.createElement("button");
-            editButton.innerText = "Edit";
-            editButton.classList = "button-small";
-            editButton.onclick = ()=>{this.editIngredient(row, ingredient, recipe);};
-            actions.appendChild(editButton);
-
-            let removeButton = document.createElement("button");
-            removeButton.innerText = "Remove";
-            removeButton.classList = "button-small";
-            removeButton.onclick = ()=>{this.deleteIngredient(recipe._id, ingredient.ingredient._id, ingredient.quantity, row);};
-            actions.appendChild(removeButton);
-        }
-    },
-
-    displayAdd: function(recipe){
-        let tbody = document.querySelector("#singleRecipeAction tbody");
-
-        let row = document.createElement("tr");
-        tbody.appendChild(row);
-
-        let nameTd = document.createElement("td");
-        row.appendChild(nameTd);
-
-        let name = document.createElement("select");
-        name.classList = "truncateLong";
-        nameTd.appendChild(name);
-
-        for(let item of merchant.inventory){
-            let exists = false;
-            for(let recipeIngredient of recipe.ingredients){
-                if(item.ingredient._id === recipeIngredient.ingredient._id){
-                    exists = true;
-                    break;
-                }
-            }
-
-            if(!exists){
-                let nameOption = document.createElement("option");
-                nameOption.innerText = `${item.ingredient.name} (${item.ingredient.unit})`;
-                nameOption.value = item.ingredient._id;
-                name.appendChild(nameOption);
-            }
-        }
-
-        let quantityTd = document.createElement("td");
-        row.appendChild(quantityTd);
-
-        let quantity = document.createElement("input");
-        quantity.type = "text";
-        quantity.step = "0.01";
-        quantity.onkeypress = (event)=>{if(event.keyCode===13) this.addIngredient(recipe, name.value, quantity.value, row)};
-        quantityTd.appendChild(quantity);
-
-        let actionTd = document.createElement("td");
-        row.appendChild(actionTd);
-
-        let saveButton = document.createElement("button");
-        saveButton.innerText = "Save";
-        saveButton.classList = "button-small";
-        saveButton.onclick = ()=>{this.addIngredient(recipe, name.value, quantity.value, row);};
-        actionTd.appendChild(saveButton);
-
-        let cancelButton = document.createElement("button");
-        cancelButton.innerText = "Cancel";
-        cancelButton.classList = "button-small";
-        cancelButton.onclick = ()=>{tbody.removeChild(row)};
-        actionTd.appendChild(cancelButton);
-    },
-
-    addIngredient: function(recipe, ingredientId, quantity, row){
-        let item = {
-            ingredient: ingredientId,
-            quantity: quantity
-        }
-        
-        if(validator.ingredient.quantity(item.quantity)){
-            axios.post("/merchant/recipes/ingredients/create", {recipeId: recipe._id, item: item})
-                .then((response)=>{
-                    if(typeof(response.data) === "string"){
-                        banner.createError(response.data);
-                    }else{
-                        for(let i = 0; i < merchant.recipes.length; i++){
-                            if(merchant.recipes[i]._id === recipe._id){
-                                merchant.recipes.splice(i, 1);
-                                break;
-                            }
-                        }
-                        merchant.recipes.push(response.data);
-                        recipesObj.isPopulated = false;
-
-                        while(row.children.length > 0){
-                            row.removeChild(row.firstChild);
-                        }
-
-                        let addIngredient = response.data.ingredients.find(i => i.ingredient._id === ingredientId);
-
-                        let name = document.createElement("td");
-                        name.innerText = addIngredient.ingredient.name;
-                        row.appendChild(name);
-
-                        let quantity = document.createElement("td");
-                        quantity.innerText = `${item.quantity} ${addIngredient.ingredient.unit}`;
-                        row.appendChild(quantity);
-
-                        let actions = document.createElement("td");
-                        row.appendChild(actions);
-
-                        let editButton = document.createElement("button");
-                        editButton.innerText = "Edit";
-                        editButton.classList = "button-small";
-                        editButton.onclick = ()=>{this.editIngredient(row, addIngredient, recipe);};
-                        actions.appendChild(editButton);
-
-                        let removeButton = document.createElement("button");
-                        removeButton.innerText = "Remove";
-                        removeButton.classList = "button-small";
-                        removeButton.onclick = ()=>{this.deleteIngredient(recipe._id, ingredientId, quantity, row);};
-                        actions.appendChild(removeButton);
-                    }
-                })
-                .catch((err)=>{
-                    row.parentNode.removeChild(row);
-                    banner.createError("There was an error and the recipe could not be updated");
-                });
-        }
-    },
-
-    //Delete ingredient from table
-    //Delete ingredient from database
-    deleteIngredient: function(recipeId, ingredientId, quantity, row){
-        axios.post("/merchant/recipes/ingredients/remove", {ingredientId: ingredientId, recipeId: recipeId, quantity: quantity})
-            .then((result)=>{
-                if(typeof(result.data) === "string"){
-                    banner.createError(result.data);
-                }else{
-                    row.parentNode.removeChild(row);
-
-                    let updateRecipe = merchant.recipes.find(r => r._id === recipeId);
-                    for(let i = 0; i < updateRecipe.ingredients.length; i++){
-                        if(updateRecipe.ingredients[i].ingredient._id === ingredientId){
-                            updateRecipe.ingredients.splice(i, 1);
-                            break;
-                        }
-                    }
-
-                    recipesObj.isPopulated = false;
-                }
-            })
-            .catch((err)=>{
-                banner.createError("There was an error and the ingredient could not be removed from the recipe");
-            });
-    },
-
-    //Change quantity field to input
-    //Change edit button
-    editIngredient: function(row, ingredient, recipe){
-        let td = row.children[1];
-        td.innerText = "";
-
-        let input = document.createElement("input");
-        input.type = "number";
-        input.step = "0.01";
-        input.value = ingredient.quantity;
-        input.onkeypress = (event)=>{if(event.keyCode===13) this.updateIngredient(row, ingredient, recipe)};
-        td.appendChild(input);
-
-        let para = document.createElement("p");
-        para.innerText = ingredient.ingredient.unit;
-        td.appendChild(para);
-
-        let editButton = row.children[2].children[0];
-        editButton.innerText = "Save";
-        editButton.onclick = ()=>{this.updateIngredient(row, ingredient, recipe);};
-
-        let removeButton = row.children[2].children[1];
-        removeButton.innerText = "Cancel";
-        removeButton.onclick = ()=>{this.cancelEdit(row, ingredient, recipe)};
-
-        input.focus();
-    },
-
-    cancelEdit: function(row, ingredient, recipe){
-        let quantity = row.children[1];
-        quantity.removeChild(quantity.firstChild);
-        quantity.innerText = `${ingredient.quantity} ${ingredient.ingredient.unit}`;
-
-        let saveButton = row.children[2].children[0];
-        saveButton.innerText = "Edit";
-        saveButton.onclick = ()=>{this.editIngredient(row, ingredient, recipe)};
-
-        let cancelButton = row.children[2].children[1];
-        cancelButton.innerText = "Remove";
-        cancelButton.onclick = ()=>{this.deleteIngredient(recipe._id, ingredient.ingredient._id, row)};
-    },
-
-    updateIngredient: function(row, ingredient, recipe){
-        let originalQuantity = ingredient.quantity;
-        ingredient.quantity = row.children[1].children[0].value;
-
-        let td = row.children[1];
-        while(td.children.length > 0){
-            td.removeChild(td.firstChild);
-        }
-
-        let saveButton = row.children[2].children[0];
-        saveButton.innerText = "Edit";
-        saveButton.onclick = ()=>{this.editIngredient(row, ingredient, recipe);};
-
-        let cancelButton = row.children[2].children[1];
-        cancelButton.innerText = "Remove";
-        cancelButton.onclick = ()=>{this.deleteIngredient(recipe._id, ingredient.ingredient._id, row)};
-
-        if(validator.ingredient.quantity(ingredient.quantity)){
-            axios.post("/merchant/recipes/ingredients/update", {recipeId: recipe._id, ingredient: ingredient})
-                .then((result)=>{
-                    if(typeof(result.data) === "string"){
-                        td.innerText = `${originalQuantity} ${ingredient.ingredient.unit}`;
-                        banner.createError(result.data);
-                    }else{
-                        td.innerText = `${ingredient.quantity} ${ingredient.ingredient.unit}`;
-                        banner.createNotification("Ingredient successfully updated");
-                    }
-                })
-                .catch((err)=>{
-                    td.innerText = `${originalQuantity} ${ingredient.ingredient.unit}`;
-                    banner.createError("There was an error and the ingredient could not be updated");
-                });
-        }else{
-            td.innerText = `${originalQuantity} ${ingredient.ingredient.unit}`;
-        }
-    },
-
-    removeRecipe(recipe){
-        axios.post("/merchant/recipes/remove", {id: recipe._id})
-            .then((response)=>{
-                if(typeof(response.data) === "string"){
-                    banner.createError(response.data);
-                }else{
-                    for(let i = 0; i < merchant.recipes.length; i++){
-                        if(merchant.recipes[i]._id === recipe._id){
-                            merchant.recipes.splice(i, 1);
-                            break;
-                        }
-                    }
-
-                    window.recipesObj.isPopulated = false;
-                    window.recipesObj.display();
-                }
-            })
-            .catch((err)=>{
-                banner.createError("Warning:  Something went wrong, try refreshing the page");
-            });
-    }
-}