diff --git a/faucet-client/src/components/status/FaucetStatusPage.tsx b/faucet-client/src/components/status/FaucetStatusPage.tsx index ed1582f70..61220f3fb 100644 --- a/faucet-client/src/components/status/FaucetStatusPage.tsx +++ b/faucet-client/src/components/status/FaucetStatusPage.tsx @@ -296,6 +296,22 @@ export class FaucetStatusPage extends React.PureComponent 0) { + let totalFactor = 1; + session.factor.forEach((f) => { + totalFactor *= f.factor; + }); + sessionStatus.push( + this.renderFactorInfo(session, props)} + > + x{Math.round(totalFactor * 100) / 100} + + ); + } + return ( {session.id} @@ -409,6 +425,30 @@ export class FaucetStatusPage extends React.PureComponent +
+ + + {session.factor.map((f) => { + return ( + + + + + ); + })} + +
x{Math.round(f.factor * 100) / 100}{f.module} {f.name ? "/" + f.name : ""}
+
+ + ); + } + private renderActiveClaims(): React.ReactElement { return ( diff --git a/faucet-client/src/types/FaucetStatus.ts b/faucet-client/src/types/FaucetStatus.ts index 14e2aa0f0..4186cf801 100644 --- a/faucet-client/src/types/FaucetStatus.ts +++ b/faucet-client/src/types/FaucetStatus.ts @@ -26,6 +26,7 @@ export interface IClientSessionStatus { boost: any; connected: boolean; idle: number; + factor: ISessionRewardFactor[]; } export interface IClientClaimStatusRsp { @@ -92,4 +93,10 @@ export interface IClientSessionRestrictionStatus { notify: boolean|string; }[]; blocked: false|"close"|"kill"; -} \ No newline at end of file +} + +export interface ISessionRewardFactor { + factor: number; + module: string; + name?: string; +} diff --git a/src/session/FaucetSession.ts b/src/session/FaucetSession.ts index 044cd84e1..168557a46 100644 --- a/src/session/FaucetSession.ts +++ b/src/session/FaucetSession.ts @@ -362,6 +362,7 @@ export class FaucetSession { let rewardFactors: ISessionRewardFactor[] = []; await ServiceManager.GetService(ModuleManager).processActionHooks([], ModuleHookAction.SessionRewardFactor, [this, rewardFactors]); + this.setSessionData("reward.factors", rewardFactors); let rewardFactor = 1; //console.log(rewardFactors); diff --git a/src/webserv/api/faucetStatus.ts b/src/webserv/api/faucetStatus.ts index 795a57256..c8349bf88 100644 --- a/src/webserv/api/faucetStatus.ts +++ b/src/webserv/api/faucetStatus.ts @@ -8,6 +8,7 @@ import { FaucetBalanceModule } from "../../modules/faucet-balance/FaucetBalanceM import { FaucetOutflowModule } from "../../modules/faucet-outflow/FaucetOutflowModule"; import { ModuleManager } from "../../modules/ModuleManager"; import { SessionManager } from "../../session/SessionManager"; +import { ISessionRewardFactor } from "../../session/SessionRewardFactor"; import { getHashedIp, getHashedSessionId } from "../../utils/HashedInfo"; export interface IClientClaimStatus { @@ -37,6 +38,7 @@ export interface IClientSessionStatus { boost: any; connected: boolean; idle: number; + factors: ISessionRewardFactor[]; } export interface IClientFaucetStatus { @@ -125,6 +127,7 @@ export async function buildSessionStatus(unmasked?: boolean): Promise0&&a.length>o&&!a.warned){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=a.length,u=c,console&&console.warn&&console.warn(u)}return e}function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function f(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=c.bind(r);return o.listener=n,r.wrapFn=o,o}function p(e,t,n){var r=e._events;if(void 0===r)return[];var o=r[t];return void 0===o?[]:"function"==typeof o?n?[o.listener||o]:[o]:n?function(e){for(var t=new Array(e.length),n=0;n0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var l=i[e];if(void 0===l)return!1;if("function"==typeof l)r(l,this,t);else{var u=l.length,c=h(l,u);for(n=0;n=0;i--)if(n[i]===t||n[i].listener===t){a=n[i].listener,o=i;break}if(o<0)return this;0===o?n.shift():function(e,t){for(;t+1=0;r--)this.removeListener(e,t[r]);return this},i.prototype.listeners=function(e){return p(this,e,!0)},i.prototype.rawListeners=function(e){return p(this,e,!1)},i.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):d.call(e,t)},i.prototype.listenerCount=d,i.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},679:function(e,t,n){var r=n(864),o={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},i={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},a={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},s={};function l(e){return r.isMemo(e)?a:s[e.$$typeof]||o}s[r.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},s[r.Memo]=a;var u=Object.defineProperty,c=Object.getOwnPropertyNames,f=Object.getOwnPropertySymbols,p=Object.getOwnPropertyDescriptor,d=Object.getPrototypeOf,h=Object.prototype;e.exports=function e(t,n,r){if("string"!=typeof n){if(h){var o=d(n);o&&o!==h&&e(t,o,r)}var a=c(n);f&&(a=a.concat(f(n)));for(var s=l(t),m=l(n),v=0;v