Many changes aded to system.
This commit is contained in:
parent
e0571d14b7
commit
5ba618f471
22 changed files with 640 additions and 57 deletions
28
imports/api/assets.js
Normal file
28
imports/api/assets.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import { Meteor } from 'meteor/meteor';
|
||||
import { Mongo } from 'meteor/mongo';
|
||||
import { check } from 'meteor/check';
|
||||
|
||||
export const Assets = new Mongo.Collection('assets');
|
||||
|
||||
Assets.allow({
|
||||
insert: function(userId, doc){
|
||||
// if use id exists, allow insert
|
||||
return !!userId;
|
||||
},
|
||||
});
|
||||
|
||||
Meteor.methods({
|
||||
async 'add.asset' (assetName {
|
||||
check(assetName, String);
|
||||
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('You are not allowed to add assets. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return await Assets.insertAsync({
|
||||
assetName: assetName,
|
||||
tenant_id: "000000",
|
||||
|
||||
});
|
||||
},
|
||||
});
|
||||
30
imports/api/locationTypes.js
Normal file
30
imports/api/locationTypes.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import { Meteor } from 'meteor/meteor';
|
||||
import { Mongo } from 'meteor/mongo';
|
||||
import { check } from 'meteor/check';
|
||||
|
||||
export const LocationTypes = new Mongo.Collection('locationTypes');
|
||||
|
||||
LocationTypes.allow({
|
||||
insert: function(userId, doc){
|
||||
// if use id exists, allow insert
|
||||
return !!userId;
|
||||
},
|
||||
});
|
||||
|
||||
Meteor.methods({
|
||||
async "add.locationType" (typeName, typeDesc) {
|
||||
check(typeName, String);
|
||||
check(typeDesc, String);
|
||||
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('You are not allowed to add location types. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return await LocationTypes.insertAsync({
|
||||
locationTypeName: typeName,
|
||||
locationTypeDesc: typeDesc,
|
||||
dateAdded: new Date(),
|
||||
addedBy: this.userId,
|
||||
});
|
||||
}
|
||||
});
|
||||
16
imports/api/locations.js
Normal file
16
imports/api/locations.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import { Meteor } from 'meteor/meteor';
|
||||
import { Mongo } from 'meteor/mongo';
|
||||
import { check } from 'meteor/check';
|
||||
|
||||
export const Locations = new Mongo.Collection('locations');
|
||||
|
||||
Locations.allow({
|
||||
insert: function(userId, doc){
|
||||
// if use id exists, allow insert
|
||||
return !!userId;
|
||||
},
|
||||
});
|
||||
|
||||
Meteor.methods({
|
||||
|
||||
});
|
||||
0
imports/api/tenants.js
Normal file
0
imports/api/tenants.js
Normal file
|
|
@ -6,11 +6,23 @@ export const UserInfo = new Mongo.Collection('userInfo');
|
|||
|
||||
UserInfo.allow({
|
||||
insert: function(userId, doc){
|
||||
// if use id exists, allow insert
|
||||
// if user id exists, allow insert
|
||||
return !!userId;
|
||||
},
|
||||
});
|
||||
|
||||
Meteor.methods({
|
||||
async 'addUserToTenant' (userId, tenant_id) {
|
||||
check(userId, String);
|
||||
check(tenant_id, String);
|
||||
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('You are not allowed to add tenants for users. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return await UserInfo.insertAsync({
|
||||
userId: userId,
|
||||
tenant_id: tenant_id,
|
||||
});
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue