More progress, committing to get assistance with TS
This commit is contained in:
parent
a76bde5b1d
commit
ed5ebe9155
8 changed files with 45 additions and 27 deletions
|
@ -1,16 +1,13 @@
|
|||
import http from './../http';
|
||||
import filter from 'lodash/filter';
|
||||
import isObject from 'lodash/isObject';
|
||||
import http from '../http';
|
||||
import { filter, isObject } from 'lodash';
|
||||
// @ts-ignore
|
||||
import route from '../../../../../vendor/tightenco/ziggy/src/js/route';
|
||||
import {DirectoryContents} from "./types";
|
||||
|
||||
/**
|
||||
* Get the contents of a specific directory for a given server.
|
||||
*
|
||||
* @param {String} server
|
||||
* @param {String} directory
|
||||
* @return {Promise}
|
||||
*/
|
||||
export function getDirectoryContents (server, directory) {
|
||||
export function getDirectoryContents (server: string, directory: string): Promise<DirectoryContents> {
|
||||
return new Promise((resolve, reject) => {
|
||||
http.get(route('server.files', { server, directory }))
|
||||
.then((response) => {
|
||||
|
@ -30,7 +27,7 @@ export function getDirectoryContents (server, directory) {
|
|||
}
|
||||
|
||||
if (err.response.data && isObject(err.response.data.errors)) {
|
||||
err.response.data.errors.forEach(error => {
|
||||
err.response.data.errors.forEach((error: any) => {
|
||||
return reject(error.detail);
|
||||
});
|
||||
}
|
5
resources/assets/scripts/api/server/types.ts
Normal file
5
resources/assets/scripts/api/server/types.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
export type DirectoryContents = {
|
||||
files: Array<string>,
|
||||
directories: Array<string>,
|
||||
editable: Array<string>
|
||||
}
|
Reference in a new issue