Skip to content

Commit b9779c1

Browse files
authored
Merge pull request #19 from IBMStreams/develop
November release
2 parents 0f65419 + b436cd2 commit b9779c1

File tree

8 files changed

+504
-174
lines changed

8 files changed

+504
-174
lines changed

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,16 @@ This is the initial public release. For best results you should also install th
1010
* ide-ibmstreams
1111

1212
### Setup Instructions
13-
#### Build
14-
You need to capture your VCAP credentials for IBM Streaming Analytics service in order to build.
13+
#### Build - Streaming Analytics Credentials
14+
The <b>build-ibmstreams</b> package requires a running IBM Streaming Analytics service. SPL applications will be built and deployed on this service. If you need to create one, start <a href="https://console.bluemix.net/catalog/services/streaming-analytics" rel="noopener" target="_blank">here</a> and follow the instructions to create an account.
15+
16+
<b>Note:</b>The service needs to support V2 of the rest api.
17+
18+
Once you have an account go to your <a href="https://console.bluemix.net/dashboard/apps" rel="noopener" target="_blank">dashboard</a> and select the Streaming Analytic service you want to use. You need to make sure it is running and then copy your credentials to the clipboard. To get your credentials select <b>Service Credentials</b> from the actions on the left. From the credentials page, press <b>View credentials</b> for the one you want to use and press the copy button in the upper right side of the credentials to copy them to the clipboard.
19+
20+
In Atom there is a setting in the <b>build-ibmstreams</b> package for the credentials. Go to <b>Atom->Preferences->Packages</b> and press the <b>Settings</b> button on the <b>build-ibmstreams</b> package and paste your credentials into the setting.
21+
![](./images/atomcredssetting.png)
22+
23+
24+
### SPL Application build
25+
![](./images/build.gif)
39.3 KB
Loading

images/atomcredssetting.png

71.5 KB
Loading

images/build.gif

1.26 MB
Loading

lib/MessageHandler.js

Lines changed: 63 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
"use strict";
44
"use babel";
55

6+
import path from "path";
7+
8+
const packageRoot = atom.packages.resolvePackagePath("build-ibmstreams");
9+
const STREAMING_ANALYTICS_ICON_PATH = `${packageRoot}${path.sep}assets${path.sep}streaming_analytics_200x200.png`;
10+
611
export class MessageHandler {
712
consoleService: null;
813

@@ -25,28 +30,15 @@ export class MessageHandler {
2530
atom.notifications.addInfo(messageOutput, {});
2631
}
2732
}
28-
// if (input && input.output) {
29-
// const messageText = input.output
30-
// .map(outputMsg => outputMsg.message_text)
31-
// .join("\n");
32-
// if (input.status === "building" || input.status === "waiting") {
33-
// atom.notifications.addInfo(input.status+"...", {detail: messageText});
34-
// }
35-
// } else if (typeof(input) === "string") {
36-
// this.consoleService.log(input);
37-
// if (showNotification) {
38-
// atom.notifications.addInfo(input, {});
39-
// }
40-
// }
4133
}
4234

4335
handleBuildSuccess(messageOutput: Array<any>) {
4436
const message = this.getLoggableMessage(messageOutput);
4537
if (message) {
46-
this.consoleService.log(message);
38+
this.consoleService.success(message);
4739
atom.notifications.addSuccess("Build succeeded", {detail: message, dismissable: true});
4840
} else {
49-
this.consoleService.log("Build succeeded");
41+
this.consoleService.success("Build succeeded");
5042
atom.notifications.addSuccess("Build succeeded", {dismissable: true});
5143
}
5244
}
@@ -63,14 +55,21 @@ export class MessageHandler {
6355
}
6456

6557
handleSubmitProgressMessage(input) {
66-
58+
if (typeof(input) === "string") {
59+
atom.notifications.addInfo(input, {});
60+
}
61+
this.consoleService.log(input);
6762
}
6863

