Skip to content

Commit b42c32a

Browse files
fix: switch_version terminal blank — use this.jobModal via settingsSwitchVersion() instead of bare jobModal assignment
1 parent 357ede0 commit b42c32a

2 files changed

Lines changed: 33 additions & 28 deletions

File tree

web/static/js/app.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,6 +2110,38 @@ function modulesPage() {
21102110
toast(r.ok?'PHP version updated':'Failed: '+(r.error||''), r.ok?'success':'error');
21112111
},
21122112

2113+
async settingsSwitchVersion() {
2114+
const sm = this.settingsModal;
2115+
if (!sm.switchVer) { toast('Select a version first','error'); return; }
2116+
const modName = sm.mod?.name || sm.mod?.id;
2117+
const label = `Switching ${modName} to v${sm.switchVer}`;
2118+
const r = await post(`/api/modules/${sm.mod.id}/settings`, {
2119+
action: 'switch_version', version: sm.switchVer,
2120+
});
2121+
if (!r.ok) { toast(r.error || 'Failed to start switch', 'error'); return; }
2122+
sm.show = false;
2123+
this.jobModal = {show:true, title:label, lines:[], done:false, success:false, action:'switch_version', installedVer:''};
2124+
const es = new EventSource(`/api/modules/job/${r.job_id}`);
2125+
es.onmessage = (e) => {
2126+
const d = JSON.parse(e.data);
2127+
if (d.line) this.jobModal.lines.push(d.line);
2128+
if (d.done) {
2129+
es.close();
2130+
this.jobModal.done = true;
2131+
this.jobModal.success = d.success;
2132+
this.jobModal.installedVer = d.installedVer || sm.switchVer;
2133+
if (d.success) sm.version = d.installedVer || sm.switchVer;
2134+
setTimeout(() => this.load(), 1200);
2135+
}
2136+
if (d.error) { es.close(); toast(d.error, 'error'); }
2137+
this.$nextTick(() => {
2138+
const t = document.querySelector('.job-terminal');
2139+
if (t) t.scrollTop = t.scrollHeight;
2140+
});
2141+
};
2142+
es.onerror = () => es.close();
2143+
},
2144+
21132145
settingsTabs(modId) {
21142146
const tabs = {
21152147
nginx: ['service','config','optimization','switch_version','logs'],

web/templates/index.html

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2678,34 +2678,7 @@
26782678
<option :value="v.value" x-text="v.label"></option>
26792679
</template>
26802680
</select>
2681-
<button class="btn btn-primary btn-sm"
2682-
@click="async () => {
2683-
if (!settingsModal.switchVer) { toast('Select a version first', 'error'); return; }
2684-
const modName = settingsModal.mod?.name || settingsModal.mod?.id;
2685-
const label = 'Switching ' + modName + ' to v' + settingsModal.switchVer;
2686-
const r = await post('/api/modules/'+settingsModal.mod.id+'/settings', {action:'switch_version', version:settingsModal.switchVer});
2687-
if (r.ok && r.job_id) {
2688-
settingsModal.show = false;
2689-
jobModal = {show:true, title:label, lines:[], done:false, success:false, action:'switch_version', installedVer:''};
2690-
const es = new EventSource('/api/modules/job/'+r.job_id);
2691-
es.onmessage = (e) => {
2692-
const d = JSON.parse(e.data);
2693-
if (d.line) jobModal.lines.push(d.line);
2694-
if (d.done) {
2695-
es.close();
2696-
jobModal.done = true;
2697-
jobModal.success = d.success;
2698-
jobModal.installedVer = d.installedVer || settingsModal.switchVer;
2699-
if (d.success) {
2700-
settingsModal.version = d.installedVer || settingsModal.switchVer;
2701-
}
2702-
}
2703-
$nextTick(() => { const t = document.querySelector('.job-terminal'); if (t) t.scrollTop = t.scrollHeight; });
2704-
};
2705-
} else {
2706-
toast(r.error || 'Failed to start switch', 'error');
2707-
}
2708-
}">Switch</button>
2681+
<button class="btn btn-primary btn-sm" @click="settingsSwitchVersion()">Switch</button>
27092682
</div>
27102683
<div style="font-size:11px;color:var(--text-muted);line-height:1.7">
27112684
⚠ Switching version will stop and restart the service. A live progress terminal will show the output.<br>

0 commit comments

Comments
 (0)