Skip to content

Commit

Permalink
there should be only 1 instace of startmenu
Browse files Browse the repository at this point in the history
  • Loading branch information
chinonso098 committed Oct 7, 2024
1 parent f9a94f8 commit 8da0d5b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 25 deletions.
4 changes: 3 additions & 1 deletion src/app/system-apps/startmenu/startmenu.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ export class StartMenuComponent implements OnInit, AfterViewInit {
this._triggerProcessService = triggerProcessService;

this.processId = this._processIdService.getNewProcessId()
this._runningProcessService.addProcess(this.getComponentDetail());
if(this._runningProcessService.getProcesses().findIndex(x => x.getProcessName === this.name) === -1){
this._runningProcessService.addProcess(this.getComponentDetail());
}
}

ngOnInit(): void {
Expand Down
2 changes: 1 addition & 1 deletion src/app/system-apps/taskmanager/taskmanager.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class TaskmanagerComponent implements BaseComponent,OnInit,OnDestroy,Afte
SECONDS_DELAY = 250

processes:Process[] =[];
closingNotAllowed:string[] = ["system", "desktop", "filemanager", "taskbar", "startbutton", "clock", "taskbarentry"];
closingNotAllowed:string[] = ["system", "desktop", "filemanager", "taskbar", "startbutton", "clock", "taskbarentry", "startmenu"];
groupedData: any = {};
selectedRefreshRate = 0;

Expand Down
4 changes: 2 additions & 2 deletions src/app/system-apps/terminal/terminal.commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface OctalRepresentation {
permission: string;
}

export class TerminalCommands{
export class TerminalCommandProcessor{

private _triggerProcessService:TriggerProcessService;
private _runningProcessService:RunningProcessService;
Expand All @@ -26,7 +26,7 @@ export class TerminalCommands{
private _consts:Constants = new Constants();

private permissionChart!:Map<number, OctalRepresentation>;
private closingNotAllowed:string[] = ["system", "desktop", "filemanager", "taskbar", "startbutton","clock","taskbarentry"];
private closingNotAllowed:string[] = ["system", "desktop", "filemanager", "taskbar", "startbutton","clock","taskbarentry","startmenu"];
private files:FileInfo[] = [];
private readonly defaultDirectoryPath = this._consts.ROOT;
private currentDirectoryPath = this._consts.ROOT;
Expand Down
42 changes: 21 additions & 21 deletions src/app/system-apps/terminal/terminal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { BaseComponent } from 'src/app/system-base/base/base.component';
import { ComponentType } from 'src/app/system-files/component.types';
import { Process } from 'src/app/system-files/process';
import { TerminalCommand } from './model/terminal.command';
import { TerminalCommands } from './terminal.commands';
import { TerminalCommandProcessor } from './terminal.commands';
import { AppState, BaseState } from 'src/app/system-files/state/state.interface';
import { StateType } from 'src/app/system-files/state/state.type';
import { StateManagmentService } from 'src/app/shared/system-service/state.management.service';
Expand All @@ -32,7 +32,7 @@ export class TerminalComponent implements BaseComponent, OnInit, AfterViewInit,
private _maximizeWindowSub!: Subscription;
private _minimizeWindowSub!: Subscription;
private _formBuilder;
private _terminaCommandsImpl!:TerminalCommands;
private _terminaCommandsProc!:TerminalCommandProcessor;
private _stateManagmentService:StateManagmentService;
private _sessionManagmentService: SessionManagmentService;
private _appState!:AppState;
Expand Down Expand Up @@ -85,7 +85,7 @@ export class TerminalComponent implements BaseComponent, OnInit, AfterViewInit,
this._formBuilder = formBuilder;
this._stateManagmentService = stateManagmentService;
this._sessionManagmentService = sessionManagmentService;
this._terminaCommandsImpl = new TerminalCommands();
this._terminaCommandsProc = new TerminalCommandProcessor();

this.retrievePastSessionData();

Expand Down Expand Up @@ -554,79 +554,79 @@ export class TerminalComponent implements BaseComponent, OnInit, AfterViewInit,
}

if(rootCmd == "curl"){
const result = await this._terminaCommandsImpl.curl(cmdStringArr);
const result = await this._terminaCommandsProc.curl(cmdStringArr);
terminalCmd.setResponseCode = this.Success;
terminalCmd.setCommandOutput = result;
}

if(rootCmd == "close"){
const result = this._terminaCommandsImpl.close(cmdStringArr[1], cmdStringArr[2]);
const result = this._terminaCommandsProc.close(cmdStringArr[1], cmdStringArr[2]);
terminalCmd.setResponseCode = this.Success;
terminalCmd.setCommandOutput = result;
}

if(rootCmd == "date"){
const result = this._terminaCommandsImpl.date();
const result = this._terminaCommandsProc.date();
terminalCmd.setResponseCode = this.Success;
terminalCmd.setCommandOutput = result;
}

if(rootCmd == "download"){
this._terminaCommandsImpl.download(cmdStringArr[1], cmdStringArr[2]);
this._terminaCommandsProc.download(cmdStringArr[1], cmdStringArr[2]);
terminalCmd.setResponseCode = this.Success;
terminalCmd.setCommandOutput = 'downloading ..';
}

if(rootCmd == "exit"){
this._terminaCommandsImpl.exit(this.processId);
this._terminaCommandsProc.exit(this.processId);
}

if(rootCmd == "help"){
const result = this._terminaCommandsImpl.help(this.echoCommands, this.utilityCommands, cmdStringArr[1]);
const result = this._terminaCommandsProc.help(this.echoCommands, this.utilityCommands, cmdStringArr[1]);
terminalCmd.setResponseCode = this.Success;
terminalCmd.setCommandOutput = result;
}

if(rootCmd == "open"){
const result = this._terminaCommandsImpl.open(cmdStringArr[1], cmdStringArr[2]);
const result = this._terminaCommandsProc.open(cmdStringArr[1], cmdStringArr[2]);
terminalCmd.setResponseCode = this.Success;
terminalCmd.setCommandOutput = result;
}

if(rootCmd == "version"){
const result = this._terminaCommandsImpl.version(this.versionNum);
const result = this._terminaCommandsProc.version(this.versionNum);
terminalCmd.setResponseCode = this.Success;
terminalCmd.setCommandOutput = result;
}

if(rootCmd == "whoami"){
const result = this._terminaCommandsImpl.whoami();
const result = this._terminaCommandsProc.whoami();
terminalCmd.setResponseCode = this.Success;
terminalCmd.setCommandOutput = result;
}

if(rootCmd == "weather"){
const result = await this._terminaCommandsImpl.weather(cmdStringArr[1]);
const result = await this._terminaCommandsProc.weather(cmdStringArr[1]);
terminalCmd.setResponseCode = this.Success;
terminalCmd.setCommandOutput = result;
}

if(rootCmd == "list"){
const result = this._terminaCommandsImpl.list(cmdStringArr[1], cmdStringArr[2]);
const result = this._terminaCommandsProc.list(cmdStringArr[1], cmdStringArr[2]);
terminalCmd.setResponseCode = this.Success;
terminalCmd.setCommandOutput = result;
}

if(rootCmd == "pwd"){
const result = this._terminaCommandsImpl.pwd();
const result = this._terminaCommandsProc.pwd();
terminalCmd.setResponseCode = this.Success;
terminalCmd.setCommandOutput = result;
}

if(rootCmd == "cd"){
const str = 'string';
const strArr = 'string[]';
const result = await this._terminaCommandsImpl.cd(cmdStringArr[1], key);
const result = await this._terminaCommandsProc.cd(cmdStringArr[1], key);

if(result.type === str || result.type === strArr)
terminalCmd.setResponseCode = this.Success;
Expand All @@ -647,7 +647,7 @@ export class TerminalComponent implements BaseComponent, OnInit, AfterViewInit,
if(rootCmd == "ls"){
const str = 'string';
const strArr = 'string[]';
const result = await this._terminaCommandsImpl.ls(cmdStringArr[1]);
const result = await this._terminaCommandsProc.ls(cmdStringArr[1]);
terminalCmd.setResponseCode = this.Success;


Expand All @@ -664,21 +664,21 @@ export class TerminalComponent implements BaseComponent, OnInit, AfterViewInit,
}

if(rootCmd == "mkdir"){
const result = await this._terminaCommandsImpl.mkdir(cmdStringArr[1], cmdStringArr[2]);
const result = await this._terminaCommandsProc.mkdir(cmdStringArr[1], cmdStringArr[2]);
terminalCmd.setResponseCode = this.Success;
terminalCmd.setCommandOutput = result;
}

if(rootCmd == "rm"){
const result = await this._terminaCommandsImpl.rm(cmdStringArr[1], cmdStringArr[2]);
const result = await this._terminaCommandsProc.rm(cmdStringArr[1], cmdStringArr[2]);
terminalCmd.setResponseCode = this.Success;
terminalCmd.setCommandOutput = result;
}



if(rootCmd == "mv"){
const result = await this._terminaCommandsImpl.mv(cmdStringArr[1], cmdStringArr[2]);
const result = await this._terminaCommandsProc.mv(cmdStringArr[1], cmdStringArr[2]);
terminalCmd.setResponseCode = this.Success;
terminalCmd.setCommandOutput = result;
}
Expand All @@ -691,7 +691,7 @@ export class TerminalComponent implements BaseComponent, OnInit, AfterViewInit,
const source = cmdStringArr[2];
const destination = cmdStringArr[3];

const result = await this._terminaCommandsImpl.cp(option, source, destination);
const result = await this._terminaCommandsProc.cp(option, source, destination);

terminalCmd.setResponseCode = this.Success;
terminalCmd.setCommandOutput = result;
Expand Down

0 comments on commit 8da0d5b

Please sign in to comment.