fix: валидация дублей ключей env vars + подсветка красным
This commit is contained in:
@@ -55,7 +55,7 @@ spec:
|
||||
serviceAccountName: fission-console
|
||||
containers:
|
||||
- name: console
|
||||
image: naeel/fission-console:v1.3.73
|
||||
image: naeel/fission-console:v1.3.74
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 8090
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
<div class="nubes">NUBES</div>
|
||||
<div class="product">FISSION CONSOLE</div>
|
||||
</div>
|
||||
<div style="font-size:0.65rem; color:var(--text-secondary); margin-left:10px; align-self:center; opacity:0.7;">v1.3.73</div>
|
||||
<div style="font-size:0.65rem; color:var(--text-secondary); margin-left:10px; align-self:center; opacity:0.7;">v1.3.74</div>
|
||||
</div>
|
||||
<div class="row" style="margin:0;">
|
||||
<button class="btn ghost" onclick="reloadAll()">Refresh</button>
|
||||
@@ -509,7 +509,7 @@
|
||||
</div>
|
||||
|
||||
<div class="actions" style="justify-content:space-between; align-items:center;">
|
||||
<span style="font-size:0.75rem; color:var(--text-secondary);">v1.3.73</span>
|
||||
<span style="font-size:0.75rem; color:var(--text-secondary);">v1.3.74</span>
|
||||
<button class="btn ghost" onclick="closeHelp()">Закрыть</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -248,6 +248,12 @@ async function submitEdit() {
|
||||
var isTfFn = /^tf-/.test(name);
|
||||
if (!isTfFn) {
|
||||
var envVars = collectEnvVars('e');
|
||||
// Проверка на дубли ключей
|
||||
var keys = envVars.map(function(e) { return e.name; });
|
||||
var dupes = keys.filter(function(k, i) { return keys.indexOf(k) !== i; });
|
||||
if (dupes.length > 0) {
|
||||
throw new Error('Дублирующиеся ключи переменных: ' + dupes.join(', '));
|
||||
}
|
||||
await requestJSON(API_BASE + '/functions/' + encodeURIComponent(name) + '/envvars', 'PUT', {
|
||||
env_vars: envVars
|
||||
});
|
||||
@@ -311,6 +317,8 @@ function makeEnvVarRow(prefix, key, val, readOnly, idx) {
|
||||
kInput.disabled = readOnly;
|
||||
kInput.style.cssText = 'flex:1; font-size:12px; font-family:monospace;';
|
||||
kInput.dataset.envKey = '1';
|
||||
// Подсветка дублей при изменении ключа
|
||||
kInput.addEventListener('input', function() { highlightDupeKeys(prefix); });
|
||||
|
||||
var vInput = document.createElement('input');
|
||||
vInput.placeholder = 'value';
|
||||
@@ -340,6 +348,20 @@ function makeEnvVarRow(prefix, key, val, readOnly, idx) {
|
||||
return row;
|
||||
}
|
||||
|
||||
// highlightDupeKeys подсвечивает красным все поля KEY с одинаковыми именами
|
||||
function highlightDupeKeys(prefix) {
|
||||
var list = document.getElementById(prefix + '-envvars-list');
|
||||
if (!list) return;
|
||||
var inputs = list.querySelectorAll('[data-env-key]');
|
||||
var keys = Array.from(inputs).map(function(i) { return i.value.trim(); });
|
||||
inputs.forEach(function(inp) {
|
||||
var k = inp.value.trim();
|
||||
var isDupe = k !== '' && keys.filter(function(x) { return x === k; }).length > 1;
|
||||
inp.style.outline = isDupe ? '2px solid #f44' : '';
|
||||
inp.title = isDupe ? 'Дублирующийся ключ!' : '';
|
||||
});
|
||||
}
|
||||
|
||||
// addEnvVarRow добавляет пустую строку в список env vars
|
||||
function addEnvVarRow(prefix) {
|
||||
var list = document.getElementById(prefix + '-envvars-list');
|
||||
|
||||
Reference in New Issue
Block a user