From bc8cbec474699d57f2a859c6716ba670e07cdee1 Mon Sep 17 00:00:00 2001 From: chinons098 Date: Mon, 30 Oct 2023 01:11:09 -0400 Subject: [PATCH] taskmanager v0.9.7 --- src/app/app.component.ts | 3 +- src/app/app.module.ts | 2 + .../taskmanager/taskmanager.component.html | 9 ++- .../taskmanager/taskmanager.component.ts | 60 ++++++++++++++---- .../taskmanager.mini.component.html | 34 ++++++++++ .../taskmanager/taskmanager.mini.component.ts | 59 +++++++++++++++++ src/app/system-files/process.ts | 2 +- src/osdrive.json | 2 +- src/osdrive/icons/econo.png | Bin 0 -> 875 bytes 9 files changed, 154 insertions(+), 17 deletions(-) create mode 100644 src/app/system-apps/taskmanager/taskmanager.mini.component.html create mode 100644 src/app/system-apps/taskmanager/taskmanager.mini.component.ts create mode 100644 src/osdrive/icons/econo.png diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 54a49788..e569c9ee 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -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}[] =[ {type: FileexplorerComponent}, - {type: TaskmanagerComponent}, + {type: TaskmanagerMiniComponent}, {type: TitleComponent}, {type: GreetingComponent}, {type: JsdosComponent} diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 3bd3f965..e7880c5a 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -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 diff --git a/src/app/system-apps/taskmanager/taskmanager.component.html b/src/app/system-apps/taskmanager/taskmanager.component.html index 03c392e3..b645ada0 100644 --- a/src/app/system-apps/taskmanager/taskmanager.component.html +++ b/src/app/system-apps/taskmanager/taskmanager.component.html @@ -81,13 +81,18 @@ - +
{{ process.getProcessName}}
- {{ process.getStatus}} + +
+
{{ process.getProcessStatus}}
+ +
+ {{ process.getCpuUsage}}% {{ process.getMemoryUsage}} MB {{ process.getDiskUsage}} MB/s diff --git a/src/app/system-apps/taskmanager/taskmanager.component.ts b/src/app/system-apps/taskmanager/taskmanager.component.ts index 453674a8..03468954 100644 --- a/src/app/system-apps/taskmanager/taskmanager.component.ts +++ b/src/app/system-apps/taskmanager/taskmanager.component.ts @@ -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 = {}; 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); diff --git a/src/app/system-apps/taskmanager/taskmanager.mini.component.html b/src/app/system-apps/taskmanager/taskmanager.mini.component.html new file mode 100644 index 00000000..d452c0f4 --- /dev/null +++ b/src/app/system-apps/taskmanager/taskmanager.mini.component.html @@ -0,0 +1,34 @@ + +
+
+
+ + + + + + +
+
+ +
{{ process.getProcessName}}
+
+
+
+
+ + +
+ +
More details
+
+
+ + + +
+
+
\ No newline at end of file diff --git a/src/app/system-apps/taskmanager/taskmanager.mini.component.ts b/src/app/system-apps/taskmanager/taskmanager.mini.component.ts new file mode 100644 index 00000000..0acbff27 --- /dev/null +++ b/src/app/system-apps/taskmanager/taskmanager.mini.component.ts @@ -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) + } + +} diff --git a/src/app/system-files/process.ts b/src/app/system-files/process.ts index bd0b68bc..246f9ad4 100644 --- a/src/app/system-files/process.ts +++ b/src/app/system-files/process.ts @@ -68,7 +68,7 @@ export class Process{ return this._networkUsage; } - public get getStatus(){ + public get getProcessStatus(){ return this._status; } diff --git a/src/osdrive.json b/src/osdrive.json index 8eac3d90..5fe540ac 100644 --- a/src/osdrive.json +++ b/src/osdrive.json @@ -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}} diff --git a/src/osdrive/icons/econo.png b/src/osdrive/icons/econo.png new file mode 100644 index 0000000000000000000000000000000000000000..15e386ebd0353b7173508f11cbcdf81afab06969 GIT binary patch literal 875 zcmV-x1C;!UP)^12P%+{hG_n8h38G*mB1BLS6I6^RQ4ozcK|~M_;z5WJb5Oy3jZ}AK2yr^ylWnk| z58d_pzxS8=zl8X&S2jJlc;rpn#!JHIl7U69C>e8pNzkeod-Wp;&X1`G#m+9DobbIO z{1S-3<}nc=J*-p&KNQ1H={oBr;c7+r$rr)kjw-owVTEG&?0fIQ-kd1L4T|8K{%(<- z8WnOYi_83w2RZi!?n}lkis848j$~LjqT~tJS*#d)40&r zD#lxZH~3VG>Ax*K*r*7)B|}5rdSU#oYeEvP9TLA{IBYzBD?FV0&pyFE6Y8@e{~t8< z@LDwPm{bsXBAY4?JkVjZEAnA<_cH`_p%EmwXGESWNPuFvW{h7B!$`(X-?)dB;f_=< z>T6n-hfCwJyXiTK@RwrzDjJ+=p&|+2XaPD}gPD^AXUxoKkHxPDYl7Uvl~7QodYmHs zqdki}YJ@X1PN!6ORZ}AcNX8aZd^KSh-DFH|Uql)V3bwO=oz0;lJ$sEg zo}IA-Fzn8C(WoT}o1-F7O7?c+(aksl{D~O|co=`yGqij z^t&QFqz6