Skip to content

Commit d0fccec

Browse files
committed
wip
1 parent 8e876aa commit d0fccec

2 files changed

Lines changed: 110 additions & 17 deletions

File tree

hwproj.front/src/api/api.ts

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,20 @@ export interface ResultTokenCredentials {
836836
errors?: Array<string>;
837837
}
838838

839+
/**
840+
*
841+
* @export
842+
* @interface SheetUrl
843+
*/
844+
export interface SheetUrl {
845+
/**
846+
*
847+
* @type {string}
848+
* @memberof SheetUrl
849+
*/
850+
url?: string;
851+
}
852+
839853
/**
840854
*
841855
* @export
@@ -5143,6 +5157,41 @@ export const StatisticsApiFetchParamCreator = function (configuration?: Configur
51435157
delete localVarUrlObj.search;
51445158
localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers);
51455159

5160+
return {
5161+
url: url.format(localVarUrlObj),
5162+
options: localVarRequestOptions,
5163+
};
5164+
},
5165+
/**
5166+
*
5167+
* @param {SheetUrl} [sheetUrl]
5168+
* @param {*} [options] Override http request option.
5169+
* @throws {RequiredError}
5170+
*/
5171+
apiStatisticsGetSheetTitlesPost(sheetUrl?: SheetUrl, options: any = {}): FetchArgs {
5172+
const localVarPath = `/api/Statistics/getSheetTitles`;
5173+
const localVarUrlObj = url.parse(localVarPath, true);
5174+
const localVarRequestOptions = Object.assign({ method: 'POST' }, options);
5175+
const localVarHeaderParameter = {} as any;
5176+
const localVarQueryParameter = {} as any;
5177+
5178+
// authentication Bearer required
5179+
if (configuration && configuration.apiKey) {
5180+
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
5181+
? configuration.apiKey("Authorization")
5182+
: configuration.apiKey;
5183+
localVarHeaderParameter["Authorization"] = localVarApiKeyValue;
5184+
}
5185+
5186+
localVarHeaderParameter['Content-Type'] = 'application/json-patch+json';
5187+
5188+
localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query);
5189+
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
5190+
delete localVarUrlObj.search;
5191+
localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers);
5192+
const needsSerialization = (<any>"SheetUrl" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
5193+
localVarRequestOptions.body = needsSerialization ? JSON.stringify(sheetUrl || {}) : (sheetUrl || "");
5194+
51465195
return {
51475196
url: url.format(localVarUrlObj),
51485197
options: localVarRequestOptions,
@@ -5175,6 +5224,24 @@ export const StatisticsApiFp = function(configuration?: Configuration) {
51755224
});
51765225
};
51775226
},
5227+
/**
5228+
*
5229+
* @param {SheetUrl} [sheetUrl]
5230+
* @param {*} [options] Override http request option.
5231+
* @throws {RequiredError}
5232+
*/
5233+
apiStatisticsGetSheetTitlesPost(sheetUrl?: SheetUrl, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Array<string>> {
5234+
const localVarFetchArgs = StatisticsApiFetchParamCreator(configuration).apiStatisticsGetSheetTitlesPost(sheetUrl, options);
5235+
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
5236+
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
5237+
if (response.status >= 200 && response.status < 300) {
5238+
return response.json();
5239+
} else {
5240+
throw response;
5241+
}
5242+
});
5243+
};
5244+
},
51785245
}
51795246
};
51805247

@@ -5193,6 +5260,15 @@ export const StatisticsApiFactory = function (configuration?: Configuration, fet
51935260
apiStatisticsByCourseIdGet(courseId: number, options?: any) {
51945261
return StatisticsApiFp(configuration).apiStatisticsByCourseIdGet(courseId, options)(fetch, basePath);
51955262
},
5263+
/**
5264+
*
5265+
* @param {SheetUrl} [sheetUrl]
5266+
* @param {*} [options] Override http request option.
5267+
* @throws {RequiredError}
5268+
*/
5269+
apiStatisticsGetSheetTitlesPost(sheetUrl?: SheetUrl, options?: any) {
5270+
return StatisticsApiFp(configuration).apiStatisticsGetSheetTitlesPost(sheetUrl, options)(fetch, basePath);
5271+
},
51965272
};
51975273
};
51985274

