-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: lock/unlock network & highlight multipleNodes
- Loading branch information
Showing
11 changed files
with
266 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#network-locker { | ||
position: absolute; | ||
bottom: 10px; | ||
right: 10px; | ||
z-index: 30; | ||
display: flex; | ||
height: 30px; | ||
border-radius: 4px; | ||
align-items: center; | ||
box-sizing: border-box; | ||
overflow: hidden; | ||
background-color: var(--primary); | ||
transition: 0.3s all linear; | ||
cursor: pointer; | ||
} | ||
|
||
#network-locker:not(.enabled) { | ||
background-color: var(--primary); | ||
} | ||
|
||
#network-locker.enabled { | ||
background-color: #af2222; | ||
} | ||
|
||
#network-locker>i { | ||
height: inherit; | ||
padding: 0 5px; | ||
display: flex; | ||
align-items: center; | ||
border-radius: 4px; | ||
margin-right: 10px; | ||
transition: 0.3s all linear; | ||
} | ||
|
||
#network-locker>i:not(.enabled) { | ||
background-color: var(--primary-lighter); | ||
} | ||
|
||
#network-locker>i.enabled { | ||
background-color: #cb3d3d; | ||
} | ||
|
||
#network-locker>p { | ||
font-family: "mononoki"; | ||
padding-right: 10px; | ||
display: flex; | ||
align-items: center; | ||
height: inherit; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
|
||
export class Locker { | ||
constructor(nsn) { | ||
this.dom = document.getElementById("network-locker"); | ||
this.networkView = document.getElementById("network--view"); | ||
this.nsn = nsn; | ||
this.unlock(); | ||
|
||
document.addEventListener("keydown", (event) => { | ||
const hotkeys = JSON.parse(localStorage.getItem("hotkeys")); | ||
switch (event.key.toUpperCase()) { | ||
case hotkeys.lock: { | ||
this.auto(); | ||
break; | ||
} | ||
} | ||
}); | ||
this.dom.addEventListener("click", () => { | ||
this.auto(); | ||
}); | ||
} | ||
|
||
auto() { | ||
this[this.locked ? "unlock" : "lock"](); | ||
} | ||
|
||
lock() { | ||
this.dom.classList.add("enabled"); | ||
this.dom.querySelector("p").textContent = "LOCKED"; | ||
this.networkView.classList.add("locked"); | ||
|
||
const iconElement = this.dom.querySelector("i"); | ||
iconElement.classList.remove("icon-plus-squared"); | ||
iconElement.classList.add("icon-minus-squared"); | ||
iconElement.classList.add("enabled"); | ||
|
||
this.nsn.lock(); | ||
this.locked = true; | ||
} | ||
|
||
unlock() { | ||
this.dom.classList.remove("enabled"); | ||
this.dom.querySelector("p").textContent = "UNLOCKED"; | ||
this.networkView.classList.remove("locked"); | ||
|
||
const iconElement = this.dom.querySelector("i"); | ||
iconElement.classList.remove("icon-minus-squared"); | ||
iconElement.classList.remove("enabled"); | ||
iconElement.classList.add("icon-plus-squared"); | ||
|
||
this.nsn.unlock(); | ||
this.locked = false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,13 +7,15 @@ import { ViewNavigation } from "./components/navigation/navigation.js"; | |
import { Wiki } from "./components/wiki/wiki.js"; | ||
import { SearchBar } from "./components/searchbar/searchbar.js"; | ||
import { Popup } from "./components/popup/popup.js"; | ||
import { Locker } from "./components/locker/locker.js"; | ||
|
||
// Import Views Components | ||
import { Settings } from "./components/views/settings/settings.js"; | ||
import { HomeView } from "./components/views/home/home.js"; | ||
import { NetworkNavigation } from "./core/network-navigation.js"; | ||
|
||
document.addEventListener("DOMContentLoaded", async() => { | ||
window.locker = null; | ||
window.popup = new Popup(); | ||
window.settings = await new Settings().fetchUserConfig(); | ||
window.navigation = new ViewNavigation(); | ||
|
@@ -30,8 +32,28 @@ document.addEventListener("DOMContentLoaded", async() => { | |
// Initialize vis Network | ||
NodeSecureNetwork.networkElementId = "dependency-graph"; | ||
const nsn = new NodeSecureNetwork(secureDataSet); | ||
window.locker = new Locker(nsn); | ||
new HomeView(secureDataSet, nsn); | ||
|
||
// document.addEventListener("keydown", (event) => { | ||
// if (event.code === "KeyP") { | ||
// nsn.highlightMultipleNodes( | ||
// nsn.findNodeIds( | ||
// new Set([ | ||
// "[email protected]", | ||
// "warp-ansi", | ||
// "[email protected]", | ||
// "@nodesecure/licenses-conformance" | ||
// ]) | ||
// ) | ||
// ); | ||
// } | ||
// else if (event.code === "KeyL") { | ||
// nsn.lock(); | ||
// console.log("locked: ", nsn.locked); | ||
// } | ||
// }); | ||
|
||
window.addEventListener("package-info-closed", () => { | ||
networkNavigation.currentNodeParams = null; | ||
packageInfoOpened = false; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.