Trying to display value of selected checkbox in griffon - griffon

in my griffon app, I can choose the check boxes, but my JOptionPane window shows blanks for the values when I hit submit. Any ideas as to what I may be doing wrong?
Here is my model code:
==================================================================================
package test1
import groovy.beans.Bindable
class Test1Model {
#Bindable String deviceType
List deviceTypes = [
[title: 'No Devices', selected: true, devices: []],
[title: 'Android Tablets', selected: false,
devices: [
[name: 'Asus Transformer Prime #1', selected: false],
[name: 'Asus Transformer Prime #2', selected: false],
[name: 'Motorola Xoom #1', selected: false],
[name: 'Motorola Xoom #2', selected: false],
[name: 'Sony S Tablet #1', selected: false],
[name: 'Sony S Tablet #2', selected: false]
]
],
[title: 'Android Phones', selected: false,
devices: [
[name: 'Nexus 7 #1', selected: false],
[name: 'Nexus 7 #2', selected: false],
[name: 'HTC Droid Eris', selected: false],
[name: 'HTC EVO 4G LTE', selected: false],
[name: 'Samsung Galaxy Nexus #1', selected: false],
[name: 'Samsung Galaxy Nexus #2', selected: false],
[name: 'Droid Razr Maxx #1', selected: false],
[name: 'Droid Razr Maxx #2', selected: false],
[name: 'Samsung Galaxy S2', selected: false]
]
],
[title: 'iOS Devices', selected: false,
devices: [
[name: 'iPad Gen1', selected: false],
[name: 'iPad Gen2', selected: false],
[name: 'iPad Gen3', selected: false],
[name: 'iPod Touch', selected: false]
]
]
]
}
=========================================================================================
and here is my controller code:
package test1
import griffon.transform.Threading
import griffon.util.GriffonNameUtils as GNU
class Test1Controller {
def model
def clear = {
model.griffonClass.propertyNames.each { name ->
model[name] = ''
}
}
#Threading(Threading.Policy.SKIP)
def submit = {
javax.swing.JOptionPane.showMessageDialog(
null, "You have selected: " + model.deviceTypes.devices.grep.{it.selected}
)
println model.deviceTypes.devices.grep.{it.selected = true}
}
}
Thanks!!
ironmantis7x!!

The answer lies in the GPath expression. This one does what you need
model.deviceTypes.devices.flatten().grep{ it.selected }
or even
model.deviceTypes.devices.flatten().grep{ it.selected == true }

Related

I want to filter the columns with condition '>0' and den find minimum value along filtered columns and sort them and get index of column using numpy

I am looking for this solution using Numpy, So anyone wish to do this operation/steps with minimal code it would help me a lot.
Step 1. This is the given array arr_a=
[[0, 1.2, -0.3, 8, 3, -4],
[1.3, -0.9, 3.2, -7.2, -4.2, 5.1],
[-2.1, 3.2, -3, -0.4, 4.3, 98],
[6.1, 3.1, 4, -0.43, 2, -21],
[3.4, -9.8, 3, 4.2, -2.5, 33],
[-2.1, 4, -9, 45, 3.2, -0.30],
[3, -4.5, -5.0, -8, 5.6, -0.3]]
Step 2:
I want to filter each column of array 'arr_a' with an expression '>0' it should return an array as below.
[[False, True, False, True, True, False],
[True, False, True, False, False, True],
[False, True, False, False, True, True],
[True, True, True, False, True, False],
[True, False, True, True, False, True],
[False, True, False, True, True, False],
[True, False, False, False, True, False]]
Step 3:
From the above filtered array find the minimum number along the column skipping the values's which are 'False'
vector_min =
[1.3, 1.2, 3, 4.2, 2, 5.1]
Step 4:
sort them in descending order
f_ordered =
[5.1, 4.2, 3, 2, 1.3, 1.2]
Step 5:
Get the indices of the columns after ordering.
index of column =
[5, 3, 2, 4, 0, 1]
You can use:
# step2
m = arr_a>0
# array([[False, True, False, True, True, False],
# [ True, False, True, False, False, True],
# [False, True, False, False, True, True],
# [ True, True, True, False, True, False],
# [ True, False, True, True, False, True],
# [False, True, False, True, True, False],
# [ True, False, False, False, True, False]])
# step 3
vector_min = np.nanmin(np.where(m, arr_a, np.nan), axis=0)
# array([1.3, 1.2, 3. , 4.2, 2. , 5.1])
# step 5
index_of_column = np.argsort(-vector_min)
# array([5, 3, 2, 4, 0, 1])
# step 4
f_ordered = vector_min[index_of_column]
# array([5.1, 4.2, 3. , 2. , 1.3, 1.2])

