zcatalyst-cli 1.10.0 → 1.12.0
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/docs/.DS_Store +0 -0
- package/docs/client-utils.toml +5 -0
- package/docs/command_needs/auth.toml +1 -1
- package/docs/optional-import.toml +10 -0
- package/docs/plugin-loader.toml +4 -0
- package/docs/serve/server/index.toml +4 -0
- package/docs/serve/server/lib/web_client/server.toml +4 -0
- package/lib/apig-utils.js +2 -1
- package/lib/archiver.js +3 -3
- package/lib/client-utils.js +8 -6
- package/lib/command_needs/auth.js +2 -2
- package/lib/commands/client/delete.js +1 -0
- package/lib/commands/event/generate/index.js +4 -13
- package/lib/commands/functions/shell.js +5 -2
- package/lib/commands/iac/import.js +29 -6
- package/lib/commands/init.js +1 -1
- package/lib/commands/pull.js +1 -1
- package/lib/commands/serve.js +2 -1
- package/lib/endpoints/lib/sdk.js +2 -2
- package/lib/error.js +16 -13
- package/lib/errorOut.js +2 -2
- package/lib/fn-utils/lib/common.js +6 -5
- package/lib/fn-utils/lib/java.js +1 -1
- package/lib/fn-utils/lib/node.js +2 -2
- package/lib/init/dependencies/npm-install.js +10 -10
- package/lib/init/features/client/index.js +47 -0
- package/lib/init/features/client/initializers/angular.js +104 -0
- package/lib/init/features/client/initializers/basic.js +50 -0
- package/lib/init/features/client/initializers/lyte.js +56 -0
- package/lib/init/features/client/initializers/react.js +78 -0
- package/lib/init/features/functions/languages/node.js +3 -1
- package/lib/init/features/index.js +10 -3
- package/lib/init/features/project.js +2 -1
- package/lib/init/util/client.js +89 -4
- package/lib/internal/command.js +4 -1
- package/lib/internal/config.js +2 -1
- package/lib/optional-import.js +27 -26
- package/lib/plugin-loader.js +27 -10
- package/lib/port-resolver.js +4 -2
- package/lib/serve/index.js +6 -1
- package/lib/serve/server/index.js +52 -8
- package/lib/serve/server/lib/master.js +24 -12
- package/lib/serve/server/lib/web_client/index.js +30 -0
- package/lib/serve/server/lib/web_client/server.js +171 -0
- package/lib/shell/index.js +10 -6
- package/lib/util_modules/char.js +1 -1
- package/lib/util_modules/config/lib/apig.js +2 -1
- package/lib/util_modules/config/lib/client.js +18 -21
- package/lib/util_modules/constants/index.js +3 -1
- package/lib/util_modules/constants/lib/placeholders.js +1 -0
- package/lib/util_modules/constants/lib/plugin.js +28 -0
- package/lib/util_modules/constants/lib/template.js +11 -1
- package/lib/util_modules/constants/lib/urls.js +29 -13
- package/lib/util_modules/{contextHelp.js → context-help.js} +0 -0
- package/lib/util_modules/env.js +13 -12
- package/lib/util_modules/fs/index.js +1 -9
- package/lib/util_modules/fs/lib/async.js +3 -3
- package/lib/util_modules/fs/utils.js +8 -0
- package/lib/util_modules/global-space.js +2 -0
- package/lib/util_modules/option.js +5 -1
- package/lib/util_modules/shell.js +10 -6
- package/lib/winston.js +1 -1
- package/package.json +7 -4
- package/templates/.DS_Store +0 -0
- package/templates/init/.DS_Store +0 -0
- package/templates/init/client/.DS_Store +0 -0
- package/templates/init/client/{client-package.json → basic/client-package.json} +0 -0
- package/templates/init/client/{index.html → basic/index.html} +0 -0
- package/templates/init/client/{main.css → basic/main.css} +0 -0
- package/templates/init/client/{main.js → basic/main.js} +0 -0
- package/templates/init/client/lyte/build/build.js +301 -0
- package/templates/init/client/lyte/build/scripts/cliDownloadScript.js +54 -0
- package/templates/init/client/lyte/client-package.json +5 -0
- package/templates/init/client/lyte/components/javascript/welcome-comp.js +13 -0
- package/templates/init/client/lyte/components/styles/welcome-comp.css +0 -0
- package/templates/init/client/lyte/components/templates/welcome-comp.html +8 -0
- package/templates/init/client/lyte/data-store/adapters/.gitkeep +0 -0
- package/templates/init/client/lyte/data-store/models/.gitkeep +0 -0
- package/templates/init/client/lyte/data-store/serializers/.gitkeep +0 -0
- package/templates/init/client/lyte/index.html +17 -0
- package/templates/init/client/lyte/package.json +12 -0
- package/templates/init/client/lyte/router.js +14 -0
- package/templates/init/client/lyte/routes/index.js +54 -0
- package/templates/init/client/react/.DS_Store +0 -0
- package/templates/init/client/react/react_js/package.json +11 -0
- package/templates/init/client/react/react_js/template/README.md +70 -0
- package/templates/init/client/react/react_js/template/client-package.json +5 -0
- package/templates/init/client/react/react_js/template/gitignore +23 -0
- package/templates/init/client/react/react_js/template/public/favicon.ico +0 -0
- package/templates/init/client/react/react_js/template/public/index.html +43 -0
- package/templates/init/client/react/react_js/template/public/logo192.png +0 -0
- package/templates/init/client/react/react_js/template/public/logo512.png +0 -0
- package/templates/init/client/react/react_js/template/public/manifest.json +25 -0
- package/templates/init/client/react/react_js/template/public/robots.txt +3 -0
- package/templates/init/client/react/react_js/template/src/App.css +38 -0
- package/templates/init/client/react/react_js/template/src/App.js +25 -0
- package/templates/init/client/react/react_js/template/src/App.test.js +8 -0
- package/templates/init/client/react/react_js/template/src/index.css +13 -0
- package/templates/init/client/react/react_js/template/src/index.js +17 -0
- package/templates/init/client/react/react_js/template/src/logo.svg +1 -0
- package/templates/init/client/react/react_js/template/src/reportWebVitals.js +13 -0
- package/templates/init/client/react/react_js/template/src/setupTests.js +5 -0
- package/templates/init/client/react/react_js/template.json +13 -0
- package/templates/init/client/react/react_ts/package.json +11 -0
- package/templates/init/client/react/react_ts/template/README.md +46 -0
- package/templates/init/client/react/react_ts/template/client-package.json +5 -0
- package/templates/init/client/react/react_ts/template/gitignore +23 -0
- package/templates/init/client/react/react_ts/template/public/favicon.ico +0 -0
- package/templates/init/client/react/react_ts/template/public/index.html +43 -0
- package/templates/init/client/react/react_ts/template/public/logo192.png +0 -0
- package/templates/init/client/react/react_ts/template/public/logo512.png +0 -0
- package/templates/init/client/react/react_ts/template/public/manifest.json +25 -0
- package/templates/init/client/react/react_ts/template/public/robots.txt +3 -0
- package/templates/init/client/react/react_ts/template/src/App.css +38 -0
- package/templates/init/client/react/react_ts/template/src/App.test.tsx +9 -0
- package/templates/init/client/react/react_ts/template/src/App.tsx +26 -0
- package/templates/init/client/react/react_ts/template/src/index.css +13 -0
- package/templates/init/client/react/react_ts/template/src/index.tsx +17 -0
- package/templates/init/client/react/react_ts/template/src/logo.svg +1 -0
- package/templates/init/client/react/react_ts/template/src/reportWebVitals.ts +15 -0
- package/templates/init/client/react/react_ts/template/src/setupTests.ts +5 -0
- package/templates/init/client/react/react_ts/template.json +18 -0
- package/templates/init/functions/java/integ/cliq/com/handlers/BotHandler.java +96 -111
- package/templates/init/functions/java/integ/cliq/com/handlers/CommandHandler.java +20 -27
- package/templates/init/functions/java/integ/cliq/com/handlers/FunctionHandler.java +143 -112
- package/templates/init/functions/java/integ/cliq/com/handlers/InstallationHandler.java +4 -7
- package/templates/init/functions/java/integ/cliq/com/handlers/InstallationValidator.java +4 -7
- package/templates/init/functions/java/integ/cliq/com/handlers/MessageActionHandler.java +10 -12
- package/templates/init/functions/java/integ/cliq/com/handlers/WidgetHandler.java +100 -66
- package/templates/init/functions/java/integ/cliq/sample.java +5 -7
- package/templates/init/functions/node/integ/cliq/handlers/bot-handler.js +2 -3
- package/templates/init/functions/node/integ/cliq/handlers/command-handler.js +0 -1
- package/templates/init/functions/node/integ/cliq/handlers/function-handler.js +46 -0
- package/templates/init/functions/node/integ/cliq/handlers/widget-handler.js +31 -0
- package/templates/web-socket.txt +21 -0
- package/lib/init/features/client.js +0 -50
- package/lib/serve/server/lib/client.js +0 -30
|
@@ -7,6 +7,7 @@ import java.util.Arrays;
|
|
|
7
7
|
import java.util.Date;
|
|
8
8
|
import java.util.List;
|
|
9
9
|
import java.util.Map;
|
|
10
|
+
import java.util.logging.Logger;
|
|
10
11
|
|
|
11
12
|
import org.json.JSONArray;
|
|
12
13
|
import org.json.JSONObject;
|
|
@@ -15,11 +16,12 @@ import com.zc.cliq.enums.ACTION_TYPE;
|
|
|
15
16
|
import com.zc.cliq.enums.BANNER_STATUS;
|
|
16
17
|
import com.zc.cliq.enums.FORM_FIELD_TYPE;
|
|
17
18
|
import com.zc.cliq.enums.FORM_MODIFICATION_ACTION_TYPE;
|
|
18
|
-
import com.zc.cliq.enums.MESSAGE_TYPE;
|
|
19
19
|
import com.zc.cliq.enums.SLIDE_TYPE;
|
|
20
20
|
import com.zc.cliq.enums.SYSTEM_API_ACTION;
|
|
21
21
|
import com.zc.cliq.enums.WIDGET_ELEMENT_TYPE;
|
|
22
|
+
import com.zc.cliq.enums.WIDGET_NAVIGATION;
|
|
22
23
|
import com.zc.cliq.enums.WIDGET_TYPE;
|
|
24
|
+
import com.zc.cliq.objects.ButtonObject;
|
|
23
25
|
import com.zc.cliq.objects.CardDetails;
|
|
24
26
|
import com.zc.cliq.objects.Form;
|
|
25
27
|
import com.zc.cliq.objects.FormAction;
|
|
@@ -30,10 +32,11 @@ import com.zc.cliq.objects.FormModificationAction;
|
|
|
30
32
|
import com.zc.cliq.objects.FormTarget;
|
|
31
33
|
import com.zc.cliq.objects.FormValue;
|
|
32
34
|
import com.zc.cliq.objects.Message;
|
|
33
|
-
import com.zc.cliq.objects.MessageBuilder;
|
|
34
35
|
import com.zc.cliq.objects.Slide;
|
|
35
36
|
import com.zc.cliq.objects.WidgetButton;
|
|
36
37
|
import com.zc.cliq.objects.WidgetElement;
|
|
38
|
+
import com.zc.cliq.objects.WidgetFooter;
|
|
39
|
+
import com.zc.cliq.objects.WidgetHeader;
|
|
37
40
|
import com.zc.cliq.objects.WidgetResponse;
|
|
38
41
|
import com.zc.cliq.objects.WidgetSection;
|
|
39
42
|
import com.zc.cliq.requests.ButtonFunctionRequest;
|
|
@@ -41,67 +44,61 @@ import com.zc.cliq.requests.FormFunctionRequest;
|
|
|
41
44
|
import com.zc.cliq.requests.WidgetFunctionRequest;
|
|
42
45
|
import com.zc.cliq.util.ZCCliqUtil;
|
|
43
46
|
|
|
44
|
-
public class FunctionHandler implements com.zc.cliq.interfaces.FunctionHandler
|
|
45
|
-
|
|
47
|
+
public class FunctionHandler implements com.zc.cliq.interfaces.FunctionHandler {
|
|
48
|
+
|
|
49
|
+
Logger LOGGER = Logger.getLogger(FunctionHandler.class.getName());
|
|
46
50
|
|
|
47
51
|
@Override
|
|
48
|
-
public Map<String, Object> buttonFunctionHandler(ButtonFunctionRequest req) throws Exception
|
|
49
|
-
|
|
50
|
-
MessageBuilder msg = MessageBuilder.getInstance("Button function executed");
|
|
52
|
+
public Map<String, Object> buttonFunctionHandler(ButtonFunctionRequest req) throws Exception {
|
|
53
|
+
Message msg = Message.getInstance("Button function executed");
|
|
51
54
|
return ZCCliqUtil.toMap(msg);
|
|
52
55
|
}
|
|
53
|
-
|
|
56
|
+
|
|
54
57
|
@Override
|
|
55
|
-
public Map<String, Object> formSubmitHandler(FormFunctionRequest req) throws Exception
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
public Map<String, Object> formSubmitHandler(FormFunctionRequest req) throws Exception {
|
|
59
|
+
JSONObject values = req.getForm().getValues();
|
|
60
|
+
|
|
59
61
|
String type = values.optString("type", null);
|
|
60
|
-
if(type != null){
|
|
61
|
-
if(type.equals("formtab")){
|
|
62
|
+
if (type != null) {
|
|
63
|
+
if (type.equals("formtab")) {
|
|
62
64
|
WidgetResponse widgetResp = WidgetResponse.getInstance();
|
|
63
65
|
widgetResp.setType(WIDGET_TYPE.APPLET);
|
|
64
|
-
|
|
66
|
+
|
|
65
67
|
WidgetSection titleSection = WidgetSection.getInstance();
|
|
66
68
|
titleSection.setId("100");
|
|
67
|
-
|
|
69
|
+
|
|
68
70
|
WidgetElement editedBy = WidgetElement.getInstance(WIDGET_ELEMENT_TYPE.TITLE);
|
|
69
71
|
editedBy.setText("Edited by " + values.optString("text") + " :wink:");
|
|
70
72
|
titleSection.addElement(editedBy);
|
|
71
|
-
|
|
73
|
+
|
|
72
74
|
WidgetElement time = WidgetElement.getInstance(WIDGET_ELEMENT_TYPE.SUBTEXT);
|
|
73
75
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
74
76
|
time.setText("Target:buttons\nTime : " + sdf.format(new Date()));
|
|
75
77
|
titleSection.addElement(time);
|
|
76
|
-
|
|
78
|
+
|
|
77
79
|
widgetResp.addSection(titleSection);
|
|
78
|
-
|
|
80
|
+
|
|
79
81
|
WidgetSection buttonSection = getButtonsSection();
|
|
80
82
|
widgetResp.addSection(buttonSection);
|
|
81
|
-
|
|
83
|
+
|
|
82
84
|
return ZCCliqUtil.toMap(widgetResp);
|
|
83
|
-
}
|
|
84
|
-
else if(type.equals("formsection")){
|
|
85
|
+
} else if (type.equals("formsection")) {
|
|
85
86
|
WidgetSection section = WidgetSection.getInstance();
|
|
86
87
|
section.setId("102");
|
|
87
88
|
section.setType("section");
|
|
88
89
|
WidgetElement editedBy = WidgetElement.getInstance(WIDGET_ELEMENT_TYPE.TITLE);
|
|
89
90
|
editedBy.setText("Edited by " + values.optString("text") + " :wink:");
|
|
90
91
|
section.addElement(editedBy);
|
|
91
|
-
|
|
92
|
+
|
|
92
93
|
return ZCCliqUtil.toMap(section);
|
|
93
|
-
}
|
|
94
|
-
else{
|
|
94
|
+
} else {
|
|
95
95
|
Message msg = Message.getInstance("Applet Button executed successfully");
|
|
96
|
-
msg.
|
|
97
|
-
msg.setStatus(BANNER_STATUS.SUCCESS);
|
|
98
|
-
|
|
96
|
+
msg.setBannerResponse(BANNER_STATUS.SUCCESS);
|
|
99
97
|
return ZCCliqUtil.toMap(msg);
|
|
100
98
|
}
|
|
101
99
|
}
|
|
102
|
-
String text = new StringBuilder().append("Hi ").append(values.getString("username"))
|
|
103
|
-
|
|
104
|
-
MessageBuilder msg = MessageBuilder.getInstance(text);
|
|
100
|
+
String text = new StringBuilder().append("Hi ").append(values.getString("username")).append(", thanks for raising your request. Your request will be processed based on the device availability.").toString();
|
|
101
|
+
Message msg = Message.getInstance(text);
|
|
105
102
|
msg.setCard(CardDetails.getInstance("Asset Request"));
|
|
106
103
|
Slide slide = Slide.getInstance();
|
|
107
104
|
slide.setType(SLIDE_TYPE.LABEL);
|
|
@@ -110,15 +107,14 @@ JSONObject values = req.getForm().getValues();
|
|
|
110
107
|
JSONObject obj1 = new JSONObject();
|
|
111
108
|
obj1.put("Asset Type", values.getJSONObject("asset-type").getString("label"));
|
|
112
109
|
dataArray.put(obj1);
|
|
113
|
-
if(values.getJSONObject("asset-type").getString("value").equals("mobile")){
|
|
110
|
+
if (values.getJSONObject("asset-type").getString("value").equals("mobile")) {
|
|
114
111
|
JSONObject obj2 = new JSONObject();
|
|
115
112
|
obj2.put("Preferred OS", values.getJSONObject("mobile-os").getString("label"));
|
|
116
113
|
dataArray.put(obj2);
|
|
117
114
|
JSONObject obj3 = new JSONObject();
|
|
118
115
|
obj3.put("Preferred Device", values.getJSONObject("mobile-list").getString("label"));
|
|
119
116
|
dataArray.put(obj3);
|
|
120
|
-
}
|
|
121
|
-
else{
|
|
117
|
+
} else {
|
|
122
118
|
JSONObject obj2 = new JSONObject();
|
|
123
119
|
obj2.put("OS/Device Preferred", values.getJSONObject("os-type").getString("label"));
|
|
124
120
|
dataArray.put(obj2);
|
|
@@ -129,15 +125,14 @@ JSONObject values = req.getForm().getValues();
|
|
|
129
125
|
}
|
|
130
126
|
|
|
131
127
|
@Override
|
|
132
|
-
public FormChangeResponse formChangeHandler(FormFunctionRequest req) throws Exception
|
|
133
|
-
{
|
|
128
|
+
public FormChangeResponse formChangeHandler(FormFunctionRequest req) throws Exception {
|
|
134
129
|
FormChangeResponse resp = FormChangeResponse.getInstance();
|
|
135
130
|
String target = req.getTarget().getName();
|
|
136
131
|
JSONObject values = req.getForm().getValues();
|
|
137
|
-
String fieldValue = ((JSONObject)values.get("asset-type")).get("value").toString();
|
|
138
|
-
if(target.equalsIgnoreCase("asset-type")){
|
|
139
|
-
|
|
140
|
-
if(fieldValue.equals("laptop")){
|
|
132
|
+
String fieldValue = ((JSONObject) values.get("asset-type")).get("value").toString();
|
|
133
|
+
if (target.equalsIgnoreCase("asset-type")) {
|
|
134
|
+
|
|
135
|
+
if (fieldValue.equals("laptop")) {
|
|
141
136
|
FormModificationAction selectBoxAction = FormModificationAction.getInstance();
|
|
142
137
|
selectBoxAction.setType(FORM_MODIFICATION_ACTION_TYPE.ADD_AFTER);
|
|
143
138
|
selectBoxAction.setName("asset-type");
|
|
@@ -162,20 +157,19 @@ JSONObject values = req.getForm().getValues();
|
|
|
162
157
|
OS.addOption(windows);
|
|
163
158
|
OS.addOption(ubuntu);
|
|
164
159
|
selectBoxAction.setInput(OS);
|
|
165
|
-
|
|
160
|
+
|
|
166
161
|
FormModificationAction removeMobileOSAction = FormModificationAction.getInstance();
|
|
167
162
|
removeMobileOSAction.setType(FORM_MODIFICATION_ACTION_TYPE.REMOVE);
|
|
168
163
|
removeMobileOSAction.setName("mobile-os");
|
|
169
|
-
|
|
164
|
+
|
|
170
165
|
FormModificationAction removeMobileListAction = FormModificationAction.getInstance();
|
|
171
166
|
removeMobileListAction.setType(FORM_MODIFICATION_ACTION_TYPE.REMOVE);
|
|
172
167
|
removeMobileListAction.setName("mobile-list");
|
|
173
|
-
|
|
168
|
+
|
|
174
169
|
resp.addAction(selectBoxAction);
|
|
175
170
|
resp.addAction(removeMobileOSAction);
|
|
176
171
|
resp.addAction(removeMobileListAction);
|
|
177
|
-
}
|
|
178
|
-
else if(fieldValue.equals("mobile")){
|
|
172
|
+
} else if (fieldValue.equals("mobile")) {
|
|
179
173
|
FormModificationAction selectBoxAction = FormModificationAction.getInstance();
|
|
180
174
|
selectBoxAction.setType(FORM_MODIFICATION_ACTION_TYPE.ADD_AFTER);
|
|
181
175
|
selectBoxAction.setName("asset-type");
|
|
@@ -196,19 +190,18 @@ JSONObject values = req.getForm().getValues();
|
|
|
196
190
|
OS.addOption(android);
|
|
197
191
|
OS.addOption(ios);
|
|
198
192
|
selectBoxAction.setInput(OS);
|
|
199
|
-
|
|
193
|
+
|
|
200
194
|
FormModificationAction removeOSTypeAction = FormModificationAction.getInstance();
|
|
201
195
|
removeOSTypeAction.setType(FORM_MODIFICATION_ACTION_TYPE.REMOVE);
|
|
202
196
|
removeOSTypeAction.setName("os-type");
|
|
203
|
-
|
|
197
|
+
|
|
204
198
|
resp.addAction(selectBoxAction);
|
|
205
199
|
resp.addAction(removeOSTypeAction);
|
|
206
200
|
}
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
if(fieldValue != null){
|
|
201
|
+
|
|
202
|
+
} else if (target.equalsIgnoreCase("mobile-os")) {
|
|
203
|
+
|
|
204
|
+
if (fieldValue != null) {
|
|
212
205
|
FormModificationAction mobileListAction = FormModificationAction.getInstance();
|
|
213
206
|
mobileListAction.setType(FORM_MODIFICATION_ACTION_TYPE.ADD_AFTER);
|
|
214
207
|
mobileListAction.setName("mobile-os");
|
|
@@ -219,55 +212,46 @@ JSONObject values = req.getForm().getValues();
|
|
|
219
212
|
listInput.setPlaceholder("Choose your preferred mobile device");
|
|
220
213
|
listInput.setMandatory(true);
|
|
221
214
|
mobileListAction.setInput(listInput);
|
|
222
|
-
|
|
215
|
+
|
|
223
216
|
resp.addAction(mobileListAction);
|
|
224
|
-
}
|
|
225
|
-
else{
|
|
217
|
+
} else {
|
|
226
218
|
FormModificationAction removeMobileListAction = FormModificationAction.getInstance();
|
|
227
219
|
removeMobileListAction.setType(FORM_MODIFICATION_ACTION_TYPE.REMOVE);
|
|
228
220
|
removeMobileListAction.setName("mobile-list");
|
|
229
|
-
|
|
230
221
|
resp.addAction(removeMobileListAction);
|
|
231
222
|
}
|
|
232
|
-
|
|
233
223
|
}
|
|
234
224
|
return resp;
|
|
235
225
|
}
|
|
236
226
|
|
|
237
227
|
@Override
|
|
238
|
-
public FormDynamicFieldResponse formDynamicFieldHandler(FormFunctionRequest req) throws Exception
|
|
239
|
-
{
|
|
228
|
+
public FormDynamicFieldResponse formDynamicFieldHandler(FormFunctionRequest req) throws Exception {
|
|
240
229
|
FormDynamicFieldResponse resp = FormDynamicFieldResponse.getInstance();
|
|
241
230
|
FormTarget target = req.getTarget();
|
|
242
|
-
String query = target.getQuery();
|
|
231
|
+
String query = target.getQuery();
|
|
243
232
|
JSONObject values = req.getForm().getValues();
|
|
244
|
-
if(target.getName().equals("mobile-list") && !values.get("mobile-os").toString().isEmpty()){
|
|
233
|
+
if (target.getName().equals("mobile-list") && !values.get("mobile-os").toString().isEmpty()) {
|
|
245
234
|
String device = values.getJSONObject("mobile-os").getString("value");
|
|
246
|
-
if(device.equals("android")){
|
|
247
|
-
Arrays.stream(new String[]{"One Plus 6T","One Plus 6","Google Pixel 3","Google Pixel 2XL"})
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
else if(device.equals("ios")){
|
|
252
|
-
Arrays.stream(new String[]{"IPhone XR","IPhone XS","IPhone X","Iphone 8 Plus"})
|
|
253
|
-
.filter(phone -> phone.contains(query))
|
|
254
|
-
.forEach(phone -> resp.addOption(new FormValue(phone, phone.toLowerCase().replace(" ", "_"))));
|
|
235
|
+
if (device.equals("android")) {
|
|
236
|
+
Arrays.stream(new String[] { "One Plus 6T", "One Plus 6", "Google Pixel 3", "Google Pixel 2XL" }).filter(phone -> phone.contains(query)).forEach(phone -> resp.addOption(new FormValue(phone, phone.toLowerCase().replace(" ", "_"))));
|
|
237
|
+
} else if (device.equals("ios")) {
|
|
238
|
+
Arrays.stream(new String[] { "IPhone XR", "IPhone XS", "IPhone X", "Iphone 8 Plus" }).filter(phone -> phone.contains(query)).forEach(phone -> resp.addOption(new FormValue(phone, phone.toLowerCase().replace(" ", "_"))));
|
|
255
239
|
}
|
|
256
240
|
}
|
|
257
241
|
return resp;
|
|
258
242
|
}
|
|
259
243
|
|
|
260
244
|
@Override
|
|
261
|
-
public Map<String, Object> widgetButtonHandler(WidgetFunctionRequest req) throws Exception
|
|
262
|
-
|
|
263
|
-
String id =
|
|
264
|
-
switch(id){
|
|
265
|
-
case "tab"
|
|
266
|
-
|
|
245
|
+
public Map<String, Object> widgetButtonHandler(WidgetFunctionRequest req) throws Exception {
|
|
246
|
+
ButtonObject target = req.getTarget();
|
|
247
|
+
String id = target.getId();
|
|
248
|
+
switch (id) {
|
|
249
|
+
case "tab": {
|
|
250
|
+
|
|
267
251
|
WidgetResponse widgetResp = WidgetResponse.getInstance();
|
|
268
252
|
widgetResp.setType(WIDGET_TYPE.APPLET);
|
|
269
|
-
|
|
270
|
-
//Time
|
|
253
|
+
|
|
254
|
+
// Time
|
|
271
255
|
WidgetElement time = WidgetElement.getInstance(WIDGET_ELEMENT_TYPE.SUBTEXT);
|
|
272
256
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
273
257
|
time.setText("Target:buttons\nTime : " + sdf.format(new Date()));
|
|
@@ -275,14 +259,14 @@ JSONObject values = req.getForm().getValues();
|
|
|
275
259
|
titleSection.addElement(time);
|
|
276
260
|
titleSection.setId("100");
|
|
277
261
|
widgetResp.addSection(titleSection);
|
|
278
|
-
|
|
262
|
+
|
|
279
263
|
WidgetSection buttonSection = getButtonsSection();
|
|
280
|
-
|
|
264
|
+
|
|
281
265
|
widgetResp.addSection(buttonSection);
|
|
282
266
|
return ZCCliqUtil.toMap(widgetResp);
|
|
283
267
|
}
|
|
284
|
-
|
|
285
|
-
case "section"
|
|
268
|
+
|
|
269
|
+
case "section": {
|
|
286
270
|
WidgetSection section = WidgetSection.getInstance();
|
|
287
271
|
section.setId("102");
|
|
288
272
|
section.setType("section");
|
|
@@ -291,9 +275,9 @@ JSONObject values = req.getForm().getValues();
|
|
|
291
275
|
section.addElement(element);
|
|
292
276
|
return ZCCliqUtil.toMap(section);
|
|
293
277
|
}
|
|
294
|
-
|
|
295
|
-
case "formtab"
|
|
296
|
-
case "formsection"
|
|
278
|
+
|
|
279
|
+
case "formtab":
|
|
280
|
+
case "formsection": {
|
|
297
281
|
Form form = Form.getInstance();
|
|
298
282
|
form.setTitle("Zylker Annual Marathon");
|
|
299
283
|
form.setName("a");
|
|
@@ -307,67 +291,114 @@ JSONObject values = req.getForm().getValues();
|
|
|
307
291
|
input1.setMinLength("0");
|
|
308
292
|
input1.setMaxLength("25");
|
|
309
293
|
input1.setMandatory(true);
|
|
310
|
-
|
|
294
|
+
|
|
311
295
|
FormInput input2 = FormInput.getIntance();
|
|
312
296
|
input2.setType(FORM_FIELD_TYPE.HIDDEN);
|
|
313
297
|
input2.setName("type");
|
|
314
298
|
input2.setValue(id);
|
|
315
|
-
|
|
299
|
+
|
|
316
300
|
form.addFormInput(input1);
|
|
317
301
|
form.addFormInput(input2);
|
|
318
302
|
form.setAction(FormAction.getInstance("appletForm"));// ** ENTER YOUR FORM FUNCTION NAME HERE **
|
|
319
303
|
return ZCCliqUtil.toMap(form);
|
|
320
304
|
}
|
|
321
|
-
|
|
322
|
-
case "
|
|
323
|
-
|
|
305
|
+
|
|
306
|
+
case "breadcrumbs":
|
|
307
|
+
|
|
308
|
+
Integer page = Integer.parseInt(target.getLabel().split("Page : ")[1].trim()) + 1;
|
|
309
|
+
WidgetResponse widgetResp = WidgetResponse.getInstance();
|
|
310
|
+
widgetResp.setType(WIDGET_TYPE.APPLET);
|
|
311
|
+
WidgetElement elem = WidgetElement.getInstance(WIDGET_ELEMENT_TYPE.SUBTEXT);
|
|
312
|
+
elem.setText("Page " + page);
|
|
313
|
+
WidgetSection titleSection = WidgetSection.getInstance();
|
|
314
|
+
titleSection.addElement(elem);
|
|
315
|
+
titleSection.setId("12345");
|
|
316
|
+
widgetResp.addSection(titleSection);
|
|
317
|
+
|
|
318
|
+
WidgetButton fistNav = new WidgetButton();
|
|
319
|
+
fistNav.setLabel("Page : " + page);
|
|
320
|
+
fistNav.setType(ACTION_TYPE.INVOKE_FUNCTION);
|
|
321
|
+
fistNav.setName("appletFunction");
|
|
322
|
+
fistNav.setId("breadcrumbs");
|
|
323
|
+
|
|
324
|
+
WidgetButton linkButton = new WidgetButton();
|
|
325
|
+
linkButton.setLabel("Link");
|
|
326
|
+
linkButton.setType(ACTION_TYPE.OPEN_URL);
|
|
327
|
+
linkButton.setUrl("https://www.zoho.com");
|
|
328
|
+
|
|
329
|
+
WidgetButton bannerBtn = new WidgetButton();
|
|
330
|
+
bannerBtn.setLabel("Banner");
|
|
331
|
+
bannerBtn.setType(ACTION_TYPE.INVOKE_FUNCTION);
|
|
332
|
+
bannerBtn.setName("appletFunction");
|
|
333
|
+
bannerBtn.setId("banner");
|
|
334
|
+
|
|
335
|
+
WidgetHeader header = WidgetHeader.getInstance();
|
|
336
|
+
header.setTitle("Header " + page);
|
|
337
|
+
header.setNavigation(WIDGET_NAVIGATION.CONTINUE);
|
|
338
|
+
List<WidgetButton> headerButtons = new ArrayList<WidgetButton>();
|
|
339
|
+
headerButtons.add(fistNav);
|
|
340
|
+
headerButtons.add(bannerBtn);
|
|
341
|
+
headerButtons.add(linkButton);
|
|
342
|
+
header.setButtons(headerButtons);
|
|
343
|
+
widgetResp.setHeader(header);
|
|
344
|
+
|
|
345
|
+
WidgetFooter footer = WidgetFooter.getInstance();
|
|
346
|
+
footer.setText("Footer Text");
|
|
347
|
+
List<WidgetButton> footerButtons = new ArrayList<WidgetButton>();
|
|
348
|
+
footerButtons.add(bannerBtn);
|
|
349
|
+
footerButtons.add(linkButton);
|
|
350
|
+
footer.setButtons(footerButtons);
|
|
351
|
+
widgetResp.setFooter(footer);
|
|
352
|
+
|
|
353
|
+
return ZCCliqUtil.toMap(widgetResp);
|
|
354
|
+
|
|
355
|
+
case "banner":
|
|
356
|
+
default: {
|
|
324
357
|
Message msg = Message.getInstance("Applet Button executed successfully");
|
|
325
|
-
msg.
|
|
326
|
-
msg.setStatus(BANNER_STATUS.SUCCESS);
|
|
358
|
+
msg.setBannerResponse(BANNER_STATUS.SUCCESS);
|
|
327
359
|
return ZCCliqUtil.toMap(msg);
|
|
328
360
|
}
|
|
329
361
|
}
|
|
330
362
|
}
|
|
331
363
|
|
|
332
|
-
private WidgetSection getButtonsSection()
|
|
333
|
-
{
|
|
364
|
+
private WidgetSection getButtonsSection() {
|
|
334
365
|
WidgetSection buttonSection = WidgetSection.getInstance();
|
|
335
|
-
|
|
336
|
-
//Buttons - Row1
|
|
366
|
+
|
|
367
|
+
// Buttons - Row1
|
|
337
368
|
WidgetElement title = WidgetElement.getInstance(WIDGET_ELEMENT_TYPE.TITLE);
|
|
338
369
|
title.setText("Buttons");
|
|
339
|
-
|
|
370
|
+
|
|
340
371
|
WidgetElement buttonElement1 = WidgetElement.getInstance(WIDGET_ELEMENT_TYPE.BUTTONS);
|
|
341
372
|
List<WidgetButton> buttonsList1 = new ArrayList<WidgetButton>();
|
|
342
373
|
WidgetButton button1 = new WidgetButton();
|
|
343
374
|
button1.setLabel("Link");
|
|
344
375
|
button1.setType(ACTION_TYPE.OPEN_URL);
|
|
345
376
|
button1.setUrl("https://www.zoho.com");
|
|
346
|
-
|
|
377
|
+
|
|
347
378
|
WidgetButton button2 = new WidgetButton();
|
|
348
379
|
button2.setLabel("Banner");
|
|
349
380
|
button2.setType(ACTION_TYPE.INVOKE_FUNCTION);
|
|
350
381
|
button2.setName("appletFunction");
|
|
351
382
|
button2.setId("banner");
|
|
352
|
-
|
|
383
|
+
|
|
353
384
|
WidgetButton button3 = new WidgetButton();
|
|
354
385
|
button3.setLabel("Open Channel");
|
|
355
386
|
button3.setType(ACTION_TYPE.SYSTEM_API);
|
|
356
387
|
button3.setApi(SYSTEM_API_ACTION.JOIN_CHANNEL, "CD_1283959962893705602_14598233");// ** ENTER YOUR CHANNEL ID HERE **
|
|
357
|
-
|
|
388
|
+
|
|
358
389
|
WidgetButton button4 = new WidgetButton();
|
|
359
390
|
button4.setLabel("Preview");
|
|
360
391
|
button4.setType(ACTION_TYPE.PREVIEW_URL);
|
|
361
392
|
button4.setUrl("https://www.zoho.com/catalyst/features.html");
|
|
362
|
-
|
|
393
|
+
|
|
363
394
|
buttonsList1.add(button1);
|
|
364
395
|
buttonsList1.add(button2);
|
|
365
396
|
buttonsList1.add(button3);
|
|
366
397
|
buttonsList1.add(button4);
|
|
367
|
-
|
|
398
|
+
|
|
368
399
|
buttonElement1.setButtons(buttonsList1);
|
|
369
|
-
|
|
370
|
-
//Buttons - Row2
|
|
400
|
+
|
|
401
|
+
// Buttons - Row2
|
|
371
402
|
WidgetElement buttonElement2 = WidgetElement.getInstance(WIDGET_ELEMENT_TYPE.BUTTONS);
|
|
372
403
|
List<WidgetButton> buttonsList2 = new ArrayList<WidgetButton>();
|
|
373
404
|
WidgetButton button5 = new WidgetButton();
|
|
@@ -375,44 +406,44 @@ JSONObject values = req.getForm().getValues();
|
|
|
375
406
|
button5.setType(ACTION_TYPE.INVOKE_FUNCTION);
|
|
376
407
|
button5.setName("appletFunction");
|
|
377
408
|
button5.setId("section");
|
|
378
|
-
|
|
409
|
+
|
|
379
410
|
WidgetButton button6 = new WidgetButton();
|
|
380
411
|
button6.setLabel("Form Edit Section");
|
|
381
412
|
button6.setType(ACTION_TYPE.INVOKE_FUNCTION);
|
|
382
413
|
button6.setName("appletFunction");
|
|
383
414
|
button6.setId("formsection");
|
|
384
|
-
|
|
415
|
+
|
|
385
416
|
WidgetButton button7 = new WidgetButton();
|
|
386
417
|
button7.setLabel("Banner");
|
|
387
418
|
button7.setType(ACTION_TYPE.INVOKE_FUNCTION);
|
|
388
419
|
button7.setName("appletFunction");
|
|
389
420
|
button7.setId("banner");
|
|
390
|
-
|
|
421
|
+
|
|
391
422
|
WidgetButton button8 = new WidgetButton();
|
|
392
423
|
button8.setLabel("Edit Whole Tab");
|
|
393
424
|
button8.setType(ACTION_TYPE.INVOKE_FUNCTION);
|
|
394
425
|
button8.setName("appletFunction");
|
|
395
426
|
button8.setId("tab");
|
|
396
|
-
|
|
427
|
+
|
|
397
428
|
WidgetButton button9 = new WidgetButton();
|
|
398
429
|
button9.setLabel("Form Edit Tab");
|
|
399
430
|
button9.setType(ACTION_TYPE.INVOKE_FUNCTION);
|
|
400
431
|
button9.setName("appletFunction");
|
|
401
432
|
button9.setId("formtab");
|
|
402
|
-
|
|
433
|
+
|
|
403
434
|
buttonsList2.add(button5);
|
|
404
435
|
buttonsList2.add(button6);
|
|
405
436
|
buttonsList2.add(button7);
|
|
406
437
|
buttonsList2.add(button8);
|
|
407
438
|
buttonsList2.add(button9);
|
|
408
|
-
|
|
439
|
+
|
|
409
440
|
buttonElement2.setButtons(buttonsList2);
|
|
410
|
-
|
|
441
|
+
|
|
411
442
|
buttonSection.addElement(title);
|
|
412
443
|
buttonSection.addElement(buttonElement1);
|
|
413
444
|
buttonSection.addElement(buttonElement2);
|
|
414
445
|
buttonSection.setId("101");
|
|
415
|
-
|
|
446
|
+
|
|
416
447
|
return buttonSection;
|
|
417
448
|
}
|
|
418
449
|
}
|
|
@@ -5,18 +5,15 @@ import com.zc.cliq.enums.STATUS;
|
|
|
5
5
|
import com.zc.cliq.objects.InstallationResponse;
|
|
6
6
|
import com.zc.cliq.requests.InstallationRequest;
|
|
7
7
|
|
|
8
|
-
public class InstallationHandler implements com.zc.cliq.interfaces.InstallationHandler
|
|
9
|
-
{
|
|
8
|
+
public class InstallationHandler implements com.zc.cliq.interfaces.InstallationHandler {
|
|
10
9
|
@Override
|
|
11
|
-
public InstallationResponse handleInstallation(InstallationRequest req) throws Exception
|
|
12
|
-
{
|
|
10
|
+
public InstallationResponse handleInstallation(InstallationRequest req) throws Exception {
|
|
13
11
|
InstallationResponse resp = InstallationResponse.getInstance();
|
|
14
12
|
/*
|
|
15
|
-
|
|
16
|
-
* {
|
|
13
|
+
* // Logic for installation post handling {
|
|
17
14
|
*
|
|
18
15
|
* }
|
|
19
|
-
|
|
16
|
+
*/
|
|
20
17
|
resp.setStatus(STATUS.SUCCESS);
|
|
21
18
|
return resp;
|
|
22
19
|
}
|
|
@@ -6,18 +6,15 @@ import com.zc.cliq.enums.STATUS;
|
|
|
6
6
|
import com.zc.cliq.objects.InstallationResponse;
|
|
7
7
|
import com.zc.cliq.requests.InstallationRequest;
|
|
8
8
|
|
|
9
|
-
public class InstallationValidator implements com.zc.cliq.interfaces.InstallationValidator
|
|
10
|
-
{
|
|
9
|
+
public class InstallationValidator implements com.zc.cliq.interfaces.InstallationValidator {
|
|
11
10
|
@Override
|
|
12
|
-
public InstallationResponse validateInstallation(InstallationRequest req) throws Exception
|
|
13
|
-
{
|
|
11
|
+
public InstallationResponse validateInstallation(InstallationRequest req) throws Exception {
|
|
14
12
|
InstallationResponse resp = InstallationResponse.getInstance();
|
|
15
|
-
if(req.getUser().getFirstName().equals("**INVALID_USER**") && req.getAppInfo().getType().equals(EXTENSION_TYPE.UPGRADE)){
|
|
13
|
+
if (req.getUser().getFirstName().equals("**INVALID_USER**") && req.getAppInfo().getType().equals(EXTENSION_TYPE.UPGRADE)) {
|
|
16
14
|
resp.setStatus(STATUS.FAILURE);
|
|
17
15
|
resp.setTitle("Update not allowed !");
|
|
18
16
|
resp.setMessage("Sorry. Update not allowed for the current app. Please contact admin.");
|
|
19
|
-
}
|
|
20
|
-
else{
|
|
17
|
+
} else {
|
|
21
18
|
resp.setStatus(STATUS.SUCCESS);
|
|
22
19
|
}
|
|
23
20
|
return resp;
|
|
@@ -3,24 +3,22 @@ package com.handlers;
|
|
|
3
3
|
|
|
4
4
|
import java.util.Map;
|
|
5
5
|
|
|
6
|
-
import com.zc.cliq.enums.
|
|
7
|
-
import com.zc.cliq.objects.
|
|
6
|
+
import com.zc.cliq.enums.RESPONSE_TYPE;
|
|
7
|
+
import com.zc.cliq.objects.Message;
|
|
8
8
|
import com.zc.cliq.requests.MessageActionHandlerRequest;
|
|
9
9
|
import com.zc.cliq.util.ZCCliqUtil;
|
|
10
10
|
|
|
11
|
-
public class MessageActionHandler implements com.zc.cliq.interfaces.MessageActionHandler
|
|
12
|
-
{
|
|
11
|
+
public class MessageActionHandler implements com.zc.cliq.interfaces.MessageActionHandler {
|
|
13
12
|
@Override
|
|
14
|
-
public Map<String,Object> executionHandler(MessageActionHandlerRequest req) throws Exception {
|
|
15
|
-
|
|
13
|
+
public Map<String, Object> executionHandler(MessageActionHandlerRequest req) throws Exception {
|
|
14
|
+
RESPONSE_TYPE msgType = req.getMessage().getType();
|
|
16
15
|
String firstName = req.getUser() != null ? req.getUser().getFirstName() : "user";
|
|
17
|
-
|
|
18
|
-
String text = "Hey " + firstName + ", You have performed an action on a *" + msgType.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
MessageBuilder resp = MessageBuilder.getInstance();
|
|
16
|
+
|
|
17
|
+
String text = "Hey " + firstName + ", You have performed an action on a *" + msgType.getKey() + "*. Manipulate the message variable and perform your own action.";
|
|
18
|
+
|
|
19
|
+
Message resp = Message.getInstance();
|
|
22
20
|
resp.setText(text);
|
|
23
|
-
|
|
21
|
+
|
|
24
22
|
return ZCCliqUtil.toMap(resp);
|
|
25
23
|
}
|
|
26
24
|
|