Move everything back to vue SFCs
This commit is contained in:
parent
761704408e
commit
5bff8d99cc
58 changed files with 2558 additions and 2518 deletions
|
@ -1,121 +0,0 @@
|
|||
import Vue from 'vue';
|
||||
import Navigation from '@/components/core/Navigation';
|
||||
import ProgressBar from './components/ProgressBar';
|
||||
import { mapState } from 'vuex';
|
||||
import * as io from 'socket.io-client';
|
||||
import { Socketio } from "@/mixins/socketio";
|
||||
import Icon from "@/components/core/Icon";
|
||||
import PowerButtons from "@/components/server/components/PowerButtons";
|
||||
|
||||
export default Vue.component('server', {
|
||||
components: { ProgressBar, PowerButtons, Navigation, Icon },
|
||||
computed: {
|
||||
...mapState('server', ['server', 'credentials']),
|
||||
...mapState('socket', ['connected', 'connectionError']),
|
||||
},
|
||||
|
||||
mixins: [ Socketio ],
|
||||
|
||||
// Watch for route changes that occur with different server parameters. This occurs when a user
|
||||
// uses the search bar. Because of the way vue-router works, it won't re-mount the server component
|
||||
// so we will end up seeing the wrong server data if we don't perform this watch.
|
||||
watch: {
|
||||
'$route': function (toRoute, fromRoute) {
|
||||
if (toRoute.params.id !== fromRoute.params.id) {
|
||||
this.loadingServerData = true;
|
||||
this.loadServer();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
data: function () {
|
||||
return {
|
||||
loadingServerData: true,
|
||||
};
|
||||
},
|
||||
|
||||
mounted: function () {
|
||||
this.loadServer();
|
||||
},
|
||||
|
||||
beforeDestroy: function () {
|
||||
this.removeSocket();
|
||||
},
|
||||
|
||||
methods: {
|
||||
/**
|
||||
* Load the core server information needed for these pages to be functional.
|
||||
*/
|
||||
loadServer: function () {
|
||||
Promise.all([
|
||||
this.$store.dispatch('server/getServer', {server: this.$route.params.id}),
|
||||
this.$store.dispatch('server/getCredentials', {server: this.$route.params.id})
|
||||
])
|
||||
.then(() => {
|
||||
// Configure the socket.io implementation. This is a really ghetto way of handling things
|
||||
// but all of these plugins assume you have some constant connection, which we don't.
|
||||
const socket = io(`${this.credentials.node}/v1/ws/${this.server.uuid}`, {
|
||||
query: `token=${this.credentials.key}`,
|
||||
});
|
||||
|
||||
this.$socket().connect(socket);
|
||||
this.loadingServerData = false;
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('There was an error performing Server::loadServer', { err });
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
template: `
|
||||
<div>
|
||||
<navigation></navigation>
|
||||
<flash class="m-6"/>
|
||||
<div v-if="loadingServerData" class="container">
|
||||
<div class="mt-6 h-16">
|
||||
<div class="spinner spinner-xl spinner-thick blue"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="container">
|
||||
<div class="my-6 flex flex-no-shrink rounded animate fadein">
|
||||
<div class="sidebar flex-no-shrink w-1/3 max-w-xs">
|
||||
<div class="mr-6">
|
||||
<div class="p-6 text-center bg-white rounded shadow">
|
||||
<h3 class="mb-2 text-primary-500 font-medium">{{server.name}}</h3>
|
||||
<span class="text-neutral-600 text-sm">{{server.node}}</span>
|
||||
<power-buttons class="mt-6 pt-6 text-center border-t border-neutral-100"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sidenav mt-6 mr-6">
|
||||
<ul>
|
||||
<li>
|
||||
<router-link :to="{ name: 'server', params: { id: $route.params.id } }">
|
||||
Console
|
||||
</router-link>
|
||||
</li>
|
||||
<li>
|
||||
<router-link :to="{ name: 'server-files' }">
|
||||
File Manager
|
||||
</router-link>
|
||||
</li>
|
||||
<li>
|
||||
<router-link :to="{ name: 'server-databases' }">
|
||||
Databases
|
||||
</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="h-full w-full">
|
||||
<router-view :key="server.identifier"></router-view>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="fixed pin-r pin-b m-6 max-w-sm" v-show="connectionError">
|
||||
<div class="alert error">
|
||||
There was an error while attempting to connect to the Daemon websocket. Error reported was: "{{connectionError.message}}"
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
});
|
123
resources/assets/scripts/components/server/Server.vue
Normal file
123
resources/assets/scripts/components/server/Server.vue
Normal file
|
@ -0,0 +1,123 @@
|
|||
<template>
|
||||
<div>
|
||||
<Navigation/>
|
||||
<Flash class="m-6"/>
|
||||
<div v-if="loadingServerData" class="container">
|
||||
<div class="mt-6 h-16">
|
||||
<div class="spinner spinner-xl spinner-thick blue"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="container">
|
||||
<div class="my-6 flex flex-no-shrink rounded animate fadein">
|
||||
<div class="sidebar flex-no-shrink w-1/3 max-w-xs">
|
||||
<div class="mr-6">
|
||||
<div class="p-6 text-center bg-white rounded shadow">
|
||||
<h3 class="mb-2 text-primary-500 font-medium">{{server.name}}</h3>
|
||||
<span class="text-neutral-600 text-sm">{{server.node}}</span>
|
||||
<PowerButtons class="mt-6 pt-6 text-center border-t border-neutral-100"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sidenav mt-6 mr-6">
|
||||
<ul>
|
||||
<li>
|
||||
<router-link :to="{ name: 'server', params: { id: $route.params.id } }">
|
||||
Console
|
||||
</router-link>
|
||||
</li>
|
||||
<li>
|
||||
<router-link :to="{ name: 'server-files' }">
|
||||
File Manager
|
||||
</router-link>
|
||||
</li>
|
||||
<li>
|
||||
<router-link :to="{ name: 'server-databases' }">
|
||||
Databases
|
||||
</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="h-full w-full">
|
||||
<router-view :key="server.identifier"></router-view>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="fixed pin-r pin-b m-6 max-w-sm" v-show="connectionError">
|
||||
<div class="alert error">
|
||||
There was an error while attempting to connect to the Daemon websocket. Error reported was: "{{connectionError.message}}"
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
import Navigation from '@/components/core/Navigation.vue';
|
||||
import {mapState} from 'vuex';
|
||||
import * as io from 'socket.io-client';
|
||||
import {Socketio} from "@/mixins/socketio";
|
||||
import PowerButtons from "@/components/server/components/PowerButtons.vue";
|
||||
import Flash from "@/components/Flash.vue";
|
||||
|
||||
export default Vue.extend({
|
||||
name: 'Server',
|
||||
components: {Flash, PowerButtons, Navigation},
|
||||
computed: {
|
||||
...mapState('server', ['server', 'credentials']),
|
||||
...mapState('socket', ['connected', 'connectionError']),
|
||||
},
|
||||
|
||||
mixins: [Socketio],
|
||||
|
||||
// Watch for route changes that occur with different server parameters. This occurs when a user
|
||||
// uses the search bar. Because of the way vue-router works, it won't re-mount the server component
|
||||
// so we will end up seeing the wrong server data if we don't perform this watch.
|
||||
watch: {
|
||||
'$route': function (toRoute, fromRoute) {
|
||||
if (toRoute.params.id !== fromRoute.params.id) {
|
||||
this.loadingServerData = true;
|
||||
this.loadServer();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
data: function () {
|
||||
return {
|
||||
loadingServerData: true,
|
||||
};
|
||||
},
|
||||
|
||||
mounted: function () {
|
||||
this.loadServer();
|
||||
},
|
||||
|
||||
beforeDestroy: function () {
|
||||
this.removeSocket();
|
||||
},
|
||||
|
||||
methods: {
|
||||
/**
|
||||
* Load the core server information needed for these pages to be functional.
|
||||
*/
|
||||
loadServer: function () {
|
||||
Promise.all([
|
||||
this.$store.dispatch('server/getServer', {server: this.$route.params.id}),
|
||||
this.$store.dispatch('server/getCredentials', {server: this.$route.params.id})
|
||||
])
|
||||
.then(() => {
|
||||
// Configure the socket.io implementation. This is a really ghetto way of handling things
|
||||
// but all of these plugins assume you have some constant connection, which we don't.
|
||||
const socket = io(`${this.credentials.node}/v1/ws/${this.server.uuid}`, {
|
||||
query: `token=${this.credentials.key}`,
|
||||
});
|
||||
|
||||
this.$socket().connect(socket);
|
||||
this.loadingServerData = false;
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('There was an error performing Server::loadServer', {err});
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
|
@ -1,48 +0,0 @@
|
|||
import Vue from 'vue';
|
||||
import {mapState} from 'vuex';
|
||||
import Status from '../../../helpers/statuses';
|
||||
import {Socketio} from "@/mixins/socketio";
|
||||
|
||||
export default Vue.component('power-buttons', {
|
||||
computed: {
|
||||
...mapState('socket', ['connected', 'status']),
|
||||
},
|
||||
|
||||
mixins: [Socketio],
|
||||
|
||||
data: function () {
|
||||
return {
|
||||
statuses: Status,
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
sendPowerAction: function (action: string) {
|
||||
this.$socket().instance().emit('set status', action)
|
||||
},
|
||||
},
|
||||
|
||||
template: `
|
||||
<div>
|
||||
<div v-if="connected">
|
||||
<transition name="slide-fade" mode="out-in">
|
||||
<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>
|
||||
<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>
|
||||
<button class="btn btn-secondary btn-red uppercase text-xs px-4 py-2" v-on:click.prevent="sendPowerAction('kill')">Kill</button>
|
||||
</div>
|
||||
</transition>
|
||||
</div>
|
||||
<div v-else>
|
||||
<div class="text-center">
|
||||
<div class="spinner"></div>
|
||||
<div class="pt-2 text-xs text-neutral-400">Connecting to node</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
});
|
|
@ -0,0 +1,51 @@
|
|||
<template>
|
||||
<div>
|
||||
<div v-if="connected">
|
||||
<transition name="slide-fade" mode="out-in">
|
||||
<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>
|
||||
<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>
|
||||
<button class="btn btn-secondary btn-red uppercase text-xs px-4 py-2" v-on:click.prevent="sendPowerAction('kill')">Kill</button>
|
||||
</div>
|
||||
</transition>
|
||||
</div>
|
||||
<div v-else>
|
||||
<div class="text-center">
|
||||
<div class="spinner"></div>
|
||||
<div class="pt-2 text-xs text-neutral-400">Connecting to node</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
import {mapState} from 'vuex';
|
||||
import Status from '../../../helpers/statuses';
|
||||
import {Socketio} from "@/mixins/socketio";
|
||||
|
||||
export default Vue.extend({
|
||||
name: 'PowerButtons',
|
||||
computed: {
|
||||
...mapState('socket', ['connected', 'status']),
|
||||
},
|
||||
|
||||
mixins: [Socketio],
|
||||
|
||||
data: function () {
|
||||
return {
|
||||
statuses: Status,
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
sendPowerAction: function (action: string) {
|
||||
this.$socket().instance().emit('set status', action)
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
|
@ -1,42 +0,0 @@
|
|||
import Vue from 'vue';
|
||||
|
||||
export default Vue.component('progress-bar', {
|
||||
props: {
|
||||
percent: {type: Number, default: 0},
|
||||
title: {type: String}
|
||||
},
|
||||
|
||||
computed: {
|
||||
backgroundColor: function () {
|
||||
if (this.percent < 70) {
|
||||
return "bg-green-600";
|
||||
} else if (this.percent >= 70 && this.percent < 90) {
|
||||
return "bg-yellow-dark";
|
||||
} else {
|
||||
return "bg-red-600";
|
||||
}
|
||||
},
|
||||
borderColor: function () {
|
||||
if (this.percent < 70) {
|
||||
return "border-green-600";
|
||||
} else if (this.percent >= 70 && this.percent < 90) {
|
||||
return "border-yellow-dark";
|
||||
} else {
|
||||
return "border-red-600";
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
template: `
|
||||
<div>
|
||||
<div class="text-right mb-1" v-if="title.length > 0">
|
||||
<span class="text-neutral-600 text-xs uppercase">{{ title }}</span>
|
||||
</div>
|
||||
<div class="w-full border rounded h-4" :class="borderColor">
|
||||
<div class="h-full w-1/3 text-center" :style="{ width: percent + '%' }" :class="backgroundColor">
|
||||
<span class="mt-1 text-xs text-white leading-none">{{ percent }} %</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
});
|
|
@ -1,86 +0,0 @@
|
|||
import Vue from 'vue';
|
||||
import MessageBox from "@/components/MessageBox";
|
||||
import {createDatabase} from "@/api/server/createDatabase";
|
||||
|
||||
export default Vue.component('CreateDatabaseModal', {
|
||||
components: {MessageBox},
|
||||
|
||||
data: function () {
|
||||
return {
|
||||
loading: false,
|
||||
showSpinner: false,
|
||||
database: '',
|
||||
remote: '%',
|
||||
errorMessage: '',
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
canSubmit: function () {
|
||||
return this.database.length && this.remote.length;
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
submit: function () {
|
||||
this.showSpinner = true;
|
||||
this.errorMessage = '';
|
||||
this.loading = true;
|
||||
|
||||
createDatabase(this.$route.params.id, this.database, this.remote)
|
||||
.then((response) => {
|
||||
this.$emit('database', response);
|
||||
this.$emit('close');
|
||||
})
|
||||
.catch((err: Error | string): void => {
|
||||
if (typeof err === 'string') {
|
||||
this.errorMessage = err;
|
||||
return;
|
||||
}
|
||||
|
||||
console.error('A network error was encountered while processing this request.', { err });
|
||||
})
|
||||
.then(() => {
|
||||
this.loading = false;
|
||||
this.showSpinner = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
template: `
|
||||
<div>
|
||||
<message-box class="alert error mb-6" :message="errorMessage" v-show="errorMessage.length"/>
|
||||
<h2 class="font-medium text-neutral-900 mb-6">Create a new database</h2>
|
||||
<div class="mb-6">
|
||||
<label class="input-label" for="grid-database-name">Database name</label>
|
||||
<input id="grid-database-name" type="text" class="input" name="database_name" required
|
||||
v-model="database"
|
||||
v-validate="{ alpha_dash: true, max: 100 }"
|
||||
:class="{ error: errors.has('database_name') }"
|
||||
>
|
||||
<p class="input-help error" v-show="errors.has('database_name')">{{ errors.first('database_name') }}</p>
|
||||
</div>
|
||||
<div class="mb-6">
|
||||
<label class="input-label" for="grid-database-remote">Allow connections from</label>
|
||||
<input id="grid-database-remote" type="text" class="input" name="remote" required
|
||||
v-model="remote"
|
||||
v-validate="{ regex: /^[0-9%.]{1,15}$/ }"
|
||||
:class="{ error: errors.has('remote') }"
|
||||
>
|
||||
<p class="input-help error" v-show="errors.has('remote')">{{ errors.first('remote') }}</p>
|
||||
</div>
|
||||
<div class="text-right">
|
||||
<button class="btn btn-secondary btn-sm mr-2" v-on:click.once="$emit('close')">Cancel</button>
|
||||
<button class="btn btn-primary btn-sm"
|
||||
:disabled="errors.any() || !canSubmit || showSpinner"
|
||||
v-on:click="submit"
|
||||
>
|
||||
<span class="spinner white" v-bind:class="{ hidden: !showSpinner }"> </span>
|
||||
<span :class="{ hidden: showSpinner }">
|
||||
Create
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
});
|
|
@ -0,0 +1,89 @@
|
|||
<template>
|
||||
<div>
|
||||
<MessageBox class="alert error mb-6" :message="errorMessage" v-show="errorMessage.length"/>
|
||||
<h2 class="font-medium text-neutral-900 mb-6">Create a new database</h2>
|
||||
<div class="mb-6">
|
||||
<label class="input-label" for="grid-database-name">Database name</label>
|
||||
<input id="grid-database-name" type="text" class="input" name="database_name" required
|
||||
v-model="database"
|
||||
v-validate="{ alpha_dash: true, max: 100 }"
|
||||
:class="{ error: errors.has('database_name') }"
|
||||
>
|
||||
<p class="input-help error" v-show="errors.has('database_name')">{{ errors.first('database_name') }}</p>
|
||||
</div>
|
||||
<div class="mb-6">
|
||||
<label class="input-label" for="grid-database-remote">Allow connections from</label>
|
||||
<input id="grid-database-remote" type="text" class="input" name="remote" required
|
||||
v-model="remote"
|
||||
v-validate="{ regex: /^[0-9%.]{1,15}$/ }"
|
||||
:class="{ error: errors.has('remote') }"
|
||||
>
|
||||
<p class="input-help error" v-show="errors.has('remote')">{{ errors.first('remote') }}</p>
|
||||
</div>
|
||||
<div class="text-right">
|
||||
<button class="btn btn-secondary btn-sm mr-2" v-on:click.once="$emit('close')">Cancel</button>
|
||||
<button class="btn btn-primary btn-sm"
|
||||
:disabled="errors.any() || !canSubmit || showSpinner"
|
||||
v-on:click="submit"
|
||||
>
|
||||
<span class="spinner white" v-bind:class="{ hidden: !showSpinner }"> </span>
|
||||
<span :class="{ hidden: showSpinner }">
|
||||
Create
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
import MessageBox from "@/components/MessageBox.vue";
|
||||
import {createDatabase} from "@/api/server/createDatabase";
|
||||
|
||||
export default Vue.extend({
|
||||
name: 'CreateDatabaseModal',
|
||||
components: {MessageBox},
|
||||
|
||||
data: function () {
|
||||
return {
|
||||
loading: false,
|
||||
showSpinner: false,
|
||||
database: '',
|
||||
remote: '%',
|
||||
errorMessage: '',
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
canSubmit: function () {
|
||||
return this.database.length && this.remote.length;
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
submit: function () {
|
||||
this.showSpinner = true;
|
||||
this.errorMessage = '';
|
||||
this.loading = true;
|
||||
|
||||
createDatabase(this.$route.params.id, this.database, this.remote)
|
||||
.then((response) => {
|
||||
this.$emit('database', response);
|
||||
this.$emit('close');
|
||||
})
|
||||
.catch((err: Error | string): void => {
|
||||
if (typeof err === 'string') {
|
||||
this.errorMessage = err;
|
||||
return;
|
||||
}
|
||||
|
||||
console.error('A network error was encountered while processing this request.', {err});
|
||||
})
|
||||
.then(() => {
|
||||
this.loading = false;
|
||||
this.showSpinner = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
|
@ -1,70 +0,0 @@
|
|||
import Vue from 'vue';
|
||||
import Icon from "@/components/core/Icon";
|
||||
import Modal from "@/components/core/Modal";
|
||||
import {ServerDatabase} from "@/api/server/types";
|
||||
import DeleteDatabaseModal from "@/components/server/components/database/DeleteDatabaseModal";
|
||||
|
||||
export default Vue.component('DatabaseRow', {
|
||||
components: {DeleteDatabaseModal, Modal, Icon},
|
||||
props: {
|
||||
database: {
|
||||
type: Object as () => ServerDatabase,
|
||||
required: true,
|
||||
}
|
||||
},
|
||||
|
||||
data: function () {
|
||||
return {
|
||||
showDeleteModal: false,
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
revealPassword: function () {
|
||||
this.database.showPassword = !this.database.showPassword;
|
||||
},
|
||||
},
|
||||
|
||||
template: `
|
||||
<div class="content-box mb-6 hover:border-neutral-200">
|
||||
<div class="flex items-center text-neutral-800">
|
||||
<icon name="database" class="flex-none text-green-500"></icon>
|
||||
<div class="flex-1 px-4">
|
||||
<p class="uppercase text-xs text-neutral-500 pb-1 select-none">Database Name</p>
|
||||
<p>{{database.name}}</p>
|
||||
</div>
|
||||
<div class="flex-1 px-4">
|
||||
<p class="uppercase text-xs text-neutral-500 pb-1 select-none">Username</p>
|
||||
<p>{{database.username}}</p>
|
||||
</div>
|
||||
<div class="flex-1 px-4">
|
||||
<p class="uppercase text-xs text-neutral-500 pb-1 select-none">Password</p>
|
||||
<p>
|
||||
<code class="text-sm cursor-pointer" v-on:click="revealPassword">
|
||||
<span class="select-none" v-if="!database.showPassword">
|
||||
<icon name="lock" class="h-3"/> ••••••
|
||||
</span>
|
||||
<span v-else>{{database.password}}</span>
|
||||
</code>
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex-1 px-4">
|
||||
<p class="uppercase text-xs text-neutral-500 pb-1 select-none">Server</p>
|
||||
<p><code class="text-sm">{{database.host.address}}:{{database.host.port}}</code></p>
|
||||
</div>
|
||||
<div class="flex-none px-4">
|
||||
<button class="btn btn-xs btn-secondary btn-red" v-on:click="showDeleteModal = true">
|
||||
<icon name="trash-2" class="w-3 h-3 mx-1"/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<modal :show="showDeleteModal" v-on:close="showDeleteModal = false">
|
||||
<DeleteDatabaseModal
|
||||
:database="database"
|
||||
v-on:close="showDeleteModal = false"
|
||||
v-if="showDeleteModal"
|
||||
/>
|
||||
</modal>
|
||||
</div>
|
||||
`,
|
||||
})
|
|
@ -0,0 +1,73 @@
|
|||
<template>
|
||||
<div class="content-box mb-6 hover:border-neutral-200">
|
||||
<div class="flex items-center text-neutral-800">
|
||||
<Icon name="database" class="flex-none text-green-500"></icon>
|
||||
<div class="flex-1 px-4">
|
||||
<p class="uppercase text-xs text-neutral-500 pb-1 select-none">Database Name</p>
|
||||
<p>{{database.name}}</p>
|
||||
</div>
|
||||
<div class="flex-1 px-4">
|
||||
<p class="uppercase text-xs text-neutral-500 pb-1 select-none">Username</p>
|
||||
<p>{{database.username}}</p>
|
||||
</div>
|
||||
<div class="flex-1 px-4">
|
||||
<p class="uppercase text-xs text-neutral-500 pb-1 select-none">Password</p>
|
||||
<p>
|
||||
<code class="text-sm cursor-pointer" v-on:click="revealPassword">
|
||||
<span class="select-none" v-if="!database.showPassword">
|
||||
<Icon name="lock" class="h-3"/> ••••••
|
||||
</span>
|
||||
<span v-else>{{database.password}}</span>
|
||||
</code>
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex-1 px-4">
|
||||
<p class="uppercase text-xs text-neutral-500 pb-1 select-none">Server</p>
|
||||
<p><code class="text-sm">{{database.host.address}}:{{database.host.port}}</code></p>
|
||||
</div>
|
||||
<div class="flex-none px-4">
|
||||
<button class="btn btn-xs btn-secondary btn-red" v-on:click="showDeleteModal = true">
|
||||
<Icon name="trash-2" class="w-3 h-3 mx-1"/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<Modal :show="showDeleteModal" v-on:close="showDeleteModal = false">
|
||||
<DeleteDatabaseModal
|
||||
:database="database"
|
||||
v-on:close="showDeleteModal = false"
|
||||
v-if="showDeleteModal"
|
||||
/>
|
||||
</modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
import Icon from "@/components/core/Icon.vue";
|
||||
import Modal from "@/components/core/Modal.vue";
|
||||
import {ServerDatabase} from "@/api/server/types";
|
||||
import DeleteDatabaseModal from "@/components/server/components/database/DeleteDatabaseModal.vue";
|
||||
|
||||
export default Vue.extend({
|
||||
name: 'DatabaseRow',
|
||||
components: {DeleteDatabaseModal, Modal, Icon},
|
||||
props: {
|
||||
database: {
|
||||
type: Object as () => ServerDatabase,
|
||||
required: true,
|
||||
}
|
||||
},
|
||||
|
||||
data: function () {
|
||||
return {
|
||||
showDeleteModal: false,
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
revealPassword: function () {
|
||||
this.database.showPassword = !this.database.showPassword;
|
||||
},
|
||||
},
|
||||
})
|
||||
</script>
|
|
@ -1,84 +0,0 @@
|
|||
import Vue from 'vue';
|
||||
import {ServerDatabase} from "@/api/server/types";
|
||||
|
||||
export default Vue.component('DeleteDatabaseModal', {
|
||||
props: {
|
||||
database: {
|
||||
type: Object as () => ServerDatabase,
|
||||
required: true
|
||||
},
|
||||
},
|
||||
|
||||
data: function () {
|
||||
return {
|
||||
showSpinner: false,
|
||||
nameConfirmation: '',
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
/**
|
||||
* Determine if the 'Delete' button should be enabled or not. This requires the user
|
||||
* to enter the database name before actually deleting the DB.
|
||||
*/
|
||||
disabled: function () {
|
||||
const splits: Array<string> = this.database.name.split('_');
|
||||
|
||||
return (
|
||||
this.nameConfirmation !== this.database.name && this.nameConfirmation !== splits.slice(1).join('_')
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
/**
|
||||
* Handle deleting the database for the server instance.
|
||||
*/
|
||||
deleteDatabase: function () {
|
||||
this.nameConfirmation = '';
|
||||
this.showSpinner = true;
|
||||
|
||||
window.axios.delete(this.route('api.client.servers.databases.delete', {
|
||||
server: this.$route.params.id,
|
||||
database: this.database.id,
|
||||
}))
|
||||
.then(() => {
|
||||
window.events.$emit('server:deleted-database', this.database.id);
|
||||
})
|
||||
.catch(err => {
|
||||
this.$flash.clear();
|
||||
console.error({ err });
|
||||
|
||||
const response = err.response;
|
||||
if (response.data && typeof response.data.errors === 'object') {
|
||||
response.data.errors.forEach((error: any) => {
|
||||
this.$flash.error(error.detail);
|
||||
});
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
this.$emit('close');
|
||||
})
|
||||
},
|
||||
},
|
||||
|
||||
template: `
|
||||
<div>
|
||||
<h2 class="font-medium text-neutral-900 mb-6">Delete this database?</h2>
|
||||
<p class="text-neutral-900 text-sm">This action <strong>cannot</strong> be undone. This will permanetly delete the <strong>{{database.name}}</strong> database and remove all associated data.</p>
|
||||
<div class="mt-6">
|
||||
<label class="input-label">Confirm database name</label>
|
||||
<input type="text" class="input" v-model="nameConfirmation"/>
|
||||
</div>
|
||||
<div class="mt-6 text-right">
|
||||
<button class="btn btn-sm btn-secondary mr-2" v-on:click="$emit('close')">Cancel</button>
|
||||
<button class="btn btn-sm btn-red" :disabled="disabled" v-on:click="deleteDatabase">
|
||||
<span class="spinner white" v-bind:class="{ hidden: !showSpinner }"> </span>
|
||||
<span :class="{ hidden: showSpinner }">
|
||||
Confirm Deletion
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
});
|
|
@ -0,0 +1,89 @@
|
|||
<template>
|
||||
<div>
|
||||
<h2 class="font-medium text-neutral-900 mb-6">Delete this database?</h2>
|
||||
<p class="text-neutral-900 text-sm">This action
|
||||
<strong>cannot</strong> be undone. This will permanetly delete the
|
||||
<strong>{{database.name}}</strong> database and remove all associated data.</p>
|
||||
<div class="mt-6">
|
||||
<label class="input-label">Confirm database name</label>
|
||||
<input type="text" class="input" v-model="nameConfirmation"/>
|
||||
</div>
|
||||
<div class="mt-6 text-right">
|
||||
<button class="btn btn-sm btn-secondary mr-2" v-on:click="$emit('close')">Cancel</button>
|
||||
<button class="btn btn-sm btn-red" :disabled="disabled" v-on:click="deleteDatabase">
|
||||
<span class="spinner white" v-bind:class="{ hidden: !showSpinner }"> </span>
|
||||
<span :class="{ hidden: showSpinner }">
|
||||
Confirm Deletion
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
import {ServerDatabase} from "@/api/server/types";
|
||||
|
||||
export default Vue.extend({
|
||||
name: 'DeleteDatabaseModal',
|
||||
props: {
|
||||
database: {
|
||||
type: Object as () => ServerDatabase,
|
||||
required: true
|
||||
},
|
||||
},
|
||||
|
||||
data: function () {
|
||||
return {
|
||||
showSpinner: false,
|
||||
nameConfirmation: '',
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
/**
|
||||
* Determine if the 'Delete' button should be enabled or not. This requires the user
|
||||
* to enter the database name before actually deleting the DB.
|
||||
*/
|
||||
disabled: function () {
|
||||
const splits: Array<string> = this.database.name.split('_');
|
||||
|
||||
return (
|
||||
this.nameConfirmation !== this.database.name && this.nameConfirmation !== splits.slice(1).join('_')
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
/**
|
||||
* Handle deleting the database for the server instance.
|
||||
*/
|
||||
deleteDatabase: function () {
|
||||
this.nameConfirmation = '';
|
||||
this.showSpinner = true;
|
||||
|
||||
window.axios.delete(this.route('api.client.servers.databases.delete', {
|
||||
server: this.$route.params.id,
|
||||
database: this.database.id,
|
||||
}))
|
||||
.then(() => {
|
||||
window.events.$emit('server:deleted-database', this.database.id);
|
||||
})
|
||||
.catch(err => {
|
||||
this.$flash.clear();
|
||||
console.error({err});
|
||||
|
||||
const response = err.response;
|
||||
if (response.data && typeof response.data.errors === 'object') {
|
||||
response.data.errors.forEach((error: any) => {
|
||||
this.$flash.error(error.detail);
|
||||
});
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
this.$emit('close');
|
||||
})
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
|
@ -1,59 +0,0 @@
|
|||
import Vue from 'vue';
|
||||
import Icon from "../../../core/Icon";
|
||||
|
||||
export default Vue.component('file-context-menu', {
|
||||
components: { Icon },
|
||||
|
||||
template: `
|
||||
<div class="context-menu">
|
||||
<div>
|
||||
<div class="context-row">
|
||||
<div class="icon">
|
||||
<icon name="edit-3"/>
|
||||
</div>
|
||||
<div class="action"><span>Rename</span></div>
|
||||
</div>
|
||||
<div class="context-row">
|
||||
<div class="icon">
|
||||
<icon name="corner-up-left" class="h-4"/>
|
||||
</div>
|
||||
<div class="action"><span class="text-left">Move</span></div>
|
||||
</div>
|
||||
<div class="context-row">
|
||||
<div class="icon">
|
||||
<icon name="copy" class="h-4"/>
|
||||
</div>
|
||||
<div class="action">Copy</div>
|
||||
</div>
|
||||
<div class="context-row">
|
||||
<div class="icon">
|
||||
<icon name="download" class="h-4"/>
|
||||
</div>
|
||||
<div class="action">Download</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="context-row">
|
||||
<div class="icon">
|
||||
<icon name="file-plus" class="h-4"/>
|
||||
</div>
|
||||
<div class="action">New File</div>
|
||||
</div>
|
||||
<div class="context-row">
|
||||
<div class="icon">
|
||||
<icon name="folder-plus" class="h-4"/>
|
||||
</div>
|
||||
<div class="action">New Folder</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="context-row danger">
|
||||
<div class="icon">
|
||||
<icon name="delete" class="h-4"/>
|
||||
</div>
|
||||
<div class="action">Delete</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
})
|
|
@ -0,0 +1,62 @@
|
|||
<template>
|
||||
<div class="context-menu">
|
||||
<div>
|
||||
<div class="context-row">
|
||||
<div class="icon">
|
||||
<Icon name="edit-3"/>
|
||||
</div>
|
||||
<div class="action"><span>Rename</span></div>
|
||||
</div>
|
||||
<div class="context-row">
|
||||
<div class="icon">
|
||||
<Icon name="corner-up-left" class="h-4"/>
|
||||
</div>
|
||||
<div class="action"><span class="text-left">Move</span></div>
|
||||
</div>
|
||||
<div class="context-row">
|
||||
<div class="icon">
|
||||
<Icon name="copy" class="h-4"/>
|
||||
</div>
|
||||
<div class="action">Copy</div>
|
||||
</div>
|
||||
<div class="context-row">
|
||||
<div class="icon">
|
||||
<Icon name="download" class="h-4"/>
|
||||
</div>
|
||||
<div class="action">Download</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="context-row">
|
||||
<div class="icon">
|
||||
<Icon name="file-plus" class="h-4"/>
|
||||
</div>
|
||||
<div class="action">New File</div>
|
||||
</div>
|
||||
<div class="context-row">
|
||||
<div class="icon">
|
||||
<Icon name="folder-plus" class="h-4"/>
|
||||
</div>
|
||||
<div class="action">New Folder</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="context-row danger">
|
||||
<div class="icon">
|
||||
<Icon name="delete" class="h-4"/>
|
||||
</div>
|
||||
<div class="action">Delete</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
import Icon from "../../../core/Icon.vue";
|
||||
|
||||
export default Vue.extend({
|
||||
name: 'FileContextMenu',
|
||||
components: { Icon },
|
||||
});
|
||||
</script>
|
|
@ -1,99 +0,0 @@
|
|||
import Vue from 'vue';
|
||||
import Icon from "../../../core/Icon";
|
||||
import {Vue as VueType} from "vue/types/vue";
|
||||
import { readableSize, formatDate } from '../../../../helpers'
|
||||
import FileContextMenu from "./FileContextMenu";
|
||||
|
||||
export default Vue.component('file-row', {
|
||||
components: {
|
||||
Icon,
|
||||
FileContextMenu,
|
||||
},
|
||||
|
||||
props: {
|
||||
file: {type: Object, required: true},
|
||||
editable: {type: Array, required: true}
|
||||
},
|
||||
|
||||
data: function () {
|
||||
return {
|
||||
contextMenuVisible: false,
|
||||
};
|
||||
},
|
||||
|
||||
mounted: function () {
|
||||
document.addEventListener('click', this._clickListener);
|
||||
|
||||
// If the parent component emits the collapse menu event check if the unique ID of the component
|
||||
// is this one. If not, collapse the menu (we right clicked into another element).
|
||||
this.$parent.$on('collapse-menus', (uid: string) => {
|
||||
// @ts-ignore
|
||||
if (this._uid !== uid) {
|
||||
this.contextMenuVisible = false;
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
beforeDestroy: function () {
|
||||
document.removeEventListener('click', this._clickListener, false);
|
||||
},
|
||||
|
||||
methods: {
|
||||
/**
|
||||
* Handle a right-click action on a file manager row.
|
||||
*/
|
||||
showContextMenu: function (e: MouseEvent) {
|
||||
e.preventDefault();
|
||||
|
||||
// @ts-ignore
|
||||
this.$parent.$emit('collapse-menus', this._uid);
|
||||
|
||||
this.contextMenuVisible = true;
|
||||
|
||||
const menuWidth = (this.$refs.contextMenu as VueType).$el.clientWidth;
|
||||
const positionElement = e.clientX - Math.round(menuWidth / 2);
|
||||
|
||||
(this.$refs.contextMenu as VueType).$el.setAttribute('style', `left: ${positionElement}; top: ${e.clientY}`);
|
||||
},
|
||||
|
||||
/**
|
||||
* Determine if a file can be edited on the Panel.
|
||||
*/
|
||||
canEdit: function (file: any): boolean {
|
||||
return this.editable.indexOf(file.mime) >= 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle a click anywhere in the document and hide the context menu if that click is not
|
||||
* a right click and isn't occurring somewhere in the currently visible context menu.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
_clickListener: function (e: MouseEvent) {
|
||||
if (e.button !== 2 && this.contextMenuVisible) {
|
||||
if (e.target !== (this.$refs.contextMenu as VueType).$el && !(this.$refs.contextMenu as VueType).$el.contains(e.target as Node)) {
|
||||
this.contextMenuVisible = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
readableSize: readableSize,
|
||||
formatDate: formatDate,
|
||||
},
|
||||
|
||||
template: `
|
||||
<div>
|
||||
<div class="row" :class="{ clickable: canEdit(file), 'active-selection': contextMenuVisible }" v-on:contextmenu="showContextMenu">
|
||||
<div class="flex-none icon">
|
||||
<icon name="file-text" v-if="!file.symlink"/>
|
||||
<icon name="link2" v-else/>
|
||||
</div>
|
||||
<div class="flex-1">{{file.name}}</div>
|
||||
<div class="flex-1 text-right text-neutral-600">{{readableSize(file.size)}}</div>
|
||||
<div class="flex-1 text-right text-neutral-600">{{formatDate(file.modified)}}</div>
|
||||
<div class="flex-none w-1/6"></div>
|
||||
</div>
|
||||
<file-context-menu class="context-menu" v-show="contextMenuVisible" ref="contextMenu"/>
|
||||
</div>
|
||||
`
|
||||
});
|
|
@ -0,0 +1,102 @@
|
|||
<template>
|
||||
<div>
|
||||
<div class="row" :class="{ clickable: canEdit(file), 'active-selection': contextMenuVisible }" v-on:contextmenu="showContextMenu">
|
||||
<div class="flex-none icon">
|
||||
<Icon name="file-text" v-if="!file.symlink"/>
|
||||
<Icon name="link2" v-else/>
|
||||
</div>
|
||||
<div class="flex-1">{{file.name}}</div>
|
||||
<div class="flex-1 text-right text-neutral-600">{{readableSize(file.size)}}</div>
|
||||
<div class="flex-1 text-right text-neutral-600">{{formatDate(file.modified)}}</div>
|
||||
<div class="flex-none w-1/6"></div>
|
||||
</div>
|
||||
<FileContextMenu class="context-menu" v-show="contextMenuVisible" ref="contextMenu"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
import Icon from "../../../core/Icon.vue";
|
||||
import {Vue as VueType} from "vue/types/vue";
|
||||
import {formatDate, readableSize} from '../../../../helpers'
|
||||
import FileContextMenu from "./FileContextMenu.vue";
|
||||
|
||||
export default Vue.extend({
|
||||
name: 'FileRow',
|
||||
components: {
|
||||
Icon,
|
||||
FileContextMenu,
|
||||
},
|
||||
|
||||
props: {
|
||||
file: {type: Object, required: true},
|
||||
editable: {type: Array, required: true}
|
||||
},
|
||||
|
||||
data: function () {
|
||||
return {
|
||||
contextMenuVisible: false,
|
||||
};
|
||||
},
|
||||
|
||||
mounted: function () {
|
||||
document.addEventListener('click', this._clickListener);
|
||||
|
||||
// If the parent component emits the collapse menu event check if the unique ID of the component
|
||||
// is this one. If not, collapse the menu (we right clicked into another element).
|
||||
this.$parent.$on('collapse-menus', (uid: string) => {
|
||||
// @ts-ignore
|
||||
if (this._uid !== uid) {
|
||||
this.contextMenuVisible = false;
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
beforeDestroy: function () {
|
||||
document.removeEventListener('click', this._clickListener, false);
|
||||
},
|
||||
|
||||
methods: {
|
||||
/**
|
||||
* Handle a right-click action on a file manager row.
|
||||
*/
|
||||
showContextMenu: function (e: MouseEvent) {
|
||||
e.preventDefault();
|
||||
|
||||
// @ts-ignore
|
||||
this.$parent.$emit('collapse-menus', this._uid);
|
||||
|
||||
this.contextMenuVisible = true;
|
||||
|
||||
const menuWidth = (this.$refs.contextMenu as VueType).$el.clientWidth;
|
||||
const positionElement = e.clientX - Math.round(menuWidth / 2);
|
||||
|
||||
(this.$refs.contextMenu as VueType).$el.setAttribute('style', `left: ${positionElement}; top: ${e.clientY}`);
|
||||
},
|
||||
|
||||
/**
|
||||
* Determine if a file can be edited on the Panel.
|
||||
*/
|
||||
canEdit: function (file: any): boolean {
|
||||
return this.editable.indexOf(file.mime) >= 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle a click anywhere in the document and hide the context menu if that click is not
|
||||
* a right click and isn't occurring somewhere in the currently visible context menu.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
_clickListener: function (e: MouseEvent) {
|
||||
if (e.button !== 2 && this.contextMenuVisible) {
|
||||
if (e.target !== (this.$refs.contextMenu as VueType).$el && !(this.$refs.contextMenu as VueType).$el.contains(e.target as Node)) {
|
||||
this.contextMenuVisible = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
readableSize: readableSize,
|
||||
formatDate: formatDate,
|
||||
},
|
||||
});
|
||||
</script>
|
|
@ -1,44 +0,0 @@
|
|||
import Vue from 'vue';
|
||||
import { formatDate } from "@/helpers";
|
||||
import Icon from "@/components/core/Icon";
|
||||
|
||||
export default Vue.component('folder-row', {
|
||||
components: { Icon },
|
||||
|
||||
props: {
|
||||
directory: {type: Object, required: true},
|
||||
},
|
||||
|
||||
data: function () {
|
||||
return {
|
||||
currentDirectory: this.$route.params.path || '/',
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
/**
|
||||
* Return a formatted directory path that is used to switch to a nested directory.
|
||||
*/
|
||||
getClickablePath (directory: string): string {
|
||||
return `${this.currentDirectory.replace(/\/$/, '')}/${directory}`;
|
||||
},
|
||||
|
||||
formatDate: formatDate,
|
||||
},
|
||||
|
||||
template: `
|
||||
<div>
|
||||
<router-link class="row clickable"
|
||||
:to="{ name: 'server-files', params: { path: getClickablePath(directory.name).replace(/^\\//, '') }}"
|
||||
>
|
||||
<div class="flex-none icon text-primary-700">
|
||||
<icon name="folder"/>
|
||||
</div>
|
||||
<div class="flex-1">{{directory.name}}</div>
|
||||
<div class="flex-1 text-right text-neutral-600"></div>
|
||||
<div class="flex-1 text-right text-neutral-600">{{formatDate(directory.modified)}}</div>
|
||||
<div class="flex-none w-1/6"></div>
|
||||
</router-link>
|
||||
</div>
|
||||
`
|
||||
});
|
|
@ -0,0 +1,47 @@
|
|||
<template>
|
||||
<div>
|
||||
<router-link class="row clickable"
|
||||
:to="{ name: 'server-files', params: { path: getClickablePath(directory.name) }}"
|
||||
>
|
||||
<div class="flex-none icon text-primary-700">
|
||||
<Icon name="folder"/>
|
||||
</div>
|
||||
<div class="flex-1">{{directory.name}}</div>
|
||||
<div class="flex-1 text-right text-neutral-600"></div>
|
||||
<div class="flex-1 text-right text-neutral-600">{{formatDate(directory.modified)}}</div>
|
||||
<div class="flex-none w-1/6"></div>
|
||||
</router-link>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
import { formatDate } from "@/helpers";
|
||||
import Icon from "@/components/core/Icon.vue";
|
||||
|
||||
export default Vue.extend({
|
||||
name: 'FolderRow',
|
||||
components: { Icon },
|
||||
|
||||
props: {
|
||||
directory: {type: Object, required: true},
|
||||
},
|
||||
|
||||
data: function () {
|
||||
return {
|
||||
currentDirectory: this.$route.params.path || '/',
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
/**
|
||||
* Return a formatted directory path that is used to switch to a nested directory.
|
||||
*/
|
||||
getClickablePath (directory: string): string {
|
||||
return `${this.currentDirectory.replace(/\/$/, '')}/${directory}`;
|
||||
},
|
||||
|
||||
formatDate: formatDate,
|
||||
},
|
||||
});
|
||||
</script>
|
|
@ -1,4 +0,0 @@
|
|||
export {default as Server} from './Server';
|
||||
export {default as ConsolePage} from './subpages/Console';
|
||||
export {default as DatabasesPage} from './subpages/Databases';
|
||||
export {default as FileManagerPage} from './subpages/FileManager';
|
|
@ -1,186 +0,0 @@
|
|||
import Vue from 'vue';
|
||||
import {mapState} from "vuex";
|
||||
import {Terminal} from 'xterm';
|
||||
import * as TerminalFit from 'xterm/lib/addons/fit/fit';
|
||||
import {Socketio} from "@/mixins/socketio";
|
||||
|
||||
type DataStructure = {
|
||||
terminal: Terminal | null,
|
||||
command: string,
|
||||
commandHistory: Array<string>,
|
||||
commandHistoryIndex: number,
|
||||
}
|
||||
|
||||
export default Vue.component('server-console', {
|
||||
mixins: [Socketio],
|
||||
computed: {
|
||||
...mapState('socket', ['connected']),
|
||||
},
|
||||
|
||||
watch: {
|
||||
/**
|
||||
* Watch the connected variable and when it becomes true request the server logs.
|
||||
*/
|
||||
connected: function (state: boolean) {
|
||||
if (state) {
|
||||
this.$nextTick(() => {
|
||||
this.mountTerminal();
|
||||
});
|
||||
} else {
|
||||
this.terminal && this.terminal.clear();
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Listen for specific socket.io emits from the server.
|
||||
*/
|
||||
sockets: {
|
||||
'server log': function (data: string) {
|
||||
data.split(/\n/g).forEach((line: string): void => {
|
||||
if (this.terminal) {
|
||||
this.terminal.writeln(line + '\u001b[0m');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
'console': function (data: { line: string }) {
|
||||
data.line.split(/\n/g).forEach((line: string): void => {
|
||||
if (this.terminal) {
|
||||
this.terminal.writeln(line + '\u001b[0m');
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Mount the component and setup all of the terminal actions. Also fetches the initial
|
||||
* logs from the server to populate into the terminal if the socket is connected. If the
|
||||
* socket is not connected this will occur automatically when it connects.
|
||||
*/
|
||||
mounted: function () {
|
||||
if (this.connected) {
|
||||
this.mountTerminal();
|
||||
}
|
||||
},
|
||||
|
||||
data: function (): DataStructure {
|
||||
return {
|
||||
terminal: null,
|
||||
command: '',
|
||||
commandHistory: [],
|
||||
commandHistoryIndex: -1,
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
/**
|
||||
* Mount the terminal and grab the most recent server logs.
|
||||
*/
|
||||
mountTerminal: function () {
|
||||
// Get a new instance of the terminal setup.
|
||||
this.terminal = this._terminalInstance();
|
||||
|
||||
this.terminal.open((this.$refs.terminal as HTMLElement));
|
||||
// @ts-ignore
|
||||
this.terminal.fit();
|
||||
this.terminal.clear();
|
||||
|
||||
this.$socket().instance().emit('send server log');
|
||||
},
|
||||
|
||||
/**
|
||||
* Send a command to the server using the configured websocket.
|
||||
*/
|
||||
sendCommand: function () {
|
||||
this.commandHistoryIndex = -1;
|
||||
this.commandHistory.unshift(this.command);
|
||||
this.$socket().instance().emit('send command', this.command);
|
||||
this.command = '';
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle a user pressing up/down arrows when in the command field to scroll through thier
|
||||
* command history for this server.
|
||||
*/
|
||||
handleArrowKey: function (e: KeyboardEvent) {
|
||||
if (['ArrowUp', 'ArrowDown'].indexOf(e.key) < 0 || e.key === 'ArrowDown' && this.commandHistoryIndex < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
if (e.key === 'ArrowUp' && (this.commandHistoryIndex + 1 > (this.commandHistory.length - 1))) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.commandHistoryIndex += (e.key === 'ArrowUp') ? 1 : -1;
|
||||
this.command = this.commandHistoryIndex < 0 ? '' : this.commandHistory[this.commandHistoryIndex];
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a new instance of the terminal to be used.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
_terminalInstance() {
|
||||
Terminal.applyAddon(TerminalFit);
|
||||
|
||||
return new Terminal({
|
||||
disableStdin: true,
|
||||
cursorStyle: 'underline',
|
||||
allowTransparency: true,
|
||||
fontSize: 12,
|
||||
fontFamily: 'Menlo, Monaco, Consolas, monospace',
|
||||
rows: 30,
|
||||
theme: {
|
||||
background: 'transparent',
|
||||
cursor: 'transparent',
|
||||
black: '#000000',
|
||||
red: '#E54B4B',
|
||||
green: '#9ECE58',
|
||||
yellow: '#FAED70',
|
||||
blue: '#396FE2',
|
||||
magenta: '#BB80B3',
|
||||
cyan: '#2DDAFD',
|
||||
white: '#d0d0d0',
|
||||
brightBlack: 'rgba(255, 255, 255, 0.2)',
|
||||
brightRed: '#FF5370',
|
||||
brightGreen: '#C3E88D',
|
||||
brightYellow: '#FFCB6B',
|
||||
brightBlue: '#82AAFF',
|
||||
brightMagenta: '#C792EA',
|
||||
brightCyan: '#89DDFF',
|
||||
brightWhite: '#ffffff',
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
template: `
|
||||
<div class="animate fadein shadow-md">
|
||||
<div class="text-xs font-mono">
|
||||
<div class="rounded-t p-2 bg-black overflow-scroll w-full" style="min-height: 16rem;max-height:64rem;">
|
||||
<div class="mb-2 text-neutral-400" ref="terminal" v-if="connected"></div>
|
||||
<div v-else>
|
||||
<div class="spinner spinner-xl mt-24"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="rounded-b bg-neutral-900 text-white flex">
|
||||
<div class="flex-no-shrink p-2">
|
||||
<span class="font-bold">$</span>
|
||||
</div>
|
||||
<div class="w-full">
|
||||
<input type="text" aria-label="Send console command" class="bg-transparent text-white p-2 pl-0 w-full" placeholder="enter command and press enter to send"
|
||||
ref="command"
|
||||
v-model="command"
|
||||
v-on:keyup.enter="sendCommand"
|
||||
v-on:keydown="handleArrowKey"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
});
|
189
resources/assets/scripts/components/server/subpages/Console.vue
Normal file
189
resources/assets/scripts/components/server/subpages/Console.vue
Normal file
|
@ -0,0 +1,189 @@
|
|||
<template>
|
||||
<div class="animate fadein shadow-md">
|
||||
<div class="text-xs font-mono">
|
||||
<div class="rounded-t p-2 bg-black overflow-scroll w-full" style="min-height: 16rem;max-height:64rem;">
|
||||
<div class="mb-2 text-neutral-400" ref="terminal" v-if="connected"></div>
|
||||
<div v-else>
|
||||
<div class="spinner spinner-xl mt-24"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="rounded-b bg-neutral-900 text-white flex">
|
||||
<div class="flex-no-shrink p-2">
|
||||
<span class="font-bold">$</span>
|
||||
</div>
|
||||
<div class="w-full">
|
||||
<input type="text" aria-label="Send console command" class="bg-transparent text-white p-2 pl-0 w-full" placeholder="enter command and press enter to send"
|
||||
ref="command"
|
||||
v-model="command"
|
||||
v-on:keyup.enter="sendCommand"
|
||||
v-on:keydown="handleArrowKey"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
import {mapState} from "vuex";
|
||||
import {Terminal} from 'xterm';
|
||||
import * as TerminalFit from 'xterm/lib/addons/fit/fit';
|
||||
import {Socketio} from "@/mixins/socketio";
|
||||
|
||||
type DataStructure = {
|
||||
terminal: Terminal | null,
|
||||
command: string,
|
||||
commandHistory: Array<string>,
|
||||
commandHistoryIndex: number,
|
||||
}
|
||||
|
||||
export default Vue.extend({
|
||||
name: 'ServerConsole',
|
||||
mixins: [Socketio],
|
||||
computed: {
|
||||
...mapState('socket', ['connected']),
|
||||
},
|
||||
|
||||
watch: {
|
||||
/**
|
||||
* Watch the connected variable and when it becomes true request the server logs.
|
||||
*/
|
||||
connected: function (state: boolean) {
|
||||
if (state) {
|
||||
this.$nextTick(() => {
|
||||
this.mountTerminal();
|
||||
});
|
||||
} else {
|
||||
this.terminal && this.terminal.clear();
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Listen for specific socket.io emits from the server.
|
||||
*/
|
||||
sockets: {
|
||||
'server log': function (data: string) {
|
||||
data.split(/\n/g).forEach((line: string): void => {
|
||||
if (this.terminal) {
|
||||
this.terminal.writeln(line + '\u001b[0m');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
'console': function (data: { line: string }) {
|
||||
data.line.split(/\n/g).forEach((line: string): void => {
|
||||
if (this.terminal) {
|
||||
this.terminal.writeln(line + '\u001b[0m');
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Mount the component and setup all of the terminal actions. Also fetches the initial
|
||||
* logs from the server to populate into the terminal if the socket is connected. If the
|
||||
* socket is not connected this will occur automatically when it connects.
|
||||
*/
|
||||
mounted: function () {
|
||||
if (this.connected) {
|
||||
this.mountTerminal();
|
||||
}
|
||||
},
|
||||
|
||||
data: function (): DataStructure {
|
||||
return {
|
||||
terminal: null,
|
||||
command: '',
|
||||
commandHistory: [],
|
||||
commandHistoryIndex: -1,
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
/**
|
||||
* Mount the terminal and grab the most recent server logs.
|
||||
*/
|
||||
mountTerminal: function () {
|
||||
// Get a new instance of the terminal setup.
|
||||
this.terminal = this._terminalInstance();
|
||||
|
||||
this.terminal.open((this.$refs.terminal as HTMLElement));
|
||||
// @ts-ignore
|
||||
this.terminal.fit();
|
||||
this.terminal.clear();
|
||||
|
||||
this.$socket().instance().emit('send server log');
|
||||
},
|
||||
|
||||
/**
|
||||
* Send a command to the server using the configured websocket.
|
||||
*/
|
||||
sendCommand: function () {
|
||||
this.commandHistoryIndex = -1;
|
||||
this.commandHistory.unshift(this.command);
|
||||
this.$socket().instance().emit('send command', this.command);
|
||||
this.command = '';
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle a user pressing up/down arrows when in the command field to scroll through thier
|
||||
* command history for this server.
|
||||
*/
|
||||
handleArrowKey: function (e: KeyboardEvent) {
|
||||
if (['ArrowUp', 'ArrowDown'].indexOf(e.key) < 0 || e.key === 'ArrowDown' && this.commandHistoryIndex < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
if (e.key === 'ArrowUp' && (this.commandHistoryIndex + 1 > (this.commandHistory.length - 1))) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.commandHistoryIndex += (e.key === 'ArrowUp') ? 1 : -1;
|
||||
this.command = this.commandHistoryIndex < 0 ? '' : this.commandHistory[this.commandHistoryIndex];
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a new instance of the terminal to be used.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
_terminalInstance() {
|
||||
Terminal.applyAddon(TerminalFit);
|
||||
|
||||
return new Terminal({
|
||||
disableStdin: true,
|
||||
cursorStyle: 'underline',
|
||||
allowTransparency: true,
|
||||
fontSize: 12,
|
||||
fontFamily: 'Menlo, Monaco, Consolas, monospace',
|
||||
rows: 30,
|
||||
theme: {
|
||||
background: 'transparent',
|
||||
cursor: 'transparent',
|
||||
black: '#000000',
|
||||
red: '#E54B4B',
|
||||
green: '#9ECE58',
|
||||
yellow: '#FAED70',
|
||||
blue: '#396FE2',
|
||||
magenta: '#BB80B3',
|
||||
cyan: '#2DDAFD',
|
||||
white: '#d0d0d0',
|
||||
brightBlack: 'rgba(255, 255, 255, 0.2)',
|
||||
brightRed: '#FF5370',
|
||||
brightGreen: '#C3E88D',
|
||||
brightYellow: '#FFCB6B',
|
||||
brightBlue: '#82AAFF',
|
||||
brightMagenta: '#C792EA',
|
||||
brightCyan: '#89DDFF',
|
||||
brightWhite: '#ffffff',
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
|
@ -1,112 +0,0 @@
|
|||
import Vue from 'vue';
|
||||
import { map, filter } from 'lodash';
|
||||
import Modal from '@/components/core/Modal';
|
||||
import CreateDatabaseModal from './../components/database/CreateDatabaseModal';
|
||||
import Icon from "@/components/core/Icon";
|
||||
import {ServerDatabase} from "@/api/server/types";
|
||||
import DatabaseRow from "@/components/server/components/database/DatabaseRow";
|
||||
|
||||
type DataStructure = {
|
||||
loading: boolean,
|
||||
showCreateModal: boolean,
|
||||
databases: Array<ServerDatabase>,
|
||||
}
|
||||
|
||||
export default Vue.component('server-databases', {
|
||||
components: {DatabaseRow, CreateDatabaseModal, Modal, Icon },
|
||||
|
||||
data: function (): DataStructure {
|
||||
return {
|
||||
databases: [],
|
||||
loading: true,
|
||||
showCreateModal: false,
|
||||
};
|
||||
},
|
||||
|
||||
mounted: function () {
|
||||
this.getDatabases();
|
||||
|
||||
window.events.$on('server:deleted-database', this.removeDatabase);
|
||||
},
|
||||
|
||||
methods: {
|
||||
/**
|
||||
* Get all of the databases that exist for this server.
|
||||
*/
|
||||
getDatabases: function () {
|
||||
this.$flash.clear();
|
||||
this.loading = true;
|
||||
|
||||
window.axios.get(this.route('api.client.servers.databases', {
|
||||
server: this.$route.params.id,
|
||||
include: 'password'
|
||||
}))
|
||||
.then(response => {
|
||||
this.databases = map(response.data.data, (object) => {
|
||||
const data = object.attributes;
|
||||
|
||||
data.password = data.relationships.password.attributes.password;
|
||||
data.showPassword = false;
|
||||
delete data.relationships;
|
||||
|
||||
return data;
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
this.$flash.error('There was an error encountered while attempting to fetch databases for this server.');
|
||||
console.error(err);
|
||||
})
|
||||
.then(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Add the database to the list of existing databases automatically when the modal
|
||||
* is closed with a successful callback.
|
||||
*/
|
||||
handleModalCallback: function (data: ServerDatabase) {
|
||||
this.databases.push(data);
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle event that is removing a database.
|
||||
*/
|
||||
removeDatabase: function (databaseId: string) {
|
||||
this.databases = filter(this.databases, (database) => {
|
||||
return database.id !== databaseId;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
template: `
|
||||
<div>
|
||||
<div v-if="loading">
|
||||
<div class="spinner spinner-xl blue"></div>
|
||||
</div>
|
||||
<div class="animate fadein" v-else>
|
||||
<div class="content-box mb-6" v-if="!databases.length">
|
||||
<div class="flex items-center">
|
||||
<icon name="database" class="flex-none text-neutral-800"></icon>
|
||||
<div class="flex-1 px-4 text-neutral-800">
|
||||
<p>You have no databases.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<DatabaseRow v-for="database in databases" :database="database" :key="database.name"/>
|
||||
</div>
|
||||
<div>
|
||||
<button class="btn btn-primary btn-lg" v-on:click="showCreateModal = true">Create new database</button>
|
||||
</div>
|
||||
<modal :show="showCreateModal" v-on:close="showCreateModal = false">
|
||||
<CreateDatabaseModal
|
||||
v-on:close="showCreateModal = false"
|
||||
v-on:database="handleModalCallback"
|
||||
v-if="showCreateModal"
|
||||
/>
|
||||
</modal>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
});
|
|
@ -0,0 +1,115 @@
|
|||
<template>
|
||||
<div>
|
||||
<div v-if="loading">
|
||||
<div class="spinner spinner-xl blue"></div>
|
||||
</div>
|
||||
<div class="animate fadein" v-else>
|
||||
<div class="content-box mb-6" v-if="!databases.length">
|
||||
<div class="flex items-center">
|
||||
<Icon name="database" class="flex-none text-neutral-800"></icon>
|
||||
<div class="flex-1 px-4 text-neutral-800">
|
||||
<p>You have no databases.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<DatabaseRow v-for="database in databases" :database="database" :key="database.name"/>
|
||||
</div>
|
||||
<div>
|
||||
<button class="btn btn-primary btn-lg" v-on:click="showCreateModal = true">Create new database</button>
|
||||
</div>
|
||||
<Modal :show="showCreateModal" v-on:close="showCreateModal = false">
|
||||
<CreateDatabaseModal
|
||||
v-on:close="showCreateModal = false"
|
||||
v-on:database="handleModalCallback"
|
||||
v-if="showCreateModal"
|
||||
/>
|
||||
</modal>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
import {filter, map} from 'lodash';
|
||||
import Modal from '@/components/core/Modal.vue';
|
||||
import CreateDatabaseModal from './../components/database/CreateDatabaseModal.vue';
|
||||
import Icon from "@/components/core/Icon.vue";
|
||||
import {ServerDatabase} from "@/api/server/types";
|
||||
import DatabaseRow from "@/components/server/components/database/DatabaseRow.vue";
|
||||
|
||||
type DataStructure = {
|
||||
loading: boolean,
|
||||
showCreateModal: boolean,
|
||||
databases: Array<ServerDatabase>,
|
||||
}
|
||||
|
||||
export default Vue.extend({
|
||||
name: 'ServerDatabases',
|
||||
components: {DatabaseRow, CreateDatabaseModal, Modal, Icon},
|
||||
|
||||
data: function (): DataStructure {
|
||||
return {
|
||||
databases: [],
|
||||
loading: true,
|
||||
showCreateModal: false,
|
||||
};
|
||||
},
|
||||
|
||||
mounted: function () {
|
||||
this.getDatabases();
|
||||
|
||||
window.events.$on('server:deleted-database', this.removeDatabase);
|
||||
},
|
||||
|
||||
methods: {
|
||||
/**
|
||||
* Get all of the databases that exist for this server.
|
||||
*/
|
||||
getDatabases: function () {
|
||||
this.$flash.clear();
|
||||
this.loading = true;
|
||||
|
||||
window.axios.get(this.route('api.client.servers.databases', {
|
||||
server: this.$route.params.id,
|
||||
include: 'password'
|
||||
}))
|
||||
.then(response => {
|
||||
this.databases = map(response.data.data, (object) => {
|
||||
const data = object.attributes;
|
||||
|
||||
data.password = data.relationships.password.attributes.password;
|
||||
data.showPassword = false;
|
||||
delete data.relationships;
|
||||
|
||||
return data;
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
this.$flash.error('There was an error encountered while attempting to fetch databases for this server.');
|
||||
console.error(err);
|
||||
})
|
||||
.then(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Add the database to the list of existing databases automatically when the modal
|
||||
* is closed with a successful callback.
|
||||
*/
|
||||
handleModalCallback: function (data: ServerDatabase) {
|
||||
this.databases.push(data);
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle event that is removing a database.
|
||||
*/
|
||||
removeDatabase: function (databaseId: string) {
|
||||
this.databases = filter(this.databases, (database) => {
|
||||
return database.id !== databaseId;
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
|
@ -1,9 +1,62 @@
|
|||
<template>
|
||||
<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><!--
|
||||
--><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>
|
||||
</span>
|
||||
<span v-else>
|
||||
/<span class="px-1 text-neutral-600 font-medium">{{crumb.directoryName}}</span>
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
<div class="content-box">
|
||||
<div v-if="loading">
|
||||
<div class="spinner spinner-xl blue"></div>
|
||||
</div>
|
||||
<div v-else-if="!loading && errorMessage">
|
||||
<div class="alert error" v-text="errorMessage"></div>
|
||||
</div>
|
||||
<div v-else-if="!directories.length && !files.length">
|
||||
<p class="text-neutral-500 text-sm text-center p-6 pb-4">This directory is empty.</p>
|
||||
</div>
|
||||
<div class="filemanager animated-fade-in" v-else>
|
||||
<div class="header">
|
||||
<div class="flex-none w-8"></div>
|
||||
<div class="flex-1">Name</div>
|
||||
<div class="flex-1 text-right">Size</div>
|
||||
<div class="flex-1 text-right">Modified</div>
|
||||
<div class="flex-none w-1/6">Actions</div>
|
||||
</div>
|
||||
<div v-for="directory in directories">
|
||||
<FolderRow :directory="directory"/>
|
||||
</div>
|
||||
<div v-for="file in files">
|
||||
<FileRow :file="file" :editable="editableFiles" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex mt-6" v-if="!loading && !errorMessage">
|
||||
<div class="flex-1"></div>
|
||||
<div class="mr-4">
|
||||
<a href="#" class="block btn btn-secondary btn-sm">New Folder</a>
|
||||
</div>
|
||||
<div>
|
||||
<a href="#" class="block btn btn-primary btn-sm">New File</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</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";
|
||||
import FolderRow from "@/components/server/components/filemanager/FolderRow";
|
||||
import FileRow from "@/components/server/components/filemanager/FileRow.vue";
|
||||
import FolderRow from "@/components/server/components/filemanager/FolderRow.vue";
|
||||
|
||||
type DataStructure = {
|
||||
loading: boolean,
|
||||
|
@ -14,7 +67,8 @@ type DataStructure = {
|
|||
editableFiles: Array<string>,
|
||||
}
|
||||
|
||||
export default Vue.component('file-manager', {
|
||||
export default Vue.extend({
|
||||
name: 'FileManager',
|
||||
components: { FileRow, FolderRow },
|
||||
computed: {
|
||||
...mapState('server', ['server', 'credentials']),
|
||||
|
@ -113,56 +167,5 @@ export default Vue.component('file-manager', {
|
|||
});
|
||||
},
|
||||
},
|
||||
|
||||
template: `
|
||||
<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><!--
|
||||
--><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>
|
||||
</span>
|
||||
<span v-else>
|
||||
/<span class="px-1 text-neutral-600 font-medium">{{crumb.directoryName}}</span>
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
<div class="content-box">
|
||||
<div v-if="loading">
|
||||
<div class="spinner spinner-xl blue"></div>
|
||||
</div>
|
||||
<div v-else-if="!loading && errorMessage">
|
||||
<div class="alert error" v-text="errorMessage"></div>
|
||||
</div>
|
||||
<div v-else-if="!directories.length && !files.length">
|
||||
<p class="text-neutral-500 text-sm text-center p-6 pb-4">This directory is empty.</p>
|
||||
</div>
|
||||
<div class="filemanager animated-fade-in" v-else>
|
||||
<div class="header">
|
||||
<div class="flex-none w-8"></div>
|
||||
<div class="flex-1">Name</div>
|
||||
<div class="flex-1 text-right">Size</div>
|
||||
<div class="flex-1 text-right">Modified</div>
|
||||
<div class="flex-none w-1/6">Actions</div>
|
||||
</div>
|
||||
<div v-for="directory in directories">
|
||||
<folder-row :directory="directory"/>
|
||||
</div>
|
||||
<div v-for="file in files">
|
||||
<file-row :file="file" :editable="editableFiles" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex mt-6" v-if="!loading && !errorMessage">
|
||||
<div class="flex-1"></div>
|
||||
<div class="mr-4">
|
||||
<a href="#" class="block btn btn-secondary btn-sm">New Folder</a>
|
||||
</div>
|
||||
<div>
|
||||
<a href="#" class="block btn btn-primary btn-sm">New File</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue