Skip to content

Commit e2b9c69

Browse files
committed
feat: #1516 aggiunta correzione massiva problemi database
1 parent 2e892e9 commit e2b9c69

3 files changed

Lines changed: 528 additions & 87 deletions

File tree

assets/src/css/style.css

Lines changed: 160 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,75 @@ span.form-control {
649649
box-shadow: 0 0 5px rgba(0, 0, 0, 0.02) inset;
650650
}
651651

652+
/* Stili per il modal di controllo database */
653+
.btn-resolve-all {
654+
margin-bottom: 20px;
655+
}
656+
657+
.table-database {
658+
width: 100%;
659+
margin-bottom: 15px;
660+
}
661+
662+
.table-database thead {
663+
background-color: #f5f5f5 !important;
664+
}
665+
666+
.table-database thead th {
667+
background-color: #f5f5f5 !important;
668+
color: #333 !important;
669+
padding: 6px !important;
670+
border-bottom: 1px solid #ddd !important;
671+
}
672+
673+
.table-database th,
674+
.table-database td {
675+
padding: 6px !important;
676+
}
677+
678+
.table-database .column-name {
679+
width: 30%;
680+
font-weight: bold;
681+
vertical-align: middle;
682+
}
683+
684+
.table-database .column-conflict {
685+
width: 70%;
686+
font-family: monospace;
687+
white-space: collapse !important;
688+
}
689+
690+
/* Stile per il nome della tabella */
691+
.modules-aggiornamenti h3 {
692+
font-size: 1.1em;
693+
margin-top: 15px;
694+
margin-bottom: 5px;
695+
font-weight: 600;
696+
}
697+
698+
.table-title {
699+
margin-top: 20px;
700+
margin-bottom: 10px;
701+
font-size: 1.5em;
702+
}
703+
704+
.row-warning td {
705+
background-color: #fff3cd;
706+
}
707+
708+
.row-info td {
709+
background-color: #d1ecf1;
710+
}
711+
712+
.row-danger td {
713+
background-color: #f8d7da;
714+
}
715+
716+
.alert-database {
717+
margin-top: 15px;
718+
margin-bottom: 15px;
719+
}
720+
652721
.sidebar-form {
653722
border-radius: 3px;
654723
margin: 10px 10px;
@@ -1167,10 +1236,6 @@ table.dataTable {
11671236
border-collapse: collapse !important;
11681237
}
11691238

1170-
.alert-warning {
1171-
background-color: #EC971F;
1172-
}
1173-
11741239
.row-list .form-group {
11751240
margin-bottom: 0px;
11761241
}
@@ -1868,8 +1933,8 @@ body:not(.sidebar-collapse) .sidebar .nav-treeview .nav-treeview .nav-link {
18681933

18691934
@media screen and (min-width: 1920px) {
18701935
.large-modal .modal-dialog {
1871-
width: 80%;
1872-
max-width: 80%;
1936+
width: 70%;
1937+
max-width: 70%;
18731938
}
18741939
}
18751940

@@ -2035,3 +2100,92 @@ body:not(.sidebar-collapse) .sidebar .nav-treeview .nav-treeview .nav-link {
20352100
.tab-pane[id^="tab_"]:not(#tab_0) {
20362101
padding: 0 20px 20px 20px;
20372102
}
2103+
2104+
/* Stili per il modal di controllo database */
2105+
2106+
/* Stili per i pulsanti */
2107+
.btn-resolve-all {
2108+
margin-bottom: 0;
2109+
}
2110+
2111+
/* Stili per le tabelle */
2112+
.table-database {
2113+
width: 100%;
2114+
margin-bottom: 20px;
2115+
}
2116+
2117+
.table-database thead {
2118+
background-color: #343a40;
2119+
color: white;
2120+
}
2121+
2122+
.table-database th,
2123+
.table-database td {
2124+
padding: 10px;
2125+
}
2126+
2127+
.table-database .column-name {
2128+
width: 30%;
2129+
font-weight: bold;
2130+
vertical-align: middle;
2131+
}
2132+
2133+
.table-database .column-conflict {
2134+
width: 70%;
2135+
font-family: monospace;
2136+
white-space: pre-wrap;
2137+
}
2138+
2139+
/* Stili per i messaggi */
2140+
.table-title {
2141+
margin-top: 20px;
2142+
margin-bottom: 10px;
2143+
font-size: 1.5em;
2144+
}
2145+
2146+
/* Stili per le righe di avviso */
2147+
.row-warning td {
2148+
background-color: #ffffff; /* Sfondo bianco invece di giallo */
2149+
border-bottom: 1px solid #f0f0f0; /* Bordo sottile per separare le righe */
2150+
}
2151+
2152+
/* Mantieni lo sfondo giallo per le righe nella sezione problemi impostazioni */
2153+
.table-title + .table-database .row-warning td {
2154+
background-color: #fff3cd;
2155+
}
2156+
2157+
.row-info td {
2158+
background-color: #d1ecf1;
2159+
}
2160+
2161+
.row-danger td {
2162+
background-color: #f8d7da;
2163+
}
2164+
2165+
/* Stili per i messaggi di errore/successo */
2166+
.alert-database {
2167+
margin-top: 15px;
2168+
margin-bottom: 15px;
2169+
}
2170+
2171+
/* Stili per il controllo database */
2172+
.row.align-items-center {
2173+
margin-bottom: 15px;
2174+
}
2175+
2176+
.row.align-items-center p {
2177+
line-height: 1.5;
2178+
}
2179+
2180+
/* Stile per il nome della tabella */
2181+
.table-name {
2182+
font-size: 1.2em;
2183+
font-weight: 600;
2184+
color: #2c3e50;
2185+
background-color: #fff3cd; /* Sfondo giallo come .row-warning td */
2186+
padding: 8px 12px;
2187+
margin-top: 20px;
2188+
margin-bottom: 10px;
2189+
border-left: 4px solid #ffc107; /* Colore più intenso che si abbina al giallo */
2190+
border-radius: 0 4px 4px 0;
2191+
}

modules/aggiornamenti/actions.php

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,79 @@
3333
$id = post('id');
3434

3535
switch (filter('op')) {
36+
case 'risolvi-conflitti-database':
37+
$queries_json = post('queries');
38+
if (empty($queries_json)) {
39+
echo json_encode([
40+
'success' => false,
41+
'message' => tr('Nessuna query ricevuta.'),
42+
]);
43+
break;
44+
}
45+
46+
$queries = json_decode($queries_json, true);
47+
if (empty($queries)) {
48+
echo json_encode([
49+
'success' => false,
50+
'message' => tr('Nessuna query da eseguire.'),
51+
]);
52+
break;
53+
}
54+
55+
if (empty($queries)) {
56+
echo json_encode([
57+
'success' => false,
58+
'message' => tr('Nessuna query valida da eseguire.'),
59+
]);
60+
break;
61+
}
62+
63+
$debug_queries = implode('<br>', $queries);
64+
65+
$dbo->query('SET FOREIGN_KEY_CHECKS=0');
66+
67+
$errors = [];
68+
$executed = 0;
69+
70+
foreach ($queries as $query) {
71+
try {
72+
$dbo->query($query);
73+
$executed++;
74+
} catch (Exception $e) {
75+
$errors[] = $query . ' - ' . $e->getMessage();
76+
}
77+
}
78+
$dbo->query('SET FOREIGN_KEY_CHECKS=1');
79+
80+
if (empty($errors)) {
81+
$success_message = tr('Tutte le query sono state eseguite con successo (_NUM_ query).', [
82+
'_NUM_' => $executed,
83+
]);
84+
85+
flash()->info($success_message);
86+
87+
echo json_encode([
88+
'success' => true,
89+
'message' => $success_message . '<br><br>' . tr('Query eseguite:') . '<br>' . $debug_queries,
90+
'flash_message' => true,
91+
]);
92+
} else {
93+
$error_message = tr('Si sono verificati errori durante l\'esecuzione di alcune query (_NUM_ su _TOTAL_).', [
94+
'_NUM_' => count($errors),
95+
'_TOTAL_' => count($queries),
96+
]);
97+
98+
flash()->error($error_message);
99+
100+
echo json_encode([
101+
'success' => false,
102+
'message' => $error_message . '<br>' . implode('<br>', $errors) . '<br><br>' . tr('Query da eseguire:') . '<br>' . $debug_queries,
103+
'flash_message' => true,
104+
]);
105+
}
106+
107+
exit;
108+
36109
case 'check':
37110
$result = UpdateHook::isAvailable();
38111
$versione = false;

0 commit comments

Comments
 (0)