Skip to content

Commit cba6fa6

Browse files
feat: add credential eye toggle and fix check route error handling
Add show/hide password toggle (eye icon) on credential value inputs for both single and multi-custom entry modes. Extract check logic into _execute_check() with try/except wrapper to return proper JSON errors instead of unhandled 500 responses (fixes Trendyol JSON parse error). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b838254 commit cba6fa6

2 files changed

Lines changed: 84 additions & 18 deletions

File tree

schema-monitor/api/routes.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,43 @@ async def manual_check(request: Request, provider: str, endpoint: str) -> dict[s
707707
"auth_config": auth_config,
708708
}
709709

710-
# Fetch
710+
# Fetch — tüm işlem try/except içinde, beklenmeyen hatalar JSON olarak döner
711+
try:
712+
return await _execute_check(
713+
storage, file_store, provider, endpoint,
714+
endpoint_config, auth_handler,
715+
)
716+
except Exception as exc:
717+
logger.error(f"Check hatası ({provider}/{endpoint}): {exc}")
718+
return {
719+
"provider": provider,
720+
"endpoint": endpoint,
721+
"status": "error",
722+
"error": f"Sunucu hatası: {exc}",
723+
}
724+
725+
726+
async def _execute_check(
727+
storage: Any,
728+
file_store: Any,
729+
provider: str,
730+
endpoint: str,
731+
endpoint_config: dict[str, Any],
732+
auth_handler: Any | None,
733+
) -> dict[str, Any]:
734+
"""Schema check işlemini gerçekleştirir.
735+
736+
Args:
737+
storage: Storage backend
738+
file_store: Dosya tabanlı snapshot store
739+
provider: Provider adı
740+
endpoint: Endpoint adı
741+
endpoint_config: Endpoint yapılandırması
742+
auth_handler: Auth handler instance
743+
744+
Returns:
745+
Check sonucu dict'i
746+
"""
711747
result = await fetch_endpoint(endpoint_config, auth_handler)
712748

713749
if result.get("error"):

