Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wishlist: status control #116

Open
jpmens opened this issue Jun 27, 2013 · 17 comments
Open

Wishlist: status control #116

jpmens opened this issue Jun 27, 2013 · 17 comments

Comments

@jpmens
Copy link

jpmens commented Jun 27, 2013

Maybe a nice enhancement? A control that can take one of four values (0, 1, 2, 3) to display a Nagios/Icinga status as in

0 = green = OK
1 = yellow = WARNING
2 = red = CRITICAL
3 = grey? = UNKNOWN

Mock screen shot:

jmbp-639

@binarybucks
Copy link
Owner

How would it look on android?

Mit freundlichen Grüßen / With kind regards
Alexander Rust
On 27 Jun 2013 17:53, "JP Mens" [email protected] wrote:

Maybe a nice enhancement? A control that can take one of four values (0,
1, 2, 3) to display a Nagios/Icinga status as in

0 = green = OK
1 = yellow = WARNING
2 = red = CRITICAL
3 = grey? = UNKNOWN

Mock screen shot:

[image: jmbp-639]https://f.cloud.github.com/assets/60706/716976/8cc88b56-df41-11e2-82cf-200c836bece7.jpg


Reply to this email directly or view it on GitHubhttps://github.com//issues/116
.

@jpmens
Copy link
Author

jpmens commented Jun 27, 2013

I can't judge that, because I don't know what UI capabilities there are there...
Maybe a LED or something similar?
Maybe possible with the "card" interface?

@binarybucks
Copy link
Owner

We just had a little chat about it during breakfast. Generally that functionality is quite specific and probably not very useful for a majority of users. But as HomA aims to be extensible it would be good if there was a more generic feature that allows such functionality to be implemented.

One suggestion we came up with was to add a /meta/style tag to the text control.
As the current content of the text control is currently not escaped, you could add some nasty styles inline directly but that of course looks awful in the Android App as it doesn't know anything about html or css. With a new meta tag that is (for now) ignored by the Android app interfaces that do not implement the tag would display a plain old text control with 0,1,2 or 3 as value. However, with some custom CSS applied from the /meta/style tag those values could be interpreted somehow to fit your needs.

One problem now is how the CSS would interpret the value to apply different styles. I guess there is some CSS3 magic to achieve this.

Would that be a viable alternative?

@jpmens
Copy link
Author

jpmens commented Jun 28, 2013

While it pleases me you're considering this, the CSS thing sounds pretty messy to me, particularly since it won't, as you say, work on Android (or on iOS later, I assume).

Supposing your proposed "card" interface is implemented on Android, I'm assuming it would have the approximate appearance of the current Web interface? Are there other 'controls' possible then? If you can point me to some description of Android's GUI possibilities, I'll gladly look to see if I find something suitable, also in view of a possible future iOS implementation.

@binarybucks
Copy link
Owner

Theres an overview of intput controls at http://developer.android.com/guide/topics/ui/controls.html and general building blocks at http://developer.android.com/design/building-blocks/index.html.

The thing is, that I would happily implement controls that are generally useful but at the moment I think it would probably result in a feature creep when we'd start to add custom controls for edgy usecases that might also be satisfied with standard controls. Besides that, I agree with the CSS solution being pretty messy.

@stylpen
Copy link
Collaborator

stylpen commented Jun 28, 2013

The "right" way to introduce this kind of extension is to add a new control type (/meta/type = nagios for example). This means that all interfaces need to be aware of that and handle the new control type in the appropriate way.

In contrast to that, adding just a new meta attribute will not break interfaces (like the Android app) that are not aware of it. This requires the least effort to "hack" that functionality into the web interface. A little less messy may be not to add a /meta/style attribute to the control but something like /meta/class or /meta/CSSclass. The web interface could then add that class to the DOM element. This would be a generic way to let users influence the look of the web interface but requires changes to the css file of the interface. There could also be something like a user.css file where those additional styles can be placed in and which gets included in the main style sheet.
Of course, that approach can only add styling functionalities to the web interface but at least is doesn't require changes to the Android app or anything else.

@binarybucks
Copy link
Owner

@stylpen 's approach is certainly cleaner whereas the /meta/style approach would not require the use of an additional css file as everything would be stored in the MQTT tree, of course. As of now, I've not found a viable golden solution for this :/

