Compare commits

...

5 Commits

Author SHA1 Message Date
52e1f555bf Update to 1.1.1 2023-11-21 20:16:50 +08:00
31726315c3 Improvements (#124)
* Improvements

* Add inspect to dev:backend

* Skip debug log at the beginning
2023-11-21 18:51:38 +08:00
e95ef66ca1 Add "docker compose down" (#122) 2023-11-21 18:17:11 +08:00
b7c6bbba67 Slovenian language file (#108)
* Slovenian language file

This is a translation from the en.json file to the Slovenian language

* Update for Slovenian language in i18n.ts

Slovenian languge added to the language list

* Update i18n.ts

Removed trailing spaces
2023-11-21 18:12:54 +08:00
dc8c3a7568 Update Turkish language (#121) 2023-11-21 15:13:12 +08:00
11 changed files with 271 additions and 52 deletions

View File

@ -103,6 +103,10 @@ class Logger {
* @param level Log level. One of INFO, WARN, ERROR, DEBUG or can be customized.
*/
log(module: string, msg: unknown, level: string) {
if (level === "DEBUG" && !isDev) {
return;
}
if (this.hideLog[level] && this.hideLog[level].includes(module.toLowerCase())) {
return;
}

View File

@ -187,6 +187,27 @@ export class DockerSocketHandler extends SocketHandler {
}
});
// down stack
socket.on("downStack", async (stackName : unknown, callback) => {
try {
checkLogin(socket);
if (typeof(stackName) !== "string") {
throw new ValidationError("Stack name must be a string");
}
const stack = Stack.getStack(server, stackName);
await stack.down(socket);
callback({
ok: true,
msg: "Downed"
});
server.sendStackList();
} catch (e) {
callbackError(e, callback);
}
});
// Services status
socket.on("serviceStatusList", async (stackName : unknown, callback) => {
try {
@ -196,7 +217,7 @@ export class DockerSocketHandler extends SocketHandler {
throw new ValidationError("Stack name must be a string");
}
const stack = Stack.getStack(server, stackName);
const stack = Stack.getStack(server, stackName, true);
const serviceStatusList = Object.fromEntries(await stack.getServiceStatusList());
callback({
ok: true,

View File

@ -31,17 +31,19 @@ export class Stack {
protected static managedStackList: Map<string, Stack> = new Map();
constructor(server : DockgeServer, name : string, composeYAML? : string) {
constructor(server : DockgeServer, name : string, composeYAML? : string, skipFSOperations = false) {
this.name = name;
this.server = server;
this._composeYAML = composeYAML;
// Check if compose file name is different from compose.yaml
const supportedFileNames = [ "compose.yaml", "compose.yml", "docker-compose.yml", "docker-compose.yaml" ];
for (const filename of supportedFileNames) {
if (fs.existsSync(path.join(this.path, filename))) {
this._composeFileName = filename;
break;
if (!skipFSOperations) {
// Check if compose file name is different from compose.yaml
const supportedFileNames = [ "compose.yaml", "compose.yml", "docker-compose.yml", "docker-compose.yaml" ];
for (const filename of supportedFileNames) {
if (fs.existsSync(path.join(this.path, filename))) {
this._composeFileName = filename;
break;
}
}
}
}
@ -281,23 +283,34 @@ export class Stack {
}
}
static getStack(server: DockgeServer, stackName: string) : Stack {
static getStack(server: DockgeServer, stackName: string, skipFSOperations = false) : Stack {
let dir = path.join(server.stacksDir, stackName);
if (!fs.existsSync(dir) || !fs.statSync(dir).isDirectory()) {
// Maybe it is a stack managed by docker compose directly
let stackList = this.getStackList(server);
let stack = stackList.get(stackName);
if (!skipFSOperations) {
if (!fs.existsSync(dir) || !fs.statSync(dir).isDirectory()) {
// Maybe it is a stack managed by docker compose directly
let stackList = this.getStackList(server, true);
let stack = stackList.get(stackName);
if (stack) {
return stack;
} else {
// Really not found
throw new ValidationError("Stack not found");
if (stack) {
return stack;
} else {
// Really not found
throw new ValidationError("Stack not found");
}
}
} else {
log.debug("getStack", "Skip FS operations");
}
let stack : Stack;
if (!skipFSOperations) {
stack = new Stack(server, stackName);
} else {
stack = new Stack(server, stackName, undefined, true);
}
let stack = new Stack(server, stackName);
stack._status = UNKNOWN;
stack._configFilePath = path.resolve(dir);
return stack;
@ -330,6 +343,15 @@ export class Stack {
return exitCode;
}
async down(socket: DockgeSocket) : Promise<number> {
const terminalName = getComposeTerminalName(this.name);
let exitCode = await Terminal.exec(this.server, socket, terminalName, "docker", [ "compose", "down" ], this.path);
if (exitCode !== 0) {
throw new Error("Failed to down, please check the terminal output for more information.");
}
return exitCode;
}
async update(socket: DockgeSocket) {
const terminalName = getComposeTerminalName(this.name);
let exitCode = await Terminal.exec(this.server, socket, terminalName, "docker", [ "compose", "pull" ], this.path);
@ -377,11 +399,11 @@ export class Stack {
async getServiceStatusList() {
let statusList = new Map<string, number>();
let res = childProcess.execSync("docker compose ps --format json", {
let res = childProcess.spawnSync("docker", [ "compose", "ps", "--format", "json" ], {
cwd: this.path,
});
let lines = res.toString().split("\n");
let lines = res.stdout.toString().split("\n");
for (let line of lines) {
try {

View File

@ -80,37 +80,53 @@ export class Terminal {
return;
}
this._ptyProcess = pty.spawn(this.file, this.args, {
name: this.name,
cwd: this.cwd,
cols: TERMINAL_COLS,
rows: this.rows,
});
try {
this._ptyProcess = pty.spawn(this.file, this.args, {
name: this.name,
cwd: this.cwd,
cols: TERMINAL_COLS,
rows: this.rows,
});
// On Data
this._ptyProcess.onData((data) => {
this.buffer.pushItem(data);
if (this.server.io) {
this.server.io.to(this.name).emit("terminalWrite", this.name, data);
// On Data
this._ptyProcess.onData((data) => {
this.buffer.pushItem(data);
if (this.server.io) {
this.server.io.to(this.name).emit("terminalWrite", this.name, data);
}
});
// On Exit
this._ptyProcess.onExit(this.exit);
} catch (error) {
if (error instanceof Error) {
log.error("Terminal", "Failed to start terminal: " + error.message);
const exitCode = Number(error.message.split(" ").pop());
this.exit({
exitCode,
});
}
});
// On Exit
this._ptyProcess.onExit((res) => {
this.server.io.to(this.name).emit("terminalExit", this.name, res.exitCode);
// Remove room
this.server.io.in(this.name).socketsLeave(this.name);
Terminal.terminalMap.delete(this.name);
log.debug("Terminal", "Terminal " + this.name + " exited with code " + res.exitCode);
if (this.callback) {
this.callback(res.exitCode);
}
});
}
}
/**
* Exit event handler
* @param res
*/
protected exit = (res : {exitCode: number, signal?: number | undefined}) => {
this.server.io.to(this.name).emit("terminalExit", this.name, res.exitCode);
// Remove room
this.server.io.in(this.name).socketsLeave(this.name);
Terminal.terminalMap.delete(this.name);
log.debug("Terminal", "Terminal " + this.name + " exited with code " + res.exitCode);
if (this.callback) {
this.callback(res.exitCode);
}
};
public onExit(callback : (exitCode : number) => void) {
this.callback = callback;
}

View File

@ -11,6 +11,9 @@ declare module 'vue' {
Appearance: typeof import('./src/components/settings/Appearance.vue')['default']
ArrayInput: typeof import('./src/components/ArrayInput.vue')['default']
ArraySelect: typeof import('./src/components/ArraySelect.vue')['default']
BDropdown: typeof import('bootstrap-vue-next')['BDropdown']
BDropdownDivider: typeof import('bootstrap-vue-next')['BDropdownDivider']
BDropdownItem: typeof import('bootstrap-vue-next')['BDropdownItem']
BModal: typeof import('bootstrap-vue-next')['BModal']
Confirm: typeof import('./src/components/Confirm.vue')['default']
Container: typeof import('./src/components/Container.vue')['default']

View File

@ -8,11 +8,12 @@ const languageList = {
"de": "Deutsch",
"fr": "Français",
"pt": "Português",
"sl": "Slovenščina",
"tr": "Türkçe",
"zh-CN": "简体中文",
"ur": "Urdu",
"ko-KR": "한국어",
"ru": "Русский",
"ru": "Русский"
};
let messages = {

View File

@ -19,6 +19,7 @@
"restartStack": "Restart",
"updateStack": "Update",
"startStack": "Start",
"downStack": "Stop & Down",
"editStack": "Edit",
"discardStack": "Discard",
"saveStackDraft": "Save",

94
frontend/src/lang/sl.json Normal file
View File

@ -0,0 +1,94 @@
{
"languageName": "Slovenščina",
"Create your admin account": "Ustvarite svoj skrbniški račun",
"authIncorrectCreds": "Napačno uporabniško ime ali geslo.",
"PasswordsDoNotMatch": "Gesli se ne ujemata.",
"Repeat Password": "Ponovi geslo",
"Create": "Ustvari",
"signedInDisp": "Prijavljeni kot {0}",
"signedInDispDisabled": "Preverjanje pristnosti onemogočeno.",
"home": "Domov",
"console": "Konzola",
"registry": "Register",
"compose": "Compose",
"addFirstStackMsg": "Ustvarite svoj prvi Stack!",
"stackName": "Ime Stack-a",
"deployStack": "Razporedi",
"deleteStack": "Izbriši",
"stopStack": "Ustavi",
"restartStack": "Ponovni zagon",
"updateStack": "Posodobi",
"startStack": "Zaženi",
"editStack": "Uredi",
"discardStack": "Zavrzi",
"saveStackDraft": "Shrani",
"notAvailableShort": "Ni na voljo",
"deleteStackMsg": "Ste prepričani, da želite izbrisati ta Stack?",
"stackNotManagedByDockgeMsg": "Ta Stack ni upravljan s strani Dockge.",
"primaryHostname": "Osnovno gostiteljsko ime",
"general": "Splošno",
"container": "Kontejner | Kontejnerji",
"scanFolder": "Preglej Stack mapo",
"dockerImage": "Slika",
"restartPolicyUnlessStopped": "Razen ko je zaustavljeno",
"restartPolicyAlways": "Vedno",
"restartPolicyOnFailure": "Ob napaki",
"restartPolicyNo": "Ne",
"environmentVariable": "Okoljska spremenljivka | Okoljske spremenljivke",
"restartPolicy": "Politika ponovnega zagona",
"containerName": "Ime kontejnerja",
"port": "Vrata | Vrata",
"volume": "Zvezek | Zvezki",
"network": "Omrežje | Omrežja",
"dependsOn": "Odvisnost kontejnerja | Odvisnosti kontejnerjev",
"addListItem": "Dodaj {0}",
"deleteContainer": "Izbriši",
"addContainer": "Dodaj kontejner",
"addNetwork": "Dodaj omrežje",
"disableauth.message1": "Ste prepričani, da želite <strong>onemogočiti overjanje</strong>?",
"disableauth.message2": "Namerno je zasnovano za scenarije, <strong>kjer nameravate izvajati avtentikacijo tretjih oseb</strong> pred Dockge, kot so Cloudflare Access, Authelia ali druge avtentikacijske mehanizme.",
"passwordNotMatchMsg": "Ponovljeno geslo se ne ujema.",
"autoGet": "Samodejno pridobi",
"add": "Dodaj",
"Edit": "Uredi",
"applyToYAML": "Uporabi za YAML",
"createExternalNetwork": "Ustvari",
"addInternalNetwork": "Dodaj",
"Save": "Shrani",
"Language": "Jezik",
"Current User": "Trenutni uporabnik",
"Change Password": "Spremeni geslo",
"Current Password": "Trenutno geslo",
"New Password": "Novo geslo",
"Repeat New Password": "Ponovi novo geslo",
"Update Password": "Posodobi geslo",
"Advanced": "Napredno",
"Please use this option carefully!": "Prosimo, uporabite to možnost previdno!",
"Enable Auth": "Omogoči overjanje",
"Disable Auth": "Onemogoči overjanje",
"I understand, please disable": "Razumem, prosim onemogočite",
"Leave": "Zapusti",
"Frontend Version": "Različica vmesnika",
"Check Update On GitHub": "Preveri posodobitve na GitHubu",
"Show update if available": "Prikaži posodobitve, če so na voljo",
"Also check beta release": "Preveri tudi beta izdaje",
"Remember me": "Zapomni si me",
"Login": "Prijava",
"Username": "Uporabniško ime",
"Password": "Geslo",
"Settings": "Nastavitve",
"Logout": "Odjava",
"Lowercase only": "Samo male črke",
"Convert to Compose": "Pretvori v Compose",
"Docker Run": "Zagon Dockerja",
"active": "aktivno",
"exited": "izklopljeno",
"inactive": "neaktivno",
"Appearance": "Videz",
"Security": "Varnost",
"About": "O nas",
"Allowed commands:": "Dovoljeni ukazi:",
"Internal Networks": "Notranja omrežja",
"External Networks": "Zunanja omrežja",
"No External Networks": "Ni zunanjih omrežij"
}

View File

@ -1,7 +1,10 @@
{
"languageName": "Türkçe",
"Create your admin account": "Yönetici hesabınızı oluşturun",
"authIncorrectCreds": "Yanlış kullanıcı adı veya parola.",
"PasswordsDoNotMatch": "Parolalar eşleşmiyor.",
"Repeat Password": "Parolayı Tekrarla",
"Create": "Oluştur",
"signedInDisp": "{0} olarak oturum açıldı",
"signedInDispDisabled": "Yetkilendirme Devre Dışı.",
"home": "Anasayfa",
@ -47,7 +50,45 @@
"passwordNotMatchMsg": "Tekrarlanan parola eşleşmiyor.",
"autoGet": "Otomatik Al",
"add": "Ekle",
"Edit": "Düzenle",
"applyToYAML": "YAML'ye uygulayın",
"createExternalNetwork": "Oluştur",
"addInternalNetwork": "Ekle"
"addInternalNetwork": "Ekle",
"Save": "Kaydet",
"Language": "Dil",
"Current User": "Mevcut Kullanıcı",
"Change Password": "Mevcut Parola",
"Current Password": "Mevcut Parola",
"New Password": "Yeni Parola",
"Repeat New Password": "Yeni Parolayı Tekrarla",
"Update Password": "Parolayı Güncelle",
"Advanced": "Gelişmiş",
"Please use this option carefully!": "Lütfen bu seçeneği dikkatli kullanın!",
"Enable Auth": "Kimlik Doğrulamayı Etkinleştir",
"Disable Auth": "Kimlik Doğrulamayı Devre Dışı Bırak",
"I understand, please disable": "Anlıyorum, lütfen devre dışı bırakın",
"Leave": "Ayrıl",
"Frontend Version": "Frontend Versiyon",
"Check Update On GitHub": "GitHub'da Güncellemeyi Kontrol Edin",
"Show update if available": "Varsa güncellemeyi göster",
"Also check beta release": "Ayrıca beta sürümünü kontrol edin",
"Remember me": "Beni Hatırla",
"Login": "Oturum Aç",
"Username": "Kullanıcı Adı",
"Password": "Parola",
"Settings": "Ayarlar",
"Logout": "Oturumu Kapat",
"Lowercase only": "Yalnızca küçük harf",
"Convert to Compose": "Compose'a Dönüştür",
"Docker Run": "Docker Run",
"active": "aktif",
"exited": ıkış yaptı",
"inactive": "aktif değil",
"Appearance": "Görünüm",
"Security": "Güvenlik",
"About": "Hakkında",
"Allowed commands:": "İzin verilen komutlar:",
"Internal Networks": "İç Ağlar",
"External Networks": "Dış Ağlar",
"No External Networks": "Dış Ağ Yok"
}

View File

@ -40,6 +40,13 @@
<font-awesome-icon icon="stop" class="me-1" />
{{ $t("stopStack") }}
</button>
<BDropdown v-if="!isEditMode && active" right text="" variant="normal">
<BDropdownItem @click="downStack">
<font-awesome-icon icon="stop" class="me-1" />
{{ $t("downStack") }}
</BDropdownItem>
</BDropdown>
</div>
<button v-if="isEditMode && !isAdd" class="btn btn-normal" :disabled="processing" @click="discardStack">{{ $t("discardStack") }}</button>
@ -473,6 +480,15 @@ export default {
});
},
downStack() {
this.processing = true;
this.$root.getSocket().emit("downStack", this.stack.name, (res) => {
this.processing = false;
this.$root.toastRes(res);
});
},
restartStack() {
this.processing = true;

View File

@ -1,13 +1,13 @@
{
"name": "dockge",
"version": "1.1.0",
"version": "1.1.1",
"type": "module",
"scripts": {
"fmt": "eslint \"**/*.{ts,vue}\" --fix",
"lint": "eslint \"**/*.{ts,vue}\"",
"check-ts": "tsc --noEmit",
"start": "tsx ./backend/index.ts",
"dev:backend": "cross-env NODE_ENV=development tsx watch ./backend/index.ts",
"dev:backend": "cross-env NODE_ENV=development tsx watch --inspect ./backend/index.ts",
"dev:frontend": "cross-env NODE_ENV=development vite --host --config ./frontend/vite.config.ts",
"release-final": "tsx ./extra/test-docker.ts && tsx extra/update-version.ts && pnpm run build:frontend && npm run build:docker",
"build:frontend": "vite build --config ./frontend/vite.config.ts",