Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default to USS home directory #16

Merged
merged 3 commits into from
Jul 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/app/components/filebrowseruss/filebrowseruss.component.html
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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