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 | fe5128137f530daf8ca315cb89811121c6c2c9da (patch) | |
tree | 34cbdb7895e18d34779b2209a1e9aae0fde20cf2 /FrontEnd/src/app/http/timeline.ts | |
parent | aeed3cb80d8c0a62d0ccc565733c4a213759c5bd (diff) | |
download | timeline-fe5128137f530daf8ca315cb89811121c6c2c9da.tar.gz timeline-fe5128137f530daf8ca315cb89811121c6c2c9da.tar.bz2 timeline-fe5128137f530daf8ca315cb89811121c6c2c9da.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 |