Browse Source

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

pull/9759/head
John Cowen 4 years ago committed by GitHub
parent
commit
f9b0e50ca0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      ui/packages/consul-ui/blueprints/adapter/files/__root__/__path__/__name__.js
  2. 18
      ui/packages/consul-ui/blueprints/model/files/__root__/__path__/__name__.js
  3. 33
      ui/packages/consul-ui/blueprints/repository/files/__root__/__path__/__name__.js
  4. 15
      ui/packages/consul-ui/blueprints/serializer/files/__root__/__path__/__name__.js

15
ui/packages/consul-ui/blueprints/adapter/files/__root__/__path__/__name__.js

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

18
ui/packages/consul-ui/blueprints/model/files/__root__/__path__/__name__.js

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

33
ui/packages/consul-ui/blueprints/repository/files/__root__/__path__/__name__.js

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

15
ui/packages/consul-ui/blueprints/serializer/files/__root__/__path__/__name__.js

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

Loading…
Cancel
Save