Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inventory frontend rewrite #17

Draft
wants to merge 34 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
3ed5634
started inventory frontend rewrite. display saved items and folders.
shocktail39 Jan 6, 2023
badda09
added functions for creating new items and folders
shocktail39 Jan 6, 2023
f21b6ed
commented out some testing lines i accidentally left in
shocktail39 Jan 6, 2023
3b1d24b
added function to use item
shocktail39 Jan 7, 2023
a9be09a
added use button
shocktail39 Jan 19, 2023
e601566
added delete button for items and folders
shocktail39 Jan 20, 2023
40da601
put delete button at top of folder instead of underneath all items
shocktail39 Jan 20, 2023
8eaca1f
removed some sloppy left-in lines
shocktail39 Jan 20, 2023
fa735de
added new folder button
shocktail39 Jan 20, 2023
a7903d2
added new item dialog, and greatly reduced for loop usage
shocktail39 Jan 21, 2023
28a7797
made folders collapsable
shocktail39 Jan 21, 2023
3a58802
made inventory sort, and removed redundant sanitizing
shocktail39 Feb 16, 2023
5d72de3
made items editable
shocktail39 Feb 16, 2023
f70196a
removed unnecessary scripts and favicon
shocktail39 Feb 16, 2023
dfa1bf2
moved files to be more consistent with other apps in the repo
shocktail39 Feb 16, 2023
025a97e
edit now checks if an item with the new name already exists.
shocktail39 Feb 16, 2023
63d7f20
a message now shows up if an item with the same name already exists.
shocktail39 Feb 16, 2023
731d07f
added inbox view and working delete button
shocktail39 Feb 18, 2023
9fc2df9
optimized for loop out of removeItemOrFolder
shocktail39 Feb 18, 2023
f88b3c9
added ability to move items to different folders
shocktail39 Feb 18, 2023
3890501
can now accept items in your inbox
shocktail39 Feb 18, 2023
dc70cc8
new and edit prompts now tell you why when they fail on no name.
shocktail39 Feb 18, 2023
18c6c36
optimized moving items and accepting inbox items
shocktail39 Feb 18, 2023
9329e8d
destination folder gets checked for another item with the same name b…
shocktail39 Feb 18, 2023
974c715
fixed empty inventory edge case
shocktail39 Jun 25, 2023
67a2985
added ability to share items
shocktail39 Jun 25, 2023
b492ef0
renamed user-select to share to make clearer
shocktail39 Jun 25, 2023
6aa9d84
UI Work
Armored-Dragon Jun 29, 2023
cdfd303
Cleanup templates
Armored-Dragon Jun 29, 2023
a6656dd
Delete overte_chat_rewrite.code-workspace
Armored-Dragon Jun 29, 2023
1e9edf8
Merge pull request #1 from Armored-Dragon/inventory-app-rewrite
shocktail39 Jun 29, 2023
8d86859
Merge branch 'overte-org:master' into inventory-app-rewrite
shocktail39 Jun 29, 2023
14465cf
got started on functionality with new ui
shocktail39 Jun 29, 2023
3e2b053
idk why nested folders don't work unless i do it like this.
shocktail39 Jun 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions applications/inventory-app/README.md

This file was deleted.

187 changes: 187 additions & 0 deletions applications/inventory-app/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
"use strict";

var inventory = [];
var inbox = [];
var nearbyUsers = [];

var currentFolder = [];

function sendEvent(command, data) {
EventBridge.emitWebEvent(JSON.stringify({app:"inventory",command:command,data:data}));
}

function folderSorter(a, b) {
var aIsFolder = ("items" in a);
var bIsFolder = ("items" in b);
if (aIsFolder && !bIsFolder) return -1;
if (!aIsFolder && bIsFolder) return 1;
return a["name"].localeCompare(b["name"]);
}

function changeFolder(folderPath) {
currentFolder = inventory;
// change buttons up top
const directoryDiv = document.getElementsByClassName("directory")[0];
directoryDiv.innerHTML = "";
var folderButton = document.createElement("button");
folderButton.className = "item";
folderButton.appendChild(document.createTextNode("ROOT"));
folderButton.onclick = function() {changeFolder([]);};
directoryDiv.appendChild(folderButton);
for (var i = 0; i < folderPath.length; i++) {
const currentPath = folderPath.slice(0, i+1);
folderButton = document.createElement("button");
folderButton.class = "item";
folderButton.appendChild(document.createTextNode(folderPath[i]));
folderButton.onclick = function() {changeFolder(currentPath);};
directoryDiv.appendChild(folderButton);
// path traversal
for (var j = 0; j < currentFolder.length; j++) {
if (currentFolder[j]["name"] === folderPath[i]) {
currentFolder = currentFolder[j]["items"];
break;
}
}
}
// change items down low
const itemListingsDiv = document.getElementById("item-listings");
itemListingsDiv.innerHTML = "";
const itemListingTemplate = document.getElementById("item-listing-template");
const folderListingTemplate = document.getElementById("folder-listing-template");
for (var i = 0; i < currentFolder.length; i++) {
const currentItem = currentFolder[i];
const itemIsFolder = "items" in currentItem;
const itemName = currentItem["name"];
const listing = (itemIsFolder ? folderListingTemplate : itemListingTemplate).getElementsByClassName("item-listing")[0].cloneNode(true);
const itemNameBar = listing.getElementsByClassName("title")[0];
if (itemIsFolder) {
itemNameBar.onclick = function() {changeFolder(folderPath.concat([itemName]));};
}
itemNameBar.appendChild(document.createTextNode(itemName));
itemListingsDiv.appendChild(listing);
}
}

function newItem(folder, name, type, url) {
folder.push({name:name,type:type,url:url});
folder.sort(folderSorter);
sendEvent("web-to-script-inventory", inventory);
refreshInventoryView();
}

function newFolder(folder, name) {
folder.push({name:name,items:[]});
folder.sort(folderSorter);
sendEvent("web-to-script-inventory", inventory);
refreshInventoryView();
}

function removeItemOrFolder(folder, index) {
for (var itemToShift = index + 1; itemToShift < folder.length; itemToShift++) {
folder[itemToShift - 1] = folder[itemToShift];
}
folder.pop();
sendEvent("web-to-script-inventory", inventory);
refreshInventoryView();
return;
}

function refreshInventoryView() {
/* const folderList = document.getElementById("folder-select-list");
folderList.innerHTML = "";
var child = document.createElement("option");
child.appendChild(document.createTextNode("/"));
folderList.appendChild(child);
const view = document.getElementById("inventory");
view.innerHTML = "";
child = document.createElement("button");
child.appendChild(document.createTextNode("new folder"));
child.onclick = function(){showNewFolder(inventory)};
view.appendChild(child);
child = document.createElement("button");
child.appendChild(document.createTextNode("new item"));
child.onclick = function(){showNewItem(inventory)};
view.appendChild(child);
for (var i = 0; i < inventory.length; i++) {
if ("items" in inventory[i]) {
view.appendChild(createFolderDiv(inventory, i, "/" + inventory[i]["name"] + "/"));
} else {
view.appendChild(createItemDiv(inventory, i));
}
}*/
changeFolder([]);
}



function deleteInboxItem(index) {
for (var itemToShift = index + 1; itemToShift < inbox.length; itemToShift++) {
inbox[itemToShift - 1] = inbox[itemToShift];
}
inbox.pop();
sendEvent("web-to-script-update-receiving-item-queue", inbox);
refreshInboxView();
return;
}

function refreshInboxView() {
const inboxDiv = document.getElementById("inbox");
inboxDiv.innerHTML = "";
if (inbox.length > 0) {
const contents = document.createElement("div");
contents.style.display = "none";
var child = document.createElement("p");
child.appendChild(document.createTextNode(inbox.length + " item(s) in inbox"));
inboxDiv.appendChild(child);
child = document.createElement("button");
child.appendChild(document.createTextNode("show/hide"));
child.onclick = function() {
contents.style.display = contents.style.display === "block" ? "none" : "block";
};
inboxDiv.appendChild(child);
for (var index = 0; index < inbox.length; index++) {
contents.appendChild(createInboxDiv(index));
}
inboxDiv.appendChild(contents);
}
}



function refreshNearbyUsers(userList) {
document.getElementById("share-list").innerHTML = "";
for (var i = 0; i < userList.length; i++) {
var child = document.createElement("option");
child.appendChild(document.createTextNode(userList[i].name));
document.getElementById("share-list").appendChild(child);
}
}

EventBridge.scriptEventReceived.connect(function(message) {
const parsed_message = JSON.parse(message);
if (parsed_message["app"] === "inventory") {
switch (parsed_message["command"]) {
case "script-to-web-inventory":
inventory = parsed_message["data"];
if (typeof inventory !== "object") { // if data is empty, then inventory becomes an empty string instead of an array.
inventory = [];
}
refreshInventoryView();
break;
case "script-to-web-receiving-item-queue":
//inbox = parsed_message["data"];
//refreshInboxView();
break;
case "script-to-web-nearby-users":
nearbyUsers = parsed_message["data"];
if (typeof nearbyUsers === "object") {
refreshNearbyUsers(parsed_message["data"]);
}
break;
//default:
//alert(message);
}
}
});

window.onload = function() {sendEvent("ready", {});}
1 change: 0 additions & 1 deletion applications/inventory-app/dist/css/app.a93e8b1f.css

This file was deleted.

This file was deleted.

Binary file removed applications/inventory-app/dist/favicon.ico
Binary file not shown.
1 change: 0 additions & 1 deletion applications/inventory-app/dist/index.html

This file was deleted.

2 changes: 0 additions & 2 deletions applications/inventory-app/dist/js/app.a3555a80.js

This file was deleted.

1 change: 0 additions & 1 deletion applications/inventory-app/dist/js/app.a3555a80.js.map

This file was deleted.

21 changes: 0 additions & 21 deletions applications/inventory-app/dist/js/chunk-vendors.a0f21a27.js

This file was deleted.

This file was deleted.

Binary file added applications/inventory-app/icons/folder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions applications/inventory-app/icons/folder.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added applications/inventory-app/icons/folder_black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added applications/inventory-app/icons/gear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions applications/inventory-app/icons/gear.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added applications/inventory-app/icons/inventory.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions applications/inventory-app/icons/inventory.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added applications/inventory-app/icons/mail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions applications/inventory-app/icons/mail.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions applications/inventory-app/icons/mail_unread.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading