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 | |
parent | b9703104b5b416dd3211adedb878d1916072c96d (diff) | |
download | timeline-c8bd19aacf9059f740df4f6fa9890127c20c1f6d.tar.gz timeline-c8bd19aacf9059f740df4f6fa9890127c20c1f6d.tar.bz2 timeline-c8bd19aacf9059f740df4f6fa9890127c20c1f6d.zip |
...
Diffstat (limited to 'FrontEnd/src/app/http')
-rw-r--r-- | FrontEnd/src/app/http/timeline.ts | 33 | ||||
-rw-r--r-- | FrontEnd/src/app/http/user.ts | 6 |
2 files changed, 33 insertions, 6 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 diff --git a/FrontEnd/src/app/http/user.ts b/FrontEnd/src/app/http/user.ts index c6a567d3..dcb222bf 100644 --- a/FrontEnd/src/app/http/user.ts +++ b/FrontEnd/src/app/http/user.ts @@ -61,7 +61,7 @@ export interface IHttpUserClient { get(username: string): Promise<HttpUser>; patch(username: string, req: HttpUserPatchRequest): Promise<HttpUser>; delete(username: string): Promise<void>; - // return etag + generateAvatarUrl(username: string): string; putAvatar(username: string, data: Blob): Promise<string>; changePassword(req: HttpChangePasswordRequest): Promise<void>; putUserPermission( @@ -100,6 +100,10 @@ export class HttpUserClient implements IHttpUserClient { return axios.delete(`${apiBaseUrl}/users/${username}`).then(); } + generateAvatarUrl(username: string): string { + return `${apiBaseUrl}/users/${username}/avatar`; + } + putAvatar(username: string, data: Blob): Promise<string> { return axios .put(`${apiBaseUrl}/users/${username}/avatar`, data, { |