Commit bbc15dcc authored by wangqinghua's avatar wangqinghua

init

parent cff03473
This diff is collapsed.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Page Not Found</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="favicon.ico" />
<style>
* {
line-height: 1.2;
margin: 0;
}
html {
color: #888;
display: table;
font-family: sans-serif;
height: 100%;
text-align: center;
width: 100%;
}
body {
display: table-cell;
vertical-align: middle;
margin: 2em auto;
}
h1 {
color: #555;
font-size: 2em;
font-weight: 400;
}
p {
margin: 0 auto;
width: 280px;
}
@media only screen and (max-width: 280px) {
body, p {
width: 95%;
}
h1 {
font-size: 1.5em;
margin: 0 0 0.3em;
}
}
</style>
</head>
<body>
<h1>Page Not Found</h1>
<p>Sorry, but the page you were trying to view does not exist.</p>
</body>
</html>
<!-- IE needs 512+ bytes: http://blogs.msdn.com/b/ieinternals/archive/2010/08/19/http-error-pages-in-internet-explorer.aspx -->
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { errorRoute, navbarRoute } from './layouts';
import { DEBUG_INFO_ENABLED } from './app.constants';
const LAYOUT_ROUTES = [
navbarRoute,
...errorRoute
];
@NgModule({
imports: [
RouterModule.forRoot(LAYOUT_ROUTES, { useHash: true , enableTracing: DEBUG_INFO_ENABLED })
],
exports: [
RouterModule
]
})
export class BootappAppRoutingModule {}
// These constants are injected via webpack environment variables.
// You can add more variables in webpack.common.js or in profile specific webpack.<dev|prod>.js files.
// If you change the values in the webpack config files, you need to re run webpack to update the application
export const VERSION = process.env.VERSION;
export const DEBUG_INFO_ENABLED: boolean = !!process.env.DEBUG_INFO_ENABLED;
export const SERVER_API_URL = '/api/';
export const BUILD_TIMESTAMP = process.env.BUILD_TIMESTAMP;
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { ProdConfig } from './blocks/config/prod.config';
import { BootappAppModule } from './app.module';
ProdConfig();
if (module['hot']) {
module['hot'].accept();
}
platformBrowserDynamic().bootstrapModule(BootappAppModule)
.then((success) => console.log(`Application started`))
.catch((err) => console.error(err));
import './vendor.ts';
import { NgModule, Injector } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { Ng2Webstorage, LocalStorageService, SessionStorageService } from 'ngx-webstorage';
import { JhiEventManager } from 'ng-jhipster';
import { AuthInterceptor } from './blocks/interceptor/auth.interceptor';
import { AuthExpiredInterceptor } from './blocks/interceptor/auth-expired.interceptor';
import { ErrorHandlerInterceptor } from './blocks/interceptor/errorhandler.interceptor';
import { NotificationInterceptor } from './blocks/interceptor/notification.interceptor';
import { BootappSharedModule, UserRouteAccessService } from './shared';
import { BootappAppRoutingModule} from './app-routing.module';
import { BootappHomeModule } from './home/home.module';
import { PaginationConfig } from './blocks/config/uib-pagination.config';
import { FileUploadModule } from 'ng2-file-upload';
import { CommonModule } from '@angular/common';
// jhipster-needle-angular-add-module-import JHipster will add new module here
import {
JhiMainComponent,
NavbarComponent,
FooterComponent,
ProfileService,
PageRibbonComponent,
ErrorComponent
} from './layouts';
@NgModule({
imports: [
BrowserModule,
BootappAppRoutingModule,
Ng2Webstorage.forRoot({ prefix: 'jhi', separator: '-'}),
BootappSharedModule,
BootappHomeModule,
FileUploadModule,
CommonModule,
// jhipster-needle-angular-add-module JHipster will add new module here
],
declarations: [
JhiMainComponent,
NavbarComponent,
ErrorComponent,
PageRibbonComponent,
FooterComponent
],
providers: [
ProfileService,
PaginationConfig,
UserRouteAccessService,
{
provide: HTTP_INTERCEPTORS,
useClass: AuthInterceptor,
multi: true,
deps: [
LocalStorageService,
SessionStorageService
]
},
{
provide: HTTP_INTERCEPTORS,
useClass: AuthExpiredInterceptor,
multi: true,
deps: [
Injector
]
},
{
provide: HTTP_INTERCEPTORS,
useClass: ErrorHandlerInterceptor,
multi: true,
deps: [
JhiEventManager
]
},
{
provide: HTTP_INTERCEPTORS,
useClass: NotificationInterceptor,
multi: true,
deps: [
Injector
]
}
],
bootstrap: [ JhiMainComponent ]
})
export class BootappAppModule {}
import { Route } from '@angular/router';
import { NavbarComponent } from './layouts';
export const navbarRoute: Route = {
path: '',
component: NavbarComponent,
outlet: 'navbar'
};
import { enableProdMode } from '@angular/core';
import { DEBUG_INFO_ENABLED } from '../../app.constants';
export function ProdConfig() {
// disable debug data on prod profile to improve performance
if (!DEBUG_INFO_ENABLED) {
enableProdMode();
}
}
import { ITEMS_PER_PAGE } from '../../shared';
import { Injectable } from '@angular/core';
import { NgbPaginationConfig} from '@ng-bootstrap/ng-bootstrap';
@Injectable()
export class PaginationConfig {
// tslint:disable-next-line: no-unused-variable
constructor(private config: NgbPaginationConfig) {
config.boundaryLinks = true;
config.maxSize = 5;
config.pageSize = ITEMS_PER_PAGE;
config.size = 'sm';
}
}
import { Injector } from '@angular/core';
import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent, HttpErrorResponse } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/do';
import { LoginService } from '../../shared/login/login.service';
export class AuthExpiredInterceptor implements HttpInterceptor {
constructor(
private injector: Injector
) {}
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
return next.handle(request).do((event: HttpEvent<any>) => {}, (err: any) => {
if (err instanceof HttpErrorResponse) {
if (err.status === 401) {
const loginService: LoginService = this.injector.get(LoginService);
loginService.logout();
}
}
});
}
}
import { Observable } from 'rxjs/Observable';
import { LocalStorageService, SessionStorageService } from 'ngx-webstorage';
import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent } from '@angular/common/http';
import { SERVER_API_URL } from '../../app.constants';
export class AuthInterceptor implements HttpInterceptor {
constructor(
private localStorage: LocalStorageService,
private sessionStorage: SessionStorageService
) {
}
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
if (!request || !request.url || (/^http/.test(request.url) && !(SERVER_API_URL && request.url.startsWith(SERVER_API_URL)))) {
return next.handle(request);
}
const token = this.localStorage.retrieve('authenticationToken') || this.sessionStorage.retrieve('authenticationToken');
if (!!token) {
request = request.clone({
setHeaders: {
Authorization: 'Bearer ' + token
}
});
}
return next.handle(request);
}
}
import { JhiEventManager } from 'ng-jhipster';
import { HttpInterceptor, HttpRequest, HttpErrorResponse, HttpHandler, HttpEvent } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/do';
export class ErrorHandlerInterceptor implements HttpInterceptor {
constructor(private eventManager: JhiEventManager) {
}
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
return next.handle(request).do((event: HttpEvent<any>) => {}, (err: any) => {
if (err instanceof HttpErrorResponse) {
if (!(err.status === 401 && (err.message === '' || (err.url && err.url.indexOf('/api/account') === 0)))) {
if (this.eventManager !== undefined) {
this.eventManager.broadcast({name: 'bootappApp.httpError', content: err});
}
}
}
});
}
}
import { JhiAlertService } from 'ng-jhipster';
import { HttpInterceptor, HttpRequest, HttpResponse, HttpHandler, HttpEvent } from '@angular/common/http';
import { Injector } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/do';
export class NotificationInterceptor implements HttpInterceptor {
private alertService: JhiAlertService;
// tslint:disable-next-line: no-unused-variable
constructor(private injector: Injector) {
setTimeout(() => this.alertService = injector.get(JhiAlertService));
}
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
return next.handle(request).do((event: HttpEvent<any>) => {
if (event instanceof HttpResponse) {
const arr = event.headers.keys();
let alert = null;
arr.forEach((entry) => {
if (entry.endsWith('app-alert')) {
alert = event.headers.get(entry);
}
});
if (alert) {
if (typeof alert === 'string') {
if (this.alertService) {
this.alertService.success(alert, null, null);
}
}
}
}
}, (err: any) => {});
}
}
import { Component, OnInit } from '@angular/core';
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
import { JhiEventManager } from 'ng-jhipster';
import { Account, LoginModalService, Principal } from '../shared';
@Component({
selector: 'jhi-home',
templateUrl: './home.component.html',
styleUrls: [
'home.css'
]
})
export class HomeComponent implements OnInit {
account: Account;
modalRef: NgbModalRef;
constructor(
private principal: Principal,
private loginModalService: LoginModalService,
private eventManager: JhiEventManager
) {
}
ngOnInit() {
// this.principal.identity().then((account) => {
// this.account = account;
// });
// this.registerAuthenticationSuccess();
}
registerAuthenticationSuccess() {
this.eventManager.subscribe('authenticationSuccess', (message) => {
this.principal.identity().then((account) => {
this.account = account;
});
});
}
isAuthenticated() {
return this.principal.isAuthenticated();
}
login() {
this.modalRef = this.loginModalService.open();
}
}
/* ==========================================================================
Main page styles
========================================================================== */
.hipster {
display: inline-block;
width: 347px;
height: 497px;
background: url("../../content/images/hipster.png") no-repeat center top;
background-size: contain;
}
/* wait autoprefixer update to allow simple generation of high pixel density media query */
@media
only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and ( min--moz-device-pixel-ratio: 2),
only screen and ( -o-min-device-pixel-ratio: 2/1),
only screen and ( min-device-pixel-ratio: 2),
only screen and ( min-resolution: 192dpi),
only screen and ( min-resolution: 2dppx) {
.hipster {
background: url("../../content/images/hipster2x.png") no-repeat center top;
background-size: contain;
}
}
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { RouterModule } from '@angular/router';
import { BootappSharedModule } from '../shared';
import { HOME_ROUTE, HomeComponent } from './';
@NgModule({
imports: [
BootappSharedModule,
RouterModule.forChild([ HOME_ROUTE ])
],
declarations: [
HomeComponent,
],
entryComponents: [
],
providers: [
],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class BootappHomeModule {}
import { Route } from '@angular/router';
import { HomeComponent } from './';
export const HOME_ROUTE: Route = {
path: '',
component: HomeComponent,
data: {
authorities: [],
pageTitle: 'web'
}
};
export * from './home.component';
export * from './home.route';
export * from './home.module';
<div>
<div class="row">
<div class="col-md-4">
<span class="hipster img-fluid rounded"></span>
</div>
<div class="col-md-8">
<h1>Error Page!</h1>
<div [hidden]="!errorMessage">
<div class="alert alert-danger">{{errorMessage}}
</div>
</div>
<div [hidden]="!error403" class="alert alert-danger">You are not authorized to access this page.
</div>
</div>
</div>
</div>
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
@Component({
selector: 'jhi-error',
templateUrl: './error.component.html'
})
export class ErrorComponent implements OnInit {
errorMessage: string;
error403: boolean;
constructor(
private route: ActivatedRoute
) {
}
ngOnInit() {
this.route.data.subscribe((routeData) => {
if (routeData.error403) {
this.error403 = routeData.error403;
}
if (routeData.errorMessage) {
this.errorMessage = routeData.errorMessage;
}
});
}
}
import { Routes } from '@angular/router';
import { ErrorComponent } from './error.component';
export const errorRoute: Routes = [
{
path: 'error',
component: ErrorComponent,
data: {
authorities: [],
pageTitle: 'Error page!'
},
},
{
path: 'accessdenied',
component: ErrorComponent,
data: {
authorities: [],
pageTitle: 'Error page!',
error403: true
},
}
];
import { Component } from '@angular/core';
@Component({
selector: 'jhi-footer',
templateUrl: './footer.component.html'
})
export class FooterComponent {}
export * from './error/error.component';
export * from './error/error.route';
export * from './main/main.component';
export * from './footer/footer.component';
export * from './navbar/navbar.component';
export * from './navbar/navbar.route';
export * from './profiles/page-ribbon.component';
export * from './profiles/profile.service';
export * from './profiles/profile-info.model';
<jhi-page-ribbon></jhi-page-ribbon>
<div>
<router-outlet name="navbar"></router-outlet>
</div>
<div class="container-fluid">
<div class="card jh-card">
<router-outlet></router-outlet>
<router-outlet name="popup"></router-outlet>
</div>
<jhi-footer></jhi-footer>
</div>
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRouteSnapshot, NavigationEnd } from '@angular/router';
import { Title } from '@angular/platform-browser';
@Component({
selector: 'jhi-main',
templateUrl: './main.component.html'
})
export class JhiMainComponent implements OnInit {
constructor(
private titleService: Title,
private router: Router
) {}
private getPageTitle(routeSnapshot: ActivatedRouteSnapshot) {
let title: string = (routeSnapshot.data && routeSnapshot.data['pageTitle']) ? routeSnapshot.data['pageTitle'] : 'bootappApp';
if (routeSnapshot.firstChild) {
title = this.getPageTitle(routeSnapshot.firstChild) || title;
}
return title;
}
ngOnInit() {
this.router.events.subscribe((event) => {
if (event instanceof NavigationEnd) {
this.titleService.setTitle(this.getPageTitle(this.router.routerState.snapshot.root));
}
});
}
}
<nav class="navbar navbar-dark navbar-expand-md jh-navbar">
<div class="navbar-collapse collapse" id="navbarResponsive" [ngbCollapse]="isNavbarCollapsed" [ngSwitch]="isAuthenticated()">
<ul class="navbar-nav ml-auto">
<li class="nav-item" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}">
<a class="nav-link" routerLink="/" (click)="collapseNavbar()">
<span>
<i class="fa fa-home" aria-hidden="true"></i>
<span>首页</span>
</span>
</a>
</li>
<li *ngSwitchCase="true" ngbDropdown class="nav-item dropdown pointer" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}">
</li>
<li ngbDropdown class="nav-item dropdown pointer" placement="bottom-right" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}">
<a class="nav-link dropdown-toggle" ngbDropdownToggle href="javascript:void(0);" id="account-menu">
<span *ngIf="!getImageUrl()">
<i class="fa fa-user" aria-hidden="true"></i>
<span>
账户
</span>
</span>
<span *ngIf="getImageUrl()">
<img [src]="getImageUrl()" class="profile-image img-circle" alt="Avatar">
</span>
</a>
<ul class="dropdown-menu" ngbDropdownMenu>
<li *ngSwitchCase="true">
<a class="dropdown-item" routerLink="password" routerLinkActive="active" (click)="collapseNavbar()">
<i class="fa fa-fw fa-clock-o" aria-hidden="true"></i>
<span>密码</span>
</a>
</li>
<li *ngSwitchCase="true">
<a class="dropdown-item" (click)="logout()" id="logout">
<i class="fa fa-fw fa-sign-out" aria-hidden="true"></i>
<span>退出</span>
</a>
</li>
<li *ngSwitchCase="false">
<a class="dropdown-item" (click)="login()" id="login">
<i class="fa fa-fw fa-sign-in" aria-hidden="true"></i>
<span>登录</span>
</a>
</li>
</ul>
</li>
</ul>
</div>
</nav>
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
import { ProfileService } from '../profiles/profile.service';
import { Principal, LoginModalService, LoginService } from '../../shared';
import { VERSION } from '../../app.constants';
@Component({
selector: 'jhi-navbar',
templateUrl: './navbar.component.html',
styleUrls: [
'navbar.css'
]
})
export class NavbarComponent implements OnInit {
inProduction: boolean;
isNavbarCollapsed: boolean;
languages: any[];
swaggerEnabled: boolean;
modalRef: NgbModalRef;
version: string;
constructor(
private loginService: LoginService,
private principal: Principal,
private loginModalService: LoginModalService,
private profileService: ProfileService,
private router: Router
) {
this.version = VERSION ? 'v' + VERSION : '';
this.isNavbarCollapsed = true;
}
ngOnInit() {
// this.profileService.getProfileInfo().then((profileInfo) => {
// this.inProduction = profileInfo.inProduction;
// this.swaggerEnabled = profileInfo.swaggerEnabled;
// });
}
collapseNavbar() {
this.isNavbarCollapsed = true;
}
isAuthenticated() {
return this.principal.isAuthenticated();
}
login() {
this.modalRef = this.loginModalService.open();
}
logout() {
this.collapseNavbar();
this.loginService.logout();
this.router.navigate(['']);
}
toggleNavbar() {
this.isNavbarCollapsed = !this.isNavbarCollapsed;
}
getImageUrl() {
return this.isAuthenticated() ? this.principal.getImageUrl() : null;
}
}
/* ==========================================================================
Navbar
========================================================================== */
.navbar-version {
font-size: 10px;
color: #ccc
}
.jh-navbar {
background-color: #353d47;
padding: .2em 1em;
}
.jh-navbar .profile-image {
margin: -10px 0px;
height: 40px;
width: 40px;
border-radius: 50%;
}
.jh-navbar .dropdown-item.active, .jh-navbar .dropdown-item.active:focus, .jh-navbar .dropdown-item.active:hover {
background-color: #353d47;
}
.jh-navbar .dropdown-toggle::after {
margin-left: 0.15em;
}
.jh-navbar ul.navbar-nav {
padding: 0.5em;
}
.jh-navbar .navbar-nav .nav-item {
margin-left: 1.5rem;
}
.jh-navbar a.nav-link {
font-weight: 400;
}
.jh-navbar .jh-navbar-toggler {
color: #ccc;
font-size: 1.5em;
padding: 10px;
}
.jh-navbar .jh-navbar-toggler:hover {
color: #fff;
}
@media screen and (min-width: 768px) {
.jh-navbar-toggler {
display: none;
}
}
@media screen and (max-width: 992px) {
.jh-logo-container {
width: 100%;
}
}
.navbar-title {
display: inline-block;
vertical-align: middle;
}
/* ==========================================================================
Logo styles
========================================================================== */
.navbar-brand.logo {
padding: 5px 15px;
}
.logo .logo-img {
height: 45px;
display: inline-block;
vertical-align: middle;
width: 70px;
}
.logo-img {
height: 100%;
background: url("../../../content/images/logo-jhipster.png") no-repeat center center;
background-size: contain;
width: 100%;
}
import { Route } from '@angular/router';
import { NavbarComponent } from './navbar.component';
export const navbarRoute: Route = {
path: '',
component: NavbarComponent,
outlet: 'navbar'
};
import { Component, OnInit } from '@angular/core';
import { ProfileService } from './profile.service';
import { ProfileInfo } from './profile-info.model';
@Component({
selector: 'jhi-page-ribbon',
template: ``,
styleUrls: [
'page-ribbon.css'
]
})
export class PageRibbonComponent implements OnInit {
profileInfo: ProfileInfo;
ribbonEnv: string;
constructor(private profileService: ProfileService) {}
ngOnInit() {
// this.profileService.getProfileInfo().then((profileInfo) => {
// this.profileInfo = profileInfo;
// this.ribbonEnv = profileInfo.ribbonEnv;
// });
}
}
/* ==========================================================================
Developement Ribbon
========================================================================== */
.ribbon {
background-color: rgba(170, 0, 0, 0.5);
left: -3.5em;
moz-transform: rotate(-45deg);
ms-transform: rotate(-45deg);
o-transform: rotate(-45deg);
webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
overflow: hidden;
position: absolute;
top: 40px;
white-space: nowrap;
width: 15em;
z-index: 9999;
pointer-events: none;
opacity: 0.75;
}
.ribbon a {
color: #fff;
display: block;
font-weight: 400;
margin: 1px 0;
padding: 10px 50px;
text-align: center;
text-decoration: none;
text-shadow: 0 0 5px #444;
pointer-events: none;
}
export class ProfileInfo {
activeProfiles: string[];
ribbonEnv: string;
inProduction: boolean;
swaggerEnabled: boolean;
}
import { Injectable } from '@angular/core';
import { HttpClient, HttpResponse } from '@angular/common/http';
import { SERVER_API_URL } from '../../app.constants';
import { ProfileInfo } from './profile-info.model';
@Injectable()
export class ProfileService {
private profileInfoUrl = SERVER_API_URL + 'api/profile-info';
private profileInfo: Promise<ProfileInfo>;
constructor(private http: HttpClient) { }
getProfileInfo(): Promise<ProfileInfo> {
if (!this.profileInfo) {
this.profileInfo = this.http.get<ProfileInfo>(this.profileInfoUrl, { observe: 'response' })
.map((res: HttpResponse<ProfileInfo>) => {
const data = res.body;
const pi = new ProfileInfo();
pi.activeProfiles = data.activeProfiles;
pi.ribbonEnv = data.ribbonEnv;
pi.inProduction = data.activeProfiles.includes('prod') ;
pi.swaggerEnabled = data.activeProfiles.includes('swagger');
return pi;
}).toPromise();
}
return this.profileInfo;
}
}
/**
* This file includes polyfills needed by Angular and is loaded before the app.
* You can add your own extra polyfills to this file.
*
* This file is divided into 2 sections:
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
* file.
*
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
*
* Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
*/
/***************************************************************************************************
* BROWSER POLYFILLS
*/
/** IE9, IE10 and IE11 requires all of the following polyfills. **/
import 'core-js/es6/symbol';
import 'core-js/es6/object';
import 'core-js/es6/function';
import 'core-js/es6/parse-int';
import 'core-js/es6/parse-float';
import 'core-js/es6/number';
import 'core-js/es6/math';
import 'core-js/es6/string';
import 'core-js/es6/date';
import 'core-js/es6/array';
import 'core-js/es7/array';
import 'core-js/es6/regexp';
import 'core-js/es6/map';
import 'core-js/es6/weak-map';
import 'core-js/es6/set';
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
// import 'classlist.js'; // Run `npm install --save classlist.js`.
/** Evergreen browsers require these. **/
import 'core-js/es6/reflect';
import 'core-js/es7/reflect';
/**
* Required to support Web Animations `@angular/animation`.
* Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation
**/
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
/***************************************************************************************************
* Zone JS is required by Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.
/***************************************************************************************************
* APPLICATION IMPORTS
*/
/**
* Date, currency, decimal and percent pipes.
* Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10
*/
// import 'intl'; // Run `npm install --save intl`.
/**
* Need to import at least one locale-data with intl.
*/
// import 'intl/locale-data/jsonp/en';
require('../manifest.webapp');
import { Component, OnDestroy } from '@angular/core';
import { JhiEventManager, JhiAlertService } from 'ng-jhipster';
import { Subscription } from 'rxjs/Subscription';
@Component({
selector: 'jhi-alert-error',
template: `
<div class="alerts" role="alert">
<div *ngFor="let alert of alerts" [ngClass]="{\'alert.position\': true, \'toast\': alert.toast}">
<ngb-alert *ngIf="alert && alert.type && alert.msg" [type]="alert.type" (close)="alert.close(alerts)">
<pre [innerHTML]="alert.msg"></pre>
</ngb-alert>
</div>
</div>`
})
export class JhiAlertErrorComponent implements OnDestroy {
alerts: any[];
cleanHttpErrorListener: Subscription;
// tslint:disable-next-line: no-unused-variable
constructor(private alertService: JhiAlertService, private eventManager: JhiEventManager) {
this.alerts = [];
this.cleanHttpErrorListener = eventManager.subscribe('bootappApp.httpError', (response) => {
let i;
const httpErrorResponse = response.content;
switch (httpErrorResponse.status) {
// connection refused, server not reachable
case 0:
this.addErrorAlert('Server not reachable', 'error.server.not.reachable');
break;
case 400:
const arr = httpErrorResponse.headers.keys();
let errorHeader = null;
let entityKey = null;
arr.forEach((entry) => {
if (entry.endsWith('app-error')) {
errorHeader = httpErrorResponse.headers.get(entry);
} else if (entry.endsWith('app-params')) {
entityKey = httpErrorResponse.headers.get(entry);
}
});
if (errorHeader) {
const entityName = entityKey;
this.addErrorAlert(errorHeader, errorHeader, { entityName });
} else if (httpErrorResponse.error !== '' && httpErrorResponse.error.fieldErrors) {
const fieldErrors = httpErrorResponse.error.fieldErrors;
for (i = 0; i < fieldErrors.length; i++) {
const fieldError = fieldErrors[i];
// convert 'something[14].other[4].id' to 'something[].other[].id' so translations can be written to it
const convertedField = fieldError.field.replace(/\[\d*\]/g, '[]');
const fieldName = convertedField.charAt(0).toUpperCase() +
convertedField.slice(1);
this.addErrorAlert(
'Error on field "' + fieldName + '"', 'error.' + fieldError.message, { fieldName });
}
} else if (httpErrorResponse.error !== '' && httpErrorResponse.error.message) {
this.addErrorAlert(httpErrorResponse.error.message, httpErrorResponse.error.message, httpErrorResponse.error.params);
} else {
this.addErrorAlert(httpErrorResponse.error);
}
break;
case 404:
this.addErrorAlert('Not found', 'error.url.not.found');
break;
default:
if (httpErrorResponse.error !== '' && httpErrorResponse.error.message) {
this.addErrorAlert(httpErrorResponse.error.message);
} else {
this.addErrorAlert(httpErrorResponse.error);
}
}
});
}
ngOnDestroy() {
if (this.cleanHttpErrorListener !== undefined && this.cleanHttpErrorListener !== null) {
this.eventManager.destroy(this.cleanHttpErrorListener);
this.alerts = [];
}
}
addErrorAlert(message, key?, data?) {
this.alerts.push(
this.alertService.addAlert(
{
type: 'danger',
msg: message,
timeout: 5000,
toast: this.alertService.isToast(),
scoped: true
},
this.alerts
)
);
}
}
import { Component, OnDestroy, OnInit } from '@angular/core';
import { JhiAlertService } from 'ng-jhipster';
@Component({
selector: 'jhi-alert',
template: `
<div class="alerts" role="alert">
<div *ngFor="let alert of alerts" [ngClass]="{\'alert.position\': true, \'toast\': alert.toast}">
<ngb-alert *ngIf="alert && alert.type && alert.msg" [type]="alert.type" (close)="alert.close(alerts)">
<pre [innerHTML]="alert.msg"></pre>
</ngb-alert>
</div>
</div>`
})
export class JhiAlertComponent implements OnInit, OnDestroy {
alerts: any[];
constructor(private alertService: JhiAlertService) { }
ngOnInit() {
this.alerts = this.alertService.get();
}
ngOnDestroy() {
this.alerts = [];
}
}
import { Injectable } from '@angular/core';
import { HttpClient, HttpResponse } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import { SERVER_API_URL } from '../../app.constants';
@Injectable()
export class AccountService {
constructor(private http: HttpClient) { }
get(): Observable<HttpResponse<Account>> {
return this.http.get<Account>(SERVER_API_URL + '', {observe : 'response'});
}
save(account: any): Observable<HttpResponse<any>> {
return this.http.post(SERVER_API_URL + '', account, {observe: 'response'});
}
}
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import { LocalStorageService, SessionStorageService } from 'ngx-webstorage';
import { SERVER_API_URL } from '../../app.constants';
@Injectable()
export class AuthServerProvider {
constructor(
private http: HttpClient,
private $localStorage: LocalStorageService,
private $sessionStorage: SessionStorageService
) {}
getToken() {
return this.$localStorage.retrieve('authenticationToken') || this.$sessionStorage.retrieve('authenticationToken');
}
login(credentials): Observable<any> {
const data = {
username: credentials.username,
password: credentials.password,
rememberMe: credentials.rememberMe
};
return this.http.post(SERVER_API_URL + 'api/authenticate', data, {observe : 'response'}).map(authenticateSuccess.bind(this));
function authenticateSuccess(resp) {
const bearerToken = resp.headers.get('Authorization');
if (bearerToken && bearerToken.slice(0, 7) === 'Bearer ') {
const jwt = bearerToken.slice(7, bearerToken.length);
this.storeAuthenticationToken(jwt, credentials.rememberMe);
return jwt;
}
}
}
loginWithToken(jwt, rememberMe) {
if (jwt) {
this.storeAuthenticationToken(jwt, rememberMe);
return Promise.resolve(jwt);
} else {
return Promise.reject('auth-jwt-service Promise reject'); // Put appropriate error message here
}
}
storeAuthenticationToken(jwt, rememberMe) {
if (rememberMe) {
this.$localStorage.store('authenticationToken', jwt);
} else {
this.$sessionStorage.store('authenticationToken', jwt);
}
}
logout(): Observable<any> {
return new Observable((observer) => {
this.$localStorage.clear('authenticationToken');
this.$sessionStorage.clear('authenticationToken');
observer.complete();
});
}
}
import { Injectable } from '@angular/core';
import { CookieService } from 'ngx-cookie';
@Injectable()
export class CSRFService {
constructor(private cookieService: CookieService) {}
getCSRF(name?: string) {
name = `${name ? name : 'XSRF-TOKEN'}`;
return this.cookieService.get(name);
}
}
import { Directive, Input, TemplateRef, ViewContainerRef } from '@angular/core';
import { Principal } from './principal.service';
/**
* @whatItDoes Conditionally includes an HTML element if current user has any
* of the authorities passed as the `expression`.
*
* @howToUse
* ```
* <some-element *jhiHasAnyAuthority="'ROLE_ADMIN'">...</some-element>
*
* <some-element *jhiHasAnyAuthority="['ROLE_ADMIN', 'ROLE_USER']">...</some-element>
* ```
*/
@Directive({
selector: '[jhiHasAnyAuthority]'
})
export class HasAnyAuthorityDirective {
private authorities: string[];
constructor(private principal: Principal, private templateRef: TemplateRef<any>, private viewContainerRef: ViewContainerRef) {
}
@Input()
set jhiHasAnyAuthority(value: string|string[]) {
this.authorities = typeof value === 'string' ? [ <string> value ] : <string[]> value;
this.updateView();
// Get notified each time authentication state changes.
this.principal.getAuthenticationState().subscribe((identity) => this.updateView());
}
private updateView(): void {
this.principal.hasAnyAuthority(this.authorities).then((result) => {
this.viewContainerRef.clear();
if (result) {
this.viewContainerRef.createEmbeddedView(this.templateRef);
}
});
}
}
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Subject } from 'rxjs/Subject';
import { AccountService } from './account.service';
@Injectable()
export class Principal {
private userIdentity: any;
private authenticated = false;
private authenticationState = new Subject<any>();
constructor(
private account: AccountService
) {}
authenticate(identity) {
this.userIdentity = identity;
this.authenticated = identity !== null;
this.authenticationState.next(this.userIdentity);
}
hasAnyAuthority(authorities: string[]): Promise<boolean> {
return Promise.resolve(this.hasAnyAuthorityDirect(authorities));
}
hasAnyAuthorityDirect(authorities: string[]): boolean {
if (!this.authenticated || !this.userIdentity || !this.userIdentity.authorities) {
return false;
}
for (let i = 0; i < authorities.length; i++) {
if (this.userIdentity.authorities.includes(authorities[i])) {
return true;
}
}
return false;
}
hasAuthority(authority: string): Promise<boolean> {
if (!this.authenticated) {
return Promise.resolve(false);
}
return this.identity().then((id) => {
return Promise.resolve(id.authorities && id.authorities.includes(authority));
}, () => {
return Promise.resolve(false);
});
}
identity(force?: boolean): Promise<any> {
if (force === true) {
this.userIdentity = undefined;
}
// check and see if we have retrieved the userIdentity data from the server.
// if we have, reuse it by immediately resolving
if (this.userIdentity) {
return Promise.resolve(this.userIdentity);
}
// retrieve the userIdentity data from the server, update the identity object, and then resolve.
return this.account.get().toPromise().then((response) => {
console.log(response);
const account = response.body;
if (account) {
this.userIdentity = account;
if (this.userIdentity.authorities.length > 0) {
this.authenticated = true;
}else {
this.authenticated = false;
}
} else {
this.userIdentity = null;
this.authenticated = false;
}
this.authenticationState.next(this.userIdentity);
return this.userIdentity;
}).catch((err) => {
this.userIdentity = null;
this.authenticated = false;
this.authenticationState.next(this.userIdentity);
return null;
});
}
isAuthenticated(): boolean {
return this.authenticated;
}
isIdentityResolved(): boolean {
return this.userIdentity !== undefined;
}
getAuthenticationState(): Observable<any> {
return this.authenticationState.asObservable();
}
getImageUrl(): String {
return this.isIdentityResolved() ? this.userIdentity.imageUrl : null;
}
}
import { Injectable } from '@angular/core';
import { SessionStorageService } from 'ngx-webstorage';
@Injectable()
export class StateStorageService {
constructor(
private $sessionStorage: SessionStorageService
) {}
getPreviousState() {
return this.$sessionStorage.retrieve('previousState');
}
resetPreviousState() {
this.$sessionStorage.clear('previousState');
}
storePreviousState(previousStateName, previousStateParams) {
const previousState = { 'name': previousStateName, 'params': previousStateParams };
this.$sessionStorage.store('previousState', previousState);
}
getDestinationState() {
return this.$sessionStorage.retrieve('destinationState');
}
storeUrl(url: string) {
this.$sessionStorage.store('previousUrl', url);
}
getUrl() {
return this.$sessionStorage.retrieve('previousUrl');
}
storeDestinationState(destinationState, destinationStateParams, fromState) {
const destinationInfo = {
'destination': {
'name': destinationState.name,
'data': destinationState.data,
},
'params': destinationStateParams,
'from': {
'name': fromState.name,
}
};
this.$sessionStorage.store('destinationState', destinationInfo);
}
}
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from '@angular/router';
import { Principal } from '../';
import { LoginModalService } from '../login/login-modal.service';
import { StateStorageService } from './state-storage.service';
@Injectable()
export class UserRouteAccessService implements CanActivate {
constructor(private router: Router,
private loginModalService: LoginModalService,
private principal: Principal,
private stateStorageService: StateStorageService) {
}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean | Promise<boolean> {
const authorities = route.data['authorities'];
// We need to call the checkLogin / and so the principal.identity() function, to ensure,
// that the client has a principal too, if they already logged in by the server.
// This could happen on a page refresh.
return this.checkLogin(authorities, state.url);
}
checkLogin(authorities: string[], url: string): Promise<boolean> {
const principal = this.principal;
return Promise.resolve(principal.identity().then((account) => {
if (!authorities || authorities.length === 0) {
return true;
}
if (account) {
return principal.hasAnyAuthority(authorities).then((response) => {
if (response) {
return true;
}
return false;
});
}
this.stateStorageService.storeUrl(url);
this.router.navigate(['accessdenied']).then(() => {
// only show the login dialog, if the user hasn't logged in yet
if (!account) {
this.loginModalService.open();
}
});
return false;
}));
}
}
export const PROBLEM_BASE_URL = '';
export const EMAIL_ALREADY_USED_TYPE = PROBLEM_BASE_URL + '/email-already-used';
export const LOGIN_ALREADY_USED_TYPE = PROBLEM_BASE_URL + '/login-already-used';
export const EMAIL_NOT_FOUND_TYPE = PROBLEM_BASE_URL + '/email-not-found';
export * from './constants/error.constants';
export * from './constants/pagination.constants';
export * from './alert/alert.component';
export * from './alert/alert-error.component';
export * from './auth/csrf.service';
export * from './auth/state-storage.service';
export * from './auth/account.service';
export * from './auth/auth-jwt.service';
export * from './auth/principal.service';
export * from './auth/has-any-authority.directive';
export * from './auth/user-route-access-service';
export * from './login/login.component';
export * from './login/login-modal.service';
export * from './login/login.service';
export * from './user/account.model';
export * from './user/user.model';
export * from './user/user.service';
export * from './model/request-util';
export * from './model/base-entity';
export * from './shared-libs.module';
export * from './shared-common.module';
export * from './shared.module';
import { Injectable } from '@angular/core';
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
import { JhiLoginModalComponent } from './login.component';
@Injectable()
export class LoginModalService {
private isOpen = false;
constructor(
private modalService: NgbModal,
) {}
open(): NgbModalRef {
if (this.isOpen) {
return;
}
this.isOpen = true;
const modalRef = this.modalService.open(JhiLoginModalComponent);
modalRef.result.then((result) => {
this.isOpen = false;
}, (reason) => {
this.isOpen = false;
});
return modalRef;
}
}
<div class="modal-header">
<h4 class="modal-title">登录</h4>
<button aria-label="Close" data-dismiss="modal" class="close" type="button" (click)="activeModal.dismiss('closed')"><span aria-hidden="true">x</span>
</button>
</div>
<div class="modal-body">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="alert alert-danger" *ngIf="authenticationError">
<strong>登录失败!</strong> 请确认你的账号!
</div>
</div>
<div class="col-md-8">
<form class="form" role="form" (ngSubmit)="login()">
<div class="form-group">
<label for="username">账号</label>
<input type="text" class="form-control" name="username" id="username" placeholder="用户名"
[(ngModel)]="username">
</div>
<div class="form-group">
<label for="password">密码</label>
<input type="password" class="form-control" name="password" id="password" placeholder="密码"
[(ngModel)]="password">
</div>
<button type="submit" class="btn btn-primary">登录</button>
</form>
</div>
</div>
</div>
import { Component, AfterViewInit, Renderer, ElementRef } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Router } from '@angular/router';
import { JhiEventManager } from 'ng-jhipster';
import { LoginService } from './login.service';
import { StateStorageService } from '../auth/state-storage.service';
@Component({
selector: 'jhi-login-modal',
templateUrl: './login.component.html'
})
export class JhiLoginModalComponent implements AfterViewInit {
authenticationError: boolean;
password: string;
rememberMe: boolean;
username: string;
credentials: any;
constructor(
private eventManager: JhiEventManager,
private loginService: LoginService,
private stateStorageService: StateStorageService,
private elementRef: ElementRef,
private renderer: Renderer,
private router: Router,
public activeModal: NgbActiveModal
) {
this.credentials = {};
}
ngAfterViewInit() {
this.renderer.invokeElementMethod(this.elementRef.nativeElement.querySelector('#username'), 'focus', []);
}
cancel() {
this.credentials = {
username: null,
password: null,
rememberMe: true
};
this.authenticationError = false;
this.activeModal.dismiss('cancel');
}
login() {
this.loginService.login({
username: this.username,
password: this.password,
rememberMe: this.rememberMe
}).then(() => {
this.authenticationError = false;
this.activeModal.dismiss('login success');
if (this.router.url === '/register' || (/^\/activate\//.test(this.router.url)) ||
(/^\/reset\//.test(this.router.url))) {
this.router.navigate(['']);
}
this.eventManager.broadcast({
name: 'authenticationSuccess',
content: 'Sending Authentication Success'
});
// // previousState was set in the authExpiredInterceptor before being redirected to login modal.
// // since login is succesful, go to stored previousState and clear previousState
const redirect = this.stateStorageService.getUrl();
if (redirect) {
this.stateStorageService.storeUrl(null);
this.router.navigate([redirect]);
}
}).catch(() => {
this.authenticationError = true;
});
}
register() {
this.activeModal.dismiss('to state register');
this.router.navigate(['/register']);
}
requestResetPassword() {
this.activeModal.dismiss('to state requestReset');
this.router.navigate(['/reset', 'request']);
}
}
import { Injectable } from '@angular/core';
import { Principal } from '../auth/principal.service';
import { AuthServerProvider } from '../auth/auth-jwt.service';
@Injectable()
export class LoginService {
constructor(
private principal: Principal,
private authServerProvider: AuthServerProvider
) {}
login(credentials, callback?) {
const cb = callback || function() {};
return new Promise((resolve, reject) => {
this.authServerProvider.login(credentials).subscribe((data) => {
this.principal.identity(true).then((account) => {
resolve(data);
});
return cb();
}, (err) => {
this.logout();
reject(err);
return cb(err);
});
});
}
loginWithToken(jwt, rememberMe) {
return this.authServerProvider.loginWithToken(jwt, rememberMe);
}
logout() {
this.authServerProvider.logout().subscribe();
this.principal.authenticate(null);
}
}
export interface BaseEntity {
// using type any to avoid methods complaining of invalid type
id?: any;
}
import { HttpParams } from '@angular/common/http';
export const createRequestOption = (req?: any): HttpParams => {
let options: HttpParams = new HttpParams();
if (req) {
Object.keys(req).forEach((key) => {
if (key !== 'sort') {
options = options.set(key, req[key]);
}
});
if (req.sort) {
req.sort.forEach((val) => {
options = options.append('sort', val);
});
}
}
return options;
};
import { NgModule, LOCALE_ID } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { registerLocaleData } from '@angular/common';
import locale from '@angular/common/locales/en';
import {
BootappSharedLibsModule,
JhiAlertComponent,
JhiAlertErrorComponent
} from './';
@NgModule({
imports: [
BootappSharedLibsModule
],
declarations: [
JhiAlertComponent,
JhiAlertErrorComponent
],
providers: [
Title,
{
provide: LOCALE_ID,
useValue: 'en'
},
],
exports: [
BootappSharedLibsModule,
JhiAlertComponent,
JhiAlertErrorComponent
]
})
export class BootappSharedCommonModule {
constructor() {
registerLocaleData(locale);
}
}
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { CommonModule } from '@angular/common';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { NgJhipsterModule } from 'ng-jhipster';
import { InfiniteScrollModule } from 'ngx-infinite-scroll';
import { CookieModule } from 'ngx-cookie';
@NgModule({
imports: [
NgbModule.forRoot(),
NgJhipsterModule.forRoot({
// set below to true to make alerts look like toast
alertAsToast: false,
}),
InfiniteScrollModule,
CookieModule.forRoot()
],
exports: [
FormsModule,
HttpClientModule,
CommonModule,
NgbModule,
NgJhipsterModule,
InfiniteScrollModule
]
})
export class BootappSharedLibsModule {}
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { DatePipe } from '@angular/common';
import {
BootappSharedLibsModule,
BootappSharedCommonModule,
CSRFService,
AuthServerProvider,
AccountService,
UserService,
StateStorageService,
LoginService,
LoginModalService,
JhiLoginModalComponent,
Principal,
HasAnyAuthorityDirective,
} from './';
@NgModule({
imports: [
BootappSharedLibsModule,
BootappSharedCommonModule
],
declarations: [
JhiLoginModalComponent,
HasAnyAuthorityDirective
],
providers: [
LoginService,
LoginModalService,
AccountService,
StateStorageService,
Principal,
CSRFService,
AuthServerProvider,
UserService,
DatePipe
],
entryComponents: [JhiLoginModalComponent],
exports: [
BootappSharedCommonModule,
JhiLoginModalComponent,
HasAnyAuthorityDirective,
DatePipe
],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class BootappSharedModule {}
export class Account {
constructor(
public activated: boolean,
public authorities: string[],
public email: string,
public firstName: string,
public langKey: string,
public lastName: string,
public login: string,
public imageUrl: string
) { }
}
export class User {
public id?: any;
public login?: string;
public firstName?: string;
public lastName?: string;
public email?: string;
public activated?: Boolean;
public langKey?: string;
public authorities?: any[];
public createdBy?: string;
public createdDate?: Date;
public lastModifiedBy?: string;
public lastModifiedDate?: Date;
public password?: string;
constructor(
id?: any,
login?: string,
firstName?: string,
lastName?: string,
email?: string,
activated?: Boolean,
langKey?: string,
authorities?: any[],
createdBy?: string,
createdDate?: Date,
lastModifiedBy?: string,
lastModifiedDate?: Date,
password?: string
) {
this.id = id ? id : null;
this.login = login ? login : null;
this.firstName = firstName ? firstName : null;
this.lastName = lastName ? lastName : null;
this.email = email ? email : null;
this.activated = activated ? activated : false;
this.langKey = langKey ? langKey : null;
this.authorities = authorities ? authorities : null;
this.createdBy = createdBy ? createdBy : null;
this.createdDate = createdDate ? createdDate : null;
this.lastModifiedBy = lastModifiedBy ? lastModifiedBy : null;
this.lastModifiedDate = lastModifiedDate ? lastModifiedDate : null;
this.password = password ? password : null;
}
}
import { Injectable } from '@angular/core';
import { HttpClient, HttpResponse } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import { SERVER_API_URL } from '../../app.constants';
import { User } from './user.model';
import { createRequestOption } from '../model/request-util';
@Injectable()
export class UserService {
private resourceUrl = SERVER_API_URL + 'api/users';
constructor(private http: HttpClient) { }
create(user: User): Observable<HttpResponse<User>> {
return this.http.post<User>(this.resourceUrl, user, { observe: 'response' });
}
update(user: User): Observable<HttpResponse<User>> {
return this.http.put<User>(this.resourceUrl, user, { observe: 'response' });
}
find(login: string): Observable<HttpResponse<User>> {
return this.http.get<User>(`${this.resourceUrl}/${login}`, { observe: 'response' });
}
query(req?: any): Observable<HttpResponse<User[]>> {
const options = createRequestOption(req);
return this.http.get<User[]>(this.resourceUrl, { params: options, observe: 'response' });
}
delete(login: string): Observable<HttpResponse<any>> {
return this.http.delete(`${this.resourceUrl}/${login}`, { observe: 'response' });
}
authorities(): Observable<string[]> {
return this.http.get<string[]>(SERVER_API_URL + 'api/users/authorities');
}
}
/* after changing this file run 'yarn run webpack:build' */
/* tslint:disable */
import '../content/css/vendor.css';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import 'rxjs/add/observable/of';
import 'rxjs/add/observable/throw';
/*!
* Your CSS files will be generated in this directory by "gulp sass"
*/
/* ==============================================================
Bootstrap tweaks
===============================================================*/
body, h1, h2, h3, h4 {
font-weight: 300;
}
body {
background: #e4e5e6;
}
a {
color: #533f03;
font-weight: bold;
}
a:hover {
color: #533f03;
font-weight: bold;
}
/* ==========================================================================
Browser Upgrade Prompt
========================================================================== */
.browserupgrade {
margin: 0.2em 0;
background: #ccc;
color: #000;
padding: 0.2em 0;
}
/* ==========================================================================
Generic styles
========================================================================== */
/* Error highlight on input fields */
.ng-valid[required], .ng-valid.required {
border-left: 5px solid green;
}
.ng-invalid:not(form) {
border-left: 5px solid red;
}
/* other generic styles */
.jh-card {
padding: 1.5%;
margin-top: 20px;
border: none;
}
.error {
color: white;
background-color: red;
}
.pad {
padding: 10px;
}
.w-40 {
width: 40% !important;
}
.w-60 {
width: 60% !important;
}
.break {
white-space: normal;
word-break:break-all;
}
.readonly {
background-color: #eee;
opacity: 1;
}
.footer {
border-top: 1px solid rgba(0,0,0,.125);
padding: 10px;
}
.footer span{
margin-right: 20px;
}
/* ==========================================================================
make sure browsers use the pointer cursor for anchors, even with no href
========================================================================== */
a:hover {
cursor: pointer;
}
.hand, [jhisortby] {
cursor: pointer;
}
/* ==========================================================================
Custom alerts for notification
========================================================================== */
.alerts .alert{
text-overflow: ellipsis;
}
.alert pre{
background: none;
border: none;
font: inherit;
color: inherit;
padding: 0;
margin: 0;
}
.alert .popover pre {
font-size: 10px;
}
.alerts .toast {
position: fixed;
width: 100%;
}
.alerts .toast.left {
left: 5px;
}
.alerts .toast.right {
right: 5px;
}
.alerts .toast.top {
top: 55px;
}
.alerts .toast.bottom {
bottom: 55px;
}
@media screen and (min-width: 480px) {
.alerts .toast {
width: 50%;
}
}
/* ==========================================================================
entity tables helpers
========================================================================== */
/* Remove Bootstrap padding from the element
http://stackoverflow.com/questions/19562903/remove-padding-from-columns-in-bootstrap-3 */
.no-padding-left { padding-left: 0 !important; }
.no-padding-right { padding-right: 0 !important; }
.no-padding-top { padding-top: 0 !important; }
.no-padding-bottom { padding-bottom: 0 !important; }
.no-padding { padding: 0 !important; }
/* bootstrap 3 input-group 100% width
http://stackoverflow.com/questions/23436430/bootstrap-3-input-group-100-width */
.width-min { width: 1% !important; }
/* Makes toolbar not wrap on smaller screens
http://www.sketchingwithcss.com/samplechapter/cheatsheet.html#right */
.flex-btn-group-container {
display: -webkit-flex;
display: flex;
-webkit-flex-direction: row;
flex-direction: row;
-webkit-justify-content: flex-end;
justify-content: flex-end;
}
/* ==========================================================================
entity detail page css
========================================================================== */
.row.jh-entity-details > dd {
margin-bottom: 15px;
}
@media screen and (min-width: 768px) {
.row.jh-entity-details > dt {
margin-bottom: 15px;
}
.row.jh-entity-details > dd {
border-bottom: 1px solid #eee;
padding-left: 180px;
margin-left: 0;
}
}
/* ==========================================================================
ui bootstrap tweaks
========================================================================== */
.nav, .pagination, .carousel, .card-title a {
cursor: pointer;
}
.datetime-picker-dropdown > li.date-picker-menu div > table .btn-secondary,
.uib-datepicker-popup > li > div.uib-datepicker > table .btn-secondary {
border: 0;
}
.datetime-picker-dropdown > li.date-picker-menu div > table:focus,
.uib-datepicker-popup > li > div.uib-datepicker > table:focus {
outline: none;
}
.thread-dump-modal-lock {
max-width: 450px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/* jhipster-needle-css-add-main JHipster will add new css style */
.header-logo{
display: inline-block;
width: 155px;
height: 45px;
background-image: url("../images/logo.svg");
-webkit-background-size: contain;
background-size: contain;
vertical-align: middle;
background-repeat: no-repeat;
}
/* after changing this file run 'yarn run webpack:build' */
@import '~bootstrap/dist/css/bootstrap.min.css';
@import '~font-awesome/css/font-awesome.css';
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 235.83 73.14">
<defs>
<style>
.a{fill:#009ea7}.b{fill:#a9cd36}
</style>
</defs>
<path class="a" d="M88.7 9a36.15 36.15 0 0 0 7.59 2h.08a.51.51 0 0 0 .5-.5V7.37a.5.5 0 0 0-.43-.49 32.09 32.09 0 0 1-7.37-2.07.5.5 0 0 0-.69.45v3.31a.5.5 0 0 0 .32.43m.01 8.15a35.47 35.47 0 0 0 7.59 1.93h.07a.5.5 0 0 0 .35-.15.48.48 0 0 0 .15-.36v-3.1a.49.49 0 0 0-.42-.48 31.78 31.78 0 0 1-7.37-2.08.51.51 0 0 0-.69.46v3.31a.49.49 0 0 0 .32.47m7.42 5.43a.49.49 0 0 0-.37-.17h-3.27a.5.5 0 0 0-.48.39 84.81 84.81 0 0 1-4.52 15 .49.49 0 0 0 0 .47.49.49 0 0 0 .41.22h3.45a.48.48 0 0 0 .45-.28A74.39 74.39 0 0 0 96.24 23a.5.5 0 0 0-.11-.41m26.77 15.03a51.66 51.66 0 0 1-10.75-9.42c7.44-9.15 8.77-16.85 8.94-20.34v-.22a1.78 1.78 0 0 0-.41-1.4 1.82 1.82 0 0 0-1.36-.54H99.63a.5.5 0 0 0-.49.5v2.93a.49.49 0 0 0 .49.5h17.29a28.88 28.88 0 0 1-2.44 7.46 42.22 42.22 0 0 1-4.89 7.82 38.36 38.36 0 0 1-2.59-4.36 29.31 29.31 0 0 1-2.9-8.18.5.5 0 0 0-.49-.41h-3a.49.49 0 0 0-.49.56c.32 2.28 1.65 8.45 6.89 15.56a70.77 70.77 0 0 1-10.84 9.54.48.48 0 0 0-.18.55.5.5 0 0 0 .48.35h4.9a.55.55 0 0 0 .32-.11 71.91 71.91 0 0 0 7.87-7.19 54.1 54.1 0 0 0 7.74 7.19.5.5 0 0 0 .31.11h5.07a.49.49 0 0 0 .47-.35.5.5 0 0 0-.2-.56m23.84-15.54h17.9a2 2 0 0 0 2.06-2.1v-7a2.08 2.08 0 0 0-2.16-2.1h-7.8c.09-.41.18-.86.26-1.34h9.42A.5.5 0 0 0 167 9V6.57a.49.49 0 0 0-.5-.5h-8.95c0-.41.07-.83.09-1.25a.5.5 0 0 0-.14-.37.51.51 0 0 0-.36-.15h-2.44a.49.49 0 0 0-.49.47c0 .44-.06.88-.11 1.31h-8.94a.5.5 0 0 0-.5.5V9a.5.5 0 0 0 .5.5h8.42c-.1.5-.2 1-.29 1.34h-6.4a2.12 2.12 0 0 0-2.24 2.1v7a2.08 2.08 0 0 0 2.15 2.1m10.63-3.43H154v-4.33h3.43zm5.9 0h-2.47v-4.33h2.47zm-15.25-4.35h2.48v4.35h-2.48zm-6.48-1.04a32 32 0 0 1-8 2.3.5.5 0 0 0-.42.49v2.79a.51.51 0 0 0 .5.5h.06c1.06-.14 2.06-.34 3-.55V38a.5.5 0 0 0 .5.5H140a.5.5 0 0 0 .5-.5V17.66l1.46-.54a.49.49 0 0 0 .31-.46v-3a.5.5 0 0 0-.69-.45m.02-8.29a32 32 0 0 1-8 2.3.5.5 0 0 0-.41.49v2.79a.51.51 0 0 0 .5.5h.07A35.6 35.6 0 0 0 142 8.83a.49.49 0 0 0 .3-.46v-3a.51.51 0 0 0-.69-.45M167 26.18v-2.43a.5.5 0 0 0-.49-.5h-21.37a.5.5 0 0 0-.5.5v2.43a.5.5 0 0 0 .5.5h21.34a.49.49 0 0 0 .49-.5m-3.89 8.97h-7.85c-1.78 0-2.61-.28-2.61-2.83v-4a.5.5 0 0 0-.49-.5h-2.44a.5.5 0 0 0-.5.5v4c0 4.15 2 6.26 6 6.26h7.85a.5.5 0 0 0 .5-.5v-2.44a.49.49 0 0 0-.5-.49m-15.31-7.3h-2.57a.48.48 0 0 0-.49.46 66.83 66.83 0 0 1-1 8.77.49.49 0 0 0 .49.59h2.61a.5.5 0 0 0 .49-.41 67.77 67.77 0 0 0 1-8.91.5.5 0 0 0-.5-.51"/>
<path class="a" d="M158.86 27.85h-2.57a.51.51 0 0 0-.37.16.49.49 0 0 0-.13.37c.08 1.07.28 3.24.64 5.82a.5.5 0 0 0 .5.42h2.6a.5.5 0 0 0 .38-.17.48.48 0 0 0 .11-.39 98.51 98.51 0 0 1-.66-5.74.49.49 0 0 0-.49-.46m8.13.45a.49.49 0 0 0-.5-.46H164a.49.49 0 0 0-.5.51 67.3 67.3 0 0 0 1 8.9.5.5 0 0 0 .49.41h2.49a.48.48 0 0 0 .37-.17.51.51 0 0 0 .12-.42 64.66 64.66 0 0 1-1-8.77m17.65-18.63h3a45 45 0 0 1-3.15 9.42.59.59 0 0 0 .53.83h2.69a.58.58 0 0 0 .54-.34 46.05 46.05 0 0 0 3.09-9.91H195V20a.59.59 0 0 0 .59.59h2.25a.59.59 0 0 0 .59-.59V9.68h3.66a46.17 46.17 0 0 0 3.09 9.91.57.57 0 0 0 .54.35h2.68a.59.59 0 0 0 .54-.83 45.34 45.34 0 0 1-3.16-9.42h3a.59.59 0 0 0 .59-.59V6.83a.59.59 0 0 0-.59-.58h-10.33V4.67a.59.59 0 0 0-.59-.59h-2.26a.59.59 0 0 0-.59.59v1.57h-10.4a.59.59 0 0 0-.59.58v2.27a.59.59 0 0 0 .59.59m9.96 16.56h1.19a.59.59 0 0 0 .59-.59v-2.26a.59.59 0 0 0-.59-.59H190v-1.32a.59.59 0 0 0-.58-.59h-2.22a.59.59 0 0 0-.59.59v1.32h-5.71a.59.59 0 0 0-.59.59v2.26a.59.59 0 0 0 .59.59h1.19a65.64 65.64 0 0 1-1.78 10.47.58.58 0 0 0 .11.49.57.57 0 0 0 .46.22h2.2a.58.58 0 0 0 .57-.44 69.06 69.06 0 0 0 1.75-10.74h1.21v11.53a.59.59 0 0 0 .59.58h2.26a.59.59 0 0 0 .58-.58V26.24h1.21A67.87 67.87 0 0 0 193 37a.57.57 0 0 0 .57.44h2.21a.58.58 0 0 0 .57-.72 66 66 0 0 1-1.78-10.46m18.57 10.44a66 66 0 0 1-1.78-10.46h1.2a.58.58 0 0 0 .58-.59v-2.26a.59.59 0 0 0-.58-.59h-5.7v-1.32a.59.59 0 0 0-.59-.59H204a.59.59 0 0 0-.59.59v1.32h-5.7a.59.59 0 0 0-.59.59v2.26a.59.59 0 0 0 .59.59h1.16a65.89 65.89 0 0 1-1.77 10.46.57.57 0 0 0 .1.5.59.59 0 0 0 .47.22h2.2a.58.58 0 0 0 .57-.44 68.76 68.76 0 0 0 1.75-10.74h1.23v11.53a.59.59 0 0 0 .59.58h2.25a.59.59 0 0 0 .59-.58V26.24H208A69.1 69.1 0 0 0 209.8 37a.57.57 0 0 0 .57.44h2.21a.59.59 0 0 0 .47-.23.57.57 0 0 0 .1-.49"/>
<path class="b" d="M224.62 15.88V9.3h-6.58V6.59h6.58V0h2.74v6.59h6.58V9.3h-6.58v6.58h-2.74z"/>
<path class="a" d="M102.82 54.48H91.75v-9.62h-4.37v22.63h4.37v-9.36h11.07v9.36h4.38V44.86h-4.38v9.62zm71.78-4.86c-8.94 0-8.43 9.51-8.43 9.51s-.52 8.8 9.33 8.8a18.71 18.71 0 0 0 3.52-.32 12.89 12.89 0 0 0 2.51-.68v-3.38a20.26 20.26 0 0 1-2.71.72 14.33 14.33 0 0 1-2.58.25c-5.28 0-5.75-3.65-5.8-4.43h12s1.62-10.48-7.88-10.48m-3.89 7.18a3.85 3.85 0 0 1 3.92-3.65c1.28 0 4 .45 4 3.65zm25.89 1.74a5.6 5.6 0 0 0-1.61-.85 18.08 18.08 0 0 0-1.79-.52l-1.16-.29a9.11 9.11 0 0 1-1.16-.38 2.24 2.24 0 0 1-.86-.61 1.43 1.43 0 0 1-.31-1 1.61 1.61 0 0 1 .14-.65 1.44 1.44 0 0 1 .47-.56 2.54 2.54 0 0 1 .84-.38 4.85 4.85 0 0 1 1.27-.14 10.64 10.64 0 0 1 1.25.08 25.56 25.56 0 0 1 2.65.5c.43.11.85.23 1.24.37v-3.42A16 16 0 0 0 195 50a16.16 16.16 0 0 0-3-.26 8.79 8.79 0 0 0-2.47.34 5.83 5.83 0 0 0-2 1 5 5 0 0 0-1.4 1.76 5.63 5.63 0 0 0-.52 2.51 4.6 4.6 0 0 0 .38 2 3.83 3.83 0 0 0 1 1.35 5.43 5.43 0 0 0 1.51.87q.85.33 1.78.58l1.4.36a7.15 7.15 0 0 1 1.19.42 2.42 2.42 0 0 1 .83.6 1.31 1.31 0 0 1 .31.91 1.51 1.51 0 0 1-.28.92 2.2 2.2 0 0 1-.73.64 4.16 4.16 0 0 1-1.17.36 8.53 8.53 0 0 1-1.46.12 14.35 14.35 0 0 1-2.2-.19 13.46 13.46 0 0 1-2.57-.71V67a10.06 10.06 0 0 0 2.17.65 15.48 15.48 0 0 0 3 .26 12.42 12.42 0 0 0 3-.35 6.76 6.76 0 0 0 2.38-1.07 5 5 0 0 0 1.54-1.81 5.56 5.56 0 0 0 .56-2.56 4.71 4.71 0 0 0-.46-2.2 4.18 4.18 0 0 0-1.17-1.41m18.63-6.61a7.56 7.56 0 0 0-2.74-1.9 9.29 9.29 0 0 0-3.65-.68 9.11 9.11 0 0 0-3.59.68 7.65 7.65 0 0 0-2.74 1.92 8.56 8.56 0 0 0-1.74 3 11.76 11.76 0 0 0-.61 3.86 11.88 11.88 0 0 0 .6 3.87 8.49 8.49 0 0 0 1.72 3 7.6 7.6 0 0 0 2.74 1.92 9.36 9.36 0 0 0 3.65.68 9.14 9.14 0 0 0 3.59-.68 7.67 7.67 0 0 0 2.74-1.92 8.41 8.41 0 0 0 1.74-3 11.72 11.72 0 0 0 .61-3.87 11.92 11.92 0 0 0-.6-3.86 8.52 8.52 0 0 0-1.72-3m-2.37 9.38a5.48 5.48 0 0 1-.89 1.83 3.86 3.86 0 0 1-1.36 1.11 3.9 3.9 0 0 1-1.73.38 4 4 0 0 1-1.74-.38 3.92 3.92 0 0 1-1.37-1.11 5.41 5.41 0 0 1-.9-1.83 10.16 10.16 0 0 1 0-5.05 5.63 5.63 0 0 1 .89-1.84 3.65 3.65 0 0 1 1.37-1.11 4 4 0 0 1 1.73-.37 4.13 4.13 0 0 1 1.75.37 3.61 3.61 0 0 1 1.37 1.09 5.61 5.61 0 0 1 .89 1.84 10.19 10.19 0 0 1 0 5.05m22.88-6.81a6.14 6.14 0 0 0-.24-1.21 5.6 5.6 0 0 0-.89-1.72 5 5 0 0 0-1.29-1.18 7.1 7.1 0 0 0-3.65-.88l-4.63.14c-1.74.07-4.87.14-4.87.14v17.73h4.23V53l4.37-.12a2.65 2.65 0 0 1 2.81 2.87v11.7h4.23V56c0-.57 0-1.07-.06-1.51m-92.1-.49a5.68 5.68 0 0 0-.88-1.72 5 5 0 0 0-1.3-1.18 7.08 7.08 0 0 0-3.65-.88l-4.63.14c-1.74.07-4.87.14-4.87.14v17h4.23V53.74l4.37-.12a2.65 2.65 0 0 1 2.8 2.88v11H144V56.68c0-.57 0-1.07-.07-1.51a5.69 5.69 0 0 0-.24-1.21m19.67 8.38V44.62h-4.23v6.47s-8.44-3.32-11.49 4.05a10.67 10.67 0 0 0-.62 4 11.65 11.65 0 0 0 .61 4 7.66 7.66 0 0 0 1.64 2.73c.86.9 3.2 2.38 8.41 1.75a45.19 45.19 0 0 1 5.79-.33c0-.64 0-1.19-.07-2s0-1.8 0-2.95m-4.23 1.91a14.68 14.68 0 0 1-3.79.31 3.57 3.57 0 0 1-3-1.48 7.13 7.13 0 0 1-1-4.07 7.12 7.12 0 0 1 .4-2.91c1.2-2.55 3.9-2.48 5.68-2a2.27 2.27 0 0 1 1.66 2.34zM123.22 51c-1.27-.81-3.58-1.24-6.69-1.24a44.25 44.25 0 0 0-5.1.32v3.32c.81-.07 3-.29 5-.29a9.74 9.74 0 0 1 2.94.31 2.18 2.18 0 0 1 1.59 2.22v.21h-.21a12.75 12.75 0 0 1-1.39.12c-3.21.15-9.9.46-9.9 6.38a5.19 5.19 0 0 0 5.22 5.47 51 51 0 0 0 5.68-.28c.48-.06.89-.09 1.21-.11h1.63c1 0 1.8 0 2.22.08V55.63c-.07-2.28-.73-3.73-2.2-4.63zm-2.32 13.6h-.3a13.46 13.46 0 0 0-1.66.07c-.58 0-1.18.1-1.77.1-1.43 0-3.35-.28-3.35-2.79s2.82-2.83 6.79-3h.29zM57.06.07v30.42a73.66 73.66 0 0 0-46.63-9.68V2.8A69.23 69.23 0 0 0 0 7.71V24.5l7.14 5.67A63.33 63.33 0 0 1 59 42.73l8.46 6.72V3.76A61.66 61.66 0 0 0 57.06.07"/>
<path class="b" d="M60.36 43.78a63.32 63.32 0 0 1-51.9-12.56L0 24.5v45a61.62 61.62 0 0 0 10.43 3.68V43.46a73.66 73.66 0 0 0 46.63 9.67v17.28a69.33 69.33 0 0 0 10.43-4.92v-16z"/>
</svg>
<!doctype html>
<html class="no-js" lang="en" dir="ltr">
<head>
<base href="./" />
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>web</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#000000">
<link rel="shortcut icon" href="favicon.ico" />
<link rel="manifest" href="manifest.webapp" />
<!-- jhipster-needle-add-resources-to-root - JHipster will add new resources here -->
</head>
<body>
<!--[if lt IE 9]>
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<jhi-main></jhi-main>
<noscript>
<h1>You must enable javascript to view this page.</h1>
</noscript>
<!-- uncomment this for adding service worker
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker
.register('./sw.js')
.then(function() { console.log('Service Worker Registered'); });
}
</script>
-->
<!-- Google Analytics: uncomment and change UA-XXXXX-X to be your site's ID.
<script>
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;
e=o.createElement(i);r=o.getElementsByTagName(i)[0];
e.src='//www.google-analytics.com/analytics.js';
r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));
ga('create','UA-XXXXX-X');ga('send','pageview');
</script>-->
</body>
</html>
{
"name": "Bootapp",
"short_name": "Bootapp",
"icons": [
{
"src": "./content/images/logo-jhipster.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "./content/images/logo-jhipster.png",
"sizes": "256x256",
"type": "image/png"
},
{
"src": "./content/images/logo-jhipster.png",
"sizes": "384x384",
"type": "image/png"
},
{
"src": "./content/images/logo-jhipster.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#000000",
"background_color": "#e0e0e0",
"start_url": "/index.html",
"display": "standalone",
"orientation": "portrait"
}
# robotstxt.org/
User-agent: *
Disallow: /api/account
Disallow: /api/account/change-password
Disallow: /api/account/sessions
Disallow: /api/audits/
Disallow: /api/logs/
Disallow: /api/users/
Disallow: /management/
Disallow: /v2/api-docs/
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Swagger UI</title>
<link rel="icon" type="image/png" href="images/favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="images/favicon-16x16.png" sizes="16x16" />
<link href='./dist/css/typography.css' media='screen' rel='stylesheet' type='text/css'/>
<link href='./dist/css/reset.css' media='screen' rel='stylesheet' type='text/css'/>
<link href='./dist/css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
<link href='./dist/css/reset.css' media='print' rel='stylesheet' type='text/css'/>
<link href='./dist/css/print.css' media='print' rel='stylesheet' type='text/css'/>
<script src='./dist/lib/object-assign-pollyfill.js' type='text/javascript'></script>
<script src='./dist/lib/jquery-1.8.0.min.js' type='text/javascript'></script>
<script src='./dist/lib/jquery.slideto.min.js' type='text/javascript'></script>
<script src='./dist/lib/jquery.wiggle.min.js' type='text/javascript'></script>
<script src='./dist/lib/jquery.ba-bbq.min.js' type='text/javascript'></script>
<script src='./dist/lib/handlebars-4.0.5.js' type='text/javascript'></script>
<script src='./dist/lib/lodash.min.js' type='text/javascript'></script>
<script src='./dist/lib/backbone-min.js' type='text/javascript'></script>
<script src='./dist/swagger-ui.min.js' type='text/javascript'></script>
<script src='./dist/lib/highlight.9.1.0.pack.js' type='text/javascript'></script>
<script src='./dist/lib/highlight.9.1.0.pack.js' type='text/javascript'></script>
<script src='./dist/lib/jsoneditor.min.js' type='text/javascript'></script>
<script src='./dist/lib/marked.js' type='text/javascript'></script>
<script src='./dist/lib/swagger-oauth.js' type='text/javascript'></script>
<!-- Some basic translations -->
<!-- <script src='lang/translator.js' type='text/javascript'></script> -->
<!-- <script src='lang/ru.js' type='text/javascript'></script> -->
<!-- <script src='lang/en.js' type='text/javascript'></script> -->
<script type="text/javascript">
$(function() {
var springfox = {
"baseUrl": function() {
var urlMatches = /(.*)\/swagger-ui\/index.html.*/.exec(window.location.href);
return urlMatches[1];
},
"securityConfig": function(cb) {
$.getJSON(this.baseUrl() + "/swagger-resources/configuration/security", function(data) {
cb(data);
});
},
"uiConfig": function(cb) {
$.getJSON(this.baseUrl() + "/swagger-resources/configuration/ui", function(data) {
cb(data);
});
}
};
window.springfox = springfox;
window.oAuthRedirectUrl = springfox.baseUrl() + './dist/o2c.html'
window.springfox.uiConfig(function(data) {
window.swaggerUi = new SwaggerUi({
dom_id: "swagger-ui-container",
validatorUrl: data.validatorUrl,
supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
onComplete: function(swaggerApi, swaggerUi) {
initializeSpringfox();
if (window.SwaggerTranslator) {
window.SwaggerTranslator.translate();
}
$('pre code').each(function(i, e) {
hljs.highlightBlock(e)
});
},
onFailure: function(data) {
log("Unable to Load SwaggerUI");
},
docExpansion: "none",
apisSorter: "alpha",
showRequestHeaders: false
});
initializeBaseUrl();
$('#select_baseUrl').change(function() {
window.swaggerUi.headerView.trigger('update-swagger-ui', {
url: $('#select_baseUrl').val()
});
addApiKeyAuthorization();
});
function addApiKeyAuthorization() {
var authToken = JSON.parse(localStorage.getItem("jhi-authenticationtoken") || sessionStorage.getItem("jhi-authenticationtoken"));
var apiKeyAuth = new SwaggerClient.ApiKeyAuthorization("Authorization", "Bearer " + authToken, "header");
window.swaggerUi.api.clientAuthorizations.add("bearer", apiKeyAuth);
}
function getCSRF() {
var name = "XSRF-TOKEN=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1);
if (c.indexOf(name) !== -1) return c.substring(name.length,c.length);
}
return "";
}
function log() {
if ('console' in window) {
console.log.apply(console, arguments);
}
}
function oAuthIsDefined(security) {
return security.clientId
&& security.clientSecret
&& security.appName
&& security.realm;
}
function initializeSpringfox() {
var security = {};
window.springfox.securityConfig(function(data) {
security = data;
if (typeof initOAuth === "function" && oAuthIsDefined(security)) {
initOAuth(security);
}
});
}
});
function maybePrefix(location, withRelativePath) {
var pat = /^https?:\/\//i;
if (pat.test(location)) {
return location;
}
return withRelativePath + location;
}
function initializeBaseUrl() {
var relativeLocation = springfox.baseUrl();
$('#input_baseUrl').hide();
$.getJSON(relativeLocation + "/swagger-resources", function(data) {
var $urlDropdown = $('#select_baseUrl');
$urlDropdown.empty();
$.each(data, function(i, resource) {
var option = $('<option></option>')
.attr("value", maybePrefix(resource.location, relativeLocation))
.text(resource.name + " (" + resource.location + ")");
$urlDropdown.append(option);
});
$urlDropdown.change();
});
}
});
</script>
</head>
<body class="swagger-section">
<div id='header'>
<div class="swagger-ui-wrap">
<a id="logo" href="http://swagger.io">swagger</a>
<form id='api_selector'>
<div class='input'>
<select id="select_baseUrl" name="select_baseUrl"></select>
</div>
<div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/>
</div>
</form>
</div>
</div>
<div id="message-bar" class="swagger-ui-wrap" data-sw-translate>&nbsp;</div>
<div id="swagger-ui-container" class="swagger-ui-wrap"></div>
</body>
</html>
const webpackConfig = require('../../../webpack/webpack.test.js');
const WATCH = process.argv.includes('--watch');
module.exports = (config) => {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: './',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine', 'intl-shim'],
// list of files / patterns to load in the browser
files: [
'spec/entry.ts'
],
// list of files to exclude
exclude: [],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'spec/entry.ts': ['webpack', 'sourcemap']
},
webpack: webpackConfig(WATCH),
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['dots', 'junit', 'progress', 'karma-remap-istanbul', 'notify'],
junitReporter: {
outputFile: '../../../../build/test-results/karma/TESTS-results.xml'
},
notifyReporter: {
reportEachFailure: true, // Default: false, will notify on every failed sepc
reportSuccess: true // Default: true, will notify when a suite was successful
},
remapIstanbulReporter: {
reports: { // eslint-disable-line
'lcovonly': 'build/test-results/coverage/report-lcov/lcov.info',
'html': 'build/test-results/coverage',
'text-summary': null
}
},
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: WATCH,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['PhantomJS'],
// Ensure all browsers can run tests written in .ts files
mime: {
'text/x-typescript': ['ts','tsx']
},
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: !WATCH
});
};
import { TestBed, async, tick, fakeAsync, inject } from '@angular/core/testing';
import { ActivatedRoute } from '@angular/router';
import { Observable } from 'rxjs/Observable';
import { BootappTestModule } from '../../../test.module';
import { MockActivatedRoute } from '../../../helpers/mock-route.service';
import { ActivateService } from '../../../../../../main/webapp/app/account/activate/activate.service';
import { ActivateComponent } from '../../../../../../main/webapp/app/account/activate/activate.component';
describe('Component Tests', () => {
describe('ActivateComponent', () => {
let comp: ActivateComponent;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [BootappTestModule],
declarations: [ActivateComponent],
providers: [
ActivateService,
{
provide: ActivatedRoute,
useValue: new MockActivatedRoute({'key': 'ABC123'})
}
]
})
.overrideTemplate(ActivateComponent, '')
.compileComponents();
}));
beforeEach(() => {
const fixture = TestBed.createComponent(ActivateComponent);
comp = fixture.componentInstance;
});
it('calls activate.get with the key from params',
inject([ActivateService],
fakeAsync((service: ActivateService) => {
spyOn(service, 'get').and.returnValue(Observable.of());
comp.ngOnInit();
tick();
expect(service.get).toHaveBeenCalledWith('ABC123');
})
)
);
it('should set set success to OK upon successful activation',
inject([ActivateService],
fakeAsync((service: ActivateService) => {
spyOn(service, 'get').and.returnValue(Observable.of({}));
comp.ngOnInit();
tick();
expect(comp.error).toBe(null);
expect(comp.success).toEqual('OK');
})
)
);
it('should set set error to ERROR upon activation failure',
inject([ActivateService],
fakeAsync((service: ActivateService) => {
spyOn(service, 'get').and.returnValue(Observable.throw('ERROR'));
comp.ngOnInit();
tick();
expect(comp.error).toBe('ERROR');
expect(comp.success).toEqual(null);
})
)
);
});
});
import { ComponentFixture, TestBed, inject, tick, fakeAsync } from '@angular/core/testing';
import { Observable } from 'rxjs/Observable';
import { Renderer, ElementRef } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { BootappTestModule } from '../../../../test.module';
import { PasswordResetFinishComponent } from '../../../../../../../main/webapp/app/account/password-reset/finish/password-reset-finish.component';
import { PasswordResetFinishService } from '../../../../../../../main/webapp/app/account/password-reset/finish/password-reset-finish.service';
import { MockActivatedRoute } from '../../../../helpers/mock-route.service';
describe('Component Tests', () => {
describe('PasswordResetFinishComponent', () => {
let fixture: ComponentFixture<PasswordResetFinishComponent>;
let comp: PasswordResetFinishComponent;
beforeEach(() => {
fixture = TestBed.configureTestingModule({
imports: [BootappTestModule],
declarations: [PasswordResetFinishComponent],
providers: [
PasswordResetFinishService,
{
provide: ActivatedRoute,
useValue: new MockActivatedRoute({'key': 'XYZPDQ'})
},
{
provide: Renderer,
useValue: {
invokeElementMethod(renderElement: any, methodName: string, args?: any[]) {}
}
},
{
provide: ElementRef,
useValue: new ElementRef(null)
}
]
})
.overrideTemplate(PasswordResetFinishComponent, '')
.createComponent(PasswordResetFinishComponent);
});
beforeEach(() => {
fixture = TestBed.createComponent(PasswordResetFinishComponent);
comp = fixture.componentInstance;
comp.ngOnInit();
});
it('should define its initial state', () => {
comp.ngOnInit();
expect(comp.keyMissing).toBeFalsy();
expect(comp.key).toEqual('XYZPDQ');
expect(comp.resetAccount).toEqual({});
});
it('sets focus after the view has been initialized',
inject([ElementRef], (elementRef: ElementRef) => {
const element = fixture.nativeElement;
const node = {
focus() {}
};
elementRef.nativeElement = element;
spyOn(element, 'querySelector').and.returnValue(node);
spyOn(node, 'focus');
comp.ngAfterViewInit();
expect(element.querySelector).toHaveBeenCalledWith('#password');
expect(node.focus).toHaveBeenCalled();
})
);
it('should ensure the two passwords entered match', () => {
comp.resetAccount.password = 'password';
comp.confirmPassword = 'non-matching';
comp.finishReset();
expect(comp.doNotMatch).toEqual('ERROR');
});
it('should update success to OK after resetting password',
inject([PasswordResetFinishService],
fakeAsync((service: PasswordResetFinishService) => {
spyOn(service, 'save').and.returnValue(Observable.of({}));
comp.resetAccount.password = 'password';
comp.confirmPassword = 'password';
comp.finishReset();
tick();
expect(service.save).toHaveBeenCalledWith({
key: 'XYZPDQ',
newPassword: 'password'
});
expect(comp.success).toEqual('OK');
})
)
);
it('should notify of generic error',
inject([PasswordResetFinishService],
fakeAsync((service: PasswordResetFinishService) => {
spyOn(service, 'save').and.returnValue(Observable.throw('ERROR'));
comp.resetAccount.password = 'password';
comp.confirmPassword = 'password';
comp.finishReset();
tick();
expect(service.save).toHaveBeenCalledWith({
key: 'XYZPDQ',
newPassword: 'password'
});
expect(comp.success).toBeNull();
expect(comp.error).toEqual('ERROR');
})
)
);
});
});
import { ComponentFixture, TestBed, inject } from '@angular/core/testing';
import { Renderer, ElementRef } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { BootappTestModule } from '../../../../test.module';
import { PasswordResetInitComponent } from '../../../../../../../main/webapp/app/account/password-reset/init/password-reset-init.component';
import { PasswordResetInitService } from '../../../../../../../main/webapp/app/account/password-reset/init/password-reset-init.service';
import { EMAIL_NOT_FOUND_TYPE } from '../../../../../../../main/webapp/app/shared';
describe('Component Tests', () => {
describe('PasswordResetInitComponent', () => {
let fixture: ComponentFixture<PasswordResetInitComponent>;
let comp: PasswordResetInitComponent;
beforeEach(() => {
fixture = TestBed.configureTestingModule({
imports: [BootappTestModule],
declarations: [PasswordResetInitComponent],
providers: [
PasswordResetInitService,
{
provide: Renderer,
useValue: {
invokeElementMethod(renderElement: any, methodName: string, args?: any[]) {}
}
},
{
provide: ElementRef,
useValue: new ElementRef(null)
}
]
})
.overrideTemplate(PasswordResetInitComponent, '')
.createComponent(PasswordResetInitComponent);
comp = fixture.componentInstance;
comp.ngOnInit();
});
it('should define its initial state', () => {
expect(comp.success).toBeUndefined();
expect(comp.error).toBeUndefined();
expect(comp.errorEmailNotExists).toBeUndefined();
expect(comp.resetAccount).toEqual({});
});
it('sets focus after the view has been initialized',
inject([ElementRef], (elementRef: ElementRef) => {
const element = fixture.nativeElement;
const node = {
focus() {}
};
elementRef.nativeElement = element;
spyOn(element, 'querySelector').and.returnValue(node);
spyOn(node, 'focus');
comp.ngAfterViewInit();
expect(element.querySelector).toHaveBeenCalledWith('#email');
expect(node.focus).toHaveBeenCalled();
})
);
it('notifies of success upon successful requestReset',
inject([PasswordResetInitService], (service: PasswordResetInitService) => {
spyOn(service, 'save').and.returnValue(Observable.of({}));
comp.resetAccount.email = 'user@domain.com';
comp.requestReset();
expect(service.save).toHaveBeenCalledWith('user@domain.com');
expect(comp.success).toEqual('OK');
expect(comp.error).toBeNull();
expect(comp.errorEmailNotExists).toBeNull();
})
);
it('notifies of unknown email upon email address not registered/400',
inject([PasswordResetInitService], (service: PasswordResetInitService) => {
spyOn(service, 'save').and.returnValue(Observable.throw({
status: 400,
json() {
return {type : EMAIL_NOT_FOUND_TYPE};
}
}));
comp.resetAccount.email = 'user@domain.com';
comp.requestReset();
expect(service.save).toHaveBeenCalledWith('user@domain.com');
expect(comp.success).toBeNull();
expect(comp.error).toBeNull();
expect(comp.errorEmailNotExists).toEqual('ERROR');
})
);
it('notifies of error upon error response',
inject([PasswordResetInitService], (service: PasswordResetInitService) => {
spyOn(service, 'save').and.returnValue(Observable.throw({
status: 503,
data: 'something else'
}));
comp.resetAccount.email = 'user@domain.com';
comp.requestReset();
expect(service.save).toHaveBeenCalledWith('user@domain.com');
expect(comp.success).toBeNull();
expect(comp.errorEmailNotExists).toBeNull();
expect(comp.error).toEqual('ERROR');
})
);
});
});
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { PasswordStrengthBarComponent } from '../../../../../../main/webapp/app/account/password/password-strength-bar.component';
describe('Component Tests', () => {
describe('PasswordStrengthBarComponent', () => {
let comp: PasswordStrengthBarComponent;
let fixture: ComponentFixture<PasswordStrengthBarComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [PasswordStrengthBarComponent]
})
.overrideTemplate(PasswordStrengthBarComponent, '')
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(PasswordStrengthBarComponent);
comp = fixture.componentInstance;
});
describe('PasswordStrengthBarComponents', () => {
it('should initialize with default values', () => {
expect(comp.measureStrength('')).toBe(0);
expect(comp.colors).toEqual(['#F00', '#F90', '#FF0', '#9F0', '#0F0']);
expect(comp.getColor(0).idx).toBe(1);
expect(comp.getColor(0).col).toBe(comp.colors[0]);
});
it('should increase strength upon password value change', () => {
expect(comp.measureStrength('')).toBe(0);
expect(comp.measureStrength('aa')).toBeGreaterThanOrEqual(comp.measureStrength(''));
expect(comp.measureStrength('aa^6')).toBeGreaterThanOrEqual(comp.measureStrength('aa'));
expect(comp.measureStrength('Aa090(**)')).toBeGreaterThanOrEqual(comp.measureStrength('aa^6'));
expect(comp.measureStrength('Aa090(**)+-07365')).toBeGreaterThanOrEqual(comp.measureStrength('Aa090(**)'));
});
it('should change the color based on strength', () => {
expect(comp.getColor(0).col).toBe(comp.colors[0]);
expect(comp.getColor(11).col).toBe(comp.colors[1]);
expect(comp.getColor(22).col).toBe(comp.colors[2]);
expect(comp.getColor(33).col).toBe(comp.colors[3]);
expect(comp.getColor(44).col).toBe(comp.colors[4]);
});
});
});
});
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { HttpResponse } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import { BootappTestModule } from '../../../test.module';
import { PasswordComponent } from '../../../../../../main/webapp/app/account/password/password.component';
import { PasswordService } from '../../../../../../main/webapp/app/account/password/password.service';
import { Principal } from '../../../../../../main/webapp/app/shared/auth/principal.service';
import { AccountService } from '../../../../../../main/webapp/app/shared/auth/account.service';
describe('Component Tests', () => {
describe('PasswordComponent', () => {
let comp: PasswordComponent;
let fixture: ComponentFixture<PasswordComponent>;
let service: PasswordService;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [BootappTestModule],
declarations: [PasswordComponent],
providers: [
Principal,
AccountService,
PasswordService
]
})
.overrideTemplate(PasswordComponent, '')
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(PasswordComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(PasswordService);
});
it('should show error if passwords do not match', () => {
// GIVEN
comp.password = 'password1';
comp.confirmPassword = 'password2';
// WHEN
comp.changePassword();
// THEN
expect(comp.doNotMatch).toBe('ERROR');
expect(comp.error).toBeNull();
expect(comp.success).toBeNull();
});
it('should call Auth.changePassword when passwords match', () => {
// GIVEN
spyOn(service, 'save').and.returnValue(Observable.of(new HttpResponse({body: true})));
comp.password = comp.confirmPassword = 'myPassword';
// WHEN
comp.changePassword();
// THEN
expect(service.save).toHaveBeenCalledWith('myPassword');
});
it('should set success to OK upon success', function() {
// GIVEN
spyOn(service, 'save').and.returnValue(Observable.of(new HttpResponse({body: true})));
comp.password = comp.confirmPassword = 'myPassword';
// WHEN
comp.changePassword();
// THEN
expect(comp.doNotMatch).toBeNull();
expect(comp.error).toBeNull();
expect(comp.success).toBe('OK');
});
it('should notify of error if change password fails', function() {
// GIVEN
spyOn(service, 'save').and.returnValue(Observable.throw('ERROR'));
comp.password = comp.confirmPassword = 'myPassword';
// WHEN
comp.changePassword();
// THEN
expect(comp.doNotMatch).toBeNull();
expect(comp.success).toBeNull();
expect(comp.error).toBe('ERROR');
});
});
});
import { ComponentFixture, TestBed, async, inject, tick, fakeAsync } from '@angular/core/testing';
import { Observable } from 'rxjs/Observable';
import { BootappTestModule } from '../../../test.module';
import { EMAIL_ALREADY_USED_TYPE, LOGIN_ALREADY_USED_TYPE } from '../../../../../../main/webapp/app/shared';
import { Register } from '../../../../../../main/webapp/app/account/register/register.service';
import { RegisterComponent } from '../../../../../../main/webapp/app/account/register/register.component';
describe('Component Tests', () => {
describe('RegisterComponent', () => {
let fixture: ComponentFixture<RegisterComponent>;
let comp: RegisterComponent;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [BootappTestModule],
declarations: [RegisterComponent],
providers: [
Register
]
})
.overrideTemplate(RegisterComponent, '')
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(RegisterComponent);
comp = fixture.componentInstance;
comp.ngOnInit();
});
it('should ensure the two passwords entered match', () => {
comp.registerAccount.password = 'password';
comp.confirmPassword = 'non-matching';
comp.register();
expect(comp.doNotMatch).toEqual('ERROR');
});
it('should update success to OK after creating an account',
inject([Register],
fakeAsync((service: Register) => {
spyOn(service, 'save').and.returnValue(Observable.of({}));
comp.registerAccount.password = comp.confirmPassword = 'password';
comp.register();
tick();
expect(service.save).toHaveBeenCalledWith({
password: 'password',
langKey: 'en'
});
expect(comp.success).toEqual(true);
expect(comp.registerAccount.langKey).toEqual('en');
expect(comp.errorUserExists).toBeNull();
expect(comp.errorEmailExists).toBeNull();
expect(comp.error).toBeNull();
})
)
);
it('should notify of user existence upon 400/login already in use',
inject([Register],
fakeAsync((service: Register) => {
spyOn(service, 'save').and.returnValue(Observable.throw({
status: 400,
error: { type: LOGIN_ALREADY_USED_TYPE }
}));
comp.registerAccount.password = comp.confirmPassword = 'password';
comp.register();
tick();
expect(comp.errorUserExists).toEqual('ERROR');
expect(comp.errorEmailExists).toBeNull();
expect(comp.error).toBeNull();
})
)
);
it('should notify of email existence upon 400/email address already in use',
inject([Register],
fakeAsync((service: Register) => {
spyOn(service, 'save').and.returnValue(Observable.throw({
status: 400,
error: { type: EMAIL_ALREADY_USED_TYPE }
}));
comp.registerAccount.password = comp.confirmPassword = 'password';
comp.register();
tick();
expect(comp.errorEmailExists).toEqual('ERROR');
expect(comp.errorUserExists).toBeNull();
expect(comp.error).toBeNull();
})
)
);
it('should notify of generic error',
inject([Register],
fakeAsync((service: Register) => {
spyOn(service, 'save').and.returnValue(Observable.throw({
status: 503
}));
comp.registerAccount.password = comp.confirmPassword = 'password';
comp.register();
tick();
expect(comp.errorUserExists).toBeNull();
expect(comp.errorEmailExists).toBeNull();
expect(comp.error).toEqual('ERROR');
})
)
);
});
});
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { Observable } from 'rxjs/Observable';
import { BootappTestModule } from '../../../test.module';
import { Principal, AccountService } from '../../../../../../main/webapp/app/shared';
import { SettingsComponent } from '../../../../../../main/webapp/app/account/settings/settings.component';
describe('Component Tests', () => {
describe('SettingsComponent', () => {
let comp: SettingsComponent;
let fixture: ComponentFixture<SettingsComponent>;
let mockAuth: any;
let mockPrincipal: any;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [BootappTestModule],
declarations: [SettingsComponent],
providers: [
]
})
.overrideTemplate(SettingsComponent, '')
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(SettingsComponent);
comp = fixture.componentInstance;
mockAuth = fixture.debugElement.injector.get(AccountService);
mockPrincipal = fixture.debugElement.injector.get(Principal);
});
it('should send the current identity upon save', () => {
// GIVEN
const accountValues = {
firstName: 'John',
lastName: 'Doe',
activated: true,
email: 'john.doe@mail.com',
langKey: 'en',
login: 'john'
};
mockPrincipal.setResponse(accountValues);
// WHEN
comp.settingsAccount = accountValues;
comp.save();
// THEN
expect(mockPrincipal.identitySpy).toHaveBeenCalled();
expect(mockAuth.saveSpy).toHaveBeenCalledWith(accountValues);
expect(comp.settingsAccount).toEqual(accountValues);
});
it('should notify of success upon successful save', () => {
// GIVEN
const accountValues = {
firstName: 'John',
lastName: 'Doe'
};
mockPrincipal.setResponse(accountValues);
// WHEN
comp.save();
// THEN
expect(comp.error).toBeNull();
expect(comp.success).toBe('OK');
});
it('should notify of error upon failed save', () => {
// GIVEN
mockAuth.saveSpy.and.returnValue(Observable.throw('ERROR'));
// WHEN
comp.save();
// THEN
expect(comp.error).toEqual('ERROR');
expect(comp.success).toBeNull();
});
});
});
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { NgbPaginationConfig} from '@ng-bootstrap/ng-bootstrap';
import { BootappTestModule } from '../../../test.module';
import { PaginationConfig } from '../../../../../../main/webapp/app/blocks/config/uib-pagination.config';
import { AuditsComponent } from '../../../../../../main/webapp/app/admin/audits/audits.component';
import { AuditsService } from '../../../../../../main/webapp/app/admin/audits/audits.service';
import { ITEMS_PER_PAGE } from '../../../../../../main/webapp/app/shared';
function build2DigitsDatePart(datePart: number) {
return `0${datePart}`.slice(-2);
}
function getDate(isToday= true) {
let date: Date = new Date();
if (isToday) {
// Today + 1 day - needed if the current day must be included
date.setDate(date.getDate() + 1);
} else {
// get last month
if (date.getMonth() === 0) {
date = new Date(date.getFullYear() - 1, 11, date.getDate());
} else {
date = new Date(date.getFullYear(), date.getMonth() - 1, date.getDate());
}
}
const monthString = build2DigitsDatePart(date.getMonth() + 1);
const dateString = build2DigitsDatePart(date.getDate());
return `${date.getFullYear()}-${monthString}-${dateString}`;
}
describe('Component Tests', () => {
describe('AuditsComponent', () => {
let comp: AuditsComponent;
let fixture: ComponentFixture<AuditsComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [BootappTestModule],
declarations: [AuditsComponent],
providers: [
AuditsService,
NgbPaginationConfig,
PaginationConfig
]
})
.overrideTemplate(AuditsComponent, '')
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AuditsComponent);
comp = fixture.componentInstance;
});
describe('today function ', () => {
it('should set toDate to current date', () => {
comp.today();
expect(comp.toDate).toBe(getDate());
});
});
describe('previousMonth function ', () => {
it('should set fromDate to current date', () => {
comp.previousMonth();
expect(comp.fromDate).toBe(getDate(false));
});
});
describe('By default, on init', () => {
it('should set all default values correctly', () => {
fixture.detectChanges();
expect(comp.toDate).toBe(getDate());
expect(comp.fromDate).toBe(getDate(false));
expect(comp.itemsPerPage).toBe(ITEMS_PER_PAGE);
expect(comp.page).toBe(1);
expect(comp.reverse).toBeFalsy();
expect(comp.orderProp).toBe('timestamp');
});
});
});
});
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { BootappTestModule } from '../../../test.module';
import { JhiHealthCheckComponent } from '../../../../../../main/webapp/app/admin/health/health.component';
import { JhiHealthService } from '../../../../../../main/webapp/app/admin/health/health.service';
describe('Component Tests', () => {
describe('JhiHealthCheckComponent', () => {
let comp: JhiHealthCheckComponent;
let fixture: ComponentFixture<JhiHealthCheckComponent>;
let service: JhiHealthService;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [BootappTestModule],
declarations: [JhiHealthCheckComponent],
providers: [
JhiHealthService
]
})
.overrideTemplate(JhiHealthCheckComponent, '')
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(JhiHealthCheckComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(JhiHealthService);
});
describe('baseName and subSystemName', () => {
it('should return the basename when it has no sub system', () => {
expect(comp.baseName('base')).toBe('base');
});
it('should return the basename when it has sub systems', () => {
expect(comp.baseName('base.subsystem.system')).toBe('base');
});
it('should return the sub system name', () => {
expect(comp.subSystemName('subsystem')).toBe('');
});
it('should return the subsystem when it has multiple keys', () => {
expect(comp.subSystemName('subsystem.subsystem.system')).toBe(' - subsystem.system');
});
});
describe('transformHealthData', () => {
it('should flatten empty health data', () => {
const data = {};
const expected = [];
expect(service.transformHealthData(data)).toEqual(expected);
});
});
it('should flatten health data with no subsystems', () => {
const data = {
'status': 'UP',
'db': {
'status': 'UP',
'database': 'H2',
'hello': '1'
},
'mail': {
'status': 'UP',
'error': 'mail.a.b.c'
}
};
const expected = [
{
'name': 'db',
'status': 'UP',
'details': {
'database': 'H2',
'hello': '1'
}
},
{
'name': 'mail',
'error': 'mail.a.b.c',
'status': 'UP'
}
];
expect(service.transformHealthData(data)).toEqual(expected);
});
it('should flatten health data with subsystems at level 1, main system has no additional information', () => {
const data = {
'status': 'UP',
'db': {
'status': 'UP',
'database': 'H2',
'hello': '1'
},
'mail': {
'status': 'UP',
'error': 'mail.a.b.c'
},
'system': {
'status': 'DOWN',
'subsystem1': {
'status': 'UP',
'property1': 'system.subsystem1.property1'
},
'subsystem2': {
'status': 'DOWN',
'error': 'system.subsystem1.error',
'property2': 'system.subsystem2.property2'
}
}
};
const expected = [
{
'name': 'db',
'status': 'UP',
'details': {
'database': 'H2',
'hello': '1'
}
},
{
'name': 'mail',
'error': 'mail.a.b.c',
'status': 'UP'
},
{
'name': 'system.subsystem1',
'status': 'UP',
'details': {
'property1': 'system.subsystem1.property1'
}
},
{
'name': 'system.subsystem2',
'error': 'system.subsystem1.error',
'status': 'DOWN',
'details': {
'property2': 'system.subsystem2.property2'
}
}
];
expect(service.transformHealthData(data)).toEqual(expected);
});
it('should flatten health data with subsystems at level 1, main system has additional information', () => {
const data = {
'status': 'UP',
'db': {
'status': 'UP',
'database': 'H2',
'hello': '1'
},
'mail': {
'status': 'UP',
'error': 'mail.a.b.c'
},
'system': {
'status': 'DOWN',
'property1': 'system.property1',
'subsystem1': {
'status': 'UP',
'property1': 'system.subsystem1.property1'
},
'subsystem2': {
'status': 'DOWN',
'error': 'system.subsystem1.error',
'property2': 'system.subsystem2.property2'
}
}
};
const expected = [
{
'name': 'db',
'status': 'UP',
'details': {
'database': 'H2',
'hello': '1'
}
},
{
'name': 'mail',
'error': 'mail.a.b.c',
'status': 'UP'
},
{
'name': 'system',
'status': 'DOWN',
'details': {
'property1': 'system.property1'
}
},
{
'name': 'system.subsystem1',
'status': 'UP',
'details': {
'property1': 'system.subsystem1.property1'
}
},
{
'name': 'system.subsystem2',
'error': 'system.subsystem1.error',
'status': 'DOWN',
'details': {
'property2': 'system.subsystem2.property2'
}
}
];
expect(service.transformHealthData(data)).toEqual(expected);
});
it('should flatten health data with subsystems at level 1, main system has additional error', () => {
const data = {
'status': 'UP',
'db': {
'status': 'UP',
'database': 'H2',
'hello': '1'
},
'mail': {
'status': 'UP',
'error': 'mail.a.b.c'
},
'system': {
'status': 'DOWN',
'error': 'show me',
'subsystem1': {
'status': 'UP',
'property1': 'system.subsystem1.property1'
},
'subsystem2': {
'status': 'DOWN',
'error': 'system.subsystem1.error',
'property2': 'system.subsystem2.property2'
}
}
};
const expected = [
{
'name': 'db',
'status': 'UP',
'details': {
'database': 'H2',
'hello': '1'
}
},
{
'name': 'mail',
'error': 'mail.a.b.c',
'status': 'UP'
},
{
'name': 'system',
'error': 'show me',
'status': 'DOWN'
},
{
'name': 'system.subsystem1',
'status': 'UP',
'details': {
'property1': 'system.subsystem1.property1'
}
},
{
'name': 'system.subsystem2',
'error': 'system.subsystem1.error',
'status': 'DOWN',
'details': {
'property2': 'system.subsystem2.property2'
}
}
];
expect(service.transformHealthData(data)).toEqual(expected);
});
});
});
import { ComponentFixture, TestBed, async, inject, fakeAsync, tick } from '@angular/core/testing';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Observable } from 'rxjs/Observable';
import { JhiEventManager } from 'ng-jhipster';
import { BootappTestModule } from '../../../test.module';
import { UserMgmtDeleteDialogComponent } from '../../../../../../main/webapp/app/admin/user-management/user-management-delete-dialog.component';
import { UserService } from '../../../../../../main/webapp/app/shared';
describe('Component Tests', () => {
describe('User Management Delete Component', () => {
let comp: UserMgmtDeleteDialogComponent;
let fixture: ComponentFixture<UserMgmtDeleteDialogComponent>;
let service: UserService;
let mockEventManager: any;
let mockActiveModal: any;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [BootappTestModule],
declarations: [UserMgmtDeleteDialogComponent],
providers: [
UserService
]
})
.overrideTemplate(UserMgmtDeleteDialogComponent, '')
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(UserMgmtDeleteDialogComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(UserService);
mockEventManager = fixture.debugElement.injector.get(JhiEventManager);
mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal);
});
describe('confirmDelete', () => {
it('Should call delete service on confirmDelete',
inject([],
fakeAsync(() => {
// GIVEN
spyOn(service, 'delete').and.returnValue(Observable.of({}));
// WHEN
comp.confirmDelete('user');
tick();
// THEN
expect(service.delete).toHaveBeenCalledWith('user');
expect(mockActiveModal.dismissSpy).toHaveBeenCalled();
expect(mockEventManager.broadcastSpy).toHaveBeenCalled();
})
)
);
});
});
});
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { ActivatedRoute } from '@angular/router';
import { HttpResponse } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import { BootappTestModule } from '../../../test.module';
import { MockActivatedRoute } from '../../../helpers/mock-route.service';
import { UserMgmtDetailComponent } from '../../../../../../main/webapp/app/admin/user-management/user-management-detail.component';
import { UserService, User } from '../../../../../../main/webapp/app/shared';
describe('Component Tests', () => {
describe('User Management Detail Component', () => {
let comp: UserMgmtDetailComponent;
let fixture: ComponentFixture<UserMgmtDetailComponent>;
let service: UserService;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [BootappTestModule],
declarations: [UserMgmtDetailComponent],
providers: [
{
provide: ActivatedRoute,
useValue: new MockActivatedRoute({login: 'user'})
},
UserService
]
})
.overrideTemplate(UserMgmtDetailComponent, '')
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(UserMgmtDetailComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(UserService);
});
describe('OnInit', () => {
it('Should call load all on init', () => {
// GIVEN
spyOn(service, 'find').and.returnValue(Observable.of(new HttpResponse({
body: new User(1, 'user', 'first', 'last', 'first@last.com', true, 'en', ['ROLE_USER'], 'admin', null, null, null)
})));
// WHEN
comp.ngOnInit();
// THEN
expect(service.find).toHaveBeenCalledWith('user');
expect(comp.user).toEqual(jasmine.objectContaining({
id: 1,
login: 'user',
firstName: 'first',
lastName: 'last',
email: 'first@last.com',
activated: true,
langKey: 'en',
authorities: ['ROLE_USER'],
createdBy: 'admin',
createdDate: null,
lastModifiedBy: null,
lastModifiedDate: null,
password: null
}));
});
});
});
});
import { ComponentFixture, TestBed, async, inject, fakeAsync, tick } from '@angular/core/testing';
import { HttpResponse } from '@angular/common/http';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Observable } from 'rxjs/Observable';
import { JhiEventManager } from 'ng-jhipster';
import { BootappTestModule } from '../../../test.module';
import { UserMgmtDialogComponent } from '../../../../../../main/webapp/app/admin/user-management/user-management-dialog.component';
import { UserService, User } from '../../../../../../main/webapp/app/shared';
describe('Component Tests', () => {
describe('User Management Dialog Component', () => {
let comp: UserMgmtDialogComponent;
let fixture: ComponentFixture<UserMgmtDialogComponent>;
let service: UserService;
let mockEventManager: any;
let mockActiveModal: any;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [BootappTestModule],
declarations: [UserMgmtDialogComponent],
providers: [
UserService
]
})
.overrideTemplate(UserMgmtDialogComponent, '')
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(UserMgmtDialogComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(UserService);
mockEventManager = fixture.debugElement.injector.get(JhiEventManager);
mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal);
});
describe('OnInit', () => {
it('Should load authorities and language on init',
inject([],
fakeAsync(() => {
// GIVEN
spyOn(service, 'authorities').and.returnValue(Observable.of(['USER']));
// WHEN
comp.ngOnInit();
// THEN
expect(service.authorities).toHaveBeenCalled();
expect(comp.authorities).toEqual(['USER']);
})
)
);
});
describe('save', () => {
it('Should call update service on save for existing user',
inject([],
fakeAsync(() => {
// GIVEN
const entity = new User(123);
spyOn(service, 'update').and.returnValue(Observable.of(new HttpResponse({
body: entity
})));
comp.user = entity;
// WHEN
comp.save();
tick(); // simulate async
// THEN
expect(service.update).toHaveBeenCalledWith(entity);
expect(comp.isSaving).toEqual(false);
expect(mockEventManager.broadcastSpy).toHaveBeenCalledWith({ name: 'userListModification', content: 'OK'});
expect(mockActiveModal.dismissSpy).toHaveBeenCalled();
})
)
);
it('Should call create service on save for new user',
inject([],
fakeAsync(() => {
// GIVEN
const entity = new User();
spyOn(service, 'create').and.returnValue(Observable.of(new HttpResponse({body: entity})));
comp.user = entity;
// WHEN
comp.save();
tick(); // simulate async
// THEN
expect(service.create).toHaveBeenCalledWith(entity);
expect(comp.isSaving).toEqual(false);
expect(mockEventManager.broadcastSpy).toHaveBeenCalledWith({ name: 'userListModification', content: 'OK'});
expect(mockActiveModal.dismissSpy).toHaveBeenCalled();
})
)
);
});
});
});
import { ComponentFixture, TestBed, async, inject, fakeAsync, tick } from '@angular/core/testing';
import { Observable } from 'rxjs/Observable';
import { HttpHeaders, HttpResponse } from '@angular/common/http';
import { BootappTestModule } from '../../../test.module';
import { UserMgmtComponent } from '../../../../../../main/webapp/app/admin/user-management/user-management.component';
import { UserService, User } from '../../../../../../main/webapp/app/shared';
describe('Component Tests', () => {
describe('User Management Component', () => {
let comp: UserMgmtComponent;
let fixture: ComponentFixture<UserMgmtComponent>;
let service: UserService;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [BootappTestModule],
declarations: [UserMgmtComponent],
providers: [
UserService
]
})
.overrideTemplate(UserMgmtComponent, '')
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(UserMgmtComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(UserService);
});
describe('OnInit', () => {
it('Should call load all on init',
inject([],
fakeAsync(() => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(Observable.of(new HttpResponse({
body: [new User(123)],
headers
})));
// WHEN
comp.ngOnInit();
tick(); // simulate async
// THEN
expect(service.query).toHaveBeenCalled();
expect(comp.users[0]).toEqual(jasmine.objectContaining({id: 123}));
})
)
);
});
describe('setActive', () => {
it('Should update user and call load all',
inject([],
fakeAsync(() => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
const user = new User(123);
spyOn(service, 'query').and.returnValue(Observable.of(new HttpResponse({
body: [user],
headers
})));
spyOn(service, 'update').and.returnValue(Observable.of(new HttpResponse({ status: 200 })));
// WHEN
comp.setActive(user, true);
tick(); // simulate async
// THEN
expect(service.update).toHaveBeenCalledWith(user);
expect(service.query).toHaveBeenCalled();
expect(comp.users[0]).toEqual(jasmine.objectContaining({id: 123}));
})
)
);
});
});
});
import { ComponentFixture, TestBed, async, inject, fakeAsync, tick } from '@angular/core/testing';
import { Router } from '@angular/router';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { JhiEventManager } from 'ng-jhipster';
import { LoginService } from '../../../../../../main/webapp/app/shared/login/login.service';
import { JhiLoginModalComponent } from '../../../../../../main/webapp/app/shared/login/login.component';
import { StateStorageService } from '../../../../../../main/webapp/app/shared/auth/state-storage.service';
import { BootappTestModule } from '../../../test.module';
import { MockLoginService } from '../../../helpers/mock-login.service';
import { MockStateStorageService } from '../../../helpers/mock-state-storage.service';
describe('Component Tests', () => {
describe('LoginComponent', () => {
let comp: JhiLoginModalComponent;
let fixture: ComponentFixture<JhiLoginModalComponent>;
let mockLoginService: any;
let mockStateStorageService: any;
let mockRouter: any;
let mockEventManager: any;
let mockActiveModal: any;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [BootappTestModule],
declarations: [JhiLoginModalComponent],
providers : [
{
provide: LoginService,
useClass: MockLoginService
},
{
provide: StateStorageService,
useClass: MockStateStorageService
}
]
})
.overrideTemplate(JhiLoginModalComponent, '')
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(JhiLoginModalComponent);
comp = fixture.componentInstance;
mockLoginService = fixture.debugElement.injector.get(LoginService);
mockStateStorageService = fixture.debugElement.injector.get(StateStorageService);
mockRouter = fixture.debugElement.injector.get(Router);
mockEventManager = fixture.debugElement.injector.get(JhiEventManager);
mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal);
});
it('should authenticate the user upon login when previous state was set',
inject([],
fakeAsync(() => {
// GIVEN
const credentials = {
username: 'admin',
password: 'admin',
rememberMe: true
};
comp.username = 'admin';
comp.password = 'admin';
comp.rememberMe = true;
comp.credentials = credentials;
mockLoginService.setResponse({});
mockStateStorageService.setResponse({redirect: 'dummy'});
// WHEN/
comp.login();
tick(); // simulate async
// THEN
expect(comp.authenticationError).toEqual(false);
expect(mockActiveModal.dismissSpy).toHaveBeenCalledWith('login success');
expect(mockEventManager.broadcastSpy).toHaveBeenCalledTimes(1);
expect(mockLoginService.loginSpy).toHaveBeenCalledWith(credentials);
expect(mockStateStorageService.getUrlSpy).toHaveBeenCalledTimes(1);
expect(mockStateStorageService.storeUrlSpy).toHaveBeenCalledWith(null);
expect(mockRouter.navigateSpy).toHaveBeenCalledWith([{redirect: 'dummy'}]);
})
)
);
it('should authenticate the user upon login when previous state was not set',
inject([],
fakeAsync(() => {
// GIVEN
const credentials = {
username: 'admin',
password: 'admin',
rememberMe: true
};
comp.username = 'admin';
comp.password = 'admin';
comp.rememberMe = true;
comp.credentials = credentials;
mockLoginService.setResponse({});
mockStateStorageService.setResponse(null);
// WHEN
comp.login();
tick(); // simulate async
// THEN
expect(comp.authenticationError).toEqual(false);
expect(mockActiveModal.dismissSpy).toHaveBeenCalledWith('login success');
expect(mockEventManager.broadcastSpy).toHaveBeenCalledTimes(1);
expect(mockLoginService.loginSpy).toHaveBeenCalledWith(credentials);
expect(mockStateStorageService.getUrlSpy).toHaveBeenCalledTimes(1);
expect(mockStateStorageService.storeUrlSpy).not.toHaveBeenCalled();
expect(mockRouter.navigateSpy).not.toHaveBeenCalled();
})
)
);
it('should empty the credentials upon cancel', () => {
// GIVEN
const credentials = {
username: 'admin',
password: 'admin',
rememberMe: true
};
const expected = {
username: null,
password: null,
rememberMe: true
};
comp.credentials = credentials;
// WHEN
comp.cancel();
// THEN
expect(comp.authenticationError).toEqual(false);
expect(comp.credentials).toEqual(expected);
expect(mockActiveModal.dismissSpy).toHaveBeenCalledWith('cancel');
});
it('should redirect user when register', () => {
// WHEN
comp.register();
// THEN
expect(mockActiveModal.dismissSpy).toHaveBeenCalledWith('to state register');
expect(mockRouter.navigateSpy).toHaveBeenCalledWith(['/register']);
});
it('should redirect user when request password', () => {
// WHEN
comp.requestResetPassword();
// THEN
expect(mockActiveModal.dismissSpy).toHaveBeenCalledWith('to state requestReset');
expect(mockRouter.navigateSpy).toHaveBeenCalledWith(['/reset', 'request']);
});
});
});
import { TestBed } from '@angular/core/testing';
import { JhiDateUtils } from 'ng-jhipster';
import { UserService, User } from './../../../../../../main/webapp/app/shared';
import { SERVER_API_URL } from './../../../../../../main/webapp/app/app.constants';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
describe('Service Tests', () => {
describe('User Service', () => {
let service: UserService;
let httpMock;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
HttpClientTestingModule
],
providers: [
JhiDateUtils,
UserService
]
});
service = TestBed.get(UserService);
httpMock = TestBed.get(HttpTestingController);
});
afterEach(() => {
httpMock.verify();
});
describe('Service methods', () => {
it('should call correct URL', () => {
service.find('user').subscribe(() => {});
const req = httpMock.expectOne({ method: 'GET' });
const resourceUrl = SERVER_API_URL + 'api/users';
expect(req.request.url).toEqual(`${resourceUrl}/user`);
});
it('should return User', () => {
service.find('user').subscribe((received) => {
expect(received.body.login).toEqual('user');
});
const req = httpMock.expectOne({ method: 'GET' });
req.flush(new User(1, 'user'));
});
it('should return Authorities', () => {
service.authorities().subscribe((_authorities) => {
expect(_authorities).toEqual(['ROLE_USER', 'ROLE_ADMIN']);
});
const req = httpMock.expectOne({ method: 'GET' });
req.flush(['ROLE_USER', 'ROLE_ADMIN']);
});
it('should propagate not found response', () => {
service.find('user').subscribe(null, (_error: any) => {
expect(_error.status).toEqual(404);
});
const req = httpMock.expectOne({ method: 'GET' });
req.flush('Invalid request parameters', {
status: 404, statusText: 'Bad Request'
});
});
});
});
});
/// <reference path="../../../../node_modules/@types/jasmine/index.d.ts" />
import 'core-js';
import 'zone.js/dist/zone';
import 'zone.js/dist/long-stack-trace-zone';
import 'zone.js/dist/async-test';
import 'zone.js/dist/fake-async-test';
import 'zone.js/dist/sync-test';
import 'zone.js/dist/proxy';
import 'zone.js/dist/jasmine-patch';
import 'rxjs';
import 'intl/locale-data/jsonp/en-US.js';
import { TestBed } from '@angular/core/testing';
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
TestBed.initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());
declare let require: any;
const testsContext: any = require.context('./', true, /\.spec/);
testsContext.keys().forEach(testsContext);
import { SpyObject } from './spyobject';
import { AccountService } from '../../../../main/webapp/app/shared/auth/account.service';
import Spy = jasmine.Spy;
export class MockAccountService extends SpyObject {
getSpy: Spy;
saveSpy: Spy;
fakeResponse: any;
constructor() {
super(AccountService);
this.fakeResponse = null;
this.getSpy = this.spy('get').andReturn(this);
this.saveSpy = this.spy('save').andReturn(this);
}
subscribe(callback: any) {
callback(this.fakeResponse);
}
setResponse(json: any): void {
this.fakeResponse = json;
}
}
import { SpyObject } from './spyobject';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import Spy = jasmine.Spy;
export class MockActiveModal extends SpyObject {
dismissSpy: Spy;
constructor() {
super(NgbActiveModal);
this.dismissSpy = this.spy('dismiss').andReturn(this);
}
}
import { SpyObject } from './spyobject';
import { JhiEventManager } from 'ng-jhipster';
import Spy = jasmine.Spy;
export class MockEventManager extends SpyObject {
broadcastSpy: Spy;
constructor() {
super(JhiEventManager);
this.broadcastSpy = this.spy('broadcast').andReturn(this);
}
}
import { SpyObject } from './spyobject';
import { LoginService } from '../../../../main/webapp/app/shared/login/login.service';
import Spy = jasmine.Spy;
export class MockLoginService extends SpyObject {
loginSpy: Spy;
logoutSpy: Spy;
registerSpy: Spy;
requestResetPasswordSpy: Spy;
cancelSpy: Spy;
constructor() {
super(LoginService);
this.setLoginSpy({});
this.logoutSpy = this.spy('logout').andReturn(this);
this.registerSpy = this.spy('register').andReturn(this);
this.requestResetPasswordSpy = this.spy('requestResetPassword').andReturn(this);
this.cancelSpy = this.spy('cancel').andReturn(this);
}
setLoginSpy(json: any) {
this.loginSpy = this.spy('login').andReturn(Promise.resolve(json));
}
setResponse(json: any): void {
this.setLoginSpy(json);
}
}
import { SpyObject } from './spyobject';
import { Principal } from '../../../../main/webapp/app/shared/auth/principal.service';
import Spy = jasmine.Spy;
export class MockPrincipal extends SpyObject {
identitySpy: Spy;
constructor() {
super(Principal);
this.setIdentitySpy({});
}
setIdentitySpy(json: any): any {
this.identitySpy = this.spy('identity').andReturn(Promise.resolve(json));
}
setResponse(json: any): void {
this.setIdentitySpy(json);
}
}
import { ActivatedRoute, Router } from '@angular/router';
import { SpyObject } from './spyobject';
import { Observable } from 'rxjs';
import Spy = jasmine.Spy;
export class MockActivatedRoute extends ActivatedRoute {
constructor(parameters?: any) {
super();
this.queryParams = Observable.of(parameters);
this.params = Observable.of(parameters);
this.data = Observable.of({ ...parameters, pagingParams: {
page: 10,
ascending: false,
predicate: 'id'
}});
}
}
export class MockRouter extends SpyObject {
navigateSpy: Spy;
constructor() {
super(Router);
this.navigateSpy = this.spy('navigate');
}
}
import { SpyObject } from './spyobject';
import { StateStorageService } from '../../../../main/webapp/app/shared/auth/state-storage.service';
import Spy = jasmine.Spy;
export class MockStateStorageService extends SpyObject {
getUrlSpy: Spy;
storeUrlSpy: Spy;
constructor() {
super(StateStorageService);
this.setUrlSpy({});
this.storeUrlSpy = this.spy('storeUrl').andReturn(this);
}
setUrlSpy(json) {
this.getUrlSpy = this.spy('getUrl').andReturn(json);
}
setResponse(json: any): void {
this.setUrlSpy(json);
}
}
export interface GuinessCompatibleSpy extends jasmine.Spy {
/** By chaining the spy with and.returnValue, all calls to the function will return a specific
* value. */
andReturn(val: any): void;
/** By chaining the spy with and.callFake, all calls to the spy will delegate to the supplied
* function. */
andCallFake(fn: Function): GuinessCompatibleSpy;
/** removes all recorded calls */
reset();
}
export class SpyObject {
static stub(object = null, config = null, overrides = null) {
if (!(object instanceof SpyObject)) {
overrides = config;
config = object;
object = new SpyObject();
}
const m = {};
Object.keys(config).forEach((key) => m[key] = config[key]);
Object.keys(overrides).forEach((key) => m[key] = overrides[key]);
Object.keys(m).forEach((key) => {
object.spy(key).andReturn(m[key]);
});
return object;
}
constructor(type = null) {
if (type) {
Object.keys(type.prototype).forEach((prop) => {
let m = null;
try {
m = type.prototype[prop];
} catch (e) {
// As we are creating spys for abstract classes,
// these classes might have getters that throw when they are accessed.
// As we are only auto creating spys for methods, this
// should not matter.
}
if (typeof m === 'function') {
this.spy(prop);
}
});
}
}
spy(name) {
if (!this[name]) {
this[name] = this._createGuinnessCompatibleSpy(name);
}
return this[name];
}
prop(name, value) {
this[name] = value;
}
/** @internal */
_createGuinnessCompatibleSpy(name): GuinessCompatibleSpy {
const newSpy: GuinessCompatibleSpy = < any > jasmine.createSpy(name);
newSpy.andCallFake = < any > newSpy.and.callFake;
newSpy.andReturn = < any > newSpy.and.returnValue;
newSpy.reset = < any > newSpy.calls.reset;
// revisit return null here (previously needed for rtts_assert).
newSpy.and.returnValue(null);
return newSpy;
}
}
import { DatePipe } from '@angular/common';
import { ActivatedRoute, Router } from '@angular/router';
import { NgModule, ElementRef, Renderer } from '@angular/core';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { JhiDataUtils, JhiDateUtils, JhiEventManager, JhiAlertService, JhiParseLinks } from 'ng-jhipster';
import { Principal, AccountService, LoginModalService } from '../../../main/webapp/app/shared';
import { MockPrincipal } from './helpers/mock-principal.service';
import { MockAccountService } from './helpers/mock-account.service';
import { MockActivatedRoute, MockRouter } from './helpers/mock-route.service';
import { MockActiveModal } from './helpers/mock-active-modal.service';
import { MockEventManager } from './helpers/mock-event-manager.service';
@NgModule({
providers: [
DatePipe,
JhiDataUtils,
JhiDateUtils,
JhiParseLinks,
{
provide: JhiEventManager,
useClass:  MockEventManager
},
{
provide: NgbActiveModal,
useClass: MockActiveModal
},
{
provide: ActivatedRoute,
useValue: new MockActivatedRoute({id: 123})
},
{
provide: Router,
useClass: MockRouter
},
{
provide: Principal,
useClass: MockPrincipal
},
{
provide: AccountService,
useClass: MockAccountService
},
{
provide: LoginModalService,
useValue: null
},
{
provide: ElementRef,
useValue: null
},
{
provide: Renderer,
useValue: null
},
{
provide: JhiAlertService,
useValue: null
},
{
provide: NgbModal,
useValue: null
},
],
imports: [HttpClientTestingModule]
})
export class BootappTestModule {}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment