Skip to content

Commit

Permalink
Merge pull request jhipster#413 from clement26695/add-no-db-support
Browse files Browse the repository at this point in the history
feature: add no database support
  • Loading branch information
hdurix authored Jul 9, 2019
2 parents 9a84755 + dc87822 commit 0d0225f
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 41 deletions.
72 changes: 53 additions & 19 deletions generators/client/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,17 @@ const vueFiles = {
condition: generator => generator.authenticationType !== 'oauth2',
path: VUE_DIR,
templates: [
'account/change-password/change-password.vue',
'account/change-password/change-password.component.ts',
'account/login-form/login-form.vue',
'account/login-form/login-form.component.ts',
'account/login.service.ts',
]
},
{
condition: generator => !generator.skipUserManagement,
path: VUE_DIR,
templates: [
'account/change-password/change-password.vue',
'account/change-password/change-password.component.ts',
'account/register/register.vue',
'account/register/register.component.ts',
'account/register/register.service.ts',
Expand All @@ -201,7 +207,7 @@ const vueFiles = {
]
},
{
condition: generator => generator.authenticationType === 'session',
condition: generator => generator.authenticationType === 'session' && !this.skipUserManagement,
path: VUE_DIR,
templates: [
'account/sessions/sessions.vue',
Expand Down Expand Up @@ -234,16 +240,22 @@ const vueFiles = {
'admin/logs/logs.vue',
'admin/logs/logs.component.ts',
'admin/logs/logs.service.ts',
'admin/audits/audits.vue',
'admin/audits/audits.component.ts',
'admin/audits/audits.service.ts',
'admin/metrics/metrics.vue',
'admin/metrics/metrics.component.ts',
'admin/metrics/metrics.service.ts',
'admin/metrics/metrics-modal.vue',
'admin/metrics/metrics-modal.component.ts'
]
},
{
condition: generator => ((generator.databaseType !== 'no' || generator.authenticationType === 'uaa') && generator.databaseType !== 'cassandra'),
path: VUE_DIR,
templates: [
'admin/audits/audits.vue',
'admin/audits/audits.component.ts',
'admin/audits/audits.service.ts'
]
},
{
condition: generator => generator.websocket === 'spring-websocket',
path: VUE_DIR,
Expand Down Expand Up @@ -304,11 +316,17 @@ const vueFiles = {
'spec/app/admin/health/health-modal.component.spec.ts',
'spec/app/admin/health/health.service.spec.ts',
'spec/app/admin/logs/logs.component.spec.ts',
'spec/app/admin/audits/audits.component.spec.ts',
'spec/app/admin/metrics/metrics.component.spec.ts',
'spec/app/admin/metrics/metrics-modal.component.spec.ts'
]
},
{
condition: generator => ((generator.databaseType !== 'no' || generator.authenticationType === 'uaa') && generator.databaseType !== 'cassandra'),
path: TEST_SRC_DIR,
templates: [
'spec/app/admin/audits/audits.component.spec.ts'
]
},
{
condition: generator => generator.enableTranslation,
path: TEST_SRC_DIR,
Expand All @@ -320,23 +338,29 @@ const vueFiles = {
condition: generator => generator.authenticationType === 'oauth2',
path: TEST_SRC_DIR,
templates: [
'spec/app/account/login.service.spec.ts'
'spec/app/account/login.service.spec.ts',
]
},
{
condition: generator => generator.authenticationType === 'session',
condition: generator => generator.authenticationType !== 'oauth2',
path: TEST_SRC_DIR,
templates: [
'spec/app/account/login-form/login-form.component.spec.ts'
]
},
{
condition: generator => generator.authenticationType === 'session' && !generator.skipUserManagement,
path: TEST_SRC_DIR,
templates: [
'spec/app/account/sessions/sessions.component.spec.ts',
'spec/app/account/login.service.spec.ts'
]
},
{
condition: generator => generator.authenticationType !== 'oauth2',
condition: generator => !generator.skipUserManagement,
path: TEST_SRC_DIR,
templates: [
'spec/app/account/change-password/change-password.component.spec.ts',
'spec/app/account/login-form/login-form.component.spec.ts',
'spec/app/account/register/register.component.spec.ts',
'spec/app/account/reset-password/init/reset-password-init.component.spec.ts',
'spec/app/account/reset-password/finish/reset-password-finish.component.spec.ts',
Expand All @@ -345,7 +369,7 @@ const vueFiles = {
]
},
{
condition: generator => generator.databaseType !== 'no' && generator.databaseType !== 'cassandra',
condition: generator => (generator.databaseType !== 'no' || generator.authenticationType === 'uaa') && generator.databaseType !== 'cassandra',
path: TEST_SRC_DIR,
templates: ['spec/app/admin/audits/audits.component.spec.ts']
},
Expand Down Expand Up @@ -389,7 +413,7 @@ const vueFiles = {
]
},
{
condition: generator => generator.protractorTests && generator.authenticationType !== 'oauth2',
condition: generator => generator.protractorTests && !generator.skipUserManagement,
path: TEST_SRC_DIR,
templates: [
'e2e/page-objects/password-page.ts',
Expand All @@ -406,7 +430,8 @@ function writeFiles() {
this.writeFilesToDisk(vueFiles, this, false, `${CLIENT_VUE_TEMPLATES_DIR}`);

if (!this.enableTranslation) {
utils.replaceTranslation(this, ['app/app.vue',
utils.replaceTranslation(this, [
'app/app.vue',
'app/core/home/home.vue',
'app/core/error/error.vue',
'app/core/jhi-footer/jhi-footer.vue',
Expand All @@ -418,13 +443,22 @@ function writeFiles() {
'app/admin/health/health-modal.vue',
'app/admin/logs/logs.vue',
'app/admin/metrics/metrics.vue',
'app/admin/metrics/metrics-modal.vue',
'app/admin/audits/audits.vue'
'app/admin/metrics/metrics-modal.vue'
]);
if ((this.databaseType !== 'no' || this.authenticationType === 'uaa') && this.databaseType !== 'cassandra') {
utils.replaceTranslation(this, [
'app/admin/audits/audits.vue'
]);
}
if (this.authenticationType !== 'oauth2') {
utils.replaceTranslation(this, ['app/account/change-password/change-password.vue',
'app/account/activate/activate.vue',
utils.replaceTranslation(this, [
'app/account/login-form/login-form.vue',
]);
}
if (!this.skipUserManagement) {
utils.replaceTranslation(this, [
'app/account/change-password/change-password.vue',
'app/account/activate/activate.vue',
'app/account/register/register.vue',
'app/account/reset-password/init/reset-password-init.vue',
'app/account/reset-password/finish/reset-password-finish.vue',
Expand All @@ -434,7 +468,7 @@ function writeFiles() {
'app/admin/user-management/user-management-edit.vue'
]);
}
if (this.authenticationType === 'session') {
if (this.authenticationType === 'session' && !this.skipUserManagement) {
utils.replaceTranslation(this, ['app/account/sessions/sessions.vue']);
}
if (this.applicationType === 'gateway' && this.serviceDiscoveryType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
<b-form-input id="password" type="password" name="password" v-model.trim="name" v-bind:placeholder="$t('login.form[\'password.placeholder\']')" <% if (!enableTranslation) { %>placeholder="Your password" <% } %>v-model="password">
</b-form-input>
</b-form-group>
<b-form-checkbox id="rememberMe" name="rememberMe" v-model="rememberMe" checked>
<b-form-checkbox id="rememberMe" name="rememberMe" v-model="rememberMe" checked <% if (authenticationType === 'session' && databaseType === 'no') { %> hidden<% } %>>
<span v-text="$t('login.form.rememberme')">Remember me</span>
</b-form-checkbox>
<div>
<b-button type="submit" variant="primary" v-text="$t('login.form.button')">Sign in</b-button>
</div>
</b-form>
<p></p>
<%_ if (!skipUserManagement) { _%>
<div>
<b-alert show variant="warning">
<b-link :to="'/reset/request'" class="alert-link" v-text="$t('login.password.forgot')">Did you forget your password?</b-link>
Expand All @@ -35,6 +36,7 @@
<b-link :to="'/register'" class="alert-link" v-text="$t('global.messages.info.register.link')">Register a new account</b-link>
</b-alert>
</div>
<%_ } _%>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<span v-text="$t('global.messages.info.authenticated.prefix')">If you want to </span>
<a class="alert-link" v-on:click="openLogin()" v-text="$t('global.messages.info.authenticated.link')">sign in</a><span v-html="$t('global.messages.info.authenticated.suffix')">, you can try the default accounts:<br/>- Administrator (login="admin" and password="admin") <br/>- User (login="user" and password="user").</span>
</div>
<%_ if (authenticationType !== 'oauth2') { _%>
<%_ if (!skipUserManagement) { _%>
<div class="alert alert-warning" v-if="!authenticated">
<span v-text="$t('global.messages.info.register.noaccount')">You don't have an account yet?</span>&nbsp;
<router-link class="alert-link" to="/register" v-text="$t('global.messages.info.register.link')">Register a new account</router-link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<font-awesome-icon icon="list" />
<span v-text="$t('global.menu.admin.configuration')">Configuration</span>
</b-dropdown-item>
<%_ if (databaseType !== 'no' && databaseType !== 'cassandra') { _%>
<%_ if ((databaseType !== 'no' || authenticationType === 'uaa') && databaseType !== 'cassandra') { _%>
<b-dropdown-item to="/admin/audits">
<font-awesome-icon icon="bell" />
<span v-text="$t('global.menu.admin.audits')">Audits</span>
Expand Down Expand Up @@ -114,7 +114,7 @@
Account
</span>
</span>
<%_ if (authenticationType !== 'oauth2') { _%>
<%_ if (!skipUserManagement) { _%>
<b-dropdown-item to="/account/settings" tag="b-dropdown-item" v-if="authenticated">
<font-awesome-icon icon="wrench" />
<span v-text="$t('global.menu.account.settings')">Settings</span>
Expand All @@ -124,7 +124,7 @@
<span v-text="$t('global.menu.account.password')">Password</span>
</b-dropdown-item>
<%_ } _%>
<%_ if (authenticationType === 'session') { _%>
<%_ if (authenticationType === 'session' && !skipUserManagement) { _%>
<b-dropdown-item to="/account/sessions" tag="b-dropdown-item" v-if="authenticated">
<font-awesome-icon icon="cloud" />
<span v-text="$t('global.menu.account.sessions')">Sessions</span>
Expand All @@ -138,7 +138,7 @@
<font-awesome-icon icon="sign-in-alt" />
<span v-text="$t('global.menu.account.login')">Sign in</span>
</b-dropdown-item>
<%_ if (authenticationType !== 'oauth2') { _%>
<%_ if (!skipUserManagement) { _%>
<b-dropdown-item to="/register" tag="b-dropdown-item" id="register" v-if="!authenticated">
<font-awesome-icon icon="user-plus" />
<span v-text="$t('global.menu.account.register')">Register</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import router from './router';
import * as config from './shared/config/config';
import * as bootstrapVueConfig from './shared/config/config-bootstrap-vue';
import JhiItemCountComponent from './shared/jhi-item-count.vue';
<%_ if ((databaseType !== 'no' || authenticationType === 'uaa') && databaseType !== 'cassandra') { _%>
import AuditsService from './admin/audits/audits.service';
<%_ } %>
import HealthService from './admin/health/health.service';
import MetricsService from './admin/metrics/metrics.service';
import LogsService from './admin/logs/logs.service';
<%_ if (authenticationType !== 'oauth2') { _%>
<%_ if (!skipUserManagement) { _%>
import ActivateService from './account/activate/activate.service';
import RegisterService from './account/register/register.service';
import UserManagementService from '@/admin/user-management/user-management.service';
Expand Down Expand Up @@ -82,12 +84,14 @@ new Vue({
router,
provide: {
loginService: () => loginService,
<%_ if (authenticationType !== 'oauth2') { _%>
<%_ if (!skipUserManagement) { _%>
activateService: () => new ActivateService(),
registerService: () => new RegisterService(),
userService: () => new UserManagementService(),
<%_ } %>
<%_ if ((databaseType !== 'no' || authenticationType === 'uaa') && databaseType !== 'cassandra') { _%>
auditsService: () => new AuditsService(),
<%_ } %>
healthService: () => new HealthService(),
<%_ if (applicationType === 'gateway' && serviceDiscoveryType) { %>
gatewayService: () => new GatewayService(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Component.registerHooks([
import Router from 'vue-router';
const Home = () => import('../core/home/home.vue');
const Error = () => import('../core/error/error.vue');
<%_ if (authenticationType !== 'oauth2') { _%>
<%_ if (!skipUserManagement) { _%>
const Register = () => import('../account/register/register.vue');
const Activate = () => import('../account/activate/activate.vue');
const ResetPasswordInit = () => import('../account/reset-password/init/reset-password-init.vue');
Expand All @@ -19,14 +19,16 @@ const <%= jhiPrefixCapitalized %>UserManagementComponent = () => import('../admi
const <%= jhiPrefixCapitalized %>UserManagementViewComponent = () => import('../admin/user-management/user-management-view.vue');
const <%= jhiPrefixCapitalized %>UserManagementEditComponent = () => import('../admin/user-management/user-management-edit.vue');
<%_ } _%>
<%_ if (authenticationType === 'session') { _%>
<%_ if (authenticationType === 'session' && !skipUserManagement) { _%>
const Sessions = () => import('../account/sessions/sessions.vue');
<%_ } _%>
const <%= jhiPrefixCapitalized %>ConfigurationComponent = () => import('../admin/configuration/configuration.vue');
const <%= jhiPrefixCapitalized %>DocsComponent = () => import('../admin/docs/docs.vue');
const <%= jhiPrefixCapitalized %>HealthComponent = () => import('../admin/health/health.vue');
const <%= jhiPrefixCapitalized %>LogsComponent = () => import('../admin/logs/logs.vue');
<%_ if ((databaseType !== 'no' || authenticationType === 'uaa') && databaseType !== 'cassandra') { _%>
const <%= jhiPrefixCapitalized %>AuditsComponent = () => import('../admin/audits/audits.vue');
<%_ } _%>
const <%= jhiPrefixCapitalized %>MetricsComponent = () => import('../admin/metrics/metrics.vue');
<%_ if (applicationType === 'gateway' && serviceDiscoveryType) { _%>
const <%= jhiPrefixCapitalized %>GatewayComponent = () => import('../admin/gateway/gateway.vue');
Expand Down Expand Up @@ -59,7 +61,7 @@ export default new Router({
name: 'NotFound',
component: Error,
meta: { error404: true }
}<% if (authenticationType !== 'oauth2') { %>,
}<%_ if (!skipUserManagement) { _%>,
{
path: '/register',
name: 'Register',
Expand Down Expand Up @@ -130,12 +132,13 @@ export default new Router({
component: <%= jhiPrefixCapitalized %>DocsComponent,
meta: { authorities: ['ROLE_ADMIN'] }
},
<%_ if ((databaseType !== 'no' || authenticationType === 'uaa') && databaseType !== 'cassandra') { _%>
{
path: '/admin/audits',
name: '<%= jhiPrefixCapitalized %>AuditsComponent',
component: <%= jhiPrefixCapitalized %>AuditsComponent,
meta: { authorities: ['ROLE_ADMIN'] }
},
},<% } %>
{
path: '/admin/<%= jhiPrefixDashed %>-health',
name: '<%= jhiPrefixCapitalized %>HealthComponent',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

User-agent: *
Disallow: /api/account
<%_ if (authenticationType !== 'oauth2') { _%>
<%_ if (!skipUserManagement) { _%>
Disallow: /api/account/change-password
Disallow: /api/account/sessions
<%_ } _%>
<%_ if (databaseType !== 'no' && databaseType !== 'cassandra') { _%>
<%_ if ((databaseType !== 'no' || authenticationType === 'uaa') && databaseType !== 'cassandra') { _%>
Disallow: /api/audits/
<%_ } _%>
Disallow: /api/logs/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {browser<%_ if (authenticationType === 'oauth2') { _%>, element, by<%_ }

import SignInPage from '../../page-objects/signin-page';
import NavBarPage from '../../page-objects/navbar-page';
<%_ if (authenticationType !== 'oauth2') { _%>
<%_ if (!skipUserManagement) { _%>
import RegisterPage from '../../page-objects/register-page';
import PasswordPage from '../../page-objects/password-page';
import SettingsPage from '../../page-objects/settings-page';
Expand All @@ -21,7 +21,7 @@ describe('Account', () => {

let navBarPage: NavBarPage = new NavBarPage();
let signInPage: SignInPage;
<%_ if (authenticationType !== 'oauth2') { _%>
<%_ if (!skipUserManagement) { _%>
let passwordPage: PasswordPage;
let settingsPage: SettingsPage;
let registerPage: RegisterPage;
Expand Down Expand Up @@ -104,7 +104,7 @@ describe('Account', () => {
});
});

<%_ if (authenticationType !== 'oauth2') { _%>
<%_ if (!skipUserManagement) { _%>
describe('User Registration Flow', () => {

before(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('Administration', () => {
await navBarPage.autoSignOut();
});

<%_ if (authenticationType !== 'oauth2') { _%>
<%_ if (!skipUserManagement) { _%>
it('should load user management', async () => {
const userManagementPage = await navBarPage.getUserManagementPage();
expect(await userManagementPage.title.isDisplayed()).to.be.true;
Expand Down Expand Up @@ -54,7 +54,7 @@ describe('Administration', () => {
expect(await configurationsPage.title.getText()).not.to.be.empty;
});

<%_ if (databaseType !== 'no' && databaseType !== 'cassandra') { _%>
<%_ if ((databaseType !== 'no' || authenticationType === 'uaa') && databaseType !== 'cassandra') { _%>
it('should load audits', async () => {
const auditsPage = await navBarPage.getAuditsPage();
expect(await auditsPage.title.isDisplayed()).to.be.true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default class NavBarPage {
await click(this.selector.$(`.dropdown-item[href="/account/${item}"]`));
}

<%_ if (authenticationType !== 'oauth2') { _%>
<%_ if (!skipUserManagement) { _%>
async getPasswordPage() {
await this.clickOnAccountMenuItem('password');

Expand Down
Loading

0 comments on commit 0d0225f

Please sign in to comment.