Skip to content

Commit 4a02fc1

Browse files
committed
Fix configuration export and config helper link anchor
1 parent d80078b commit 4a02fc1

16 files changed

+25
-33
lines changed

console/ui/dist/prod-nt/index.html

+2-2
Large diffs are not rendered by default.

console/ui/dist/prod-nt/main.c8a4957aed3434e8.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

console/ui/dist/prod-nt/static/main.c4960f6b7eee23f1.js

-1
This file was deleted.

console/ui/dist/prod/index.html

+2-2
Large diffs are not rendered by default.

console/ui/dist/prod/main.9aac6bd3447e92de.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

console/ui/dist/prod/static/main.175bb59cdaac7d41.js

-1
This file was deleted.

console/ui/src/app/config/config.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ <h5><b>Server version:</b> {{nakamaVersion}}</h5>
1616
<div class="col-lg-3">
1717
<b>{{c.name}}</b>
1818
<label class="pl-1" [for]="c.name">
19-
<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>
19+
<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>
2020
</label>
2121
</div>
2222
<div class="col-lg-3">

console/ui/src/app/config/config.component.ts

+18-26
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {Component, Injectable, OnDestroy, OnInit} from '@angular/core';
1616
import {ActivatedRoute, ActivatedRouteSnapshot, Resolve, RouterStateSnapshot} from '@angular/router';
1717
import {Config, ConfigParams, ConsoleService} from '../console.service';
1818
import {Observable} from 'rxjs';
19-
import {safeDump} from 'js-yaml';
19+
import {dump} from 'js-yaml';
2020
import * as FileSaver from 'file-saver';
2121
import {FileSystemFileEntry, NgxFileDropEntry} from 'ngx-file-drop';
2222
import {HttpClient} from '@angular/common/http';
@@ -73,34 +73,26 @@ export class ConfigComponent implements OnInit, OnDestroy {
7373
});
7474
}
7575

76-
private flattenConfig(config: Config): any {
77-
const flatConfig = [];
78-
this.traverseConfig('', config, flatConfig);
79-
const sortedConfig = flatConfig.sort((a, b) => a.name.localeCompare(b.name));
80-
return sortedConfig;
81-
}
76+
private flattenConfig(data: any, currPath: string = ''): any[] {
77+
let result: any[] = []
8278

83-
private traverseConfig(prefix: string, config: any, flattened: any[]): void {
84-
for (const key in config) {
85-
if (key === 'env') {
86-
// we'll separate out runtime environments into its own config handling
87-
continue;
88-
}
79+
Object.keys(data).forEach((key) => {
80+
const node = data[key]
81+
const path = currPath ? `${currPath}.${key}` : key
82+
83+
if (!key) return
8984

90-
if (Array.isArray(config[key])) {
91-
flattened.push({
92-
name: prefix + key,
93-
value: config[key].join(', '),
94-
});
95-
} else if (typeof config[key] === 'object') {
96-
this.traverseConfig(key + '.', config[key], flattened);
85+
if (node && typeof node === 'object' && !Array.isArray(node)) {
86+
result = result.concat(this.flattenConfig(node, path))
9787
} else {
98-
flattened.push({
99-
name: prefix + key,
100-
value: config[key],
101-
});
88+
result.push({
89+
name: path,
90+
value: node,
91+
})
10292
}
103-
}
93+
})
94+
95+
return result
10496
}
10597

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

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

0 commit comments

Comments
 (0)