Skip to content

Commit 0fa1871

Browse files
committed
Use modal instead of alert() if a python exception occurs
1 parent 4f1175b commit 0fa1871

File tree

7 files changed

+54
-29
lines changed

7 files changed

+54
-29
lines changed

httpGUI/index.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@
2121
<h3>New Installer Available</h3>
2222
<p>{{metaInfo.installerIsLatest[1]}}</p>
2323
<p>You should update the installer to get bug-fixes and new features.</p>
24-
<p>Please go to <strong><a href="https://github.com/07th-mod/python-patcher/releases" target="_blank">the download page</a></strong>, then download and install the new installer.
25-
<strong>Remember to close this old installer so it doesn't interfere!</strong></p>
26-
<p>If you wish to continue using the old installer, <a v-on:click="clearModal()">click here</a></p>
24+
<a href="https://github.com/07th-mod/python-patcher/releases" target="_blank"><button type="button" class="btn">Go to installer download page</button></a>
25+
<button type="button" class="btn" style="border: grey;" v-on:click="clearModal()">Use old installer (not recommended)</button>
2726
</modal>
2827
</div>
2928

httpGUI/installer.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@
1717
<!-- Only elements inside this <div id="app"> will be monitored by Vue.
1818
The "v-cloak" tells Vue to disable showing this element until it has finished loading. -->
1919
<div id="app" class="main-container" v-cloak>
20+
<div id="modal-container" >
21+
<modal v-bind:visible="installErrorDescription" v-on:close="installErrorDescription = ''">
22+
<h3>The install can't continue - please read</h3>
23+
<p>Please read the below error message, it might tell you how to fix this problem.<br>
24+
If you're not sure what to do, please send the error message and install log to the developers at their Discord server</p>
25+
<hr>
26+
<span style="white-space: pre-line; font-family: monospace;">{{installErrorDescription}}</span>
27+
<button type="button" class="btn" v-on:click="clearModal()">OK</button></a>
28+
<button type="button" class="btn" v-on:click="getLogsZip(selectedSubMod, selectedInstallPath)">Download Install Logs</button>
29+
<button type="button" class="btn">Visit 07th-mod Discord server (send install log here!)</button>
30+
</modal>
31+
</div>
2032
<div class="nav-container">
2133
<nav>
2234
<div class="nav-bar">

httpGUI/python-patcher-index.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,6 @@ let app = null;
1010
// - the subModHandles are retrieved from the python server to populate the app.subModList property
1111
window.onload = function onWindowLoaded() {
1212

13-
Vue.component('modal', {
14-
data() {
15-
return {
16-
};
17-
},
18-
props: ['visible'],
19-
template: `
20-
<div id="myModal" class="modal" v-if=visible>
21-
<div class="modal-content">
22-
<span class="close" v-on:click="$emit('close')">&times;</span>
23-
<slot></slot>
24-
</div>
25-
</div>`,
26-
});
27-
2813
// Forces all links which have been sanitized to open in new window (in this case, markdown links)
2914
// See https://github.com/cure53/DOMPurify/issues/317#issuecomment-698800327
3015
DOMPurify.addHook('afterSanitizeAttributes', (node) => {

httpGUI/python-patcher-lib.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ window.onload = function onWindowLoaded() {
181181
changelogURL: null,
182182
// Game installs which have been partially uninstalled via Steam, but where some mod files still exist on disk
183183
partiallyUninstalledPaths: [],
184+
installErrorDescription: "",
184185
},
185186
methods: {
186187
doInstall(deleteVersionInformation) {
@@ -354,6 +355,10 @@ Continue install anyway?`)) {
354355
autoscrollCheckbox: document.getElementById('autoscrollCheckbox'),
355356
};
356357

358+
setInstallerErrorCallback(function (errorMessage) {
359+
app.installErrorDescription = errorMessage;
360+
})
361+
357362
// populate the app.subModList with subMods from the python server
358363
doPost('subModHandles', [], (responseData) => {
359364
console.log(responseData);

httpGUI/python-patcher-rest-lib.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ function setPOSTNotificationErrorCallback(callback) {
1010
POSTNotificationErrorCallback = callback;
1111
}
1212

13+
let InstallerErrorCallback = function defaultInstallerErrorCallback(message) {
14+
alert(message);
15+
};
16+
17+
function setInstallerErrorCallback(callback) {
18+
InstallerErrorCallback = callback;
19+
}
20+
21+
1322
// Note: { requestType, requestData } = { requestType : requestType, requestData : requestData }
1423
function makeJSONRequest(requestType, requestData) {
1524
return JSON.stringify({ requestType, requestData });
@@ -51,7 +60,7 @@ function doPost(requestType, requestData, onSuccessCallback) {
5160
const [responseType, responseDataObject] = decodeJSONResponse(http.responseText);
5261
if (responseType === 'error') {
5362
console.log(`Error: ${responseDataObject.errorReason}`);
54-
alert(responseDataObject.errorReason);
63+
InstallerErrorCallback(responseDataObject.errorReason);
5564
} else if (responseType === 'unknownRequest' || responseType !== requestType) {
5665
console.log(`ERROR: sent ${requestType} but got ${responseType}. requestData: ${responseDataObject}`);
5766
} else {

httpGUI/python-patcher-vue-common.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,19 @@ Vue.component('snack-bar', {
8585
<div id="snackbar" v-show="toastVisible">{{ toastCount }}x {{ toastMessage }}</div>
8686
</transition>`,
8787
});
88+
89+
90+
Vue.component('modal', {
91+
data() {
92+
return {
93+
};
94+
},
95+
props: ['visible'],
96+
template: `
97+
<div id="myModal" class="modal" v-if=visible>
98+
<div class="modal-content">
99+
<span class="modal-close-button" v-on:click="$emit('close')">&times;</span>
100+
<slot></slot>
101+
</div>
102+
</div>`,
103+
});

httpGUI/style.css

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -257,25 +257,24 @@ The snackbar - position it at the bottom and in the middle of the screen */
257257
.modal-content {
258258
background-color: #fefefe;
259259
position: absolute;
260-
top: 50%;
261-
left: 50%; /* 'top:50%; left:50%;' set top left corner of the box to the middle of screen */
262-
transform: translate(-50%, -50%) !important; /* This offsets the box so it's midpoint is at center of screen, rather than the top left corner*/
260+
top: 30%;
261+
left: 10%;
263262
padding: 20px;
264263
border: 1px solid #888;
265-
width: 600px; /* Could be more or less, depending on screen size */
264+
width: 80%;
266265
}
267266

268267
/* The Close Button */
269-
.close {
270-
color: #aaa;
268+
.modal-close-button {
269+
color: #47b475;
271270
float: right;
272-
font-size: 28px;
271+
font-size: 50px;
273272
font-weight: bold;
274273
}
275274

276-
.close:hover,
277-
.close:focus {
278-
color: black;
275+
.modal-close-button:hover,
276+
.modal-close-button:focus {
277+
color: #e5c92c;
279278
text-decoration: none;
280279
cursor: pointer;
281280
}

0 commit comments

Comments
 (0)