ui: Update project blueprints for native classes (#9775)

This commit is contained in:
John Cowen 2021-02-24 09:03:18 +00:00 committed by GitHub
parent 26d41f076b
commit e81eea229b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 57 additions and 24 deletions

View File

@ -1,14 +1,16 @@
import Adapter from './application';
export default Adapter.extend({
requestForQuery: function(request, { dc, index }) {
export default class <%= classifiedModuleName %>Adapter extends Adapter {
requestForQuery(request, { ns, dc, index }) {
return request`
GET /v1/<%= dasherizedModuleName %>?${{ dc }}
${{ index }}
`;
},
requestForQueryRecord: function(request, { dc, index, id }) {
}
requestForQueryRecord(request, { ns, dc, index, id }) {
if (typeof id === 'undefined') {
throw new Error('You must specify an id');
}
@ -17,5 +19,6 @@ export default Adapter.extend({
${{ index }}
`;
},
});
}
};

View File

@ -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?
};

View File

@ -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);
}
};

View File

@ -1,11 +1,12 @@
import Serializer from './application';
import { PRIMARY_KEY, SLUG_KEY } from 'consul-ui/models/<%= dasherizedModuleName %>';
export default Serializer.extend({
primaryKey: PRIMARY_KEY,
slugKey: SLUG_KEY,
// respondForQueryRecord: function(respond, query) {
// return this._super(
export default class <%= classifiedModuleName %>Serializer extends Serializer {
primaryKey = PRIMARY_KEY;
slugKey = SLUG_KEY;
// respondForQueryRecord(respond, query) {
// return super.respondForQueryRecord(
// function(cb) {
// return respond(
// function(headers, body) {
@ -20,5 +21,5 @@ export default Serializer.extend({
// },
// query
// );
// },
});
// }
};