Skip to content

Commit 3ad4422

Browse files
committed
Begin transfering things to TS
1 parent 81f5e49 commit 3ad4422

File tree

17 files changed

+280
-138
lines changed

17 files changed

+280
-138
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
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/node": "^10.12.15",
24+
"@types/webpack-env": "^1.13.6",
2325
"autoprefixer": "^8.2.0",
2426
"axios": "^0.18.0",
2527
"babel-cli": "6.18.0",
@@ -36,7 +38,6 @@
3638
"css-loader": "^0.28.11",
3739
"eslint": "^5.6.0",
3840
"eslint-config-vue": "^2.0.2",
39-
"eslint-plugin-flowtype-errors": "^3.6.0",
4041
"eslint-plugin-html": "^4.0.6",
4142
"eslint-plugin-vue": "^4.7.1",
4243
"extract-text-webpack-plugin": "^4.0.0-beta.0",

resources/assets/scripts/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require('./bootstrap');
1111
import { Ziggy } from './helpers/ziggy';
1212
import Locales from './../../../resources/lang/locales';
1313
import { flash } from './mixins/flash';
14-
import store from './store/index.js';
14+
import store from './store/index';
1515
import router from './router';
1616

1717
window.events = new Vue();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</template>
2424

2525
<script>
26-
import Status from './../../../helpers/statuses';
26+
import Status from '../../../helpers/statuses';
2727
import { Socketio } from './../../../mixins/socketio';
2828
import { mapState } from 'vuex';
2929
File renamed without changes.

resources/assets/scripts/models/server.js

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
2+
type ServerAllocation = {
3+
ip: string,
4+
port: number,
5+
};
6+
7+
type ServerLimits = {
8+
memory: number,
9+
swap: number,
10+
disk: number,
11+
io: number,
12+
cpu: number,
13+
}
14+
15+
type ServerFeatureLimits = {
16+
databases: number,
17+
allocations: number,
18+
};
19+
20+
export type ServerData = {
21+
identifier: string,
22+
uuid: string,
23+
name: string,
24+
node: string,
25+
description: string,
26+
allocation: ServerAllocation,
27+
limits: ServerLimits,
28+
feature_limits: ServerFeatureLimits,
29+
};
30+
31+
/**
32+
* A model representing a server returned by the client API.
33+
*/
34+
export default class Server {
35+
/**
36+
* The server identifier, generally the 8-character representation of the server UUID.
37+
*/
38+
identifier: string;
39+
40+
/**
41+
* The long form identifier for this server.
42+
*/
43+
uuid: string;
44+
45+
/**
46+
* The human friendy name for this server.
47+
*/
48+
name: string;
49+
50+
/**
51+
* The name of the node that this server belongs to.
52+
*/
53+
node: string;
54+
55+
/**
56+
* A description of this server.
57+
*/
58+
description: string;
59+
60+
/**
61+
* The primary allocation details for this server.
62+
*/
63+
allocation: ServerAllocation;
64+
65+
/**
66+
* The base limits for this server when it comes to the actual docker container.
67+
*/
68+
limits: ServerLimits;
69+
70+
/**
71+
* The feature limits for this server, database & allocations currently.
72+
*/
73+
featureLimits: ServerFeatureLimits;
74+
75+
/**
76+
* Construct a new server model instance.
77+
*/
78+
constructor (data: ServerData) {
79+
this.identifier = data.identifier;
80+
this.uuid = data.uuid;
81+
this.name = data.name;
82+
this.node = data.node;
83+
this.description = data.description;
84+
this.allocation = data.allocation;
85+
this.limits = data.limits;
86+
this.featureLimits = data.feature_limits;
87+
}
88+
}