Is there a chance to get a printer paper and ink status in NodeJS on Windows?

I try to use Node.JS with the plugin node-printer (on Windows) to find out the status, if the paper or the ink is empty. Is that possible somehow? Because node-printer only gives me informations about jobs and says "PRINTING RETAINED" but not the real problem, that shows off in the printer screen. Like "Paper empty" or "Ink empty".
const printer = require("printer")
console.log(printer.getPrinter("CANON SELPHY CP1300"))
Output:
/*
{ name: 'Canon SELPHY CP1300',
portName: 'USB001',
driverName: 'Canon SELPHY CP1300',
printProcessor: 'winprint',
datatype: 'RAW',
status: [],
statusNumber: 0,
attributes: [ 'DO-COMPLETE-FIRST', 'LOCAL' ],
priority: 1,
defaultPriority: 0,
averagePPM: 0,
jobs: [ { id: 7,
name: 'Canon SELPHY CP1300',
printerName: 'Canon SELPHY CP1300',
user: 'Leon',
format: 'NT EMF 1.008',
priority: 1,
size: 3161316,
status: [ 'PRINTING', 'RETAINED' ],
machineName: '\\\\DESKTOP-DUMDTFI',
document: 'Testseite',
notifyName: 'Leon',
printProcessor: 'winprint',
driverName: 'Canon SELPHY CP1300',
position: 1,
startTime: 0,
untilTime: 0,
totalPages: 1,
time: 97482546,
pagesPrinted: 0 } ] }
*/

Google Assistant / Dialogflow: Cannot receive location thru mobile connection, but works on wifi

