Elastic search combine aggregations - asp.net

Currently query below removes duplicates on a single field - "name", but we need top_hits results for all fields:"name", "venueName", "venueTown". Is this possible to achieve within one query without sending 3 requests and setting "field" to be "venueName" and "venueTown"?
{
"aggs": {
"query": {
"terms": {
"field": "name"
}
,
"aggs": {
"top": {
"top_hits": {
"size": 1
}
}
}
}
},
"size": 0,
"query": {
"multi_match": {
"query": "LAURA",
"operator": "OR",
"fields": [
"name",
"venueName",
"venueTown"
]
}
}
}

If I understand correctly, you can write multiple aggregations with top hits.
{
"query": {
"multi_match": {
"query": "LAURA",
"fields": [
"name",
"venueName",
"venueTown",
]
}
},
"aggs": {
"name": {
"terms": {
"field": "name"
},
"aggs": {
"top": {
"top_hits": {
"size": 1
}
}
}
},
"venue_name": {
"terms": {
"field": "venueName"
},
"aggs": {
"top": {
"top_hits": {
"size": 1
}
}
}
},
"venue_town": {
"terms": {
"field": "venueTown"
},
"aggs": {
"top": {
"top_hits": {
"size": 1
}
}
}
}
}
}

Related

One or more parameter values were invalid: Missing the key Sensor in the item

