Skip to content

Commit

Permalink
Merge pull request #19 from IBMStreams/develop
Browse files Browse the repository at this point in the history
November release
  • Loading branch information
petenicholls authored Nov 20, 2018
2 parents 0f65419 + b436cd2 commit b9779c1
Show file tree
Hide file tree
Showing 8 changed files with 504 additions and 174 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,16 @@ This is the initial public release. For best results you should also install th
* ide-ibmstreams

### Setup Instructions
#### Build
You need to capture your VCAP credentials for IBM Streaming Analytics service in order to build.
#### Build - Streaming Analytics Credentials
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.

<b>Note:</b>The service needs to support V2 of the rest api.

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.

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.
![](./images/atomcredssetting.png)


### SPL Application build
![](./images/build.gif)
Binary file added assets/streaming_analytics_200x200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/atomcredssetting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/build.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 63 additions & 25 deletions lib/MessageHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
"use strict";
"use babel";

import path from "path";

const packageRoot = atom.packages.resolvePackagePath("build-ibmstreams");
const STREAMING_ANALYTICS_ICON_PATH = `${packageRoot}${path.sep}assets${path.sep}streaming_analytics_200x200.png`;

export class MessageHandler {
consoleService: null;

Expand All @@ -25,28 +30,15 @@ export class MessageHandler {
atom.notifications.addInfo(messageOutput, {});
}
}
// if (input && input.output) {
// const messageText = input.output
// .map(outputMsg => outputMsg.message_text)
// .join("\n");
// if (input.status === "building" || input.status === "waiting") {
// atom.notifications.addInfo(input.status+"...", {detail: messageText});
// }
// } else if (typeof(input) === "string") {
// this.consoleService.log(input);
// if (showNotification) {
// atom.notifications.addInfo(input, {});
// }
// }
}

handleBuildSuccess(messageOutput: Array<any>) {
const message = this.getLoggableMessage(messageOutput);
if (message) {
this.consoleService.log(message);
this.consoleService.success(message);
atom.notifications.addSuccess("Build succeeded", {detail: message, dismissable: true});
} else {
this.consoleService.log("Build succeeded");
this.consoleService.success("Build succeeded");
atom.notifications.addSuccess("Build succeeded", {dismissable: true});
}
}
Expand All @@ -63,14 +55,21 @@ export class MessageHandler {
}

handleSubmitProgressMessage(input) {

if (typeof(input) === "string") {
atom.notifications.addInfo(input, {});
}
this.consoleService.log(input);
}

handleSubmitSuccess(input) {
atom.notifications.addSuccess(`Job ${input.name} is ${input.health}`, {dismissable: true});
handleSubmitSuccess(input, notificationButtons = []) {
let addedButtons = {};
if (Array.isArray(notificationButtons)) {
addedButtons.buttons = notificationButtons.map(obj => ({onDidClick: obj.callbackFn, text: obj.label}));
}
atom.notifications.addSuccess(`Job ${input.name} is ${input.health}`, {...addedButtons, dismissable: true});

if (this.consoleService) {
this.consoleService.log(`Job ${input.name} is ${input.health}`);
this.consoleService.success(`Job ${input.name} is ${input.health}`);
}
}

Expand All @@ -82,20 +81,30 @@ export class MessageHandler {
this.consoleService.error(`Job submission failed\n${errorString}`);
}
}
handleError(input) {
handleError(input, notificationButtons = []) {
let addedButtons = {};
if (Array.isArray(notificationButtons)) {
addedButtons.buttons = notificationButtons.map(obj => ({onDidClick: obj.callbackFn, text: obj.label}));
}
if (typeof(input) === "string") {
atom.notifications.addError(input, {dismissable: true});
atom.notifications.addError(input, {...addedButtons, dismissable: true});
this.consoleService.error(input);
} else if (input.message) {
atom.notifications.addError(
input.message,
{detail: input.stack, stack: input.stack}
{...addedButtons, dismissable: true, detail: input.stack, stack: input.stack}
);
this.consoleService.error(input.message);
}
console.error(input);
}
handleSuccess(input, detail, showNotification, showConsoleMsg) {
handleSuccess(input, detail, showNotification, showConsoleMsg, notificationButtons = []) {
let addedButtons = {};
if (Array.isArray(notificationButtons)) {
addedButtons.buttons = notificationButtons.map(obj => ({onDidClick: obj.callbackFn, text: obj.label}));
}
if (showNotification) {
atom.notifications.addSuccess(input, {detail: detail, dismissable: true});
atom.notifications.addSuccess(input, {...addedButtons, detail: detail, dismissable: true});
}
if (showConsoleMsg) {
if (this.consoleService) {
Expand All @@ -112,13 +121,42 @@ export class MessageHandler {
}

showDialog(message, detail, buttonObjs) {

const nativeImage = require("electron").nativeImage;

const labels = buttonObjs.map(obj => obj.label);
const callbacks = buttonObjs.map(obj => obj.callbackFn);
let buttons = {};
labels.forEach((label, index) => {
buttons[label] = callbacks[index];
});
atom.confirm({message: message, detailedMessage: detail, buttons: buttons});
atom.confirm(
{
message: message,
detail: detail,
buttons: labels,
icon: STREAMING_ANALYTICS_ICON_PATH
},
(chosen, checkboxChecked) => {
const callback = callbacks[chosen];
if (typeof(callback) === "function") {
return callback();
}
}
);
}

handleCredentialsMissing() {
atom.notifications.addError(
"Copy and paste the Streaming Analytics service credentials into the build-ibmstreams package settings page.",
{
dismissable: true,
buttons: [{
text: "Open package settings",
onDidClick: () => {atom.workspace.open("atom://config/packages/build-ibmstreams")}
}]
}
);
}

getLoggableMessage(messages: Array<any>) {
Expand Down
Loading

0 comments on commit b9779c1

Please sign in to comment.