diff options
| author | crupest <crupest@outlook.com> | 2021-02-13 21:23:30 +0800 |
|---|---|---|
| committer | crupest <crupest@outlook.com> | 2021-02-13 21:23:30 +0800 |
| commit | c8bd19aacf9059f740df4f6fa9890127c20c1f6d (patch) | |
| tree | 01b3d74965415aff1ab1ef36fb9c92551c2166a4 /FrontEnd/src/app/http/timeline.ts | |
| parent | b9703104b5b416dd3211adedb878d1916072c96d (diff) | |
| download | timeline-c8bd19aacf9059f740df4f6fa9890127c20c1f6d.tar.gz timeline-c8bd19aacf9059f740df4f6fa9890127c20c1f6d.tar.bz2 timeline-c8bd19aacf9059f740df4f6fa9890127c20c1f6d.zip | |
...
Diffstat (limited to 'FrontEnd/src/app/http/timeline.ts')
| -rw-r--r-- | FrontEnd/src/app/http/timeline.ts | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/FrontEnd/src/app/http/timeline.ts b/FrontEnd/src/app/http/timeline.ts index 375a2325..50af259e 100644 --- a/FrontEnd/src/app/http/timeline.ts +++ b/FrontEnd/src/app/http/timeline.ts @@ -7,6 +7,7 @@ import { apiBaseUrl, extractResponseData, convertToIfErrorCodeIs, + getHttpToken, } from "./common"; import { HttpUser } from "./user"; @@ -50,20 +51,22 @@ export interface HttpTimelinePostInfo { id: number; time: string; author: HttpUser; - dataList: HttpTimelinePostDataDigest; + dataList: HttpTimelinePostDataDigest[]; color: string; lastUpdated: string; timelineName: string; editable: boolean; } +export interface HttpTimelinePostPostRequestData { + contentType: string; + data: string; +} + export interface HttpTimelinePostPostRequest { time?: string; color?: string; - dataList: { - contentType: string; - data: string; - }[]; + dataList: HttpTimelinePostPostRequestData[]; } export interface HttpTimelinePatchRequest { @@ -91,6 +94,8 @@ export interface IHttpTimelineClient { memberPut(timelineName: string, username: string): Promise<void>; memberDelete(timelineName: string, username: string): Promise<void>; listPost(timelineName: string): Promise<HttpTimelinePostInfo[]>; + generatePostDataUrl(timelineName: string, postId: number): string; + getPostDataAsString(timelineName: string, postId: number): Promise<string>; postPost( timelineName: string, req: HttpTimelinePostPostRequest @@ -153,6 +158,24 @@ export class HttpTimelineClient implements IHttpTimelineClient { .then(extractResponseData); } + generatePostDataUrl(timelineName: string, postId: number): string { + return applyQueryParameters( + `${apiBaseUrl}/timelines/${timelineName}/posts/${postId}/data`, + { token: getHttpToken() } + ); + } + + getPostDataAsString(timelineName: string, postId: number): Promise<string> { + return axios + .get<string>( + `${apiBaseUrl}/timelines/${timelineName}/posts/${postId}/data`, + { + responseType: "text", + } + ) + .then(extractResponseData); + } + postPost( timelineName: string, req: HttpTimelinePostPostRequest |
