Dojo Build Tool - dojo-build

error(311) Missing dependency. module: app/ui/module/Widget1; dependency: appui/module/Widget2
The Dojo build tool does not take into consideration the configuration provided in the "paths" property of the Profile object
I have coded "paths" property as follows
paths : {
appui : "app/ui"
}

I don't believe "paths" is a valid property of the profile object.
The profile object often looks something like:
var profile = {
basePath:"/home/user/dev/",
releaseDir:"./release",
packages:[{
name:"dojo",
location:"./lib/dojo"
},{
name:"dijit",
location:"./lib/dijit"
},{
name:"myapp",
location:"./myapp"
}]
}
More info here: https://dojotoolkit.org/reference-guide/1.10/build/buildSystem.html#specifying-resources

Related

Component reuse in manifest.json file

We are currently building a set of apps, where there is a lot of reuse.
Currently we got it working by using
jQuery.sap.registerModulePath and jQuery.sap.require.
But according to
Using and Nesting Components you should be able to declare your reuse components in the manifest.json file.
I had a look in the SAPUI5 Developer Guide, but couldn't really make it work. As far as i can see I need to add the following:
"sap.App" :{
"embeddedBy" : "../.."
},
"sap.ui5": {
"componentUsages" :{
"<string for my reuse component>" : {
"name" : "<name of the component>"
}
"dependencies" :{
"components" : {
"<namespace of my component>"
}}
Anyone got a working example?
Here is a working example with nested components: https://embed.plnkr.co/e7KS48/
The descriptor attribute componentUsages is available since 1.47.0. Once defined, UI5 takes care of resolving the Component and its module path before rendering the owning ComponentContainer.
ComponentContainer is needed because a Component cannot be placed into the UI without a container. In my example above, the Container is defined declaratively in Home.view.xml with the respective usage property.
<core:ComponentContainer id="containerForChildComponent"
autoPrefixId="true"
settings="{id: 'childComponent'}"
usage="reuseAnotherComponent"
manifest="true"
height="100%"
async="true"
/>
"sap.ui5": {
"componentUsages": {
"reuseAnotherComponent": {
"name": "anotherComponent",
"lazy": false
}
},
"resourceRoots": {
"anotherComponent": "./component_B"
},
// ...
}
As you can see, the resourceRoots can be also defined in the descriptor which could point to other component / app locations.
Example for UI5 apps w/ version below 1.47: https://embed.plnkr.co/ytXZJ9

Meteor - Update Collection with location object (in GeoJSON format)

Here is my schema (simple schema):
officelocation: {
type: String,
label: 'Location of Office',
autoform: {
type: 'map',
afFieldInput: {
type: 'map',
geolocation: true,
searchBox: true,
autolocate: true
}
}
},
location: {
optional: true,
type: 'Point'
}
My server side js code is below (note this is in a collection.after hook) so I want to update it based on the address that user has entered, which I have resolved into lat long:
Providers.update({_id: doc._id}, {$set: {location: {type:"Point", coordinates:[lng,lat]} } });
When I see the file in the collection (db.providers.find();), I see the below.. Note that the location embedded object is empty:
{ "_id" : "X8ZfKYJAP9cduwvmd", "phone" : 999999999, "officelocation" : "40.7192714,14.872363899999982", "createdAt" : ISODate("2015-04-24T02:00:40.447Z"), "updatedAt" : ISODate("2015-04-24T02:00:40.799Z"), "owner" : "GB4TxTHodkykeeXp6", "officeaddress" : "Via Califri, 5, 84099 San Cipriano Picentino SA, Italy", "location" : { } }
I am basically trying to make sure by collections are stored in a geo-spatial-searchable way, but this approach does not seem to work. Any help?
There could be a number of things causing your update to fail, from allow-deny rules to Simple Schema cleaning out your data.
I see that you are using a custom type to store your location. Make sure you have used a Transform to ensure the type isn't lost on the way to the server. From the Simple Schema readme:
Custom object types are treated as blackbox objects by default. However, when using collection2, you must ensure that the custom type is not lost between client and server. This can be done with a transform function that converts the generic Object to the custom object. Without this transformation, client-side inserts and updates might succeed on the client but then fail on the server. Alternatively, if you don't care about losing the custom type, you can explicitly set blackbox: true for a custom object type instead of using a transformation.
Alternatively you could use a sub-schema to define what a location is allowed to look like, instead of using a custom type, but it won't keep the methods of the Point type.

Adding custom baucis routes to its generated swagger api

When we create our apps, we usually add our own routes.
So using the baucis.rest i added some custom routes like example:
var controller = baucis.rest( {
singular: 'User'
} );
controller.put('/myroute/:id', function(req,res,done){
//doing something
})
My app runs and using the swagger ui i can see the operations about users.
GET /Users/{id} description
PUT /Users/{id} description
......
I would like to add my "/myroute/:id' to the generated swagger api.
PUT /Users/myroute/{id} description
Does anyone know how to do about this?
As of v0.9.0 , you can modify the swagger definitions directly. It's purely cosmetic, only altering the swagger documentation, not any other functionality.
For example:
var controller = baucis.rest('User');
controller.swagger.apis.push({
'path': '/Users/myroute/{id}',
'description': 'Myroute custom description.',
'operations': [
{
'httpMethod': 'PUT',
'nickname': 'putSomethingCustom',
'responseClass': 'User',
'summary': 'Something custom.'
}
]
})
controller.swagger.models is also exposed.

how to query attributes inside a role in chef?

I am using chef version 10.16.2
I have a role (in ruby format). I need to access an attrubute set in one of the cookbooks
eg.
name "basebox"
description "A basic box with some packages, ruby and rbenv installed"
deployers = node['users']['names'].find {|k,v| v['role'] == "deploy" }
override_attributes {
{"rbenv" => {
"group_users" => deployers
}
}
}
run_list [
"recipe[users]",
"recipe[packages]",
"recipe[nginx]",
"recipe[ruby]"
]
I am using chef-solo so i cannot use search as given on http://wiki.opscode.com/display/chef/Search#Search-FindNodeswithaRoleintheExpandedRunList
How do i access node attributes in a role definition ?
Roles are JSON data.
That is, when you upload the role Ruby file to the server with knife, they are converted to JSON. Consider this role:
name "gaming-system"
description "Systems used for gaming"
run_list(
"recipe[steam::installer]",
"recipe[teamspeak3::client]"
)
When I upload it with knife role from file gaming-system.rb, I have this on the server:
{
"name": "gaming-system",
"description": "Systems used for gaming",
"json_class": "Chef::Role",
"default_attributes": {
},
"override_attributes": {
},
"chef_type": "role",
"run_list": [
"recipe[steam::installer]",
"recipe[teamspeak3::client]"
],
"env_run_lists": {
}
}
The reason for the Ruby DSL is that it is "nicer" or "easier" to write than the JSON. Compare the lines and syntax, and it's easy to see which is preferable to new users (who may not be familiar with JSON).
That data is consumed through the API. If you need to do any logic with attributes on your node, do it in a recipe.
Not sure if I 100% follow, but if you want to access an attribute which is set by a role from a recipe, then you just call it like any other node attribute. For example, in the case you presented, assuming the node has the basebox role in its run_list, you would just call:
node['rbenv']['group_users']
The role attributes are merged into the node.
HTH

Using HATEOAS and Backbone.js

I've started experimenting with Backbone.js, and was struck by the documentation for the documentation for the url property on Backbone.Model.
In particular, I'm building out a REST API that uses HATEOAS/hypermedia to drive the client(s).
I can see the usefulness of Backbone's default behaviour of building up URLs itself for items in a collection, but for my case, would prefer to have the model URLs built out of the data that is parsed.
Has anyone extended/built on Backbone to make it do this? Maybe building upon a "standard" like HAL?
EDIT:
For clarification, let's say I have the following:
GET /orders >>
[
{
"_links": {
"self": "/orders/123"
}
"name": "Order #123",
"date": "2012/02/23"
},
{
"_links": {
"self": "/orders/6666"
}
"name": "Order #666",
"date": "2012/03/01"
},
]
and I have an Order model like:
var Order = Backbone.Model.extend({
});
I would like the url property to be automatically pulled out of the "self" reference in the HAL. I think creating a new base model something like (not tested):
var HalModel = Backbone.Model.extend({
url: function() {
return get("_links").self;
},
});
Thoughts?
I've extended backbone to do exactly this, the library is available here:
https://github.com/mikekelly/backbone.hal
Thanks for the clarification #Pete.
I think I see what your proposing and I suppose it could work. However, in your example, you first had to know the /Orders url before you were able to get the orders. And if you reworked your json to have an id property, you'd be pretty close to the default implementation of backbone.
Now if you just want to use a generic model or base model (e.g. HALModel) and just bootstrap it with data, your approach could be useful and definitely could work. However, I would look at overriding parse to pull the url out and set it on the model:
parse: function(response) {
this.url = response._links.self;
delete response._links;
return response;
}
I complement here the response of Simon to explain how to easily do it using gomoob/backbone.hateoas.
// Instanciation of an Hal.Model object is done the same way as you're
// used to with a standard Backbone model
var user = new Hal.Model({
firstName: "John",
lastName: "Doe",
_links: {
avatar: {
href: "http://localhost/api/users/1/avatar.png"
},
self: {
href: "http://localhost/api/users/1"
}
},
_embedded: {
address: {
"city" : "Paris",
"country" : "France",
"street" : "142 Rue de Rivoli",
"zip" : "75001",
"_links" : {
"self" : {
"href" : "http://localhost/api/addresses/1"
}
}
}
}
});
// Now we you can easily get links, those lines are equivalent
var link1 = user.getLink('avatar');
var link2 = user.getLinks().get('avatar');
// So getting self link is simple too
var self = user.getLink('self');
// All the Hal.Link objects returned by backbone.hateoas are in fact
// standard Backbone models so its standard Backbone
link1.get('href');
link1.getHref();
// You can do more with shortcut methods if your HAL links
// have more properties
link1.get('deprecation');
link1.getDeprecation();
link1.get('name');
link1.getName();
link1.get('hreflang');
link1.getHreflang();
link1.get('profile');
link1.getProfile();
link1.get('title');
link1.getTitle();
link1.get('type');
link1.getType();
linke1.get('templated');
link1.isTemplated();
// You can also manipulate embedded resources if you need
user.getEmbedded('address').get('city');
user.getEmbedded('address').getLink('self');
...
Finally we provide an Hal.Model.url() implementation which is more powerful than standard Backbone url() and which is very useful if you use HAL.
// By default url() returns the href of the self link if this self
// link is present
user.url();
// If the self link is not defined then url() has the same behavior
// as standard Backbone url() method
// My user is link to a user collection having a URL equal to
// 'http://localhost/user1'
user.url(); // http://localhost/users/1
// My user is not link to a user collection in this case the URL is
// generate using the model urlRoot property by default
user.urlRoot = 'http://myserver/users';
user.url(); // http://localhost/users/1
// backbone.hateoas also allows you to define an application wide root
// URL which prevent to use absolute URLs everywhere in your code
Hal.urlRoot = 'http://localhost/api'; // HAL root API URL
var user = new Hal.Model({ id : 1});
user.urlMiddle = 'users';
user.url(); // http://localhost/api/users/1
Hope this helps, don't hesitate to post issues on our github if you need help on this.
You can override the url function on the model to calculate the URL however you want; it's completely extensible.