OHIF-55: Add Test Drive button to login with demo user for Lesion Tracker

This commit is contained in:
Aysel Afsar 2016-08-25 12:08:40 -04:00
parent 4b627198b7
commit 793c2f3c0f
4 changed files with 69 additions and 1 deletions

View File

@ -26,7 +26,8 @@ Package.onUse(function (api) {
api.use([
'zuuk:stale-session@1.0.8',
'typ:accounts-ldap'
'typ:accounts-ldap',
'random'
], ['client', 'server']);
api.addFiles([

View File

@ -0,0 +1,25 @@
import { Template } from 'meteor/templating';
import { ActiveEntry } from 'meteor/clinical:active-entry';
Template.entrySignIn.hooks({
rendered: function () {
// Create Test Drive button dynamically
let btnTestDrive = $('<button/>', {
id: 'btnTestDrive',
text: 'Test Drive',
class: 'btn btn-primary',
style: 'position: absolute; width: 150px; top: 20px; right: 20px; padding-left: 0;',
title: 'Login with Demo User',
click: function () {
// Login with demo user
ActiveEntry.signIn('demo@ohif.org', '12345678aA*');
}
});
const entrySignIn = this.find('#entrySignIn');
$(entrySignIn).append(btnTestDrive);
}
});

View File

@ -101,6 +101,8 @@ Package.onUse(function(api) {
api.addFiles('client/components/activeEntry/activeEntry.styl', 'client');
api.addFiles('client/components/activeEntry/activeEntry.js', 'client');
api.addFiles('client/components/activeEntry/activeEntrySignIn/activeEntrySignIn.js', 'client');
api.addFiles('client/components/hipaaLogPage/hipaaLogPage.styl', 'client');
api.addFiles('client/components/hipaaLogPage/hipaaLogPage.js', 'client');
@ -211,6 +213,7 @@ Package.onUse(function(api) {
api.addFiles('server/publications.js', 'server');
api.addFiles('server/methods.js', [ 'server' ]);
api.addFiles('server/reviewers.js', [ 'server' ]);
api.addFiles('server/createDemoUser.js', [ 'server' ]);
// Both client and server functions
api.addFiles('both/collections.js', [ 'client', 'server' ]);

View File

@ -0,0 +1,39 @@
import { Accounts } from 'meteor/accounts-base';
Meteor.startup(function() {
const options = {
email: 'demo@ohif.org',
password: '12345678aA*',
profile: {
fullName: 'Demo User'
}
};
createDemoUser = function() {
const user = Meteor.users.findOne({
emails: {
$elemMatch: {
address: 'demo@ohif.org'
}
}
});
if (user) {
return;
}
console.log('create user!');
// Create user
const userId = Accounts.createUser(options);
if (!userId) {
console.log('Demo user cannot be created');
return;
}
};
// Create demo user
createDemoUser();
});