Skip to content

Commit

Permalink
#29 update frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Werfling committed Apr 15, 2024
1 parent bf746d5 commit bfd8195
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 2 deletions.
14 changes: 14 additions & 0 deletions backend/src/Routes/Main/Dashboard.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Router} from 'express';
import {DefaultRoute} from 'flyingfish_core';
import {DashboardInfoResponse, DefaultReturn, StatusCodes} from 'flyingfish_schemas';
import {HimHIP} from './Dashboard/HimHIP.js';
import {Info} from './Dashboard/Info.js';
import {PublicIPBlacklistCheck} from './Dashboard/PublicIPBlacklistCheck.js';
import {StreamRequests} from './Dashboard/StreamRequests.js';
Expand Down Expand Up @@ -58,6 +59,19 @@ export class Dashboard extends DefaultRoute {
}
);

this._get(
'/json/dashboard/refrechhimhip',
async(req, res) => {
if (this.isUserLogin(req, res, false)) {
res.status(200).json(await HimHIP.refrechHimHIP());
} else {
res.status(200).json({
statusCode: StatusCodes.UNAUTHORIZED
} as DefaultReturn);
}
}
);

return super.getExpressRouter();
}

Expand Down
25 changes: 25 additions & 0 deletions backend/src/Routes/Main/Dashboard/HimHIP.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {RedisChannels, RedisClient} from 'flyingfish_core';
import {DefaultReturn, HimHIPUpdate, StatusCodes} from 'flyingfish_schemas';

export class HimHIP {

/**
* Refrech HimHIP data information
*/
public static async refrechHimHIP(): Promise<DefaultReturn> {
if (RedisClient.hasInstance()) {
const client = RedisClient.getInstance();
await client.sendChannel(
RedisChannels.HIMHIP_UPDATE_REQ,
JSON.stringify({
update: true
} as HimHIPUpdate)
);
}

return {
statusCode: StatusCodes.OK
};
}

}
10 changes: 9 additions & 1 deletion frontend/src/inc/Api/Dashboard.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
DashboardInfoResponse,
PublicIPBlacklistCheckResponse,
SchemaDashboardInfoResponse,
SchemaDashboardInfoResponse, SchemaDefaultReturn,
SchemaPublicIPBlacklistCheckResponse,
SchemaStreamRequestsResponse,
StreamRequestsResponse
Expand Down Expand Up @@ -34,4 +34,12 @@ export class Dashboard {
return NetFetch.getData('/json/dashboard/streamrequests', SchemaStreamRequestsResponse);
}

/**
* Refrech HimHIP data
*/
public static async refrechHimHIP(): Promise<boolean> {
NetFetch.getData('/json/dashboard/refrechhimhip', SchemaDefaultReturn);

return true;
}
}
37 changes: 36 additions & 1 deletion frontend/src/inc/Pages/Dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import {
InfoBox,
InfoBoxBg,
LeftNavbarLink,
SwitchTimer, Tooltip, TooltipInfo
SwitchTimer,
Tooltip,
TooltipInfo
} from 'bambooo';
import moment from 'moment/moment';
import {Vts} from 'vts';
Expand Down Expand Up @@ -187,6 +189,17 @@ export class Dashboard extends BasePage {
});

}, IconFa.copy);

btnPubIp.addDivider();

btnPubIp.addMenuItem('Refrech', async() => {
if (await DashboardApi.refrechHimHIP()) {
this._toast.fire({
icon: 'success',
title: 'Refrech is success'
});
}
}, IconFa.sync);
}

// gateway ip ----------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -214,6 +227,17 @@ export class Dashboard extends BasePage {
});

}, IconFa.copy);

btnGateway.addDivider();

btnGateway.addMenuItem('Refrech', async() => {
if (await DashboardApi.refrechHimHIP()) {
this._toast.fire({
icon: 'success',
title: 'Refrech is success'
});
}
}, IconFa.sync);
}

// host ip -------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -241,6 +265,17 @@ export class Dashboard extends BasePage {
});

}, IconFa.copy);

btnHostIp.addDivider();

btnHostIp.addMenuItem('Refrech', async() => {
if (await DashboardApi.refrechHimHIP()) {
this._toast.fire({
icon: 'success',
title: 'Refrech is success'
});
}
}, IconFa.sync);
}

// ip infos ------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit bfd8195

Please sign in to comment.