Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix configuration export and config helper link anchor #1268

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions console/ui/dist/prod-nt/index.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions console/ui/dist/prod-nt/main.c8a4957aed3434e8.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion console/ui/dist/prod-nt/static/main.c4960f6b7eee23f1.js

This file was deleted.

4 changes: 2 additions & 2 deletions console/ui/dist/prod/index.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions console/ui/dist/prod/main.9aac6bd3447e92de.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion console/ui/dist/prod/static/main.175bb59cdaac7d41.js

This file was deleted.

2 changes: 1 addition & 1 deletion console/ui/src/app/config/config.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h5><b>Server version:</b> {{nakamaVersion}}</h5>
<div class="col-lg-3">
<b>{{c.name}}</b>
<label class="pl-1" [for]="c.name">
<a target="_blank" href="https://heroiclabs.com/docs/nakama/getting-started/configuration/#{{c.value.name}}" class="d-inline"><img src="/static/svg/hint.svg" alt="" width="16" height="16"></a>
<a target="_blank" href="https://heroiclabs.com/docs/nakama/getting-started/configuration/#{{c.name}}" class="d-inline"><img src="/static/svg/hint.svg" alt="" width="16" height="16"></a>
</label>
</div>
<div class="col-lg-3">
Expand Down
44 changes: 18 additions & 26 deletions console/ui/src/app/config/config.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {Component, Injectable, OnDestroy, OnInit} from '@angular/core';
import {ActivatedRoute, ActivatedRouteSnapshot, Resolve, RouterStateSnapshot} from '@angular/router';
import {Config, ConfigParams, ConsoleService} from '../console.service';
import {Observable} from 'rxjs';
import {safeDump} from 'js-yaml';
import {dump} from 'js-yaml';
import * as FileSaver from 'file-saver';
import {FileSystemFileEntry, NgxFileDropEntry} from 'ngx-file-drop';
import {HttpClient} from '@angular/common/http';
Expand Down Expand Up @@ -73,34 +73,26 @@ export class ConfigComponent implements OnInit, OnDestroy {
});
}

private flattenConfig(config: Config): any {
const flatConfig = [];
this.traverseConfig('', config, flatConfig);
const sortedConfig = flatConfig.sort((a, b) => a.name.localeCompare(b.name));
return sortedConfig;
}
private flattenConfig(data: any, currPath: string = ''): any[] {
let result: any[] = []

private traverseConfig(prefix: string, config: any, flattened: any[]): void {
for (const key in config) {
if (key === 'env') {
// we'll separate out runtime environments into its own config handling
continue;
}
Object.keys(data).forEach((key) => {
const node = data[key]
const path = currPath ? `${currPath}.${key}` : key

if (!key) return

if (Array.isArray(config[key])) {
flattened.push({
name: prefix + key,
value: config[key].join(', '),
});
} else if (typeof config[key] === 'object') {
this.traverseConfig(key + '.', config[key], flattened);
if (node && typeof node === 'object' && !Array.isArray(node)) {
result = result.concat(this.flattenConfig(node, path))
} else {
flattened.push({
name: prefix + key,
value: config[key],
});
result.push({
name: path,
value: node,
})
}
}
})

return result
}

public isEmpty(value: any): boolean {
Expand All @@ -114,7 +106,7 @@ export class ConfigComponent implements OnInit, OnDestroy {
}

public exportYaml(): void {
const blob = new Blob([safeDump(this.jsonConfig)], {type: 'text/yaml;charset=utf-8'});
const blob = new Blob([dump(this.jsonConfig)], {type: 'text/yaml;charset=utf-8'});
FileSaver.saveAs(blob, 'config.yaml');
}

Expand Down
Loading