Skip to content

Commit

Permalink
Default display #164
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Dec 12, 2021
1 parent ef63142 commit 2bc667a
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 44 deletions.
20 changes: 15 additions & 5 deletions app/settings/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,21 @@ <h4>Uses GPU for smoother experience. Enable this option if you experience frame
</div>
<hr />
</div>
<h3>Default display</h3>
<h4>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="dropdownButton1" class="buttoni" onclick="display()">
<svg xmlns="http://www.w3.org/2000/svg" class="relative top-1 h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z" />
</svg>
Display #1
</button>

<div id="dropdownContent1" class="animation hidden absolute right-0 z-20 w-72 mt-2 bg-white rounded-2xl overflow-hidden border-white border-2">
<!-- displays -->
</div>
</div>
<hr />
<h3>Clear data</h3>
<h4>Clear password, 2FA codes and all other settings. Be careful.</h4>
<button class="buttoni" id="but1" onclick="clearData()">
Expand Down Expand Up @@ -323,11 +338,6 @@ <h4>You can view the logs for debugging. You can view all the logs in the settin
Logs folder
</button>
</div>

<hr />
<h3>Status</h3>
<h4>Current status of the API, used for updates only. Click for all the status information.</h4>
<button class="buttoni" id="but6" onclick="statusLink()">-</button>
<hr />
<h3>Version</h3>
<h4>Your current Authme version. Click for more info about Authme.</h4>
Expand Down
38 changes: 0 additions & 38 deletions app/settings/src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -636,43 +636,6 @@ const logsFolder = () => {
shell.openPath(path.join(folder_path, "logs"))
}

// ? status api
const status = document.querySelector("#but6")

const api = () => {
fetch("https://api.levminer.com/api/v1/status/all")
.then((res) => res.json())
.then((data) => {
try {
if (data.state === "up") {
status.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5.636 18.364a9 9 0 010-12.728m12.728 0a9 9 0 010 12.728m-9.9-2.829a5 5 0 010-7.07m7.072 0a5 5 0 010 7.07M13 12a1 1 0 11-2 0 1 1 0 012 0z" />
</svg> \n All systems online`
} else {
status.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18.364 5.636a9 9 0 010 12.728m0 0l-2.829-2.829m2.829 2.829L21 21M15.536 8.464a5 5 0 010 7.072m0 0l-2.829-2.829m-4.243 2.829a4.978 4.978 0 01-1.414-2.83m-1.414 5.658a9 9 0 01-2.167-9.238m7.824 2.167a1 1 0 111.414 1.414m-1.414-1.414L3 3m8.293 8.293l1.414 1.414" />
</svg> \n Some systems offline`
}
} catch (error) {
return logger.warn("Error loading API", error.stack)
}
})
.catch((error) => {
logger.warn("Can't connect to API", error.stack)

status.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18.364 5.636a9 9 0 010 12.728m0 0l-2.829-2.829m2.829 2.829L21 21M15.536 8.464a5 5 0 010 7.072m0 0l-2.829-2.829m-4.243 2.829a4.978 4.978 0 01-1.414-2.83m-1.414 5.658a9 9 0 01-2.167-9.238m7.824 2.167a1 1 0 111.414 1.414m-1.414-1.414L3 3m8.293 8.293l1.414 1.414" />
</svg> \n Can't connect to API`
})
}

api()

// ? open status
const statusLink = () => {
shell.openExternal("https://status.levminer.com")
}

// ? shortcuts docs
const shortcutsLink = () => {
shell.openExternal("https://docs.authme.levminer.com/#/settings?id=shortcuts")
Expand Down Expand Up @@ -849,7 +812,6 @@ check_for_internet()

setInterval(() => {
check_for_internet()
api()
}, 10000)

// ? dismiss dialog on click outside
Expand Down
36 changes: 35 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { app, BrowserWindow, Menu, Tray, shell, dialog, clipboard, globalShortcut, nativeTheme, ipcMain: ipc, powerMonitor: power } = require("electron")
const { app, BrowserWindow, Menu, Tray, shell, dialog, clipboard, globalShortcut, nativeTheme, ipcMain: ipc, powerMonitor: power, screen } = require("electron")
const logger = require("@levminer/lib/logger/main")
const { autoUpdater } = require("electron-updater")
const { number, date } = require("./build.json")
Expand Down Expand Up @@ -186,6 +186,7 @@ const settings_file = {
name: true,
description: false,
},
default_display: 1,
},
experimental: {
sort: null,
Expand Down Expand Up @@ -346,10 +347,31 @@ const createWindow = () => {
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.id === primary_display.id) {
displays[i].pop()
}
}

// 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({
x: display.bounds.x,
y: display.bounds.y,
width: 1900,
height: 1000,
minWidth: 1000,
Expand All @@ -371,6 +393,8 @@ const createWindow = () => {
})

window_confirm = new BrowserWindow({
x: display.bounds.x,
y: display.bounds.y,
width: 1900,
height: 1000,
minWidth: 1000,
Expand All @@ -392,6 +416,8 @@ const createWindow = () => {
})

window_application = new BrowserWindow({
x: display.bounds.x,
y: display.bounds.y,
width: 1900,
height: 1000,
minWidth: 1000,
Expand All @@ -413,6 +439,8 @@ const createWindow = () => {
})

window_settings = new BrowserWindow({
x: display.bounds.x,
y: display.bounds.y,
width: 1900,
height: 1000,
minWidth: 1000,
Expand All @@ -434,6 +462,8 @@ const createWindow = () => {
})

window_import = new BrowserWindow({
x: display.bounds.x,
y: display.bounds.y,
width: 1900,
height: 1000,
minWidth: 1000,
Expand All @@ -455,6 +485,8 @@ const createWindow = () => {
})

window_export = new BrowserWindow({
x: display.bounds.x,
y: display.bounds.y,
width: 1900,
height: 1000,
minWidth: 1000,
Expand All @@ -476,6 +508,8 @@ const createWindow = () => {
})

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

0 comments on commit 2bc667a

Please sign in to comment.