Skip to content

Commit

Permalink
#55 change tsconfig to strict, update code
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Werfling committed Apr 8, 2024
1 parent f7ee7a6 commit 7092103
Show file tree
Hide file tree
Showing 35 changed files with 160 additions and 69 deletions.
7 changes: 7 additions & 0 deletions frontend/src/inc/Api/GatewayIdentifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import {
SchemaDefaultReturn,
SchemaGatewayIdentifierListResponse
} from 'flyingfish_schemas';
import {Vts} from 'vts';
import {NetFetch} from '../Net/NetFetch';
import {UnknownResponse} from './Error/UnknownResponse';

/**
* GatewayIdentifier
Expand All @@ -16,6 +18,11 @@ export class GatewayIdentifier {
*/
public static async getList(): Promise<GatewayIdentifierEntry[]> {
const result = await NetFetch.getData('/json/gatewayidentifier/list', SchemaGatewayIdentifierListResponse);

if (Vts.isUndefined(result.data)) {
throw new UnknownResponse('Gateway identifier return empty list!');
}

return result.data;
}

Expand Down
7 changes: 7 additions & 0 deletions frontend/src/inc/Api/IpAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ import {
SchemaIpAccessWhiteListResponse,
SchemaIpAccessWhiteSaveResponse
} from 'flyingfish_schemas';
import {Vts} from 'vts';
import {NetFetch} from '../Net/NetFetch';
import {UnknownResponse} from './Error/UnknownResponse';

/**
* BlacklistCategory
Expand Down Expand Up @@ -59,6 +61,11 @@ export class IpAccess {
*/
public static async getMaintainerList(): Promise<IpAccessMaintainer[]> {
const result = await NetFetch.getData('/json/ipaccess/maintainer/list', SchemaIpAccessMaintainerResponse);

if (Vts.isUndefined(result.list)) {
throw new UnknownResponse('IP Access maintainer return empty list!');
}

return result.list;
}

Expand Down
6 changes: 5 additions & 1 deletion frontend/src/inc/Api/Response/Response.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {DefaultReturn, StatusCodes} from 'flyingfish_schemas';
import {Schema, SchemaErrors} from 'vts';
import {Schema, SchemaErrors, Vts} from 'vts';
import {InternalError} from '../Error/InternalError';
import {SchemaError} from '../Error/SchemaError';
import {UnauthorizedError} from '../Error/UnauthorizedError';
Expand Down Expand Up @@ -47,6 +47,10 @@ export class Response {
throw new UnauthorizedError();

case StatusCodes.INTERNAL_ERROR:
if (Vts.isUndefined(data.msg)) {
throw new InternalError('');
}

throw new InternalError(data.msg);
}
}
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/inc/Api/Settings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import {SchemaDefaultReturn, SchemaSettingsResponse, SettingsList} from 'flyingfish_schemas';
import {Vts} from 'vts';
import {NetFetch} from '../Net/NetFetch';
import {UnknownResponse} from './Error/UnknownResponse';

/**
* Settings
Expand All @@ -11,6 +13,11 @@ export class Settings {
*/
public static async getSettings(): Promise<SettingsList> {
const result = await NetFetch.getData('/json/settings/list', SchemaSettingsResponse);

if (Vts.isUndefined(result.list)) {
throw new UnknownResponse('Settings return empty list!');
}

return result.list;
}

Expand Down
6 changes: 6 additions & 0 deletions frontend/src/inc/Api/Ssl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import {
SslDetails,
SslProvidersResponse
} from 'flyingfish_schemas';
import {Vts} from 'vts';
import {NetFetch} from '../Net/NetFetch';
import {UnknownResponse} from './Error/UnknownResponse';

/**
* Ssl
Expand All @@ -26,6 +28,10 @@ export class Ssl {
public static async getCertDetails(httpid: number): Promise<SslDetails> {
const resultContent = await NetFetch.postData('/json/ssl/cert/details', {httpid}, SchemaSslDetailsResponse);

if (Vts.isUndefined(resultContent.details)) {
throw new UnknownResponse('Ssl cert return empty details!');
}

return resultContent.details;
}

Expand Down
7 changes: 7 additions & 0 deletions frontend/src/inc/Api/UpnpNat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import {
UpnpNatDeleteRequest,
UpnpNatGatwayInfo, UpnpNatPort, UpnpNatSaveRequest
} from 'flyingfish_schemas';
import {Vts} from 'vts';
import {NetFetch} from '../Net/NetFetch';
import {UnknownResponse} from './Error/UnknownResponse';

/**
* NatStatuts
Expand Down Expand Up @@ -33,6 +35,11 @@ export class UpnpNat {
*/
public static async getCurrentGatewayInfo(): Promise<UpnpNatGatwayInfo> {
const result = await NetFetch.getData('/json/upnpnat/current_gateway_info', SchemaUpnpNatCurrentGatwayInfoResponse);

if (Vts.isUndefined(result.data)) {
throw new UnknownResponse('UpnpNat current gateway return empty info!');
}

return result.data;
}

