mirror of
https://github.com/louislam/dockge.git
synced 2025-03-13 21:04:47 +00:00
Compare commits
11 commits
ec982ecf30
...
b05cabb974
Author | SHA1 | Date | |
---|---|---|---|
|
b05cabb974 | ||
|
a65a9f5549 | ||
|
9b73e44cd9 | ||
|
165a944822 | ||
|
8533d18723 | ||
|
d5e8f17aa1 | ||
|
c451067ac4 | ||
|
9615b844c3 | ||
|
ff922232c1 | ||
|
be72cdbffe | ||
|
4fe1625f8d |
4 changed files with 98 additions and 41 deletions
|
@ -236,42 +236,63 @@ export function copyYAMLComments(doc : Document, src : Document) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy yaml comments from srcItems to items
|
* Copy yaml comments from srcItems to items
|
||||||
* Typescript is super annoying here, so I have to use any here
|
* Attempts to preserve comments by matching content rather than just array indices
|
||||||
* TODO: Since comments are belong to the array index, the comments will be lost if the order of the items is changed or removed or added.
|
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
function copyYAMLCommentsItems(items : any, srcItems : any) {
|
function copyYAMLCommentsItems(items: any, srcItems: any) {
|
||||||
if (!items || !srcItems) {
|
if (!items || !srcItems) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// First pass - try to match items by their content
|
||||||
for (let i = 0; i < items.length; i++) {
|
for (let i = 0; i < items.length; i++) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const item : any = items[i];
|
const item: any = items[i];
|
||||||
|
|
||||||
|
// Try to find matching source item by content
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const srcItem : any = srcItems[i];
|
const srcIndex = srcItems.findIndex((srcItem: any) =>
|
||||||
|
JSON.stringify(srcItem.value) === JSON.stringify(item.value) &&
|
||||||
|
JSON.stringify(srcItem.key) === JSON.stringify(item.key)
|
||||||
|
);
|
||||||
|
|
||||||
if (!srcItem) {
|
if (srcIndex !== -1) {
|
||||||
continue;
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
}
|
const srcItem: any = srcItems[srcIndex];
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
const nextSrcItem: any = srcItems[srcIndex + 1];
|
||||||
|
|
||||||
if (item.key && srcItem.key) {
|
if (item.key && srcItem.key) {
|
||||||
item.key.comment = srcItem.key.comment;
|
item.key.comment = srcItem.key.comment;
|
||||||
item.key.commentBefore = srcItem.key.commentBefore;
|
item.key.commentBefore = srcItem.key.commentBefore;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (srcItem.comment) {
|
if (srcItem.comment) {
|
||||||
item.comment = srcItem.comment;
|
item.comment = srcItem.comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.value && srcItem.value) {
|
// Handle comments between array items
|
||||||
if (typeof item.value === "object" && typeof srcItem.value === "object") {
|
if (nextSrcItem && nextSrcItem.commentBefore) {
|
||||||
item.value.comment = srcItem.value.comment;
|
if (items[i + 1]) {
|
||||||
item.value.commentBefore = srcItem.value.commentBefore;
|
items[i + 1].commentBefore = nextSrcItem.commentBefore;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (item.value.items && srcItem.value.items) {
|
// Handle trailing comments after array items
|
||||||
copyYAMLCommentsItems(item.value.items, srcItem.value.items);
|
if (srcItem.value && srcItem.value.comment) {
|
||||||
|
if (item.value) {
|
||||||
|
item.value.comment = srcItem.value.comment;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.value && srcItem.value) {
|
||||||
|
if (typeof item.value === "object" && typeof srcItem.value === "object") {
|
||||||
|
item.value.comment = srcItem.value.comment;
|
||||||
|
item.value.commentBefore = srcItem.value.commentBefore;
|
||||||
|
|
||||||
|
if (item.value.items && srcItem.value.items) {
|
||||||
|
copyYAMLCommentsItems(item.value.items, srcItem.value.items);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,3 +20,6 @@ services:
|
||||||
environment:
|
environment:
|
||||||
# Tell Dockge where is your stacks directory
|
# Tell Dockge where is your stacks directory
|
||||||
- DOCKGE_STACKS_DIR=/opt/stacks
|
- DOCKGE_STACKS_DIR=/opt/stacks
|
||||||
|
# Usefull for interactive action within the container
|
||||||
|
stdin_open: true # docker run -i
|
||||||
|
tty: true # docker run -t
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { DockgeServer } from "../backend/dockge-server";
|
||||||
import { log } from "../backend/log";
|
import { log } from "../backend/log";
|
||||||
import { io } from "socket.io-client";
|
import { io } from "socket.io-client";
|
||||||
import { BaseRes } from "../common/util-common";
|
import { BaseRes } from "../common/util-common";
|
||||||
|
import { generatePasswordHash } from "../backend/password-hash";
|
||||||
|
|
||||||
console.log("== Dockge Reset Password Tool ==");
|
console.log("== Dockge Reset Password Tool ==");
|
||||||
|
|
||||||
|
@ -29,36 +30,68 @@ export const main = async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
let user ;
|
||||||
// No need to actually reset the password for testing, just make sure no connection problem. It is ok for now.
|
// No need to actually reset the password for testing, just make sure no connection problem. It is ok for now.
|
||||||
|
|
||||||
if (!process.env.TEST_BACKEND) {
|
if (!process.env.TEST_BACKEND) {
|
||||||
const user = await R.findOne("user");
|
user = await R.findOne("user");
|
||||||
if (! user) {
|
|
||||||
throw new Error("user not found, have you installed?");
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("Found user: " + user.username);
|
if (! user ) {
|
||||||
|
if ( !process.env.USER ) {
|
||||||
while (true) {
|
throw new Error("user not found or provided, have you installed? Try to set USER and PASSWORD variables ...");
|
||||||
let password = await question("New Password: ");
|
} else {
|
||||||
let confirmPassword = await question("Confirm New Password: ");
|
console.log("Trying to initialise user : " + process.env.USER);
|
||||||
|
user = R.dispense("user");
|
||||||
if (password === confirmPassword) {
|
user.username = process.env.USER;
|
||||||
await User.resetPassword(user.id, password);
|
user.password = generatePasswordHash(process.env.PASSWORD);
|
||||||
|
await R.store(user);
|
||||||
|
console.log("User/Password set successfully");
|
||||||
|
|
||||||
// Reset all sessions by reset jwt secret
|
// Reset all sessions by reset jwt secret
|
||||||
await server.initJWTSecret();
|
await server.initJWTSecret();
|
||||||
|
console.log("JWT reset successfully.");
|
||||||
console.log("Password reset successfully.");
|
|
||||||
|
|
||||||
// Disconnect all other socket clients of the user
|
// Disconnect all other socket clients of the user
|
||||||
await disconnectAllSocketClients(user.username, password);
|
await disconnectAllSocketClients(user.username, user.password);
|
||||||
|
console.log("You may have to restart");
|
||||||
break;
|
exit;
|
||||||
} else {
|
|
||||||
console.log("Passwords do not match, please try again.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let password = "";
|
||||||
|
let confirmPassword = " ";
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
|
||||||
|
if (process.env.PASSWORD) {
|
||||||
|
console.log("Found password : " + process.env.PASSWORD) ;
|
||||||
|
password = process.env.PASSWORD ;
|
||||||
|
confirmPassword = process.env.PASSWORD ;
|
||||||
|
} else {
|
||||||
|
console.log("No found password: " ) ;
|
||||||
|
password = await question("New Password: ");
|
||||||
|
confirmPassword = await question("Confirm New Password: ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (password === confirmPassword) {
|
||||||
|
await User.resetPassword(user.id, password);
|
||||||
|
console.log("Password reset successfully.");
|
||||||
|
|
||||||
|
// Reset all sessions by reset jwt secret
|
||||||
|
await server.initJWTSecret();
|
||||||
|
|
||||||
|
console.log("JWT reset successfully.");
|
||||||
|
|
||||||
|
// Disconnect all other socket clients of the user
|
||||||
|
await disconnectAllSocketClients(user.username, password);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
console.log("Passwords do not match, please try again.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof Error) {
|
if (e instanceof Error) {
|
||||||
console.error("Error: " + e.message);
|
console.error("Error: " + e.message);
|
||||||
|
@ -127,3 +160,4 @@ function disconnectAllSocketClients(username : string, password : string) : Prom
|
||||||
if (!process.env.TEST_BACKEND) {
|
if (!process.env.TEST_BACKEND) {
|
||||||
main();
|
main();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -247,7 +247,6 @@ export default {
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.main-terminal {
|
.main-terminal {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow-x: scroll;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue