Format all the files
This commit is contained in:
parent
5bff8d99cc
commit
b6773b56c1
22 changed files with 158 additions and 159 deletions
|
@ -9,7 +9,7 @@ import {ServerDatabase} from "@/api/server/types";
|
|||
*/
|
||||
export function createDatabase(server: string, database: string, remote: string): Promise<ServerDatabase> {
|
||||
return new Promise((resolve, reject) => {
|
||||
http.post(route('api.client.servers.databases', { server }), {database, remote})
|
||||
http.post(route('api.client.servers.databases', {server}), {database, remote})
|
||||
.then(response => {
|
||||
const copy: any = response.data.attributes;
|
||||
copy.password = copy.relationships.password.attributes.password;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import http from '../http';
|
||||
import { filter, isObject } from 'lodash';
|
||||
import {filter, isObject} from 'lodash';
|
||||
// @ts-ignore
|
||||
import route from '../../../../../vendor/tightenco/ziggy/src/js/route';
|
||||
import {DirectoryContents} from "./types";
|
||||
|
@ -7,9 +7,9 @@ import {DirectoryContents} from "./types";
|
|||
/**
|
||||
* Get the contents of a specific directory for a given server.
|
||||
*/
|
||||
export function getDirectoryContents (server: string, directory: string): Promise<DirectoryContents> {
|
||||
export function getDirectoryContents(server: string, directory: string): Promise<DirectoryContents> {
|
||||
return new Promise((resolve, reject) => {
|
||||
http.get(route('server.files', { server, directory }))
|
||||
http.get(route('server.files', {server, directory}))
|
||||
.then((response) => {
|
||||
return resolve({
|
||||
files: filter(response.data.contents, function (o) {
|
||||
|
|
|
@ -10,7 +10,8 @@ window._ = require('lodash');
|
|||
|
||||
try {
|
||||
window.$ = window.jQuery = require('jquery');
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
window.axios = axios;
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@
|
|||
|
||||
if (response.data.send_to_login) {
|
||||
this.$flash.success('Your password has been reset, please login to continue.');
|
||||
return this.$router.push({ name: 'login' });
|
||||
return this.$router.push({name: 'login'});
|
||||
}
|
||||
|
||||
return window.location = response.data.redirect_to;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
import { replace } from 'feather-icons';
|
||||
import {replace} from 'feather-icons';
|
||||
|
||||
export default Vue.extend({
|
||||
name: 'Icon',
|
||||
|
|
|
@ -24,9 +24,9 @@
|
|||
components: {Icon},
|
||||
|
||||
props: {
|
||||
modalName: { type: String, default: 'modal' },
|
||||
show: { type: Boolean, default: false },
|
||||
closeOnEsc: { type: Boolean, default: true },
|
||||
modalName: {type: String, default: 'modal'},
|
||||
show: {type: Boolean, default: false},
|
||||
closeOnEsc: {type: Boolean, default: true},
|
||||
},
|
||||
|
||||
mounted: function () {
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
|
||||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
import { isObject } from 'lodash';
|
||||
import {isObject} from 'lodash';
|
||||
import {AxiosError} from "axios";
|
||||
|
||||
export default Vue.extend({
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<input type="hidden" name="_token" v-bind:value="X_CSRF_TOKEN" />
|
||||
<input type="hidden" name="_token" v-bind:value="X_CSRF_TOKEN"/>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
<button class="btn btn-green uppercase text-xs px-4 py-2"
|
||||
v-if="status === statuses.STATUS_OFF"
|
||||
v-on:click.prevent="sendPowerAction('start')"
|
||||
>Start</button>
|
||||
>Start
|
||||
</button>
|
||||
<div v-else>
|
||||
<button class="btn btn-red uppercase text-xs px-4 py-2" v-on:click.prevent="sendPowerAction('stop')">Stop</button>
|
||||
<button class="btn btn-secondary uppercase text-xs px-4 py-2" v-on:click.prevent="sendPowerAction('restart')">Restart</button>
|
||||
|
|
|
@ -57,6 +57,6 @@
|
|||
|
||||
export default Vue.extend({
|
||||
name: 'FileContextMenu',
|
||||
components: { Icon },
|
||||
components: {Icon},
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -16,12 +16,12 @@
|
|||
|
||||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
import { formatDate } from "@/helpers";
|
||||
import {formatDate} from "@/helpers";
|
||||
import Icon from "@/components/core/Icon.vue";
|
||||
|
||||
export default Vue.extend({
|
||||
name: 'FolderRow',
|
||||
components: { Icon },
|
||||
components: {Icon},
|
||||
|
||||
props: {
|
||||
directory: {type: Object, required: true},
|
||||
|
@ -37,7 +37,7 @@
|
|||
/**
|
||||
* Return a formatted directory path that is used to switch to a nested directory.
|
||||
*/
|
||||
getClickablePath (directory: string): string {
|
||||
getClickablePath(directory: string): string {
|
||||
return `${this.currentDirectory.replace(/\/$/, '')}/${directory}`;
|
||||
},
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
<div class="animated-fade-in">
|
||||
<div class="filemanager-breadcrumbs">
|
||||
/<span class="px-1">home</span><!--
|
||||
-->/<router-link :to="{ name: 'server-files' }" class="px-1">container</router-link><!--
|
||||
-->/
|
||||
<router-link :to="{ name: 'server-files' }" class="px-1">container</router-link><!--
|
||||
--><span v-for="crumb in breadcrumbs" class="inline-block">
|
||||
<span v-if="crumb.path">
|
||||
/<router-link :to="{ name: 'server-files', params: { path: crumb.path } }" class="px-1">{{crumb.directoryName}}</router-link>
|
||||
|
@ -34,7 +35,7 @@
|
|||
<FolderRow :directory="directory"/>
|
||||
</div>
|
||||
<div v-for="file in files">
|
||||
<FileRow :file="file" :editable="editableFiles" />
|
||||
<FileRow :file="file" :editable="editableFiles"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -51,121 +52,121 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
import {mapState} from "vuex";
|
||||
import { map } from 'lodash';
|
||||
import getDirectoryContents from "@/api/server/getDirectoryContents";
|
||||
import FileRow from "@/components/server/components/filemanager/FileRow.vue";
|
||||
import FolderRow from "@/components/server/components/filemanager/FolderRow.vue";
|
||||
import Vue from 'vue';
|
||||
import {mapState} from "vuex";
|
||||
import {map} from 'lodash';
|
||||
import getDirectoryContents from "@/api/server/getDirectoryContents";
|
||||
import FileRow from "@/components/server/components/filemanager/FileRow.vue";
|
||||
import FolderRow from "@/components/server/components/filemanager/FolderRow.vue";
|
||||
|
||||
type DataStructure = {
|
||||
loading: boolean,
|
||||
errorMessage: string | null,
|
||||
currentDirectory: string,
|
||||
files: Array<any>,
|
||||
directories: Array<any>,
|
||||
editableFiles: Array<string>,
|
||||
}
|
||||
type DataStructure = {
|
||||
loading: boolean,
|
||||
errorMessage: string | null,
|
||||
currentDirectory: string,
|
||||
files: Array<any>,
|
||||
directories: Array<any>,
|
||||
editableFiles: Array<string>,
|
||||
}
|
||||
|
||||
export default Vue.extend({
|
||||
name: 'FileManager',
|
||||
components: { FileRow, FolderRow },
|
||||
computed: {
|
||||
...mapState('server', ['server', 'credentials']),
|
||||
...mapState('socket', ['connected']),
|
||||
export default Vue.extend({
|
||||
name: 'FileManager',
|
||||
components: {FileRow, FolderRow},
|
||||
computed: {
|
||||
...mapState('server', ['server', 'credentials']),
|
||||
...mapState('socket', ['connected']),
|
||||
|
||||
/**
|
||||
* Configure the breadcrumbs that display on the filemanager based on the directory that the
|
||||
* user is currently in.
|
||||
*/
|
||||
breadcrumbs: function () {
|
||||
const directories = this.currentDirectory.replace(/^\/|\/$/, '').split('/');
|
||||
if (directories.length < 1 || !directories[0]) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return map(directories, function (value: string, key: number) {
|
||||
if (key === directories.length - 1) {
|
||||
return { directoryName: value };
|
||||
/**
|
||||
* Configure the breadcrumbs that display on the filemanager based on the directory that the
|
||||
* user is currently in.
|
||||
*/
|
||||
breadcrumbs: function () {
|
||||
const directories = this.currentDirectory.replace(/^\/|\/$/, '').split('/');
|
||||
if (directories.length < 1 || !directories[0]) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return {
|
||||
directoryName: value,
|
||||
path: directories.slice(0, key + 1).join('/'),
|
||||
};
|
||||
});
|
||||
},
|
||||
},
|
||||
return map(directories, function (value: string, key: number) {
|
||||
if (key === directories.length - 1) {
|
||||
return {directoryName: value};
|
||||
}
|
||||
|
||||
watch: {
|
||||
/**
|
||||
* When the route changes reload the directory.
|
||||
*/
|
||||
'$route': function (to) {
|
||||
this.currentDirectory = to.params.path || '/';
|
||||
return {
|
||||
directoryName: value,
|
||||
path: directories.slice(0, key + 1).join('/'),
|
||||
};
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Watch the current directory setting and when it changes update the file listing.
|
||||
*/
|
||||
currentDirectory: function () {
|
||||
watch: {
|
||||
/**
|
||||
* When the route changes reload the directory.
|
||||
*/
|
||||
'$route': function (to) {
|
||||
this.currentDirectory = to.params.path || '/';
|
||||
},
|
||||
|
||||
/**
|
||||
* Watch the current directory setting and when it changes update the file listing.
|
||||
*/
|
||||
currentDirectory: function () {
|
||||
this.listDirectory();
|
||||
},
|
||||
|
||||
/**
|
||||
* 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 () {
|
||||
// @ts-ignore
|
||||
if (this.connected) {
|
||||
this.listDirectory();
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
data: function (): DataStructure {
|
||||
return {
|
||||
currentDirectory: this.$route.params.path || '/',
|
||||
loading: true,
|
||||
errorMessage: null,
|
||||
directories: [],
|
||||
editableFiles: [],
|
||||
files: [],
|
||||
};
|
||||
},
|
||||
|
||||
mounted: function () {
|
||||
this.listDirectory();
|
||||
},
|
||||
|
||||
/**
|
||||
* 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 () {
|
||||
// @ts-ignore
|
||||
if (this.connected) {
|
||||
this.listDirectory();
|
||||
}
|
||||
methods: {
|
||||
/**
|
||||
* List the contents of a directory.
|
||||
*/
|
||||
listDirectory: function () {
|
||||
this.loading = true;
|
||||
|
||||
const directory = encodeURI(this.currentDirectory.replace(/^\/|\/$/, ''));
|
||||
getDirectoryContents(this.$route.params.id, directory)
|
||||
.then((response) => {
|
||||
this.files = response.files;
|
||||
this.directories = response.directories;
|
||||
this.editableFiles = response.editable;
|
||||
this.errorMessage = null;
|
||||
})
|
||||
.catch((err) => {
|
||||
if (typeof err === 'string') {
|
||||
this.errorMessage = err;
|
||||
return;
|
||||
}
|
||||
|
||||
console.error('An error was encountered while processing this request.', {err});
|
||||
})
|
||||
.then(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
data: function (): DataStructure {
|
||||
return {
|
||||
currentDirectory: this.$route.params.path || '/',
|
||||
loading: true,
|
||||
errorMessage: null,
|
||||
directories: [],
|
||||
editableFiles: [],
|
||||
files: [],
|
||||
};
|
||||
},
|
||||
|
||||
mounted: function () {
|
||||
this.listDirectory();
|
||||
},
|
||||
|
||||
methods: {
|
||||
/**
|
||||
* List the contents of a directory.
|
||||
*/
|
||||
listDirectory: function () {
|
||||
this.loading = true;
|
||||
|
||||
const directory = encodeURI(this.currentDirectory.replace(/^\/|\/$/, ''));
|
||||
getDirectoryContents(this.$route.params.id, directory)
|
||||
.then((response) => {
|
||||
this.files = response.files;
|
||||
this.directories = response.directories;
|
||||
this.editableFiles = response.editable;
|
||||
this.errorMessage = null;
|
||||
})
|
||||
.catch((err) => {
|
||||
if (typeof err === 'string') {
|
||||
this.errorMessage = err;
|
||||
return;
|
||||
}
|
||||
|
||||
console.error('An error was encountered while processing this request.', { err });
|
||||
})
|
||||
.then(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { format } from 'date-fns';
|
||||
import {format} from 'date-fns';
|
||||
|
||||
/**
|
||||
* Return the human readable filesize for a given number of bytes. This
|
||||
* uses 1024 as the base, so the response is denoted accordingly.
|
||||
*/
|
||||
export function readableSize (bytes: number): string {
|
||||
export function readableSize(bytes: number): string {
|
||||
if (Math.abs(bytes) < 1024) {
|
||||
return `${bytes} Bytes`;
|
||||
}
|
||||
|
@ -23,6 +23,6 @@ export function readableSize (bytes: number): string {
|
|||
/**
|
||||
* Format the given date as a human readable string.
|
||||
*/
|
||||
export function formatDate (date: string): string {
|
||||
export function formatDate(date: string): string {
|
||||
return format(date, 'MMM D, YYYY [at] HH:MM');
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,4 +1,3 @@
|
|||
|
||||
type ServerAllocation = {
|
||||
ip: string,
|
||||
port: number,
|
||||
|
@ -75,7 +74,7 @@ export default class Server {
|
|||
/**
|
||||
* Construct a new server model instance.
|
||||
*/
|
||||
constructor (data: ServerData) {
|
||||
constructor(data: ServerData) {
|
||||
this.identifier = data.identifier;
|
||||
this.uuid = data.uuid;
|
||||
this.name = data.name;
|
||||
|
|
|
@ -5,7 +5,6 @@ import {AxiosInstance} from "axios";
|
|||
import {Vue as VueType} from "vue/types/vue";
|
||||
import {ApplicationState} from "./store/types";
|
||||
import {Route} from "vue-router";
|
||||
|
||||
// @ts-ignore
|
||||
import {Ziggy} from './helpers/ziggy';
|
||||
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
import VueRouter, {Route} from 'vue-router';
|
||||
import store from './store/index';
|
||||
import User from './models/user';
|
||||
|
||||
const route = require('./../../../vendor/tightenco/ziggy/src/js/route').default;
|
||||
|
||||
// Base Vuejs Templates
|
||||
import Login from './components/auth/Login.vue';
|
||||
import Dashboard from './components/dashboard/Dashboard.vue';
|
||||
|
@ -17,13 +14,15 @@ import ConsolePage from "@/components/server/subpages/Console.vue";
|
|||
import FileManagerPage from "@/components/server/subpages/FileManager.vue";
|
||||
import DatabasesPage from "@/components/server/subpages/Databases.vue";
|
||||
|
||||
const route = require('./../../../vendor/tightenco/ziggy/src/js/route').default;
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: '/auth', component: Login,
|
||||
children: [
|
||||
{ name: 'login', path: 'login', component: LoginForm },
|
||||
{ name: 'forgot-password', path: 'password', component: ForgotPassword },
|
||||
{ name: 'checkpoint', path: 'checkpoint', component: TwoFactorForm },
|
||||
{name: 'login', path: 'login', component: LoginForm},
|
||||
{name: 'forgot-password', path: 'password', component: ForgotPassword},
|
||||
{name: 'checkpoint', path: 'checkpoint', component: TwoFactorForm},
|
||||
]
|
||||
},
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ export default {
|
|||
return new Promise((resolve, reject) => {
|
||||
// @ts-ignore
|
||||
window.axios.post(route('auth.login'), {user, password})
|
||||
// @ts-ignore
|
||||
// @ts-ignore
|
||||
.then(response => {
|
||||
commit('logout');
|
||||
|
||||
|
@ -75,7 +75,7 @@ export default {
|
|||
return new Promise((resolve, reject) => {
|
||||
// @ts-ignore
|
||||
window.axios.put(route('api.client.account.update-email'), {email, password})
|
||||
// @ts-ignore
|
||||
// @ts-ignore
|
||||
.then(response => {
|
||||
// If there is a 302 redirect or some other odd behavior (basically, response that isnt
|
||||
// in JSON format) throw an error and don't try to continue with the login.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import Server, {ServerData} from '../../models/server';
|
||||
import {ActionContext} from "vuex";
|
||||
import {DashboardState} from "../types";
|
||||
|
||||
const route = require('./../../../../../vendor/tightenco/ziggy/src/js/route').default;
|
||||
|
||||
export default {
|
||||
|
@ -22,9 +23,9 @@ export default {
|
|||
return new Promise((resolve, reject) => {
|
||||
// @ts-ignore
|
||||
window.axios.get(route('api.client.index'), {
|
||||
params: { query: state.searchTerm },
|
||||
params: {query: state.searchTerm},
|
||||
})
|
||||
// @ts-ignore
|
||||
// @ts-ignore
|
||||
.then(response => {
|
||||
// If there is a 302 redirect or some other odd behavior (basically, response that isnt
|
||||
// in JSON format) throw an error and don't try to continue with the request processing.
|
||||
|
|
|
@ -11,8 +11,7 @@ export default {
|
|||
credentials: {node: '', key: ''},
|
||||
console: [],
|
||||
},
|
||||
getters: {
|
||||
},
|
||||
getters: {},
|
||||
actions: {
|
||||
/**
|
||||
* Fetches the active server from the API and stores it in vuex.
|
||||
|
@ -20,8 +19,8 @@ export default {
|
|||
getServer: ({commit}: ActionContext<ServerState, any>, {server}: { server: string }): Promise<void> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
// @ts-ignore
|
||||
window.axios.get(route('api.client.servers.view', { server }))
|
||||
// @ts-ignore
|
||||
window.axios.get(route('api.client.servers.view', {server}))
|
||||
// @ts-ignore
|
||||
.then(response => {
|
||||
// If there is a 302 redirect or some other odd behavior (basically, response that isnt
|
||||
// in JSON format) throw an error and don't try to continue with the login.
|
||||
|
@ -47,7 +46,7 @@ export default {
|
|||
return new Promise((resolve, reject) => {
|
||||
// @ts-ignore
|
||||
window.axios.get(route('server.credentials', {server}))
|
||||
// @ts-ignore
|
||||
// @ts-ignore
|
||||
.then(response => {
|
||||
// If there is a 302 redirect or some other odd behavior (basically, response that isnt
|
||||
// in JSON format) throw an error and don't try to continue with the login.
|
||||
|
|
|
@ -14,12 +14,12 @@ export default {
|
|||
state.connectionError = false;
|
||||
},
|
||||
|
||||
SOCKET_ERROR: (state: SocketState, err : Error) => {
|
||||
SOCKET_ERROR: (state: SocketState, err: Error) => {
|
||||
state.connected = false;
|
||||
state.connectionError = err;
|
||||
},
|
||||
|
||||
SOCKET_CONNECT_ERROR: (state: SocketState, err : Error) => {
|
||||
SOCKET_CONNECT_ERROR: (state: SocketState, err: Error) => {
|
||||
state.connected = false;
|
||||
state.connectionError = err;
|
||||
},
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import {ServerData} from "../models/server";
|
||||
import Server from "../models/server";
|
||||
import Server, {ServerData} from "../models/server";
|
||||
import User from "../models/user";
|
||||
|
||||
export type ApplicationState = {
|
||||
|
|
Loading…
Reference in a new issue