Data modeling for tokens and policies
This commit is contained in:
parent
c04d9020c2
commit
040e3fec10
5
ui/app/adapters/policy.js
Normal file
5
ui/app/adapters/policy.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
import { default as ApplicationAdapter, namespace } from './application';
|
||||
|
||||
export default ApplicationAdapter.extend({
|
||||
namespace: namespace + '/acl',
|
||||
});
|
5
ui/app/adapters/token.js
Normal file
5
ui/app/adapters/token.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
import { default as ApplicationAdapter, namespace } from './application';
|
||||
|
||||
export default ApplicationAdapter.extend({
|
||||
namespace: namespace + '/acl',
|
||||
});
|
8
ui/app/models/policy.js
Normal file
8
ui/app/models/policy.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
import Model from 'ember-data/model';
|
||||
import attr from 'ember-data/attr';
|
||||
|
||||
export default Model.extend({
|
||||
name: attr('string'),
|
||||
description: attr('string'),
|
||||
rules: attr('string'),
|
||||
});
|
18
ui/app/models/token.js
Normal file
18
ui/app/models/token.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
import Ember from 'ember';
|
||||
import Model from 'ember-data/model';
|
||||
import attr from 'ember-data/attr';
|
||||
import { hasMany } from 'ember-data/relationships';
|
||||
|
||||
const { computed } = Ember;
|
||||
|
||||
export default Model.extend({
|
||||
secret: attr('string'),
|
||||
name: attr('string'),
|
||||
global: attr('boolean'),
|
||||
createTime: attr('date'),
|
||||
type: attr('string'),
|
||||
policies: hasMany('policy'),
|
||||
policyNames: attr(),
|
||||
|
||||
accessor: computed.alias('id'),
|
||||
});
|
|
@ -11,7 +11,10 @@ export default JSONSerializer.extend({
|
|||
},
|
||||
|
||||
keyForRelationship(attr, relationshipType) {
|
||||
const key = `${attr.camelize().capitalize()}ID`;
|
||||
const key = `${attr
|
||||
.singularize()
|
||||
.camelize()
|
||||
.capitalize()}ID`;
|
||||
return relationshipType === 'hasMany' ? key.pluralize() : key;
|
||||
},
|
||||
|
||||
|
|
8
ui/app/serializers/policy.js
Normal file
8
ui/app/serializers/policy.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
import ApplicationSerializer from './application';
|
||||
|
||||
export default ApplicationSerializer.extend({
|
||||
normalize(typeHash, hash) {
|
||||
hash.ID = hash.Name;
|
||||
return this._super(typeHash, hash);
|
||||
},
|
||||
});
|
19
ui/app/serializers/token.js
Normal file
19
ui/app/serializers/token.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
import Ember from 'ember';
|
||||
import ApplicationSerializer from './application';
|
||||
|
||||
const { copy } = Ember;
|
||||
|
||||
export default ApplicationSerializer.extend({
|
||||
primaryKey: 'AccessorID',
|
||||
|
||||
attrs: {
|
||||
taskGroupName: 'TaskGroup',
|
||||
secret: 'SecretID',
|
||||
},
|
||||
|
||||
normalize(typeHash, hash) {
|
||||
hash.PolicyIDs = hash.Policies;
|
||||
hash.PolicyNames = copy(hash.Policies);
|
||||
return this._super(typeHash, hash);
|
||||
},
|
||||
});
|
Loading…
Reference in a new issue