@@ -5214,6 +5290,17 @@ export class StatisticsApi extends BaseAPI {
52145290
return StatisticsApiFp(this.configuration).apiStatisticsByCourseIdGet(courseId, options)(this.fetch, this.basePath);
52155291
}
52165292

5293+
/**
5294+
*
5295+
* @param {SheetUrl} [sheetUrl]
5296+
* @param {*} [options] Override http request option.
5297+
* @throws {RequiredError}
5298+
* @memberof StatisticsApi
5299+
*/
5300+
public apiStatisticsGetSheetTitlesPost(sheetUrl?: SheetUrl, options?: any) {
5301+
return StatisticsApiFp(this.configuration).apiStatisticsGetSheetTitlesPost(sheetUrl, options)(this.fetch, this.basePath);
5302+
}
5303+
52175304
}
52185305

52195306
/**

hwproj.front/src/components/Courses/StudentStats.tsx

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import React from "react";
22
import {CourseViewModel, HomeworkViewModel, StatisticsCourseMatesModel} from "../../api/";
33
import {Table, TableBody, TableCell, TableContainer, TableHead, TableRow} from "@material-ui/core";
44
import StudentStatsCell from "../Tasks/StudentStatsCell";
5-
import {Alert} from "@mui/material";
5+
import {Alert, MenuItem, Select, TextField} from "@mui/material";
6+
import apiSingleton from "../../api/ApiSingleton";
67

78
interface IStudentStatsProps {
89
course: CourseViewModel;
@@ -14,35 +15,29 @@ interface IStudentStatsProps {
1415

1516
interface IStudentStatsState {
1617
searched: string
18+
googleDocUrl: string
19+
sheetTitles: string[]
1720
}
1821

1922
class StudentStats extends React.Component<IStudentStatsProps, IStudentStatsState> {
2023
constructor(props: IStudentStatsProps) {
2124
super(props);
2225
this.state = {
23-
searched: ""
26+
searched: "",
27+
googleDocUrl: "",
28+
sheetTitles: []
2429
}
2530

26-
document.addEventListener('keydown', (event: KeyboardEvent) => {
27-
const {searched} = this.state
31+
}
2832

29-
if (searched && event.key === "Escape") {
30-
event.preventDefault();
31-
this.setState({searched: ""})
32-
} else if (searched && event.key === "Backspace") {
33-
event.preventDefault();
34-
this.setState({searched: searched.slice(0, -1)})
35-
} else if (event.key.length === 1 && event.key.match(/[a-zA-Zа-яА-Я\s]/i)
36-
) {
37-
event.preventDefault();
38-
this.setState({searched: searched + event.key})
39-
}
40-
})
33+
private handleGoogleDocUrlChange = async (value: string) => {
34+
const titles = await apiSingleton.statisticsApi.apiStatisticsGetSheetTitlesPost({url: value})
35+
this.setState({googleDocUrl: value, sheetTitles: titles});
4136
}
4237

4338
public render() {
4439
const homeworks = this.props.homeworks.filter(h => h.tasks && h.tasks.length > 0)
45-
const {searched} = this.state
40+
const {searched, googleDocUrl, sheetTitles} = this.state
4641
const solutions = searched
4742
? this.props.solutions.filter(cm => (cm.surname + " " + cm.name).toLowerCase().includes(searched.toLowerCase()))
4843
: this.props.solutions
@@ -110,6 +105,17 @@ class StudentStats extends React.Component<IStudentStatsProps, IStudentStatsStat
110105
</TableBody>
111106
</Table>
112107
</TableContainer>
108+
<TextField fullWidth label={"Ссылка на Google Docs"} value={googleDocUrl}
109+
onChange={event => {
110+
event.persist()
111+
this.handleGoogleDocUrlChange(event.target.value)
112+
}}/>
113+
{googleDocUrl && <Select
114+
labelId="demo-simple-select-label"
115+
id="demo-simple-select"
116+
label="Course"
117+
>
118+
{sheetTitles.map((title, i) => <MenuItem value={i}>{title}</MenuItem>)}</Select>}
113119
</div>
114120
);
115121
}

0 commit comments

Comments
 (0)