I am trying to put items within the table and getting this error:
This is the objects.json file I am trying to insert into the db:
{
"Sensors":{
"L": [
{ "M": {
"Sensor": { "S": "Sensor1" },
"SensorDescription": { "S": "This is a description of a Sensor"},
"ImageFile": {"S": "/Sensors/image/Sensor1.txt"},
"SampleRate": {"N": "1"},
"Locations": {"S": "Orlando, FL"}
}
},
{ "M": {
"Sensor": { "S": "Sensor2" },
"SensorDescription": { "S": "This is a description of a Sensor"},
"ImageFile": {"S": "/Sensors/image/Sensor2.txt"},
"SampleRate": {"N": "2"},
"Locations": {"S": "Annapolis, MD"}
}
},
{ "M": {
"Sensor": { "S": "Sensor3" },
"SensorDescription": { "S": "This is a description of a Sensor"},
"ImageFile": {"S": "/Sensors/image/Sensor3.txt"},
"SampleRate": {"N": "3"},
"Locations": {"S": "Jacksonville, FL"}
}
},
{ "M": {
"Sensor": { "S": "Sensor4" },
"SensorDescription": { "S": "This is a description of a Sensor"},
"ImageFile": {"S": "/Sensors/image/Sensor4.txt"},
"SampleRate": {"N": "4"},
"Locations": {"S": "Balitimore, MD"}
}
},
{ "M": {
"Sensor": { "S": "Sensor5" },
"SensorDescription": { "S": "This is a description of a Sensor"},
"ImageFile": {"S": "/Sensors/image/Sensor5.txt"},
"SampleRate": {"N": "5"},
"Locations": {"S": "Washington DC"}
}
},
{ "M": {
"Sensor": { "S": "Sensor6" },
"SensorDescription": { "S": "This is a description of a Sensor"}
}
},
{ "M": {
"Sensor": { "S": "Sensor7" },
"SensorDescription": { "S": "This is a description of a Sensor" }
}
},
{ "M": {
"Sensor": { "S": "Sensor8" },
"SensorDescription": { "S": "This is a description of a Sensor"}
}
},
{ "M": {
"Sensor": { "S": "Sensor9" },
"SensorDescription": { "S": "This is a description of a Sensor"}
}
},
{ "M": {
"Sensor": { "S": "Sensor10" },
"SensorDescription": { "S": "This is a description of a Sensor"}
}
},
{ "M": {
"Sensor": { "S": "Sensor11" },
"SampleRate": {"N": "11"},
"Locations": {"S": "New York, NY"}
}
},
{ "M": {
"Sensor": { "S": "Sensor12" },
"SampleRate": {"N": "12"},
"Locations": {"S": "Buffalo, NY"}
}
},
{ "M": {
"Sensor": { "S": "Sensor13" },
"SampleRate": {"N": "13"},
"Locations": {"S": "Chicago, IL"}
}
},
{ "M": {
"Sensor": { "S": "Sensor14" },
"SampleRate": {"N": "14"},
"Locations": {"S": "Trenton, NJ"}
}
},
{ "M": {
"Sensor": { "S": "Sensor15" },
"SampleRate": {"N": "15"},
"Locations": {"S": "Los Angeles, CA"}
}
},
{ "M": {
"Sensor": { "S": "Sensor16" },
"SampleRate": {"N": "16"},
"SensorDescription": { "S": "This is a description of a Sensor"},
"AltName": {"S": "Sensor-16"}
}
},
{ "M": {
"Sensor": { "S": "Sensor17" },
"SampleRate": {"N": "17"},
"SensorDescription": { "S": "This is a description of a Sensor"},
"Date": {"S": "2022-09-11 15:00:00.000"}
}
},
{ "M": {
"Sensor": { "S": "Sensor18" },
"SampleRate": {"N": "18"},
"SensorDescription": { "S": "This is a description of a Sensor"},
"Working": {"BOOL": false }
}
},
{ "M": {
"Sensor": { "S": "Sensor19" },
"SampleRate": {"N": "19"},
"SensorDescription": { "S": "This is a description of a Sensor"},
"color": {"S": "Green" }
}
},
{ "M": {
"Sensor": { "S": "Sensor20" },
"SampleRate": {"N": "20"},
"SensorDescription": { "S": "This is a description of a Sensor"},
"Senor_type": {"S": "Type 2" }
}
}
]
}
}
Here is the table:
My eyes must be playing tricks on me because I can't see the issue or am I doing something else wrong? Any help is greatly appreciated.
Apparently my description of the issue is too short so I am writing this sentence so I may post..
While the previous answer by hunterhacker is correct, put-item cannot be used to insert batches of items. Instead, to insert a batch of items we must use batch-write-item which will allow us insert up to 25 items per batch:
https://docs.aws.amazon.com/cli/latest/reference/dynamodb/batch-write-item.html
For your use-case, you will need to alter your JSON slightly to make it work. I have edited your example given which you can further refer to and use:
{
"Sensors": [
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor1"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
},
"ImageFile": {
"S": "/Sensors/image/Sensor1.txt"
},
"SampleRate": {
"N": "1"
},
"Locations": {
"S": "Orlando, FL"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor2"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
},
"ImageFile": {
"S": "/Sensors/image/Sensor2.txt"
},
"SampleRate": {
"N": "2"
},
"Locations": {
"S": "Annapolis, MD"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor3"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
},
"ImageFile": {
"S": "/Sensors/image/Sensor3.txt"
},
"SampleRate": {
"N": "3"
},
"Locations": {
"S": "Jacksonville, FL"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor4"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
},
"ImageFile": {
"S": "/Sensors/image/Sensor4.txt"
},
"SampleRate": {
"N": "4"
},
"Locations": {
"S": "Balitimore, MD"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor5"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
},
"ImageFile": {
"S": "/Sensors/image/Sensor5.txt"
},
"SampleRate": {
"N": "5"
},
"Locations": {
"S": "Washington DC"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor6"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor7"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor8"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor9"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor10"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor11"
},
"SampleRate": {
"N": "11"
},
"Locations": {
"S": "New York, NY"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor12"
},
"SampleRate": {
"N": "12"
},
"Locations": {
"S": "Buffalo, NY"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor13"
},
"SampleRate": {
"N": "13"
},
"Locations": {
"S": "Chicago, IL"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor14"
},
"SampleRate": {
"N": "14"
},
"Locations": {
"S": "Trenton, NJ"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor15"
},
"SampleRate": {
"N": "15"
},
"Locations": {
"S": "Los Angeles, CA"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor16"
},
"SampleRate": {
"N": "16"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
},
"AltName": {
"S": "Sensor-16"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor17"
},
"SampleRate": {
"N": "17"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
},
"Date": {
"S": "2022-09-11 15:00:00.000"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor18"
},
"SampleRate": {
"N": "18"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
},
"Working": {
"BOOL": false
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor19"
},
"SampleRate": {
"N": "19"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
},
"color": {
"S": "Green"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor20"
},
"SampleRate": {
"N": "20"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
},
"Senor_type": {
"S": "Type 2"
}
}
}
}
]
}
Now to insert this into your table, you can use the following batch-write-item command:
aws dynamodb batch-write-item \
--request-items file://sensors.json \
--return-consumed-capacity TOTAL
Hope that helps :)
The put-item call takes a singular item and you’re trying to pass a list. You can see the docs and format definition at https://docs.aws.amazon.com/cli/latest/reference/dynamodb/put-item.html

