Skip to content

Commit

Permalink
filemanager v0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
chinonso098 committed Nov 20, 2023
1 parent 9a066a6 commit 40c2be5
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 33 deletions.
1 change: 0 additions & 1 deletion src/app/shared/system-service/file.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export class FileService{
this._fileInfo.setOpensWith = sc.getOpensWith;
}
else{

const fileMetaData = await this.getExtraFileMetaDataAsync(path) as FileMetaData;

if(extension == '.url'){
Expand Down
17 changes: 8 additions & 9 deletions src/app/system-apps/filemanager/filemanager.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<ol (dragover)="onDragOver($event)" (drop)="onDrop($event)" (click)="hideIconContextMenu()" #myBounds>
<li *ngFor="let file of files; let i = index">
<!-- -->
<button fileMngrHighlight (dblclick)="runProcess(file)"
ngDraggable [bounds]="myBounds" [inBounds]="true" [gridSize]="gridSize" zIndex="1" [preventDefaultEvent]="true"
(stopped)="onDragEnd($event)" (started)="onDragStart($event)"
Expand All @@ -19,29 +18,29 @@
<div class="icon-vertical-menu" [style]="iconCntxtMenuStyle">

<div class="icon-vertical-menu-item">
<span class="span head"> <figure class="figure-cntx-menu"> </figure></span>
<span class="span head"> <figure class="figure-cntxt-menu"> </figure></span>
<span class="span mid">Open</span>
<span class="span tail"> <figure class="figure-cntx-menu"> </figure> </span>
<span class="span tail"> <figure class="figure-cntxt-menu"> </figure> </span>
</div>

<div class="icon-vertical-menu-item">
<span class="span head"> <figure class="figure-cntx-menu"> </figure></span>
<span class="span head"> <figure class="figure-cntxt-menu"> </figure></span>
<span class="span mid">Pin to Start</span>
<span class="span tail"> <figure class="figure-cntx-menu"> </figure> </span>
<span class="span tail"> <figure class="figure-cntxt-menu"> </figure> </span>
</div>

<div class="icon-vertical-menu-item" >
<span class="span head"> <figure class="figure-cntx-menu"> </figure></span>
<span class="span head"> <figure class="figure-cntxt-menu"> </figure></span>
<span class="span mid">Pin to taskbar</span>
<span class="span tail"> <figure class="figure-cntx-menu"> </figure> </span>
<span class="span tail"> <figure class="figure-cntxt-menu"> </figure> </span>
</div>

<div class="line-container"><div class="line"></div></div>

<div class="icon-vertical-menu-item">
<span class="span head"> <figure class="figure-cntx-menu" > </figure></span>
<span class="span head"> <figure class="figure-cntxt-menu" > </figure></span>
<span class="span mid">Delete</span>
<span class="span tail"> <figure class="figure-cntx-menu"> </figure> </span>
<span class="span tail"> <figure class="figure-cntxt-menu"> </figure> </span>
</div>
</div>
</ol>
78 changes: 55 additions & 23 deletions src/app/system-apps/filemanager/filemanager.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AfterViewInit, Component, Input, OnInit, OnDestroy, EventEmitter, Output, ViewChild, ElementRef, Renderer2 } from '@angular/core';
import { AfterViewInit, Component, Input, OnInit, OnDestroy, EventEmitter, Output, ViewChild, ElementRef} from '@angular/core';
import { FileService } from 'src/app/shared/system-service/file.service';
import { ProcessIDService } from 'src/app/shared/system-service/process.id.service';
import { RunningProcessService } from 'src/app/shared/system-service/running.process.service';
Expand All @@ -8,6 +8,7 @@ import { FileEntry } from 'src/app/system-files/fileentry';
import { FileInfo } from 'src/app/system-files/fileinfo';
import { Subscription } from 'rxjs';
import { TriggerProcessService } from 'src/app/shared/system-service/trigger.process.service';
import { FileManagerService } from 'src/app/shared/system-service/file.manager.services';

@Component({
selector: 'cos-filemanager',
Expand All @@ -16,19 +17,21 @@ import { TriggerProcessService } from 'src/app/shared/system-service/trigger.pro
})
export class FilemanagerComponent implements OnInit, AfterViewInit, OnDestroy {
@ViewChild('myBounds', {static: true}) myBounds!: ElementRef;


@Input() folderPath = '';
@Output() updateExplorerIconAndName = new EventEmitter<FileInfo>();

private _processIdService:ProcessIDService;
private _runningProcessService:RunningProcessService;
private _fileService:FileService
private _directoryFilesEntires!:FileEntry[];
private _dirFilesUpdatedSub!: Subscription;
private _triggerProcessService:TriggerProcessService;

private _renderer:Renderer2;
private _viewByNotifySub!:Subscription;
private _sortByNotifySub!:Subscription;
private _refreshNotifySub!:Subscription;
private _autoArrangeIconsNotifySub!:Subscription;
private _autoAlignIconsNotifyBySub!:Subscription;
private _dirFilesUpdatedSub!: Subscription;

iconCntxtMenuStyle:Record<string, unknown> = {};

Expand All @@ -42,20 +45,25 @@ export class FilemanagerComponent implements OnInit, AfterViewInit, OnDestroy {
files:FileInfo[] = [];

gridSize = 90;
autoAlign = true;
autoArrange = false;
private autoAlign = true;
private autoArrange = false;


constructor( processIdService:ProcessIDService, runningProcessService:RunningProcessService, fileInfoService:FileService, triggerProcessService:TriggerProcessService,renderer: Renderer2) {
constructor( processIdService:ProcessIDService, runningProcessService:RunningProcessService, fileInfoService:FileService, triggerProcessService:TriggerProcessService, fileManagerService:FileManagerService) {
this._processIdService = processIdService;
this._runningProcessService = runningProcessService;
this._fileService = fileInfoService;
this._triggerProcessService = triggerProcessService;
this._renderer = renderer;

this.processId = this._processIdService.getNewProcessId();
this._runningProcessService.addProcess(this.getComponentDetail());
this._dirFilesUpdatedSub = this._fileService.dirFilesUpdateNotify.subscribe(() =>{this.loadFilesInfoAsync();})

this._dirFilesUpdatedSub = this._fileService.dirFilesUpdateNotify.subscribe(() =>{this.loadFilesInfoAsync()});
this._viewByNotifySub = fileManagerService.viewByNotify.subscribe((p) =>{this.changeIconsSize(p)});
this._sortByNotifySub = fileManagerService.sortByNotify.subscribe((p)=>{this.sortIcons(p)});
this._autoArrangeIconsNotifySub = fileManagerService.autoArrangeIconsNotify.subscribe((p) =>{this.toggleAutoArrangeIcons(p)});
this._autoAlignIconsNotifyBySub = fileManagerService.alignIconsToGridNotify.subscribe((p) => {this.toggleAutoAlignIconsToGrid(p)});
this._refreshNotifySub = fileManagerService.refreshNotify.subscribe(()=>{this.refreshIcons()});
}

ngOnInit():void{
Expand All @@ -69,18 +77,14 @@ export class FilemanagerComponent implements OnInit, AfterViewInit, OnDestroy {

async ngAfterViewInit():Promise<void>{
await this.loadFilesInfoAsync();

setTimeout(()=> {
const filePaths = this.files;
if(filePaths != null || filePaths != undefined){
for(const filePath of filePaths){
URL.revokeObjectURL(filePath.getIcon);
}
}
}, 5000);
}

ngOnDestroy(): void {
this._viewByNotifySub?.unsubscribe();
this._sortByNotifySub?.unsubscribe();
this._refreshNotifySub?.unsubscribe();
this._autoArrangeIconsNotifySub?.unsubscribe();
this._autoAlignIconsNotifyBySub?.unsubscribe();
this._dirFilesUpdatedSub?.unsubscribe();
}

Expand Down Expand Up @@ -189,21 +193,49 @@ export class FilemanagerComponent implements OnInit, AfterViewInit, OnDestroy {


sortIcons(sortBy:string): void {
if(sortBy == "Size"){
if(sortBy === "Size"){
this.files = this.files.sort((objA, objB) => objB.getSize - objA.getSize);
}else if(sortBy == "Date Modified"){
}else if(sortBy === "Date Modified"){
this.files = this.files.sort((objA, objB) => objB.getDateModified.getTime() - objA.getDateModified.getTime());
}else if(sortBy == "Name"){
}else if(sortBy === "Name"){
this.files = this.files.sort((objA, objB) => {
return objA.getFileName < objB.getFileName ? -1 : 1;
});
}else if(sortBy == "Type"){
}else if(sortBy === "Item Type"){
this.files = this.files.sort((objA, objB) => {
return objA.getFileType < objB.getFileType ? -1 : 1;
});
}
}

changeIconsSize(iconSize:string):void{
//
}

toggleAutoAlignIconsToGrid(alignIcon:boolean):void{
this.autoAlign = alignIcon;
if(!this.autoAlign){
this.gridSize = 0;
}else{
this.gridSize = 90;
}
}

toggleAutoArrangeIcons(arrangeIcon:boolean):void{

this.autoArrange = arrangeIcon;

if(this.autoArrange){
// clear (x,y) position of icons in memory
this.refreshIcons();
}

}

refreshIcons():void{
1
}


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

0 comments on commit 40c2be5

Please sign in to comment.