Skip to content

Commit

Permalink
chore: improve the UX of starting emu from URL and branch
Browse files Browse the repository at this point in the history
  • Loading branch information
grdddj committed Dec 3, 2024
1 parent f63e9fa commit 9c4fb95
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions src/dashboard/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,22 @@ const app = createApp({
T1B1: {
header: "Trezor One",
versions: [],
selected: "",
},
T2T1: {
header: "Trezor T",
versions: [],
selected: "",
},
T2B1: {
header: "Trezor Safe 3",
versions: [],
selected: "",
},
T3T1: {
header: "Trezor Safe 5",
versions: [],
selected: "",
},
T3W1: {
header: "T3W1",
versions: [],
selected: "",
},
},
wipeDevice: false,
Expand All @@ -50,11 +45,11 @@ const app = createApp({
},
emulatorUrl: {
url: "",
model: "T2T1",
model: "",
},
emulatorBranch: {
branch: "",
model: "T2T1",
model: "",
btcOnly: false,
},
emulatorDownloadMessage: "",
Expand Down Expand Up @@ -102,7 +97,19 @@ const app = createApp({
}
});
},
watch: {
'emulatorUrl.url': function (newUrl) {
this.updateModelFromUrl(newUrl);
}
},
methods: {
updateModelFromUrl(url) {
Object.keys(this.emulators.versions).forEach((model) => {
if (url.toLowerCase().includes(model.toLowerCase())) {
this.emulatorUrl.model = model;
}
});
},
setupWebSocket() {
this.ws = new WebSocket(websocketUrl);

Expand Down Expand Up @@ -273,13 +280,17 @@ const app = createApp({
});
},
emulatorStartFromUrl() {
let url = this.emulatorUrl.url;
const url = this.emulatorUrl.url;
if (!url) {
this.showNotification("URL is empty!", true);
return;
}

const model = this.emulatorUrl.model;
if (!model) {
this.showNotification("Model is empty!", true);
return;
}

this.sendMessage({
type: "emulator-start-from-url",
Expand All @@ -301,6 +312,10 @@ const app = createApp({
}

const model = this.emulatorBranch.model;
if (!model) {
this.showNotification("Model is empty!", true);
return;
}

this.sendMessage({
type: "emulator-start-from-branch",
Expand Down

0 comments on commit 9c4fb95

Please sign in to comment.