Skip to content

Commit

Permalink
Fix API endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
AlecDusheck committed Mar 6, 2019
1 parent f879695 commit f83aac7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@ export class PanelFileEditorComponent extends ResponsiveServerPage implements On

private getContents = async (): Promise<void> => {
this.loading = true;

const filePath = await this.activatedRoute.queryParams.toPromise()['f'];
this.editName = filePath;
this.editName = this.activatedRoute.snapshot.queryParams['f'];
console.log("edit name: " + this.editName);

try {
this.editForm.controls.content.setValue(await this.serverActions.getFileContents(filePath));
this.editForm.controls.content.setValue(await this.serverActions.getFileContents(this.editName));
} catch (e) {
if (e === 'File not found.') {
this.newFile = true;
Expand Down
10 changes: 7 additions & 3 deletions src/app/controllers/panel/panel-files/panel-files.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,22 @@ export class PanelFilesComponent extends ResponsiveServerPage implements OnInit,
ngOnDestroy(): void {
super.ngUnload();
}

loadData = async (): Promise<void> => {
this.currentPath = '/';

// Make sure the server isn't blocked
if (this.serverSocket.blockedSource.value) {
console.log("blocked true");
return;
}

await this.updateListing();
console.log("load data called");

await this.updateFileListing();
};

updateListing = async (): Promise<void> => {
updateFileListing = async (): Promise<void> => {
console.log("called")
this.loading = true;

try {
Expand Down
22 changes: 11 additions & 11 deletions src/app/services/server-actions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class ServerActionsService {
return (await this.http.post<any>(
ConfigStorage.config.endpoints.api + 'server/' + this.currentServer.selectedServer.value.details._id + '/addSubuser',
{
email
email: email
},
this.auth.authOptions
).toPromise());
Expand All @@ -75,7 +75,7 @@ export class ServerActionsService {
return (await this.http.post<any>(
ConfigStorage.config.endpoints.api + 'server/' + this.currentServer.selectedServer.value.details._id + '/removeSubuser',
{
id
id: id
},
this.auth.authOptions
).toPromise());
Expand All @@ -85,37 +85,37 @@ export class ServerActionsService {
return (await this.http.post<any>(
ConfigStorage.config.endpoints.api + 'server/' + this.currentServer.selectedServer.value.details._id + '/changePreset',
{
preset
preset: preset
},
this.auth.authOptions
).toPromise());
};

public listDir = async (path: string): Promise<FileDetails[]> => {
return (await this.http.post<any>(
ConfigStorage.config.endpoints.api + 'server/' + this.currentServer.selectedServer.value.details._id + '/fs/directory',
ConfigStorage.config.endpoints.api + 'server/' + this.currentServer.selectedServer.value.details._id + '/fs/listDir',
{
path
path: path
},
this.auth.authOptions
).toPromise()).files;
};

public getFileContents = async (path: string): Promise<string> => {
return (await this.http.post<any>(
ConfigStorage.config.endpoints.api + 'server/' + this.currentServer.selectedServer.value.details._id + '/fs/contents',
ConfigStorage.config.endpoints.api + 'server/' + this.currentServer.selectedServer.value.details._id + '/fs/fileContents',
{
path
path: path
},
this.auth.authOptions
).toPromise()).content;
).toPromise()).contents;
};

public checkAllowed = async (path: string): Promise<boolean> => {
return (await this.http.post<any>(
ConfigStorage.config.endpoints.api + 'server/' + this.currentServer.selectedServer.value.details._id + '/fs/checkAllowed',
{
path
path: path
},
this.auth.authOptions
).toPromise()).allowed;
Expand All @@ -136,7 +136,7 @@ export class ServerActionsService {
return (await this.http.post<any>(
ConfigStorage.config.endpoints.api + 'server/' + this.currentServer.selectedServer.value.details._id + '/fs/removeFile',
{
path,
path: path
},
this.auth.authOptions
).toPromise());
Expand All @@ -146,7 +146,7 @@ export class ServerActionsService {
return (await this.http.post<any>(
ConfigStorage.config.endpoints.api + 'server/' + this.currentServer.selectedServer.value.details._id + '/fs/removeFolder',
{
path,
path: path
},
this.auth.authOptions
).toPromise());
Expand Down
4 changes: 2 additions & 2 deletions src/app/services/server-socket-io.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ export class ServerSocketIOService {

private _statusSource: BehaviorSubject<ServerStatus> = new BehaviorSubject(ServerStatus.LOADING);
private _consoleSource: BehaviorSubject<string> = new BehaviorSubject('');
private _blockedSource: BehaviorSubject<boolean> = new BehaviorSubject(true);
private _installedSource: BehaviorSubject<boolean> = new BehaviorSubject(false);
private _blockedSource: BehaviorSubject<boolean> = new BehaviorSubject(false);
private _installedSource: BehaviorSubject<boolean> = new BehaviorSubject(true);
private _announceSource: Subject<string> = new Subject();

private ioSocket;
Expand Down

0 comments on commit f83aac7

Please sign in to comment.