@jpmens
Copy link
Author

jpmens commented Jun 28, 2013

I'm just trying to shoehorn everything into homA and MQTT, that's all. ;)

@binarybucks
Copy link
Owner

Yes and that's awesome. The above was not meant to be criticism not to use homA for that, only the attempt to find an optimal solution how to fit everything into homA ;)

At the moment we're writing our bachelor thesis so bigger features might have to wait a bit. However that shouldn't stop us from discussing ideas. Just the implementation might take a little longer.

@jpmens
Copy link
Author

jpmens commented Jul 2, 2013

Thanks guys. I've glanced at the possible Android controls, and can't think of something generic enough.

@jpmens jpmens closed this as completed Jul 2, 2013
@binarybucks binarybucks reopened this Jul 2, 2013
@binarybucks
Copy link
Owner

Just came to my mind. What about a generic "image" control that can display e.g. base64 encoded images? That one could be used for more elaborate usecases like displaying rudimentary charts, webcam images or little status color tiles.

Definately possible with the webinterface, probably somehow also in Android.

@jpmens
Copy link
Author

jpmens commented Jul 2, 2013

Sounds like just what the doctor ordered. I didn't dare suggest that, even though the thought crossed my mind.

On Jul 2, 2013, at 17:20, Alexander Rust [email protected] wrote:

Just came to my mind. What about a generic "image" control that can display e.g. base64 encoded images? That one could be used for more elaborate usecases like displaying rudimentary charts, webcam images or little status color tiles.

Definately possible with the webinterface, probably somehow also in Android.


Reply to this email directly or view it on GitHub.

@binarybucks
Copy link
Owner

Mh, so the implementation for the webinterface turned out to be pretty trivial. However, while playing with it I noticed that Paho returns an unknown error for longer message payloads (such as a base64 encoded image), so that I was just able to get it working with a standard url source.

@jpmens could you try to reproduce that Paho fails with longer message payloads so I can file a bug for this? Just publish some value for a text control that is a bit longer (as I was on the plane I had somewhat limited debugging capabilities, but I guess the limit is some power of two > 128 byte)

@jpmens
Copy link
Author

jpmens commented Jul 9, 2013

@binarybucks The text control breaks here at a length > 89

payload = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam a porttitor nisl. Nam vel'

homa.mqttHelper.publish("/devices/"+ systemId + "/controls/Status", payload , true);

If I add a single char to payload, the Web interface 'dies'. It periodically tries to reconnect and fails.

@stylpen
Copy link
Collaborator

stylpen commented Jul 9, 2013

I fixed it. It was a websocket server issue. There are new x86 Linux binaries (version 0.5). Raspberry Pi and OSX versions will be compiled soon.

@jpmens
Copy link
Author

jpmens commented Jul 11, 2013

Pulled new WSS_osx a moment ago, and confirm I can send a text payload > 89. Thanks.

@binarybucks
Copy link
Owner

Android side should be fairly easy to implement according to the research I did while my kernle is compiling:

for non-data urls the http image can be acquired via

new DownloadImageTask((ImageView) findViewById(R.id.imageView1))
            .execute("http://java.sogeti.nl/JavaBlog/wp-content/uploads/2009/04/android_icon_256.png");
}

public void onClick(View v) {
    startActivity(new Intent(this, IndexActivity.class));
    finish();

}

private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
    ImageView bmImage;

    public DownloadImageTask(ImageView bmImage) {
        this.bmImage = bmImage;
    }

    protected Bitmap doInBackground(String... urls) {
        String urldisplay = urls[0];
        Bitmap mIcon11 = null;
        try {
            InputStream in = new java.net.URL(urldisplay).openStream();
            mIcon11 = BitmapFactory.decodeStream(in);
        } catch (Exception e) {
            Log.e("Error", e.getMessage());
            e.printStackTrace();
        }
        return mIcon11;
    }

    protected void onPostExecute(Bitmap result) {
        bmImage.setImageBitmap(result);
    }
}

for base64 encoded data uris this should do

byte[] decodedString = Base64.decode(encodedImage, Base64.DEFAULT);
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length); 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants