Skip to content

Commit

Permalink
Merge pull request #16 from jordanCain/default-uss-home-directory
Browse files Browse the repository at this point in the history
Default to USS home directory
  • Loading branch information
1000TurquoisePogs committed Jul 1, 2019
2 parents feecf36 + 1ade624 commit 07bc657
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/app/components/filebrowseruss/filebrowseruss.component.html
Expand Up @@ -13,14 +13,15 @@
<img src="../../../assets/explorer-uparrow.png" (click)="levelUp()" style="width: 20px; height: 20px; filter: brightness(3);">
<!-- <svg width="14" height="16" viewBox="0 0 14 16" fill-rule="evenodd" (click)="levelUp()"><path d="M6 3.4V16h2V3.4l4.7 4.9L14 7 7 0 0 7l1.3 1.3z"></path></svg> -->
<div class="filebrowseruss-search">
<input [(ngModel)]="path" placeholder="Enter a directory..." class="filebrowseruss-search-input" (change)="displayTree(path, false)">
<input [(ngModel)]="path" placeholder="Enter a directory..." class="filebrowseruss-search-input" (change)="displayTree(path, false)" [disabled]="isLoading">
</div>
<div class="fa fa-spinner fa-spin" [hidden]="!isLoading"></div>
<div (click)="onClick($event);" [hidden]="hideExplorer" style="height: 100%;">
<tree-root [treeData]="data" (clickEvent)="onNodeClick($event)" [style]="style"
(contextmenu)="$event.preventDefault(); onRightClick($event);"
></tree-root>
<tree-root [treeData]="data" (clickEvent)="onNodeClick($event)" [style]="style"
(contextmenu)="$event.preventDefault(); onRightClick($event);"
></tree-root>
</div>
</div>
</div>

<!-- <p-dialog header="New File" [(visible)]="addFileDisplay" [modal]="false" [responsive]="true" [width]="350" [minWidth]="200" >
<input type="text" placeholder="New Name" name="newPath" [(ngModel)]="newPath">
Expand Down
28 changes: 27 additions & 1 deletion src/app/components/filebrowseruss/filebrowseruss.component.ts
Expand Up @@ -57,6 +57,7 @@ export class FileBrowserUSSComponent implements OnInit, OnDestroy {//IFileBrowse
popUpMenuX: number;
popUpMenuY: number;
selectedFile: TreeNode;
isLoading: boolean;

//TODO:define interface types for uss-data/data
data: TreeNode[];
Expand All @@ -81,6 +82,7 @@ export class FileBrowserUSSComponent implements OnInit, OnDestroy {//IFileBrowse
this.path = this.root;
this.data = [];
this.hideExplorer = false;
this.isLoading = false;
}

@Output() nodeClick: EventEmitter<any> = new EventEmitter<any>();
Expand All @@ -106,6 +108,7 @@ export class FileBrowserUSSComponent implements OnInit, OnDestroy {//IFileBrowse
}

ngOnInit() {
this.loadUserHomeDirectory();
this.persistanceDataService.getData()
.subscribe(data => {
if (data.contents.ussInput) {
Expand All @@ -126,6 +129,24 @@ export class FileBrowserUSSComponent implements OnInit, OnDestroy {//IFileBrowse
}
}

loadUserHomeDirectory(): void {
this.isLoading = true;
this.ussSrv.getUserHomeFolder()
.subscribe(
resp => {
if(resp && resp.home){
this.path = resp.home.trim();
this.displayTree(this.path, true);
this.isLoading = false;
}
},
error => {
this.isLoading = false;
this.errorMessage = <any>error;
}
);
}

browsePath(path: string): void {
this.path = path;
}
Expand Down Expand Up @@ -217,6 +238,7 @@ export class FileBrowserUSSComponent implements OnInit, OnDestroy {//IFileBrowse
if (path === undefined || path == '') {
path = this.root;
}
this.isLoading = true;
this.ussData = this.ussSrv.getFile(path);
this.ussData.subscribe(
files => {
Expand All @@ -238,6 +260,7 @@ export class FileBrowserUSSComponent implements OnInit, OnDestroy {//IFileBrowse
files.entries[i].id = i;
tempChildren.push(files.entries[i]);
}
this.isLoading = false;
if (update == true) {//Tree is displayed to update existing opened nodes, while maintaining currently opened trees

let indexArray: number[];
Expand Down Expand Up @@ -305,7 +328,10 @@ export class FileBrowserUSSComponent implements OnInit, OnDestroy {//IFileBrowse
.subscribe((res: any) => { });
})
},
error => this.errorMessage = <any>error
error => {
this.isLoading = false;
this.errorMessage = <any>error;
}
);

}
Expand Down
8 changes: 8 additions & 0 deletions src/app/services/uss.crud.service.ts
Expand Up @@ -68,6 +68,7 @@ export class UssCrudService {
.map(res=>res.json())
.catch(this.handleErrorObservable);
}

saveFile(path:string, fileContents:string, targetEncoding?: string, forceOverwrite?: boolean): Observable<any>{
let url :string = ZoweZLUX.uriBroker.unixFileUri('contents', path, "UTF-8", targetEncoding, undefined, forceOverwrite, undefined, true);
return this.http.put(url,fileContents)
Expand All @@ -76,6 +77,13 @@ export class UssCrudService {
})
.catch(this.handleErrorObservable);
}

getUserHomeFolder(): Observable<any>{
let url :string = ZoweZLUX.uriBroker.omvsSegmentUri();
return this.http.get(url)
.map(res=>res.json())
.catch(this.handleErrorObservable);
}
}

/*
Expand Down

0 comments on commit 07bc657

Please sign in to comment.