mirror of
https://github.com/yuzu-emu/liftinstall.git
synced 2024-11-22 10:45:36 +01:00
Merge 'master' onto 'vue-router'.
This commit is contained in:
parent
bada9d18c2
commit
0634e1a328
@ -41,8 +41,12 @@ pub fn file_from_string(file_path: &str) -> Option<(String, &'static [u8])> {
|
||||
"/fonts/roboto-v18-latin-regular.ttf",
|
||||
"/fonts/roboto-v18-latin-regular.woff",
|
||||
"/fonts/roboto-v18-latin-regular.woff2",
|
||||
"/js/vue.min.js",
|
||||
"/js/vue.js",
|
||||
"/js/vue-router.min.js",
|
||||
"/js/vue-router.js",
|
||||
"/js/helpers.js",
|
||||
"/js/vue.min.js"
|
||||
"/js/views.js"
|
||||
)?;
|
||||
|
||||
Some((string_mime, contents))
|
||||
|
@ -149,7 +149,7 @@ fn main() {
|
||||
let server = WebServer::with_addr(framework.clone(), address)
|
||||
.log_expect("Failed to bind to address");
|
||||
|
||||
debug!("Server: {:?}", address);
|
||||
info!("Server: {:?}", address);
|
||||
|
||||
http_address = Some(address);
|
||||
|
||||
|
@ -28,7 +28,9 @@
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<div class="column has-padding">
|
||||
<router-view></router-view>
|
||||
|
||||
<!--<div class="column has-padding">
|
||||
<div v-if="has_error">
|
||||
<h4 class="subtitle">An error occurred:</h4>
|
||||
|
||||
@ -71,7 +73,6 @@
|
||||
<div v-else-if="select_packages">
|
||||
<h4 class="subtitle">Select your preferred settings:</h4>
|
||||
|
||||
<!-- Build options -->
|
||||
<div class="tile is-ancestor">
|
||||
<div class="tile is-parent" v-for="package in config.packages" :index="package.name">
|
||||
<div class="tile is-child">
|
||||
@ -135,6 +136,7 @@
|
||||
<div>A error occurred during installation. Please retry!</div>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@ -153,9 +155,11 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/js/vue.js"></script>
|
||||
<script src="/js/vue-router.js"></script>
|
||||
<script src="/api/attrs"></script>
|
||||
<script src="/js/helpers.js"></script>
|
||||
<script src="/js/vue.min.js"></script>
|
||||
<script src="/js/views.js"></script>
|
||||
<script>
|
||||
// Overwrite loggers with the logging backend
|
||||
window.onerror = function(msg, url, line) {
|
||||
@ -192,7 +196,7 @@
|
||||
}
|
||||
|
||||
var app = new Vue({
|
||||
el: '#app',
|
||||
router,
|
||||
data: {
|
||||
attrs: base_attributes,
|
||||
config : {},
|
||||
@ -225,107 +229,6 @@
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
"download_config": function() {
|
||||
app.is_downloading_config = true;
|
||||
|
||||
ajax("/api/config", function(e) {
|
||||
app.download_install_status();
|
||||
app.config = e;
|
||||
});
|
||||
},
|
||||
"download_install_status": function() {
|
||||
ajax("/api/installation-status", function(e) {
|
||||
app.is_downloading_config = false;
|
||||
app.metadata = e;
|
||||
if (e.preexisting_install) {
|
||||
app.modify_install = true;
|
||||
app.select_packages = false;
|
||||
app.show_install_location = false;
|
||||
app.install_location = e.install_path;
|
||||
|
||||
// Copy over installed packages
|
||||
for (var x = 0; x < app.config.packages.length; x++) {
|
||||
app.config.packages[x].default = false;
|
||||
app.config.packages[x].installed = false;
|
||||
}
|
||||
|
||||
for (var i = 0; i < app.metadata.database.length; i++) {
|
||||
// Find this config package
|
||||
for (var x = 0; x < app.config.packages.length; x++) {
|
||||
if (app.config.packages[x].name === app.metadata.database[i].name) {
|
||||
app.config.packages[x].default = true;
|
||||
app.config.packages[x].installed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (e.is_launcher) {
|
||||
document.getElementById("window-title").innerText = app.attrs.name + " Updater";
|
||||
|
||||
app.is_launcher = true;
|
||||
app.install();
|
||||
}
|
||||
} else {
|
||||
for (var x = 0; x < app.config.packages.length; x++) {
|
||||
app.config.packages[x].installed = false;
|
||||
}
|
||||
|
||||
ajax("/api/default-path", function(e) {
|
||||
if (e.path != null) {
|
||||
app.install_location = e.path;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
"select_file": function() {
|
||||
window.external.invoke(JSON.stringify({
|
||||
SelectInstallDir: {
|
||||
callback_name: "selectFileCallback"
|
||||
}
|
||||
}));
|
||||
},
|
||||
"install": function() {
|
||||
this.is_installing = true;
|
||||
this.modify_install = false;
|
||||
this.select_packages = false;
|
||||
|
||||
var results = {};
|
||||
|
||||
for (var package_index = 0; package_index < this.config.packages.length; package_index++) {
|
||||
var current_package = this.config.packages[package_index];
|
||||
if (current_package.default != null) {
|
||||
results[current_package.name] = current_package.default;
|
||||
}
|
||||
}
|
||||
|
||||
results["path"] = this.install_location;
|
||||
|
||||
stream_ajax("/api/start-install", function(line) {
|
||||
if (line.hasOwnProperty("Status")) {
|
||||
app.progress_message = line.Status[0];
|
||||
app.progress = line.Status[1] * 100;
|
||||
}
|
||||
|
||||
if (line.hasOwnProperty("Error")) {
|
||||
app.is_installing = false;
|
||||
app.has_error = true;
|
||||
app.error = line.Error;
|
||||
|
||||
// Exit anyway - don't want to disturb the user
|
||||
if (app.is_launcher) {
|
||||
app.exit();
|
||||
}
|
||||
}
|
||||
}, function(e) {
|
||||
app.is_installing = false;
|
||||
if (app.is_launcher) {
|
||||
app.exit();
|
||||
} else {
|
||||
app.is_finished = true;
|
||||
}
|
||||
}, undefined, results);
|
||||
},
|
||||
"back_to_packages": function() {
|
||||
app.select_packages = true;
|
||||
app.has_error = false;
|
||||
@ -342,40 +245,11 @@
|
||||
app.select_packages = true;
|
||||
app.modify_install = false;
|
||||
},
|
||||
"uninstall": function() {
|
||||
app.is_installing = true;
|
||||
app.confirm_uninstall = false;
|
||||
app.modify_install = false;
|
||||
app.select_packages = false;
|
||||
|
||||
stream_ajax("/api/uninstall", function(line) {
|
||||
if (line.hasOwnProperty("Status")) {
|
||||
app.progress_message = line.Status[0];
|
||||
app.progress = line.Status[1] * 100;
|
||||
}
|
||||
|
||||
if (line.hasOwnProperty("Error")) {
|
||||
app.is_installing = false;
|
||||
app.has_error = true;
|
||||
app.error = line.Error;
|
||||
}
|
||||
}, function(e) {
|
||||
app.is_installing = false;
|
||||
app.is_finished = true;
|
||||
}, undefined, {});
|
||||
},
|
||||
"back_to_modify": function() {
|
||||
app.modify_install = true;
|
||||
app.select_packages = false;
|
||||
app.show_install_location = false;
|
||||
},
|
||||
"exit": function() {
|
||||
ajax("/api/exit", function() {});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
app.download_config();
|
||||
}).$mount("#app");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -39,9 +39,14 @@ function ajax(path, successCallback, failCallback, data) {
|
||||
var form = "";
|
||||
|
||||
for (var key in data) {
|
||||
if (!data.hasOwnProperty(key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (form !== "") {
|
||||
form += "&";
|
||||
}
|
||||
|
||||
form += encodeURIComponent(key) + "=" + encodeURIComponent(data[key]);
|
||||
}
|
||||
|
||||
@ -74,10 +79,11 @@ function stream_ajax(path, callback, successCallback, failCallback, data) {
|
||||
});
|
||||
|
||||
var buffer = "";
|
||||
var seenBytes = 0;
|
||||
|
||||
req.onreadystatechange = function() {
|
||||
if(req.readyState > 2) {
|
||||
buffer += req.responseText.substr(req.seenBytes);
|
||||
buffer += req.responseText.substr(seenBytes);
|
||||
|
||||
var pointer;
|
||||
while ((pointer = buffer.indexOf("\n")) >= 0) {
|
||||
@ -92,7 +98,7 @@ function stream_ajax(path, callback, successCallback, failCallback, data) {
|
||||
callback(contents);
|
||||
}
|
||||
|
||||
req.seenBytes = req.responseText.length;
|
||||
seenBytes = req.responseText.length;
|
||||
}
|
||||
};
|
||||
|
||||
@ -106,9 +112,14 @@ function stream_ajax(path, callback, successCallback, failCallback, data) {
|
||||
var form = "";
|
||||
|
||||
for (var key in data) {
|
||||
if (!data.hasOwnProperty(key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (form !== "") {
|
||||
form += "&";
|
||||
}
|
||||
|
||||
form += encodeURIComponent(key) + "=" + encodeURIComponent(data[key]);
|
||||
}
|
||||
|
||||
|
274
static/js/views.js
Normal file
274
static/js/views.js
Normal file
@ -0,0 +1,274 @@
|
||||
const DownloadConfig = {
|
||||
template: `
|
||||
<div class="column">
|
||||
<h4 class="subtitle">Downloading config...</h4>
|
||||
|
||||
<br />
|
||||
<progress class="progress is-info is-medium" value="0" max="100">
|
||||
0%
|
||||
</progress>
|
||||
</div>
|
||||
`,
|
||||
created: function() {
|
||||
this.download_install_status();
|
||||
},
|
||||
methods: {
|
||||
download_install_status: function() {
|
||||
ajax("/api/installation-status", (e) => {
|
||||
app.metadata = e;
|
||||
|
||||
this.download_config();
|
||||
});
|
||||
},
|
||||
download_config: function() {
|
||||
ajax("/api/config", (e) => {
|
||||
app.config = e;
|
||||
|
||||
this.choose_next_state();
|
||||
|
||||
}, (e) => {
|
||||
console.error("Got error while downloading config: "
|
||||
+ e);
|
||||
|
||||
if (app.is_launcher) {
|
||||
// Just launch the target application
|
||||
app.exit();
|
||||
} else {
|
||||
router.replace({name: 'showerr', params: {msg: "Got error while downloading config: "
|
||||
+ e}});
|
||||
}
|
||||
});
|
||||
},
|
||||
choose_next_state: function() {
|
||||
if (app.metadata.preexisting_install) {
|
||||
app.install_location = app.metadata.install_path;
|
||||
|
||||
// Copy over installed packages
|
||||
for (var x = 0; x < app.config.packages.length; x++) {
|
||||
app.config.packages[x].default = false;
|
||||
app.config.packages[x].installed = false;
|
||||
}
|
||||
|
||||
for (var i = 0; i < app.metadata.database.length; i++) {
|
||||
// Find this config package
|
||||
for (var x = 0; x < app.config.packages.length; x++) {
|
||||
if (app.config.packages[x].name === app.metadata.database[i].name) {
|
||||
app.config.packages[x].default = true;
|
||||
app.config.packages[x].installed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (app.metadata.is_launcher) {
|
||||
router.replace("/install/regular");
|
||||
} else {
|
||||
router.replace("/modify");
|
||||
}
|
||||
} else {
|
||||
for (var x = 0; x < app.config.packages.length; x++) {
|
||||
app.config.packages[x].installed = false;
|
||||
}
|
||||
|
||||
// Need to do a bit more digging to get at the
|
||||
// install location.
|
||||
ajax("/api/default-path", (e) => {
|
||||
if (e.path != null) {
|
||||
app.install_location = e.path;
|
||||
}
|
||||
});
|
||||
|
||||
router.replace("/packages");
|
||||
}
|
||||
|
||||
/*app.is_downloading_config = false;
|
||||
if (e.preexisting_install) {
|
||||
app.modify_install = true;
|
||||
app.select_packages = false;
|
||||
app.show_install_location = false;
|
||||
app.install_location = e.install_path;
|
||||
|
||||
|
||||
|
||||
if (e.is_launcher) {
|
||||
|
||||
app.is_launcher = true;
|
||||
app.install();
|
||||
}
|
||||
} else {
|
||||
}*/
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const SelectPackages = {
|
||||
template: `
|
||||
<div class="column">
|
||||
<h4 class="subtitle">Select your preferred settings:</h4>
|
||||
|
||||
<!-- Build options -->
|
||||
<div class="tile is-ancestor">
|
||||
<div class="tile is-parent" v-for="package in $root.$data.config.packages" :index="package.name">
|
||||
<div class="tile is-child">
|
||||
<div class="box">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" v-model="package.default" />
|
||||
{{ package.name }}
|
||||
<span v-if="package.installed"><i>(installed)</i></span>
|
||||
</label>
|
||||
<p>
|
||||
{{ package.description }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="subtitle is-6" v-if="!$root.$data.metadata.preexisting_install">Install Location</div>
|
||||
<div class="field has-addons" v-if="!$root.$data.metadata.preexisting_install">
|
||||
<div class="control is-expanded">
|
||||
<input class="input" type="text" v-model="$root.$data.install_location"
|
||||
placeholder="Enter a install path here">
|
||||
</div>
|
||||
<div class="control">
|
||||
<a class="button is-info" v-on:click="select_file">
|
||||
Select
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a class="button is-primary is-pulled-right" v-on:click="install">Install!</a>
|
||||
</div>
|
||||
`,
|
||||
methods: {
|
||||
select_file: function() {
|
||||
window.external.invoke(JSON.stringify({
|
||||
SelectInstallDir: {
|
||||
callback_name: "selectFileCallback"
|
||||
}
|
||||
}));
|
||||
},
|
||||
install: function() {
|
||||
router.push("/install/regular");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const InstallPackages = {
|
||||
template: `
|
||||
<div class="column">
|
||||
<h4 class="subtitle" v-if="$root.$data.metadata.is_launcher">Checking for updates...</h4>
|
||||
<h4 class="subtitle" v-else-if="is_uninstall">Uninstalling...</h4>
|
||||
<h4 class="subtitle" v-else>Installing...</h4>
|
||||
<div v-html="$root.$data.config.installing_message"></div>
|
||||
<br />
|
||||
|
||||
<div v-html="progress_message"></div>
|
||||
<progress class="progress is-info is-medium" v-bind:value="progress" max="100">
|
||||
{{ progress }}%
|
||||
</progress>
|
||||
</div>
|
||||
`,
|
||||
data: function() {
|
||||
return {
|
||||
progress: 0.0,
|
||||
progress_message: "Please wait...",
|
||||
is_uninstall: false,
|
||||
failed_with_error: false
|
||||
}
|
||||
},
|
||||
created: function() {
|
||||
this.is_uninstall = this.$route.params.kind === "uninstall";
|
||||
this.install();
|
||||
},
|
||||
methods: {
|
||||
install: function() {
|
||||
var results = {};
|
||||
|
||||
for (var package_index = 0; package_index < app.config.packages.length; package_index++) {
|
||||
var current_package = app.config.packages[package_index];
|
||||
if (current_package.default != null) {
|
||||
results[current_package.name] = current_package.default;
|
||||
}
|
||||
}
|
||||
|
||||
results["path"] = app.install_location;
|
||||
|
||||
stream_ajax(this.is_uninstall ? "/api/uninstall" :
|
||||
"/api/start-install", (line) => {
|
||||
if (line.hasOwnProperty("Status")) {
|
||||
this.progress_message = line.Status[0];
|
||||
this.progress = line.Status[1] * 100;
|
||||
}
|
||||
|
||||
if (line.hasOwnProperty("Error")) {
|
||||
if (app.metadata.is_launcher) {
|
||||
app.exit();
|
||||
} else {
|
||||
this.failed_with_error = true;
|
||||
router.replace({name: 'showerr', params: {msg: line.Error}});
|
||||
}
|
||||
}
|
||||
}, (e) => {
|
||||
if (app.metadata.is_launcher) {
|
||||
app.exit();
|
||||
} else if (!this.failed_with_error) {
|
||||
router.push("/complete");
|
||||
}
|
||||
}, undefined, results);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const ErrorView = {
|
||||
template: `
|
||||
<div class="column">
|
||||
<h4 class="subtitle">An error occurred:</h4>
|
||||
|
||||
<code>{{ msg }}</code>
|
||||
|
||||
<a class="button is-primary is-pulled-right" v-if="remaining" v-on:click="go_back">Back</a>
|
||||
</div>
|
||||
`,
|
||||
data: function() {
|
||||
return {
|
||||
msg: this.$route.params.msg,
|
||||
remaining: window.history.length > 1
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
go_back: function() {
|
||||
router.go(-1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const
|
||||
|
||||
const router = new VueRouter({
|
||||
routes: [
|
||||
{
|
||||
path: '/config',
|
||||
name: 'config',
|
||||
component: DownloadConfig
|
||||
},
|
||||
{
|
||||
path: '/packages',
|
||||
name: 'packages',
|
||||
component: SelectPackages
|
||||
},
|
||||
{
|
||||
path: '/install/:kind',
|
||||
name: 'install',
|
||||
component: InstallPackages
|
||||
},
|
||||
{
|
||||
path: '/showerr',
|
||||
name: 'showerr',
|
||||
component: ErrorView
|
||||
},
|
||||
{
|
||||
path: '/',
|
||||
redirect: '/config'
|
||||
}
|
||||
]
|
||||
});
|
2631
static/js/vue-router.js
Normal file
2631
static/js/vue-router.js
Normal file
File diff suppressed because it is too large
Load Diff
6
static/js/vue-router.min.js
vendored
Normal file
6
static/js/vue-router.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
10947
static/js/vue.js
Normal file
10947
static/js/vue.js
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user