I am currently using the Google Places API. What I want to do is to receive the user's device lat / long coordinates and find nearby places of a certain type.
Somehow, this works with a wifi connection ie. I get back my list of nearby places and can display them on cards.
But when I disabled wifi and am connected to my 4G connection, I get the "[app name] isn't responding at the moment. Try again soon." message.
I checked my firebase function logs and I got back a response status of 200 with valid data, but at an incorrect location. Even so, shouldn't it display the data even at the wrong location?
Any idea on why this is happening? Google Maps location works fine for me ie. I can get my current location thru clicking on the appropriate button on Google Maps. I've also enabled Mobile Data for Google Maps and Assistant.
EDIT: I dug deeper into my logs.
So turns out that on Google Cloud Platform, I found out that I'm getting a malformed response because of only one item in a Carousel.
MalformedResponse at
expected_inputs[0].input_prompt.rich_initial_prompt.items[1].carousel_browse:
'carousel_browse' requires at least 2 items.
BUT this still doesn't solve the issue of wrong coordinates from the location itself.
This is what I got through a 4G connection (Firebase function logs):
listPolicePost [ { geometry: { location: [Object], viewport: [Object]
},
icon: 'https://maps.gstatic.com/mapfiles/place_api/icons/police-71.png',
id: '0e7b9a2a292b190e98e46bbdcb2c81ad6eb48f5e',
name: 'Serangoon Garden Neighbourhood Police Post',
photos: [ [Object] ],
place_id: 'ChIJFzNrGAAX2jER2PowrtSXY_A',
plus_code:
{ compound_code: '9V78+9G Singapore',
global_code: '6PH59V78+9G' },
rating: 3.5,
reference: 'CmRSAAAA-vgZQmvol1ZcY4srSlQGLRLIErqMGaZPJvgyySiigXxG_O9ysjoAZOjBwIxH99q6fAMnml69NOuogaYzpc84yYgGf6BaNJ7c0QhI4gwqxUUpeYPe9pW4EundAFi4IbTKEhAhCFSAhJeHTmmurQzf55eEGhTYyD6BAiFSZ35QMftDtdehqVhF0Q',
scope: 'GOOGLE',
types: [ 'police', 'point_of_interest', 'establishment' ],
vicinity: '51 Serangoon Garden Way, Singapore' }, { geometry: { location: [Object], viewport: [Object] },
icon: 'https://maps.gstatic.com/mapfiles/place_api/icons/police-71.png',
id: '122baf85e424de14925665be49f5984cf367d61b',
name: 'Serangoon Neighbourhood Police Centre',
photos: [ [Object] ],
place_id: 'ChIJo_ADBqcX2jERaelpKPuk7_0',
plus_code:
{ compound_code: '9V2C+R5 Singapore',
global_code: '6PH59V2C+R5' },
rating: 4.6,
reference: 'CmRSAAAAt4STs5V8zT4-xRBKNU5EAqtLvHE1_CZr_Bk0WbNZqFdQztPT8HSeoRcw-Yksvz8TdiqzfQQGYXnAAqSJxNT6B9nAxhh0XlqkVLJh3Au0hCN8VrBhoSPujE8SBMfhjWPCEhCAgTBiiW9CWycfc9KneqEdGhT9BRJiiWfyx2KzqAJUyjAN3Snhpg',
scope: 'GOOGLE',
types: [ 'police', 'point_of_interest', 'establishment' ],
vicinity: '50 Serangoon Avenue 2, #01-02' } ]
Results with WIFI at the same location:
listPolicePost [ { geometry: { location: [Object], viewport: [Object]
},
icon: 'https://maps.gstatic.com/mapfiles/place_api/icons/police-71.png',
id: '95c157891f885550b39dc74767a1ebc6fc426fa2',
name: 'Alexandra Neighbourhood Police Post',
photos: [ [Object] ],
place_id: 'ChIJ42CR00Aa2jERvHTJPpayEZQ',
plus_code:
{ compound_code: '8Q2X+46 Singapore',
global_code: '6PH58Q2X+46' },
rating: 5,
reference: 'CmRSAAAA6BBPfMynSJdnUhiFv3hGRmJxzSp4P6DGZ9_zAWX36EQEUXpxgmNgQNv1RYcH4B3d3Yxic5CaQK3Ec7UeY3dQW4Us92P8Y29yArsYfRuULrTOjdI4-GquWMzwB2wf6UubEhCHHitSm1_8jKBYWgPoU0vyGhRZUWXrfi9ShbA-dryqFABVCCwsmw',
scope: 'GOOGLE',
types: [ 'police', 'point_of_interest', 'establishment' ],
vicinity: 'Blk 46 Tanglin Halt Rd, #01-328' }, { geometry: { location: [Object], viewport: [Object] },
icon: 'https://maps.gstatic.com/mapfiles/place_api/icons/police-71.png',
id: '8bdb0e2f344ec77efcc198ed410f0a06bc04fbbb',
name: 'Commonwealth Neighbourhood Police Post',
place_id: 'ChIJ39iOiz8a2jER6Wv2o-9yeGs',
plus_code:
{ compound_code: '8Q4X+HF Singapore',
global_code: '6PH58Q4X+HF' },
rating: 5,
reference: 'CmRRAAAAprrqfgGSHVqj2xKP-TgSAagHxEIsWcak0WLiD_hqotMH-_lwWJg0HhlpW0MnxKZ5_yD3UWNkBT_0CjePxvt5Glu8PIC58AdmfDAmQ1fmPYxC64Au1WhwNuskwnS1a2M4EhCiJ7JzCXBGezyKo8HzhMwzGhRmp_Df8vfjWU_vasmr-QtXmWEi3Q',
scope: 'GOOGLE',
types: [ 'police', 'point_of_interest', 'establishment' ],
vicinity: '111 Commonwealth Crescent, Singapore' }, { geometry: { location: [Object], viewport: [Object] },
icon: 'https://maps.gstatic.com/mapfiles/place_api/icons/police-71.png',
id: '34e78e46388c52c814cc5c0858b5f6ad3221511c',
name: 'Buona Vista Police Post',
photos: [ [Object] ],
place_id: 'ChIJzeD5Imoa2jERih3LNGr2MSM',
plus_code:
{ compound_code: '8Q5V+P7 Singapore',
global_code: '6PH58Q5V+P7' },
rating: 2.8,
reference: 'CmRRAAAAqDe2CLznGR81_LoV_7OnWIOne7g-zrP4h1U6ELKlc1zhVBMG15AmyxXJWJlZdys7ILMVUSj6Mv5_gDBsII72NMLHZ97gELkaUbrnKEBu0_o72VXwyJRLvuzcjCK8MqKyEhC6GmBSJYtpY4mSyNUeNk6WGhTwCRXaS5B5Xwx5zyrDE9xapnlRIg',
scope: 'GOOGLE',
types: [ 'police', 'point_of_interest', 'establishment' ],
vicinity: 'block 13 Holland Dr #01-38/40' }, { geometry: { location: [Object], viewport: [Object] },
icon: 'https://maps.gstatic.com/mapfiles/place_api/icons/police-71.png',
id: '434ce574c05e43e70c33b6ba64d7f21c840b132f',
name: 'Dover Neighbourhood Police Post',
place_id: 'ChIJ73qudVwa2jERlggLteLz6nU',
plus_code:
{ compound_code: '8Q3J+GV Singapore',
global_code: '6PH58Q3J+GV' },
rating: 5,
reference: 'CmRRAAAAdXD9jiCrSsH6oBqvxFviOGDBq_KOj08XfSR8mLSgTZhk8FCbt4UVqUUiWnvoLJv5jw5nytcTfellRW8Js_cRvQca_ToDtVbp6nQqaiq9RR408qaJm-9WOJuBZXTui9TQEhCyyQlxS4MRYvjh9dTD0qTmGhS95n1YPfpmR0BDcdYuWFQ6lYKG0A',
scope: 'GOOGLE',
types: [ 'police', 'point_of_interest', 'establishment' ],
vicinity: 'Block 3, Dover Road, #01-368, 130003' }, { geometry: { location: [Object], viewport: [Object] },
icon: 'https://maps.gstatic.com/mapfiles/place_api/icons/police-71.png',
id: 'b2b998513d890ac0061b4b75380f26a3b7c4c81e',
name: 'Special Operations Command',
photos: [ [Object] ],
place_id: 'ChIJH2LnQ8sb2jERA-RABTXay8c',
plus_code:
{ compound_code: '7RW2+76 Singapore',
global_code: '6PH57RW2+76' },
rating: 5,
reference: 'CmRSAAAA8n7968a6h62bOQchkLcjdLGNlcCih7H3pQ1UmojLIXJOOD_RI8v5t3pZJlL0tZtTRBLpnIpgpXtEGu-48dPoELTPRu2Q_aHriAV4l2_YBf-tLR0RSNEQzOivTA7fPPxAEhDXhPRQs18Vfe-Ord4z-i0MGhS3eoucLyTZ504RQROrKrx18OEmGQ',
scope: 'GOOGLE',
types: [ 'police', 'point_of_interest', 'establishment' ],
vicinity: 'Queensway, Singapore' } ]

