Skip to content

Commit eebb9ff

Browse files
committed
Bugfix: Solved PGSQL Migration Issue, Msg Edit Remove Btn Issue.
1 parent 63e4c2f commit eebb9ff

File tree

4 files changed

+46
-54
lines changed

4 files changed

+46
-54
lines changed

database/migrations/2025_04_04_123507_update_enum_type_on_usage_records_table.php

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,38 @@ class UpdateEnumTypeOnUsageRecordsTable extends Migration
88
{
99
public function up()
1010
{
11-
// This updates the 'type' column to include 'api'.
12-
DB::statement("
13-
ALTER TABLE `usage_records`
14-
MODIFY COLUMN `type` ENUM('private', 'group', 'api')
15-
");
11+
if(env('DB_CONNECTION') == 'pgsql') {
12+
// Check if the column uses a custom enum type or is just a varchar with a check constraint:
13+
// Query information_schema to get the column type
14+
$columnType = DB::table('information_schema.columns')
15+
->where('table_name', 'usage_records')
16+
->where('column_name', 'type')
17+
->value('udt_name');
18+
19+
if ($columnType === 'usage_type') {
20+
// If the column uses a custom enum type 'usage_type'
21+
DB::statement("ALTER TYPE usage_type ADD VALUE IF NOT EXISTS 'api';");
22+
} else {
23+
// Default Laravel enum - type is string/varchar with a check constraint
24+
// Drop the old check constraint (if any), then add the new one
25+
26+
// Constraint names can be different if the table was renamed, but by default it's "usage_records_type_check"
27+
// You might want to check your postgres schema if unsure
28+
DB::statement('ALTER TABLE usage_records DROP CONSTRAINT IF EXISTS usage_records_type_check;');
29+
DB::statement(
30+
"ALTER TABLE usage_records
31+
ADD CONSTRAINT usage_records_type_check
32+
CHECK (type IN ('private', 'group', 'api'));"
33+
);
34+
}
35+
}
36+
else{
37+
// This updates the 'type' column to include 'api'.
38+
DB::statement("
39+
ALTER TABLE `usage_records`
40+
MODIFY COLUMN `type` ENUM('private', 'group', 'api')
41+
");
42+
}
1643
}
1744

1845
public function down()
@@ -23,4 +50,4 @@ public function down()
2350
MODIFY COLUMN `type` ENUM('private', 'group')
2451
");
2552
}
26-
}
53+
}

public/js_v2.1.0/message_functions.js

Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ function addMessageToChatlog(messageObj, isFromServer = false){
6868
}
6969

7070
/// Set Author Name
71-
console.log(messageObj);
7271
if(messageObj.model && messageObj.message_role === 'assistant'){
73-
console.log(messageObj);
7472
model = modelsList.find(m => m.id === messageObj.model);
7573
messageElement.querySelector('.message-author').innerHTML =
7674
model ?
@@ -607,27 +605,6 @@ function editMessage(provider){
607605
});
608606

609607

610-
/// ATTACHMENTS
611-
if(wrapper.querySelectorAll('.attachment').length > 0){
612-
const atchs = wrapper.querySelectorAll('.attachment');
613-
atchs.forEach(atch => {
614-
atch.classList.add('edit-mode');
615-
const rmBtn = atch.querySelector('.remove-btn');
616-
rmBtn.style.display = 'flex';
617-
rmBtn.disabled = false;
618-
rmBtn.addEventListener('click', async ()=> {
619-
const confirm = await openModal(ModalType.WARNING, translation.Cnf_RemoveFile);
620-
if(!confirm){
621-
return;
622-
}
623-
const deleted = await requestAtchDelete(atch.dataset.fileId, 'conv');
624-
if(deleted){
625-
atch.remove();
626-
}
627-
});
628-
});
629-
}
630-
631608
content.setAttribute('contenteditable', true);
632609
content.dataset.tempContent = content.innerHTML;
633610
const rawMsg = content.closest('.message').dataset.rawMsg;
@@ -667,15 +644,15 @@ function abortEditMessage(provider){
667644
wrapper.classList.remove('edit-mode');
668645

669646

670-
if(wrapper.querySelectorAll('.attachment').length > 0){
671-
const atchs = wrapper.querySelectorAll('.attachment');
672-
atchs.forEach(atch => {
673-
atch.classList.remove('edit-mode');
674-
const rmBtn = atch.querySelector('.remove-btn');
675-
rmBtn.disabled = true;
676-
rmBtn.style.display = 'none';
677-
})
678-
};
647+
// if(wrapper.querySelectorAll('.attachment').length > 0){
648+
// const atchs = wrapper.querySelectorAll('.attachment');
649+
// atchs.forEach(atch => {
650+
// atch.classList.remove('edit-mode');
651+
// const rmBtn = atch.querySelector('.remove-btn');
652+
// rmBtn.disabled = true;
653+
// rmBtn.style.display = 'none';
654+
// })
655+
// };
679656

680657

681658
const content = wrapper.querySelector('.message-content');
@@ -700,18 +677,6 @@ async function confirmEditMessage(provider){
700677
const wrapper = provider.closest('.message-wrapper');
701678
wrapper.classList.remove('edit-mode');
702679

703-
704-
if(wrapper.querySelectorAll('.attachment').length > 0){
705-
const atchs = wrapper.querySelectorAll('.attachment');
706-
atchs.forEach(atch => {
707-
atch.classList.remove('edit-mode');
708-
const rmBtn = atch.querySelector('.remove-btn');
709-
rmBtn.disabled = true;
710-
rmBtn.style.display = 'none';
711-
})
712-
};
713-
714-
715680
const content = wrapper.querySelector('.message-content');
716681
content.setAttribute('contenteditable', false);
717682

resources/views/layouts/login.blade.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,12 @@
6161
</html>
6262

6363
<script>
64-
window.addEventListener('DOMContentLoaded', (event) => {
64+
window.addEventListener('DOMContentLoaded', () => {
6565
if(window.innerWidth < 480){
6666
const bgVideo = document.querySelector(".image_preview_container");
6767
bgVideo.remove();
6868
}
6969
70-
// console.log(@json($activeOverlay));
7170
setTimeout(() => {
7271
if(@json($activeOverlay)){
7372
// console.log('close overlay');
@@ -77,14 +76,14 @@
7776
});
7877
7978
function onLoginKeydown(event){
80-
if(event.key == "Enter"){
79+
if(event.key === "Enter"){
8180
const username = document.getElementById('account');
8281
// console.log(username.value);
8382
if(!username.value){
8483
return;
8584
}
8685
const password = document.getElementById('password');
87-
if(document.activeElement != password){
86+
if(document.activeElement !== password){
8887
password.focus();
8988
return;
9089
}

routes/web.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
Route::post('/req/login-ldap', [AuthenticationController::class, 'ldapLogin']);
2626
Route::post('/req/login-shibboleth', [AuthenticationController::class, 'shibbolethLogin']);
2727
Route::post('/req/login-oidc', [AuthenticationController::class, 'openIDLogin']);
28+
Route::get('/req/login-oidc', [AuthenticationController::class, 'openIDLogin']);
2829

2930

3031
Route::post('/req/changeLanguage', [LanguageController::class, 'changeLanguage']);

0 commit comments

Comments
 (0)