Remove flow defs and usage, will be using TS
This commit is contained in:
parent
8fd0e5ff57
commit
cc7f7d7123
10 changed files with 110 additions and 88 deletions
|
@ -1,12 +1,10 @@
|
|||
// @flow
|
||||
import axios from 'axios';
|
||||
import type { AxiosInstance } from 'axios';
|
||||
|
||||
// This token is set in the bootstrap.js file at the beginning of the request
|
||||
// and is carried through from there.
|
||||
// const token: string = '';
|
||||
|
||||
const http: AxiosInstance = axios.create({
|
||||
const http = axios.create({
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
|
|
|
@ -1,23 +1,16 @@
|
|||
// @flow
|
||||
import http from './../http';
|
||||
import filter from 'lodash/filter';
|
||||
import isObject from 'lodash/isObject';
|
||||
import route from '../../../../../vendor/tightenco/ziggy/src/js/route';
|
||||
|
||||
export interface DirectoryContentsResponse {
|
||||
files: Object,
|
||||
directories: Object,
|
||||
editable: Array<string>,
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the contents of a specific directory for a given server.
|
||||
*
|
||||
* @param {String} server
|
||||
* @param {String} directory
|
||||
* @return {Promise<DirectoryContentsResponse>}
|
||||
* @return {Promise}
|
||||
*/
|
||||
export function getDirectoryContents(server: string, directory: string): Promise<DirectoryContentsResponse> {
|
||||
export function getDirectoryContents (server, directory) {
|
||||
return new Promise((resolve, reject) => {
|
||||
http.get(route('server.files', { server, directory }))
|
||||
.then((response) => {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
// @flow
|
||||
import Vue from 'vue';
|
||||
import Vuex from 'vuex';
|
||||
import vuexI18n from 'vuex-i18n';
|
||||
|
|
|
@ -42,13 +42,11 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
// @flow
|
||||
import map from 'lodash/map';
|
||||
import { mapState } from 'vuex';
|
||||
import type { Route } from 'vue-router';
|
||||
import FileManagerFileRow from '../components/filemanager/FileManagerFileRow';
|
||||
import FileManagerFolderRow from '../components/filemanager/FileManagerFolderRow';
|
||||
import { getDirectoryContents, DirectoryContentsResponse } from '../../../api/server/getDirectoryContents';
|
||||
import { getDirectoryContents } from '../../../api/server/getDirectoryContents';
|
||||
|
||||
export default {
|
||||
name: 'file-manager-page',
|
||||
|
@ -62,13 +60,13 @@ export default {
|
|||
* Configure the breadcrumbs that display on the filemanager based on the directory that the
|
||||
* user is currently in.
|
||||
*/
|
||||
breadcrumbs: function (): Array<Object> {
|
||||
const directories: Array<string> = this.currentDirectory.replace(/^\/|\/$/, '').split('/');
|
||||
breadcrumbs: function () {
|
||||
const directories = this.currentDirectory.replace(/^\/|\/$/, '').split('/');
|
||||
if (directories.length < 1 || !directories[0]) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return map(directories, function (value: string, key: number) {
|
||||
return map(directories, function (value, key) {
|
||||
if (key === directories.length - 1) {
|
||||
return { directoryName: value };
|
||||
}
|
||||
|
@ -85,14 +83,14 @@ export default {
|
|||
/**
|
||||
* When the route changes reload the directory.
|
||||
*/
|
||||
'$route': function (to: Route) {
|
||||
'$route': function (to) {
|
||||
this.currentDirectory = to.params.path || '/';
|
||||
},
|
||||
|
||||
/**
|
||||
* Watch the current directory setting and when it changes update the file listing.
|
||||
*/
|
||||
currentDirectory: function (): void {
|
||||
currentDirectory: function () {
|
||||
this.listDirectory();
|
||||
},
|
||||
|
||||
|
@ -100,7 +98,7 @@ export default {
|
|||
* When we reconnect to the Daemon make sure we grab a listing of all of the files
|
||||
* so that the error message disappears and we then load in a fresh listing.
|
||||
*/
|
||||
connected: function (): void {
|
||||
connected: function () {
|
||||
if (this.connected) {
|
||||
this.listDirectory();
|
||||
}
|
||||
|
@ -127,18 +125,18 @@ export default {
|
|||
/**
|
||||
* List the contents of a directory.
|
||||
*/
|
||||
listDirectory: function (): void {
|
||||
listDirectory: function () {
|
||||
this.loading = true;
|
||||
|
||||
const directory: string = encodeURI(this.currentDirectory.replace(/^\/|\/$/, ''));
|
||||
const directory = encodeURI(this.currentDirectory.replace(/^\/|\/$/, ''));
|
||||
getDirectoryContents(this.$route.params.id, directory)
|
||||
.then((response: DirectoryContentsResponse) => {
|
||||
.then((response) => {
|
||||
this.files = response.files;
|
||||
this.directories = response.directories;
|
||||
this.editableFiles = response.editable;
|
||||
this.errorMessage = null;
|
||||
})
|
||||
.catch((err: string|Object) => {
|
||||
.catch((err) => {
|
||||
if (err instanceof String) {
|
||||
this.errorMessage = err;
|
||||
return;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
// @flow
|
||||
import format from 'date-fns/format';
|
||||
|
||||
/**
|
||||
|
@ -8,13 +7,13 @@ import format from 'date-fns/format';
|
|||
* @param {Number} bytes
|
||||
* @return {String}
|
||||
*/
|
||||
export function readableSize (bytes: number): string {
|
||||
export function readableSize (bytes) {
|
||||
if (Math.abs(bytes) < 1024) {
|
||||
return `${bytes} Bytes`;
|
||||
}
|
||||
|
||||
let u: number = -1;
|
||||
const units: Array<string> = ['KiB', 'MiB', 'GiB', 'TiB'];
|
||||
let u = -1;
|
||||
const units = ['KiB', 'MiB', 'GiB', 'TiB'];
|
||||
|
||||
do {
|
||||
bytes /= 1024;
|
||||
|
@ -30,6 +29,6 @@ export function readableSize (bytes: number): string {
|
|||
* @param {String} date
|
||||
* @return {String}
|
||||
*/
|
||||
export function formatDate (date: string): string {
|
||||
export function formatDate (date) {
|
||||
return format(date, 'MMM D, YYYY [at] HH:MM');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue