automatic project update

This commit is contained in:
Julien Dubois 2015-11-02 20:32:50 +01:00
parent 484ccbb7f1
commit 392818363b
72 changed files with 2383 additions and 537 deletions

5
.gitignore vendored
View File

@ -121,3 +121,8 @@ Desktop.ini
# Gradle Wrapper
######################
!gradle/wrapper/gradle-wrapper.jar
######################
# Maven Wrapper
######################
!.mvn/wrapper/maven-wrapper.jar

BIN
.mvn/wrapper/maven-wrapper.jar vendored Normal file

Binary file not shown.

1
.mvn/wrapper/maven-wrapper.properties vendored Normal file
View File

@ -0,0 +1 @@
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.3/apache-maven-3.3.3-bin.zip

View File

@ -1,4 +1,4 @@
// Generated on 2015-10-23 using generator-jhipster 2.23.0
// Generated on 2015-11-02 using generator-jhipster 2.23.0
'use strict';
var fs = require('fs');

View File

@ -1,6 +1,6 @@
# Developing sampleApplication
This application was generated using JHipster, you can find documentation and help at [https://jhipster.gitub.io][].
This application was generated using JHipster, you can find documentation and help at [https://jhipster.github.io](https://jhipster.github.io).
Before you can build this project, you must install and configure the following dependencies on your machine:

View File

@ -12,6 +12,7 @@
"angular-dynamic-locale": "0.1.27",
"angular-i18n": "1.4.5",
"angular-local-storage": "0.2.2",
"angular-loading-bar": "0.8.0",
"angular-resource": "1.4.5",
"angular-sanitize": "1.4.5",
"angular-translate": "2.7.2",

View File

@ -1,6 +1,6 @@
jhipster-prod-mysql:
container_name: sampleApplication-prod-mysql
image: mysql
image: mysql:5.7.9
# volumes:
# - ~/volumes/jhipster/sampleApplication/prod-mysql/:/var/lib/mysql/
environment:
@ -9,5 +9,5 @@ jhipster-prod-mysql:
- MYSQL_DATABASE=sampleapplication
ports:
- "3306:3306"
command: mysqld --lower_case_table_name=1
command: mysqld --lower_case_table_names=1

233
mvnw vendored Executable file
View File

@ -0,0 +1,233 @@
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Maven2 Start Up Batch script
#
# Required ENV vars:
# ------------------
# JAVA_HOME - location of a JDK home dir
#
# Optional ENV vars
# -----------------
# M2_HOME - location of maven2's installed home dir
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
if [ -z "$MAVEN_SKIP_RC" ] ; then
if [ -f /etc/mavenrc ] ; then
. /etc/mavenrc
fi
if [ -f "$HOME/.mavenrc" ] ; then
. "$HOME/.mavenrc"
fi
fi
# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
mingw=false
case "`uname`" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true;;
Darwin*) darwin=true
#
# Look for the Apple JDKs first to preserve the existing behaviour, and then look
# for the new JDKs provided by Oracle.
#
if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then
#
# Apple JDKs
#
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
fi
if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then
#
# Apple JDKs
#
export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
fi
if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then
#
# Oracle JDKs
#
export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
fi
if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then
#
# Apple JDKs
#
export JAVA_HOME=`/usr/libexec/java_home`
fi
;;
esac
if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
JAVA_HOME=`java-config --jre-home`
fi
fi
if [ -z "$M2_HOME" ] ; then
## resolve links - $0 may be a link to maven's home
PRG="$0"
# need this for relative symlinks
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done
saveddir=`pwd`
M2_HOME=`dirname "$PRG"`/..
# make it fully qualified
M2_HOME=`cd "$M2_HOME" && pwd`
cd "$saveddir"
# echo Using m2 at $M2_HOME
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --unix "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi
# For Migwn, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$M2_HOME" ] &&
M2_HOME="`(cd "$M2_HOME"; pwd)`"
[ -n "$JAVA_HOME" ] &&
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
# TODO classpath?
fi
if [ -z "$JAVA_HOME" ]; then
javaExecutable="`which javac`"
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
readLink=`which readlink`
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
if $darwin ; then
javaHome="`dirname \"$javaExecutable\"`"
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
else
javaExecutable="`readlink -f \"$javaExecutable\"`"
fi
javaHome="`dirname \"$javaExecutable\"`"
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
fi
fi
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="`which java`"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly." >&2
echo " We cannot execute $JAVACMD" >&2
exit 1
fi
if [ -z "$JAVA_HOME" ] ; then
echo "Warning: JAVA_HOME environment variable is not set."
fi
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --path --windows "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
fi
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
local basedir=$(pwd)
local wdir=$(pwd)
while [ "$wdir" != '/' ] ; do
if [ -d "$wdir"/.mvn ] ; then
basedir=$wdir
break
fi
wdir=$(cd "$wdir/.."; pwd)
done
echo "${basedir}"
}
# concatenates all lines of a file
concat_lines() {
if [ -f "$1" ]; then
echo "$(tr -s '\n' ' ' < "$1")"
fi
}
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)}
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
export MAVEN_CMD_LINE_ARGS
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
exec "$JAVACMD" \
$MAVEN_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} "$@"

145
mvnw.cmd vendored Normal file
View File

@ -0,0 +1,145 @@
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM http://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Maven2 Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
set MAVEN_CMD_LINE_ARGS=%*
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar""
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%" == "on" pause
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
exit /B %ERROR_CODE%

View File

@ -82,6 +82,7 @@ public class DatabaseConfiguration {
* Open the TCP port for the H2 database, so it is available remotely.
*/
@Bean(initMethod = "start", destroyMethod = "stop")
@Profile(Constants.SPRING_PROFILE_DEVELOPMENT)
public Server h2TCPServer() throws SQLException {
return Server.createTcpServer("-tcp","-tcpAllowOthers");
}

View File

@ -1,73 +0,0 @@
package com.mycompany.myapp.config.metrics;
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
import org.springframework.boot.actuate.health.Health;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.StringUtils;
import javax.sql.DataSource;
import java.sql.Connection;
import java.util.HashMap;
import java.util.Map;
/**
* SpringBoot Actuator HealthIndicator check for the Database.
*/
public class DatabaseHealthIndicator extends AbstractHealthIndicator {
private JdbcTemplate jdbcTemplate;
private static Map<String, String> queries = new HashMap<>();
static {
queries.put("HSQL Database Engine",
"SELECT COUNT(*) FROM INFORMATION_SCHEMA.SYSTEM_USERS");
queries.put("Oracle", "SELECT 'Hello' from DUAL");
queries.put("Apache Derby", "SELECT 1 FROM SYSIBM.SYSDUMMY1");
queries.put("MySQL", "SELECT 1");
queries.put("PostgreSQL", "SELECT 1");
queries.put("Microsoft SQL Server", "SELECT 1");
}
private static String DEFAULT_QUERY = "SELECT 1";
private String query = null;
public DatabaseHealthIndicator(DataSource dataSource) {
this.jdbcTemplate = new JdbcTemplate(dataSource);
}
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
String product = getProduct();
builder.up().withDetail("database", product);
String query = detectQuery(product);
if (StringUtils.hasText(query)) {
try {
builder.withDetail("hello",
this.jdbcTemplate.queryForObject(query, Object.class));
} catch (Exception ex) {
builder.down(ex);
}
}
}
private String getProduct() {
return this.jdbcTemplate.execute((Connection connection) -> connection.getMetaData().getDatabaseProductName());
}
protected String detectQuery(String product) {
String query = this.query;
if (!StringUtils.hasText(query)) {
query = queries.get(product);
}
if (!StringUtils.hasText(query)) {
query = DEFAULT_QUERY;
}
return query;
}
public void setQuery(String query) {
this.query = query;
}
}

View File

@ -1,20 +0,0 @@
package com.mycompany.myapp.config.metrics;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.inject.Inject;
import javax.sql.DataSource;
@Configuration
public class JHipsterHealthIndicatorConfiguration {
@Inject
private DataSource dataSource;
@Bean
public HealthIndicator dbHealthIndicator() {
return new DatabaseHealthIndicator(dataSource);
}
}

View File

@ -1,4 +0,0 @@
/**
* Health and Metrics specific code.
*/
package com.mycompany.myapp.config.metrics;

View File