resources/assets/scripts/models/user.js

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
export type UserData = {
2+
root_admin: boolean,
3+
username: string,
4+
email: string,
5+
first_name: string,
6+
last_name: string,
7+
language: string,
8+
};
9+
10+
/**
11+
* A user model that represents an user in Pterodactyl.
12+
*/
13+
export default class User {
14+
/**
15+
* Determines wether or not the user is an admin.
16+
*/
17+
admin: boolean;
18+
19+
/**
20+
* The username for the currently authenticated user.
21+
*/
22+
username: string;
23+
24+
/**
25+
* The currently authenticated users email address.
26+
*/
27+
email: string;
28+
29+
/**
30+
* The full name of the logged in user.
31+
*/
32+
name: string;
33+
first_name: string;
34+
last_name: string;
35+
36+
/**
37+
* The language the user has selected to use.
38+
*/
39+
language: string;
40+
41+
/**
42+
* Create a new user model.
43+
*/
44+
constructor(data: UserData) {
45+
this.admin = data.root_admin;
46+
this.username = data.username;
47+
this.email = data.email;
48+
this.name = `${data.first_name} ${data.last_name}`;
49+
this.first_name = data.first_name;
50+
this.last_name = data.last_name;
51+
this.language = data.language;
52+
}
53+
}
Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import VueRouter from 'vue-router';
1+
import VueRouter, {Route} from 'vue-router';
22
import store from './store/index';
33

44
const route = require('./../../../vendor/tightenco/ziggy/src/js/route').default;
@@ -17,7 +17,7 @@ import {
1717
DatabasesPage,
1818
ServerSchedules,
1919
ServerSettings,
20-
ServerSubusers
20+
ServerSubusers,
2121
} from './components/server';
2222

2323
const routes = [
@@ -28,31 +28,32 @@ const routes = [
2828
name: 'reset-password',
2929
path: '/auth/password/reset/:token',
3030
component: ResetPassword,
31-
props: function (route) {
31+
props: function (route: Route) {
3232
return {token: route.params.token, email: route.query.email || ''};
33-
}
33+
},
3434
},
3535

3636
{name: 'dashboard', path: '/', component: Dashboard},
3737
{name: 'account', path: '/account', component: Account},
3838
{name: 'account.api', path: '/account/api', component: Account},
3939
{name: 'account.security', path: '/account/security', component: Account},
4040

41-
{ path: '/server/:id', component: Server,
41+
{
42+
path: '/server/:id', component: Server,
4243
children: [
43-
{ name: 'server', path: '', component: ConsolePage },
44-
{ name: 'server-files', path: 'files/:path(.*)?', component: FileManagerPage },
45-
{ name: 'server-subusers', path: 'subusers', component: ServerSubusers },
46-
{ name: 'server-schedules', path: 'schedules', component: ServerSchedules },
47-
{ name: 'server-databases', path: 'databases', component: DatabasesPage },
48-
{ name: 'server-allocations', path: 'allocations', component: ServerAllocations },
49-
{ name: 'server-settings', path: 'settings', component: ServerSettings },
50-
]
51-
}
44+
{name: 'server', path: '', component: ConsolePage},
45+
{name: 'server-files', path: 'files/:path(.*)?', component: FileManagerPage},
46+
{name: 'server-subusers', path: 'subusers', component: ServerSubusers},
47+
{name: 'server-schedules', path: 'schedules', component: ServerSchedules},
48+
{name: 'server-databases', path: 'databases', component: DatabasesPage},
49+
{name: 'server-allocations', path: 'allocations', component: ServerAllocations},
50+
{name: 'server-settings', path: 'settings', component: ServerSettings},
51+
],
52+
},
5253
];
5354

5455
const router = new VueRouter({
55-
mode: 'history', routes
56+
mode: 'history', routes,
5657
});
5758

5859
// Redirect the user to the login page if they try to access a protected route and
Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
import Vue from 'vue';
22
import Vuex from 'vuex';
3-
import auth from './modules/auth';
4-
import dashboard from './modules/dashboard';
5-
import server from './modules/server';
6-
import socket from './modules/socket';
3+
import auth, {AuthenticationState} from './modules/auth';
4+
import dashboard, {DashboardState} from './modules/dashboard';
5+
import server, {ServerState} from './modules/server';
6+
import socket, {SocketState} from './modules/socket';
77

88
Vue.use(Vuex);
99

10+
export type ApplicationState = {
11+
socket: SocketState,
12+
server: ServerState,
13+
auth: AuthenticationState,
14+
dashboard: DashboardState,
15+
}
16+
1017
const store = new Vuex.Store({
1118
strict: process.env.NODE_ENV !== 'production',
1219
modules: {auth, dashboard, server, socket},

0 commit comments

Comments
 (0)