welcome page

This commit is contained in:
Athou
2014-08-09 16:07:24 +02:00
parent 33b683d037
commit bbf04c4687
10 changed files with 139 additions and 13 deletions

View File

@@ -18,7 +18,7 @@
"angular-ui-utils": "0.1.0",
"angular-ui-select2": "0.0.5",
"angular-bootstrap": "0.2.0",
"angular-loading-bar": "0.4.0",
"angular-loading-bar": "0.5.0",
"ngInfiniteScroll": "1.0.0",
"ng-grid": "2.0.6",
"mousetrap": "1.4.6",

View File

@@ -47,6 +47,16 @@ gulp.task('template-cache', function() {
return gulp.src(SRC_DIR + 'templates/**/*.html').pipe(templateCache(options)).pipe(gulp.dest(TEMP_DIR + 'js'));
});
gulp.task('build-dev', ['images', 'favicons', 'sass', 'fonts', 'template-cache', 'bower'], function() {
var assets = useref.assets({
searchPath : [SRC_DIR, TEMP_DIR]
});
var jsFilter = filter("**/*.js");
var cssFilter = filter("**/*.css");
return gulp.src([SRC_DIR + 'index.html', TEMP_DIR + 'app.css']).pipe(assets).pipe(assets.restore()).pipe(useref()).pipe(
gulp.dest(BUILD_DIR));
});
gulp.task('build', ['images', 'favicons', 'sass', 'fonts', 'template-cache', 'bower'], function() {
var assets = useref.assets({
searchPath : [SRC_DIR, TEMP_DIR]
@@ -63,8 +73,9 @@ gulp.task('build', ['images', 'favicons', 'sass', 'fonts', 'template-cache', 'bo
});
gulp.task('watch', function() {
gulp.watch(SRC_DIR + 'sass/**/*.scss', ['build']);
gulp.watch(SRC_DIR + 'js/**/*.js', ['build']);
gulp.watch(SRC_DIR + 'sass/**/*.scss', ['build-dev']);
gulp.watch(SRC_DIR + 'js/**/*.js', ['build-dev']);
gulp.watch(SRC_DIR + 'templates/**/*.html', ['build-dev']);
});
gulp.task('serve', function() {
@@ -80,5 +91,5 @@ gulp.task('serve', function() {
});
});
gulp.task('dev', ['build', 'watch', 'serve']);
gulp.task('dev', ['build-dev', 'watch', 'serve']);
gulp.task('default', ['build']);

View File

@@ -1454,3 +1454,32 @@ module.controller('FooterController', ['$scope', '$sce', function($scope, $sce)
module.controller('MetricsCtrl', ['$scope', 'AdminMetricsService', function($scope, AdminMetricsService) {
$scope.metrics = AdminMetricsService.get();
}]);
module.controller('WelcomeCtrl', ['$scope', '$location', 'SessionService', 'ServerService', function($scope, $location, SessionService, ServerService) {
$scope.ServerService = ServerService.get();
$scope.model = {};
var login = function(model) {
var success = function(data) {
$location.path('/');
$scope.$emit('emitReload');
};
var error = function(data) {
$scope.message = data.data;
};
SessionService.login({
name : model.name,
password : model.password
}, success, error);
}
$scope.demoLogin = function() {
login({
name : 'demo',
password : 'demo'
});
};
$scope.login = function() {
login($scope.model);
};
}]);

View File

@@ -17,10 +17,8 @@ app.config(['$routeProvider', '$stateProvider', '$urlRouterProvider', '$httpProv
var status = response.status;
if (status == 401) {
$injector.get('$state').transitionTo('welcome');
return;
} else {
return $q.reject(response);
}
return $q.reject(response);
};
var promise = function(promise) {

View File

@@ -32,6 +32,13 @@ module.factory('ProfileService', ['$resource', function($resource) {
return res;
}]);
module.factory('SessionService', ['$resource', function($resource) {
var res = {};
res.login = $resource('rest/user/login').save;
res.register = $resource('rest/user/register').save;
return res;
}]);
module.factory('SettingsService', ['$resource', function($resource) {
var res = $resource('rest/user/settings');

View File

@@ -1,3 +1,82 @@
<div class="container">
<div class="admin" ui-view></div>
</div>
<div class="row header">
<div class="pull-left">
<a>
<img src="images/logo_2.png"></img>
</a>
</div>
<div class="pull-right tagline">Bloat-free feed reader</div>
<div class="text-center">
<a href="#" ng-click="demoLogin()">
<img src="images/preview.jpg" class="preview" />
<br />
<span class="demo">
Try out the demo
<br />
<small>(some features are disabled)</small>
</span>
</a>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="well" id="login-panel">
<h3>Login</h3>
<span class="feedback">{{message}}</span>
<form ng-submit="login()">
<div class="form-group">
<label for="username">User Name</label>
<input type="text" name="username" class="form-control" ng-model="model.name"></input>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" name="password" class="form-control" ng-model="model.password"></input>
</div>
<div>
<input type="submit" class="btn btn-primary" value="Log in" />
<a class="pull-right">Forgot password?</a>
</div>
</form>
</div>
</div>
<div class="col-md-6" ng-if="ServerService.allowRegistrations">
<div class="well" id="register-panel">
<h3>Register</h3>
<span></span>
</div>
</div>
</div>
<hr />
<div class="footer">
<div class="row">
<span>
&copy;
<a href="http://www.commafeed.com" target="_blank">CommaFeed</a>
</span>
<span>
- Sources on
<a href="https://github.com/Athou/commafeed" target="_blank">GitHub</a>
</span>
<span>
- REST API
<a href="api" target="_blank">documentation</a>
</span>
<span class="pull-right">
<a href="https://twitter.com/CommaFeed" class="twitter-follow-button" data-show-count="false" data-size="large">Follow @CommaFeed</a>
<script>
!function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0], p = /^http:/.test(d.location) ? 'http' : 'https';
if (!d.getElementById(id)) {
js = d.createElement(s);
js.id = id;
js.src = p + '://platform.twitter.com/widgets.js';
fjs.parentNode.insertBefore(js, fjs);
}
}(document, 'script', 'twitter-wjs');
</script>
</span>
</div>
</div>
</div>

View File

@@ -33,7 +33,7 @@ public class UserService {
public Optional<User> login(String name, String password) {
if (name == null || password == null) {
return null;
return Optional.absent();
}
User user = userDAO.findByName(name);

View File

@@ -14,5 +14,6 @@ public class ServerInfo implements Serializable {
private String announcement;
private String version;
private String gitCommit;
private boolean allowRegistrations;
}

View File

@@ -39,11 +39,12 @@ public class ServerREST {
@GET
@UnitOfWork
@ApiOperation(value = "Get server infos", notes = "Get server infos", response = ServerInfo.class)
public Response get(@SecurityCheck User user) {
public Response get() {
ServerInfo infos = new ServerInfo();
infos.setAnnouncement(config.getApplicationSettings().getAnnouncement());
infos.setVersion(applicationPropertiesService.getVersion());
infos.setGitCommit(applicationPropertiesService.getGitCommit());
infos.setAllowRegistrations(config.getApplicationSettings().isAllowRegistrations());
return Response.ok(infos).build();
}

View File

@@ -216,10 +216,10 @@ public class UserREST {
public Response login(@ApiParam(required = true) LoginRequest req, @Session HttpSession session) {
Optional<User> user = userService.login(req.getName(), req.getPassword());
if (user.isPresent()) {
session.setAttribute(CommaFeedApplication.SESSION_USER, user);
session.setAttribute(CommaFeedApplication.SESSION_USER, user.get());
return Response.ok().build();
} else {
return Response.status(Response.Status.UNAUTHORIZED).build();
return Response.status(Response.Status.UNAUTHORIZED).entity("wrong username or password").build();
}
}