Skip to content

Commit

Permalink
filemanager v6.0.26
Browse files Browse the repository at this point in the history
  • Loading branch information
chinonso098 committed Nov 23, 2023
1 parent 921cbc2 commit dca7aef
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 55 deletions.
16 changes: 0 additions & 16 deletions src/app/shared/system-service/file.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,19 +297,6 @@ export class FileService{
await this.initBrowserFsAsync();

new Promise((resolve, reject) =>{

// const basePath = basename(path)
// const fileExt = extname(path)
// const dir = dirname(path);

// console.log('basePath:',basePath);
// console.log('fileExt:',fileExt);
// console.log('dir:',dir);

// console.log('current path:', path);
// console.log('file rename:', `${dir}/${newFileName}${fileExt}`);


this._fileSystem.readFile(path,(err, contents = Buffer.from('')) =>{
if(err){
console.log('getFile in renameFileAsync error:',err)
Expand All @@ -333,9 +320,6 @@ export class FileService{
resolve(console.log('successfully fetched'));
}
});
}).then(()=>{
//Send update notification
this.dirFilesUpdateNotify.next();
});
}

Expand Down
8 changes: 4 additions & 4 deletions src/app/system-apps/desktop/desktop.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ export class DesktopComponent implements OnInit, OnDestroy, AfterViewInit{
this._vantaEffect = VANTA.WAVES({
el: '#vanta',
color:this.defaultColor, //this._numSequence,
// waveHeight:20,
// shininess: 50,
// waveSpeed:0.5,
// zoom:0.75,
waveHeight:20,
shininess: 50,
waveSpeed:0.5,
zoom:0.75,
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/system-apps/filemanager/filemanager.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<button (dblclick)="runProcess(file)" (mouseenter)="onMouseEnter(i)" (mouseleave)="onMouseLeave(i)"
ngDraggable [bounds]="myBounds" [inBounds]="true" [gridSize]="gridSize" zIndex="1" [preventDefaultEvent]="true"
(stopped)="onDragEnd($event)" (started)="onDragStart($event)"
(contextmenu)="onShowIconContextMenu($event, file, i)"
(contextmenu)="onShowIconContextMenu($event, file, i)" (click)="onBtnClick()"
id="iconBtn{{i}}" [style]="btnStyle">
<figure>
<img [src]="file.getIconPath | safeResourceUrl" [alt]="file.getFileName" [style]="iconSizeStyle"/>
Expand Down
76 changes: 42 additions & 34 deletions src/app/system-apps/filemanager/filemanager.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class FilemanagerComponent implements OnInit, AfterViewInit, OnDestroy {
directory ='/osdrive/desktop';
files:FileInfo[] = [];

gridSize = 90;
gridSize = 90; //column size of grid = 90px
private autoAlign = true;
private autoArrange = false;
private showDesktopIcon = true;
Expand All @@ -59,7 +59,7 @@ export class FilemanagerComponent implements OnInit, AfterViewInit, OnDestroy {
isIconHighlightActive = false;
private selectedFile!:FileInfo;
renameForm!: FormGroup;
elementId = -1;
selectedElementId = -1;

hideCntxtMenuEvtCnt = 0; // this is a dirty solution
renameFileTriggerCnt = 0; // this is a dirty solution
Expand All @@ -85,7 +85,6 @@ export class FilemanagerComponent implements OnInit, AfterViewInit, OnDestroy {
}

ngOnInit():void{

this.renameForm = this._formBuilder.nonNullable.group({
renameInput: '',
});
Expand Down Expand Up @@ -159,15 +158,20 @@ export class FilemanagerComponent implements OnInit, AfterViewInit, OnDestroy {
}
}

onBtnClick():void{
this.isIconHighlightActive = false;
}

onTriggerRunProcess():void{
this.runProcess(this.selectedFile);
}


onShowIconContextMenu(evt:MouseEvent, file:FileInfo, id:number):void{
this.elementId = id;
this.selectedElementId = id;
this._runningProcessService.responseToEventCount++;
this.selectedFile = file;
this.isIconHighlightActive = false;

this.iconCntxtMenuStyle = {
'width': '205px',
Expand All @@ -185,7 +189,7 @@ export class FilemanagerComponent implements OnInit, AfterViewInit, OnDestroy {
'height': '0px',
'transform': 'translate(-100000px, 100000px)',
'z-index': -1,
'opacity':0
'opacity':0,
}

this.hideCntxtMenuEvtCnt++;
Expand Down Expand Up @@ -234,12 +238,12 @@ export class FilemanagerComponent implements OnInit, AfterViewInit, OnDestroy {

onMouseLeave(id:number):void{
const btnElement = document.getElementById(`iconBtn${id}`) as HTMLElement;
if(id != this.elementId){
if(id != this.selectedElementId){
if(btnElement){
btnElement.style.backgroundColor = 'transparent';
btnElement.style.border = 'none'
}
}else if((id == this.elementId) && this.isIconHighlightActive){
}else if((id == this.selectedElementId) && this.isIconHighlightActive){
this.iconWasInfocus();
}
}
Expand Down Expand Up @@ -316,8 +320,9 @@ export class FilemanagerComponent implements OnInit, AfterViewInit, OnDestroy {

}

refreshIcons():void{
1
async refreshIcons():Promise<void>{
this.isIconHighlightActive = false;
await this.loadFilesInfoAsync();
}

onDeleteFile():void{
Expand Down Expand Up @@ -345,7 +350,7 @@ export class FilemanagerComponent implements OnInit, AfterViewInit, OnDestroy {
// get the position of the textbox
const toolTipID = 'invalidChars';
const invalidCharToolTipElement = document.getElementById(toolTipID) as HTMLElement;
const renameContainerElement= document.getElementById(`renameContainer${this.elementId}`) as HTMLElement;
const renameContainerElement= document.getElementById(`renameContainer${this.selectedElementId}`) as HTMLElement;

const rect = renameContainerElement.getBoundingClientRect();

Expand All @@ -365,21 +370,15 @@ export class FilemanagerComponent implements OnInit, AfterViewInit, OnDestroy {
invalidCharToolTipElement.style.transform =`translate(${-100000}px, ${100000}px)`;
invalidCharToolTipElement.style.zIndex = '-1';
invalidCharToolTipElement.style.opacity = '0';
invalidCharToolTipElement.style.transition = 'opacity 1s ease 1';
invalidCharToolTipElement.style.transition = 'opacity 0.5s ease 1';
}
}

isFormDirty(): void {
// form is not dirty and not submitted

// console.log('this.isFormSubmitted :',this.isFormSubmitted);
// console.log('this.renameForm.dirty :',this.renameForm.dirty );
// console.log('this.renameForm.valid :',this.renameForm.valid );

if (this.renameForm.dirty == true){
this.onTriggerRenameFileStep2();
this.hideCntxtMenuEvtCnt = 0;
}else if (this.renameForm.dirty == false){
this.onTriggerRenameFileStep2();
this.hideCntxtMenuEvtCnt = 0;
}else if(this.renameForm.dirty == false){
this.renameFileTriggerCnt ++;

if(this.renameFileTriggerCnt > 1){
Expand All @@ -394,9 +393,9 @@ export class FilemanagerComponent implements OnInit, AfterViewInit, OnDestroy {
onTriggerRenameFileStep1():void{
this.isRenameActive = !this.isRenameActive;

const figCapElement= document.getElementById(`figCap${this.elementId}`) as HTMLElement;
const renameContainerElement= document.getElementById(`renameContainer${this.elementId}`) as HTMLElement;
const renameTxtBoxElement= document.getElementById(`renameTxtBox${this.elementId}`) as HTMLInputElement;
const figCapElement= document.getElementById(`figCap${this.selectedElementId}`) as HTMLElement;
const renameContainerElement= document.getElementById(`renameContainer${this.selectedElementId}`) as HTMLElement;
const renameTxtBoxElement= document.getElementById(`renameTxtBox${this.selectedElementId}`) as HTMLInputElement;

if(figCapElement){
figCapElement.style.display = 'none';
Expand All @@ -415,19 +414,28 @@ export class FilemanagerComponent implements OnInit, AfterViewInit, OnDestroy {
}

onTriggerRenameFileStep2():void{
this.isRenameActive = !this.isRenameActive;

const btnElement = document.getElementById(`iconBtn${this.elementId}`) as HTMLElement;
const figCapElement= document.getElementById(`figCap${this.elementId}`) as HTMLElement;
const renameContainerElement= document.getElementById(`renameContainer${this.elementId}`) as HTMLElement;
const btnElement = document.getElementById(`iconBtn${this.selectedElementId}`) as HTMLElement;
const figCapElement= document.getElementById(`figCap${this.selectedElementId}`) as HTMLElement;
const renameContainerElement= document.getElementById(`renameContainer${this.selectedElementId}`) as HTMLElement;

const renameText = this.renameForm.value.renameInput as string;

if( renameText !== '' || renameText.length !== 0)
this._fileService.renameFileAsync(this.selectedFile.getCurrentPath, renameText);
if(renameText !== '' || renameText.length !== 0){
this._fileService.renameFileAsync(this.selectedFile.getCurrentPath, renameText);

// renamFileAsync, doesn't trigger a reload of the file directory, so to give the user the impression that the file has been updated, the code below
const fileIdx = this.files.findIndex(f => (f.getCurrentPath == this.selectedFile.getContentPath) && (f.getFileName == this.selectedFile.getFileName));
this.selectedFile.setFileName = renameText;
this.selectedFile.setDateModified = Date.now();
this.files[fileIdx] = this.selectedFile;
}

if(btnElement){
btnElement.style.backgroundColor = 'hsl(206deg 77% 70%/20%)';
btnElement.style.border = '2px solid hsla(0,0%,50%,25%)'
this.isIconHighlightActive = true;
}

if(figCapElement){
Expand All @@ -438,15 +446,15 @@ export class FilemanagerComponent implements OnInit, AfterViewInit, OnDestroy {
renameContainerElement.style.display = 'none';
}

//this.elementId = -1;
//this.selectedElementId = -1;
}

untriggerRenameFile():void{
this.isRenameActive = !this.isRenameActive;

const btnElement = document.getElementById(`iconBtn${this.elementId}`) as HTMLElement;
const figCapElement= document.getElementById(`figCap${this.elementId}`) as HTMLElement;
const renameContainerElement= document.getElementById(`renameContainer${this.elementId}`) as HTMLElement;
const btnElement = document.getElementById(`iconBtn${this.selectedElementId}`) as HTMLElement;
const figCapElement= document.getElementById(`figCap${this.selectedElementId}`) as HTMLElement;
const renameContainerElement= document.getElementById(`renameContainer${this.selectedElementId}`) as HTMLElement;

if(figCapElement){
figCapElement.style.display = 'block';
Expand All @@ -462,9 +470,9 @@ export class FilemanagerComponent implements OnInit, AfterViewInit, OnDestroy {
}

iconWasInfocus():void{
const btnElement = document.getElementById(`iconBtn${this.elementId}`) as HTMLElement;
const btnElement = document.getElementById(`iconBtn${this.selectedElementId}`) as HTMLElement;

if(this.hideCntxtMenuEvtCnt >= 1){
if(this.hideCntxtMenuEvtCnt >= 0){
if(btnElement){
btnElement.style.backgroundColor = 'transparent';
btnElement.style.border = '1px dotted white'
Expand Down

0 comments on commit dca7aef

Please sign in to comment.