Expand Down
7 changes: 7 additions & 0 deletions frontend/src/inc/Api/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import {
UserEntry,
UserInfo
} from 'flyingfish_schemas';
import {Vts} from 'vts';
import {NetFetch} from '../Net/NetFetch';
import {UnknownResponse} from './Error/UnknownResponse';

/**
* User
Expand All @@ -18,6 +20,11 @@ export class User {
*/
public static async getUserInfo(): Promise<UserInfo> {
const result = await NetFetch.getData('/json/user/info', SchemaUserInfoResponse);

if (Vts.isUndefined(result.data)) {
throw new UnknownResponse('User return empty info!');
}

return result.data;
}

Expand Down
29 changes: 20 additions & 9 deletions frontend/src/inc/Pages/Dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
SwitchTimer, Tooltip, TooltipInfo
} from 'bambooo';
import moment from 'moment/moment';
import {Vts} from 'vts';
import {Dashboard as DashboardApi} from '../Api/Dashboard';
import {UnauthorizedError} from '../Api/Error/UnauthorizedError';
import {Lang} from '../Lang';
Expand All @@ -35,7 +36,7 @@ export class Dashboard extends BasePage {
* name
* @protected
*/
protected _name: string = 'dashboard';
protected override _name: string = 'dashboard';

/**
* switch timer
Expand All @@ -53,13 +54,13 @@ export class Dashboard extends BasePage {
* line chart requests
* @protected
*/
protected _lineChartRequests: LineChartRequests;
protected _lineChartRequests: LineChartRequests | undefined;

/**
* ip blacklist map
* @protected
*/
protected _ipBlacklistMap: DashboardMapIp;
protected _ipBlacklistMap: DashboardMapIp | undefined;

/**
* constructor
Expand Down Expand Up @@ -87,7 +88,7 @@ export class Dashboard extends BasePage {
/**
* loadContent
*/
public async loadContent(): Promise<void> {
public override async loadContent(): Promise<void> {
const content = this._wrapper.getContentWrapper().getContent();

const row = new ContentRow(content);
Expand Down Expand Up @@ -157,7 +158,9 @@ export class Dashboard extends BasePage {
streamRequestsPoints.push(streamRequestPoint.counts);
}

this._lineChartRequests.updateData(streamRequestsPoints);
if (this._lineChartRequests) {
this._lineChartRequests.updateData(streamRequestsPoints);
}

// public ip -----------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -260,7 +263,9 @@ export class Dashboard extends BasePage {
}
}

this._ipBlacklistMap.setMarks(blockMarkList);
if (this._ipBlacklistMap) {
this._ipBlacklistMap.setMarks(blockMarkList);
}

// ip blocks -----------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -294,7 +299,9 @@ export class Dashboard extends BasePage {

this._updateSwitch.setTimeoutFn(async() => {
try {
this._onLoadTable();
if (!Vts.isNull(this._onLoadTable)) {
this._onLoadTable();
}
} catch (e) {
if (e instanceof UnauthorizedError) {
UtilRedirect.toLogin();
Expand All @@ -306,9 +313,13 @@ export class Dashboard extends BasePage {
/**
* unloadContent
*/
public async unloadContent(): Promise<void> {
public override async unloadContent(): Promise<void> {
super.unloadContent();
await this._ipBlacklistMap.unloadContent();

if (this._ipBlacklistMap) {
await this._ipBlacklistMap.unloadContent();
}

this._updateSwitch.setEnable(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class DashboardIpBlacklistModal extends ModalDialog {
/**
* show
*/
public show(): void {
public override show(): void {
super.show();

const bodyCard = jQuery('<div class="card-body"/>').appendTo(this._body.empty());
Expand Down
18 changes: 17 additions & 1 deletion frontend/src/inc/Pages/Dashboard/DashboardMapIp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {getVectorContext} from 'ol/render.js';
import {easeOut} from 'ol/easing.js';
import {Element} from 'bambooo';
import {Circle as CircleStyle, Fill, Stroke, Style} from 'ol/style';
import {Vts} from 'vts';

/**
* DashboardMapIpMark
Expand Down Expand Up @@ -140,11 +141,26 @@ export class DashboardMapIp extends Element {
const map = this._map;

this._source.on('addfeature', (e) => {
if (Vts.isUndefined(e.feature)) {
return;
}

const feature = e.feature;
const start = Date.now();
const flashGeom = feature.getGeometry().clone();
const geometry = feature.getGeometry();

if (Vts.isUndefined(geometry)) {
return;
}

const flashGeom = geometry.clone();
const listenerKey = tileLayer.on('postrender', (event) => {
const frameState = event.frameState;

if (Vts.isUndefined(frameState)) {
return;
}

const elapsed = frameState.time - start;
if (elapsed >= duration) {
unByKey(listenerKey);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/inc/Pages/DnsResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class DnsResolver extends BasePage {
* name
* @protected
*/
protected _name: string = 'dnsresolver';
protected override _name: string = 'dnsresolver';

/**
* constructor
Expand Down
12 changes: 8 additions & 4 deletions frontend/src/inc/Pages/Domains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
} from 'bambooo';
import {DomainData} from 'flyingfish_schemas';
import moment from 'moment';
import {Vts} from 'vts';
import {Domain as DomainAPI} from '../Api/Domain';
import {Nginx as NginxAPI} from '../Api/Nginx';
import {BasePage} from './BasePage';
Expand All @@ -39,7 +40,7 @@ export class Domains extends BasePage {
* name
* @protected
*/
protected _name: string = 'domains';
protected override _name: string = 'domains';

/**
* domain dialog
Expand Down Expand Up @@ -186,7 +187,7 @@ export class Domains extends BasePage {
/**
* loadContent
*/
public async loadContent(): Promise<void> {
public override async loadContent(): Promise<void> {
const content = this._wrapper.getContentWrapper().getContent();

/**
Expand All @@ -208,9 +209,12 @@ export class Domains extends BasePage {
}

const domainCollection = domainMap.get(domain.parent_id);
domainCollection.push(domain);

domainMap.set(domain.parent_id, domainCollection);
if (!Vts.isUndefined(domainCollection)) {
domainCollection.push(domain);

domainMap.set(domain.parent_id, domainCollection);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/inc/Pages/Domains/DomainEditModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class DomainEditModal extends ModalDialog {
/**
* resetValues
*/
public resetValues(): void {
public override resetValues(): void {
this.setId(null);
this.setName('');
this.setDisable(false);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/inc/Pages/Domains/DomainRecordEditModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export class DomainRecordEditModal extends ModalDialog {
/**
* resetValues
*/
public resetValues(): void {
public override resetValues(): void {
this.setId(null);
this.setDomainId(null);
this.setDomainName('');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export class DynDnsClientEditModal extends ModalDialog {
/**
* resetValues
*/
public resetValues(): void {
public override resetValues(): void {
this.setProvider('none');
this._multipleDomains.setValue([]);
this._inputUsername.setValue('');
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/inc/Pages/DynDnsClients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class DynDnsClients extends BasePage {
* name
* @protected
*/
protected _name: string = 'dyndnsclients';
protected override _name: string = 'dyndnsclients';

/**
* dyn dns client dialog
Expand Down Expand Up @@ -123,7 +123,7 @@ export class DynDnsClients extends BasePage {
/**
* loadContent
*/
public async loadContent(): Promise<void> {
public override async loadContent(): Promise<void> {
const row1 = new ContentRow(this._wrapper.getContentWrapper().getContent());

const card = new Card(new ContentCol(row1, ContentColSize.col12));
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/inc/Pages/DynDnsServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class DynDnsServer extends BasePage {
* name
* @member {string}
*/
protected _name: string = 'dyndnsserver';
protected override _name: string = 'dyndnsserver';

/**
* dyn dns client dialog
Expand Down Expand Up @@ -123,7 +123,7 @@ export class DynDnsServer extends BasePage {
/**
* loadContent
*/
public async loadContent(): Promise<void> {
public override async loadContent(): Promise<void> {
const row1 = new ContentRow(this._wrapper.getContentWrapper().getContent());

const card = new Card(new ContentCol(row1, ContentColSize.col12));
Expand Down
Loading

0 comments on commit 7092103

Please sign in to comment.