I have some problems I have to make a graph with Kibana when I add a division with my field I have no result

/* excuse my english i'm french my split is nginx.access.response_code.keyword
lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
mmmmmmmmmmmmmmmmmm
mmmmmmmmmmmmmmmmmmmmm
mmmmmmmmmmmmmmmm
*/
{
"aggs": {
"2": {
"significant_terms": {
"field": "nginx.access.response_code.keyword",
"size": 10
},
"aggs": {
"3": {
"date_histogram": {
"field": "#timestamp",
"fixed_interval": "12h",
"time_zone": "Europe/Paris",
"min_doc_count": 1
}
}
}
}
},
"size": 0,
"stored_fields": [
"*"
],
"script_fields": {},
"docvalue_fields": [
{
"field": "#timestamp",
"format": "date_time"
},
{
"field": "event.created",
"format": "date_time"
},
{
"field": "read_timestamp",
"format": "date_time"
}
],
"_source": {
"excludes": []
},
"query": {
"bool": {
"must": [],
"filter": [
{
"match_all": {}
},
{
"range": {
"#timestamp": {
"gte": "2020-11-07T14:57:01.503Z",
"lte": "2020-12-07T14:57:01.503Z",
"format": "strict_date_optional_time"
}
}
}
],
"should": [],
"must_not": [
{
"match_phrase": {
"nginx.access.response_code.keyword": {
"query": "200"
}
}
},
{
"match_phrase": {
"nginx.access.response_code.keyword": {
"query": "301"
}
}
},
{
"match_phrase": {
"nginx.access.response_code.keyword": {
"query": "304"
}
}
}
]
}
}
}
/* the result my buckets are empty */
{
"took": 302,
"timed_out": false,
"_shards": {
"total": 11,
"successful": 11,
"skipped": 10,
"failed": 0
},
"hits": {
"total": 6418480,
"max_score": null,
"hits": []
},
"aggregations": {
"2": {
"buckets": []
}
}
}
I found it. it did not exist in my data nginx.access.response_code.keyword. Be careful, Kibana does not show you your error.

JQ: Merging deep data

How can I merge the data in stubs[] matched by port property.
{
"imposters": [
{
"protocol": "http",
"port": 9000,
"name": "sanc",
"stubs": []
},
{
"protocol": "http",
"port": 9001,
"name": "sanp",
"stubs": [
{
"predicates": [
{
"deepEquals": {
"path": "/user/access/resources"
}
}
],
"responses": [
{
"is": {
"statusCode": 200,
"body": "H4sIAAAAAAAAA4yRQYvCMBCF="
}
}
]
},
{
"predicates": [
{
"deepEquals": {
"path": "/user/access/pilot"
}
}
],
"responses": [
{
"is": {
"statusCode": 200,
"body": "H4sIAAAAAAAAA6quBQAAAP//AwBDv6ajAgAAAA=="
}
}
]
}
]
}
]
}
{
"imposters": [
{
"protocol": "http",
"port": 9000,
"name": "sanc",
"stubs": []
},
{
"protocol": "http",
"port": 9001,
"name": "sanp",
"stubs": [
{
"predicates": [
{
"deepEquals": {
"path": "/pay/resources"
}
}
],
"responses": [
{
"is": {
"statusCode": 200,
"body": "H4sIAAAAAAAAA4yRQYvCMBCF="
}
}
]
},
{
"predicates": [
{
"deepEquals": {
"path": "/pay/5"
}
}
],
"responses": [
{
"is": {
"statusCode": 200,
"body": "H4sIAAAAAAAAA6quBQAAAP//AwBDv6ajAgAAAA=="
}
}
]
}
]
}
]
}
Using the following command:
jq -s '
def merge:
{"protocol": .[0].protocol,
"port": .[0].port,
"name": .[0].name,
"stubs": (reduce .[].stubs as $item ([]; . + $item) | unique)};
[[.[].imposters[]] | group_by(.port) | .[] | merge] |
{"imposters": .}' a.json
This type of output can be generated:
{
"imposters": [
{
"protocol": "http",
"port": 9000,
"name": "sanc",
"stubs": []
},
{
"protocol": "http",
"port": 9001,
"name": "sanp",
"stubs": [
{
"predicates": [
{
"deepEquals": {
"path": "/pay/5"
}
}
],
"responses": [
{
"is": {
"statusCode": 200,
"body": "H4sIAAAAAAAAA6quBQAAAP//AwBDv6ajAgAAAA=="
}
}
]
},
{
"predicates": [
{
"deepEquals": {
"path": "/pay/resources"
}
}
],
"responses": [
{
"is": {
"statusCode": 200,
"body": "H4sIAAAAAAAAA4yRQYvCMBCF="
}
}
]
},
{
"predicates": [
{
"deepEquals": {
"path": "/user/access/pilot"
}
}
],
"responses": [
{
"is": {
"statusCode": 200,
"body": "H4sIAAAAAAAAA6quBQAAAP//AwBDv6ajAgAAAA=="
}
}
]
},
{
"predicates": [
{
"deepEquals": {
"path": "/user/access/resources"
}
}
],
"responses": [
{
"is": {
"statusCode": 200,
"body": "H4sIAAAAAAAAA4yRQYvCMBCF="
}
}
]
}
]
}
]
}

