Skip to content

Commit

Permalink
feat: Show bootloader config
Browse files Browse the repository at this point in the history
  • Loading branch information
Xtr126 committed Apr 23, 2023
1 parent 1393369 commit 64f4f46
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ tauri-build = { version = "1.2", features = [] }
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.2", features = ["dialog-open", "path-all", "shell-open"] }
tauri = { version = "1.2", features = ["dialog-open", "path-all", "process-exit", "shell-open"] }
compress-tools = "0.14.1"
fs_extra = "1.3.0"

Expand Down
5 changes: 4 additions & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"package": {
"productName": "android-x86-installer",
"version": "0.0.0"
"version": "0.1.0"
},
"tauri": {
"allowlist": {
Expand All @@ -25,6 +25,9 @@
"open": true,
"save": false
},
"process": {
"exit": true
},
"path": {
"all": true
}
Expand Down
61 changes: 59 additions & 2 deletions src/installer_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import '@material/web/button/outlined-button';
import '@material/web/button/text-button';
import '@material/web/dialog/dialog';
import '@material/web/circularprogress/circular-progress';
import '@material/web/elevation/elevation'
import { exit } from '@tauri-apps/api/process';

import androidLogo from './assets/android.svg'

Expand All @@ -19,13 +21,20 @@ export class InstallerApp extends LitElement {
dialogTitle_: {type: String},
dialogMsg_: {type: String},
progressPercent_: {type: Number},
bootloaderMsg_: {type: String},
};
}

constructor() {
super();
this.activeCategory_ = 'install';
this.progressPercent_ = 0;
this.bootloaderMsg_ =
` menuentry "Android" --class android-x86 {
savedefault
search --no-floppy --set=root --file /boot/grub/grub.cfg
configfile /boot/grub/grub.cfg
}`;
}

/** @override */
Expand Down Expand Up @@ -93,6 +102,32 @@ export class InstallerApp extends LitElement {
height: 80vh;
width: 60vh;
}
.codeblock-surface {
background-color: var( --md-sys-color-surface-container-high);
border-radius: 1em;
border-width: 1px;
margin-bottom: 1.5rem;
overflow: hidden;
width: 100%;
--md-elevation-level: 5;
}
.copy-button {
display: flex;
border-radius: 9999px;
background-color: rgb(34 34 34);
color: rgb(158 158 158);
position: absolute;
justify-content: center;
align-items: center;
width: 2.5rem;
height: 2.5rem;
outline: 2px solid transparent;
outline-offset: 2px;
top: 0;
right: 0;
}
`
}

Expand Down Expand Up @@ -143,13 +178,26 @@ export class InstallerApp extends LitElement {
</section>
<section class="installer-app-category" ?active-category="${this.activeCategory_ === 'bootloader'}">
<md-filled-button class="button-next" label="Done" @click="${this.onNextButtonClicked}"> </md-filled-button>
<div class="display-small" style="margin-left: 50px;">
<p> Open /etc/grub.d/40_custom or /boot/grub/grub.cfg in a text editor </p>
<p> Create a new grub entry with the following code: </p>
<div class="codeblock-surface">
<md-elevation></md-elevation>
<div style="position: relative" title="Copy">
<md-standard-icon-button class="copy-button" @click="${this.copyCode}"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="16" viewBox="-3 -4 30 30" role="presentation"><g fill="currentColor"><g><path d="M20 8h-9c-1.65 0-3 1.35-3 3v9c0 1.65 1.35 3 3 3h9c1.65 0 3-1.35 3-3v-9c0-1.65-1.35-3-3-3zm1 12c0 .55-.45 1-1 1h-9c-.55 0-1-.45-1-1v-9c0-.55.45-1 1-1h9c.55 0 1 .45 1 1v9z"></path><path d="M5 14H4c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1h9c.55 0 1 .45 1 1v1c0 .55.45 1 1 1s1-.45 1-1V4c0-1.65-1.35-3-3-3H4C2.35 1 1 2.35 1 4v9c0 1.65 1.35 3 3 3h1c.55 0 1-.45 1-1s-.45-1-1-1z"></path></g></g></svg></md-standard-icon-button>
</div>
<pre><code>${this.bootloaderMsg_}</code></pre>
</div>
<p> If it is desired to edit /etc/grub.d/40_custom then
re-generate grub config after saving file to apply changes </p>
</div>
<md-filled-button class="button-next" label="Done" @click="${this.onFinishButtonClicked}"> </md-filled-button>
</section>
<md-dialog id="dialog">
<span slot="header">${this.dialogTitle_}</span>
<div>
${this.dialogMsg_}
${this.dialogMsg_}
</div>
<md-text-button @click="${this.closeDialog}" label="OK" slot="footer"></md-text-button>
</md-dialog>
Expand Down Expand Up @@ -190,6 +238,10 @@ export class InstallerApp extends LitElement {
this.dialog.show();
}

async onFinishButtonClicked() {
await exit(1);
}

closeDialog() {
this.dialog.close();
}
Expand All @@ -198,6 +250,11 @@ export class InstallerApp extends LitElement {
this.progressPercent_ = progress;
this.circularProgress.progress = progress / 100;
}

async copyCode() {
await navigator.clipboard.writeText(this.bootloaderMsg_);
this.showDialog('Copied to clipboard', this.bootloaderMsg_);
}

firstUpdated() {
this.dialog = this.renderRoot.querySelector('#dialog');
Expand Down
11 changes: 10 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,16 @@ async function updateProgress() {
await listen('new-dir-size', (event) => {
installEl.updateProgress(event.payload)
});
if (installEl.progressPercent_ >= 100) break;
if (installEl.progressPercent_ >= 100) {
sidePanelEl.activateNextCategory();
installEl.bootloaderMsg_ =
` menuentry "${osTitleTextFieldEl.value}" --class android-x86 {
savedefault
search --no-floppy --set=root --file ${installDirTextFieldEl.value}/boot/grub/grub.cfg
configfile ${installDirTextFieldEl.value}/boot/grub/grub.cfg
}`;
break;
}
}
}

Expand Down

0 comments on commit 64f4f46

Please sign in to comment.