Skip to content

Commit

Permalink
changed the way the tray menu works showing actual active sessions an…
Browse files Browse the repository at this point in the history
…d last used
  • Loading branch information
urz9999 committed Oct 5, 2020
1 parent e8cefdb commit 1398551
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 14 deletions.
8 changes: 6 additions & 2 deletions electron/dist/electron/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion electron/dist/electron/main.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,19 @@ const generateMainWindow = () => {
const initWorkspace = () => {

// Remove unused voices from contextual menu
Menu.setApplicationMenu(Menu.buildFromTemplate([
const template = [
{
label: 'Leapp',
submenu: [
{ label: 'About', role: 'about' },
{ label: 'Quit', role: 'quit' }
]
}
]));
];
if (!environment.production) {
template[0].submenu.push({ label: 'Open DevTool', role: 'toggledevtools' });
}
Menu.setApplicationMenu(Menu.buildFromTemplate(template));

if (process.platform === 'linux' && ['Pantheon', 'Unity:Unity7'].indexOf(process.env.XDG_CURRENT_DESKTOP) !== -1) {
process.env.XDG_CURRENT_DESKTOP = 'Unity';
Expand Down
1 change: 1 addition & 0 deletions src/app/services-system/configuration.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {Workspace} from '../models/workspace';
import {Configuration} from '../models/configuration';
import {_} from '../core/translation-marker';
import {Session} from '../models/session';
import {MenuService} from '../services/menu.service';


@Injectable({
Expand Down
12 changes: 6 additions & 6 deletions src/app/services/menu.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,24 @@ export class MenuService extends NativeService {
const version = this.appService.getApp().getVersion();

let voices = [];
this.sessionService.listSessions().slice(0, 5).forEach((session: Session) => {
const activeSessions = this.sessionService.listSessions().filter(s => s.active);
const allSessions = activeSessions.concat(this.sessionService.listSessions().filter(s => !s.active).slice(0, 5 - activeSessions.length));
allSessions.forEach((session: Session) => {
let icon = '';
let label = '';
switch (session.account.type) {
case AccountType.AWS_PLAIN_USER:
icon = session.active ? __dirname + `/assets/images/icon-online-aws.png` : __dirname + `/assets/images/icon-offline.png`;
icon = (session.active && !session.loading) ? __dirname + `/assets/images/icon-online-aws.png` : __dirname + `/assets/images/icon-offline.png`;
label = ' ' + session.account.accountName + ' - ' + (session.account as AwsPlainAccount).user;
break;
case AccountType.AWS:
case AccountType.AWS_TRUSTER:
icon = session.active ? __dirname + `/assets/images/icon-online-aws.png` : __dirname + `/assets/images/icon-offline.png`;
icon = (session.active && !session.loading) ? __dirname + `/assets/images/icon-online-aws.png` : __dirname + `/assets/images/icon-offline.png`;
label = ' ' + session.account.accountName + ' - ' + (session.account as AwsAccount).role.name;
break;

case AccountType.AZURE:
icon = session.active ? __dirname + `/assets/images/icon-online-azure.png` : __dirname + `/assets/images/icon-offline.png`;
icon = (session.active && !session.loading) ? __dirname + `/assets/images/icon-online-azure.png` : __dirname + `/assets/images/icon-offline.png`;
label = ' ' + session.account.accountName;
}
voices.push(
Expand All @@ -71,9 +73,7 @@ export class MenuService extends NativeService {
this.sessionService.stopSession(session);
}
this.appService.redrawList.emit(true);
// this.currentTray.destroy();
this.generateMenu();

} },
);
});
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/session.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class SessionService extends NativeService {
const workspace = this.configurationService.getDefaultWorkspaceSync();
if (workspace.sessions) {
workspace.sessions.sort((a, b) => {
return (a as Session).lastStopDate <= (b as Session).lastStopDate ? 1 : -1;
return (a as Session).lastStopDate < (b as Session).lastStopDate ? 1 : -1;
});
return workspace.sessions;
}
Expand Down
6 changes: 4 additions & 2 deletions src/app/session/session/session.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {AntiMemLeak} from '../../core/anti-mem-leak';
import {FileService} from '../../services-system/file.service';
import {CredentialsService} from '../../services/credentials.service';
import {SessionService} from '../../services/session.service';
import {MenuService} from '../../services/menu.service';

@Component({
selector: 'app-session',
Expand All @@ -25,7 +26,6 @@ export class SessionComponent extends AntiMemLeak implements OnInit, OnDestroy {

// Data for the select
modalAccounts = [];
modalRoles = [];
currentSelectedColor;
currentSelectedAccountNumber;

Expand All @@ -51,7 +51,8 @@ export class SessionComponent extends AntiMemLeak implements OnInit, OnDestroy {
private ssmService: SsmService,
private fileService: FileService,
private credentialsService: CredentialsService,
private sessionService: SessionService
private sessionService: SessionService,
private menuService: MenuService
) { super(); }

ngOnInit() {
Expand All @@ -77,6 +78,7 @@ export class SessionComponent extends AntiMemLeak implements OnInit, OnDestroy {

this.appService.redrawList.subscribe(r => {
this.getSessions();
this.menuService.generateMenu();
});
}

Expand Down

0 comments on commit 1398551

Please sign in to comment.