adjusting angularjs material design data table column width

I'm using the old AngularJS Material Design Data Table and would like to know how to adjust the column width.
https://github.com/daniel-nagy/md-data-table
For instance if I wanted to change the 'fat' column in the demo to a fixed width of 40px how would I go about this?
Demo: http://codepen.io/anon/pen/BjvLVJ
There is a fixed padding which seems to be the main problem.
table.md-table.md-row-select td.md-cell:nth-child(n+3):nth-last-child(n+2), table.md-table.md-row-select th.md-column:nth-child(n+3):nth-last-child(n+2) {
 padding: 0 56px 0 0;
}
You could use the following css class.
.width-override{
width:40px !important;
padding:0px !important;
}
You will need to add it to the th and td tags of the respective column like so.
<th md-column md-numeric md-order-by="fat.value" class="width-override"><span>Fat (g)</span></th>
<td md-cell class="width-override">{{dessert.fat.value | number: 2}}</td>
Please checkout the below example!
Note: The contents are of width 56px so the column is of that width, you might want to use the same, since we do not want to clip the contents inside the column.
angular.module('demoApp', ['ngMaterial', 'md.data.table'])
.config(['$mdThemingProvider', function ($mdThemingProvider) {
'use strict';
$mdThemingProvider.theme('default')
.primaryPalette('blue');
}])
.controller('nutritionController', ['$mdEditDialog', '$q', '$scope', '$timeout', function ($mdEditDialog, $q, $scope, $timeout) {
'use strict';
$scope.selected = [];
$scope.limitOptions = [5, 10, 15];
$scope.options = {
rowSelection: true,
multiSelect: true,
autoSelect: true,
decapitate: false,
largeEditDialog: false,
boundaryLinks: false,
limitSelect: true,
pageSelect: true
};
$scope.query = {
order: 'name',
limit: 5,
page: 1
};
$scope.desserts = {
"count": 9,
"data": [
{
"name": "Frozen yogurt",
"type": "Ice cream",
"calories": { "value": 159.0 },
"fat": { "value": 6.0 },
"carbs": { "value": 24.0 },
"protein": { "value": 4.0 },
"sodium": { "value": 87.0 },
"calcium": { "value": 14.0 },
"iron": { "value": 1.0 }
}, {
"name": "Ice cream sandwich",
"type": "Ice cream",
"calories": { "value": 237.0 },
"fat": { "value": 9.0 },
"carbs": { "value": 37.0 },
"protein": { "value": 4.3 },
"sodium": { "value": 129.0 },
"calcium": { "value": 8.0 },
"iron": { "value": 1.0 }
}, {
"name": "Eclair",
"type": "Pastry",
"calories": { "value": 262.0 },
"fat": { "value": 16.0 },
"carbs": { "value": 24.0 },
"protein": { "value": 6.0 },
"sodium": { "value": 337.0 },
"calcium": { "value": 6.0 },
"iron": { "value": 7.0 }
}, {
"name": "Cupcake",
"type": "Pastry",
"calories": { "value": 305.0 },
"fat": { "value": 3.7 },
"carbs": { "value": 67.0 },
"protein": { "value": 4.3 },
"sodium": { "value": 413.0 },
"calcium": { "value": 3.0 },
"iron": { "value": 8.0 }
}, {
"name": "Jelly bean",
"type": "Candy",
"calories": { "value": 375.0 },
"fat": { "value": 0.0 },
"carbs": { "value": 94.0 },
"protein": { "value": 0.0 },
"sodium": { "value": 50.0 },
"calcium": { "value": 0.0 },
"iron": { "value": 0.0 }
}, {
"name": "Lollipop",
"type": "Candy",
"calories": { "value": 392.0 },
"fat": { "value": 0.2 },
"carbs": { "value": 98.0 },
"protein": { "value": 0.0 },
"sodium": { "value": 38.0 },
"calcium": { "value": 0.0 },
"iron": { "value": 2.0 }
}, {
"name": "Honeycomb",
"type": "Other",
"calories": { "value": 408.0 },
"fat": { "value": 3.2 },
"carbs": { "value": 87.0 },
"protein": { "value": 6.5 },
"sodium": { "value": 562.0 },
"calcium": { "value": 0.0 },
"iron": { "value": 45.0 }
}, {
"name": "Donut",
"type": "Pastry",
"calories": { "value": 452.0 },
"fat": { "value": 25.0 },
"carbs": { "value": 51.0 },
"protein": { "value": 4.9 },
"sodium": { "value": 326.0 },
"calcium": { "value": 2.0 },
"iron": { "value": 22.0 }
}, {
"name": "KitKat",
"type": "Candy",
"calories": { "value": 518.0 },
"fat": { "value": 26.0 },
"carbs": { "value": 65.0 },
"protein": { "value": 7.0 },
"sodium": { "value": 54.0 },
"calcium": { "value": 12.0 },
"iron": { "value": 6.0 }
}
]
};
$scope.editComment = function (event, dessert) {
event.stopPropagation(); // in case autoselect is enabled
var editDialog = {
modelValue: dessert.comment,
placeholder: 'Add a comment',
save: function (input) {
if(input.$modelValue === 'Donald Trump') {
input.$invalid = true;
return $q.reject();
}
if(input.$modelValue === 'Bernie Sanders') {
return dessert.comment = 'FEEL THE BERN!'
}
dessert.comment = input.$modelValue;
},
targetEvent: event,
title: 'Add a comment',
validators: {
'md-maxlength': 30
}
};
var promise;
if($scope.options.largeEditDialog) {
promise = $mdEditDialog.large(editDialog);
} else {
promise = $mdEditDialog.small(editDialog);
}
promise.then(function (ctrl) {
var input = ctrl.getInput();
input.$viewChangeListeners.push(function () {
input.$setValidity('test', input.$modelValue !== 'test');
});
});
};
$scope.toggleLimitOptions = function () {
$scope.limitOptions = $scope.limitOptions ? undefined : [5, 10, 15];
};
$scope.getTypes = function () {
return ['Candy', 'Ice cream', 'Other', 'Pastry'];
};
$scope.loadStuff = function () {
$scope.promise = $timeout(function () {
// loading
}, 2000);
}
$scope.logItem = function (item) {
console.log(item.name, 'was selected');
};
$scope.logOrder = function (order) {
console.log('order: ', order);
};
$scope.logPagination = function (page, limit) {
console.log('page: ', page);
console.log('limit: ', limit);
}
}]);
body,
md-content {
background-color: #f5f5f5 !important;
}
body > md-toolbar {
z-index: 3;
}
md-toolbar.md-table-toolbar.alternate {
color: #1e88e5;
background-color: #e3f2fd;
}
md-toolbar.md-table-toolbar.alternate .md-toolbar-tools {
font-size: 16px;
}
md-card:first-child {
padding: 8px 8px 8px 24px;
}
.checkboxes > md-checkbox {
margin: 0;
padding: 16px;
min-width: 300px;
flex: 0 0 auto;
}
.width-override{
width:40px !important;
padding:0px !important;
overflow:hidden;
}
<html lang="en" ng-app="demoApp">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Demo</title>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="https://rawgit.com/daniel-nagy/md-data-table/master/dist/md-data-table.css">
</head>
<body layout="column">
<md-toolbar class="md-whiteframe-1dp">
<div class="md-toolbar-tools">
<div class="md-title">Material Design Data Table</div>
</div>
</md-toolbar>
<md-content laout="column" flex ng-controller="nutritionController">
<md-card>
<div layout="row" layout-wrap class="checkboxes">
<md-checkbox ng-model="options.rowSelection">Row Selection</md-checkbox>
<md-checkbox ng-model="options.multiSelect">Multiple Selection</md-checkbox>
<md-checkbox ng-model="options.autoSelect">Auto Selection</md-checkbox>
<md-checkbox ng-model="options.decapitate">Decapitate</md-checkbox>
<md-checkbox ng-model="options.largeEditDialog">Lard Edit Dialogs</md-checkbox>
<md-checkbox ng-model="options.boundaryLinks">Pagination Boundary Links</md-checkbox>
<md-checkbox ng-model="options.limitSelect" ng-click="toggleLimitOptions()">Pagination Limit Select</md-checkbox>
<md-checkbox ng-model="options.pageSelect">Pagination Page Select</md-checkbox>
</div>
</md-card>
<md-card>
<md-toolbar class="md-table-toolbar md-default" ng-hide="options.rowSelection && selected.length">
<div class="md-toolbar-tools">
<span>Nutrition</span>
<div flex></div>
<md-button class="md-icon-button" ng-click="loadStuff()">
<md-icon>refresh</md-icon>
</md-button>
</div>
</md-toolbar>
<md-toolbar class="md-table-toolbar alternate" ng-show="options.rowSelection && selected.length">
<div class="md-toolbar-tools">
<span>{{selected.length}} {{selected.length > 1 ? 'items' : 'item'}} selected</span>
</div>
</md-toolbar>
<md-table-container>
<table md-table md-row-select="options.rowSelection" multiple="{{options.multiSelect}}" ng-model="selected" md-progress="promise">
<thead ng-if="!options.decapitate" md-head md-order="query.order" md-on-reorder="logOrder">
<tr md-row>
<th md-column md-order-by="name"><span>Dessert (100g serving)</span></th>
<th md-column md-order-by="type"><span>Type</span></th>
<th md-column md-numeric md-order-by="calories.value" md-desc><span>Calories</span></th>
<th md-column md-numeric md-order-by="fat.value" class="width-override"><span>Fat (g)</span></th>
<th md-column md-numeric md-order-by="carbs.value"><span>Carbs (g)</span></th>
<th md-column md-numeric md-order-by="protein.value"><span>Protein (g)</span></th>
<th md-column md-numeric md-order-by="sodium.value" hide-gt-xs show-gt-md><span>Sodium (mg)</span></th>
<th md-column md-numeric md-order-by="calcium.value" hide-gt-xs show-gt-lg><span>Calcium (%)</span></th>
<th md-column md-numeric md-order-by="iron.value" hide-gt-xs show-gt-lg><span>Iron (%)</span></th>
<th md-column md-order-by="comment">
<md-icon>comments</md-icon>
<span>Comments</span>
</th>
</tr>
</thead>
<tbody md-body>
<tr md-row md-select="dessert" md-on-select="logItem" md-auto-select="options.autoSelect" ng-disabled="dessert.calories.value > 400" ng-repeat="dessert in desserts.data | filter: filter.search | orderBy: query.order | limitTo: query.limit : (query.page -1) * query.limit">
<td md-cell>{{dessert.name}}</td>
<td md-cell>
<md-select ng-model="dessert.type" placeholder="Other">
<md-option ng-value="type" ng-repeat="type in getTypes()">{{type}}</md-option>
</md-select>
</td>
<td md-cell>{{dessert.calories.value}}</td>
<td md-cell class="width-override">{{dessert.fat.value | number: 2}}</td>
<td md-cell>{{dessert.carbs.value}}</td>
<td md-cell>{{dessert.protein.value | number: 2}}</td>
<td md-cell hide-gt-xs show-gt-md>{{dessert.sodium.value}}</td>
<td md-cell hide-gt-xs show-gt-lg>{{dessert.calcium.value}}%</td>
<td md-cell hide-gt-xs show-gt-lg>{{dessert.iron.value}}%</td>
<td md-cell ng-click="editComment($event, dessert)" ng-class="{'md-placeholder': !dessert.comment}">
{{dessert.comment || 'Add a comment'}}
</td>
</tr>
</tbody>
</table>
</md-table-container>
<md-table-pagination md-limit="query.limit" md-limit-options="limitOptions" md-page="query.page" md-total="{{desserts.count}}" md-page-select="options.pageSelect" md-boundary-links="options.boundaryLinks" md-on-paginate="logPagination"></md-table-pagination>
</md-card>
</md-content>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-animate.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-aria.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.js"></script>
<script src="https://rawgit.com/daniel-nagy/md-data-table/master/dist/md-data-table.js"></script>
</body>
</html>

