Skip to content

Commit

Permalink
taskmanager v0.9.7
Browse files Browse the repository at this point in the history
  • Loading branch information
chinonso098 committed Oct 30, 2023
1 parent df83177 commit bc8cbec
Showing 9 changed files with 154 additions and 17 deletions.
3 changes: 2 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ import { TitleComponent } from './user-apps/title/title.component';
import { GreetingComponent } from './user-apps/greeting/greeting.component';
import { FileexplorerComponent } from './system-apps/fileexplorer/fileexplorer.component';
import { TaskmanagerComponent } from './system-apps/taskmanager/taskmanager.component';
import { TaskmanagerMiniComponent } from './system-apps/taskmanager/taskmanager.mini.component';
import { SessionManagmentService } from './shared/system-service/session.management.service';
import { AppDirectory } from './system-files/app.directory';
import { JsdosComponent } from './user-apps/jsdos/jsdos.component';
@@ -56,7 +57,7 @@ export class AppComponent implements OnDestroy, AfterViewInit {
//appname
private apps: {type: Type<BaseComponent>}[] =[
{type: FileexplorerComponent},
{type: TaskmanagerComponent},
{type: TaskmanagerMiniComponent},
{type: TitleComponent},
{type: GreetingComponent},
{type: JsdosComponent}
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ import { HighlightDirective } from './system-apps/window/window.btn.highlight.di
import { FlieManagerHighlightDirective } from './shared/system-directive/file.mngr.highlight.directives';
import { GreetingComponent } from './user-apps/greeting/greeting.component';
import { TaskmanagerComponent } from './system-apps/taskmanager/taskmanager.component';
import { TaskmanagerMiniComponent } from './system-apps/taskmanager/taskmanager.mini.component';
import { JsdosComponent } from './user-apps/jsdos/jsdos.component';
import { SafeUrlPipe } from './shared/system-pipes/safe.resource.url.pipe';
import { TaskBarEntryHighlightDirective } from './shared/system-directive/taskbar.entry.highlight.directives';
@@ -43,6 +44,7 @@ import { WinampComponent } from './user-apps/winamp/winamp.component';
TaskBarEntryHighlightDirective,
GreetingComponent,
TaskmanagerComponent,
TaskmanagerMiniComponent,
JsdosComponent,
SafeUrlPipe,
WinampComponent
9 changes: 7 additions & 2 deletions src/app/system-apps/taskmanager/taskmanager.component.html
Original file line number Diff line number Diff line change
@@ -81,13 +81,18 @@
</thead>
<tbody>
<tr *ngFor='let process of processes'>
<td>
<td style="width: 65%;">
<figure>
<img [src]="process.getIcon">
<figcaption>{{ process.getProcessName}}</figcaption>
</figure>
</td>
<td>{{ process.getStatus}}</td>
<td>
<figure *ngIf = 'process.getProcessStatus === "Suspended"' >
<figcaption>{{ process.getProcessStatus}}</figcaption>
<img [src]="'osdrive/icons/econo.png'">
</figure>
</td>
<td [style]="setUtilColoumnColors(process.getCpuUsage)" #cpuId>{{ process.getCpuUsage}}%</td>
<td [style]="setUtilColoumnColors(process.getMemoryUsage)" #memoryId>{{ process.getMemoryUsage}} MB</td>
<td [style]="setUtilColoumnColors(process.getDiskUsage)" #diskId>{{ process.getDiskUsage}} MB/s</td>
60 changes: 48 additions & 12 deletions src/app/system-apps/taskmanager/taskmanager.component.ts
Original file line number Diff line number Diff line change
@@ -29,6 +29,9 @@ export class TaskmanagerComponent implements BaseComponent,OnInit,OnDestroy,Afte
column: '',
order: 'asc',
}
private SLEEP_NUMBER = 0;
private SLEEP_COUNTER = 0;
private SLEEP_PROCESS_NUM = 0;

processes:Process[] =[];

@@ -42,6 +45,7 @@ export class TaskmanagerComponent implements BaseComponent,OnInit,OnDestroy,Afte
thStyle1:Record<string,unknown> = {};
groupedData: any = {};


cpuUtil = 0;
memUtil = 0;
diskUtil = 0;
@@ -70,7 +74,7 @@ export class TaskmanagerComponent implements BaseComponent,OnInit,OnDestroy,Afte
ngAfterViewInit(): void {
//Initial delay 1 seconds and interval countdown also 2 second
this._taskmgrTimerSubscription = timer(1000, 2000).subscribe(() => {
this.generateNumber();
this.generateLies();
this.sortTable(this._sorting.column, false);

});
@@ -144,7 +148,7 @@ export class TaskmanagerComponent implements BaseComponent,OnInit,OnDestroy,Afte
}
if(this._currentSortingOrder == 'asc'){
this.processes = this.processes.sort((objA, objB) => {
return objA.getProcessName < objB.getProcessName ? -1 : 1
return objA.getProcessName < objB.getProcessName ? -1 : 1;
});
}else{
this.processes = this.processes.sort((objA, objB) => {
@@ -154,22 +158,54 @@ export class TaskmanagerComponent implements BaseComponent,OnInit,OnDestroy,Afte
}
}

generateNumber(){
generateLies(){
const processes:Process[] = this._runningProcessService.getProcesses();
const maxUtilNum = 100;
const minUtilNum = 0;
const maxNum = 10;
const minNum = 1;
const suspended = 'Suspended';

this.SLEEP_NUMBER == 0 ?
this.SLEEP_NUMBER = this.getRandomNums(minNum, (maxNum*maxNum)*2) : this.SLEEP_NUMBER;

this.SLEEP_PROCESS_NUM == 0 ? this.SLEEP_PROCESS_NUM =
processes[this.getRandomNums(minNum-1,processes.length-1)].getProcessId : this.SLEEP_PROCESS_NUM;

for(let i =0; i < processes.length; i++){
const tmpProcess = processes[i];
if(this.getRandomNums(1,10) > 5){
tmpProcess.setCpuUsage = this.addTrailingZeros(this.getRandomFloatingNums(0, 100));
const tmpProcess = processes[i];

if(tmpProcess.getProcessId == this.SLEEP_PROCESS_NUM){

if(this.SLEEP_COUNTER <= this.SLEEP_NUMBER){

tmpProcess.setProcessStatus = suspended;
tmpProcess.setCpuUsage = 0;
tmpProcess.setDiskUsage = 0;
tmpProcess.setMemoryUsage = 0;
tmpProcess.setNetworkUsage = 0

this.SLEEP_COUNTER++;
}else{
this.SLEEP_COUNTER = 0;
this.SLEEP_PROCESS_NUM = 0;
tmpProcess.setProcessStatus = '';
}
}else{
if(this.getRandomNums(minNum,maxNum) > 5){
tmpProcess.setCpuUsage = this.addTrailingZeros(this.getRandomFloatingNums(minUtilNum, maxUtilNum));
}
if(this.getRandomNums(1,10) <= 1){
tmpProcess.setDiskUsage = this.addTrailingZeros(this.getRandomFloatingNums(0, 100));
if(this.getRandomNums(minNum,maxNum) <= 1){
tmpProcess.setDiskUsage = this.addTrailingZeros(this.getRandomFloatingNums(minUtilNum, maxUtilNum));
}
if(this.getRandomNums(1,10) > 7){
tmpProcess.setMemoryUsage = this.addTrailingZeros(this.getRandomFloatingNums(0, 100));
if(this.getRandomNums(minNum,maxNum) > 7){
tmpProcess.setMemoryUsage = this.addTrailingZeros(this.getRandomFloatingNums(minUtilNum, maxUtilNum));
}
if(this.getRandomNums(1,10) <= 2){
tmpProcess.setNetworkUsage = this.addTrailingZeros(this.getRandomFloatingNums(0, 100));
if(this.getRandomNums(minNum,maxNum) <= 2){
tmpProcess.setNetworkUsage = this.addTrailingZeros(this.getRandomFloatingNums(minUtilNum, maxUtilNum));
}
}

}
this.processes = processes;
this.sumRowValues(processes);
34 changes: 34 additions & 0 deletions src/app/system-apps/taskmanager/taskmanager.mini.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<cos-window [runningProcessID]="this.processId" [processAppIcon]="this.icon" [processAppName]="this.name" (click)="setTaskMangrMiniWindowToFocus(this.processId)">
<div class='card'>
<div class='card-body'>
<div class='table-responsive'>
<table class='table' *ngIf = 'processes.length > 0' >
<tbody>
<tr *ngFor='let process of processes'>
<td style="width: 55%;">
<figure>
<img [src]="process.getIcon">
<figcaption>{{ process.getProcessName}}</figcaption>
</figure>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<span class="basediv">
<span style="display: inline-block; width: 50%;
padding-top:15px; height:50px; margin-left: 0;">
<figure style="padding-right: 45%;">
<img [src]="'osdrive/icons/arrow_down.png'">
<figcaption>More details</figcaption>
</figure>
</span>
<span style="display: inline-block; height:50px; margin-top:10px; width:50%; margin-right: 0;">
<button class="btn btn-primary" style="margin-left: 45%;" >
End task
</button>
</span>
</span>
</div>
</cos-window>
59 changes: 59 additions & 0 deletions src/app/system-apps/taskmanager/taskmanager.mini.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { Component, OnInit,OnDestroy} from '@angular/core';
import { Subscription } from 'rxjs';
import { ProcessIDService } from 'src/app/shared/system-service/process.id.service';
import { RunningProcessService } from 'src/app/shared/system-service/running.process.service';
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';

@Component({
selector: 'cos-taskmanager-mini',
templateUrl: './taskmanager.mini.component.html',
styleUrls: ['./taskmanager.component.css']
})
export class TaskmanagerMiniComponent implements BaseComponent,OnInit,OnDestroy {

private _processIdService:ProcessIDService;
private _runningProcessService:RunningProcessService;
private _processListChangeSub!: Subscription;

processes:Process[] =[];

hasWindow = true;
icon = 'osdrive/icons/taskmanger.png';
name = 'taskmanager';
processId = 0;
type = ComponentType.systemComponent
displayName = 'Task Manager';


constructor( processIdService:ProcessIDService,runningProcessService:RunningProcessService) {
this._processIdService = processIdService;
this._runningProcessService = runningProcessService;
this.processId = this._processIdService.getNewProcessId()
this._runningProcessService.addProcess(this.getComponentDetail());
this._processListChangeSub = this._runningProcessService.processListChangeNotify.subscribe(() =>{this.updateRunningProcess();})
}

ngOnInit(): void {
this.processes = this._runningProcessService.getProcesses();

}

ngOnDestroy(): void {
this._processListChangeSub?.unsubscribe();
}

setTaskMangrMiniWindowToFocus(pid: number):void {
this._runningProcessService.focusOnCurrentProcessNotify.next(pid);
}

updateRunningProcess():void{
this.processes = this._runningProcessService.getProcesses();
}

private getComponentDetail():Process{
return new Process(this.processId, this.name, this.icon, this.hasWindow, this.type)
}

}
2 changes: 1 addition & 1 deletion src/app/system-files/process.ts
Original file line number Diff line number Diff line change
@@ -68,7 +68,7 @@ export class Process{
return this._networkUsage;
}

public get getStatus(){
public get getProcessStatus(){
return this._status;
}

2 changes: 1 addition & 1 deletion src/osdrive.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"osdrive":{"desktop":{"fileexplorer.url":null,"heat.url":null,"hello.url":null,"taskmanager.url":null},"download":{"anothertest.txt":null},"games":{"D3D.url":null,"Diggers.url":null,"Doom.url":null,"data":{"3d_duke.jsdos":null,"Digger.jsdos":null,"Doom.jsdos":null,"Jill_of_the_Jungle.jsdos":null,"Machine_Nation.jsdos":null,"Shadow_knight.jsdos":null},"icons":{"d3d.png":null,"diggers.png":null,"doom.png":null}},"home":{},"icons":{"arrow_up.png":null,"audio.ico":null,"cmd.ico":null,"config.ico":null,"download_folder.ico":null,"empty_folder.ico":null,"empty_recycle.ico":null,"file.ico":null,"file_explorer.ico":null,"floppy.ico":null,"folder.ico":null,"generic-program.ico":null,"image.ico":null,"js-dos-logo.png":null,"movie_folder.ico":null,"music_folder.ico":null,"my_computer.ico":null,"non_empty_folder.ico":null,"non_empty_recycle.ico":null,"picture_folder.ico":null,"taskmanger.png":null,"taskmanger_2.png":null,"unknown.ico":null,"video.ico":null,"zip_folder.ico":null},"picture":{"favicon.ico":null,"favicon1.ico":null,"heat.png":null},"simple.txt":null}}
{"osdrive":{"desktop":{"fileexplorer.url":null,"heat.url":null,"hello.url":null,"taskmanager.url":null},"download":{"anothertest.txt":null},"games":{"D3D.url":null,"Diggers.url":null,"Doom.url":null,"data":{"3d_duke.jsdos":null,"Digger.jsdos":null,"Doom.jsdos":null,"Jill_of_the_Jungle.jsdos":null,"Machine_Nation.jsdos":null,"Shadow_knight.jsdos":null},"icons":{"d3d.png":null,"diggers.png":null,"doom.png":null}},"home":{},"icons":{"arrow_down.png":null,"arrow_up.png":null,"audio.ico":null,"cmd.ico":null,"config.ico":null,"download_folder.ico":null,"econo.png":null,"empty_folder.ico":null,"empty_recycle.ico":null,"file.ico":null,"file_explorer.ico":null,"floppy.ico":null,"folder.ico":null,"generic-program.ico":null,"image.ico":null,"js-dos-logo.png":null,"movie_folder.ico":null,"music_folder.ico":null,"my_computer.ico":null,"non_empty_folder.ico":null,"non_empty_recycle.ico":null,"picture_folder.ico":null,"taskmanger.png":null,"taskmanger_2.png":null,"unknown.ico":null,"video.ico":null,"zip_folder.ico":null},"picture":{"favicon.ico":null,"favicon1.ico":null,"heat.png":null},"simple.txt":null}}
Binary file added src/osdrive/icons/econo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bc8cbec

Please sign in to comment.