Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
feat: install snapd
Browse files Browse the repository at this point in the history
  • Loading branch information
MessiasLima committed May 4, 2021
1 parent eef1bfe commit 8447fce
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 21 deletions.
20 changes: 8 additions & 12 deletions src/app/service/setup/setup.service.ts
Expand Up @@ -6,24 +6,20 @@ export class SetupService {
constructor(private processService: ProcessService) {}

installSnapd(): Promise<string> {
return this.processService.executeCommand('pkexec apt install snapd');
return this.processService.executeCommand(
'pkexec apt-get install snapd -y',
);
}

installFlatpak(): Promise<string> {
return this.processService.executeCommand('pkexec apt install snapd');
return this.processService.executeCommand('pkexec apt install flatpak');
}

checkIfSnapdIsInstalled(): Promise<void> {
return this.processService.executeCommand('snap version').then(() => {
return;
});
checkIfSnapdIsInstalled(): Promise<string> {
return this.processService.executeCommand('snap version');
}

checkIfFlatpakIsInstalled(): Promise<void> {
return this.processService
.executeCommand('flatpak --version')
.then(() => {
return;
});
checkIfFlatpakIsInstalled(): Promise<string> {
return this.processService.executeCommand('flatpak --version');
}
}
Expand Up @@ -10,6 +10,7 @@
status="primary"
size="small"
*ngIf="status === 'not_installed'"
(click)="onInstallClicked()"
>
{{ installButtonText }}
</button>
Expand All @@ -19,6 +20,7 @@
status="danger"
size="small"
*ngIf="status === 'error'"
(click)="onInstallClicked()"
>
{{ tryAgainButtonText || 'GENERAL.TRY_AGAIN' | translate }}
</button>
Expand Down
Expand Up @@ -12,13 +12,8 @@ export class SetupItemCardComponent {
@Input() tryAgainButtonText?: string;
@Input() status = CardStatus.LOADING;
@Output() installClicked = new EventEmitter<void>();
@Output() tryAgainClicked = new EventEmitter<void>();

onInstallClicked(): void {
this.installClicked.emit();
}

onTryAgainClicked(): void {
this.tryAgainClicked.emit();
}
}
2 changes: 0 additions & 2 deletions src/app/ui/pages/initial-setup/initial-setup.component.html
Expand Up @@ -20,7 +20,6 @@ <h4 class="greetings">
'PAGES.INITIAL_SETUP.INSTALL_SNAPD' | translate
}}"
(installClicked)="installSnapd()"
(tryAgainClicked)="installSnapd()"
></app-setup-item-card>
<app-setup-item-card
[status]="flatpakStatus"
Expand All @@ -29,7 +28,6 @@ <h4 class="greetings">
'PAGES.INITIAL_SETUP.INSTALL_FLATPAK' | translate
}}"
(installClicked)="installFlatpak()"
(tryAgainClicked)="installFlatpak()"
></app-setup-item-card>
</nb-card-body>
<nb-card-footer>
Expand Down
22 changes: 20 additions & 2 deletions src/app/ui/pages/initial-setup/initial-setup.component.ts
Expand Up @@ -47,10 +47,28 @@ export class InitialSetupComponent implements OnInit {
}

installSnapd(): void {
this.setupService.installSnapd().then();
this.snapdStatus = CardStatus.INSTALLING;
this.setupService
.installSnapd()
.then((result) => {
console.log(result);
this.snapdStatus = CardStatus.INSTALLED;
})
.catch((err) => {
console.error(err);
this.snapdStatus = CardStatus.ERROR;
});
}

installFlatpak(): void {
this.setupService.installFlatpak().then();
this.flatpakStatus = CardStatus.INSTALLING;
this.setupService
.installFlatpak()
.then(() => {
this.flatpakStatus = CardStatus.INSTALLED;
})
.catch(() => {
this.flatpakStatus = CardStatus.ERROR;
});
}
}

0 comments on commit 8447fce

Please sign in to comment.