google calender api setColorId

I want to do something event.setColorId("RED") to change my event color
unfortunetaly this is the response i got
{
"code" : 400,
"errors" : [ {
"domain" : "global",
"message" : "Invalid Value",
"reason" : "invalid"
} ],
"message" : "Invalid Value"
}
does anyone know the correct way?
Thanks
You should do event.setColorId("11") for red.
These are all the possible options for colorId.
"1": {
"background": "#ac725e",
"foreground": "#1d1d1d"
},
"2": {
"background": "#d06b64",
"foreground": "#1d1d1d"
},
"3": {
"background": "#f83a22",
"foreground": "#1d1d1d"
},
"4": {
"background": "#fa573c",
"foreground": "#1d1d1d"
},
"5": {
"background": "#ff7537",
"foreground": "#1d1d1d"
},
"6": {
"background": "#ffad46",
"foreground": "#1d1d1d"
},
"7": {
"background": "#42d692",
"foreground": "#1d1d1d"
},
"8": {
"background": "#16a765",
"foreground": "#1d1d1d"
},
"9": {
"background": "#7bd148",
"foreground": "#1d1d1d"
},
"10": {
"background": "#b3dc6c",
"foreground": "#1d1d1d"
},
"11": {
"background": "#fbe983",
"foreground": "#1d1d1d"
},
"12": {
"background": "#fad165",
"foreground": "#1d1d1d"
},
"13": {
"background": "#92e1c0",
"foreground": "#1d1d1d"
},
"14": {
"background": "#9fe1e7",
"foreground": "#1d1d1d"
},
"15": {
"background": "#9fc6e7",
"foreground": "#1d1d1d"
},
"16": {
"background": "#4986e7",
"foreground": "#1d1d1d"
},
"17": {
"background": "#9a9cff",
"foreground": "#1d1d1d"
},
"18": {
"background": "#b99aff",
"foreground": "#1d1d1d"
},
"19": {
"background": "#c2c2c2",
"foreground": "#1d1d1d"
},
"20": {
"background": "#cabdbf",
"foreground": "#1d1d1d"
},
"21": {
"background": "#cca6ac",
"foreground": "#1d1d1d"
},
"22": {
"background": "#f691b2",
"foreground": "#1d1d1d"
},
"23": {
"background": "#cd74e6",
"foreground": "#1d1d1d"
},
"24": {
"background": "#a47ae2",
"foreground": "#1d1d1d"
}
},
"event": {
"1": {
"background": "#a4bdfc",
"foreground": "#1d1d1d"
},
"2": {
"background": "#7ae7bf",
"foreground": "#1d1d1d"
},
"3": {
"background": "#dbadff",
"foreground": "#1d1d1d"
},
"4": {
"background": "#ff887c",
"foreground": "#1d1d1d"
},
"5": {
"background": "#fbd75b",
"foreground": "#1d1d1d"
},
"6": {
"background": "#ffb878",
"foreground": "#1d1d1d"
},
"7": {
"background": "#46d6db",
"foreground": "#1d1d1d"
},
"8": {
"background": "#e1e1e1",
"foreground": "#1d1d1d"
},
"9": {
"background": "#5484ed",
"foreground": "#1d1d1d"
},
"10": {
"background": "#51b749",
"foreground": "#1d1d1d"
},
"11": {
"background": "#dc2127",
"foreground": "#1d1d1d"
}

Categories

Resources