Extjs child item not filling the parent container

My problem is, even if I used "layout: 'fit'" in all my children items within a boarder layout, they just shrinks into a small box rather than fill the parent, as described in fit layout.
I want the EDS.view.selector.Container to fill the "navigation" section of my boarder layout.
(Code excerpt)
Ext.define('EDS.view.selector.Container', {
extend: 'Ext.panel.Panel',
alias : 'widget.selectorcontainer',
layout: 'fit',
initComponent: function(){
this.items = [
{
xtype: 'tabpanel',
defaults: {
bodyPadding: 10
},
layout: 'fit',
items:[
{
title: 'Organization',
id: 'selector-organization',
tag: 'div',
html: 'div here',
height: '100%',
}
]
}
],
this.callParent();
},
});
(Controller)
init: function(){
console.log('controller.init()');
new Ext.Viewport({
title: 'Data Analysis',
layout: 'border',
defaults: {
collapsible: true,
split: true,
bodyStyle: 'padding: 15px',
},
items: [{
title: 'Navigation',
region:'west',
margins: '5 0 0 0',
cmargins: '5 5 0 0',
width: 600,
minSize: 100,
maxSize: 250,
items: [
{
id: 'selector-container',
xtype: 'selectorcontainer',
layout: 'fit',
}
]
},{
title: 'Main Content',
collapsible: false,
region:'center',
margins: '5 0 0 0'
}]
});
}
You did not set up layout for wrapper containers in your border layout:
items: [{
title: 'Navigation',
region:'west',
layout: 'fit',
...
items: [
]
},{
title: 'Main Content',
collapsible: false,
region:'center',
layout: 'fit',
...
}]
Remember: In ExtJS any plain JS object that goes into items property of a container will be converted into some type of Ext component with xtype defined by defaultType property of that container. In most cases it will be panel.

layoutConfig dosn't work in accordion layout in extjs 4

I want to use viewport and use accordion layout for my menu items.
but I want my accordion layout not fill and use all spaces for each item
I use layoutConfig like examples but it dosn't work and the accordion fill all spaces and stretch vertically :
this.view = new Ext.Viewport({
layout: 'border',
renderTo : document.body,
items: [{
xtype: 'box',
region: 'north',
height: 60,
contentEl: 'framework_north'
},{
region: 'east',
title: 'امکانات سیستم',
split: true,
collapsible: true,
width: 200,
minSize: 200,
maxSize: 200,
layout:'accordion',
layoutConfig: {
fill : false,
collapseFirst : true,
hideCollapseTool : true
},
tbar : [
{
contentEl : "framework_clock",
autoWidth : true,
xtype: 'box',
height : 80
}],
items: this.menuItems
},
this.centerPanel]
});
what is my fault :'(
wrap your accordion in a vbox container and set the height to whatever you want.

Resources