Skip to content

Commit

Permalink
selction from filetreeview works
Browse files Browse the repository at this point in the history
  • Loading branch information
chinonso098 committed Sep 18, 2024
1 parent c1585f9 commit ca8b9fc
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ export class FileTreeViewComponent implements OnInit, OnChanges {
@Input() showRoot = true;
@Input() isHoverActive = false;
@Output() updateFileTreeData = new EventEmitter<string>();
@Output() navigateToPath = new EventEmitter<string[]>();

chevronBtnStyle:Record<string, unknown> = {};
expandedViews:string[]= [];
selectedElementId = 0;

constructor( ){
//
Expand Down Expand Up @@ -173,11 +175,11 @@ export class FileTreeViewComponent implements OnInit, OnChanges {
}
}

showCurrentSelection(path:string):void{
1
navigateToSelectedPath(name:string, path:string):void{
const data:string[] = [name, path]
this.navigateToPath.emit(data);
}


setcolorChevron(isHoverActive:boolean):void{
if(!isHoverActive){
this.chevronBtnStyle ={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
<div class="fileexp-content-container">
<div class="navigation-content-container" (mouseenter)="showExpandTreeIconBtn()" (mouseleave)="showExpandTreeIconBtn()" #navExplorerContainer>
<div style="height: 10px; width: 100%;"></div>
<cos-filetreeview [treeData]="fileTreeNode" [pid] ="processId" [isHoverActive]="showExpandTreeIcon" (updateFileTreeData)="updateFileTreeAsync($event)"></cos-filetreeview>
<cos-filetreeview [treeData]="fileTreeNode" [pid] ="processId" [isHoverActive]="showExpandTreeIcon" (updateFileTreeData)="updateFileTreeAsync($event)" (navigateToPath)="navigateToFolder($event)" ></cos-filetreeview>
</div>
<div class="file-content-container" #fileExplorerContentContainer>
<!-- ngResizable [rzHandles]="'w'" [rzMinWidth]="270" -->
Expand Down
118 changes: 63 additions & 55 deletions src/app/system-apps/fileexplorer/fileexplorer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export class FileExplorerComponent implements BaseComponent, OnInit, AfterViewIn
recentPathEntries:string[] = [];
upPathEntries:string[] = ['/Desktop'];
_directoryHops:string[] = ['This PC'];
fileTreeHistory:string[] = [];
SECONDS_DELAY:number[] = [100, 1500, 6000, 12000, 250];

defaultviewOption = ViewOptions.MEDIUM_ICON_VIEW;
Expand Down Expand Up @@ -675,15 +676,15 @@ export class FileExplorerComponent implements BaseComponent, OnInit, AfterViewIn
}
}

private async loadFilesInfoAsync(path?:string, showUrl=true):Promise<void>{
private async loadFilesInfoAsync(showUrlFiles=true):Promise<void>{
this.files = [];
this._fileService.resetDirectoryFiles();
let directoryEntries = await this._fileService.getEntriesFromDirectoryAsync(this.directory);

console.log('directoryEntries:',directoryEntries);

if(this.directory === '/'){
if(!showUrl){
if(!showUrlFiles){
const filteredDirectoryEntries = directoryEntries.filter(x => !x.includes('.url'));
directoryEntries = filteredDirectoryEntries;
this._directoryFilesEntires = this._fileService.getFileEntriesFromDirectory(filteredDirectoryEntries,this.directory);
Expand Down Expand Up @@ -738,32 +739,34 @@ export class FileExplorerComponent implements BaseComponent, OnInit, AfterViewIn

console.log('updateFileTreeAsync called', path);

const tmpFileTreeNode:FileTreeNode[] = [];
this._fileService.resetDirectoryFiles();
const directoryEntries = await this._fileService.getEntriesFromDirectoryAsync(path);

// this.directory, will not be correct for all cases. Make sure to check
for(const dirEntry of directoryEntries){

const isFile = await this._fileService.checkIfDirectory(`${path}/${dirEntry}`);
const ftn:FileTreeNode = {
name : dirEntry,
path: `${path}/${dirEntry}`,
isFolder: isFile,
children: []
if(!this.fileTreeHistory.includes(path)){
const tmpFileTreeNode:FileTreeNode[] = [];
this._fileService.resetDirectoryFiles();
const directoryEntries = await this._fileService.getEntriesFromDirectoryAsync(path);

// this.directory, will not be correct for all cases. Make sure to check
for(const dirEntry of directoryEntries){

const isFile = await this._fileService.checkIfDirectory(`${path}/${dirEntry}`);
const ftn:FileTreeNode = {
name : dirEntry,
path: `${path}/${dirEntry}`,
isFolder: isFile,
children: []
}

console.log('update-ftn:', ftn);
tmpFileTreeNode.push(ftn);
}

console.log('update-ftn:', ftn);
tmpFileTreeNode.push(ftn);

const res = this.addChildrenToNode(this.fileTreeNode, path, tmpFileTreeNode);
console.log('updatedTreeData:', res);
this.fileTreeNode = res;
this.fileTreeHistory.push(path);
}

const res = this.addChildrenToNode(this.fileTreeNode, path, tmpFileTreeNode);
console.log('updatedTreeData:', res);
this.fileTreeNode = res;
}

private addChildrenToNode(treeData: FileTreeNode[], nodePath: string, newChildren: FileTreeNode[] ): FileTreeNode[] {

// Create a new array for the updated treeData
const updatedTreeData: FileTreeNode[] = [];

Expand Down Expand Up @@ -795,38 +798,6 @@ export class FileExplorerComponent implements BaseComponent, OnInit, AfterViewIn
return updatedTreeData;
}

// public addChildrenToNode(treeData: FileTreeNode[], nodeName: string, newChildren: string[] ): FileTreeNode[] {

// // Create a new array for the updated treeData
// const updatedTreeData: FileTreeNode[] = [];

// for (let i = 0; i < treeData.length; i++) {
// const node = treeData[i];
// const updatedNode: FileTreeNode = {
// name: node.name,
// isFile: node.isFile,
// children: node.children ? [] : undefined
// };

// // If the current node matches the nodeName, add the new children
// if (node.name === nodeName) {
// updatedNode.children = (node.children || []).concat(
// newChildren.map(childName => ({ name: childName, isFile: node.isFile}))
// );
// }

// // If the node has children, recursively call this function on the children
// if (node.children) {
// updatedNode.children = this.addChildrenToNode(node.children, nodeName, newChildren);
// }

// // Add the updated node to the new treeData array
// updatedTreeData.push(updatedNode);
// }

// return updatedTreeData;
// }

async runProcess(file:FileInfo):Promise<void>{

console.log('fileexplorer-runProcess:',file)
Expand Down Expand Up @@ -862,6 +833,43 @@ export class FileExplorerComponent implements BaseComponent, OnInit, AfterViewIn
}
}

async navigateToFolder(data:string[]):Promise<void>{
const thisPC = 'This-PC';
const fileName = data[0];
const path = data[1];

if(!this.isNavigatedBefore){
this.prevPathEntries.push(this.directory);
this.upPathEntries.push(this.directory);
this.isNavigatedBefore = true;
}

this.isPrevBtnActive = true;
this.displayName = fileName;
this.directory = (path === thisPC)? '/' : path;

if(path === `/Users/${fileName}`)
this.icon = `osdrive/Cheetah/System/Imageres/${fileName.toLocaleLowerCase()}_folder.png`;
else
this.icon = `osdrive/Cheetah/System/Imageres/folder.png`;

this.prevPathEntries.push(this.directory);
this.upPathEntries.push(this.directory);

if(this.recentPathEntries.indexOf(this.directory) == -1){
this.recentPathEntries.push(this.directory);
}

this.populateHopsList();
this.setNavPathIcon(fileName, path);
this.storeAppState(path);

if(path === thisPC || path !== '/')
await this.loadFilesInfoAsync();
else if(path === '/')
await this.loadFilesInfoAsync(false);
}

setNavPathIcon(fileName:string, directory:string){

console.log(`fileexplorer - setNavPathIcon: fileName:${fileName} ----- directory:${directory}`)
Expand Down
2 changes: 1 addition & 1 deletion src/osdrive.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"3d-objects.url":null,"Cheetah":{"System":{"Imageres":{"3d-objects_folder.png":null,"3d_objects_folder_small.png":null,"arrow_down.png":null,"arrow_next.png":null,"arrow_next_1.png":null,"arrow_up.png":null,"audioplayer.png":null,"camera_48.png":null,"chkmark26.png":null,"chkmark32.png":null,"chkmark32_blk.png":null,"circle.png":null,"circle_blk.png":null,"cmd.png":null,"code-editor-2_48.png":null,"config.png":null,"content_view.ico":null,"content_view.png":null,"cross_mark_32.png":null,"desktop_folder.png":null,"desktop_folder_small.png":null,"details_pane.png":null,"details_view.ico":null,"details_view.png":null,"documents.png":null,"documents_24.png":null,"documents_folder.png":null,"documents_folder_small.png":null,"downloads_folder.png":null,"downloads_folder_small.png":null,"econo.png":null,"empty_folder.png":null,"empty_recycle.ico":null,"emulator_1.png":null,"emulator_2.png":null,"extra_large_image.png":null,"file.png":null,"file_explorer.png":null,"folder.png":null,"folder_folder_small.png":null,"games.png":null,"games_folder.png":null,"games_folder_small.png":null,"generic_program.png":null,"grey_history_32.png":null,"grey_nav_expand_32.png":null,"grey_nav_forward_32.png":null,"grey_nav_refresh_32.png":null,"images.png":null,"info.png":null,"js-dos-logo.png":null,"large_image.png":null,"lightning_flash.png":null,"list_of_thumbnails_view.png":null,"markdown-2_50.png":null,"markdown-50.png":null,"markdown-file_50.png":null,"medium_icons_view.png":null,"music_file.png":null,"music_folder.png":null,"music_folder_small.png":null,"my_computer.png":null,"nav_expand_32.png":null,"nav_left_32.png":null,"nav_right_32.png":null,"nav_up-32.png":null,"navigation_pane.png":null,"os_disk.png":null,"pdf-48.png":null,"photos_48.png":null,"picture_16.png":null,"pictures.png":null,"pictures_folder.png":null,"pictures_folder_small.png":null,"pin_24.png":null,"preview_pane.png":null,"red_x.png":null,"search_32.png":null,"small_icons_view.ico":null,"small_icons_view.png":null,"taskmanger.png":null,"taskmanger_2.png":null,"terminal-2_48.png":null,"terminal_48.png":null,"text-editor_48.png":null,"this_pc.png":null,"tiles_view.png":null,"unknown.png":null,"unpin_24.png":null,"unpin_32.png":null,"video_file.ico":null,"video_file.png":null,"videoplayer-2_48.png":null,"videoplayer.png":null,"videos.png":null,"videos_folder.png":null,"videos_folder_small.png":null,"vs-code_48.png":null,"white_history_32.png":null,"x_32.png":null}}},"Program-Files":{"simple.txt":null},"Users":{"3D-Objects":{},"Desktop":{"fileexplorer.url":null,"heat.url":null,"hello.url":null,"surfs.url":null,"taskmanager.url":null,"terminal.url":null,"titanium.url":null},"Documents":{"Credits.md":null,"Dynamic Programming.txt":null,"PDFs":{"CyberPower_UM_EC650LCD 2.pdf":null,"MotherBoard":{"PRO-B650-P-WIFI.pdf":null}},"Screen-Shots":{"Sample ScreenShot.png":null},"simple.txt":null,"starting a new proj in VSCode.txt":null},"Downloads":{"anothertest.txt":null},"Games":{"D3D.url":null,"Data":{"D3D.jsdos":null,"Digger.jsdos":null,"Doom.jsdos":null,"Jill of the Jungle.jsdos":null,"Machine Nation.jsdos":null,"Shadow Knight.jsdos":null},"Diggers.url":null,"Doom.url":null,"Flash-Games ":{"logo-anim.swf":null},"icons":{"d3d.png":null,"diggers.png":null,"doom.png":null,"doom1.png":null}},"Music":{"jazz-club-in-new-orleans.mp3":null,"titanium.mp3":null,"watr-fluid.mp3":null},"Pictures":{"Samples":{"Chill on the Moon.jpg":null,"Sparkling Water.jpg":null,"Sunset Car.jpg":null,"Sunset.jpg":null,"mystical.jpg":null,"no_img.jpeg":null},"favicon.ico":null,"favicon1.ico":null,"favicon_nice.png":null,"heat.png":null},"Videos":{"nuts.mp4":null,"surfs.mp4":null}},"desktop.url":null,"documents.url":null,"downloads.url":null,"games.url":null,"music.url":null,"pictures.url":null,"videos.url":null}
{"3d-objects.url":null,"Cheetah":{"System":{"Imageres":{"3d-objects_folder.png":null,"3d-objects_folder_small.png":null,"arrow_down.png":null,"arrow_next.png":null,"arrow_next_1.png":null,"arrow_up.png":null,"audioplayer.png":null,"camera_48.png":null,"chkmark26.png":null,"chkmark32.png":null,"chkmark32_blk.png":null,"circle.png":null,"circle_blk.png":null,"cmd.png":null,"code-editor-2_48.png":null,"config.png":null,"content_view.png":null,"cross_mark_32.png":null,"desktop_folder.png":null,"desktop_folder_small.png":null,"details_pane.png":null,"details_view.ico":null,"details_view.png":null,"documents.png":null,"documents_folder.png":null,"documents_folder_small.png":null,"downloads_folder.png":null,"downloads_folder_small.png":null,"econo.png":null,"empty_folder.png":null,"empty_recycle.ico":null,"emulator_1.png":null,"emulator_2.png":null,"extra_large_image.png":null,"file.png":null,"file_explorer.png":null,"folder.png":null,"folder_folder_small.png":null,"games.png":null,"games_folder.png":null,"games_folder_small.png":null,"generic_program.png":null,"grey_history_32.png":null,"grey_nav_expand_32.png":null,"grey_nav_forward_32.png":null,"grey_nav_refresh_32.png":null,"images.png":null,"info.png":null,"js-dos-logo.png":null,"large_image.png":null,"lightning_flash.png":null,"list_of_thumbnails_view.png":null,"markdown-2_50.png":null,"markdown-50.png":null,"markdown-file_50.png":null,"medium_icons_view.png":null,"music_file.png":null,"music_folder.png":null,"music_folder_small.png":null,"my_computer.png":null,"nav_expand_32.png":null,"nav_left_32.png":null,"nav_right_32.png":null,"nav_up-32.png":null,"navigation_pane.png":null,"os_disk.png":null,"pdf-48.png":null,"photos_48.png":null,"picture_16.png":null,"pictures.png":null,"pictures_folder.png":null,"pictures_folder_small.png":null,"pin_24.png":null,"preview_pane.png":null,"red_x.png":null,"search_32.png":null,"small_icons_view.png":null,"taskmanger.png":null,"taskmanger_2.png":null,"terminal-2_48.png":null,"terminal_48.png":null,"text-editor_48.png":null,"this_pc.png":null,"tiles_view.png":null,"unknown.png":null,"unpin_24.png":null,"unpin_32.png":null,"video_file.png":null,"videoplayer-2_48.png":null,"videoplayer.png":null,"videos.png":null,"videos_folder.png":null,"videos_folder_small.png":null,"vs-code_48.png":null,"white_history_32.png":null,"x_32.png":null}}},"Program-Files":{"simple.txt":null},"Users":{"3D-Objects":{},"Desktop":{"fileexplorer.url":null,"heat.url":null,"hello.url":null,"surfs.url":null,"taskmanager.url":null,"terminal.url":null,"titanium.url":null},"Documents":{"Credits.md":null,"Dynamic Programming.txt":null,"PDFs":{"CyberPower_UM_EC650LCD 2.pdf":null,"MotherBoard":{"PRO-B650-P-WIFI.pdf":null}},"Screen-Shots":{"Sample ScreenShot.png":null},"simple.txt":null,"starting a new proj in VSCode.txt":null},"Downloads":{"anothertest.txt":null},"Games":{"D3D.url":null,"Data":{"D3D.jsdos":null,"Digger.jsdos":null,"Doom.jsdos":null,"Jill of the Jungle.jsdos":null,"Machine Nation.jsdos":null,"Shadow Knight.jsdos":null},"Diggers.url":null,"Doom.url":null,"Flash-Games ":{"logo-anim.swf":null},"icons":{"d3d.png":null,"diggers.png":null,"doom.png":null,"doom1.png":null}},"Music":{"jazz-club-in-new-orleans.mp3":null,"titanium.mp3":null,"watr-fluid.mp3":null},"Pictures":{"Samples":{"Chill on the Moon.jpg":null,"Sparkling Water.jpg":null,"Sunset Car.jpg":null,"Sunset.jpg":null,"mystical.jpg":null,"no_img.jpeg":null},"favicon.ico":null,"favicon1.ico":null,"favicon_nice.png":null,"heat.png":null},"Videos":{"nuts.mp4":null,"surfs.mp4":null}},"desktop.url":null,"documents.url":null,"downloads.url":null,"games.url":null,"music.url":null,"pictures.url":null,"videos.url":null}
Binary file removed src/osdrive/Cheetah/System/Imageres/content_view.ico
Binary file not shown.
Binary file removed src/osdrive/Cheetah/System/Imageres/documents_24.png
Binary file not shown.
Binary file modified src/osdrive/Cheetah/System/Imageres/documents_folder_small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.

0 comments on commit ca8b9fc

Please sign in to comment.