mirror of https://github.com/hashicorp/consul
John Cowen
4 years ago
committed by
GitHub
4 changed files with 57 additions and 24 deletions
@ -1,10 +1,18 @@
|
||||
import Model from 'ember-data/model'; |
||||
import attr from 'ember-data/attr'; |
||||
//import { nullValue } from 'consul-ui/decorators/replace';
|
||||
|
||||
export const PRIMARY_KEY = 'uid'; |
||||
export const SLUG_KEY = 'ID'; |
||||
export default Model.extend({ |
||||
[PRIMARY_KEY]: attr('string'), |
||||
[SLUG_KEY]: attr('string'), |
||||
Datacenter: attr('string'), |
||||
}); |
||||
export default class <%= classifiedModuleName %>Model extends Model { |
||||
@attr('string') uid; |
||||
@attr('string') ID; |
||||
@attr('string') Datacenter; |
||||
|
||||
// @attr('string') Namespace; // Does this Model support namespaces?
|
||||
|
||||
// @nullValue([]) @attr({ defaultValue: () => [] }) MaybeNull; // Does a property sometimes return null?
|
||||
|
||||
// @attr('number') SyncTime; // Does this Model support blocking queries?
|
||||
// @attr() meta; // {} // Does this Model support blocking queries?
|
||||
}; |
||||
|
@ -1,8 +1,29 @@
|
||||
import RepositoryService from 'consul-ui/services/repository'; |
||||
import dataSource from 'consul-ui/decorators/data-source'; |
||||
|
||||
const modelName = '<%= dasherizedModuleName %>'; |
||||
export default RepositoryService.extend({ |
||||
getModelName: function() { |
||||
return modelName; |
||||
}, |
||||
}); |
||||
const MODEL_NAME = '<%= dasherizedModuleName %>'; |
||||
const PRIMARY_KEY = 'uid'; |
||||
const SLUG_KEY = 'ID'; |
||||
export default class <%= classifiedModuleName %>Repository extends RepositoryService { |
||||
getModelName() { |
||||
return MODEL_NAME; |
||||
} |
||||
|
||||
getPrimaryKey() { |
||||
return PRIMARY_KEY; |
||||
} |
||||
|
||||
getSlugKey() { |
||||
return SLUG_KEY; |
||||
} |
||||
|
||||
@dataSource('/:ns/:dc/<%= dasherizedModuleName %>') |
||||
async findAllByDatacenter() { |
||||
return super.findAllByDatacenter(...arguments); |
||||
} |
||||
|
||||
@dataSource('/:ns/:dc/<%= dasherizedModuleName %>/:id') |
||||
async findBySlug() { |
||||
return super.findBySlug(...arguments); |
||||
} |
||||
}; |
||||
|
Loading…
Reference in new issue