Skip to content

Commit

Permalink
Remove default display #196
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Mar 28, 2022
1 parent 79e9369 commit 77a4117
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 165 deletions.
19 changes: 0 additions & 19 deletions app/settings/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -300,25 +300,6 @@ <h4 data-loc>Choose which language should Authme use by default. The translation
</div>
</div>
<hr />
<h3 data-loc>Default display</h3>
<h4 data-loc>Choose which display should Authme open by default. Authme will fall back to the primary display if the chosen one is not available.</h4>
<div class="relative inline-block">
<button id="displayButton" class="buttoni" onclick="display()">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<rect x="3" y="4" width="18" height="12" rx="1"></rect>
<line x1="7" y1="20" x2="17" y2="20"></line>
<line x1="9" y1="16" x2="9" y2="20"></line>
<line x1="15" y1="16" x2="15" y2="20"></line>
</svg>
Display #1
</button>

<div id="displayContent" class="animation absolute right-0 z-20 mt-2 hidden w-72 overflow-hidden rounded-2xl border-2 border-white bg-white">
<!-- displays -->
</div>
</div>
<hr />
<h3 data-loc>Clear data</h3>
<h4 data-loc>Clear password, 2FA codes and all other settings. Be careful.</h4>
<button class="buttoni" onclick="clearData()">
Expand Down
107 changes: 1 addition & 106 deletions app/settings/src/js/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { shell, app, dialog, BrowserWindow, screen } = require("@electron/remote")
const { shell, app, dialog, BrowserWindow } = require("@electron/remote")
const { convert, localization, time } = require("@levminer/lib")
const logger = require("@levminer/lib/logger/renderer")
const { ipcRenderer: ipc } = require("electron")
Expand Down Expand Up @@ -87,7 +87,6 @@ const currentWindow = BrowserWindow.getFocusedWindow()
* Elements
*/
const drp0 = document.querySelector("#sortButton")
const drp1 = document.querySelector("#displayButton")
const drp2 = document.querySelector("#languageButton")
const tgl0 = document.querySelector("#tgl0")
const tgt0 = document.querySelector("#tgt0")
Expand Down Expand Up @@ -193,18 +192,6 @@ if (sort_number === 1) {
</svg> Z-A`
}

// display
drp1.innerHTML = `
<svg xmlns="http://www.w3.org/2000/svg" class="relative top-1 h-6 w-6 pointer-events-none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<rect x="3" y="4" width="18" height="12" rx="1"></rect>
<line x1="7" y1="20" x2="17" y2="20"></line>
<line x1="9" y1="16" x2="9" y2="20"></line>
<line x1="15" y1="16" x2="15" y2="20"></line>
</svg>
${lang.text.display} #${settings.settings.default_display}
`

// language
switch (settings.settings.language) {
case "en":
Expand Down Expand Up @@ -965,8 +952,6 @@ const reload = () => {
window.addEventListener("click", (event) => {
const sort_content = document.querySelector("#sortContent")
const sort_button = document.querySelector("#sortButton")
const display_content = document.querySelector("#displayContent")
const display_button = document.querySelector("#displayButton")
const language_content = document.querySelector("#languageContent")
const language_button = document.querySelector("#languageButton")

Expand All @@ -976,12 +961,6 @@ window.addEventListener("click", (event) => {
sort_shown = false
}

if (event.target != display_button) {
display_content.style.display = ""

display_shown = false
}

if (event.target != language_button) {
language_content.style.display = ""

Expand Down Expand Up @@ -1081,90 +1060,6 @@ const screenCapture = () => {
})
}

/**
* Get screens
*/
const displays = screen.getAllDisplays()
const display_content = document.querySelector("#displayContent")

for (let i = 1; i < displays.length + 1; i++) {
const element = document.createElement("a")

element.innerHTML = `
<a href="#" onclick="displayChoose(${i})" class="block no-underline text-xl px-2 py-2 transform duration-200 ease-in text-black hover:bg-gray-600 hover:text-white">
<svg xmlns="http://www.w3.org/2000/svg" class="relative top-1 h-6 w-6 pointer-events-none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<rect x="3" y="4" width="18" height="12" rx="1"></rect>
<line x1="7" y1="20" x2="17" y2="20"></line>
<line x1="9" y1="16" x2="9" y2="20"></line>
<line x1="15" y1="16" x2="15" y2="20"></line>
</svg>
${lang.text.display} #${i}
</a>
`

display_content.appendChild(element)
}

/**
* Toggle default display dropdown
*/
let display_shown = false
const display = () => {
if (display_shown === false) {
display_content.style.visibility = "visible"

setTimeout(() => {
display_content.style.display = "block"
}, 10)

display_shown = true
} else {
display_content.style.display = ""

display_shown = false
}
}

const displayChoose = (id) => {
const toggle = () => {
drp1.innerHTML = `
<svg xmlns="http://www.w3.org/2000/svg" class="relative top-1 h-6 w-6 pointer-events-none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<rect x="3" y="4" width="18" height="12" rx="1"></rect>
<line x1="7" y1="20" x2="17" y2="20"></line>
<line x1="9" y1="16" x2="9" y2="20"></line>
<line x1="15" y1="16" x2="15" y2="20"></line>
</svg>
${lang.text.display} #${id}
`

settings.settings.default_display = id
save()
}

dialog
.showMessageBox({
title: "Authme",
buttons: [lang.button.yes, lang.button.no, lang.button.cancel],
defaultId: 2,
cancelId: 2,
noLink: true,
type: "warning",
message: lang.settings_dialog.restart,
})
.then((result) => {
if (result.response === 0) {
toggle()
restart()
}

if (result.response === 1) {
toggle()
}
})
}

/* Experimental docs */
const experimentalDocs = () => {
shell.openExternal("https://docs.authme.levminer.com/#/settings?id=experimental-features")
Expand Down
3 changes: 0 additions & 3 deletions languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ module.exports = {
"time": "Time",
"description": "Description",
"latest_save": "Latest save",
"display": "Display",
"default": "Default",
"quick_shortcuts": "Please save your 2FA codes on the main page and click reload to be able to create quick shortcuts!",
"refresh": "Refresh",
Expand Down Expand Up @@ -184,8 +183,6 @@ module.exports = {
"Language",
"Choose which language should Authme use by default. The translations are not perfect and changing the language requires a restart.",
"Default",
"Default display",
"Choose which display should Authme open by default. Authme will fall back to the primary display if the chosen one is not available.",
"Clear data",
"Clear password, 2FA codes and all other settings. Be careful.",
"Clear data",
Expand Down
3 changes: 0 additions & 3 deletions languages/hu.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ module.exports = {
"time": "Idő",
"description": "Leírás",
"latest_save": "Legfrisebb mentés",
"display": "Monitor",
"default": "Alapértelmezett",
"quick_shortcuts": "Kérlek mentsd el a 2FA kódjaidat a főoldalon és kattints a frissítésre!",
"refresh": "Frissítés",
Expand Down Expand Up @@ -184,8 +183,6 @@ module.exports = {
"Nyelv",
"Válaszd ki a nyelvet amin az Authme megjelenik. A fordítások nem tökéletesek, hibák előfordulhatnak.",
"Alapértelmezett",
"Alapértelmezett monitor",
"Válaszd ki melyik képernyőn nyíljon meg az Authme. Ha a kiválasztott monitor nem elérhető, a fő monitoron fog megnyílni az Authme.",
"Adatok törlése",
"A jelszavak, a 2FA kódjaid, valamint a beállításaid törlődnek. Légy óvatos.",
"Adatok törlése",
Expand Down
34 changes: 0 additions & 34 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ const settings_file = {
name: true,
description: false,
},
default_display: 1,
language: null,
sort: null,
},
Expand Down Expand Up @@ -413,32 +412,11 @@ const createWindows = () => {
wco = true
}

/**
* Open Authme on selected display
*/
const displays = screen.getAllDisplays()
const primary_display = screen.getPrimaryDisplay()

// Remove primary display
for (let i = 0; i < displays.length; i++) {
if (displays[i].id === primary_display.id) {
displays.splice(i, 1)
}
}

// Add primary display
displays.splice(0, 0, primary_display)

// Get selected display
const display = displays[settings.settings.default_display - 1]

/**
* Create windows
*/
window_landing = new BrowserWindow({
title: `Authme (${authme_version})`,
x: display.bounds.x,
y: display.bounds.y,
width: 1900,
height: 1000,
minWidth: 1000,
Expand All @@ -461,8 +439,6 @@ const createWindows = () => {

window_confirm = new BrowserWindow({
title: `Authme (${authme_version})`,
x: display.bounds.x,
y: display.bounds.y,
width: 1900,
height: 1000,
minWidth: 1000,
Expand All @@ -485,8 +461,6 @@ const createWindows = () => {

window_application = new BrowserWindow({
title: `Authme (${authme_version})`,
x: display.bounds.x,
y: display.bounds.y,
width: 1900,
height: 1000,
minWidth: 1000,
Expand All @@ -509,8 +483,6 @@ const createWindows = () => {

window_settings = new BrowserWindow({
title: "Authme Settings",
x: display.bounds.x,
y: display.bounds.y,
width: 1900,
height: 1000,
minWidth: 1000,
Expand All @@ -533,8 +505,6 @@ const createWindows = () => {

window_import = new BrowserWindow({
title: "Authme Import",
x: display.bounds.x,
y: display.bounds.y,
width: 1900,
height: 1000,
minWidth: 1000,
Expand All @@ -557,8 +527,6 @@ const createWindows = () => {

window_export = new BrowserWindow({
title: "Authme Export",
x: display.bounds.x,
y: display.bounds.y,
width: 1900,
height: 1000,
minWidth: 1000,
Expand All @@ -581,8 +549,6 @@ const createWindows = () => {

window_edit = new BrowserWindow({
title: "Authme Edit codes",
x: display.bounds.x,
y: display.bounds.y,
width: 1900,
height: 1000,
minWidth: 1000,
Expand Down

0 comments on commit 77a4117

Please sign in to comment.