Final touches

This commit is contained in:
lights0123 2020-09-27 15:54:28 -04:00
parent 84d5e82d1a
commit 944e3a39c5
No known key found for this signature in database
GPG key ID: 28F315322E37972F
5 changed files with 41 additions and 28 deletions

View file

@ -3,7 +3,7 @@ on:
push: push:
branches-ignore: branches-ignore:
- 'dependabot/**' - 'dependabot/**'
- publish - release
pull_request: pull_request:
jobs: jobs:
@ -11,7 +11,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
platform: [macos-latest, ubuntu-18.04, windows-latest] platform: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.platform }} runs-on: ${{ matrix.platform }}
steps: steps:

View file

@ -9,7 +9,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
platform: [macos-latest, ubuntu-18.04, windows-latest] platform: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.platform }} runs-on: ${{ matrix.platform }}
steps: steps:

View file

@ -1,7 +1,7 @@
// #![cfg_attr( #![cfg_attr(
// all(not(debug_assertions), target_os = "windows"), all(not(debug_assertions), target_os = "windows"),
// windows_subsystem = "windows" windows_subsystem = "windows"
// )] )]
use hashbrown::HashMap; use hashbrown::HashMap;
use std::fs::File; use std::fs::File;
@ -88,22 +88,22 @@ impl Hotplug<GlobalContext> for DeviceMon {
} }
fn device_left(&mut self, device: rusb::Device<GlobalContext>) { fn device_left(&mut self, device: rusb::Device<GlobalContext>) {
// if let Some((dev, _)) = DEVICES if let Some((dev, _)) = DEVICES
// .write() .write()
// .unwrap() .unwrap()
// .remove_entry(&(device.bus_number(), device.address())) .remove_entry(&(device.bus_number(), device.address()))
// { {
// if let Err(msg) = tauri::event::emit( if let Err(msg) = tauri::event::emit(
// &mut self.handle, &mut self.handle,
// "removeDevice", "removeDevice",
// Some(DevId { Some(DevId {
// bus_number: dev.0, bus_number: dev.0,
// address: dev.1, address: dev.1,
// }), }),
// ) { ) {
// eprintln!("{}", msg); eprintln!("{}", msg);
// }; };
// } }
} }
} }

View file

@ -119,9 +119,10 @@ let queueId = 0;
class Devices extends Vue { class Devices extends Vue {
devices: Record<string, Device> = {}; devices: Record<string, Device> = {};
enumerating = false; enumerating = false;
hasEnumerated = false;
created() { created() {
this.enumerate().catch(console.error); this.enumerate().then(() => this.hasEnumerated = true, console.error);
listen('addDevice', dev => { listen('addDevice', dev => {
const payload = dev.payload as Device & DevId; const payload = dev.payload as Device & DevId;
const str = devToString(payload); const str = devToString(payload);

View file

@ -12,7 +12,7 @@
</p> </p>
</div> </div>
<div v-else-if="calculator && !calculator.info" class="flex items-center justify-center h-full"> <div v-else-if="calculator && !calculator.info" class="flex items-center justify-center h-full">
<div class="lds-dual-ring" /> <div class="lds-dual-ring"/>
</div> </div>
<div v-else-if="calculator && calculator.info"> <div v-else-if="calculator && calculator.info">
<calc-info :info="calculator.info" :dev="selectedCalculator"/> <calc-info :info="calculator.info" :dev="selectedCalculator"/>
@ -39,6 +39,10 @@ import CalcInfo from '@/components/CalcInfo.vue';
import FileBrowser from '@/components/FileBrowser.vue'; import FileBrowser from '@/components/FileBrowser.vue';
import DeviceSelect from "@/components/DeviceSelect.vue"; import DeviceSelect from "@/components/DeviceSelect.vue";
function sleep(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms));
}
@Component({ @Component({
components: { components: {
DeviceSelect, DeviceSelect,
@ -50,9 +54,17 @@ export default class Home extends Vue {
selectedCalculator: string | null = null; selectedCalculator: string | null = null;
showHidden = false; showHidden = false;
@Watch('$devices.hasEnumerated')
onEnumerated() {
const first = Object.keys(this.$devices.devices)[0];
if (first) this.selectedCalculator = first;
}
@Watch('$devices.devices') @Watch('$devices.devices')
onDeviceChange() { async onDeviceChange() {
if (!this.selectedCalculator) { if (!this.selectedCalculator) {
await sleep(1000);
if (this.selectedCalculator) return;
const first = Object.keys(this.$devices.devices)[0]; const first = Object.keys(this.$devices.devices)[0];
if (first) this.selectedCalculator = first; if (first) this.selectedCalculator = first;
} else if (!Object.keys(this.$devices.devices).includes(this.selectedCalculator)) { } else if (!Object.keys(this.$devices.devices).includes(this.selectedCalculator)) {
@ -67,7 +79,7 @@ export default class Home extends Vue {
if (dev && !this.$devices.devices[dev].info && !this.$devices.devices[dev].needsDrivers) { if (dev && !this.$devices.devices[dev].info && !this.$devices.devices[dev].needsDrivers) {
try { try {
await this.$devices.open(dev); await this.$devices.open(dev);
}catch(e) { } catch (e) {
console.error(e); console.error(e);
this.selectedCalculator = null; this.selectedCalculator = null;
} }
@ -83,7 +95,7 @@ export default class Home extends Vue {
} }
installDrivers() { installDrivers() {
open('https://zadig.akeo.ie/'); open('https://lights0123.com/n-link/#windows');
} }
} }
</script> </script>