Archived
Private
Public Access
1
0

Fixed some bugs + added custom domain support

This commit is contained in:
2023-03-25 20:19:33 +01:00
parent 6dfb5a4b48
commit 16dfadaa7d
19 changed files with 104 additions and 47 deletions

View File

@@ -1,6 +1,6 @@
<h1 mat-dialog-title *ngIf="data.title != undefined">{{data.title}}</h1>
<div mat-dialog-content *ngIf="data.subtitle != undefined">{{data.subtitle}}</div>
<div mat-dialog-actions *ngIf="data.buttons != undefined" id="buttons">
<div mat-dialog-actions *ngIf="data.buttons != undefined" class="buttons">
<button mat-button
(click)="dialogRef.close(button.value)"
*ngFor="let button of data.buttons"

View File

@@ -1,4 +1,4 @@
#buttons {
.buttons {
width: 100%;
display: flex;
justify-content: space-evenly;

View File

@@ -6,6 +6,7 @@ export interface DialogData {
title?: string;
subtitle?: string;
buttons?: {text: string, value: any, color: ThemePalette}[];
secondInput?: string;
}
@Component({

View File

@@ -4,10 +4,14 @@
<mat-label>{{data.subtitle}}</mat-label>
<input type="text" matInput #text>
</mat-form-field>
<mat-form-field [ngStyle]="{'display': data.secondInput ? 'block' : 'none'}">
<mat-label>{{data.secondInput}}</mat-label>
<input type="text" matInput #text2>
</mat-form-field>
</form>
<div mat-dialog-actions *ngIf="data.buttons != undefined" id="buttons">
<div mat-dialog-actions *ngIf="data.buttons != undefined" class="buttons">
<button mat-button
(click)="dialogRef.close({success: button.value, data: text.value})"
(click)="dialogRef.close({success: button.value, data: text.value, data2: text2?.value})"
*ngFor="let button of data.buttons"
[color]="button.color"
>{{button.text}}</button>

View File

@@ -0,0 +1,13 @@
form {
width: 350px;
& > * {
width: 100%;
}
}
.buttons {
width: 100%;
display: flex;
justify-content: space-evenly;
}

View File

@@ -12,4 +12,5 @@ export class TextDialogComponent {
public dialogRef: MatDialogRef<TextDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: DialogData,
) {}
}

View File

@@ -16,12 +16,16 @@
open: string,
edit: string,
delete: string,
deleteProjQuestion: string,
// Popups
name: string,
domain: string,
cancel: string,
createProject: string,
editProject: string
editProject: string,
updateProject: string,
deleteProject: string,
// Profile
profile: string,

View File

@@ -2,6 +2,7 @@
projectId?: string;
ownerId?: string;
name?: string;
domain?: string;
port?: number;
containerName?: string;
proxyId?: number;

View File

@@ -21,19 +21,19 @@ export class LangService {
const res = await firstValueFrom(this.crud.client.get<{files: string[]}>(location?.origin + "/lang"));
const languages = res.files;
this.allLanguages = languages.map(lang => lang.replace(".json", ""));
const tasks = [];
for (let lang of languages) {
const task = firstValueFrom(this.crud.client.get<Language>(location?.origin + "/assets/languages/" + lang))
.then(result => this.languages.set(lang.replace(".json", ""), result));
tasks.push(task);
}
await Promise.all(tasks);
this.currentLang = this.languages.get(this.storage.getItem("language") || "en-US");
this.currentLang = await this.loadLanguage(this.storage.getItem("language") || "en-US");
}
public setLanguage(lang: string) {
private async loadLanguage(name: string): Promise<Language> {
const lang = await firstValueFrom(this.crud.client.get<Language>(`${location.origin}/assets/languages/${name}.json`));
this.languages.set(name, lang);
return lang;
}
public async setLanguage(lang: string) {
if (this.languages.get(lang) == undefined)
await this.loadLanguage(lang);
this.currentLang = this.languages.get(lang);
this.storage.setItem("language", lang);
}

View File

@@ -31,8 +31,8 @@ export class ProjectService {
return response.content?.projectId;
}
public async editProject(projectId: string, name: string): Promise<boolean> {
const response = await this.crud.sendPutRequest("projects/" + projectId, {name});
public async editProject(projectId: string, name: string, domain: string): Promise<boolean> {
const response = await this.crud.sendPutRequest("projects/" + projectId, {name, domain});
return response.success;
}

View File

@@ -33,24 +33,26 @@ export class DashboardComponent {
public async editProject(projectId: string) {
const dialogRef = this.dialog.open(TextDialogComponent, {
data: {title: "Projekt umbenennen", subtitle: "Name", buttons: [
{text: "Abbrechen", value: false},
{text: "Projekt bearbeiten", value: true, color: 'primary'}
]}
data: {title: this.langs.currentLang?.editProject, subtitle: "Name", secondInput: this.langs.currentLang?.domain, buttons: [
{text: this.langs.currentLang?.cancel, value: false},
{text: this.langs.currentLang?.editProject, value: true, color: 'primary'}
]}
});
const result = await firstValueFrom(dialogRef.afterClosed()) as {success: boolean, data: string};
const result = await firstValueFrom(dialogRef.afterClosed()) as {success: boolean, data: string, data2: string};
if (!result?.success) return;
await this.projects.editProject(projectId, result.data);
NavigationComponent.spinnerVisible = true;
await this.projects.editProject(projectId, result.data, result.data2);
NavigationComponent.spinnerVisible = false;
await this.projects.loadProjects();
this.snackBar.open("Projekt aktualisiert!", undefined, {duration: 2000});
this.snackBar.open(this.langs.currentLang?.updateProject, undefined, {duration: 2000});
}
public async deleteProject(projectId: string) {
const dialogRef = this.dialog.open(DialogComponent, {
data: {title: "Möchtest du das Projekt wirklich löschen?", subtitle: "Alle gespeicherten Daten gehen dann verloren!", buttons: [
{text: "Abbrechen", value: false},
{text: "Löschen", value: true, color: 'warn'}
data: {title: this.langs.currentLang?.deleteProjQuestion, subtitle: this.langs.currentLang?.deleteWarning, buttons: [
{text: this.langs.currentLang?.cancel, value: false},
{text: this.langs.currentLang?.delete, value: true, color: 'warn'}
]}
});
@@ -60,7 +62,7 @@ export class DashboardComponent {
await this.projects.deleteProject(projectId);
NavigationComponent.spinnerVisible = false;
await this.projects.loadProjects();
this.snackBar.open("Projekt gelöscht!", undefined, {duration: 2000});
this.snackBar.open(this.langs.currentLang?.deleteProject, undefined, {duration: 2000});
}
public async updateProjectStatus(projectId: string, start: boolean) {

View File

@@ -14,11 +14,15 @@
"open": "Öffnen",
"edit": "Bearbeiten",
"delete": "Löschen",
"deleteProjQuestion": "Möchtest du dieses Projekt wirklich löschen?",
"name": "Name",
"domain": "Domain",
"cancel": "Abbrechen",
"createProject": "Projekt erstellen",
"editProject": "Projekt bearbeiten",
"updateProject": "Projekt aktualisiert!",
"deleteProject": "Projekt gelöscht!",
"profile": "Profil",
"profileSub": "Einstellungen",
@@ -32,7 +36,7 @@
"updateFailed": "Aktualisierung fehlgeschlagen",
"accountUpdated": "Account aktualisiert!",
"deleteQuestion": "Möchtest du deinen Account wirklich löschen?",
"deleteWarning": "All deine Projekte werden für immer gelöscht!",
"deleteWarning": "Alle Daten werden für immer gelöscht!",
"accountDeleted": "Account gelöscht!",
"submit": "Bestätigen",

View File

@@ -14,11 +14,15 @@
"open": "Open",
"edit": "Edit",
"delete": "Delete",
"deleteProjQuestion": "Do you really want to delete this project?",
"name": "Name",
"domain": "Domain",
"cancel": "Cancel",
"createProject": "Create project",
"editProject": "Edit project",
"updateProject": "Updated project!",
"deleteProject": "Deleted project!",
"profile": "Profile",
"profileSub": "Settings",
@@ -32,7 +36,7 @@
"updateFailed": "Update failed",
"accountUpdated": "Account updated",
"deleteQuestion": "Do you really want to delete your account?",
"deleteWarning": "All your data will be lost!",
"deleteWarning": "All data will be lost forever!",
"accountDeleted": "Account deleted!",
"submit": "Submit",