From 3db802ec1ff128422c1916b9dd177060375f47e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janis=20Daniel=20Da=CC=88hne?= <janis.daehne2@student.uni-halle.de> Date: Sun, 17 Nov 2019 22:59:31 +0100 Subject: [PATCH] - added proper settings to get submit test server stats and config --- i18n/en.ts | 13 +- i18n/i18nRoot.ts | 11 +- src/communicationLayer/dashboardLayer.ts | 4 +- src/communicationLayer/systemSettingsLayer.ts | 4 +- .../aceEditors/aceEditorsStorageHelper.ts | 4 + .../sites/dashboardSite/dashboardSite.tsx | 11 +- .../dashboardSite/testServerSettingsView.tsx | 14 +- .../sites/systemSettingsSite/settingsView.tsx | 299 ++++++++++++------ .../systemSettingsSite/systemSettingsSite.tsx | 14 +- .../testServerSettingsView.tsx | 63 ++-- .../feedbackPanel/feedbackEditorView.tsx | 2 +- src/constants.ts | 2 +- .../dashboardSite/dashboardCrudActions.ts | 16 +- .../dashboardSite/dashboardSiteActions.ts | 15 +- .../globalSystemSettingsCrudActions.ts | 2 +- .../systemSettingsActions.ts | 23 +- .../systemSettingsCrudActions.ts | 10 +- ...tSubmitTestServerPrivateSettingsReducer.ts | 71 +++++ ...=> getTestServerPrivateSettingsReducer.ts} | 30 +- .../dashboardSite/dashboardSiteActionTypes.ts | 14 +- .../dashboardSite/dashboardSiteReducer.ts | 20 +- .../globalSystemSettingsReducer.ts | 3 + ...etSubmitTestServerPublicSettingsReducer.ts | 68 ++++ .../systemSettingsSiteActionTypes.ts | 7 + .../systemSettingsSiteReducer.ts | 56 +++- src/types/systemSettings.ts | 14 + 26 files changed, 629 insertions(+), 161 deletions(-) create mode 100644 src/state/reducers/dashboardSite/crud/getSubmitTestServerPrivateSettingsReducer.ts rename src/state/reducers/dashboardSite/crud/{getTestServerSettingsReducer.ts => getTestServerPrivateSettingsReducer.ts} (59%) create mode 100644 src/state/reducers/systemSettingsSite/crud/getSubmitTestServerPublicSettingsReducer.ts diff --git a/i18n/en.ts b/i18n/en.ts index 71ee52ae..7a1b5a4c 100644 --- a/i18n/en.ts +++ b/i18n/en.ts @@ -314,6 +314,7 @@ export const lang_en: LangObj = { "Max. tests with one request": "Max. tests with one request", "The max time the user program is allowed to run in ms" : "The max time the user program is allowed to run in ms", + "The max time the user program is allowed to compile in ms" : "The max time the user program is allowed to compile in ms", "If one runs multiple tests this is the number of tests that are actually run with one requests. If there are tests left one must issue a new requests to run all tests": "If one runs multiple tests this is the number of tests that are actually run with one requests. If there are tests left one must issue a new requests to run all tests", @@ -792,7 +793,12 @@ export const lang_en: LangObj = { "These settings are the server constants and are fixed after compiling (hardcoded)." : "These settings are the server constants and are fixed after compiling (hardcoded).", "Server app settings" : "Server app settings", "These settings are the app settings and can be overwritten in appsettings.json file. These are fixed after the server process is started." : "These settings are the app settings and can be overwritten in appsettings.json file. These are fixed after the server process is started.", - "Test server settings": "Test server settings", + + "Public test server settings": "Public test server settings", + "All test server settings (including private)": "All test server settings (including private)", + "Public submit test server settings": "Public submit test server settings", + "All submit test server settings (including private)": "All submit test server settings (including private)", + "Logical usage statistic": "Logical usage statistic", "Property": "Property", "Value": "Value", @@ -862,8 +868,13 @@ export const lang_en: LangObj = { "Submit test server url" : "Submit test server url", "Test server stats url" : "Test server stats url", "The test server status url to get test server settings." : "The test server status url to get test server settings.", + "Submit test server stats url" : "Submit test server stats url", + "The submit test server status url to get test server settings." : "The submit test server status url to get test server settings.", "Test server config ui url" : "Test server config ui url", + "Submit test server config ui url" : "Submit test server config ui url", "Resets this setting to the initial value" : "Resets this setting to the initial value", + "Test server Trace log api url": "Test server Trace log api url", + "The test server trace log api url to remove old trace log entries.": "The test server trace log api url to remove old trace log entries.", "Just run program timeout": "Just run program timeout", "Just run program compile timeout" : "Just run program compile timeout", diff --git a/i18n/i18nRoot.ts b/i18n/i18nRoot.ts index db041c1f..f2866bad 100644 --- a/i18n/i18nRoot.ts +++ b/i18n/i18nRoot.ts @@ -317,6 +317,7 @@ export interface LangObj { "Max. tests with one request": string "The max time the user program is allowed to run in ms": string + "The max time the user program is allowed to compile in ms": string "If one runs multiple tests this is the number of tests that are actually run with one requests. If there are tests left one must issue a new requests to run all tests": string "This value is overwritten by the test-server setting timeout in ms (hardTimeoutInMs) which is the max time the user program can run": string @@ -798,7 +799,10 @@ export interface LangObj { "These settings are the server constants and are fixed after compiling (hardcoded).": string "Server app settings" : string "These settings are the app settings and can be overwritten in appsettings.json file. These are fixed after the server process is started.": string - "Test server settings": string + "Public test server settings": string + "All test server settings (including private)": string + "Public submit test server settings": string + "All submit test server settings (including private)": string "Logical usage statistic": string "Property": string "Value": string @@ -867,8 +871,13 @@ export interface LangObj { "Submit test server url": string "Test server stats url": string "The test server status url to get test server settings.": string + "Submit test server stats url": string + "The submit test server status url to get test server settings.": string "Test server config ui url": string + "Submit test server config ui url": string "Resets this setting to the initial value": string + "Test server Trace log api url": string + "The test server trace log api url to remove old trace log entries.": string "Just run program timeout": string "Just run program compile timeout": string diff --git a/src/communicationLayer/dashboardLayer.ts b/src/communicationLayer/dashboardLayer.ts index 401729b9..141a083e 100644 --- a/src/communicationLayer/dashboardLayer.ts +++ b/src/communicationLayer/dashboardLayer.ts @@ -45,9 +45,9 @@ export async function getClientServerSystemSettings(): Promise<SystemSettingsFro } -export async function getTestServerSettings(): Promise<TestServerPrivateSettings> { +export async function getTestServerSettings(isSubmitTestServerSettings: boolean): Promise<TestServerPrivateSettings> { return genericLayer.get<TestServerPrivateSettings>(callingName, - `${controllerPrefix}/testserver/settings/private` + `${controllerPrefix}/testserver/settings/private/${isSubmitTestServerSettings}` ) } diff --git a/src/communicationLayer/systemSettingsLayer.ts b/src/communicationLayer/systemSettingsLayer.ts index be3f07e3..c842bd24 100644 --- a/src/communicationLayer/systemSettingsLayer.ts +++ b/src/communicationLayer/systemSettingsLayer.ts @@ -47,9 +47,9 @@ export async function changeSystemSettingsFromBackend(systemSettings: SystemSett /** * if the test server is down we get back a response from backend with initial values -1 which should signal that there is some error/problem */ -export async function getTestPublicServerSettings(): Promise<TestServerPublicSettings> { +export async function getTestPublicServerSettings(isSubmitTestServerSettings: boolean): Promise<TestServerPublicSettings> { return genericLayer.get<TestServerPublicSettings>(callingName, - `${controllerPrefix}/testserver/settings/public` + `${controllerPrefix}/testserver/settings/public/${isSubmitTestServerSettings}` ) } diff --git a/src/components/codeEditors/aceEditors/aceEditorsStorageHelper.ts b/src/components/codeEditors/aceEditors/aceEditorsStorageHelper.ts index 1bd98b59..6554d9b9 100644 --- a/src/components/codeEditors/aceEditors/aceEditorsStorageHelper.ts +++ b/src/components/codeEditors/aceEditors/aceEditorsStorageHelper.ts @@ -20,6 +20,10 @@ import {IEditSession, createEditSession} from 'brace'; * @see removeTabToEditor * and called e.g. in the multi file editor when we add/remove a file * + * so e.g. the {@link SimpleAceEditor} tries to find an old session with the same tab id + * so make sure when you want to show the same content e.g. after and modal was shown that the same id is used!! + * you can see {@link FeedbackEditorView} how this can be used when we have no real id (e.g. no backend file id) + * */ export class AceEditorsStorageHelper { private constructor() { diff --git a/src/components/sites/dashboardSite/dashboardSite.tsx b/src/components/sites/dashboardSite/dashboardSite.tsx index 2f4b1f98..bcaee104 100644 --- a/src/components/sites/dashboardSite/dashboardSite.tsx +++ b/src/components/sites/dashboardSite/dashboardSite.tsx @@ -25,6 +25,9 @@ const mapStateToProps = (rootState: RootState /*, props: MyProps*/) => { return { //test0: rootState... //test: props.test + + testServerSettings: rootState.dashboardSiteState.testServerSettings, + submitTestServerSettings: rootState.dashboardSiteState.submitTestServerSettings, } } @@ -63,7 +66,13 @@ class dashboardSite extends React.Component<Props, any> { <ServerConstantsView /> - <TestServerSettingsView/> + <TestServerSettingsView title="All test server settings (including private)" + testServerSettings={this.props.testServerSettings} + /> + + <TestServerSettingsView title="All submit test server settings (including private)" + testServerSettings={this.props.submitTestServerSettings} + /> </div> ) diff --git a/src/components/sites/dashboardSite/testServerSettingsView.tsx b/src/components/sites/dashboardSite/testServerSettingsView.tsx index 9b89349d..326f8cf5 100644 --- a/src/components/sites/dashboardSite/testServerSettingsView.tsx +++ b/src/components/sites/dashboardSite/testServerSettingsView.tsx @@ -10,21 +10,23 @@ import {RootState} from "../../../state/reducers"; import {Table} from "semantic-ui-react"; import SinglePanelSiteWrapper from '../../singlePanelSiteWrapper' import Spinner from "../../helpers/spinner"; -import {getI18n} from "../../../../i18n/i18nRoot"; +import {getI18n, LangObj} from "../../../../i18n/i18nRoot"; import {AnySettingsTable} from './anySettingsTable' import {HelpPopup} from '../../helpers/helpPopup' +import {TestServerPrivateSettings} from '../../../types/dashboard' //const css = require('./styles.styl'); export interface MyProps { - //readonly test: string + readonly title: keyof LangObj + readonly testServerSettings: TestServerPrivateSettings | null } -const mapStateToProps = (rootState: RootState /*, props: MyProps*/) => { +const mapStateToProps = (rootState: RootState, props: MyProps) => { return { //test0: rootState... //test: props.test - testServerSettings: rootState.dashboardSiteState.testServerSettings, + ...props, isLoading: rootState.dashboardSiteState.isLoading, langId: rootState.i18nState.langId } @@ -49,8 +51,6 @@ interface Pair { class logicalUsageView extends React.Component<Props, any> { render(): JSX.Element { - console.log(this.props.testServerSettings) - return ( <SinglePanelSiteWrapper> @@ -67,7 +67,7 @@ class logicalUsageView extends React.Component<Props, any> { <div className="view-caption"> <h2> { - getI18n(this.props.langId,'Test server settings') + getI18n(this.props.langId,this.props.title) } </h2> </div> diff --git a/src/components/sites/systemSettingsSite/settingsView.tsx b/src/components/sites/systemSettingsSite/settingsView.tsx index c1cb0c25..7d1bafb5 100644 --- a/src/components/sites/systemSettingsSite/settingsView.tsx +++ b/src/components/sites/systemSettingsSite/settingsView.tsx @@ -30,8 +30,8 @@ import { setServerSubmitTestServerUrl, setServerTestServerStatsUrl, setServerTestServerTimeoutInMs, - setServerTestServerUrl, - setTestServerConfigUiUrl + setServerTestServerUrl, setSubmitTestServerStatsUrl, + setTestServerConfigUiUrl, setTestServerTraceLogApiUrl } from '../../../state/actions/systemSettingsSite/systemSettingsActions' import {ErrorHelper} from '../../../helpers/errorHelper' import {updateSystemSettingsAsync} from '../../../state/actions/systemSettingsSite/systemSettingsCrudActions' @@ -69,7 +69,9 @@ const mapDispatchToProps = (dispatch: Dispatch) => bindActionCreators({ setServerMaxCustomTestsPerParticipation, setServerTestServerUrl, setServerTestServerStatsUrl, + setSubmitTestServerStatsUrl, setServerSubmitTestServerUrl, + setTestServerTraceLogApiUrl, setTestServerConfigUiUrl, setServerTestServerTimeoutInMs, setServerSubmitTestServerTimeoutInMs, @@ -87,7 +89,6 @@ const mapDispatchToProps = (dispatch: Dispatch) => bindActionCreators({ setServerCustomProjectTestMaxDiskSpaceInKb, - setServerDefaultUserGroupId, setServerDefaultGroupRoleId, setServerDefaultGroupCreatorGroupRoleId, @@ -119,9 +120,10 @@ class SettingsView extends React.Component<Props, any> { getI18n(this.props.langId, "System settings") } </h1> - <HelpPopup className="mar-left-half" style={{marginTop: '0.8em'}} wide defaultText={getI18n(this.props.langId, - 'When the site is loaded the current system settings are loaded from the server and also when the system settings get saved. The system settings (including the server message) are updated for every user every ~' - ) + ` ${refreshServerMessageIntervalInS}` + getI18n(this.props.langId, "s")}/> + <HelpPopup className="mar-left-half" style={{marginTop: '0.8em'}} wide + defaultText={getI18n(this.props.langId, + 'When the site is loaded the current system settings are loaded from the server and also when the system settings get saved. The system settings (including the server message) are updated for every user every ~' + ) + ` ${refreshServerMessageIntervalInS}` + getI18n(this.props.langId, "s")}/> </div> <div className="view-options"> @@ -176,7 +178,7 @@ class SettingsView extends React.Component<Props, any> { <span className="mar-left clickable" onClick={() => { this.props.setServerMessage('') }}> - <HelpPopup icon="remove" defaultText={getI18n(this.props.langId, "Click to clear")} /> + <HelpPopup icon="remove" defaultText={getI18n(this.props.langId, "Click to clear")}/> </span> </div> @@ -405,16 +407,17 @@ class SettingsView extends React.Component<Props, any> { /> </div> - <MaterialInput type="number" value={this.props.systemSettings.testServerTimeoutInMs} onChange={(e) => { + <MaterialInput type="number" value={this.props.systemSettings.testServerTimeoutInMs} + onChange={(e) => { - const val = parseInt(e.currentTarget.value) + const val = parseInt(e.currentTarget.value) - if (isNaN(val)) { - return - } + if (isNaN(val)) { + return + } - this.props.setServerTestServerTimeoutInMs(val) - }} + this.props.setServerTestServerTimeoutInMs(val) + }} /> </Form.Field> @@ -445,16 +448,17 @@ class SettingsView extends React.Component<Props, any> { /> </div> - <MaterialInput type="number" value={this.props.systemSettings.submitTestServerTimeoutInMs} onChange={(e) => { + <MaterialInput type="number" value={this.props.systemSettings.submitTestServerTimeoutInMs} + onChange={(e) => { - const val = parseInt(e.currentTarget.value) + const val = parseInt(e.currentTarget.value) - if (isNaN(val)) { - return - } + if (isNaN(val)) { + return + } - this.props.setServerSubmitTestServerTimeoutInMs(val) - }} + this.props.setServerSubmitTestServerTimeoutInMs(val) + }} /> </Form.Field> @@ -476,7 +480,31 @@ class SettingsView extends React.Component<Props, any> { content={getI18n(this.props.langId, "Resets this setting to the initial value")} /> </div> - <MaterialInput value={this.props.systemSettings.testServerConfigUiUrl} onChange={(e) => { + <MaterialInput value={this.props.systemSettings.testServerConfigUiUrl} onChange={(e) => { + this.props.setTestServerConfigUiUrl(e.currentTarget.value) + }} + /> + </Form.Field> + + <Form.Field> + <div className="form-field-label-with-icon"> + <label> + { + getI18n(this.props.langId, "Submit test server config ui url") + } + </label> + <MyPopup + trigger={ + <div className="clickable inline-div mar-left" onClick={() => { + this.props.setTestServerConfigUiUrl(this.props.initialSystemSettings.testServerConfigUiUrl) + }}> + <Icon name="undo"/> + </div> + } + content={getI18n(this.props.langId, "Resets this setting to the initial value")} + /> + </div> + <MaterialInput value={this.props.systemSettings.testServerConfigUiUrl} onChange={(e) => { this.props.setTestServerConfigUiUrl(e.currentTarget.value) }} /> @@ -510,7 +538,7 @@ class SettingsView extends React.Component<Props, any> { content={getI18n(this.props.langId, "Resets this setting to the initial value")} /> </div> - <MaterialInput value={this.props.systemSettings.testServerUrl} onChange={(e) => { + <MaterialInput value={this.props.systemSettings.testServerUrl} onChange={(e) => { this.props.setServerTestServerUrl(e.currentTarget.value) }} /> @@ -530,7 +558,8 @@ class SettingsView extends React.Component<Props, any> { <MyPopup trigger={ <div className="clickable inline-div mar-left" onClick={() => { - this.props.setServerSubmitTestServerUrl(this.props.initialSystemSettings.submitTestServerUrl) + this.props.setServerSubmitTestServerUrl( + this.props.initialSystemSettings.submitTestServerUrl) }}> <Icon name="undo"/> </div> @@ -580,9 +609,87 @@ class SettingsView extends React.Component<Props, any> { /> </Form.Field> + { + //submit test server stats url + } + <Form.Field> + <div className="form-field-label-with-icon"> + <label> + { + getI18n(this.props.langId, "Submit test server stats url") + } + </label> + <HelpPopup wide + className="mar-left-half" + defaultText={getI18n(this.props.langId, + "The submit test server status url to get test server settings." + )} + /> + + <MyPopup + trigger={ + <div className="clickable inline-div mar-left" onClick={() => { + this.props.setSubmitTestServerStatsUrl( + this.props.initialSystemSettings.submitTestServerStatsUrl) + }}> + <Icon name="undo"/> + </div> + } + content={getI18n(this.props.langId, "Resets this setting to the initial value")} + /> + + </div> + <MaterialInput value={this.props.systemSettings.submitTestServerStatsUrl} onChange={(e) => { + this.props.setSubmitTestServerStatsUrl(e.currentTarget.value) + }} + /> + </Form.Field> + </Form.Group> + { + //test server trace log api url + } + <Form.Group widths="equal"> + + { + //test server trace log api url + } + <Form.Field> + <div className="form-field-label-with-icon"> + <label> + { + getI18n(this.props.langId, "Test server Trace log api url") + } + </label> + <HelpPopup wide + className="mar-left-half" + defaultText={getI18n(this.props.langId, + "The test server trace log api url to remove old trace log entries." + )} + /> + + <MyPopup + trigger={ + <div className="clickable inline-div mar-left" onClick={() => { + this.props.setTestServerTraceLogApiUrl( + this.props.initialSystemSettings.testServerTraceLogApiUrl) + }}> + <Icon name="undo"/> + </div> + } + content={getI18n(this.props.langId, "Resets this setting to the initial value")} + /> + + </div> + <MaterialInput value={this.props.systemSettings.testServerTraceLogApiUrl} onChange={(e) => { + this.props.setTestServerTraceLogApiUrl(e.currentTarget.value) + }} + /> + </Form.Field> + </Form.Group> + { //just run program limits } @@ -601,7 +708,8 @@ class SettingsView extends React.Component<Props, any> { <MyPopup trigger={ <div className="clickable inline-div mar-left" onClick={() => { - this.props.setServerJustRunProgramTimeoutInMs(this.props.initialSystemSettings.justRunProgramTimeoutInMs) + this.props.setServerJustRunProgramTimeoutInMs( + this.props.initialSystemSettings.justRunProgramTimeoutInMs) }}> <Icon name="undo"/> </div> @@ -609,16 +717,17 @@ class SettingsView extends React.Component<Props, any> { content={getI18n(this.props.langId, "Resets this setting to the initial value")} /> </div> - <MaterialInput type="number" value={this.props.systemSettings.justRunProgramTimeoutInMs} onChange={(e) => { + <MaterialInput type="number" value={this.props.systemSettings.justRunProgramTimeoutInMs} + onChange={(e) => { - const val = parseInt(e.currentTarget.value) + const val = parseInt(e.currentTarget.value) - if (isNaN(val)) { - return - } + if (isNaN(val)) { + return + } - this.props.setServerJustRunProgramTimeoutInMs(val) - }} + this.props.setServerJustRunProgramTimeoutInMs(val) + }} /> </Form.Field> @@ -635,7 +744,8 @@ class SettingsView extends React.Component<Props, any> { <MyPopup trigger={ <div className="clickable inline-div mar-left" onClick={() => { - this.props.setJustRunProgramCompileTimeoutInMs(this.props.initialSystemSettings.justRunProgramCompileTimeoutInMs) + this.props.setJustRunProgramCompileTimeoutInMs( + this.props.initialSystemSettings.justRunProgramCompileTimeoutInMs) }}> <Icon name="undo"/> </div> @@ -643,16 +753,17 @@ class SettingsView extends React.Component<Props, any> { content={getI18n(this.props.langId, "Resets this setting to the initial value")} /> </div> - <MaterialInput type="number" value={this.props.systemSettings.justRunProgramCompileTimeoutInMs} onChange={(e) => { + <MaterialInput type="number" value={this.props.systemSettings.justRunProgramCompileTimeoutInMs} + onChange={(e) => { - const val = parseInt(e.currentTarget.value) + const val = parseInt(e.currentTarget.value) - if (isNaN(val)) { - return - } + if (isNaN(val)) { + return + } - this.props.setJustRunProgramCompileTimeoutInMs(val) - }} + this.props.setJustRunProgramCompileTimeoutInMs(val) + }} /> </Form.Field> @@ -669,7 +780,8 @@ class SettingsView extends React.Component<Props, any> { <MyPopup trigger={ <div className="clickable inline-div mar-left" onClick={() => { - this.props.setServerJustRunProgramMemoryLimitInKb(this.props.initialSystemSettings.justRunProgramMemoryLimitInKb) + this.props.setServerJustRunProgramMemoryLimitInKb( + this.props.initialSystemSettings.justRunProgramMemoryLimitInKb) }}> <Icon name="undo"/> </div> @@ -677,16 +789,17 @@ class SettingsView extends React.Component<Props, any> { content={getI18n(this.props.langId, "Resets this setting to the initial value")} /> </div> - <MaterialInput type="number" value={this.props.systemSettings.justRunProgramMemoryLimitInKb} onChange={(e) => { + <MaterialInput type="number" value={this.props.systemSettings.justRunProgramMemoryLimitInKb} + onChange={(e) => { - const val = parseInt(e.currentTarget.value) + const val = parseInt(e.currentTarget.value) - if (isNaN(val)) { - return - } + if (isNaN(val)) { + return + } - this.props.setServerJustRunProgramMemoryLimitInKb(val) - }} + this.props.setServerJustRunProgramMemoryLimitInKb(val) + }} /> </Form.Field> @@ -703,7 +816,8 @@ class SettingsView extends React.Component<Props, any> { <MyPopup trigger={ <div className="clickable inline-div mar-left" onClick={() => { - this.props.setServerJustRunProgramMaxDiskSpaceInKb(this.props.initialSystemSettings.justRunProgramMaxDiskSpaceInKb) + this.props.setServerJustRunProgramMaxDiskSpaceInKb( + this.props.initialSystemSettings.justRunProgramMaxDiskSpaceInKb) }}> <Icon name="undo"/> </div> @@ -711,16 +825,17 @@ class SettingsView extends React.Component<Props, any> { content={getI18n(this.props.langId, "Resets this setting to the initial value")} /> </div> - <MaterialInput type="number" value={this.props.systemSettings.justRunProgramMaxDiskSpaceInKb} onChange={(e) => { + <MaterialInput type="number" value={this.props.systemSettings.justRunProgramMaxDiskSpaceInKb} + onChange={(e) => { - const val = parseInt(e.currentTarget.value) + const val = parseInt(e.currentTarget.value) - if (isNaN(val)) { - return - } + if (isNaN(val)) { + return + } - this.props.setServerJustRunProgramMaxDiskSpaceInKb(val) - }} + this.props.setServerJustRunProgramMaxDiskSpaceInKb(val) + }} /> </Form.Field> @@ -744,7 +859,8 @@ class SettingsView extends React.Component<Props, any> { <MyPopup trigger={ <div className="clickable inline-div mar-left" onClick={() => { - this.props.setServerCustomProjectTestTimeoutInMs(this.props.initialSystemSettings.customProjectTestTimeoutInMs) + this.props.setServerCustomProjectTestTimeoutInMs( + this.props.initialSystemSettings.customProjectTestTimeoutInMs) }}> <Icon name="undo"/> </div> @@ -752,16 +868,17 @@ class SettingsView extends React.Component<Props, any> { content={getI18n(this.props.langId, "Resets this setting to the initial value")} /> </div> - <MaterialInput type="number" value={this.props.systemSettings.customProjectTestTimeoutInMs} onChange={(e) => { + <MaterialInput type="number" value={this.props.systemSettings.customProjectTestTimeoutInMs} + onChange={(e) => { - const val = parseInt(e.currentTarget.value) + const val = parseInt(e.currentTarget.value) - if (isNaN(val)) { - return - } + if (isNaN(val)) { + return + } - this.props.setServerCustomProjectTestTimeoutInMs(val) - }} + this.props.setServerCustomProjectTestTimeoutInMs(val) + }} /> </Form.Field> @@ -778,7 +895,8 @@ class SettingsView extends React.Component<Props, any> { <MyPopup trigger={ <div className="clickable inline-div mar-left" onClick={() => { - this.props.setCustomProjectTestCompileTimeoutInMs(this.props.initialSystemSettings.customProjectTestCompileTimeoutInMs) + this.props.setCustomProjectTestCompileTimeoutInMs( + this.props.initialSystemSettings.customProjectTestCompileTimeoutInMs) }}> <Icon name="undo"/> </div> @@ -786,16 +904,17 @@ class SettingsView extends React.Component<Props, any> { content={getI18n(this.props.langId, "Resets this setting to the initial value")} /> </div> - <MaterialInput type="number" value={this.props.systemSettings.customProjectTestCompileTimeoutInMs} onChange={(e) => { + <MaterialInput type="number" value={this.props.systemSettings.customProjectTestCompileTimeoutInMs} + onChange={(e) => { - const val = parseInt(e.currentTarget.value) + const val = parseInt(e.currentTarget.value) - if (isNaN(val)) { - return - } + if (isNaN(val)) { + return + } - this.props.setCustomProjectTestCompileTimeoutInMs(val) - }} + this.props.setCustomProjectTestCompileTimeoutInMs(val) + }} /> </Form.Field> { @@ -811,7 +930,8 @@ class SettingsView extends React.Component<Props, any> { <MyPopup trigger={ <div className="clickable inline-div mar-left" onClick={() => { - this.props.setServerCustomProjectTestMemoryLimitInKb(this.props.initialSystemSettings.customProjectTestMemoryLimitInKb) + this.props.setServerCustomProjectTestMemoryLimitInKb( + this.props.initialSystemSettings.customProjectTestMemoryLimitInKb) }}> <Icon name="undo"/> </div> @@ -819,16 +939,17 @@ class SettingsView extends React.Component<Props, any> { content={getI18n(this.props.langId, "Resets this setting to the initial value")} /> </div> - <MaterialInput type="number" value={this.props.systemSettings.customProjectTestMemoryLimitInKb} onChange={(e) => { + <MaterialInput type="number" value={this.props.systemSettings.customProjectTestMemoryLimitInKb} + onChange={(e) => { - const val = parseInt(e.currentTarget.value) + const val = parseInt(e.currentTarget.value) - if (isNaN(val)) { - return - } + if (isNaN(val)) { + return + } - this.props.setServerCustomProjectTestMemoryLimitInKb(val) - }} + this.props.setServerCustomProjectTestMemoryLimitInKb(val) + }} /> </Form.Field> @@ -845,7 +966,8 @@ class SettingsView extends React.Component<Props, any> { <MyPopup trigger={ <div className="clickable inline-div mar-left" onClick={() => { - this.props.setServerCustomProjectTestMaxDiskSpaceInKb(this.props.initialSystemSettings.customProjectTestMaxDiskSpaceInKb) + this.props.setServerCustomProjectTestMaxDiskSpaceInKb( + this.props.initialSystemSettings.customProjectTestMaxDiskSpaceInKb) }}> <Icon name="undo"/> </div> @@ -853,16 +975,17 @@ class SettingsView extends React.Component<Props, any> { content={getI18n(this.props.langId, "Resets this setting to the initial value")} /> </div> - <MaterialInput type="number" value={this.props.systemSettings.customProjectTestMaxDiskSpaceInKb} onChange={(e) => { + <MaterialInput type="number" value={this.props.systemSettings.customProjectTestMaxDiskSpaceInKb} + onChange={(e) => { - const val = parseInt(e.currentTarget.value) + const val = parseInt(e.currentTarget.value) - if (isNaN(val)) { - return - } + if (isNaN(val)) { + return + } - this.props.setServerCustomProjectTestMaxDiskSpaceInKb(val) - }} + this.props.setServerCustomProjectTestMaxDiskSpaceInKb(val) + }} /> </Form.Field> diff --git a/src/components/sites/systemSettingsSite/systemSettingsSite.tsx b/src/components/sites/systemSettingsSite/systemSettingsSite.tsx index 029a8a6b..27ba3f6a 100644 --- a/src/components/sites/systemSettingsSite/systemSettingsSite.tsx +++ b/src/components/sites/systemSettingsSite/systemSettingsSite.tsx @@ -17,6 +17,7 @@ import {getPLangsWithExtraDataAsync} from '../../../state/actions/plangSettingsV import LanguageSettingsView from './languageSettingsView' import {getLangsAsync} from '../../../state/actions/langsView/langCrudActions' import TestServerSettingsView from './testServerSettingsView' +import {getSubmitTestServerPublicSettingsAsync} from '../../../state/actions/systemSettingsSite/systemSettingsCrudActions' export interface MyProps { //readonly test: string @@ -32,6 +33,9 @@ const mapStateToProps = (rootState: RootState /*, props: MyProps*/) => { ? rootState.userDataSettingsSate.userData.systemRole : null, + testServerPublicSettings: rootState.globalSystemSettingsState.testServerPublicSettings, + submitTestServerPublicSettings: rootState.systemSettingsSiteState.submitTestServerPublicSettings, + langId: rootState.i18nState.langId, } } @@ -86,7 +90,15 @@ class SystemSettingsSite extends React.Component<Props, any> { <SettingsView /> - <TestServerSettingsView /> + <TestServerSettingsView title="Public test server settings" + testServerPublicSettings={this.props.testServerPublicSettings} + testServerConfigUiUrl={this.props.systemSettings.testServerConfigUiUrl} + /> + + <TestServerSettingsView title="Public submit test server settings" + testServerPublicSettings={this.props.submitTestServerPublicSettings} + testServerConfigUiUrl={this.props.systemSettings.submitTestServerConfigUiUrl} + /> <PlangSettingsView /> diff --git a/src/components/sites/systemSettingsSite/testServerSettingsView.tsx b/src/components/sites/systemSettingsSite/testServerSettingsView.tsx index a3930e50..2737cc83 100644 --- a/src/components/sites/systemSettingsSite/testServerSettingsView.tsx +++ b/src/components/sites/systemSettingsSite/testServerSettingsView.tsx @@ -5,25 +5,26 @@ import {returntypeof} from 'react-redux-typescript'; import {RootState} from '../../../state/reducers' import Spinner from '../../helpers/spinner' import SinglePanelSiteWrapper from '../../singlePanelSiteWrapper' -import {getI18n} from '../../../../i18n/i18nRoot' +import {getI18n, LangObj} from '../../../../i18n/i18nRoot' import {HelpPopup} from '../../helpers/helpPopup' -import {refreshServerMessageIntervalInS, testServerPublicSettingsNotAvailableValue} from '../../../constants' -import {ErrorHelper} from '../../../helpers/errorHelper' +import {testServerPublicSettingsNotAvailableValue} from '../../../constants' import {Form, Icon} from 'semantic-ui-react' import {MyPopup} from '../../helpers/myPopup' import MaterialInput from '../../material/materialInput' +import {TestServerPublicSettings} from '../../../types/systemSettings' export interface MyProps { - //readonly test: string + readonly title: keyof LangObj + readonly testServerPublicSettings: TestServerPublicSettings + + readonly testServerConfigUiUrl: string } -const mapStateToProps = (rootState: RootState /*, props: MyProps*/) => { +const mapStateToProps = (rootState: RootState , props: MyProps) => { return { //test0: rootState... - //test: props.test + ...props, isLoading: rootState.systemSettingsSiteState.isLoading, - testServerPublicSettings: rootState.globalSystemSettingsState.testServerPublicSettings, - systemSettings: rootState.systemSettingsSiteState.systemSettings, langId: rootState.i18nState.langId, } @@ -59,7 +60,7 @@ class TestServerSettingsView extends React.Component<Props, any> { <div className="view-caption"> <h1 className="clear-margin"> { - getI18n(this.props.langId, "Test server settings") + getI18n(this.props.langId, this.props.title) } </h1> @@ -68,16 +69,17 @@ class TestServerSettingsView extends React.Component<Props, any> { <HelpPopup icon="warning sign" className="warning-colored mar-left-half v-centered" defaultText={getI18n(this.props.langId, "The test-server settings are not available")} /> } - <MyPopup - trigger={ - <a className="mar-left-half" href={this.props.systemSettings.testServerConfigUiUrl - ? this.props.systemSettings.testServerConfigUiUrl - : '#'} target="_blank"> - <Icon name="external alternate" /> - </a> - } - content={getI18n(this.props.langId, "Click to open the test server configuration page")} - /> + { + this.props.testServerConfigUiUrl && + <MyPopup + trigger={ + <a className="mar-left-half" href={this.props.testServerConfigUiUrl} target="_blank"> + <Icon name="external alternate" /> + </a> + } + content={getI18n(this.props.langId, "Click to open the test server configuration page")} + /> + } </div> <div className="view-options"> @@ -113,6 +115,29 @@ class TestServerSettingsView extends React.Component<Props, any> { /> </Form.Field> + { + //hard timeout for all test server tests + } + <Form.Field> + + <div className="form-field-label-with-icon"> + <label> + { + getI18n(this.props.langId, "Compile timeout in ms") + } + </label> + <HelpPopup wide + className="mar-left-half" + defaultText={getI18n(this.props.langId, + "The max time the user program is allowed to compile in ms" + )} + /> + + </div> + <MaterialInput type="number" value={this.props.testServerPublicSettings.hardCompileTimeoutInMs} disabled + /> + </Form.Field> + <Form.Field> diff --git a/src/components/sites/tutorViewSite/feedbackPanel/feedbackEditorView.tsx b/src/components/sites/tutorViewSite/feedbackPanel/feedbackEditorView.tsx index 564168e6..29996b5c 100644 --- a/src/components/sites/tutorViewSite/feedbackPanel/feedbackEditorView.tsx +++ b/src/components/sites/tutorViewSite/feedbackPanel/feedbackEditorView.tsx @@ -49,7 +49,7 @@ class FeedbackEditorView extends React.Component<Props, any> { //and we switch to that empty feedback (ace session) const tempEditorTab: EditorTab = { - id: 0, //this.props.assessment.userId + id: 0, //not -1 else we cannot distinct between this and the default tab/session content: (this.props.assessment.hasAssessment && this.props.assessment.feedbackForStudent !== null) ? this.props.assessment.feedbackForStudent : '', diff --git a/src/constants.ts b/src/constants.ts index 6536091d..37fbf51a 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -13,7 +13,7 @@ import Logger from './helpers/logger' * y - breaking changes / new features * z - fixes, small changes */ -export const versionString = '2.5.15' +export const versionString = '2.6.0' export const supportMail = 'yapex@informatik.uni-halle.de' diff --git a/src/state/actions/dashboardSite/dashboardCrudActions.ts b/src/state/actions/dashboardSite/dashboardCrudActions.ts index cd18241b..d5abe517 100644 --- a/src/state/actions/dashboardSite/dashboardCrudActions.ts +++ b/src/state/actions/dashboardSite/dashboardCrudActions.ts @@ -9,9 +9,10 @@ import { } from "../../../communicationLayer/dashboardLayer"; import {GET_hardwareUsageAction} from "../../reducers/dashboardSite/crud/getHardwareUsageReducer"; import {GET_logicalUsageAction} from "../../reducers/dashboardSite/crud/getLogicalUsageReducer"; -import {GET_testServerSettingsAction} from "../../reducers/dashboardSite/crud/getTestServerSettingsReducer"; +import {GET_testServerPrivateSettingsAction} from "../../reducers/dashboardSite/crud/getTestServerPrivateSettingsReducer"; import {GET_clientServerConstantsAction} from '../../reducers/dashboardSite/crud/getClientServerConstantsReducer' import {GET_clientServerAppSettingsAction} from '../../reducers/dashboardSite/crud/getClientServerAppSettingsReducer' +import {GET_submitTestServerSettingsAction} from '../../reducers/dashboardSite/crud/getSubmitTestServerPrivateSettingsReducer' /** * Created by janis dähne. @@ -53,10 +54,17 @@ export function getClientServerAppSettingsAsync(): GET_clientServerAppSettingsAc } } -export function getTestServerSettingsAsync(): GET_testServerSettingsAction { +export function getTestServerPrivateSettingsAsync(): GET_testServerPrivateSettingsAction { return { - type: ActionType.GET_testServerSettings, - payload: delay(getTestServerSettings()) + type: ActionType.GET_testServerPrivateSettings, + payload: delay(getTestServerSettings(false)) + } +} + +export function getSubmitTestServerPrivateSettingsAsync(): GET_submitTestServerSettingsAction { + return { + type: ActionType.GET_submitTestServerSettings, + payload: delay(getTestServerSettings(true)) } } diff --git a/src/state/actions/dashboardSite/dashboardSiteActions.ts b/src/state/actions/dashboardSite/dashboardSiteActions.ts index 8b6954e7..d5c29f26 100644 --- a/src/state/actions/dashboardSite/dashboardSiteActions.ts +++ b/src/state/actions/dashboardSite/dashboardSiteActions.ts @@ -2,8 +2,11 @@ import {AwaitActions} from "../types"; import { getClientServerAppSettingsAsync, getClientServerConstantsAsync, - getClientServerSystemSettingsAsync, getHardwareUsageAsync, getLogicalUsageAsync, - getTestServerSettingsAsync + getClientServerSystemSettingsAsync, + getHardwareUsageAsync, + getLogicalUsageAsync, + getSubmitTestServerPrivateSettingsAsync, + getTestServerPrivateSettingsAsync } from "./dashboardCrudActions"; import { ResetAction, @@ -32,7 +35,13 @@ export function loadDashboardSite(): AwaitActions { } try { - await dispatch(getTestServerSettingsAsync()) + await dispatch(getTestServerPrivateSettingsAsync()) + } catch(err) { + + } + + try { + await dispatch(getSubmitTestServerPrivateSettingsAsync()) } catch(err) { } diff --git a/src/state/actions/globalSystemSettings/globalSystemSettingsCrudActions.ts b/src/state/actions/globalSystemSettings/globalSystemSettingsCrudActions.ts index fcf95c4f..b758fdac 100644 --- a/src/state/actions/globalSystemSettings/globalSystemSettingsCrudActions.ts +++ b/src/state/actions/globalSystemSettings/globalSystemSettingsCrudActions.ts @@ -20,7 +20,7 @@ export function getGlobalSystemSettingsAsync(): GET_globalSystemSettingsAction { export function getTestServerPublicSettingsAsync(): GET_testServerPublicSettingsAction { return { type: ActionType.GET_testServerPublicSettings, - payload: delay(getTestPublicServerSettings()) + payload: delay(getTestPublicServerSettings(false)) } } diff --git a/src/state/actions/systemSettingsSite/systemSettingsActions.ts b/src/state/actions/systemSettingsSite/systemSettingsActions.ts index 3060bb81..e74897aa 100644 --- a/src/state/actions/systemSettingsSite/systemSettingsActions.ts +++ b/src/state/actions/systemSettingsSite/systemSettingsActions.ts @@ -3,7 +3,7 @@ import {MultiActions} from '../types' import { getAllDefaultGroupsAsync, getAllDefaultRolesAsync, - getInitialSystemSettingsAsync, + getInitialSystemSettingsAsync, getSubmitTestServerPublicSettingsAsync, getSystemSettingsAsync } from './systemSettingsCrudActions' import { @@ -21,12 +21,12 @@ import { SET_maxCustomTestsPerParticipationAction, SET_maxNumberOfTestsWithOneRequestAction, SET_maxNumberOfTestsWithOneRequestSubmitTestServerAction, - SET_serverMessageAction, + SET_serverMessageAction, SET_submitTestServerStatsUrlAction, SET_submitTestServerTimeoutInMsAction, SET_submitTestServerUrlAction, SET_testServerConfigUiUrlAction, SET_testServerStatsUrlAction, - SET_testServerTimeoutInMsAction, + SET_testServerTimeoutInMsAction, SET_testServerTraceLogApiUrlAction, SET_testServerUrlAction } from '../../reducers/systemSettingsSite/systemSettingsSiteReducer' @@ -67,6 +67,14 @@ export function setServerTestServerStatsUrl(testServerStatsUrl: string): SET_tes } } +export function setSubmitTestServerStatsUrl(submitTestServerStatsUrl: string): SET_submitTestServerStatsUrlAction { + return { + type: ActionType.SET_submitTestServerStatsUrl, + submitTestServerStatsUrl + } +} + + export function setServerSubmitTestServerUrl(submitTestServerUrl: string): SET_submitTestServerUrlAction { return { type: ActionType.SET_submitTestServerUrl, @@ -74,6 +82,13 @@ export function setServerSubmitTestServerUrl(submitTestServerUrl: string): SET_s } } +export function setTestServerTraceLogApiUrl(testServerTraceLogApiUrl: string): SET_testServerTraceLogApiUrlAction { + return { + type: ActionType.SET_testServerTraceLogApiUrl, + testServerTraceLogApiUrl + } +} + export function setTestServerConfigUiUrl(testServerConfigUiUrl: string): SET_testServerConfigUiUrlAction { return { type: ActionType.SET_testServerConfigUiUrl, @@ -200,6 +215,8 @@ export function loadSystemSettingsSite(): MultiActions { await dispatch(getAllDefaultGroupsAsync()) await dispatch(getAllDefaultRolesAsync()) + await dispatch(getSubmitTestServerPublicSettingsAsync()) + } } diff --git a/src/state/actions/systemSettingsSite/systemSettingsCrudActions.ts b/src/state/actions/systemSettingsSite/systemSettingsCrudActions.ts index 9c296e83..84abe8e6 100644 --- a/src/state/actions/systemSettingsSite/systemSettingsCrudActions.ts +++ b/src/state/actions/systemSettingsSite/systemSettingsCrudActions.ts @@ -3,13 +3,14 @@ import {ActionType} from '../../reducers/systemSettingsSite/systemSettingsSiteAc import {delay} from '../../../../debug' import { changeSystemSettingsFromBackend, getAllDefaultGroups, getAllDefaultRoles, getInitialSystemSettingsFromBackend, - getSystemSettingsFromBackend + getSystemSettingsFromBackend, getTestPublicServerSettings } from '../../../communicationLayer/systemSettingsLayer' import {SystemSettingsForBackend} from '../../../types/systemSettings' import {UPDATE_systemSettingsAction} from '../../reducers/systemSettingsSite/crud/updateSystemSettingsReducer' import {GET_initialSystemSettingsAction} from '../../reducers/systemSettingsSite/crud/getInitialSystemSettingsReducer' import {GET_allDefaultGroupsAction} from '../../reducers/systemSettingsSite/crud/getAllDefaultGroupsReducer' import {GET_allDefaultRolesAction} from '../../reducers/systemSettingsSite/crud/getAllDefaultRolesReducer' +import {GET_submitTestServerPublicSettingsAction} from '../../reducers/systemSettingsSite/crud/getSubmitTestServerPublicSettingsReducer' export function getSystemSettingsAsync(): GET_systemSettingsAction { return { @@ -48,3 +49,10 @@ export function getAllDefaultRolesAsync(): GET_allDefaultRolesAction { } } + +export function getSubmitTestServerPublicSettingsAsync(): GET_submitTestServerPublicSettingsAction { + return { + type: ActionType.GET_submitTestServerPublicSettings, + payload: delay(getTestPublicServerSettings(true)) + } +} diff --git a/src/state/reducers/dashboardSite/crud/getSubmitTestServerPrivateSettingsReducer.ts b/src/state/reducers/dashboardSite/crud/getSubmitTestServerPrivateSettingsReducer.ts new file mode 100644 index 00000000..95b82926 --- /dev/null +++ b/src/state/reducers/dashboardSite/crud/getSubmitTestServerPrivateSettingsReducer.ts @@ -0,0 +1,71 @@ +/** + * Created by janis dähne. + */ +import {ActionBase, ActionType} from "../dashboardSiteActionTypes"; +import {initial, State} from "../dashboardSiteReducer"; +import {TestServerPrivateSettings} from "../../../../types/dashboard"; +import {ReduxPromiseAction, ReduxPromiseFulfilledAction, ReduxPromiseRejectedAction} from "../../index"; +import {notExhaustive} from "../../_notExhausiveHelper"; + + +export interface GET_submitTestServerSettingsAction + extends ActionBase, ReduxPromiseAction<TestServerPrivateSettings, GET_submitTestServerSettings_PENDINGAction, GET_submitTestServerSettings_FULFILLEDAction, GET_submitTestServerSettings_REJECTEDAction> { + readonly type: ActionType.GET_submitTestServerSettings + readonly payload: Promise<TestServerPrivateSettings> +} + +//automatically dispatched by redux promise middleware +export interface GET_submitTestServerSettings_PENDINGAction + extends ActionBase { + readonly type: ActionType.GET_submitTestServerSettings_PENDING +} + +//automatically dispatched by redux promise middleware +export interface GET_submitTestServerSettings_FULFILLEDAction + extends ActionBase, ReduxPromiseFulfilledAction<TestServerPrivateSettings> { + readonly type: ActionType.GET_submitTestServerSettings_FULFILLED + readonly payload: TestServerPrivateSettings +} + +//automatically dispatched by redux promise middleware +export interface GET_submitTestServerSettings_REJECTEDAction + extends ActionBase, ReduxPromiseRejectedAction<void> { + readonly type: ActionType.GET_submitTestServerSettings_REJECTED + readonly payload: any +} + + +export type AllActions = + GET_submitTestServerSettings_PENDINGAction + | GET_submitTestServerSettings_FULFILLEDAction + | GET_submitTestServerSettings_REJECTEDAction + + +export function reducer(state: State = initial, action: AllActions): State { + + switch (action.type) { + + case ActionType.GET_submitTestServerSettings_PENDING: + return { + ...state, + isLoading: true + } + case ActionType.GET_submitTestServerSettings_FULFILLED: + return { + ...state, + isLoading: false, + submitTestServerSettings: action.payload + } + case ActionType.GET_submitTestServerSettings_REJECTED: + return { + ...state, + isLoading: false, + submitTestServerSettings: null + } + + default: + notExhaustive(action) + return state + } +} + diff --git a/src/state/reducers/dashboardSite/crud/getTestServerSettingsReducer.ts b/src/state/reducers/dashboardSite/crud/getTestServerPrivateSettingsReducer.ts similarity index 59% rename from src/state/reducers/dashboardSite/crud/getTestServerSettingsReducer.ts rename to src/state/reducers/dashboardSite/crud/getTestServerPrivateSettingsReducer.ts index fa821033..cf31ad19 100644 --- a/src/state/reducers/dashboardSite/crud/getTestServerSettingsReducer.ts +++ b/src/state/reducers/dashboardSite/crud/getTestServerPrivateSettingsReducer.ts @@ -8,55 +8,55 @@ import {ReduxPromiseAction, ReduxPromiseFulfilledAction, ReduxPromiseRejectedAct import {notExhaustive} from "../../_notExhausiveHelper"; -export interface GET_testServerSettingsAction - extends ActionBase, ReduxPromiseAction<TestServerPrivateSettings, GET_testServerSettings_PENDINGAction, GET_testServerSettings_FULFILLEDAction, GET_testServerSettings_REJECTEDAction> { - readonly type: ActionType.GET_testServerSettings +export interface GET_testServerPrivateSettingsAction + extends ActionBase, ReduxPromiseAction<TestServerPrivateSettings, GET_testServerPrivateSettings_PENDINGAction, GET_testServerPrivateSettings_FULFILLEDAction, GET_testServerPrivateSettings_REJECTEDAction> { + readonly type: ActionType.GET_testServerPrivateSettings readonly payload: Promise<TestServerPrivateSettings> } //automatically dispatched by redux promise middleware -export interface GET_testServerSettings_PENDINGAction +export interface GET_testServerPrivateSettings_PENDINGAction extends ActionBase { - readonly type: ActionType.GET_testServerSettings_PENDING + readonly type: ActionType.GET_testServerPrivateSettings_PENDING } //automatically dispatched by redux promise middleware -export interface GET_testServerSettings_FULFILLEDAction +export interface GET_testServerPrivateSettings_FULFILLEDAction extends ActionBase, ReduxPromiseFulfilledAction<TestServerPrivateSettings> { - readonly type: ActionType.GET_testServerSettings_FULFILLED + readonly type: ActionType.GET_testServerPrivateSettings_FULFILLED readonly payload: TestServerPrivateSettings } //automatically dispatched by redux promise middleware -export interface GET_testServerSettings_REJECTEDAction +export interface GET_testServerPrivateSettings_REJECTEDAction extends ActionBase, ReduxPromiseRejectedAction<void> { - readonly type: ActionType.GET_testServerSettings_REJECTED + readonly type: ActionType.GET_testServerPrivateSettings_REJECTED readonly payload: any } export type AllActions = - GET_testServerSettings_PENDINGAction - | GET_testServerSettings_FULFILLEDAction - | GET_testServerSettings_REJECTEDAction + GET_testServerPrivateSettings_PENDINGAction + | GET_testServerPrivateSettings_FULFILLEDAction + | GET_testServerPrivateSettings_REJECTEDAction export function reducer(state: State = initial, action: AllActions): State { switch (action.type) { - case ActionType.GET_testServerSettings_PENDING: + case ActionType.GET_testServerPrivateSettings_PENDING: return { ...state, isLoading: true } - case ActionType.GET_testServerSettings_FULFILLED: + case ActionType.GET_testServerPrivateSettings_FULFILLED: return { ...state, isLoading: false, testServerSettings: action.payload } - case ActionType.GET_testServerSettings_REJECTED: + case ActionType.GET_testServerPrivateSettings_REJECTED: return { ...state, isLoading: false, diff --git a/src/state/reducers/dashboardSite/dashboardSiteActionTypes.ts b/src/state/reducers/dashboardSite/dashboardSiteActionTypes.ts index 0cc06857..49c1bf71 100644 --- a/src/state/reducers/dashboardSite/dashboardSiteActionTypes.ts +++ b/src/state/reducers/dashboardSite/dashboardSiteActionTypes.ts @@ -37,10 +37,16 @@ export enum ActionType { GET_clientServerSettings_FULFILLED = 'dashboardSiteReducer_GET_clientServerSettings_FULFILLED', GET_clientServerSettings_REJECTED = 'dashboardSiteReducer_GET_clientServerSettings_REJECTED', - GET_testServerSettings = 'dashboardSiteReducer_GET_testServerSettings', - GET_testServerSettings_PENDING = 'dashboardSiteReducer_GET_testServerSettings_PENDING', - GET_testServerSettings_FULFILLED = 'dashboardSiteReducer_GET_testServerSettings_FULFILLED', - GET_testServerSettings_REJECTED = 'dashboardSiteReducer_GET_testServerSettings_REJECTED', + GET_testServerPrivateSettings = 'dashboardSiteReducer_GET_testServerPrivateSettings', + GET_testServerPrivateSettings_PENDING = 'dashboardSiteReducer_GET_testServerPrivateSettings_PENDING', + GET_testServerPrivateSettings_FULFILLED = 'dashboardSiteReducer_GET_testServerPrivateSettings_FULFILLED', + GET_testServerPrivateSettings_REJECTED = 'dashboardSiteReducer_GET_testServerPrivateSettings_REJECTED', + + GET_submitTestServerSettings = 'dashboardSiteReducer_GET_submitTestServerSettings', + GET_submitTestServerSettings_PENDING = 'dashboardSiteReducer_GET_submitTestServerSettings_PENDING', + GET_submitTestServerSettings_FULFILLED = 'dashboardSiteReducer_GET_submitTestServerSettings_FULFILLED', + GET_submitTestServerSettings_REJECTED = 'dashboardSiteReducer_GET_submitTestServerSettings_REJECTED', + SET_isLoading = 'dashboardSiteReducer_SET_isLoading', diff --git a/src/state/reducers/dashboardSite/dashboardSiteReducer.ts b/src/state/reducers/dashboardSite/dashboardSiteReducer.ts index 00cc0601..df860cc1 100644 --- a/src/state/reducers/dashboardSite/dashboardSiteReducer.ts +++ b/src/state/reducers/dashboardSite/dashboardSiteReducer.ts @@ -19,7 +19,7 @@ import {AllActions as getLogicalUsageActions, reducer as getLogicalUsageReducer} import { AllActions as getTestServerSettingsActions, reducer as getTestServerSettingsReducer -} from './crud/getTestServerSettingsReducer' +} from './crud/getTestServerPrivateSettingsReducer' import {SystemSettingsFromBackend} from '../../../types/systemSettings' import { @@ -32,6 +32,7 @@ import { reducer as getClientServerAppSettingsReducer } from './crud/getClientServerAppSettingsReducer' import {ActionTypeGlobal, RESET_GlobalAction} from '../globalActions' +import {AllActions as AllGetSubmitTestServerPrivateSettingsReducer, reducer as getSubmitTestServerPrivateSettingsReducer} from './crud/getSubmitTestServerPrivateSettingsReducer' export type State = { @@ -56,6 +57,8 @@ export type State = { readonly testServerSettings: TestServerPrivateSettings | null + readonly submitTestServerSettings: TestServerPrivateSettings | null + } @@ -70,7 +73,8 @@ export const initial: State = { clientServerConstants: null, clientServerAppSettings: null, - testServerSettings: null + testServerSettings: null, + submitTestServerSettings: null, } @@ -102,6 +106,7 @@ export type AllActions = | getHardwareUsageActions | getLogicalUsageActions | getTestServerSettingsActions + | AllGetSubmitTestServerPrivateSettingsReducer | RESET_GlobalAction @@ -125,11 +130,16 @@ export function reducer(state: State = initial, action: AllActions): State { case ActionType.GET_clientServerSettings_REJECTED: return getClientServerSystemSettingsReducer(state, action) - case ActionType.GET_testServerSettings_PENDING: - case ActionType.GET_testServerSettings_FULFILLED: - case ActionType.GET_testServerSettings_REJECTED: + case ActionType.GET_testServerPrivateSettings_PENDING: + case ActionType.GET_testServerPrivateSettings_FULFILLED: + case ActionType.GET_testServerPrivateSettings_REJECTED: return getTestServerSettingsReducer(state, action) + case ActionType.GET_submitTestServerSettings_PENDING: + case ActionType.GET_submitTestServerSettings_FULFILLED: + case ActionType.GET_submitTestServerSettings_REJECTED: + return getSubmitTestServerPrivateSettingsReducer(state, action) + case ActionType.GET_logicalUsage_PENDING: case ActionType.GET_logicalUsage_FULFILLED: case ActionType.GET_logicalUsage_REJECTED: diff --git a/src/state/reducers/globalSystemSettings/globalSystemSettingsReducer.ts b/src/state/reducers/globalSystemSettings/globalSystemSettingsReducer.ts index 83b48592..61d2379f 100644 --- a/src/state/reducers/globalSystemSettings/globalSystemSettingsReducer.ts +++ b/src/state/reducers/globalSystemSettings/globalSystemSettingsReducer.ts @@ -83,9 +83,11 @@ export const initial: State = { submitTestServerTimeoutInMs: -1, submitTestServerUrl: '', testServerStatsUrl: '', + submitTestServerStatsUrl: '', testServerTimeoutInMs: -1, testServerUrl: '', testServerConfigUiUrl: '', + submitTestServerConfigUiUrl: '', justRunProgramMaxDiskSpaceInKb: -1, justRunProgramMemoryLimitInKb: -1, justRunProgramTimeoutInMs: -1, @@ -97,6 +99,7 @@ export const initial: State = { defaultGroupCreatorGroupRoleId: -1, defaultGroupRoleId: -1, defaultUserGroupId: -1, + testServerTraceLogApiUrl: '', }, testServerPublicSettings: { hardTimeoutInMs: testServerPublicSettingsNotAvailableValue, diff --git a/src/state/reducers/systemSettingsSite/crud/getSubmitTestServerPublicSettingsReducer.ts b/src/state/reducers/systemSettingsSite/crud/getSubmitTestServerPublicSettingsReducer.ts new file mode 100644 index 00000000..7bdfc90d --- /dev/null +++ b/src/state/reducers/systemSettingsSite/crud/getSubmitTestServerPublicSettingsReducer.ts @@ -0,0 +1,68 @@ +import {TestServerPublicSettings} from '../../../../types/systemSettings' +import {ReduxPromiseAction, ReduxPromiseFulfilledAction, ReduxPromiseRejectedAction} from '../../index' +import {ActionBase, ActionType} from '../systemSettingsSiteActionTypes' +import {State, initial} from '../systemSettingsSiteReducer' +import {notExhaustive} from '../../_notExhausiveHelper' + + +export interface GET_submitTestServerPublicSettingsAction + extends ActionBase, ReduxPromiseAction<TestServerPublicSettings, GET_submitTestServerPublicSettings_PENDINGAction, GET_submitTestServerPublicSettings_FULFILLEDAction, GET_submitTestServerPublicSettings_REJECTEDAction> { + readonly type: ActionType.GET_submitTestServerPublicSettings + readonly payload: Promise<TestServerPublicSettings> +} + +//automatically dispatched by redux promise middleware +export interface GET_submitTestServerPublicSettings_PENDINGAction + extends ActionBase { + readonly type: ActionType.GET_submitTestServerPublicSettings_PENDING +} + +//automatically dispatched by redux promise middleware +export interface GET_submitTestServerPublicSettings_FULFILLEDAction + extends ActionBase, ReduxPromiseFulfilledAction<TestServerPublicSettings> { + readonly type: ActionType.GET_submitTestServerPublicSettings_FULFILLED + readonly payload: TestServerPublicSettings +} + +//automatically dispatched by redux promise middleware +export interface GET_submitTestServerPublicSettings_REJECTEDAction + extends ActionBase, ReduxPromiseRejectedAction<void> { + readonly type: ActionType.GET_submitTestServerPublicSettings_REJECTED + readonly payload: any +} + + +export type AllActions = + GET_submitTestServerPublicSettings_PENDINGAction + | GET_submitTestServerPublicSettings_FULFILLEDAction + | GET_submitTestServerPublicSettings_REJECTEDAction + + +export function reducer(state: State = initial, action: AllActions): State { + + switch (action.type) { + + case ActionType.GET_submitTestServerPublicSettings_PENDING: + return { + ...state, + isLoading: true + } + case ActionType.GET_submitTestServerPublicSettings_FULFILLED: + return { + ...state, + isLoading: false, + submitTestServerPublicSettings: action.payload + } + case ActionType.GET_submitTestServerPublicSettings_REJECTED: + return { + ...state, + isLoading: false, + submitTestServerPublicSettings: initial.submitTestServerPublicSettings + } + + default: + notExhaustive(action) + return state + } +} + diff --git a/src/state/reducers/systemSettingsSite/systemSettingsSiteActionTypes.ts b/src/state/reducers/systemSettingsSite/systemSettingsSiteActionTypes.ts index 2bf9d1ac..a743fc9d 100644 --- a/src/state/reducers/systemSettingsSite/systemSettingsSiteActionTypes.ts +++ b/src/state/reducers/systemSettingsSite/systemSettingsSiteActionTypes.ts @@ -30,6 +30,11 @@ export enum ActionType { GET_allDefaultGroups_FULFILLED = 'systemSettingsReducerGET_allDefaultGroups_FULFILLED', GET_allDefaultGroups_REJECTED = 'systemSettingsReducerGET_allDefaultGroups_REJECTED', + GET_submitTestServerPublicSettings = 'globalSystemSettingsReducer_GET_submitTestServerPublicSettings', + GET_submitTestServerPublicSettings_PENDING = 'globalSystemSettingsReducer_GET_submitTestServerPublicSettings_PENDING', + GET_submitTestServerPublicSettings_FULFILLED = 'globalSystemSettingsReducer_GET_submitTestServerPublicSettings_FULFILLED', + GET_submitTestServerPublicSettings_REJECTED = 'globalSystemSettingsReducer_GET_submitTestServerPublicSettings_REJECTED', + SET_serverMessage = 'systemSettingsReducer_SET_serverMessage', @@ -37,7 +42,9 @@ export enum ActionType { SET_maxCustomTestsPerParticipation = 'systemSettingsReducer_SET_maxCustomTestsPerParticipation', SET_testServerUrl = 'systemSettingsReducer_SET_testServerUrl', SET_testServerStatsUrl = 'systemSettingsReducer_SET_testServerStatsUrl', + SET_submitTestServerStatsUrl = 'systemSettingsReducer_SET_submitTestServerStatsUrl', SET_submitTestServerUrl = 'systemSettingsReducer_SET_submitTestServerUrl', + SET_testServerTraceLogApiUrl = 'systemSettingsReducer_SET_testServerTraceLogApiUrl', SET_testServerConfigUiUrl = 'systemSettingsReducer_SET_testServerConfigUiUrl', diff --git a/src/state/reducers/systemSettingsSite/systemSettingsSiteReducer.ts b/src/state/reducers/systemSettingsSite/systemSettingsSiteReducer.ts index 2e4716e1..5b3b1f3d 100644 --- a/src/state/reducers/systemSettingsSite/systemSettingsSiteReducer.ts +++ b/src/state/reducers/systemSettingsSite/systemSettingsSiteReducer.ts @@ -1,4 +1,9 @@ -import {SystemSettingsBase, SystemSettingsForBackend, SystemSettingsFromBackend} from "../../../types/systemSettings"; +import { + SystemSettingsBase, + SystemSettingsForBackend, + SystemSettingsFromBackend, + TestServerPublicSettings +} from "../../../types/systemSettings"; import {notExhaustive} from "../_notExhausiveHelper"; import {ActionBase, ActionType} from './systemSettingsSiteActionTypes' @@ -26,6 +31,7 @@ export type State = { readonly allDefaultRoles: ReadonlyArray<GroupRoleFullBase> readonly allDefaultGroups: ReadonlyArray<GroupPreviewFromBackend> + readonly submitTestServerPublicSettings: TestServerPublicSettings } import { AllActions as AllGetAllDefaultRolesReducer, @@ -35,6 +41,8 @@ import { AllActions as AllGetAllDefaultGroupsReducer, reducer as getAllDefaultGroupsReducer } from './crud/getAllDefaultGroupsReducer' +import {AllActions as AllGetSubmitTestServerPublicSettingsReducer, + reducer as getSubmitTestServerPublicSettingsReducer} from './crud/getSubmitTestServerPublicSettingsReducer' export const initial: State = { @@ -48,9 +56,11 @@ export const initial: State = { submitTestServerTimeoutInMs: -1, submitTestServerUrl: '', testServerStatsUrl: '', + submitTestServerStatsUrl: '', testServerTimeoutInMs: -1, testServerUrl: '', testServerConfigUiUrl: '', + submitTestServerConfigUiUrl: '', justRunProgramMaxDiskSpaceInKb: -1, justRunProgramMemoryLimitInKb: -1, justRunProgramTimeoutInMs: -1, @@ -62,10 +72,20 @@ export const initial: State = { defaultUserGroupId: -1, defaultGroupRoleId: -1, defaultGroupCreatorGroupRoleId: -1, + testServerTraceLogApiUrl: '', }, initialSystemSettings: null, allDefaultRoles: [], allDefaultGroups: [], + + submitTestServerPublicSettings: { + hardCompileTimeoutInMs: -1, + hardDiskSpaceLimitInKb: -1, + hardMemoryLimitInKb: -1, + hardTimeoutInMs: -1, + maxNumberOfTestsWithOneRequest: -1, + } + } @@ -96,11 +116,21 @@ export interface SET_testServerStatsUrlAction extends ActionBase { readonly testServerStatsUrl: string } +export interface SET_submitTestServerStatsUrlAction extends ActionBase { + readonly type: ActionType.SET_submitTestServerStatsUrl + readonly submitTestServerStatsUrl: string +} + export interface SET_submitTestServerUrlAction extends ActionBase { readonly type: ActionType.SET_submitTestServerUrl readonly submitTestServerUrl: string } +export interface SET_testServerTraceLogApiUrlAction extends ActionBase { + readonly type: ActionType.SET_testServerTraceLogApiUrl + readonly testServerTraceLogApiUrl: string +} + export interface SET_testServerConfigUiUrlAction extends ActionBase { readonly type: ActionType.SET_testServerConfigUiUrl readonly testServerConfigUiUrl: string @@ -196,6 +226,7 @@ export type AllActions = | AllGetAllDefaultRolesReducer | AllGetAllDefaultGroupsReducer + | AllGetSubmitTestServerPublicSettingsReducer | SET_serverMessageAction @@ -203,7 +234,9 @@ export type AllActions = | SET_maxCustomTestsPerParticipationAction | SET_testServerUrlAction | SET_testServerStatsUrlAction + | SET_submitTestServerStatsUrlAction | SET_submitTestServerUrlAction + | SET_testServerTraceLogApiUrlAction | SET_testServerConfigUiUrlAction | SET_testServerTimeoutInMsAction | SET_submitTestServerTimeoutInMsAction @@ -256,6 +289,11 @@ export function reducer(state: State = initial, action: AllActions): State { case ActionType.GET_allDefaultGroups_REJECTED: return getAllDefaultGroupsReducer(state, action) + case ActionType.GET_submitTestServerPublicSettings_PENDING: + case ActionType.GET_submitTestServerPublicSettings_FULFILLED: + case ActionType.GET_submitTestServerPublicSettings_REJECTED: + return getSubmitTestServerPublicSettingsReducer(state, action) + case ActionType.SET_serverMessage: return { ...state, @@ -297,6 +335,14 @@ export function reducer(state: State = initial, action: AllActions): State { testServerStatsUrl: action.testServerStatsUrl } } + case ActionType.SET_submitTestServerStatsUrl: + return { + ...state, + systemSettings: { + ...state.systemSettings, + submitTestServerStatsUrl: action.submitTestServerStatsUrl + } + } case ActionType.SET_submitTestServerUrl: return { ...state, @@ -305,6 +351,14 @@ export function reducer(state: State = initial, action: AllActions): State { submitTestServerUrl: action.submitTestServerUrl } } + case ActionType.SET_testServerTraceLogApiUrl: + return { + ...state, + systemSettings: { + ...state.systemSettings, + testServerTraceLogApiUrl: action.testServerTraceLogApiUrl + } + } case ActionType.SET_testServerConfigUiUrl: return { ...state, diff --git a/src/types/systemSettings.ts b/src/types/systemSettings.ts index b958ba4e..f2d633d0 100644 --- a/src/types/systemSettings.ts +++ b/src/types/systemSettings.ts @@ -33,6 +33,11 @@ export interface SystemSettingsBase { */ readonly testServerStatsUrl: string + /** + * the test server stats url + */ + readonly submitTestServerStatsUrl: string + /** * the submit test server url, used to run submit tests */ @@ -43,6 +48,11 @@ export interface SystemSettingsBase { */ readonly testServerConfigUiUrl: string + /** + * the url to the ui to configure the submit test server + */ + readonly submitTestServerConfigUiUrl: string + /** * the timeout in ms to wait for a response from the test server before returning a testserver connection error */ @@ -112,6 +122,10 @@ export interface SystemSettingsBase { */ readonly defaultGroupCreatorGroupRoleId: number + /** + * the test server trace log api url + */ + readonly testServerTraceLogApiUrl: string } -- GitLab