Skip to content

Commit 5e4ca8e

Browse files
committed
Cleanup socketio stuff for typescript
1 parent 3ad4422 commit 5e4ca8e

File tree

22 files changed

+246
-210
lines changed

22 files changed

+246
-210
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
"@babel/plugin-transform-async-to-generator": "^7.0.0-beta.49",
2121
"@babel/plugin-transform-runtime": "^7.0.0-beta.49",
2222
"@babel/preset-env": "^7.0.0-beta.49",
23+
"@types/lodash": "^4.14.119",
2324
"@types/node": "^10.12.15",
25+
"@types/socket.io-client": "^1.4.32",
2426
"@types/webpack-env": "^1.13.6",
2527
"autoprefixer": "^8.2.0",
2628
"axios": "^0.18.0",
@@ -33,7 +35,6 @@
3335
"babel-plugin-transform-runtime": "^6.23.0",
3436
"babel-plugin-transform-strict-mode": "^6.18.0",
3537
"babel-register": "^6.26.0",
36-
"camelcase": "^5.0.0",
3738
"clean-webpack-plugin": "^0.1.19",
3839
"css-loader": "^0.28.11",
3940
"eslint": "^5.6.0",

resources/assets/scripts/components/server/Server.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
import ProgressBar from './components/ProgressBar';
7070
import { mapState } from 'vuex';
7171
import io from 'socket.io-client';
72-
import { Socketio } from './../../mixins/socketio';
72+
import { Socketio } from '../../mixins/socketio/index';
7373
7474
import PowerButtons from './components/PowerButtons';
7575
import Flash from '../Flash';

resources/assets/scripts/components/server/components/PowerButtons.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
<script>
2626
import Status from '../../../helpers/statuses';
27-
import { Socketio } from './../../../mixins/socketio';
27+
import { Socketio } from '../../../mixins/socketio/index';
2828
import { mapState } from 'vuex';
2929
3030
export default {

resources/assets/scripts/components/server/components/filemanager/FileManagerFileRow.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</template>
1616

1717
<script>
18-
import * as Helpers from './../../../../helpers/index';
18+
import * as Helpers from '../../../../helpers/index';
1919
import { FileTextIcon, Link2Icon } from 'vue-feather-icons';
2020
import FileManagerContextMenu from './FileManagerContextMenu';
2121

resources/assets/scripts/components/server/components/filemanager/FileManagerFolderRow.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
<script>
1818
import { FolderIcon } from 'vue-feather-icons';
19-
import { formatDate } from './../../../../helpers/index';
19+
import { formatDate } from '../../../../helpers/index';
2020
2121
export default {
2222
name: 'file-manager-folder-row',

resources/assets/scripts/components/server/subpages/Console.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import { Terminal } from 'xterm';
2929
import * as TerminalFit from 'xterm/lib/addons/fit/fit';
3030
import {mapState} from 'vuex';
31-
import {Socketio} from './../../../mixins/socketio';
31+
import {Socketio} from '../../../mixins/socketio/index';
3232
3333
Terminal.applyAddon(TerminalFit);
3434
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1+
import axios, {AxiosResponse} from 'axios';
2+
13
/**
24
* We'll load the axios HTTP library which allows us to easily issue requests
35
* to our Laravel back-end. This library automatically handles sending the
46
* CSRF token as a header based on the value of the "XSRF" token cookie.
57
*/
6-
7-
let axios = require('axios');
88
axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
99
axios.defaults.headers.common['Accept'] = 'application/json';
1010

11+
// Attach the response data to phpdebugbar so that we can see everything happening.
12+
// @ts-ignore
1113
if (typeof phpdebugbar !== 'undefined') {
12-
axios.interceptors.response.use(function (response) {
14+
axios.interceptors.response.use(function (response: AxiosResponse) {
15+
// @ts-ignore
1316
phpdebugbar.ajaxHandler.handle(response.request);
1417

1518
return response;
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
import format from 'date-fns/format';
1+
import { format } from 'date-fns';
22

33
/**
44
* Return the human readable filesize for a given number of bytes. This
55
* uses 1024 as the base, so the response is denoted accordingly.
6-
*
7-
* @param {Number} bytes
8-
* @return {String}
96
*/
10-
export function readableSize (bytes) {
7+
export function readableSize (bytes: number): string {
118
if (Math.abs(bytes) < 1024) {
129
return `${bytes} Bytes`;
1310
}
1411

15-
let u = -1;
16-
const units = ['KiB', 'MiB', 'GiB', 'TiB'];
12+
let u: number = -1;
13+
const units: Array<string> = ['KiB', 'MiB', 'GiB', 'TiB'];
1714

1815
do {
1916
bytes /= 1024;
@@ -25,10 +22,7 @@ export function readableSize (bytes) {
2522

2623
/**
2724
* Format the given date as a human readable string.
28-
*
29-
* @param {String} date
30-
* @return {String}
3125
*/
32-
export function formatDate (date) {
26+
export function formatDate (date: string): string {
3327
return format(date, 'MMM D, YYYY [at] HH:MM');
3428
}
Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,60 +2,50 @@ export const flash = {
22
methods: {
33
/**
44
* Flash a message to the event stream in the browser.
5-
*
6-
* @param {string} message
7-
* @param {string} title
8-
* @param {string} severity
95
*/
10-
flash: function (message, title, severity = 'info') {
6+
flash: function (message: string, title: string, severity: string = 'info'): void {
117
severity = severity || 'info';
128
if (['danger', 'fatal', 'error'].includes(severity)) {
139
severity = 'error';
1410
}
1511

12+
// @ts-ignore
1613
window.events.$emit('flash', { message, title, severity });
1714
},
1815

1916
/**
2017
* Clear all of the flash messages from the screen.
2118
*/
22-
clearFlashes: function () {
19+
clearFlashes: function (): void {
20+
// @ts-ignore
2321
window.events.$emit('clear-flashes');
2422
},
2523

2624
/**
2725
* Helper function to flash a normal success message to the user.
28-
*
29-
* @param {string} message
3026
*/
31-
success: function (message) {
27+
success: function (message: string): void {
3228
this.flash(message, 'Success', 'success');
3329
},
3430

3531
/**
3632
* Helper function to flash a normal info message to the user.
37-
*
38-
* @param {string} message
3933
*/
40-
info: function (message) {
34+
info: function (message: string): void {
4135
this.flash(message, 'Info', 'info');
4236
},
4337

4438
/**
4539
* Helper function to flash a normal warning message to the user.
46-
*
47-
* @param {string} message
4840
*/
49-
warning: function (message) {
41+
warning: function (message: string): void {
5042
this.flash(message, 'Warning', 'warning');
5143
},
5244

5345
/**
5446
* Helper function to flash a normal error message to the user.
55-
*
56-
* @param {string} message
5747
*/
58-
error: function (message) {
48+
error: function (message: string): void {
5949
this.flash(message, 'Error', 'danger');
6050
},
6151
}

resources/assets/scripts/mixins/socketio/connector.js

Lines changed: 0 additions & 103 deletions
This file was deleted.

0 commit comments

Comments
 (0)