schema-monitor/templates/provider_detail.html

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,13 +1093,33 @@ <h2 class="text-lg font-semibold text-gray-900 dark:text-white" x-text="credenti
10931093
<label for="cred-value" class="block text-sm font-medium text-gray-700 dark:text-gray-300">
10941094
Value <span class="text-red-500">*</span>
10951095
</label>
1096-
<input
1097-
type="password"
1098-
id="cred-value"
1099-
x-model="credentialForm.value"
1100-
:placeholder="credentialValuePlaceholder"
1101-
class="mt-1 block w-full rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 px-3 py-2 text-sm text-gray-900 dark:text-white shadow-sm placeholder:text-gray-400 dark:placeholder:text-gray-500 focus:border-indigo-500 dark:focus:border-indigo-400 focus:ring-1 focus:ring-indigo-500 dark:focus:ring-indigo-400 focus:outline-none font-mono"
1102-
>
1096+
<div class="relative mt-1">
1097+
<input
1098+
:type="credentialForm.showValue ? 'text' : 'password'"
1099+
id="cred-value"
1100+
x-model="credentialForm.value"
1101+
:placeholder="credentialValuePlaceholder"
1102+
class="block w-full rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 px-3 py-2 pr-10 text-sm text-gray-900 dark:text-white shadow-sm placeholder:text-gray-400 dark:placeholder:text-gray-500 focus:border-indigo-500 dark:focus:border-indigo-400 focus:ring-1 focus:ring-indigo-500 dark:focus:ring-indigo-400 focus:outline-none font-mono"
1103+
>
1104+
<!-- Goz ikonu — degeri goster/gizle -->
1105+
<button
1106+
type="button"
1107+
@click="credentialForm.showValue = !credentialForm.showValue"
1108+
class="absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 transition-colors"
1109+
tabindex="-1"
1110+
>
1111+
<!-- Goz acik (deger gorunuyor) -->
1112+
<svg x-show="credentialForm.showValue" class="h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
1113+
<path d="M10 12.5a2.5 2.5 0 100-5 2.5 2.5 0 000 5z"/>
1114+
<path fill-rule="evenodd" d="M.664 10.59a1.651 1.651 0 010-1.186A10.004 10.004 0 0110 3c4.257 0 7.893 2.66 9.336 6.41.147.381.146.804 0 1.186A10.004 10.004 0 0110 17c-4.257 0-7.893-2.66-9.336-6.41zM14 10a4 4 0 11-8 0 4 4 0 018 0z" clip-rule="evenodd"/>
1115+
</svg>
1116+
<!-- Goz kapali (deger gizli) -->
1117+
<svg x-show="!credentialForm.showValue" class="h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
1118+
<path fill-rule="evenodd" d="M3.28 2.22a.75.75 0 00-1.06 1.06l14.5 14.5a.75.75 0 101.06-1.06l-1.745-1.745a10.029 10.029 0 003.3-4.38 1.651 1.651 0 000-1.185A10.004 10.004 0 009.999 3a9.956 9.956 0 00-4.744 1.194L3.28 2.22zM7.752 6.69l1.092 1.092a2.5 2.5 0 013.374 3.373l1.092 1.092a4 4 0 00-5.558-5.558z" clip-rule="evenodd"/>
1119+
<path d="M10.748 13.93l2.523 2.523a9.987 9.987 0 01-3.27.547c-4.258 0-7.894-2.66-9.337-6.41a1.651 1.651 0 010-1.186A10.007 10.007 0 012.839 6.02L6.07 9.252a4 4 0 004.678 4.678z"/>
1120+
</svg>
1121+
</button>
1122+
</div>
11031123
<p class="mt-1 text-xs text-gray-400 dark:text-gray-500">Deger sifrelenerek kaydedilir. Kaydedildikten sonra goruntulenebilir olmayacaktir.</p>
11041124
</div>
11051125

@@ -1114,12 +1134,19 @@ <h2 class="text-lg font-semibold text-gray-900 dark:text-white" x-text="credenti
11141134
placeholder="Key adi"
11151135
class="flex-1 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 px-3 py-2 text-sm text-gray-900 dark:text-white shadow-sm placeholder:text-gray-400 dark:placeholder:text-gray-500 focus:border-indigo-500 dark:focus:border-indigo-400 focus:ring-1 focus:ring-indigo-500 dark:focus:ring-indigo-400 focus:outline-none font-mono"
11161136
>
1117-
<input
1118-
type="password"
1119-
x-model="entry.value"
1120-
placeholder="Deger"
1121-
class="flex-1 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 px-3 py-2 text-sm text-gray-900 dark:text-white shadow-sm placeholder:text-gray-400 dark:placeholder:text-gray-500 focus:border-indigo-500 dark:focus:border-indigo-400 focus:ring-1 focus:ring-indigo-500 dark:focus:ring-indigo-400 focus:outline-none font-mono"
1122-
>
1137+
<div class="flex-1 relative">
1138+
<input
1139+
:type="entry.showValue ? 'text' : 'password'"
1140+
x-model="entry.value"
1141+
placeholder="Deger"
1142+
class="w-full rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 px-3 py-2 pr-9 text-sm text-gray-900 dark:text-white shadow-sm placeholder:text-gray-400 dark:placeholder:text-gray-500 focus:border-indigo-500 dark:focus:border-indigo-400 focus:ring-1 focus:ring-indigo-500 dark:focus:ring-indigo-400 focus:outline-none font-mono"
1143+
>
1144+
<button type="button" @click="entry.showValue = !entry.showValue"
1145+
class="absolute inset-y-0 right-0 flex items-center pr-2.5 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300" tabindex="-1">
1146+
<svg x-show="entry.showValue" class="h-3.5 w-3.5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path d="M10 12.5a2.5 2.5 0 100-5 2.5 2.5 0 000 5z"/><path fill-rule="evenodd" d="M.664 10.59a1.651 1.651 0 010-1.186A10.004 10.004 0 0110 3c4.257 0 7.893 2.66 9.336 6.41.147.381.146.804 0 1.186A10.004 10.004 0 0110 17c-4.257 0-7.893-2.66-9.336-6.41zM14 10a4 4 0 11-8 0 4 4 0 018 0z" clip-rule="evenodd"/></svg>
1147+
<svg x-show="!entry.showValue" class="h-3.5 w-3.5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M3.28 2.22a.75.75 0 00-1.06 1.06l14.5 14.5a.75.75 0 101.06-1.06l-1.745-1.745a10.029 10.029 0 003.3-4.38 1.651 1.651 0 000-1.185A10.004 10.004 0 009.999 3a9.956 9.956 0 00-4.744 1.194L3.28 2.22zM7.752 6.69l1.092 1.092a2.5 2.5 0 013.374 3.373l1.092 1.092a4 4 0 00-5.558-5.558z" clip-rule="evenodd"/><path d="M10.748 13.93l2.523 2.523a9.987 9.987 0 01-3.27.547c-4.258 0-7.894-2.66-9.337-6.41a1.651 1.651 0 010-1.186A10.007 10.007 0 012.839 6.02L6.07 9.252a4 4 0 004.678 4.678z"/></svg>
1148+
</button>
1149+
</div>
11231150
<button
11241151
type="button"
11251152
@click="credentialForm.customEntries.splice(idx, 1)"
@@ -1134,7 +1161,7 @@ <h2 class="text-lg font-semibold text-gray-900 dark:text-white" x-text="credenti
11341161
</template>
11351162
<button
11361163
type="button"
1137-
@click="credentialForm.customEntries.push({key: '', value: ''})"
1164+
@click="credentialForm.customEntries.push({key: '', value: '', showValue: false})"
11381165
class="inline-flex items-center gap-1.5 rounded-md border border-dashed border-gray-300 dark:border-gray-600 px-3 py-1.5 text-xs font-medium text-gray-600 dark:text-gray-400 hover:border-indigo-400 hover:text-indigo-600 dark:hover:text-indigo-400 transition-colors"
11391166
>
11401167
<svg class="h-3.5 w-3.5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
@@ -1237,8 +1264,9 @@ <h2 class="text-lg font-semibold text-gray-900 dark:text-white" x-text="credenti
12371264
custom_key: '',
12381265
header_name: '',
12391266
value: '',
1267+
showValue: false,
12401268
showMulti: false,
1241-
customEntries: [{key: '', value: ''}],
1269+
customEntries: [{key: '', value: '', showValue: false}],
12421270
isEdit: false,
12431271
editKeyName: ''
12441272
},
@@ -1577,8 +1605,9 @@ <h2 class="text-lg font-semibold text-gray-900 dark:text-white" x-text="credenti
15771605
custom_key: '',
15781606
header_name: '',
15791607
value: '',
1608+
showValue: false,
15801609
showMulti: false,
1581-
customEntries: [{key: '', value: ''}],
1610+
customEntries: [{key: '', value: '', showValue: false}],
15821611
isEdit: false,
15831612
editKeyName: ''
15841613
};
@@ -1597,8 +1626,9 @@ <h2 class="text-lg font-semibold text-gray-900 dark:text-white" x-text="credenti
15971626
custom_key: '',
15981627
header_name: '',
15991628
value: '',
1629+
showValue: false,
16001630
showMulti: false,
1601-
customEntries: [{key: '', value: ''}],
1631+
customEntries: [{key: '', value: '', showValue: false}],
16021632
isEdit: true,
16031633
editKeyName: keyName
16041634
};

0 commit comments

Comments
 (0)