@wg-npm/survey-service-api 0.3.480-5.release → 0.3.489-9.release
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/survey-service-api.esm.js +81 -41
- package/package.json +3 -3
- package/src/axios.ts +9 -5
- package/src/index.ts +4 -4
- package/src/survey-service-impl.ts +163 -63
- package/src/survey-service.ts +98 -47
- package/types/index.d.ts +16 -6
- package/types/vue.d.ts +4 -4
|
@@ -6,8 +6,8 @@ function createHttpFunction(baseUrl, version) {
|
|
|
6
6
|
const baseURL = `${baseUrl}/${version}`;
|
|
7
7
|
return Axios.create({
|
|
8
8
|
baseURL: baseURL,
|
|
9
|
-
headers: { Pragma:
|
|
10
|
-
paramsSerializer: params => Qs.stringify(params, { arrayFormat:
|
|
9
|
+
headers: { Pragma: "no-cache" },
|
|
10
|
+
paramsSerializer: (params) => Qs.stringify(params, { arrayFormat: "repeat" }),
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -17,70 +17,96 @@ class SurveyServiceImpl {
|
|
|
17
17
|
if (options.httpDecorator) {
|
|
18
18
|
this.http = options.httpDecorator(this.http);
|
|
19
19
|
}
|
|
20
|
-
this.exhttp = createHttpFunction(
|
|
20
|
+
this.exhttp = createHttpFunction("", "");
|
|
21
21
|
}
|
|
22
22
|
loadSurvey(id) {
|
|
23
|
-
return this.http.get(`/surveys/${id}`).then(response => response.data);
|
|
23
|
+
return this.http.get(`/surveys/${id}`).then((response) => response.data);
|
|
24
24
|
}
|
|
25
25
|
loadSurveys(params) {
|
|
26
|
-
return this.http
|
|
26
|
+
return this.http
|
|
27
|
+
.get(`/surveys`, { params: params })
|
|
28
|
+
.then((response) => response.data);
|
|
27
29
|
}
|
|
28
30
|
createSurvey(survey) {
|
|
29
|
-
return this.http.post(
|
|
31
|
+
return this.http.post("/surveys", survey).then((response) => response.data);
|
|
30
32
|
}
|
|
31
33
|
updateSurvey(survey) {
|
|
32
|
-
return this.http.put(
|
|
34
|
+
return this.http.put("/surveys", survey).then((response) => response.data);
|
|
33
35
|
}
|
|
34
36
|
deleteSurvey(id) {
|
|
35
37
|
return this.http.delete(`/surveys/${id}`);
|
|
36
38
|
}
|
|
37
39
|
createQuestion(surveyId, question) {
|
|
38
|
-
return this.http
|
|
40
|
+
return this.http
|
|
41
|
+
.post(`/surveys/${surveyId}/question`, question)
|
|
42
|
+
.then((response) => response.data);
|
|
39
43
|
}
|
|
40
44
|
createQuestions(surveyId, questions) {
|
|
41
|
-
return this.http
|
|
45
|
+
return this.http
|
|
46
|
+
.post(`/surveys/${surveyId}/questions`, questions)
|
|
47
|
+
.then((response) => response.data);
|
|
42
48
|
}
|
|
43
49
|
updateQuestion(surveyId, question) {
|
|
44
|
-
return this.http
|
|
50
|
+
return this.http
|
|
51
|
+
.put(`/surveys/${surveyId}/questions/${question.id}`, question)
|
|
52
|
+
.then((response) => response.data);
|
|
45
53
|
}
|
|
46
54
|
updateQuestionsOptions(surveyId, questions) {
|
|
47
|
-
return this.http
|
|
55
|
+
return this.http
|
|
56
|
+
.put(`/surveys/${surveyId}/questions/options`, questions)
|
|
57
|
+
.then((response) => response.data);
|
|
48
58
|
}
|
|
49
59
|
moveQuestion(surveyId, questionId, index) {
|
|
50
|
-
return Promise.resolve(this.http.put(`/surveys/${surveyId}/questions/${questionId}/move`, {
|
|
60
|
+
return Promise.resolve(this.http.put(`/surveys/${surveyId}/questions/${questionId}/move`, {
|
|
61
|
+
index: index,
|
|
62
|
+
}));
|
|
51
63
|
}
|
|
52
64
|
deleteQuestion(surveyId, questionId) {
|
|
53
65
|
return Promise.resolve(this.http.delete(`/surveys/${surveyId}/questions/${questionId}`));
|
|
54
66
|
}
|
|
55
67
|
loadResponse(id) {
|
|
56
|
-
return this.http.get(`/responses/${id}`).then(response => response.data);
|
|
68
|
+
return this.http.get(`/responses/${id}`).then((response) => response.data);
|
|
57
69
|
}
|
|
58
70
|
dispatchResponse(surveyId, response) {
|
|
59
|
-
return this.http
|
|
71
|
+
return this.http
|
|
72
|
+
.post(`/surveys/${surveyId}/responses`, response)
|
|
73
|
+
.then((response) => response.data);
|
|
60
74
|
}
|
|
61
75
|
updateResponse(response) {
|
|
62
|
-
return this.http
|
|
76
|
+
return this.http
|
|
77
|
+
.put(`/responses/${response.id}`, response)
|
|
78
|
+
.then((response) => response.data);
|
|
63
79
|
}
|
|
64
80
|
loadMyPlans(params) {
|
|
65
|
-
return this.http
|
|
81
|
+
return this.http
|
|
82
|
+
.get(`/plans/me`, { params: params })
|
|
83
|
+
.then((response) => response.data);
|
|
66
84
|
}
|
|
67
85
|
loadPlans(params) {
|
|
68
|
-
return this.http
|
|
86
|
+
return this.http
|
|
87
|
+
.get(`/plans`, { params: params })
|
|
88
|
+
.then((response) => response.data);
|
|
69
89
|
}
|
|
70
90
|
loadPlanById(planId, params) {
|
|
71
|
-
return this.http
|
|
91
|
+
return this.http
|
|
92
|
+
.get(`/plan/${planId}`, { params: params })
|
|
93
|
+
.then((response) => response.data);
|
|
72
94
|
}
|
|
73
95
|
loadPlanWithFiltersById(planId, PlanStatisticsModel) {
|
|
74
|
-
return this.http
|
|
96
|
+
return this.http
|
|
97
|
+
.post(`/plan/${planId}`, { ...PlanStatisticsModel })
|
|
98
|
+
.then((response) => response.data);
|
|
75
99
|
}
|
|
76
100
|
loadPlanWithFiltersByIdAndTargetId(planId, targetId, PlanStatisticsModel) {
|
|
77
|
-
return this.http
|
|
101
|
+
return this.http
|
|
102
|
+
.post(`/plan/${planId}/targets/${targetId}`, { ...PlanStatisticsModel })
|
|
103
|
+
.then((response) => response.data);
|
|
78
104
|
}
|
|
79
105
|
createPlan(plan) {
|
|
80
|
-
return this.http.post(
|
|
106
|
+
return this.http.post("/plans", plan).then((response) => response.data);
|
|
81
107
|
}
|
|
82
108
|
updatePlan(plan) {
|
|
83
|
-
return this.http.put(
|
|
109
|
+
return this.http.put("/plans", plan).then((response) => response.data);
|
|
84
110
|
}
|
|
85
111
|
deletePlan(id) {
|
|
86
112
|
return this.http.delete(`/plans/${id}`);
|
|
@@ -89,79 +115,93 @@ class SurveyServiceImpl {
|
|
|
89
115
|
return this.http.post(`/surveys/${surveyId}/respondents/${respondentId}/responses`, { targets: targets });
|
|
90
116
|
}
|
|
91
117
|
loadResponses(params) {
|
|
92
|
-
return this.http
|
|
118
|
+
return this.http
|
|
119
|
+
.get(`/responses`, { params: params })
|
|
120
|
+
.then((response) => response.data);
|
|
93
121
|
}
|
|
94
122
|
loadResponsesPost(data) {
|
|
95
|
-
return this.http
|
|
123
|
+
return this.http
|
|
124
|
+
.post(`/responses`, { ...data })
|
|
125
|
+
.then((response) => response.data);
|
|
96
126
|
}
|
|
97
127
|
loadStatisticsByAll(surveyId, statistics) {
|
|
98
128
|
return this.http
|
|
99
129
|
.get(`/statistics/${surveyId}`, {
|
|
100
130
|
params: {
|
|
101
131
|
...statistics,
|
|
102
|
-
statisticsBy:
|
|
132
|
+
statisticsBy: "ALL",
|
|
103
133
|
},
|
|
104
134
|
})
|
|
105
|
-
.then(response => response.data);
|
|
135
|
+
.then((response) => response.data);
|
|
106
136
|
}
|
|
107
137
|
loadStatisticsBySurvey(surveyId, statistics) {
|
|
108
138
|
return this.http
|
|
109
139
|
.get(`/statistics/${surveyId}`, {
|
|
110
140
|
params: {
|
|
111
141
|
...statistics,
|
|
112
|
-
statisticsBy:
|
|
142
|
+
statisticsBy: "SURVEY",
|
|
113
143
|
},
|
|
114
144
|
})
|
|
115
|
-
.then(response => response.data);
|
|
145
|
+
.then((response) => response.data);
|
|
116
146
|
}
|
|
117
147
|
loadStatisticsByTargets(surveyId, statistics) {
|
|
118
148
|
return this.http
|
|
119
149
|
.get(`/statistics/${surveyId}`, {
|
|
120
150
|
params: {
|
|
121
151
|
...statistics,
|
|
122
|
-
statisticsBy:
|
|
152
|
+
statisticsBy: "TARGET",
|
|
123
153
|
},
|
|
124
154
|
})
|
|
125
|
-
.then(response => response.data);
|
|
155
|
+
.then((response) => response.data);
|
|
126
156
|
}
|
|
127
157
|
loadStatisticsWithFiltersByAll(surveyId, statistics) {
|
|
128
158
|
return this.http
|
|
129
159
|
.post(`/statistics/${surveyId}`, {
|
|
130
160
|
...statistics,
|
|
131
|
-
statisticsBy:
|
|
161
|
+
statisticsBy: "ALL",
|
|
132
162
|
})
|
|
133
|
-
.then(response => response.data);
|
|
163
|
+
.then((response) => response.data);
|
|
134
164
|
}
|
|
135
165
|
loadStatisticsWithFiltersBySurvey(surveyId, statistics) {
|
|
136
166
|
return this.http
|
|
137
167
|
.post(`/statistics/${surveyId}`, {
|
|
138
168
|
...statistics,
|
|
139
|
-
statisticsBy:
|
|
169
|
+
statisticsBy: "SURVEY",
|
|
140
170
|
})
|
|
141
|
-
.then(response => response.data);
|
|
171
|
+
.then((response) => response.data);
|
|
142
172
|
}
|
|
143
173
|
loadStatisticsWithFiltersByTargets(surveyId, statistics) {
|
|
144
174
|
return this.http
|
|
145
175
|
.post(`/statistics/${surveyId}`, {
|
|
146
176
|
...statistics,
|
|
147
|
-
statisticsBy:
|
|
177
|
+
statisticsBy: "TARGET",
|
|
148
178
|
})
|
|
149
|
-
.then(response => response.data);
|
|
179
|
+
.then((response) => response.data);
|
|
150
180
|
}
|
|
151
181
|
loadStatisticsBySurveyAndTarget(data) {
|
|
152
|
-
return this.http
|
|
182
|
+
return this.http
|
|
183
|
+
.post(`/statistics/targets`, data)
|
|
184
|
+
.then((response) => response.data);
|
|
153
185
|
}
|
|
154
186
|
loadRespondents(params) {
|
|
155
|
-
return this.http
|
|
187
|
+
return this.http
|
|
188
|
+
.get(`/respondents`, { params: params })
|
|
189
|
+
.then((response) => response.data);
|
|
156
190
|
}
|
|
157
191
|
loadRespondentByPlanAndTarget(params) {
|
|
158
|
-
return this.http
|
|
192
|
+
return this.http
|
|
193
|
+
.get(`/respondents/target`, { params: params })
|
|
194
|
+
.then((response) => response.data);
|
|
159
195
|
}
|
|
160
196
|
get(url, params) {
|
|
161
|
-
return this.exhttp
|
|
197
|
+
return this.exhttp
|
|
198
|
+
.get(url, { params: params })
|
|
199
|
+
.then((response) => response.data);
|
|
162
200
|
}
|
|
163
201
|
updatePlanStatistics(params) {
|
|
164
|
-
return this.http
|
|
202
|
+
return this.http
|
|
203
|
+
.put("/statistics", params)
|
|
204
|
+
.then((response) => response.data);
|
|
165
205
|
}
|
|
166
206
|
}
|
|
167
207
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wg-npm/survey-service-api",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4899.release",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"lint-fix": "eslint \"**/*.ts\" \"**/*.vue\" --fix --no-error-on-unmatched-pattern"
|
|
12
12
|
},
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"@wg-npm/survey-core": "0.3.
|
|
14
|
+
"@wg-npm/survey-core": "0.3.4899.release",
|
|
15
15
|
"axios": "^0.19.2",
|
|
16
16
|
"axios-case-converter": "^0.6.0",
|
|
17
17
|
"qs": "^6.9.4",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@typescript-eslint/parser": "^3.6.0",
|
|
31
31
|
"@vue/eslint-config-prettier": "^6.0.0",
|
|
32
32
|
"@vue/eslint-config-typescript": "^5.0.2",
|
|
33
|
-
"@wg-npm/survey-core": "0.3.
|
|
33
|
+
"@wg-npm/survey-core": "0.3.4899.release",
|
|
34
34
|
"acorn": "^7.3.1",
|
|
35
35
|
"axios": "^0.19.2",
|
|
36
36
|
"axios-case-converter": "^0.6.0",
|
package/src/axios.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import Axios, { AxiosInstance } from
|
|
2
|
-
import Qs from
|
|
1
|
+
import Axios, { AxiosInstance } from "axios";
|
|
2
|
+
import Qs from "qs";
|
|
3
3
|
|
|
4
|
-
export function createHttpFunction(
|
|
4
|
+
export function createHttpFunction(
|
|
5
|
+
baseUrl: string,
|
|
6
|
+
version: string
|
|
7
|
+
): AxiosInstance {
|
|
5
8
|
const baseURL = `${baseUrl}/${version}`;
|
|
6
9
|
return Axios.create({
|
|
7
10
|
baseURL: baseURL,
|
|
8
|
-
headers: { Pragma:
|
|
9
|
-
paramsSerializer: params =>
|
|
11
|
+
headers: { Pragma: "no-cache" },
|
|
12
|
+
paramsSerializer: (params) =>
|
|
13
|
+
Qs.stringify(params, { arrayFormat: "repeat" }),
|
|
10
14
|
});
|
|
11
15
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import _Vue from
|
|
2
|
-
import { SurveyServiceOptions } from
|
|
3
|
-
import { SurveyServiceImpl } from
|
|
1
|
+
import _Vue from "vue";
|
|
2
|
+
import { SurveyServiceOptions } from "./survey-service";
|
|
3
|
+
import { SurveyServiceImpl } from "./survey-service-impl";
|
|
4
4
|
|
|
5
|
-
export * from
|
|
5
|
+
export * from "./survey-service";
|
|
6
6
|
|
|
7
7
|
export default class SurveyServiceApiPlugin {
|
|
8
8
|
static install(Vue: typeof _Vue, options: SurveyServiceOptions) {
|
|
@@ -1,92 +1,151 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import {
|
|
2
|
+
PlanModel,
|
|
3
|
+
PlanStatisticsModel,
|
|
4
|
+
BaseQuestionModel,
|
|
5
|
+
ResponseModel,
|
|
6
|
+
ResponseStatisticsModel,
|
|
7
|
+
SurveyModel,
|
|
8
|
+
} from "@wg-npm/survey-core";
|
|
9
|
+
import { SurveyService, SurveyServiceOptions } from "./survey-service";
|
|
10
|
+
import { AxiosInstance } from "axios";
|
|
11
|
+
import { createHttpFunction } from "./axios";
|
|
12
|
+
import applyConverters from "axios-case-converter";
|
|
6
13
|
|
|
7
14
|
export class SurveyServiceImpl implements SurveyService {
|
|
8
15
|
http: AxiosInstance;
|
|
9
16
|
exhttp: AxiosInstance;
|
|
10
17
|
|
|
11
18
|
constructor(options: SurveyServiceOptions) {
|
|
12
|
-
this.http = applyConverters(
|
|
19
|
+
this.http = applyConverters(
|
|
20
|
+
createHttpFunction(options.baseUrl, options.version)
|
|
21
|
+
);
|
|
13
22
|
if (options.httpDecorator) {
|
|
14
23
|
this.http = options.httpDecorator(this.http);
|
|
15
24
|
}
|
|
16
25
|
|
|
17
|
-
this.exhttp = createHttpFunction(
|
|
26
|
+
this.exhttp = createHttpFunction("", "");
|
|
18
27
|
}
|
|
19
28
|
|
|
20
29
|
loadSurvey(id: string): Promise<SurveyModel> {
|
|
21
|
-
return this.http.get(`/surveys/${id}`).then(response => response.data);
|
|
30
|
+
return this.http.get(`/surveys/${id}`).then((response) => response.data);
|
|
22
31
|
}
|
|
23
32
|
|
|
24
33
|
loadSurveys(params: any): Promise<SurveyModel[]> {
|
|
25
|
-
return this.http
|
|
34
|
+
return this.http
|
|
35
|
+
.get(`/surveys`, { params: params })
|
|
36
|
+
.then((response) => response.data);
|
|
26
37
|
}
|
|
27
38
|
|
|
28
39
|
createSurvey(survey: SurveyModel): Promise<SurveyModel> {
|
|
29
|
-
return this.http.post(
|
|
40
|
+
return this.http.post("/surveys", survey).then((response) => response.data);
|
|
30
41
|
}
|
|
31
42
|
|
|
32
43
|
updateSurvey(survey: SurveyModel): Promise<SurveyModel> {
|
|
33
|
-
return this.http.put(
|
|
44
|
+
return this.http.put("/surveys", survey).then((response) => response.data);
|
|
34
45
|
}
|
|
35
46
|
|
|
36
47
|
deleteSurvey(id: string): Promise<void> {
|
|
37
48
|
return this.http.delete(`/surveys/${id}`);
|
|
38
49
|
}
|
|
39
50
|
|
|
40
|
-
createQuestion(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
51
|
+
createQuestion(
|
|
52
|
+
surveyId: string,
|
|
53
|
+
question: BaseQuestionModel
|
|
54
|
+
): Promise<BaseQuestionModel> {
|
|
55
|
+
return this.http
|
|
56
|
+
.post(`/surveys/${surveyId}/question`, question)
|
|
57
|
+
.then((response) => response.data);
|
|
46
58
|
}
|
|
47
59
|
|
|
48
|
-
|
|
49
|
-
|
|
60
|
+
createQuestions(
|
|
61
|
+
surveyId: string,
|
|
62
|
+
questions: Array<BaseQuestionModel>
|
|
63
|
+
): Promise<BaseQuestionModel> {
|
|
64
|
+
return this.http
|
|
65
|
+
.post(`/surveys/${surveyId}/questions`, questions)
|
|
66
|
+
.then((response) => response.data);
|
|
50
67
|
}
|
|
51
68
|
|
|
52
|
-
|
|
53
|
-
|
|
69
|
+
updateQuestion(
|
|
70
|
+
surveyId: string,
|
|
71
|
+
question: BaseQuestionModel
|
|
72
|
+
): Promise<BaseQuestionModel> {
|
|
73
|
+
return this.http
|
|
74
|
+
.put(`/surveys/${surveyId}/questions/${question.id}`, question)
|
|
75
|
+
.then((response) => response.data);
|
|
54
76
|
}
|
|
55
77
|
|
|
56
|
-
|
|
57
|
-
|
|
78
|
+
updateQuestionsOptions(
|
|
79
|
+
surveyId: string,
|
|
80
|
+
questions: Array<BaseQuestionModel>
|
|
81
|
+
): Promise<BaseQuestionModel> {
|
|
82
|
+
return this.http
|
|
83
|
+
.put(`/surveys/${surveyId}/questions/options`, questions)
|
|
84
|
+
.then((response) => response.data);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
moveQuestion(
|
|
88
|
+
surveyId: string,
|
|
89
|
+
questionId: string,
|
|
90
|
+
index: number
|
|
91
|
+
): Promise<void> {
|
|
92
|
+
return Promise.resolve(
|
|
93
|
+
this.http.put(`/surveys/${surveyId}/questions/${questionId}/move`, {
|
|
94
|
+
index: index,
|
|
95
|
+
})
|
|
96
|
+
);
|
|
58
97
|
}
|
|
59
98
|
|
|
60
99
|
deleteQuestion(surveyId: string, questionId: string): Promise<void> {
|
|
61
|
-
return Promise.resolve(
|
|
100
|
+
return Promise.resolve(
|
|
101
|
+
this.http.delete(`/surveys/${surveyId}/questions/${questionId}`)
|
|
102
|
+
);
|
|
62
103
|
}
|
|
63
104
|
|
|
64
105
|
loadResponse(id: string): Promise<ResponseModel> {
|
|
65
|
-
return this.http.get(`/responses/${id}`).then(response => response.data);
|
|
106
|
+
return this.http.get(`/responses/${id}`).then((response) => response.data);
|
|
66
107
|
}
|
|
67
108
|
|
|
68
|
-
dispatchResponse(
|
|
69
|
-
|
|
109
|
+
dispatchResponse(
|
|
110
|
+
surveyId: string,
|
|
111
|
+
response: ResponseModel
|
|
112
|
+
): Promise<ResponseModel> {
|
|
113
|
+
return this.http
|
|
114
|
+
.post(`/surveys/${surveyId}/responses`, response)
|
|
115
|
+
.then((response) => response.data);
|
|
70
116
|
}
|
|
71
117
|
|
|
72
118
|
updateResponse(response: ResponseModel): Promise<ResponseModel> {
|
|
73
|
-
return this.http
|
|
119
|
+
return this.http
|
|
120
|
+
.put(`/responses/${response.id}`, response)
|
|
121
|
+
.then((response) => response.data);
|
|
74
122
|
}
|
|
75
123
|
|
|
76
124
|
loadMyPlans(params: any): Promise<ResponseModel> {
|
|
77
|
-
return this.http
|
|
125
|
+
return this.http
|
|
126
|
+
.get(`/plans/me`, { params: params })
|
|
127
|
+
.then((response) => response.data);
|
|
78
128
|
}
|
|
79
129
|
|
|
80
130
|
loadPlans(params: any): Promise<PlanModel> {
|
|
81
|
-
return this.http
|
|
131
|
+
return this.http
|
|
132
|
+
.get(`/plans`, { params: params })
|
|
133
|
+
.then((response) => response.data);
|
|
82
134
|
}
|
|
83
135
|
|
|
84
136
|
loadPlanById(planId: string, params: any): Promise<PlanModel> {
|
|
85
|
-
return this.http
|
|
137
|
+
return this.http
|
|
138
|
+
.get(`/plan/${planId}`, { params: params })
|
|
139
|
+
.then((response) => response.data);
|
|
86
140
|
}
|
|
87
141
|
|
|
88
|
-
loadPlanWithFiltersById(
|
|
89
|
-
|
|
142
|
+
loadPlanWithFiltersById(
|
|
143
|
+
planId: string,
|
|
144
|
+
PlanStatisticsModel: PlanStatisticsModel
|
|
145
|
+
): Promise<PlanStatisticsModel> {
|
|
146
|
+
return this.http
|
|
147
|
+
.post(`/plan/${planId}`, { ...PlanStatisticsModel })
|
|
148
|
+
.then((response) => response.data);
|
|
90
149
|
}
|
|
91
150
|
|
|
92
151
|
loadPlanWithFiltersByIdAndTargetId(
|
|
@@ -94,110 +153,151 @@ export class SurveyServiceImpl implements SurveyService {
|
|
|
94
153
|
targetId: string,
|
|
95
154
|
PlanStatisticsModel: PlanStatisticsModel
|
|
96
155
|
): Promise<PlanStatisticsModel> {
|
|
97
|
-
return this.http
|
|
156
|
+
return this.http
|
|
157
|
+
.post(`/plan/${planId}/targets/${targetId}`, { ...PlanStatisticsModel })
|
|
158
|
+
.then((response) => response.data);
|
|
98
159
|
}
|
|
99
160
|
|
|
100
161
|
createPlan(plan: PlanModel): Promise<PlanModel> {
|
|
101
|
-
return this.http.post(
|
|
162
|
+
return this.http.post("/plans", plan).then((response) => response.data);
|
|
102
163
|
}
|
|
103
164
|
|
|
104
165
|
updatePlan(plan: PlanModel): Promise<PlanModel> {
|
|
105
|
-
return this.http.put(
|
|
166
|
+
return this.http.put("/plans", plan).then((response) => response.data);
|
|
106
167
|
}
|
|
107
168
|
|
|
108
169
|
deletePlan(id: string): Promise<void> {
|
|
109
170
|
return this.http.delete(`/plans/${id}`);
|
|
110
171
|
}
|
|
111
172
|
|
|
112
|
-
dispatchResponses(
|
|
113
|
-
|
|
173
|
+
dispatchResponses(
|
|
174
|
+
surveyId: string,
|
|
175
|
+
respondentId: string,
|
|
176
|
+
targets: Array<string>
|
|
177
|
+
): Promise<ResponseModel> {
|
|
178
|
+
return this.http.post(
|
|
179
|
+
`/surveys/${surveyId}/respondents/${respondentId}/responses`,
|
|
180
|
+
{ targets: targets }
|
|
181
|
+
);
|
|
114
182
|
}
|
|
115
183
|
|
|
116
184
|
loadResponses(params: any): Promise<ResponseModel> {
|
|
117
|
-
return this.http
|
|
185
|
+
return this.http
|
|
186
|
+
.get(`/responses`, { params: params })
|
|
187
|
+
.then((response) => response.data);
|
|
118
188
|
}
|
|
119
189
|
|
|
120
190
|
loadResponsesPost(data: any): Promise<ResponseModel> {
|
|
121
|
-
return this.http
|
|
191
|
+
return this.http
|
|
192
|
+
.post(`/responses`, { ...data })
|
|
193
|
+
.then((response) => response.data);
|
|
122
194
|
}
|
|
123
195
|
|
|
124
|
-
loadStatisticsByAll(
|
|
196
|
+
loadStatisticsByAll(
|
|
197
|
+
surveyId: string,
|
|
198
|
+
statistics: ResponseStatisticsModel
|
|
199
|
+
): Promise<ResponseStatisticsModel> {
|
|
125
200
|
return this.http
|
|
126
201
|
.get(`/statistics/${surveyId}`, {
|
|
127
202
|
params: {
|
|
128
203
|
...statistics,
|
|
129
|
-
statisticsBy:
|
|
204
|
+
statisticsBy: "ALL",
|
|
130
205
|
},
|
|
131
206
|
})
|
|
132
|
-
.then(response => response.data);
|
|
207
|
+
.then((response) => response.data);
|
|
133
208
|
}
|
|
134
209
|
|
|
135
|
-
loadStatisticsBySurvey(
|
|
210
|
+
loadStatisticsBySurvey(
|
|
211
|
+
surveyId: string,
|
|
212
|
+
statistics: ResponseStatisticsModel
|
|
213
|
+
): Promise<ResponseStatisticsModel> {
|
|
136
214
|
return this.http
|
|
137
215
|
.get(`/statistics/${surveyId}`, {
|
|
138
216
|
params: {
|
|
139
217
|
...statistics,
|
|
140
|
-
statisticsBy:
|
|
218
|
+
statisticsBy: "SURVEY",
|
|
141
219
|
},
|
|
142
220
|
})
|
|
143
|
-
.then(response => response.data);
|
|
221
|
+
.then((response) => response.data);
|
|
144
222
|
}
|
|
145
223
|
|
|
146
|
-
loadStatisticsByTargets(
|
|
224
|
+
loadStatisticsByTargets(
|
|
225
|
+
surveyId: string,
|
|
226
|
+
statistics: ResponseStatisticsModel
|
|
227
|
+
): Promise<ResponseStatisticsModel> {
|
|
147
228
|
return this.http
|
|
148
229
|
.get(`/statistics/${surveyId}`, {
|
|
149
230
|
params: {
|
|
150
231
|
...statistics,
|
|
151
|
-
statisticsBy:
|
|
232
|
+
statisticsBy: "TARGET",
|
|
152
233
|
},
|
|
153
234
|
})
|
|
154
|
-
.then(response => response.data);
|
|
235
|
+
.then((response) => response.data);
|
|
155
236
|
}
|
|
156
237
|
|
|
157
|
-
loadStatisticsWithFiltersByAll(
|
|
238
|
+
loadStatisticsWithFiltersByAll(
|
|
239
|
+
surveyId: string,
|
|
240
|
+
statistics: ResponseStatisticsModel
|
|
241
|
+
): Promise<ResponseStatisticsModel> {
|
|
158
242
|
return this.http
|
|
159
243
|
.post(`/statistics/${surveyId}`, {
|
|
160
244
|
...statistics,
|
|
161
|
-
statisticsBy:
|
|
245
|
+
statisticsBy: "ALL",
|
|
162
246
|
})
|
|
163
|
-
.then(response => response.data);
|
|
247
|
+
.then((response) => response.data);
|
|
164
248
|
}
|
|
165
249
|
|
|
166
|
-
loadStatisticsWithFiltersBySurvey(
|
|
250
|
+
loadStatisticsWithFiltersBySurvey(
|
|
251
|
+
surveyId: string,
|
|
252
|
+
statistics: ResponseStatisticsModel
|
|
253
|
+
): Promise<ResponseStatisticsModel> {
|
|
167
254
|
return this.http
|
|
168
255
|
.post(`/statistics/${surveyId}`, {
|
|
169
256
|
...statistics,
|
|
170
|
-
statisticsBy:
|
|
257
|
+
statisticsBy: "SURVEY",
|
|
171
258
|
})
|
|
172
|
-
.then(response => response.data);
|
|
259
|
+
.then((response) => response.data);
|
|
173
260
|
}
|
|
174
261
|
|
|
175
|
-
loadStatisticsWithFiltersByTargets(
|
|
262
|
+
loadStatisticsWithFiltersByTargets(
|
|
263
|
+
surveyId: string,
|
|
264
|
+
statistics: ResponseStatisticsModel
|
|
265
|
+
): Promise<ResponseStatisticsModel> {
|
|
176
266
|
return this.http
|
|
177
267
|
.post(`/statistics/${surveyId}`, {
|
|
178
268
|
...statistics,
|
|
179
|
-
statisticsBy:
|
|
269
|
+
statisticsBy: "TARGET",
|
|
180
270
|
})
|
|
181
|
-
.then(response => response.data);
|
|
271
|
+
.then((response) => response.data);
|
|
182
272
|
}
|
|
183
273
|
|
|
184
274
|
loadStatisticsBySurveyAndTarget(data: any) {
|
|
185
|
-
return this.http
|
|
275
|
+
return this.http
|
|
276
|
+
.post(`/statistics/targets`, data)
|
|
277
|
+
.then((response) => response.data);
|
|
186
278
|
}
|
|
187
279
|
|
|
188
280
|
loadRespondents(params: any): Promise<PlanModel> {
|
|
189
|
-
return this.http
|
|
281
|
+
return this.http
|
|
282
|
+
.get(`/respondents`, { params: params })
|
|
283
|
+
.then((response) => response.data);
|
|
190
284
|
}
|
|
191
285
|
|
|
192
286
|
loadRespondentByPlanAndTarget(params: any): Promise<PlanModel> {
|
|
193
|
-
return this.http
|
|
287
|
+
return this.http
|
|
288
|
+
.get(`/respondents/target`, { params: params })
|
|
289
|
+
.then((response) => response.data);
|
|
194
290
|
}
|
|
195
291
|
|
|
196
292
|
get(url: string, params: any): Promise<Object> {
|
|
197
|
-
return this.exhttp
|
|
293
|
+
return this.exhttp
|
|
294
|
+
.get(url, { params: params })
|
|
295
|
+
.then((response) => response.data);
|
|
198
296
|
}
|
|
199
297
|
|
|
200
298
|
updatePlanStatistics(params: any): Promise<ResponseStatisticsModel> {
|
|
201
|
-
return this.http
|
|
299
|
+
return this.http
|
|
300
|
+
.put("/statistics", params)
|
|
301
|
+
.then((response) => response.data);
|
|
202
302
|
}
|
|
203
303
|
}
|
package/src/survey-service.ts
CHANGED
|
@@ -1,90 +1,141 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from
|
|
2
|
+
PlanModel,
|
|
3
|
+
PlanStatisticsModel,
|
|
4
|
+
BaseQuestionModel as QuestionModel,
|
|
5
|
+
ResponseModel,
|
|
6
|
+
ResponseStatisticsModel,
|
|
7
|
+
SurveyModel,
|
|
8
|
+
} from "@wg-npm/survey-core";
|
|
9
9
|
|
|
10
10
|
export interface SurveyServiceOptions {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
baseUrl: string;
|
|
12
|
+
version: string;
|
|
13
|
+
httpDecorator: Function;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export interface SurveyService {
|
|
17
|
-
|
|
17
|
+
loadSurvey(id: string): Promise<SurveyModel>;
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
loadSurveys(params: any): Promise<SurveyModel[]>;
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
createSurvey(survey: SurveyModel): Promise<SurveyModel>;
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
updateSurvey(survey: SurveyModel): Promise<SurveyModel>;
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
deleteSurvey(id: string): Promise<void>;
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
createQuestion(
|
|
28
|
+
surveyId: string,
|
|
29
|
+
question: QuestionModel
|
|
30
|
+
): Promise<QuestionModel>;
|
|
28
31
|
|
|
29
|
-
|
|
32
|
+
createQuestions(
|
|
33
|
+
surveyId: string,
|
|
34
|
+
questions: Array<QuestionModel>
|
|
35
|
+
): Promise<QuestionModel>;
|
|
30
36
|
|
|
31
|
-
|
|
37
|
+
updateQuestion(
|
|
38
|
+
surveyId: string,
|
|
39
|
+
question: QuestionModel
|
|
40
|
+
): Promise<QuestionModel>;
|
|
32
41
|
|
|
33
|
-
|
|
42
|
+
updateQuestionsOptions(
|
|
43
|
+
surveyId: string,
|
|
44
|
+
questions: Array<QuestionModel>
|
|
45
|
+
): Promise<QuestionModel>;
|
|
34
46
|
|
|
35
|
-
|
|
47
|
+
moveQuestion(
|
|
48
|
+
surveyId: string,
|
|
49
|
+
questionId: string,
|
|
50
|
+
index: number
|
|
51
|
+
): Promise<void>;
|
|
36
52
|
|
|
37
|
-
|
|
53
|
+
deleteQuestion(surveyId: string, questionId: string): Promise<void>;
|
|
38
54
|
|
|
39
|
-
|
|
55
|
+
loadResponse(id: string): Promise<ResponseModel>;
|
|
40
56
|
|
|
41
|
-
|
|
57
|
+
loadResponses(params: any): Promise<ResponseModel>;
|
|
42
58
|
|
|
43
|
-
|
|
59
|
+
loadResponsesPost(params: any): Promise<ResponseModel>;
|
|
44
60
|
|
|
45
|
-
|
|
61
|
+
dispatchResponse(
|
|
62
|
+
surveyId: string,
|
|
63
|
+
response: ResponseModel
|
|
64
|
+
): Promise<ResponseModel>;
|
|
46
65
|
|
|
47
|
-
|
|
66
|
+
dispatchResponses(
|
|
67
|
+
surveyId: string,
|
|
68
|
+
respondentId: string,
|
|
69
|
+
targets: Array<string>
|
|
70
|
+
): Promise<ResponseModel>;
|
|
48
71
|
|
|
49
|
-
|
|
72
|
+
dispatchResponse(
|
|
73
|
+
surveyId: string,
|
|
74
|
+
response: ResponseModel
|
|
75
|
+
): Promise<ResponseModel>;
|
|
50
76
|
|
|
51
|
-
|
|
77
|
+
updateResponse(response: ResponseModel): Promise<ResponseModel>;
|
|
52
78
|
|
|
53
|
-
|
|
79
|
+
loadMyPlans(params: any): Promise<ResponseModel>;
|
|
54
80
|
|
|
55
|
-
|
|
81
|
+
loadPlans(params: any): Promise<PlanModel>;
|
|
56
82
|
|
|
57
|
-
|
|
83
|
+
loadPlanById(planId: string, params: any): Promise<PlanModel>;
|
|
58
84
|
|
|
59
|
-
|
|
85
|
+
loadPlanWithFiltersById(
|
|
86
|
+
planId: string,
|
|
87
|
+
statistics: PlanStatisticsModel
|
|
88
|
+
): Promise<PlanStatisticsModel>;
|
|
60
89
|
|
|
61
|
-
|
|
90
|
+
loadPlanWithFiltersByIdAndTargetId(
|
|
91
|
+
planId: string,
|
|
92
|
+
targetId: string,
|
|
93
|
+
statistics: PlanStatisticsModel
|
|
94
|
+
): Promise<PlanStatisticsModel>;
|
|
62
95
|
|
|
63
|
-
|
|
96
|
+
createPlan(plan: PlanModel): Promise<PlanModel>;
|
|
64
97
|
|
|
65
|
-
|
|
98
|
+
updatePlan(plan: PlanModel): Promise<PlanModel>;
|
|
66
99
|
|
|
67
|
-
|
|
100
|
+
deletePlan(id: string): Promise<void>;
|
|
68
101
|
|
|
69
|
-
|
|
102
|
+
loadStatisticsByAll(
|
|
103
|
+
surveyId: string,
|
|
104
|
+
statistics: ResponseStatisticsModel
|
|
105
|
+
): Promise<ResponseStatisticsModel>;
|
|
70
106
|
|
|
71
|
-
|
|
107
|
+
loadStatisticsBySurvey(
|
|
108
|
+
surveyId: string,
|
|
109
|
+
statistics: ResponseStatisticsModel
|
|
110
|
+
): Promise<ResponseStatisticsModel>;
|
|
72
111
|
|
|
73
|
-
|
|
112
|
+
loadStatisticsByTargets(
|
|
113
|
+
surveyId: string,
|
|
114
|
+
statistics: ResponseStatisticsModel
|
|
115
|
+
): Promise<ResponseStatisticsModel>;
|
|
74
116
|
|
|
75
|
-
|
|
117
|
+
loadStatisticsWithFiltersByAll(
|
|
118
|
+
surveyId: string,
|
|
119
|
+
statistics: ResponseStatisticsModel
|
|
120
|
+
): Promise<ResponseStatisticsModel>;
|
|
76
121
|
|
|
77
|
-
|
|
122
|
+
loadStatisticsWithFiltersBySurvey(
|
|
123
|
+
surveyId: string,
|
|
124
|
+
statistics: ResponseStatisticsModel
|
|
125
|
+
): Promise<ResponseStatisticsModel>;
|
|
78
126
|
|
|
79
|
-
|
|
127
|
+
loadStatisticsWithFiltersByTargets(
|
|
128
|
+
surveyId: string,
|
|
129
|
+
statistics: ResponseStatisticsModel
|
|
130
|
+
): Promise<ResponseStatisticsModel>;
|
|
80
131
|
|
|
81
|
-
|
|
132
|
+
loadStatisticsBySurveyAndTarget(data: any): Promise<ResponseStatisticsModel>;
|
|
82
133
|
|
|
83
|
-
|
|
134
|
+
loadRespondents(params: any): Promise<ResponseModel>;
|
|
84
135
|
|
|
85
|
-
|
|
136
|
+
loadRespondentByPlanAndTarget(params: any): Promise<ResponseModel>;
|
|
86
137
|
|
|
87
|
-
|
|
138
|
+
get(url: string, params: any): Promise<Object>;
|
|
88
139
|
|
|
89
|
-
|
|
140
|
+
updatePlanStatistics(params: any): Promise<ResponseStatisticsModel>;
|
|
90
141
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import _Vue from
|
|
2
|
-
import
|
|
3
|
-
import { SurveyModel, QuestionModel } from
|
|
1
|
+
import _Vue from "vue";
|
|
2
|
+
import "./vue.d.ts";
|
|
3
|
+
import { SurveyModel, QuestionModel } from "@wg-npm/survey-core";
|
|
4
4
|
|
|
5
5
|
interface SurveyServiceOptions {
|
|
6
6
|
baseUrl: string;
|
|
@@ -10,9 +10,19 @@ interface SurveyServiceOptions {
|
|
|
10
10
|
interface SurveyService {
|
|
11
11
|
loadSurvey(id: string): Promise<SurveyModel>;
|
|
12
12
|
loadSurveys(params: any): Promise<SurveyModel[]>;
|
|
13
|
-
createQuestion(
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
createQuestion(
|
|
14
|
+
surveyId: string,
|
|
15
|
+
question: QuestionModel
|
|
16
|
+
): Promise<QuestionModel>;
|
|
17
|
+
updateQuestion(
|
|
18
|
+
surveyId: string,
|
|
19
|
+
question: QuestionModel
|
|
20
|
+
): Promise<QuestionModel>;
|
|
21
|
+
moveQuestion(
|
|
22
|
+
surveyId: string,
|
|
23
|
+
questionId: string,
|
|
24
|
+
index: number
|
|
25
|
+
): Promise<void>;
|
|
16
26
|
deleteQuestion(surveyId: string, questionId: string): Promise<void>;
|
|
17
27
|
}
|
|
18
28
|
|
package/types/vue.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import Vue from
|
|
2
|
-
import { SurveyService } from
|
|
1
|
+
import Vue from "vue";
|
|
2
|
+
import { SurveyService } from "./index";
|
|
3
3
|
|
|
4
|
-
declare module
|
|
4
|
+
declare module "vue/types/options" {
|
|
5
5
|
interface ComponentOptions<V extends Vue> {
|
|
6
6
|
$surveyService?: SurveyService;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
declare module
|
|
10
|
+
declare module "vue/types/vue" {
|
|
11
11
|
interface Vue {
|
|
12
12
|
$surveyService: SurveyService;
|
|
13
13
|
}
|