@ -24,6 +24,8 @@ public interface UserRepository extends JpaRepository<User, Long> {
Optional<User> findOneByLogin(String login);
Optional<User> findOneById(Long userId);
@Override
void delete(User t);

View File

@ -82,9 +82,8 @@ public final class SecurityUtils {
/**
* If the current user has a specific authority (security role).
*
* <p> The name of this method comes from the isUserInRole() method in the Servlet API</p>
*/
public static boolean isUserInRole(String authority) {
public static boolean isCurrentUserInRole(String authority) {
SecurityContext securityContext = SecurityContextHolder.getContext();
Authentication authentication = securityContext.getAuthentication();
if (authentication != null) {

View File

@ -74,7 +74,7 @@ public class UserService {
public Optional<User> requestPasswordReset(String mail) {
return userRepository.findOneByEmail(mail)
.filter(user -> user.getActivated())
.filter(User::getActivated)
.map(user -> {
user.setResetKey(RandomUtil.generateResetKey());
user.setResetDate(ZonedDateTime.now());
@ -109,7 +109,7 @@ public class UserService {
}
public void updateUserInformation(String firstName, String lastName, String email, String langKey) {
userRepository.findOneByLogin(SecurityUtils.getCurrentUserLogin()).ifPresent(u -> {
userRepository.findOneById(SecurityUtils.getCurrentUserId()).ifPresent(u -> {
u.setFirstName(firstName);
u.setLastName(lastName);
u.setEmail(email);
@ -120,7 +120,7 @@ public class UserService {
}
public void changePassword(String password) {
userRepository.findOneByLogin(SecurityUtils.getCurrentUserLogin()).ifPresent(u-> {
userRepository.findOneById(SecurityUtils.getCurrentUserId()).ifPresent(u -> {
String encryptedPassword = passwordEncoder.encode(password);
u.setPassword(encryptedPassword);
userRepository.save(u);
@ -145,7 +145,7 @@ public class UserService {
@Transactional(readOnly = true)
public User getUserWithAuthorities() {
User user = userRepository.findOneByLogin(SecurityUtils.getCurrentUserLogin()).get();
User user = userRepository.findOneById(SecurityUtils.getCurrentUserId()).get();
user.getAuthorities().size(); // eagerly load the association
return user;
}

View File

@ -123,8 +123,7 @@ public class AccountResource {
@Timed
public ResponseEntity<String> saveAccount(@RequestBody UserDTO userDTO) {
return userRepository
.findOneByLogin(userDTO.getLogin())
.filter(u -> u.getLogin().equals(SecurityUtils.getCurrentUserLogin()))
.findOneById(SecurityUtils.getCurrentUserId())
.map(u -> {
userService.updateUserInformation(userDTO.getFirstName(), userDTO.getLastName(), userDTO.getEmail(),
userDTO.getLangKey());
@ -156,7 +155,7 @@ public class AccountResource {
produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public ResponseEntity<List<PersistentToken>> getCurrentSessions() {
return userRepository.findOneByLogin(SecurityUtils.getCurrentUserLogin())
return userRepository.findOneById(SecurityUtils.getCurrentUserId())
.map(user -> new ResponseEntity<>(
persistentTokenRepository.findByUser(user),
HttpStatus.OK))
@ -181,7 +180,7 @@ public class AccountResource {
@Timed
public void invalidateSession(@PathVariable String series) throws UnsupportedEncodingException {
String decodedSeries = URLDecoder.decode(series, "UTF-8");
userRepository.findOneByLogin(SecurityUtils.getCurrentUserLogin()).ifPresent(u -> {
userRepository.findOneById(SecurityUtils.getCurrentUserId()).ifPresent(u -> {
persistentTokenRepository.findByUser(u).stream()
.filter(persistentToken -> StringUtils.equals(persistentToken.getSeries(), decodedSeries))
.findAny().ifPresent(t -> persistentTokenRepository.delete(decodedSeries));

View File

@ -98,8 +98,8 @@ public class UserResource {
@Secured(AuthoritiesConstants.ADMIN)
public ResponseEntity<ManagedUserDTO> updateUser(@RequestBody ManagedUserDTO managedUserDTO) throws URISyntaxException {
log.debug("REST request to update User : {}", managedUserDTO);
return Optional.of(userRepository
.findOne(managedUserDTO.getId()))
return userRepository
.findOneById(managedUserDTO.getId())
.map(user -> {
user.setLogin(managedUserDTO.getLogin());
user.setFirstName(managedUserDTO.getFirstName());
@ -148,7 +148,7 @@ public class UserResource {
public ResponseEntity<ManagedUserDTO> getUser(@PathVariable String login) {
log.debug("REST request to get User : {}", login);
return userService.getUserWithAuthoritiesByLogin(login)
.map(user -> new ManagedUserDTO(user))
.map(ManagedUserDTO::new)
.map(managedUserDTO -> new ResponseEntity<>(managedUserDTO, HttpStatus.OK))
.orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND));
}

View File

@ -1,5 +1,5 @@
#H2 Server Properties
0=JHipster H2 (Memory)|org.h2.Driver|jdbc\:h2\:mem\:jhipster|
0=JHipster H2 (Memory)|org.h2.Driver|jdbc\:h2\:mem\:sampleapplication|
webAllowOthers=true
webPort=8082
webSSL=false

View File

@ -20,7 +20,7 @@ spring:
enabled: false # we use Grunt + BrowserSync for livereload
datasource:
driver-class-name: org.h2.jdbcx.JdbcDataSource
url: jdbc:h2:mem:jhipster;DB_CLOSE_DELAY=-1
url: jdbc:h2:mem:sampleapplication;DB_CLOSE_DELAY=-1
name:
username:
password:

View File

@ -111,14 +111,13 @@ only screen and ( min-resolution: 2dppx) {
min-width: 400px;
}
.alert .popover pre {
font-size: 10px;
}
/*Custom alerts for notification*/
/* ==========================================================================
Custom alerts for notification
========================================================================== */
.alerts .alert{
text-overflow: ellipsis;
}
.alert pre{
background: none;
border: none;
@ -128,6 +127,39 @@ only screen and ( min-resolution: 2dppx) {
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%;
}
}
/* end of Custom alerts for notification */
.voffset { margin-top: 2px; }
.voffset1 { margin-top: 5px; }
.voffset2 { margin-top: 10px; }

View File

@ -0,0 +1,39 @@
{
"name": "angular-loading-bar",
"main": [
"build/loading-bar.js",
"build/loading-bar.css"
],
"ignore": [
"**/.*",
"node_modules",
"components",
"test",
"example"
],
"dependencies": {
"angular": "^1.2.9"
},
"devDependencies": {
"angular": "~1.2.23",
"angular-1.3": "angular#1.3",
"angular-mocks": "~1.2.9",
"angular-mocks-1.3": "angular-mocks#1.3",
"angular-animate": "~1.2.9",
"angular-animate-1.3": "angular-animate#1.3"
},
"resolutions": {
"angular": "~1.2.23"
},
"homepage": "https://github.com/chieffancypants/angular-loading-bar",
"version": "0.8.0",
"_release": "0.8.0",
"_resolution": {
"type": "version",
"tag": "0.8.0",
"commit": "2582b44eca8c515635d1f667842a0e5b79fab405"
},
"_source": "git://github.com/chieffancypants/angular-loading-bar.git",
"_target": "0.8.0",
"_originalSource": "angular-loading-bar"
}

View File

@ -0,0 +1,67 @@
Changelog
==========
## 0.8.0
- auto incrementing is now configurable
([#209](https://github.com/chieffancypants/angular-loading-bar/pull/209))
- removed `version` from bower.json
([#207](https://github.com/chieffancypants/angular-loading-bar/pull/207))
- added support for webpack and browserify
([#200](https://github.com/chieffancypants/angular-loading-bar/pull/200))
- spinner border radius 10px -> 50%
([#184](https://github.com/chieffancypants/angular-loading-bar/issues/184))
## 0.7.1
- Merge correct PR for broken interceptor detection ([#133](https://github.com/chieffancypants/angular-loading-bar/pull/133), [#50](https://github.com/chieffancypants/angular-loading-bar/pull/50))
## 0.7.0
- Changes for animate.enter compatibility for 1.2 and 1.3 ([#170](https://github.com/chieffancypants/angular-loading-bar/pull/170))
- Detect errors with other interceptors ([#133](https://github.com/chieffancypants/angular-loading-bar/pull/133), [#50](https://github.com/chieffancypants/angular-loading-bar/pull/50))
- Provide more detail on response/responseError events ([#128](https://github.com/chieffancypants/angular-loading-bar/pull/128))
- Change angular dependency in bower ([#126](https://github.com/chieffancypants/angular-loading-bar/issues/126))
## 0.6.0
- Customize progress bar template: ([#111](https://github.com/chieffancypants/angular-loading-bar/pull/111))
- Only append bar to first parent found ([#108](https://github.com/chieffancypants/angular-loading-bar/pull/108))
## 0.5.2:
Fixes for Angular 1.3 breaking changes:
- Circular dependencies: ([#98](https://github.com/chieffancypants/angular-loading-bar/issues/98)), ([#101](https://github.com/chieffancypants/angular-loading-bar/pull/101))
- $animate no longer accepts callbacks: ([#102](https://github.com/chieffancypants/angular-loading-bar/pull/102))
## 0.5.1
- Reworked cache logic to allow cache:true ([#96](https://github.com/chieffancypants/angular-loading-bar/pull/96))
## 0.5.0
- Added spinner template configuration ([#82](https://github.com/chieffancypants/angular-loading-bar/pull/82))
- $timeout was not canceled properly ([#79](https://github.com/chieffancypants/angular-loading-bar/pull/79))
## 0.4.3
- update z-index to work with other css frameworks ([#69](https://github.com/chieffancypants/angular-loading-bar/pull/69))
- ignoreLoadingBar not ignored when calculating percentage complete ([#70](https://github.com/chieffancypants/angular-loading-bar/pull/70))
## 0.4.2
- Split loading bar into different modules so they can be included separately ([#46](https://github.com/chieffancypants/angular-loading-bar/issues/46))
## 0.4.1
- Fix for route views defined on body where loading bar is also attached ([#56](https://github.com/chieffancypants/angular-loading-bar/issues/56))
## 0.4.0
- Initial load percentage is now configurable ([#47](https://github.com/chieffancypants/angular-loading-bar/issues/47))
- Peg graphic reworked so the loadingbar does not require CSS changes when not at the very top of the page ([#42](https://github.com/chieffancypants/angular-loading-bar/issues/42), [#45](https://github.com/chieffancypants/angular-loading-bar/issues/45), [#10](https://github.com/chieffancypants/angular-loading-bar/issues/10))
- z-index of spinner increased to work with Bootstrap 3 z-indexes ([#53](https://github.com/chieffancypants/angular-loading-bar/issues/53))
## 0.3.0
- Loading bar only appears on XHR requests with high latency ([#27](https://github.com/chieffancypants/angular-loading-bar/issues/27))
## 0.2.0
- Progression bar not calculated correctly for consecutive calls within the 500ms delay ([#29](https://github.com/chieffancypants/angular-loading-bar/issues/29), [#32](https://github.com/chieffancypants/angular-loading-bar/issues/32))
- Event broadcasts when loading (#31)
## 0.1.1
- Alias chieffancypants.loadingbar to angular-loading-bar (#25, #19)
## 0.1.0
- Fixed issues with Angular 1.2-rc3+
- Ability to ignore particular XHR requests (#21)
- Broadcasting of events (#18)

View File

@ -0,0 +1,94 @@
/*global module:false*/
module.exports = function(grunt) {
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
banner: '/*! \n * <%= pkg.title || pkg.name %> v<%= pkg.version %>\n' +
' * <%= pkg.homepage %>\n' +
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
' * License: <%= pkg.license %>\n' +
' */\n',
// Task configuration.
uglify: {
options: {
banner: '<%= banner %>',
report: 'gzip'
},
build: {
src: 'src/loading-bar.js',
dest: 'build/loading-bar.min.js'
}
},
cssmin: {
options: {
banner: '<%= banner %>',
report: 'gzip'
},
minify: {
src: 'src/loading-bar.css',
dest: 'build/loading-bar.min.css'
}
},
karma: {
unit: {
configFile: 'test/karma-angular-1.2.conf.js',
singleRun: true,
coverageReporter: {
type: 'text',
dir: 'coverage/'
}
},
unit13: {
configFile: 'test/karma-angular-1.3.conf.js',
singleRun: true,
coverageReporter: {
type: 'text',
dir: 'coverage/'
}
},
watch: {
configFile: 'test/karma-angular-1.2.conf.js',
singleRun: false,
reporters: ['progress'] // Don't display coverage
}
},
jshint: {
jshintrc: '.jshintrc',
gruntfile: {
src: 'Gruntfile.js'
},
src: {
src: ['src/*.js']
}
},
concat: {
build: {
options: {
banner: '<%= banner %>'
},
files: {
'build/loading-bar.css': 'src/loading-bar.css',
'build/loading-bar.js': 'src/loading-bar.js',
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-karma');
grunt.registerTask('default', ['jshint', 'karma:unit', 'karma:unit13', 'uglify', 'cssmin', 'concat:build']);
grunt.registerTask('test', ['karma:watch']);
grunt.registerTask('build', ['default']);
};

View File

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2013-2014 Wes Cruver
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,180 @@
angular-loading-bar
===================
The idea is simple: Add a loading bar / progress bar whenever an XHR request goes out in angular. Multiple requests within the same time period get bundled together such that each response increments the progress bar by the appropriate amount.
This is mostly cool because you simply include it in your app, and it works. There's no complicated setup, and no need to maintain the state of the loading bar; it's all handled automatically by the interceptor.
**Requirements:** AngularJS 1.2+
**File Size:** 2.4Kb minified, 0.5Kb gzipped
## Usage:
1. include the loading bar as a dependency for your app. If you want animations, include `ngAnimate` as well. *note: ngAnimate is optional*
```js
angular.module('myApp', ['angular-loading-bar', 'ngAnimate'])
```
2. include the supplied JS and CSS file (or create your own CSS to override defaults).
```html
<link rel='stylesheet' href='build/loading-bar.min.css' type='text/css' media='all' />
<script type='text/javascript' src='build/loading-bar.min.js'></script>
```
3. That's it -- you're done!
#### via bower:
```
$ bower install angular-loading-bar
```
#### via npm:
```
$ npm install angular-loading-bar
```
#### via CDN:
```html
<link rel='stylesheet' href='//cdnjs.cloudflare.com/ajax/libs/angular-loading-bar/0.7.1/loading-bar.min.css' type='text/css' media='all' />
<script type='text/javascript' src='//cdnjs.cloudflare.com/ajax/libs/angular-loading-bar/0.7.1/loading-bar.min.js'></script>
```
## Why I created this
There are a couple projects similar to this out there, but none were ideal for me. All implementations I've seen require that you maintain state on behalf of the loading bar. In other words, you're setting the value of the loading/progress bar manually from potentially many different locations. This becomes complicated when you have a very large application with several services all making independant XHR requests. It becomes even more complicated if you want these services to be loosly coupled.
Additionally, Angular was created as a highly testable framework, so it pains me to see Angular modules without tests. That is not the case here as this loading bar ships with 100% code coverage.
**Goals for this project:**
1. Make it automatic
2. Unit tests, 100% coverage
3. Must work well with ngAnimate
4. Must be styled via external CSS (not inline)
5. No jQuery dependencies
## Configuration
#### Turn the spinner on or off:
The insertion of the spinner can be controlled through configuration. It's on by default, but if you'd like to turn it off, simply configure the service:
```js
angular.module('myApp', ['angular-loading-bar'])
.config(['cfpLoadingBarProvider', function(cfpLoadingBarProvider) {
cfpLoadingBarProvider.includeSpinner = false;
}])
```
#### Turn the loading bar on or off:
Like the spinner configuration above, the loading bar can also be turned off for cases where you only want the spinner:
```js
angular.module('myApp', ['angular-loading-bar'])
.config(['cfpLoadingBarProvider', function(cfpLoadingBarProvider) {
cfpLoadingBarProvider.includeBar = false;
}])
```
#### Latency Threshold
By default, the loading bar will only display after it has been waiting for a response for over 100ms. This helps keep things feeling snappy, and avoids the annoyingness of showing a loading bar every few seconds on really chatty applications. This threshold is totally configurable:
```js
angular.module('myApp', ['angular-loading-bar'])
.config(['cfpLoadingBarProvider', function(cfpLoadingBarProvider) {
cfpLoadingBarProvider.latencyThreshold = 500;
}])
```
#### Ignoring particular XHR requests:
The loading bar can also be forced to ignore certain requests, for example, when long-polling or periodically sending debugging information back to the server.
```js
// ignore a particular $http GET:
$http.get('/status', {
ignoreLoadingBar: true
});
// ignore a particular $http POST. Note: POST and GET have different
// method signatures:
$http.post('/save', data, {
ignoreLoadingBar: true
});
```
```js
// ignore particular $resource requests:
.factory('Restaurant', function($resource) {
return $resource('/api/restaurant/:id', {id: '@id'}, {
query: {
method: 'GET',
isArray: true,
ignoreLoadingBar: true
}
});
});
```
## How it works:
This library is split into two modules, an $http `interceptor`, and a `service`:
**Interceptor**
The interceptor simply listens for all outgoing XHR requests, and then instructs the loadingBar service to start, stop, and increment accordingly. There is no public API for the interceptor. It can be used stand-alone by including `cfp.loadingBarInterceptor` as a dependency for your module.
**Service**
The service is responsible for the presentation of the loading bar. It injects the loading bar into the DOM, adjusts the width whenever `set()` is called, and `complete()`s the whole show by removing the loading bar from the DOM.
## Service API (advanced usage)
Under normal circumstances you won't need to use this. However, if you wish to use the loading bar without the interceptor, you can do that as well. Simply include the loading bar service as a dependency instead of the main `angular-loading-bar` module:
```js
angular.module('myApp', ['cfp.loadingBar'])
```
```js
cfpLoadingBar.start();
// will insert the loading bar into the DOM, and display its progress at 1%.
// It will automatically call `inc()` repeatedly to give the illusion that the page load is progressing.
cfpLoadingBar.inc();
// increments the loading bar by a random amount.
// It is important to note that the auto incrementing will begin to slow down as
// the progress increases. This is to prevent the loading bar from appearing
// completed (or almost complete) before the XHR request has responded.
cfpLoadingBar.set(0.3) // Set the loading bar to 30%
cfpLoadingBar.status() // Returns the loading bar's progress.
// -> 0.3
cfpLoadingBar.complete()
// Set the loading bar's progress to 100%, and then remove it from the DOM.
```
## Events
The loading bar broadcasts the following events over $rootScope allowing further customization:
**`cfpLoadingBar:loading`** triggered upon each XHR request that is not already cached
**`cfpLoadingBar:loaded`** triggered each time an XHR request recieves a response (either successful or error)
**`cfpLoadingBar:started`** triggered once upon the first XHR request. Will trigger again if another request goes out after `cfpLoadingBar:completed` has triggered.
**`cfpLoadingBar:completed`** triggered once when the all XHR requests have returned (either successfully or not)
## Credits:
Credit goes to [rstacruz](https://github.com/rstacruz) for his excellent [nProgress](https://github.com/rstacruz/nprogress).
## License:
Licensed under the MIT license

View File

@ -0,0 +1,28 @@
{
"name": "angular-loading-bar",
"main": [
"build/loading-bar.js",
"build/loading-bar.css"
],
"ignore": [
"**/.*",
"node_modules",
"components",
"test",
"example"
],
"dependencies": {
"angular": "^1.2.9"
},
"devDependencies": {
"angular": "~1.2.23",
"angular-1.3": "angular#1.3",
"angular-mocks": "~1.2.9",
"angular-mocks-1.3": "angular-mocks#1.3",
"angular-animate": "~1.2.9",
"angular-animate-1.3": "angular-animate#1.3"
},
"resolutions": {
"angular": "~1.2.23"
}
}

View File

@ -0,0 +1,110 @@
/*!
* angular-loading-bar v0.8.0
* https://chieffancypants.github.io/angular-loading-bar
* Copyright (c) 2015 Wes Cruver
* License: MIT
*/
/* Make clicks pass-through */
#loading-bar,
#loading-bar-spinner {
pointer-events: none;
-webkit-pointer-events: none;
-webkit-transition: 350ms linear all;
-moz-transition: 350ms linear all;
-o-transition: 350ms linear all;
transition: 350ms linear all;
}
#loading-bar.ng-enter,
#loading-bar.ng-leave.ng-leave-active,
#loading-bar-spinner.ng-enter,
#loading-bar-spinner.ng-leave.ng-leave-active {
opacity: 0;
}
#loading-bar.ng-enter.ng-enter-active,
#loading-bar.ng-leave,
#loading-bar-spinner.ng-enter.ng-enter-active,
#loading-bar-spinner.ng-leave {
opacity: 1;
}
#loading-bar .bar {
-webkit-transition: width 350ms;
-moz-transition: width 350ms;
-o-transition: width 350ms;
transition: width 350ms;
background: #29d;
position: fixed;
z-index: 10002;
top: 0;
left: 0;
width: 100%;
height: 2px;
border-bottom-right-radius: 1px;
border-top-right-radius: 1px;
}
/* Fancy blur effect */
#loading-bar .peg {
position: absolute;
width: 70px;
right: 0;
top: 0;
height: 2px;
opacity: .45;
-moz-box-shadow: #29d 1px 0 6px 1px;
-ms-box-shadow: #29d 1px 0 6px 1px;
-webkit-box-shadow: #29d 1px 0 6px 1px;
box-shadow: #29d 1px 0 6px 1px;
-moz-border-radius: 100%;
-webkit-border-radius: 100%;
border-radius: 100%;
}
#loading-bar-spinner {
display: block;
position: fixed;
z-index: 10002;
top: 10px;
left: 10px;
}
#loading-bar-spinner .spinner-icon {
width: 14px;
height: 14px;
border: solid 2px transparent;
border-top-color: #29d;
border-left-color: #29d;
border-radius: 50%;
-webkit-animation: loading-bar-spinner 400ms linear infinite;
-moz-animation: loading-bar-spinner 400ms linear infinite;
-ms-animation: loading-bar-spinner 400ms linear infinite;
-o-animation: loading-bar-spinner 400ms linear infinite;
animation: loading-bar-spinner 400ms linear infinite;
}
@-webkit-keyframes loading-bar-spinner {
0% { -webkit-transform: rotate(0deg); transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); transform: rotate(360deg); }
}
@-moz-keyframes loading-bar-spinner {
0% { -moz-transform: rotate(0deg); transform: rotate(0deg); }
100% { -moz-transform: rotate(360deg); transform: rotate(360deg); }
}
@-o-keyframes loading-bar-spinner {
0% { -o-transform: rotate(0deg); transform: rotate(0deg); }
100% { -o-transform: rotate(360deg); transform: rotate(360deg); }
}
@-ms-keyframes loading-bar-spinner {
0% { -ms-transform: rotate(0deg); transform: rotate(0deg); }
100% { -ms-transform: rotate(360deg); transform: rotate(360deg); }
}
@keyframes loading-bar-spinner {
0% { transform: rotate(0deg); transform: rotate(0deg); }
100% { transform: rotate(360deg); transform: rotate(360deg); }
}

View File

@ -0,0 +1,329 @@
/*!
* angular-loading-bar v0.8.0
* https://chieffancypants.github.io/angular-loading-bar
* Copyright (c) 2015 Wes Cruver
* License: MIT
*/
/*
* angular-loading-bar
*
* intercepts XHR requests and creates a loading bar.
* Based on the excellent nprogress work by rstacruz (more info in readme)
*
* (c) 2013 Wes Cruver
* License: MIT
*/
(function() {
'use strict';
// Alias the loading bar for various backwards compatibilities since the project has matured:
angular.module('angular-loading-bar', ['cfp.loadingBarInterceptor']);
angular.module('chieffancypants.loadingBar', ['cfp.loadingBarInterceptor']);
/**
* loadingBarInterceptor service
*
* Registers itself as an Angular interceptor and listens for XHR requests.
*/
angular.module('cfp.loadingBarInterceptor', ['cfp.loadingBar'])
.config(['$httpProvider', function ($httpProvider) {
var interceptor = ['$q', '$cacheFactory', '$timeout', '$rootScope', '$log', 'cfpLoadingBar', function ($q, $cacheFactory, $timeout, $rootScope, $log, cfpLoadingBar) {
/**
* The total number of requests made
*/
var reqsTotal = 0;
/**
* The number of requests completed (either successfully or not)
*/
var reqsCompleted = 0;
/**
* The amount of time spent fetching before showing the loading bar
*/
var latencyThreshold = cfpLoadingBar.latencyThreshold;
/**
* $timeout handle for latencyThreshold
*/
var startTimeout;
/**
* calls cfpLoadingBar.complete() which removes the
* loading bar from the DOM.
*/
function setComplete() {
$timeout.cancel(startTimeout);
cfpLoadingBar.complete();
reqsCompleted = 0;
reqsTotal = 0;
}
/**
* Determine if the response has already been cached
* @param {Object} config the config option from the request
* @return {Boolean} retrns true if cached, otherwise false
*/
function isCached(config) {
var cache;
var defaultCache = $cacheFactory.get('$http');
var defaults = $httpProvider.defaults;
// Choose the proper cache source. Borrowed from angular: $http service
if ((config.cache || defaults.cache) && config.cache !== false &&
(config.method === 'GET' || config.method === 'JSONP')) {
cache = angular.isObject(config.cache) ? config.cache
: angular.isObject(defaults.cache) ? defaults.cache
: defaultCache;
}
var cached = cache !== undefined ?
cache.get(config.url) !== undefined : false;
if (config.cached !== undefined && cached !== config.cached) {
return config.cached;
}
config.cached = cached;
return cached;
}
return {
'request': function(config) {
// Check to make sure this request hasn't already been cached and that
// the requester didn't explicitly ask us to ignore this request:
if (!config.ignoreLoadingBar && !isCached(config)) {
$rootScope.$broadcast('cfpLoadingBar:loading', {url: config.url});
if (reqsTotal === 0) {
startTimeout = $timeout(function() {
cfpLoadingBar.start();
}, latencyThreshold);
}
reqsTotal++;
cfpLoadingBar.set(reqsCompleted / reqsTotal);
}
return config;
},
'response': function(response) {
if (!response || !response.config) {
$log.error('Broken interceptor detected: Config object not supplied in response:\n https://github.com/chieffancypants/angular-loading-bar/pull/50');
return response;
}
if (!response.config.ignoreLoadingBar && !isCached(response.config)) {
reqsCompleted++;
$rootScope.$broadcast('cfpLoadingBar:loaded', {url: response.config.url, result: response});
if (reqsCompleted >= reqsTotal) {
setComplete();
} else {
cfpLoadingBar.set(reqsCompleted / reqsTotal);
}
}
return response;
},
'responseError': function(rejection) {
if (!rejection || !rejection.config) {
$log.error('Broken interceptor detected: Config object not supplied in rejection:\n https://github.com/chieffancypants/angular-loading-bar/pull/50');
return $q.reject(rejection);
}
if (!rejection.config.ignoreLoadingBar && !isCached(rejection.config)) {
reqsCompleted++;
$rootScope.$broadcast('cfpLoadingBar:loaded', {url: rejection.config.url, result: rejection});
if (reqsCompleted >= reqsTotal) {
setComplete();
} else {
cfpLoadingBar.set(reqsCompleted / reqsTotal);
}
}
return $q.reject(rejection);
}
};
}];
$httpProvider.interceptors.push(interceptor);
}]);
/**
* Loading Bar
*
* This service handles adding and removing the actual element in the DOM.
* Generally, best practices for DOM manipulation is to take place in a
* directive, but because the element itself is injected in the DOM only upon
* XHR requests, and it's likely needed on every view, the best option is to
* use a service.
*/
angular.module('cfp.loadingBar', [])
.provider('cfpLoadingBar', function() {
this.autoIncrement = true;
this.includeSpinner = true;
this.includeBar = true;
this.latencyThreshold = 100;
this.startSize = 0.02;
this.parentSelector = 'body';
this.spinnerTemplate = '<div id="loading-bar-spinner"><div class="spinner-icon"></div></div>';
this.loadingBarTemplate = '<div id="loading-bar"><div class="bar"><div class="peg"></div></div></div>';
this.$get = ['$injector', '$document', '$timeout', '$rootScope', function ($injector, $document, $timeout, $rootScope) {
var $animate;
var $parentSelector = this.parentSelector,
loadingBarContainer = angular.element(this.loadingBarTemplate),
loadingBar = loadingBarContainer.find('div').eq(0),
spinner = angular.element(this.spinnerTemplate);
var incTimeout,
completeTimeout,
started = false,
status = 0;
var autoIncrement = this.autoIncrement;
var includeSpinner = this.includeSpinner;
var includeBar = this.includeBar;
var startSize = this.startSize;
/**
* Inserts the loading bar element into the dom, and sets it to 2%
*/
function _start() {
if (!$animate) {
$animate = $injector.get('$animate');
}
var $parent = $document.find($parentSelector).eq(0);
$timeout.cancel(completeTimeout);
// do not continually broadcast the started event:
if (started) {
return;
}
$rootScope.$broadcast('cfpLoadingBar:started');
started = true;
if (includeBar) {
$animate.enter(loadingBarContainer, $parent, angular.element($parent[0].lastChild));
}
if (includeSpinner) {
$animate.enter(spinner, $parent, angular.element($parent[0].lastChild));
}
_set(startSize);
}
/**
* Set the loading bar's width to a certain percent.
*
* @param n any value between 0 and 1
*/
function _set(n) {
if (!started) {
return;
}
var pct = (n * 100) + '%';
loadingBar.css('width', pct);
status = n;
// increment loadingbar to give the illusion that there is always
// progress but make sure to cancel the previous timeouts so we don't
// have multiple incs running at the same time.
if (autoIncrement) {
$timeout.cancel(incTimeout);
incTimeout = $timeout(function() {
_inc();
}, 250);
}
}
/**
* Increments the loading bar by a random amount
* but slows down as it progresses
*/
function _inc() {
if (_status() >= 1) {
return;
}
var rnd = 0;
// TODO: do this mathmatically instead of through conditions
var stat = _status();
if (stat >= 0 && stat < 0.25) {
// Start out between 3 - 6% increments
rnd = (Math.random() * (5 - 3 + 1) + 3) / 100;
} else if (stat >= 0.25 && stat < 0.65) {
// increment between 0 - 3%
rnd = (Math.random() * 3) / 100;
} else if (stat >= 0.65 && stat < 0.9) {
// increment between 0 - 2%
rnd = (Math.random() * 2) / 100;
} else if (stat >= 0.9 && stat < 0.99) {
// finally, increment it .5 %
rnd = 0.005;
} else {
// after 99%, don't increment:
rnd = 0;
}
var pct = _status() + rnd;
_set(pct);
}
function _status() {
return status;
}
function _completeAnimation() {
status = 0;
started = false;
}
function _complete() {
if (!$animate) {
$animate = $injector.get('$animate');
}
$rootScope.$broadcast('cfpLoadingBar:completed');
_set(1);
$timeout.cancel(completeTimeout);
// Attempt to aggregate any start/complete calls within 500ms:
completeTimeout = $timeout(function() {
var promise = $animate.leave(loadingBarContainer, _completeAnimation);
if (promise && promise.then) {
promise.then(_completeAnimation);
}
$animate.leave(spinner);
}, 500);
}
return {
start : _start,
set : _set,
status : _status,
inc : _inc,
complete : _complete,
autoIncrement : this.autoIncrement,
includeSpinner : this.includeSpinner,
latencyThreshold : this.latencyThreshold,
parentSelector : this.parentSelector,
startSize : this.startSize
};
}]; //
}); // wtf javascript. srsly
})(); //

View File

@ -0,0 +1 @@
#loading-bar,#loading-bar-spinner{pointer-events:none;-webkit-pointer-events:none;-webkit-transition:350ms linear all;-moz-transition:350ms linear all;-o-transition:350ms linear all;transition:350ms linear all}#loading-bar-spinner.ng-enter,#loading-bar-spinner.ng-leave.ng-leave-active,#loading-bar.ng-enter,#loading-bar.ng-leave.ng-leave-active{opacity:0}#loading-bar-spinner.ng-enter.ng-enter-active,#loading-bar-spinner.ng-leave,#loading-bar.ng-enter.ng-enter-active,#loading-bar.ng-leave{opacity:1}#loading-bar .bar{-webkit-transition:width 350ms;-moz-transition:width 350ms;-o-transition:width 350ms;transition:width 350ms;background:#29d;position:fixed;z-index:10002;top:0;left:0;width:100%;height:2px;border-bottom-right-radius:1px;border-top-right-radius:1px}#loading-bar .peg{position:absolute;width:70px;right:0;top:0;height:2px;opacity:.45;-moz-box-shadow:#29d 1px 0 6px 1px;-ms-box-shadow:#29d 1px 0 6px 1px;-webkit-box-shadow:#29d 1px 0 6px 1px;box-shadow:#29d 1px 0 6px 1px;-moz-border-radius:100%;-webkit-border-radius:100%;border-radius:100%}#loading-bar-spinner{display:block;position:fixed;z-index:10002;top:10px;left:10px}#loading-bar-spinner .spinner-icon{width:14px;height:14px;border:2px solid transparent;border-top-color:#29d;border-left-color:#29d;border-radius:50%;-webkit-animation:loading-bar-spinner 400ms linear infinite;-moz-animation:loading-bar-spinner 400ms linear infinite;-ms-animation:loading-bar-spinner 400ms linear infinite;-o-animation:loading-bar-spinner 400ms linear infinite;animation:loading-bar-spinner 400ms linear infinite}@-webkit-keyframes loading-bar-spinner{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@-moz-keyframes loading-bar-spinner{0%{-moz-transform:rotate(0);transform:rotate(0)}100%{-moz-transform:rotate(360deg);transform:rotate(360deg)}}@-o-keyframes loading-bar-spinner{0%{-o-transform:rotate(0);transform:rotate(0)}100%{-o-transform:rotate(360deg);transform:rotate(360deg)}}@-ms-keyframes loading-bar-spinner{0%{-ms-transform:rotate(0);transform:rotate(0)}100%{-ms-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes loading-bar-spinner{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}

View File

@ -0,0 +1,7 @@
/*!
* angular-loading-bar v0.8.0
* https://chieffancypants.github.io/angular-loading-bar
* Copyright (c) 2015 Wes Cruver
* License: MIT
*/
!function(){"use strict";angular.module("angular-loading-bar",["cfp.loadingBarInterceptor"]),angular.module("chieffancypants.loadingBar",["cfp.loadingBarInterceptor"]),angular.module("cfp.loadingBarInterceptor",["cfp.loadingBar"]).config(["$httpProvider",function(a){var b=["$q","$cacheFactory","$timeout","$rootScope","$log","cfpLoadingBar",function(b,c,d,e,f,g){function h(){d.cancel(j),g.complete(),l=0,k=0}function i(b){var d,e=c.get("$http"),f=a.defaults;!b.cache&&!f.cache||b.cache===!1||"GET"!==b.method&&"JSONP"!==b.method||(d=angular.isObject(b.cache)?b.cache:angular.isObject(f.cache)?f.cache:e);var g=void 0!==d?void 0!==d.get(b.url):!1;return void 0!==b.cached&&g!==b.cached?b.cached:(b.cached=g,g)}var j,k=0,l=0,m=g.latencyThreshold;return{request:function(a){return a.ignoreLoadingBar||i(a)||(e.$broadcast("cfpLoadingBar:loading",{url:a.url}),0===k&&(j=d(function(){g.start()},m)),k++,g.set(l/k)),a},response:function(a){return a&&a.config?(a.config.ignoreLoadingBar||i(a.config)||(l++,e.$broadcast("cfpLoadingBar:loaded",{url:a.config.url,result:a}),l>=k?h():g.set(l/k)),a):(f.error("Broken interceptor detected: Config object not supplied in response:\n https://github.com/chieffancypants/angular-loading-bar/pull/50"),a)},responseError:function(a){return a&&a.config?(a.config.ignoreLoadingBar||i(a.config)||(l++,e.$broadcast("cfpLoadingBar:loaded",{url:a.config.url,result:a}),l>=k?h():g.set(l/k)),b.reject(a)):(f.error("Broken interceptor detected: Config object not supplied in rejection:\n https://github.com/chieffancypants/angular-loading-bar/pull/50"),b.reject(a))}}}];a.interceptors.push(b)}]),angular.module("cfp.loadingBar",[]).provider("cfpLoadingBar",function(){this.autoIncrement=!0,this.includeSpinner=!0,this.includeBar=!0,this.latencyThreshold=100,this.startSize=.02,this.parentSelector="body",this.spinnerTemplate='<div id="loading-bar-spinner"><div class="spinner-icon"></div></div>',this.loadingBarTemplate='<div id="loading-bar"><div class="bar"><div class="peg"></div></div></div>',this.$get=["$injector","$document","$timeout","$rootScope",function(a,b,c,d){function e(){k||(k=a.get("$animate"));var e=b.find(n).eq(0);c.cancel(m),r||(d.$broadcast("cfpLoadingBar:started"),r=!0,v&&k.enter(o,e,angular.element(e[0].lastChild)),u&&k.enter(q,e,angular.element(e[0].lastChild)),f(w))}function f(a){if(r){var b=100*a+"%";p.css("width",b),s=a,t&&(c.cancel(l),l=c(function(){g()},250))}}function g(){if(!(h()>=1)){var a=0,b=h();a=b>=0&&.25>b?(3*Math.random()+3)/100:b>=.25&&.65>b?3*Math.random()/100:b>=.65&&.9>b?2*Math.random()/100:b>=.9&&.99>b?.005:0;var c=h()+a;f(c)}}function h(){return s}function i(){s=0,r=!1}function j(){k||(k=a.get("$animate")),d.$broadcast("cfpLoadingBar:completed"),f(1),c.cancel(m),m=c(function(){var a=k.leave(o,i);a&&a.then&&a.then(i),k.leave(q)},500)}var k,l,m,n=this.parentSelector,o=angular.element(this.loadingBarTemplate),p=o.find("div").eq(0),q=angular.element(this.spinnerTemplate),r=!1,s=0,t=this.autoIncrement,u=this.includeSpinner,v=this.includeBar,w=this.startSize;return{start:e,set:f,status:h,inc:g,complete:j,autoIncrement:this.autoIncrement,includeSpinner:this.includeSpinner,latencyThreshold:this.latencyThreshold,parentSelector:this.parentSelector,startSize:this.startSize}}]})}();

View File

@ -0,0 +1,2 @@
require('./build/loading-bar');
module.exports = 'angular-loading-bar';

View File

@ -0,0 +1,41 @@
{
"name": "angular-loading-bar",
"version": "0.8.0",
"description": "An automatic loading bar for AngularJS",
"main": "index.js",
"directories": {
"example": "example",
"test": "test"
},
"repository": {
"type": "git",
"url": "git://github.com/chieffancypants/angular-loading-bar.git"
},
"keywords": [
"angular",
"angularjs",
"loading",
"loadingbar",
"progress",
"progressbar"
],
"author": "Wes Cruver",
"license": "MIT",
"bugs": {
"url": "https://github.com/chieffancypants/angular-loading-bar/issues"
},
"homepage": "https://chieffancypants.github.io/angular-loading-bar",
"devDependencies": {
"karma-jasmine": "^0.1.3",
"karma-coffee-preprocessor": "^0.2.0",
"karma-phantomjs-launcher": "^0.1.0",
"karma": "~0.12.0",
"karma-coverage": "^0.1.0",
"grunt": "~0.4.1",
"grunt-contrib-jshint": "~0.6.4",
"grunt-contrib-uglify": "^0.9.1",
"grunt-contrib-cssmin": "~0.12.0",
"grunt-karma": "~0.11.0",
"grunt-contrib-concat": "^0.5.0"
}
}

View File

@ -0,0 +1,104 @@
/* Make clicks pass-through */
#loading-bar,
#loading-bar-spinner {
pointer-events: none;
-webkit-pointer-events: none;
-webkit-transition: 350ms linear all;
-moz-transition: 350ms linear all;
-o-transition: 350ms linear all;
transition: 350ms linear all;
}
#loading-bar.ng-enter,
#loading-bar.ng-leave.ng-leave-active,
#loading-bar-spinner.ng-enter,
#loading-bar-spinner.ng-leave.ng-leave-active {
opacity: 0;
}
#loading-bar.ng-enter.ng-enter-active,
#loading-bar.ng-leave,
#loading-bar-spinner.ng-enter.ng-enter-active,
#loading-bar-spinner.ng-leave {
opacity: 1;
}
#loading-bar .bar {
-webkit-transition: width 350ms;
-moz-transition: width 350ms;
-o-transition: width 350ms;
transition: width 350ms;
background: #29d;
position: fixed;
z-index: 10002;
top: 0;
left: 0;
width: 100%;
height: 2px;
border-bottom-right-radius: 1px;
border-top-right-radius: 1px;
}
/* Fancy blur effect */
#loading-bar .peg {
position: absolute;
width: 70px;
right: 0;
top: 0;
height: 2px;
opacity: .45;
-moz-box-shadow: #29d 1px 0 6px 1px;
-ms-box-shadow: #29d 1px 0 6px 1px;
-webkit-box-shadow: #29d 1px 0 6px 1px;
box-shadow: #29d 1px 0 6px 1px;
-moz-border-radius: 100%;
-webkit-border-radius: 100%;
border-radius: 100%;
}
#loading-bar-spinner {
display: block;
position: fixed;
z-index: 10002;
top: 10px;
left: 10px;
}
#loading-bar-spinner .spinner-icon {
width: 14px;
height: 14px;
border: solid 2px transparent;
border-top-color: #29d;
border-left-color: #29d;
border-radius: 50%;
-webkit-animation: loading-bar-spinner 400ms linear infinite;
-moz-animation: loading-bar-spinner 400ms linear infinite;
-ms-animation: loading-bar-spinner 400ms linear infinite;
-o-animation: loading-bar-spinner 400ms linear infinite;
animation: loading-bar-spinner 400ms linear infinite;
}
@-webkit-keyframes loading-bar-spinner {
0% { -webkit-transform: rotate(0deg); transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); transform: rotate(360deg); }
}
@-moz-keyframes loading-bar-spinner {
0% { -moz-transform: rotate(0deg); transform: rotate(0deg); }
100% { -moz-transform: rotate(360deg); transform: rotate(360deg); }
}
@-o-keyframes loading-bar-spinner {
0% { -o-transform: rotate(0deg); transform: rotate(0deg); }
100% { -o-transform: rotate(360deg); transform: rotate(360deg); }
}
@-ms-keyframes loading-bar-spinner {
0% { -ms-transform: rotate(0deg); transform: rotate(0deg); }
100% { -ms-transform: rotate(360deg); transform: rotate(360deg); }
}
@keyframes loading-bar-spinner {
0% { transform: rotate(0deg); transform: rotate(0deg); }
100% { transform: rotate(360deg); transform: rotate(360deg); }
}

View File

@ -0,0 +1,323 @@
/*
* angular-loading-bar
*
* intercepts XHR requests and creates a loading bar.
* Based on the excellent nprogress work by rstacruz (more info in readme)
*
* (c) 2013 Wes Cruver
* License: MIT
*/
(function() {
'use strict';
// Alias the loading bar for various backwards compatibilities since the project has matured:
angular.module('angular-loading-bar', ['cfp.loadingBarInterceptor']);
angular.module('chieffancypants.loadingBar', ['cfp.loadingBarInterceptor']);
/**
* loadingBarInterceptor service
*
* Registers itself as an Angular interceptor and listens for XHR requests.
*/
angular.module('cfp.loadingBarInterceptor', ['cfp.loadingBar'])
.config(['$httpProvider', function ($httpProvider) {
var interceptor = ['$q', '$cacheFactory', '$timeout', '$rootScope', '$log', 'cfpLoadingBar', function ($q, $cacheFactory, $timeout, $rootScope, $log, cfpLoadingBar) {
/**
* The total number of requests made
*/
var reqsTotal = 0;
/**
* The number of requests completed (either successfully or not)
*/
var reqsCompleted = 0;
/**
* The amount of time spent fetching before showing the loading bar
*/
var latencyThreshold = cfpLoadingBar.latencyThreshold;
/**
* $timeout handle for latencyThreshold
*/
var startTimeout;
/**
* calls cfpLoadingBar.complete() which removes the
* loading bar from the DOM.
*/
function setComplete() {
$timeout.cancel(startTimeout);
cfpLoadingBar.complete();
reqsCompleted = 0;
reqsTotal = 0;
}
/**
* Determine if the response has already been cached
* @param {Object} config the config option from the request
* @return {Boolean} retrns true if cached, otherwise false
*/
function isCached(config) {
var cache;
var defaultCache = $cacheFactory.get('$http');
var defaults = $httpProvider.defaults;
// Choose the proper cache source. Borrowed from angular: $http service
if ((config.cache || defaults.cache) && config.cache !== false &&
(config.method === 'GET' || config.method === 'JSONP')) {
cache = angular.isObject(config.cache) ? config.cache
: angular.isObject(defaults.cache) ? defaults.cache
: defaultCache;
}
var cached = cache !== undefined ?
cache.get(config.url) !== undefined : false;
if (config.cached !== undefined && cached !== config.cached) {
return config.cached;
}
config.cached = cached;
return cached;
}
return {
'request': function(config) {
// Check to make sure this request hasn't already been cached and that
// the requester didn't explicitly ask us to ignore this request:
if (!config.ignoreLoadingBar && !isCached(config)) {
$rootScope.$broadcast('cfpLoadingBar:loading', {url: config.url});
if (reqsTotal === 0) {
startTimeout = $timeout(function() {
cfpLoadingBar.start();
}, latencyThreshold);
}
reqsTotal++;
cfpLoadingBar.set(reqsCompleted / reqsTotal);
}
return config;
},
'response': function(response) {
if (!response || !response.config) {
$log.error('Broken interceptor detected: Config object not supplied in response:\n https://github.com/chieffancypants/angular-loading-bar/pull/50');
return response;
}
if (!response.config.ignoreLoadingBar && !isCached(response.config)) {
reqsCompleted++;
$rootScope.$broadcast('cfpLoadingBar:loaded', {url: response.config.url, result: response});
if (reqsCompleted >= reqsTotal) {
setComplete();
} else {
cfpLoadingBar.set(reqsCompleted / reqsTotal);
}
}
return response;
},
'responseError': function(rejection) {
if (!rejection || !rejection.config) {
$log.error('Broken interceptor detected: Config object not supplied in rejection:\n https://github.com/chieffancypants/angular-loading-bar/pull/50');
return $q.reject(rejection);
}
if (!rejection.config.ignoreLoadingBar && !isCached(rejection.config)) {
reqsCompleted++;
$rootScope.$broadcast('cfpLoadingBar:loaded', {url: rejection.config.url, result: rejection});
if (reqsCompleted >= reqsTotal) {
setComplete();
} else {
cfpLoadingBar.set(reqsCompleted / reqsTotal);
}
}
return $q.reject(rejection);
}
};
}];
$httpProvider.interceptors.push(interceptor);
}]);
/**
* Loading Bar
*
* This service handles adding and removing the actual element in the DOM.
* Generally, best practices for DOM manipulation is to take place in a
* directive, but because the element itself is injected in the DOM only upon
* XHR requests, and it's likely needed on every view, the best option is to
* use a service.
*/
angular.module('cfp.loadingBar', [])
.provider('cfpLoadingBar', function() {
this.autoIncrement = true;
this.includeSpinner = true;
this.includeBar = true;
this.latencyThreshold = 100;
this.startSize = 0.02;
this.parentSelector = 'body';
this.spinnerTemplate = '<div id="loading-bar-spinner"><div class="spinner-icon"></div></div>';
this.loadingBarTemplate = '<div id="loading-bar"><div class="bar"><div class="peg"></div></div></div>';
this.$get = ['$injector', '$document', '$timeout', '$rootScope', function ($injector, $document, $timeout, $rootScope) {
var $animate;
var $parentSelector = this.parentSelector,
loadingBarContainer = angular.element(this.loadingBarTemplate),
loadingBar = loadingBarContainer.find('div').eq(0),
spinner = angular.element(this.spinnerTemplate);
var incTimeout,
completeTimeout,
started = false,
status = 0;
var autoIncrement = this.autoIncrement;
var includeSpinner = this.includeSpinner;
var includeBar = this.includeBar;
var startSize = this.startSize;
/**
* Inserts the loading bar element into the dom, and sets it to 2%
*/
function _start() {
if (!$animate) {
$animate = $injector.get('$animate');
}
var $parent = $document.find($parentSelector).eq(0);
$timeout.cancel(completeTimeout);
// do not continually broadcast the started event:
if (started) {
return;
}
$rootScope.$broadcast('cfpLoadingBar:started');
started = true;
if (includeBar) {
$animate.enter(loadingBarContainer, $parent, angular.element($parent[0].lastChild));
}
if (includeSpinner) {
$animate.enter(spinner, $parent, angular.element($parent[0].lastChild));
}
_set(startSize);
}
/**
* Set the loading bar's width to a certain percent.
*
* @param n any value between 0 and 1
*/
function _set(n) {
if (!started) {
return;
}
var pct = (n * 100) + '%';
loadingBar.css('width', pct);
status = n;
// increment loadingbar to give the illusion that there is always
// progress but make sure to cancel the previous timeouts so we don't
// have multiple incs running at the same time.
if (autoIncrement) {
$timeout.cancel(incTimeout);
incTimeout = $timeout(function() {
_inc();
}, 250);
}
}
/**
* Increments the loading bar by a random amount
* but slows down as it progresses
*/
function _inc() {
if (_status() >= 1) {
return;
}
var rnd = 0;
// TODO: do this mathmatically instead of through conditions
var stat = _status();
if (stat >= 0 && stat < 0.25) {
// Start out between 3 - 6% increments
rnd = (Math.random() * (5 - 3 + 1) + 3) / 100;
} else if (stat >= 0.25 && stat < 0.65) {
// increment between 0 - 3%
rnd = (Math.random() * 3) / 100;
} else if (stat >= 0.65 && stat < 0.9) {
// increment between 0 - 2%
rnd = (Math.random() * 2) / 100;
} else if (stat >= 0.9 && stat < 0.99) {
// finally, increment it .5 %
rnd = 0.005;
} else {
// after 99%, don't increment:
rnd = 0;
}
var pct = _status() + rnd;
_set(pct);
}
function _status() {
return status;
}
function _completeAnimation() {
status = 0;
started = false;
}
function _complete() {
if (!$animate) {
$animate = $injector.get('$animate');
}
$rootScope.$broadcast('cfpLoadingBar:completed');
_set(1);
$timeout.cancel(completeTimeout);
// Attempt to aggregate any start/complete calls within 500ms:
completeTimeout = $timeout(function() {
var promise = $animate.leave(loadingBarContainer, _completeAnimation);
if (promise && promise.then) {
promise.then(_completeAnimation);
}
$animate.leave(spinner);
}, 500);
}
return {
start : _start,
set : _set,
status : _status,
inc : _inc,
complete : _complete,
autoIncrement : this.autoIncrement,
includeSpinner : this.includeSpinner,
latencyThreshold : this.latencyThreshold,
parentSelector : this.parentSelector,
startSize : this.startSize
};
}]; //
}); // wtf javascript. srsly
})(); //

View File

@ -109,7 +109,8 @@
},
"error": {
"serverNotReachable": "Server not reachable",
"NotNull": "Field {{fieldName}} cannot be empty!"
"NotNull": "Field {{fieldName}} cannot be empty!",
"Size": "Field {{fieldName}} does not meet min/max size requirements!"
},
"footer": "This is your footer"
}

View File

@ -6,6 +6,9 @@
"createLabel": "Créer un nouveau BankAccount",
"createOrEditLabel": "Créer ou éditer un BankAccount"
},
"created": "Un nouveau BankAccount a été créé avec l'identifiant {{ param }}",
"updated": "Le BankAccount avec l'identifiant {{ param }} a été mis à jour",
"deleted": "Le BankAccount avec l'identifiant {{ param }} a été supprimé",
"delete": {
"question": "Etes-vous certain de vouloir supprimer le BankAccount {{ id }} ?"
},

View File

@ -107,5 +107,10 @@
"datetimelocal": "Ce champs doit être une date et une heure."
}
},
"error": {
"serverNotReachable": "Server not reachable",
"NotNull": "Field {{fieldName}} cannot be empty!",
"Size": "Field {{fieldName}} does not meet min/max size requirements!"
},
"footer": "Ceci est votre pied de page"
}

View File

@ -6,6 +6,9 @@
"createLabel": "Créer un nouveau Label",
"createOrEditLabel": "Créer ou éditer un Label"
},
"created": "Un nouveau Label a été créé avec l'identifiant {{ param }}",
"updated": "Le Label avec l'identifiant {{ param }} a été mis à jour",
"deleted": "Le Label avec l'identifiant {{ param }} a été supprimé",
"delete": {
"question": "Etes-vous certain de vouloir supprimer le Label {{ id }} ?"
},

View File

@ -6,6 +6,9 @@
"createLabel": "Créer un nouveau Operation",
"createOrEditLabel": "Créer ou éditer un Operation"
},
"created": "Un nouveau Operation a été créé avec l'identifiant {{ param }}",
"updated": "Le Operation avec l'identifiant {{ param }} a été mis à jour",
"deleted": "Le Operation avec l'identifiant {{ param }} a été supprimé",
"delete": {
"question": "Etes-vous certain de vouloir supprimer le Operation {{ id }} ?"
},

View File

@ -10,6 +10,7 @@
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<!-- build:css assets/styles/vendor.css -->
<!-- bower:css -->
<link rel="stylesheet" href="bower_components/angular-loading-bar/build/loading-bar.css" />
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" />
<!-- endbower -->
<!-- endbuild -->
@ -52,6 +53,7 @@
<script src="bower_components/angular-cookies/angular-cookies.js"></script>
<script src="bower_components/angular-dynamic-locale/src/tmhDynamicLocale.js"></script>
<script src="bower_components/angular-local-storage/dist/angular-local-storage.js"></script>
<script src="bower_components/angular-loading-bar/build/loading-bar.js"></script>
<script src="bower_components/angular-resource/angular-resource.js"></script>
<script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
<script src="bower_components/angular-translate/angular-translate.js"></script>
@ -131,6 +133,7 @@
<script src="scripts/app/admin/metrics/metrics.controller.js"></script>
<script src="scripts/app/admin/metrics/metrics.modal.controller.js"></script>
<script src="scripts/app/admin/user-management/user-management-detail.controller.js"></script>
<script src="scripts/app/admin/user-management/user-management-dialog.controller.js"></script>
<script src="scripts/app/admin/user-management/user-management.controller.js"></script>
<script src="scripts/app/admin/user-management/user-management.js"></script>
<script src="scripts/app/entities/entity.js"></script>
@ -148,16 +151,19 @@
<script src="scripts/app/entities/bankAccount/bankAccount.js"></script>
<script src="scripts/app/entities/bankAccount/bankAccount.controller.js"></script>
<script src="scripts/app/entities/bankAccount/bankAccount-dialog.controller.js"></script>
<script src="scripts/app/entities/bankAccount/bankAccount-delete-dialog.controller.js"></script>
<script src="scripts/app/entities/bankAccount/bankAccount-detail.controller.js"></script>
<script src="scripts/components/entities/bankAccount/bankAccount.service.js"></script>
<script src="scripts/app/entities/label/label.js"></script>
<script src="scripts/app/entities/label/label.controller.js"></script>
<script src="scripts/app/entities/label/label-dialog.controller.js"></script>
<script src="scripts/app/entities/label/label-delete-dialog.controller.js"></script>
<script src="scripts/app/entities/label/label-detail.controller.js"></script>
<script src="scripts/components/entities/label/label.service.js"></script>
<script src="scripts/app/entities/operation/operation.js"></script>
<script src="scripts/app/entities/operation/operation.controller.js"></script>
<script src="scripts/app/entities/operation/operation-dialog.controller.js"></script>
<script src="scripts/app/entities/operation/operation-delete-dialog.controller.js"></script>
<script src="scripts/app/entities/operation/operation-detail.controller.js"></script>
<script src="scripts/components/entities/operation/operation.service.js"></script>
<!-- endbuild -->

View File

@ -0,0 +1,33 @@
'use strict';
angular.module('sampleApplicationApp').controller('UserManagementDialogController',
['$scope', '$stateParams', '$modalInstance', 'entity', 'User', 'Language',
function($scope, $stateParams, $modalInstance, entity, User, Language) {
$scope.user = entity;
$scope.authorities = ["ROLE_USER", "ROLE_ADMIN"];
Language.getAll().then(function (languages) {
$scope.languages = languages;
});
var onSaveSuccess = function (result) {
$scope.isSaving = false;
$modalInstance.close(result);
};
var onSaveError = function (result) {
$scope.isSaving = false;
};
$scope.save = function () {
$scope.isSaving = true;
if ($scope.user.id != null) {
User.update($scope.user, onSaveSuccess, onSaveError);
} else {
User.save($scope.user, onSaveSuccess, onSaveError);
}
};
$scope.clear = function() {
$modalInstance.dismiss('cancel');
};
}]);

View File

@ -0,0 +1,108 @@
<form name="editForm" role="form" novalidate ng-submit="save()" show-validation>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"
ng-click="clear()">&times;</button>
<h4 class="modal-title" id="myUserLabel" translate="user-management.home.createOrEditLabel">
Create or edit a User</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label translate="global.field.id">ID</label>
<input type="text" class="form-control" name="id"
ng-model="user.id" readonly>
</div>
<div class="form-group">
<label translate="user-management.login">Login</label>
<input type="text" class="form-control" name="login"
ng-model="user.login" ng-required="user.id == null" ng-maxlength="50">
<div ng-show="editForm.login.$invalid">
<p class="help-block"
ng-show="editForm.login.$error.required" translate="entity.validation.required">
This field is required.
</p>
<p class="help-block"
ng-show="editForm.login.$error.maxlength" translate="entity.validation.maxlength"
translate-value-max="50">
This field cannot be longer than 50 characters.
</p>
</div>
</div>
<div class="form-group">
<label translate="user-management.firstName">FirstName</label>
<input type="text" class="form-control" name="firstName"
ng-model="user.firstName" ng-maxlength="50">
<div ng-show="editForm.firstName.$invalid">
<p class="help-block"
ng-show="editForm.firstName.$error.maxlength" translate="entity.validation.maxlength"
translate-value-max="50">
This field cannot be longer than 50 characters.
</p>
</div>
</div>
<div class="form-group">
<label translate="user-management.lastName">LastName</label>
<input type="text" class="form-control" name="lastName"
ng-model="user.lastName" ng-maxlength="50">
<div ng-show="editForm.lastName.$invalid">
<p class="help-block"
ng-show="editForm.lastName.$error.maxlength" translate="entity.validation.maxlength"
translate-value-max="50">
This field cannot be longer than 50 characters.
</p>
</div>
</div>
<div class="form-group">
<label translate="user-management.email">Email</label>
<input type="text" class="form-control" name="email"
ng-model="user.email" required ng-maxlength="100">
<div ng-show="editForm.email.$invalid">
<p class="help-block"
ng-show="editForm.email.$error.required" translate="entity.validation.required">
This field is required.
</p>
<p class="help-block"
ng-show="editForm.email.$error.maxlength" translate="entity.validation.maxlength"
translate-value-max="100">
This field cannot be longer than 100 characters.
</p>
</div>
</div>
<div class="form-group">
<label for="activated">
<input type="checkbox" id="activated" ng-model="user.activated">
<span translate="user-management.activated">Activated</span>
</label>
</div>
<div class="form-group">
<label translate="user-management.langKey">LangKey</label>
<select class="form-control" name="langKey" ng-model="user.langKey"
ng-options="language as language for language in languages track by language">
</select>
</div>
<div class="form-group">
<label translate="user-management.profiles">Profiles</label>
<select class="form-control" multiple name="authority" ng-model="user.authorities"
ng-options="authority for authority in authorities">
</select>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" ng-click="clear()">
<span class="glyphicon glyphicon-ban-circle"></span>&nbsp;<span
translate="entity.action.cancel">Cancel</span>
</button>
<button type="submit" ng-disabled="editForm.$invalid || isSaving" class="btn btn-primary">
<span class="glyphicon glyphicon-save"></span>&nbsp;<span translate="entity.action.save">Save</span>
</button>
</div>
</form>

View File

@ -30,26 +30,6 @@ angular.module('sampleApplicationApp')
});
};
$scope.showUpdate = function (login) {
User.get({login: login}, function (result) {
$scope.user = result;
$('#saveUserModal').modal('show');
});
};
$scope.save = function () {
User.update($scope.user,
function () {
$scope.refresh();
});
};
$scope.refresh = function () {
$scope.loadAll();
$('#saveUserModal').modal('hide');
$scope.clear();
};
$scope.clear = function () {
$scope.user = {
id: null, login: null, firstName: null, lastName: null, email: null,

View File

@ -3,150 +3,6 @@
<h2 class="col-sm-6" translate="user-management.home.title">Users</h2>
</div>
<div class="modal fade" id="saveUserModal" tabindex="-1" role="dialog" aria-labelledby="myUserLabel"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<form name="editForm" role="form" novalidate ng-submit="save()" show-validation>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"
ng-click="clear()">&times;</button>
<h4 class="modal-title" id="myUserLabel" translate="user-management.home.createOrEditLabel">
Create or edit a User</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label translate="global.field.id">ID</label>
<input type="text" class="form-control" name="id"
ng-model="user.id" readonly>
</div>
<div class="form-group">
<label translate="user-management.login">Login</label>
<input type="text" class="form-control" name="login"
ng-model="user.login" ng-required="user.id == null" ng-maxlength="50">
<div ng-show="editForm.login.$invalid">
<p class="help-block"
ng-show="editForm.login.$error.required" translate="entity.validation.required">
This field is required.
</p>
<p class="help-block"
ng-show="editForm.login.$error.maxlength" translate="entity.validation.maxlength"
translate-value-max="50">
This field cannot be longer than 50 characters.
</p>
</div>
</div>
<div class="form-group">
<label translate="user-management.firstName">FirstName</label>
<input type="text" class="form-control" name="firstName"
ng-model="user.firstName" ng-maxlength="50">
<div ng-show="editForm.firstName.$invalid">
<p class="help-block"
ng-show="editForm.firstName.$error.maxlength" translate="entity.validation.maxlength"
translate-value-max="50">
This field cannot be longer than 50 characters.
</p>
</div>
</div>
<div class="form-group">
<label translate="user-management.lastName">LastName</label>
<input type="text" class="form-control" name="lastName"
ng-model="user.lastName" ng-maxlength="50">
<div ng-show="editForm.lastName.$invalid">
<p class="help-block"
ng-show="editForm.lastName.$error.maxlength" translate="entity.validation.maxlength"
translate-value-max="50">
This field cannot be longer than 50 characters.
</p>
</div>
</div>
<div class="form-group">
<label translate="user-management.email">Email</label>
<input type="text" class="form-control" name="email"
ng-model="user.email" required ng-maxlength="100">
<div ng-show="editForm.email.$invalid">
<p class="help-block"
ng-show="editForm.email.$error.required" translate="entity.validation.required">
This field is required.
</p>
<p class="help-block"
ng-show="editForm.email.$error.maxlength" translate="entity.validation.maxlength"
translate-value-max="100">
This field cannot be longer than 100 characters.
</p>
</div>
</div>
<div class="form-group">
<label for="activated">
<input type="checkbox" id="activated" ng-model="user.activated">
<span translate="user-management.activated">Activated</span>
</label>
</div>
<div class="form-group">
<label translate="user-management.langKey">LangKey</label>
<select class="form-control" name="langKey" ng-model="user.langKey"
ng-options="language as language for language in languages track by language">
</select>
</div>
<div class="form-group">
<label translate="user-management.profiles">Profiles</label>
<select class="form-control" multiple name="authority" ng-model="user.authorities"
ng-options="authority for authority in authorities">
</select>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" ng-click="clear()">
<span class="glyphicon glyphicon-ban-circle"></span>&nbsp;<span
translate="entity.action.cancel">Cancel</span>
</button>
<button type="submit" ng-disabled="editForm.$invalid" class="btn btn-primary">
<span class="glyphicon glyphicon-save"></span>&nbsp;<span translate="entity.action.save">Save</span>
</button>
</div>
</form>
</div>
</div>
</div>
<div class="modal fade" id="deleteUserConfirmation">
<div class="modal-dialog">
<div class="modal-content">
<form name="deleteForm" ng-submit="confirmDelete(user.id)">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"
ng-click="clear()">&times;</button>
<h4 class="modal-title" translate="entity.delete.title">Confirm delete operation</h4>
</div>
<div class="modal-body">
<p translate="user-management.delete.question" translate-values="{login: '{{user.login}}'}">Are you
sure you want to delete this User?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" ng-click="clear()">
<span class="glyphicon glyphicon-ban-circle"></span>&nbsp;<span
translate="entity.action.cancel">Cancel</span>
</button>
<button type="submit" ng-disabled="deleteForm.$invalid" class="btn btn-danger">
<span class="glyphicon glyphicon-remove-circle"></span>&nbsp;<span
translate="entity.action.delete">Delete</span>
</button>
</div>
</form>
</div>
</div>
</div>
<div class="table-responsive">
<table class="table table-striped">
<thead>
@ -190,7 +46,7 @@
<span class="glyphicon glyphicon-eye-open"></span>
</button>
<button type="submit"
ng-click="showUpdate(user.login)"
ui-sref="user-management.edit({login:user.login})"
class="btn btn-primary btn-sm">
<span class="glyphicon glyphicon-pencil"></span>
</button>

View File

@ -42,5 +42,56 @@ angular.module('sampleApplicationApp')
return $translate.refresh();
}]
}
})
.state('user-management.new', {
parent: 'user-management',
url: '/new',
data: {
authorities: ['ROLE_ADMIN'],
},
onEnter: ['$stateParams', '$state', '$modal', function($stateParams, $state, $modal) {
$modal.open({
templateUrl: 'scripts/app/admin/user-management/user-management-dialog.html',
controller: 'UserManagementDialogController',
size: 'lg',
resolve: {
entity: function () {
return {
id: null, login: null, firstName: null, lastName: null, email: null,
activated: null, langKey: null, createdBy: null, createdDate: null,
lastModifiedBy: null, lastModifiedDate: null, resetDate: null,
resetKey: null, authorities: null
};
}
}
}).result.then(function(result) {
$state.go('user-management', null, { reload: true });
}, function() {
$state.go('user-management');
})
}]
})
.state('user-management.edit', {
parent: 'user-management',
url: '/{login}/edit',
data: {
authorities: ['ROLE_ADMIN'],
},
onEnter: ['$stateParams', '$state', '$modal', function($stateParams, $state, $modal) {
$modal.open({
templateUrl: 'scripts/app/admin/user-management/user-management-dialog.html',
controller: 'UserManagementDialogController',
size: 'lg',
resolve: {
entity: ['User', function(User) {
return User.get({login : $stateParams.login});
}]
}
}).result.then(function(result) {
$state.go('user-management', null, { reload: true });
}, function() {
$state.go('^');
})
}]
});
});

View File

@ -2,9 +2,23 @@
angular.module('sampleApplicationApp', ['LocalStorageModule', 'tmh.dynamicLocale', 'pascalprecht.translate',
'ui.bootstrap', // for modal dialogs
'ngResource', 'ui.router', 'ngCookies', 'ngAria', 'ngCacheBuster', 'ngFileUpload', 'infinite-scroll'])
'ngResource', 'ui.router', 'ngCookies', 'ngAria', 'ngCacheBuster', 'ngFileUpload', 'infinite-scroll', 'angular-loading-bar'])
.run(function ($rootScope, $location, $window, $http, $state, $translate, Language, Auth, Principal, ENV, VERSION) {
// update the window title using params in the following
// precendence
// 1. titleKey parameter
// 2. $state.$current.data.pageTitle (current state page title)
// 3. 'global.title'
var updateTitle = function(titleKey) {
if (!titleKey && $state.$current.data && $state.$current.data.pageTitle) {
titleKey = $state.$current.data.pageTitle;
}
$translate(titleKey || 'global.title').then(function (title) {
$window.document.title = title;
});
};
$rootScope.ENV = ENV;
$rootScope.VERSION = VERSION;
$rootScope.$on('$stateChangeStart', function (event, toState, toStateParams) {
@ -38,14 +52,13 @@ angular.module('sampleApplicationApp', ['LocalStorageModule', 'tmh.dynamicLocale
if (toState.data.pageTitle) {
titleKey = toState.data.pageTitle;
}
$translate(titleKey).then(function (title) {
// Change window title with translated one
$window.document.title = title;
});
updateTitle(titleKey);
});
// if the current translation changes, update the window title
$rootScope.$on('$translateChangeSuccess', function() { updateTitle(); });
$rootScope.back = function() {
// If previous state is 'activate' or do not exist go to 'home'
if ($rootScope.previousStateName === 'activate' || $state.get($rootScope.previousStateName) === null) {
@ -55,7 +68,9 @@ angular.module('sampleApplicationApp', ['LocalStorageModule', 'tmh.dynamicLocale
}
};
})
.config(function ($stateProvider, $urlRouterProvider, $httpProvider, $locationProvider, $translateProvider, tmhDynamicLocaleProvider, httpRequestInterceptorCacheBusterProvider) {
.config(function ($stateProvider, $urlRouterProvider, $httpProvider, $locationProvider, $translateProvider, tmhDynamicLocaleProvider, httpRequestInterceptorCacheBusterProvider, AlertServiceProvider) {
// uncomment below to make alerts look like toast
//AlertServiceProvider.showAsToast(true);
//enable CSRF
$httpProvider.defaults.xsrfCookieName = 'CSRF-TOKEN';

View File

@ -0,0 +1,17 @@
'use strict';
angular.module('sampleApplicationApp')
.controller('BankAccountDeleteController', function($scope, $modalInstance, entity, BankAccount) {
$scope.bankAccount = entity;
$scope.clear = function() {
$modalInstance.dismiss('cancel');
};
$scope.confirmDelete = function (id) {
BankAccount.delete({id: id},
function () {
$modalInstance.close(true);
});
};
});

View File

@ -0,0 +1,18 @@
<form name="deleteForm" ng-submit="confirmDelete(bankAccount.id)">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"
ng-click="clear()">&times;</button>
<h4 class="modal-title" translate="entity.delete.title">Confirm delete operation</h4>
</div>
<div class="modal-body">
<p translate="sampleApplicationApp.bankAccount.delete.question" translate-values="{id: '{{bankAccount.id}}'}">Are you sure you want to delete this BankAccount?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" ng-click="clear()">
<span class="glyphicon glyphicon-ban-circle"></span>&nbsp;<span translate="entity.action.cancel">Cancel</span>
</button>
<button type="submit" ng-disabled="deleteForm.$invalid" class="btn btn-danger">
<span class="glyphicon glyphicon-remove-circle"></span>&nbsp;<span translate="entity.action.delete">Delete</span>
</button>
</div>
</form>

View File

@ -13,16 +13,22 @@ angular.module('sampleApplicationApp').controller('BankAccountDialogController',
});
};
var onSaveFinished = function (result) {
var onSaveSuccess = function (result) {
$scope.$emit('sampleApplicationApp:bankAccountUpdate', result);
$modalInstance.close(result);
$scope.isSaving = false;
};
var onSaveError = function (result) {
$scope.isSaving = false;
};
$scope.save = function () {
$scope.isSaving = true;
if ($scope.bankAccount.id != null) {
BankAccount.update($scope.bankAccount, onSaveFinished);
BankAccount.update($scope.bankAccount, onSaveSuccess, onSaveError);
} else {
BankAccount.save($scope.bankAccount, onSaveFinished);
BankAccount.save($scope.bankAccount, onSaveSuccess, onSaveError);
}
};

View File

@ -53,7 +53,7 @@
<button type="button" class="btn btn-default" data-dismiss="modal" ng-click="clear()">
<span class="glyphicon glyphicon-ban-circle"></span>&nbsp;<span translate="entity.action.cancel">Cancel</span>
</button>
<button type="submit" ng-disabled="editForm.$invalid || editForm.$submitted" class="btn btn-primary">
<button type="submit" ng-disabled="editForm.$invalid || isSaving" class="btn btn-primary">
<span class="glyphicon glyphicon-save"></span>&nbsp;<span translate="entity.action.save">Save</span>
</button>
</div>

View File

@ -1,7 +1,7 @@
'use strict';
angular.module('sampleApplicationApp')
.controller('BankAccountController', function ($scope, BankAccount) {
.controller('BankAccountController', function ($scope, $state, $modal, BankAccount) {
$scope.bankAccounts = [];
$scope.loadAll = function() {
BankAccount.query(function(result) {
@ -10,21 +10,6 @@ angular.module('sampleApplicationApp')
};
$scope.loadAll();
$scope.delete = function (id) {
BankAccount.get({id: id}, function(result) {
$scope.bankAccount = result;
$('#deleteBankAccountConfirmation').modal('show');
});
};
$scope.confirmDelete = function (id) {
BankAccount.delete({id: id},
function () {
$scope.loadAll();
$('#deleteBankAccountConfirmation').modal('hide');
$scope.clear();
});
};
$scope.refresh = function () {
$scope.loadAll();

View File

@ -96,5 +96,28 @@ angular.module('sampleApplicationApp')
$state.go('^');
})
}]
})
.state('bankAccount.delete', {
parent: 'bankAccount',
url: '/{id}/delete',
data: {
authorities: ['ROLE_USER'],
},
onEnter: ['$stateParams', '$state', '$modal', function($stateParams, $state, $modal) {
$modal.open({
templateUrl: 'scripts/app/entities/bankAccount/bankAccount-delete-dialog.html',
controller: 'BankAccountDeleteController',
size: 'md',
resolve: {
entity: ['BankAccount', function(BankAccount) {
return BankAccount.get({id : $stateParams.id});
}]
}
}).result.then(function(result) {
$state.go('bankAccount', null, { reload: true });
}, function() {
$state.go('^');
})
}]
});
});

View File

@ -11,31 +11,6 @@
</div>
</div>
<div class="modal fade" id="deleteBankAccountConfirmation">
<div class="modal-dialog">
<div class="modal-content">
<form name="deleteForm" ng-submit="confirmDelete(bankAccount.id)">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"
ng-click="clear()">&times;</button>
<h4 class="modal-title" translate="entity.delete.title">Confirm delete operation</h4>
</div>
<div class="modal-body">
<p translate="sampleApplicationApp.bankAccount.delete.question" translate-values="{id: '{{bankAccount.id}}'}">Are you sure you want to delete this BankAccount?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" ng-click="clear()">
<span class="glyphicon glyphicon-ban-circle"></span>&nbsp;<span translate="entity.action.cancel">Cancel</span>
</button>
<button type="submit" ng-disabled="deleteForm.$invalid" class="btn btn-danger">
<span class="glyphicon glyphicon-remove-circle"></span>&nbsp;<span translate="entity.action.delete">Delete</span>
</button>
</div>
</form>
</div>
</div>
</div>
<div class="table-responsive">
<table class="table table-striped">
<thead>
@ -67,7 +42,7 @@
<span class="glyphicon glyphicon-pencil"></span>&nbsp;<span translate="entity.action.edit"> Edit</span>
</button>
<button type="submit"
ng-click="delete(bankAccount.id)"
ui-sref="bankAccount.delete({id:bankAccount.id})"
class="btn btn-danger btn-sm">
<span class="glyphicon glyphicon-remove-circle"></span>&nbsp;<span translate="entity.action.delete"> Delete</span>
</button>

View File

@ -0,0 +1,17 @@
'use strict';
angular.module('sampleApplicationApp')
.controller('LabelDeleteController', function($scope, $modalInstance, entity, Label) {
$scope.label = entity;
$scope.clear = function() {
$modalInstance.dismiss('cancel');
};
$scope.confirmDelete = function (id) {
Label.delete({id: id},
function () {
$modalInstance.close(true);
});
};
});

View File

@ -0,0 +1,18 @@
<form name="deleteForm" ng-submit="confirmDelete(label.id)">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"
ng-click="clear()">&times;</button>
<h4 class="modal-title" translate="entity.delete.title">Confirm delete operation</h4>
</div>
<div class="modal-body">
<p translate="sampleApplicationApp.label.delete.question" translate-values="{id: '{{label.id}}'}">Are you sure you want to delete this Label?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" ng-click="clear()">
<span class="glyphicon glyphicon-ban-circle"></span>&nbsp;<span translate="entity.action.cancel">Cancel</span>
</button>
<button type="submit" ng-disabled="deleteForm.$invalid" class="btn btn-danger">
<span class="glyphicon glyphicon-remove-circle"></span>&nbsp;<span translate="entity.action.delete">Delete</span>
</button>
</div>
</form>

View File

@ -12,16 +12,22 @@ angular.module('sampleApplicationApp').controller('LabelDialogController',
});
};
var onSaveFinished = function (result) {
var onSaveSuccess = function (result) {
$scope.$emit('sampleApplicationApp:labelUpdate', result);
$modalInstance.close(result);
$scope.isSaving = false;
};
var onSaveError = function (result) {
$scope.isSaving = false;
};
$scope.save = function () {
$scope.isSaving = true;
if ($scope.label.id != null) {
Label.update($scope.label, onSaveFinished);
Label.update($scope.label, onSaveSuccess, onSaveError);
} else {
Label.save($scope.label, onSaveFinished);
Label.save($scope.label, onSaveSuccess, onSaveError);
}
};

View File

@ -35,7 +35,7 @@
<button type="button" class="btn btn-default" data-dismiss="modal" ng-click="clear()">
<span class="glyphicon glyphicon-ban-circle"></span>&nbsp;<span translate="entity.action.cancel">Cancel</span>
</button>
<button type="submit" ng-disabled="editForm.$invalid || editForm.$submitted" class="btn btn-primary">
<button type="submit" ng-disabled="editForm.$invalid || isSaving" class="btn btn-primary">
<span class="glyphicon glyphicon-save"></span>&nbsp;<span translate="entity.action.save">Save</span>
</button>
</div>

View File

@ -1,7 +1,7 @@
'use strict';
angular.module('sampleApplicationApp')
.controller('LabelController', function ($scope, Label) {
.controller('LabelController', function ($scope, $state, $modal, Label) {
$scope.labels = [];
$scope.loadAll = function() {
Label.query(function(result) {
@ -10,21 +10,6 @@ angular.module('sampleApplicationApp')
};
$scope.loadAll();
$scope.delete = function (id) {
Label.get({id: id}, function(result) {
$scope.label = result;
$('#deleteLabelConfirmation').modal('show');
});
};
$scope.confirmDelete = function (id) {
Label.delete({id: id},
function () {
$scope.loadAll();
$('#deleteLabelConfirmation').modal('hide');
$scope.clear();
});
};
$scope.refresh = function () {
$scope.loadAll();

View File

@ -95,5 +95,28 @@ angular.module('sampleApplicationApp')
$state.go('^');
})
}]
})
.state('label.delete', {
parent: 'label',
url: '/{id}/delete',
data: {
authorities: ['ROLE_USER'],
},
onEnter: ['$stateParams', '$state', '$modal', function($stateParams, $state, $modal) {
$modal.open({
templateUrl: 'scripts/app/entities/label/label-delete-dialog.html',
controller: 'LabelDeleteController',
size: 'md',
resolve: {
entity: ['Label', function(Label) {
return Label.get({id : $stateParams.id});
}]
}
}).result.then(function(result) {
$state.go('label', null, { reload: true });
}, function() {
$state.go('^');
})
}]
});
});

View File

@ -11,31 +11,6 @@
</div>
</div>
<div class="modal fade" id="deleteLabelConfirmation">
<div class="modal-dialog">
<div class="modal-content">
<form name="deleteForm" ng-submit="confirmDelete(label.id)">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"
ng-click="clear()">&times;</button>
<h4 class="modal-title" translate="entity.delete.title">Confirm delete operation</h4>
</div>
<div class="modal-body">
<p translate="sampleApplicationApp.label.delete.question" translate-values="{id: '{{label.id}}'}">Are you sure you want to delete this Label?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" ng-click="clear()">
<span class="glyphicon glyphicon-ban-circle"></span>&nbsp;<span translate="entity.action.cancel">Cancel</span>
</button>
<button type="submit" ng-disabled="deleteForm.$invalid" class="btn btn-danger">
<span class="glyphicon glyphicon-remove-circle"></span>&nbsp;<span translate="entity.action.delete">Delete</span>
</button>
</div>
</form>
</div>
</div>
</div>
<div class="table-responsive">
<table class="table table-striped">
<thead>
@ -61,7 +36,7 @@
<span class="glyphicon glyphicon-pencil"></span>&nbsp;<span translate="entity.action.edit"> Edit</span>
</button>
<button type="submit"
ng-click="delete(label.id)"
ui-sref="label.delete({id:label.id})"
class="btn btn-danger btn-sm">
<span class="glyphicon glyphicon-remove-circle"></span>&nbsp;<span translate="entity.action.delete"> Delete</span>
</button>

View File

@ -0,0 +1,17 @@
'use strict';
angular.module('sampleApplicationApp')
.controller('OperationDeleteController', function($scope, $modalInstance, entity, Operation) {
$scope.operation = entity;
$scope.clear = function() {
$modalInstance.dismiss('cancel');
};
$scope.confirmDelete = function (id) {
Operation.delete({id: id},
function () {
$modalInstance.close(true);
});
};
});

View File

@ -0,0 +1,18 @@
<form name="deleteForm" ng-submit="confirmDelete(operation.id)">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"
ng-click="clear()">&times;</button>
<h4 class="modal-title" translate="entity.delete.title">Confirm delete operation</h4>
</div>
<div class="modal-body">
<p translate="sampleApplicationApp.operation.delete.question" translate-values="{id: '{{operation.id}}'}">Are you sure you want to delete this Operation?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" ng-click="clear()">
<span class="glyphicon glyphicon-ban-circle"></span>&nbsp;<span translate="entity.action.cancel">Cancel</span>
</button>
<button type="submit" ng-disabled="deleteForm.$invalid" class="btn btn-danger">
<span class="glyphicon glyphicon-remove-circle"></span>&nbsp;<span translate="entity.action.delete">Delete</span>
</button>
</div>
</form>

View File

@ -13,16 +13,22 @@ angular.module('sampleApplicationApp').controller('OperationDialogController',
});
};
var onSaveFinished = function (result) {
var onSaveSuccess = function (result) {
$scope.$emit('sampleApplicationApp:operationUpdate', result);
$modalInstance.close(result);
$scope.isSaving = false;
};
var onSaveError = function (result) {
$scope.isSaving = false;
};
$scope.save = function () {
$scope.isSaving = true;
if ($scope.operation.id != null) {
Operation.update($scope.operation, onSaveFinished);
Operation.update($scope.operation, onSaveSuccess, onSaveError);
} else {
Operation.save($scope.operation, onSaveFinished);
Operation.save($scope.operation, onSaveSuccess, onSaveError);
}
};

View File

@ -67,7 +67,7 @@
<button type="button" class="btn btn-default" data-dismiss="modal" ng-click="clear()">
<span class="glyphicon glyphicon-ban-circle"></span>&nbsp;<span translate="entity.action.cancel">Cancel</span>
</button>
<button type="submit" ng-disabled="editForm.$invalid || editForm.$submitted" class="btn btn-primary">
<button type="submit" ng-disabled="editForm.$invalid || isSaving" class="btn btn-primary">
<span class="glyphicon glyphicon-save"></span>&nbsp;<span translate="entity.action.save">Save</span>
</button>
</div>

View File

@ -1,7 +1,7 @@
'use strict';
angular.module('sampleApplicationApp')
.controller('OperationController', function ($scope, Operation, ParseLinks) {
.controller('OperationController', function ($scope, $state, $modal, Operation, ParseLinks) {
$scope.operations = [];
$scope.page = 0;
$scope.loadAll = function() {
@ -23,21 +23,6 @@ angular.module('sampleApplicationApp')
};
$scope.loadAll();
$scope.delete = function (id) {
Operation.get({id: id}, function(result) {
$scope.operation = result;
$('#deleteOperationConfirmation').modal('show');
});
};
$scope.confirmDelete = function (id) {
Operation.delete({id: id},
function () {
$scope.reset();
$('#deleteOperationConfirmation').modal('hide');
$scope.clear();
});
};
$scope.refresh = function () {
$scope.reset();

View File

@ -97,5 +97,28 @@ angular.module('sampleApplicationApp')
$state.go('^');
})
}]
})
.state('operation.delete', {
parent: 'operation',
url: '/{id}/delete',
data: {
authorities: ['ROLE_USER'],
},
onEnter: ['$stateParams', '$state', '$modal', function($stateParams, $state, $modal) {
$modal.open({
templateUrl: 'scripts/app/entities/operation/operation-delete-dialog.html',
controller: 'OperationDeleteController',
size: 'md',
resolve: {
entity: ['Operation', function(Operation) {
return Operation.get({id : $stateParams.id});
}]
}
}).result.then(function(result) {
$state.go('operation', null, { reload: true });
}, function() {
$state.go('^');
})
}]
});
});

View File

@ -11,31 +11,6 @@
</div>
</div>
<div class="modal fade" id="deleteOperationConfirmation">
<div class="modal-dialog">
<div class="modal-content">
<form name="deleteForm" ng-submit="confirmDelete(operation.id)">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"
ng-click="clear()">&times;</button>
<h4 class="modal-title" translate="entity.delete.title">Confirm delete operation</h4>
</div>
<div class="modal-body">
<p translate="sampleApplicationApp.operation.delete.question" translate-values="{id: '{{operation.id}}'}">Are you sure you want to delete this Operation?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" ng-click="clear()">
<span class="glyphicon glyphicon-ban-circle"></span>&nbsp;<span translate="entity.action.cancel">Cancel</span>
</button>
<button type="submit" ng-disabled="deleteForm.$invalid" class="btn btn-danger">
<span class="glyphicon glyphicon-remove-circle"></span>&nbsp;<span translate="entity.action.delete">Delete</span>
</button>
</div>
</form>
</div>
</div>
</div>
<div class="table-responsive">
<table class="table table-striped">
<thead>
@ -69,7 +44,7 @@
<span class="glyphicon glyphicon-pencil"></span>&nbsp;<span translate="entity.action.edit"> Edit</span>
</button>
<button type="submit"
ng-click="delete(operation.id)"
ui-sref="operation.delete({id:operation.id})"
class="btn btn-danger btn-sm">
<span class="glyphicon glyphicon-remove-circle"></span>&nbsp;<span translate="entity.action.delete"> Delete</span>
</button>

View File

@ -5,8 +5,10 @@ angular.module('sampleApplicationApp')
return {
restrict: 'E',
template: '<div class="alerts" ng-cloak="">' +
'<alert ng-cloak="" ng-repeat="alert in alerts" type="{{alert.type}}" close="alert.close()"><pre>{{ alert.msg }}</pre></alert>' +
'</div>',
'<div ng-repeat="alert in alerts" ng-class="[alert.position, {\'toast\': alert.toast}]">' +
'<alert ng-cloak="" type="{{alert.type}}" close="alert.close()"><pre>{{ alert.msg }}</pre></alert>' +
'</div>' +
'</div>',
controller: ['$scope',
function($scope) {
$scope.alerts = AlertService.get();
@ -21,11 +23,14 @@ angular.module('sampleApplicationApp')
return {
restrict: 'E',
template: '<div class="alerts" ng-cloak="">' +
'<alert ng-cloak="" ng-repeat="alert in alerts" type="{{alert.type}}" close="alert.close()"><pre>{{ alert.msg }}</pre></alert>' +
'</div>',
'<div ng-repeat="alert in alerts" ng-class="[alert.position, {\'toast\': alert.toast}]">' +
'<alert ng-cloak="" type="{{alert.type}}" close="alert.close(alerts)"><pre>{{ alert.msg }}</pre></alert>' +
'</div>' +
'</div>',
controller: ['$scope',
function($scope) {
$scope.alerts = AlertService.get();
$scope.alerts = [];
var cleanHttpErrorListener = $rootScope.$on('sampleApplicationApp.httpError', function (event, httpResponse) {
var i;
@ -46,9 +51,9 @@ angular.module('sampleApplicationApp')
addErrorAlert('Field ' + fieldName + ' cannot be empty', 'error.' + fieldError.message, {fieldName: fieldName});
}
} else if (httpResponse.data && httpResponse.data.message) {
addErrorAlert(httpResponse.data.message, httpResponse.data.message, httpResponse.data);
addErrorAlert(httpResponse.data.message, httpResponse.data.message, httpResponse.data);
} else {
addErrorAlert(httpResponse.data);
addErrorAlert(httpResponse.data);
}
break;
@ -64,14 +69,25 @@ angular.module('sampleApplicationApp')
$scope.$on('$destroy', function () {
if(cleanHttpErrorListener !== undefined && cleanHttpErrorListener !== null){
cleanHttpErrorListener();
$scope.alerts = [];
}
});
var addErrorAlert = function (message, key, data) {
key = key && key != null ? key : message;
AlertService.error(key, data);
$scope.alerts.push(
AlertService.add(
{
type: "danger",
msg: key,
params: data,
timeout: 5000,
toast: AlertService.isToast(),
scoped: true
},
$scope.alerts
)
);
}
}
]

View File

@ -1,99 +1,132 @@
'use strict';
angular.module('sampleApplicationApp')
.factory('AlertService', function ($timeout, $sce,$translate) {
var exports = {
factory: factory,
add: addAlert,
closeAlert: closeAlert,
closeAlertByIndex: closeAlertByIndex,
clear: clear,
get: get,
success: success,
error: error,
info: info,
warning : warning
},
alertId = 0, // unique id for each alert. Starts from 0.
alerts = [],
timeout = 5000; // default timeout
.provider('AlertService', function () {
this.toast = false;
function clear() {
alerts = [];
}
this.$get = ['$timeout', '$sce', '$translate', function($timeout, $sce,$translate) {
function get() {
return alerts;
}
var exports = {
factory: factory,
isToast: isToast,
add: addAlert,
closeAlert: closeAlert,
closeAlertByIndex: closeAlertByIndex,
clear: clear,
get: get,
success: success,
error: error,
info: info,
warning : warning
},
toast = this.toast,
alertId = 0, // unique id for each alert. Starts from 0.
alerts = [],
timeout = 5000; // default timeout
function success(msg, params) {
this.add({
type: "success",
msg: msg,
params: params,
timeout: timeout
});
}
function error(msg, params) {
this.add({
type: "danger",
msg: msg,
params: params,
timeout: timeout
});
}
function warning(msg, params) {
this.add({
type: "warning",
msg: msg,
params: params,
timeout: timeout
});
}
function info(msg, params) {
this.add({
type: "info",
msg: msg,
params: params,
timeout: timeout
});
}
function factory(alertOptions) {
return alerts.push({
type: alertOptions.type,
msg: $sce.trustAsHtml(alertOptions.msg),
id: alertOptions.alertId,
timeout: alertOptions.timeout,
close: function () {
return exports.closeAlert(this.id);
}
});
}
function addAlert(alertOptions) {
alertOptions.alertId = alertId++;
alertOptions.msg = $translate.instant(alertOptions.msg, alertOptions.params);
var that = this;
this.factory(alertOptions);
if (alertOptions.timeout && alertOptions.timeout > 0) {
$timeout(function () {
that.closeAlert(alertOptions.alertId);
}, alertOptions.timeout);
function isToast() {
return toast;
}
}
function closeAlert(id) {
return this.closeAlertByIndex(alerts.map(function(e) { return e.id; }).indexOf(id));
}
function clear() {
alerts = [];
}
function closeAlertByIndex(index) {
return alerts.splice(index, 1);
}
function get() {
return alerts;
}
return exports;
function success(msg, params, position) {
return this.add({
type: "success",
msg: msg,
params: params,
timeout: timeout,
toast: toast,
position: position
});
}
});
function error(msg, params, position) {
return this.add({
type: "danger",
msg: msg,
params: params,
timeout: timeout,
toast: toast,
position: position
});
}
function warning(msg, params, position) {
return this.add({
type: "warning",
msg: msg,
params: params,
timeout: timeout,
toast: toast,
position: position
});
}
function info(msg, params, position) {
return this.add({
type: "info",
msg: msg,
params: params,
timeout: timeout,
toast: toast,
position: position
});
}
function factory(alertOptions) {
var alert = {
type: alertOptions.type,
msg: $sce.trustAsHtml(alertOptions.msg),
id: alertOptions.alertId,
timeout: alertOptions.timeout,
toast: alertOptions.toast,
position: alertOptions.position ? alertOptions.position : 'top right',
scoped: alertOptions.scoped,
close: function (alerts) {
return exports.closeAlert(this.id, alerts);
}
}
if(!alert.scoped) {
alerts.push(alert);
}
return alert;
}
function addAlert(alertOptions, extAlerts) {
alertOptions.alertId = alertId++;
alertOptions.msg = $translate.instant(alertOptions.msg, alertOptions.params);
var that = this;
var alert = this.factory(alertOptions);
if (alertOptions.timeout && alertOptions.timeout > 0) {
$timeout(function () {
that.closeAlert(alertOptions.alertId, extAlerts);
}, alertOptions.timeout);
}
return alert;
}
function closeAlert(id, extAlerts) {
var thisAlerts = extAlerts ? extAlerts : alerts;
return this.closeAlertByIndex(thisAlerts.map(function(e) { return e.id; }).indexOf(id), thisAlerts);
}
function closeAlertByIndex(index, thisAlerts) {
return thisAlerts.splice(index, 1);
}
return exports;
}];
this.showAsToast = function(isToast) {
this.toast = isToast;
};
});

View File

@ -21,6 +21,7 @@ module.exports = function (config) {
'main/webapp/bower_components/angular-cookies/angular-cookies.js',
'main/webapp/bower_components/angular-dynamic-locale/src/tmhDynamicLocale.js',
'main/webapp/bower_components/angular-local-storage/dist/angular-local-storage.js',
'main/webapp/bower_components/angular-loading-bar/build/loading-bar.js',
'main/webapp/bower_components/angular-resource/angular-resource.js',
'main/webapp/bower_components/angular-sanitize/angular-sanitize.js',
'main/webapp/bower_components/angular-translate/angular-translate.js',

View File

@ -10,12 +10,6 @@
# http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
# ===================================================================
# ===================================================================
# JHipster specific properties
# ===================================================================
spring:
datasource:
driver-class-name: org.h2.jdbcx.JdbcDataSource