69-
handleSubmitSuccess(input) {
70-
atom.notifications.addSuccess(`Job ${input.name} is ${input.health}`, {dismissable: true});
64+
handleSubmitSuccess(input, notificationButtons = []) {
65+
let addedButtons = {};
66+
if (Array.isArray(notificationButtons)) {
67+
addedButtons.buttons = notificationButtons.map(obj => ({onDidClick: obj.callbackFn, text: obj.label}));
68+
}
69+
atom.notifications.addSuccess(`Job ${input.name} is ${input.health}`, {...addedButtons, dismissable: true});
7170

7271
if (this.consoleService) {
73-
this.consoleService.log(`Job ${input.name} is ${input.health}`);
72+
this.consoleService.success(`Job ${input.name} is ${input.health}`);
7473
}
7574
}
7675

@@ -82,20 +81,30 @@ export class MessageHandler {
8281
this.consoleService.error(`Job submission failed\n${errorString}`);
8382
}
8483
}
85-
handleError(input) {
84+
handleError(input, notificationButtons = []) {
85+
let addedButtons = {};
86+
if (Array.isArray(notificationButtons)) {
87+
addedButtons.buttons = notificationButtons.map(obj => ({onDidClick: obj.callbackFn, text: obj.label}));
88+
}
8689
if (typeof(input) === "string") {
87-
atom.notifications.addError(input, {dismissable: true});
90+
atom.notifications.addError(input, {...addedButtons, dismissable: true});
91+
this.consoleService.error(input);
8892
} else if (input.message) {
8993
atom.notifications.addError(
9094
input.message,
91-
{detail: input.stack, stack: input.stack}
95+
{...addedButtons, dismissable: true, detail: input.stack, stack: input.stack}
9296
);
97+
this.consoleService.error(input.message);
9398
}
9499
console.error(input);
95100
}
96-
handleSuccess(input, detail, showNotification, showConsoleMsg) {
101+
handleSuccess(input, detail, showNotification, showConsoleMsg, notificationButtons = []) {
102+
let addedButtons = {};
103+
if (Array.isArray(notificationButtons)) {
104+
addedButtons.buttons = notificationButtons.map(obj => ({onDidClick: obj.callbackFn, text: obj.label}));
105+
}
97106
if (showNotification) {
98-
atom.notifications.addSuccess(input, {detail: detail, dismissable: true});
107+
atom.notifications.addSuccess(input, {...addedButtons, detail: detail, dismissable: true});
99108
}
100109
if (showConsoleMsg) {
101110
if (this.consoleService) {
@@ -112,13 +121,42 @@ export class MessageHandler {
112121
}
113122

114123
showDialog(message, detail, buttonObjs) {
124+
125+
const nativeImage = require("electron").nativeImage;
126+
115127
const labels = buttonObjs.map(obj => obj.label);
116128
const callbacks = buttonObjs.map(obj => obj.callbackFn);
117129
let buttons = {};
118130
labels.forEach((label, index) => {
119131
buttons[label] = callbacks[index];
120132
});
121-
atom.confirm({message: message, detailedMessage: detail, buttons: buttons});
133+
atom.confirm(
134+
{
135+
message: message,
136+
detail: detail,
137+
buttons: labels,
138+
icon: STREAMING_ANALYTICS_ICON_PATH
139+
},
140+
(chosen, checkboxChecked) => {
141+
const callback = callbacks[chosen];
142+
if (typeof(callback) === "function") {
143+
return callback();
144+
}
145+
}
146+
);
147+
}
148+
149+
handleCredentialsMissing() {
150+
atom.notifications.addError(
151+
"Copy and paste the Streaming Analytics service credentials into the build-ibmstreams package settings page.",
152+
{
153+
dismissable: true,
154+
buttons: [{
155+
text: "Open package settings",
156+
onDidClick: () => {atom.workspace.open("atom://config/packages/build-ibmstreams")}
157+
}]
158+
}
159+
);
122160
}
123161

124162
getLoggableMessage(messages: Array<any>) {

0 commit comments

Comments
 (0)