aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src-tauri/src/main.rs3
-rw-r--r--src-tauri/src/repair_and_verify/log_handling.rs27
-rw-r--r--src-tauri/src/repair_and_verify/mod.rs2
-rw-r--r--src-vue/src/views/DeveloperView.vue41
4 files changed, 72 insertions, 1 deletions
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 4eab7a00..06adf784 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -37,6 +37,8 @@ use tauri::Manager;
use tauri_plugin_store::PluginBuilder;
use tokio::time::sleep;
+use crate::repair_and_verify::log_handling::parse_given_log_text_for_installed_mods;
+
#[derive(Default)]
struct Counter(Arc<Mutex<i32>>);
@@ -110,6 +112,7 @@ fn main() {
delete_northstar_mod,
get_server_player_count,
delete_thunderstore_mod,
+ parse_given_log_text_for_installed_mods,
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
diff --git a/src-tauri/src/repair_and_verify/log_handling.rs b/src-tauri/src/repair_and_verify/log_handling.rs
new file mode 100644
index 00000000..3b87f632
--- /dev/null
+++ b/src-tauri/src/repair_and_verify/log_handling.rs
@@ -0,0 +1,27 @@
+use regex::Regex;
+
+/// Parse logs for installed mods
+#[tauri::command]
+pub async fn parse_given_log_text_for_installed_mods(
+ log_text: String,
+) -> Result<Vec<String>, String> {
+ // Regex to capture mod loading
+ let regex = Regex::new(r"(?m)Loaded mod (.*) successfully\n").unwrap();
+
+ // Run regex, result will be an iterator over tuples containing the start and end indices for each match in the string
+ let result = regex.captures_iter(&log_text);
+
+ let mut mods = Vec::new();
+ for mat in result {
+ // Get the captured string, which is the first and only capturing group in the regex
+ match mat.get(1) {
+ Some(mod_name) => {
+ mods.push(mod_name.as_str().to_string());
+ }
+ None => println!("Failed parsing {:?}", mat), // log on failure
+ };
+ }
+
+ // Return the captured mod names
+ return Ok(mods);
+}
diff --git a/src-tauri/src/repair_and_verify/mod.rs b/src-tauri/src/repair_and_verify/mod.rs
index 5d58dfaf..ed00ba16 100644
--- a/src-tauri/src/repair_and_verify/mod.rs
+++ b/src-tauri/src/repair_and_verify/mod.rs
@@ -1,3 +1,5 @@
+pub mod log_handling;
+
use crate::{
mod_management::{rebuild_enabled_mods_json, set_mod_enabled_status},
northstar::CORE_MODS,
diff --git a/src-vue/src/views/DeveloperView.vue b/src-vue/src/views/DeveloperView.vue
index 6770caaa..b3887ebd 100644
--- a/src-vue/src/views/DeveloperView.vue
+++ b/src-vue/src/views/DeveloperView.vue
@@ -51,6 +51,19 @@
<el-button type="primary" @click="clearFlightCorePersistentStore">
Delete FlightCore persistent store
</el-button>
+
+ <h3>Tech support</h3>
+
+ <el-button type="primary" @click="parseGivenLogTextForMods">
+ Parse logs
+ </el-button>
+ <el-input
+ v-model="log_content"
+ type="textarea"
+ :rows="5"
+ placeholder="Paste log content here"
+
+ />
</el-scrollbar>
</div>
</template>
@@ -63,11 +76,15 @@ import { GameInstall } from "../utils/GameInstall";
import { Store } from 'tauri-plugin-store-api';
const persistentStore = new Store('flight-core-settings.json');
+import { ref } from 'vue'
+const textarea = ref('')
+
export default defineComponent({
name: "DeveloperView",
data() {
return {
mod_to_install_field_string : "",
+ log_content : "",
}
},
methods: {
@@ -207,7 +224,29 @@ export default defineComponent({
await persistentStore.clear();
// ...and save
await persistentStore.save();
- }
+ },
+ async parseGivenLogTextForMods() {
+ let current_log_content = this.log_content;
+ await invoke("parse_given_log_text_for_installed_mods", { logText: current_log_content })
+ .then((message) => {
+ console.log(message); // TODO present better here
+ // Show user notification if task completed.
+ ElNotification({
+ title: `Done`,
+ message: `${message}`,
+ type: 'success',
+ position: 'bottom-right'
+ });
+ })
+ .catch((error) => {
+ ElNotification({
+ title: 'Error',
+ message: error,
+ type: 'error',
+ position: 'bottom-right'
+ });
+ });
+ },
}
});
</script>