Skip to content

Commit

Permalink
latest
Browse files Browse the repository at this point in the history
  • Loading branch information
roncodes committed Jul 15, 2024
1 parent 2555bdb commit bc9b3dd
Show file tree
Hide file tree
Showing 15 changed files with 2,699 additions and 1,913 deletions.
32 changes: 30 additions & 2 deletions addon/components/extension-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import { later } from '@ember/runloop';

export default class ExtensionCardComponent extends Component {
@service modalsManager;
Expand Down Expand Up @@ -29,14 +30,34 @@ export default class ExtensionCardComponent extends Component {
acceptButtonText: 'Install',
acceptButtonIcon: 'download',
declineButtonText: 'Done',
process: null,
step: null,
stepDescription: 'Awaiting install to begin...',
progress: 0,
extension: this.extension,
confirm: async (modal) => {
modal.startLoading();

// Listen for install progress
this.socket.listen(installChannel, ({ progress }) => {
modal.setOption('progress', progress);
this.socket.listen(installChannel, ({ process, step, progress }) => {
let stepDescription;
switch (step) {
case 'server.install':
stepDescription = '(1/3) Installing extension...';
break;

case 'engine.install':
stepDescription = '(2/3) Installing extension...';
break;

case 'console.build':
stepDescription = '(3/3) Completing install...';
break;

default:
break;
}
modal.setOptions({ process, step, progress, stepDescription });
});

// Start install progress
Expand All @@ -46,6 +67,13 @@ export default class ExtensionCardComponent extends Component {
try {
await this.extension.install();
this.notifications.info(`${this.extension.name} is now Installed.`);
later(
this,
() => {
window.location.reload(true);
},
1200
);
modal.done();
} catch (error) {
this.notifications.serverError(error);
Expand Down
2 changes: 1 addition & 1 deletion addon/components/modals/extension-details.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</div>
{{#if @options.progress}}
<div class="my-4">
<ProgressBar @title={{concat "Installing " this.extension.name}} @percent={{@options.progress}} />
<ProgressBar @title={{@options.stepDescription}} @percent={{@options.progress}} />
</div>
{{/if}}
{{#if this.extension.screenshots}}
Expand Down
2 changes: 1 addition & 1 deletion addon/components/modals/extension-uninstall.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</div>
{{#if @options.progress}}
<div class="my-4">
<ProgressBar @title={{concat "Uninstalling " this.extension.name}} @percent={{@options.progress}} />
<ProgressBar @title={{@options.stepDescription}} @percent={{@options.progress}} />
</div>
{{/if}}
</div>
Expand Down
34 changes: 31 additions & 3 deletions addon/controllers/installed.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import { later } from '@ember/runloop';

export default class InstalledController extends Controller {
@service modalsManager;
Expand Down Expand Up @@ -30,14 +31,34 @@ export default class InstalledController extends Controller {
acceptButtonText: 'Uninstall',
acceptButtonIcon: 'trash',
acceptButtonScheme: 'danger',
process: null,
step: null,
stepDescription: 'Awaiting uninstall to begin...',
progress: 0,
extension,
confirm: async (modal) => {
modal.startLoading();

// Listen for install progress
this.socket.listen(uninstallChannel, ({ progress }) => {
modal.setOption('progress', progress);
// Listen for uninstall progress
this.socket.listen(uninstallChannel, ({ process, step, progress }) => {
let stepDescription;
switch (step) {
case 'server.uninstall':
stepDescription = '(1/3) Uninstalling extension...';
break;

case 'engine.uninstall':
stepDescription = '(2/3) Uninstalling extension...';
break;

case 'console.build':
stepDescription = '(3/3) Completing uninstall...';
break;

default:
break;
}
modal.setOptions({ process, step, progress, stepDescription });
});

// Start uninstall progress
Expand All @@ -48,6 +69,13 @@ export default class InstalledController extends Controller {
await extension.uninstall();
await this.hostRouter.refresh();
this.notifications.info(`${extension.name} is now Uninstalled.`);
later(
this,
() => {
window.location.reload(true);
},
1200
);
modal.done();
} catch (error) {
this.notifications.serverError(error);
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
"@fleetbase/ember-ui": "^0.2.18",
"@babel/core": "^7.23.2",
"@fortawesome/ember-fontawesome": "^0.4.1",
"@fortawesome/fontawesome-svg-core": "^6.4.0",
"@fortawesome/free-solid-svg-icons": "^6.4.0",
"@fortawesome/fontawesome-svg-core": "^6.5.2",
"@fortawesome/free-solid-svg-icons": "^6.5.2",
"ember-cli-babel": "^8.2.0",
"ember-cli-htmlbars": "^6.3.0",
"ember-intl": "6.3.2",
Expand Down
Loading

0 comments on commit bc9b3dd

Please sign in to comment.