ui: change to ts & tsx

This commit is contained in:
undefined committed 2021-10-11 23:33:54 +08:00
1 parent 36cce6d1bd
commit d10fec361c
29 files changed
+165 -221

No files matched your search

-15
View File
@@ -49,11 +49,6 @@ function set(key: string, value: any) {
class SystemHandler extends Handler {
async prepare() {
this.checkPriv(PRIV.PRIV_EDIT_SYSTEM);
this.response.body = {
path: [
['Hydro', 'homepage'],
],
};
}
}
@@ -86,12 +81,6 @@ class SystemCheckConnHandler extends ConnectionHandler {
class SystemDashboardHandler extends SystemHandler {
async get() {
this.response.template = 'manage_dashboard.html';
this.response.body.path.push(['manage_dashboard', null]);
}
async postRestart() {
// TODO handle restart
this.back();
}
}
@@ -99,7 +88,6 @@ class SystemScriptHandler extends SystemHandler {
async get() {
this.response.template = 'manage_script.html';
this.response.body.scripts = global.Hydro.script;
this.response.body.path.push(['manage_script', null]);
}
@param('id', Types.Name)
@@ -147,7 +135,6 @@ class SystemScriptHandler extends SystemHandler {
class SystemSettingHandler extends SystemHandler {
async get() {
this.response.template = 'manage_setting.html';
this.response.body.path.push(['manage_setting', null]);
this.response.body.current = {};
this.response.body.settings = setting.SYSTEM_SETTINGS;
for (const s of this.response.body.settings) {
@@ -185,7 +172,6 @@ class SystemSettingHandler extends SystemHandler {
class SystemUserImportHandler extends SystemHandler {
async get() {
this.response.body.users = [];
this.response.body.path.push(['manage_user_import']);
this.response.template = 'manage_user_import.html';
}
@@ -232,7 +218,6 @@ class SystemUserImportHandler extends SystemHandler {
}
}
}
this.response.body.path.push(['manage_user_import']);
this.response.body.users = udocs;
this.response.body.messages = messages;
}
-30
View File
@@ -13,35 +13,6 @@ import {
} from '../service/server';
import { sortFiles } from '../utils';
class CheckInHandler extends Handler {
async prepare() {
const { checkincnt, lastcheckin } = this.user;
const today = new Date();
today.setHours(0);
today.setMinutes(0);
today.setSeconds(0);
today.setMilliseconds(0);
if (lastcheckin === today.getTime()) throw new BadRequestError("You've already checked in today!");
this.user.checkincnt++;
this.user.lastcheckin = today.getTime();
await Promise.all([
user.setById(this.user._id, { checkincnt, lastcheckin }),
user.inc(this.user._id, 'rpdelta', Math.round(Math.sqrt(checkincnt))),
]);
}
async get() {
this.response.redirect = '/';
}
async post() {
this.response.body = {
cnt: this.user.checkincnt,
last: this.user.lastcheckin,
};
}
}
class SwitchLanguageHandler extends Handler {
@param('lang', Types.Name)
async get(domainId: string, lang: string) {
@@ -132,7 +103,6 @@ export class FSDownloadHandler extends Handler {
}
export async function apply() {
Route('check_in', '/checkin', CheckInHandler, PRIV.PRIV_USER_PROFILE);
Route('switch_language', '/language/:lang', SwitchLanguageHandler);
Route('home_files', '/file', FilesHandler, PRIV.PRIV_CREATE_FILE);
Route('fs_download', '/file/:uid/:filename', FSDownloadHandler);