Added some minior stuff

parent fc0e938e
......@@ -31,6 +31,18 @@ Then issue the following command (still in the project root)
> gulp serve
Note that even though you can log in using Oauth2, we can "cheat" a bit when developing on other paths than "/"
by not commenting out the following code in archivingPortalClient.js:
Under archivingPortalClient.run([...])
LoginService.save({username: 'admin', password: 'password'}, function(data) {
$rootScope.oauth = data;
});
This will enable a sort of auto log in useful when you need it. So uncomment this line, and forget about auth.
The application will act funny when doing this, as some parts of the header injection oauth2 stuff is not there yet.
Packing the application
-----------------------
To package the application for release, simply (again in the project root), issue
......
......@@ -18,17 +18,16 @@
</head>
<body>
<div class="container">
<div class="container-fluid">
<nav class="navbar navbar-static-top navbar-inverse">
<div class="navbar-header">
<a class="navbar-brand" href="#">Archiving Portal</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-6">
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a ng-href="#">Home</a></li>
<li><a ng-href="#/archive">Send Schema</a></li>
<li><a ng-href="#">Home</a></li>
<li><a ng-href="#/project">Project</a></li>
</ul>
</div>
......@@ -43,6 +42,8 @@
</div>
<!-- build:js scripts/vendor.js -->
<!-- bower:js -->
<script src="bower_components/jquery/dist/jquery.js"></script>
......@@ -55,6 +56,7 @@
<script src="bower_components/angular-resource/angular-resource.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
<!-- endbower -->
<!-- endbuild -->
......@@ -64,9 +66,9 @@
<script src="scripts/service/LoginService.js"></script>
<script src="scripts/service/UserService.js"></script>
<script src="scripts/service/NationService.js"></script>
<script src="scripts/service/ProjectService.js"></script>
<script src="scripts/directives.js"></script>
<script src="scripts/controller/MainController.js"></script>
<script src="scripts/controller/ArchivingController.js"></script>
<script src="scripts/controller/ProjectController.js"></script>
<!-- inject:partials -->
<!-- endinject -->
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Offline :(</title>
<style>
::-moz-selection {
background: #b3d4fc;
text-shadow: none;
}
::selection {
background: #b3d4fc;
text-shadow: none;
}
html {
padding: 30px 10px;
font-size: 20px;
line-height: 1.4;
color: #737373;
background: #f0f0f0;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
html,
input {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
body {
max-width: 500px;
_width: 500px;
padding: 30px 20px 50px;
border: 1px solid #b3b3b3;
border-radius: 4px;
margin: 0 auto;
box-shadow: 0 1px 10px #a7a7a7, inset 0 1px 0 #fff;
background: #fcfcfc;
}
h1 {
margin: 0 10px;
font-size: 50px;
text-align: center;
}
h1 span {
color: #bbb;
}
h3 {
margin: 1.5em 0 0.5em;
}
p {
margin: 1em 0;
}
ul {
padding: 0 0 0 40px;
margin: 1em 0;
}
.container {
max-width: 380px;
_width: 380px;
margin: 0 auto;
}
/* google search */
#goog-fixurl ul {
list-style: none;
padding: 0;
margin: 0;
}
#goog-fixurl form {
margin: 0;
}
#goog-wm-qt,
#goog-wm-sb {
border: 1px solid #bbb;
font-size: 16px;
line-height: normal;
vertical-align: top;
color: #444;
border-radius: 2px;
}
#goog-wm-qt {
width: 220px;
height: 20px;
padding: 5px;
margin: 5px 10px 0 0;
box-shadow: inset 0 1px 1px #ccc;
}
#goog-wm-sb {
display: inline-block;
height: 32px;
padding: 0 10px;
margin: 5px 0 0;
white-space: nowrap;
cursor: pointer;
background-color: #f5f5f5;
background-image: -webkit-linear-gradient(rgba(255,255,255,0), #f1f1f1);
background-image: -moz-linear-gradient(rgba(255,255,255,0), #f1f1f1);
background-image: -ms-linear-gradient(rgba(255,255,255,0), #f1f1f1);
background-image: -o-linear-gradient(rgba(255,255,255,0), #f1f1f1);
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
*overflow: visible;
*display: inline;
*zoom: 1;
}
#goog-wm-sb:hover,
#goog-wm-sb:focus {
border-color: #aaa;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
background-color: #f8f8f8;
}
#goog-wm-qt:hover,
#goog-wm-qt:focus {
border-color: #105cb6;
outline: 0;
color: #222;
}
input::-moz-focus-inner {
padding: 0;
border: 0;
}
</style>
</head>
<body>
<div class="container">
<h1><span>:(</span></h1>
<p>
<h3>We are offline</h3>
Sorry, but the service is not responding to our request.
Please try again later or click <a href="/">here</a> to try again.
</p>
</div>
</body>
</html>
<div class="container">
archive
</div>
<form class="form-horizontal" role="form" name="project-form">
<fieldset>
<!-- Form Name -->
<legend>New Project</legend>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="grantNo">Grant No</label>
<div class="col-md-4">
<input ng-model="project.grantNo" id="grantNo" name="grantNo" type="text" placeholder="Grant No" class="form-control input-md">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="title">Title</label>
<div class="col-md-4">
<input ng-model="project.titl" id="title" name="title" type="text" placeholder="Title" class="form-control input-md">
</div>
<div class="row">
<div class="col-xs-12 col-md-6">
<h2>New Project</h2>
<form class="form-horizontal" role="form" name="project-form">
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="grantNo">Grant No</label>
<div class="col-md-4">
<input ng-model="project.grantNo" id="grantNo" name="grantNo" type="text" placeholder="Grant No"
class="form-control input-md">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="title">Title</label>
<div class="col-md-4">
<input ng-model="project.titl" id="title" name="title" type="text" placeholder="Title"
class="form-control input-md">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="authEnty">AuthEnty</label>
<div class="col-md-4">
<input ng-model="project.authEnty" id="authEnty" name="authEnty" type="text" placeholder="AuthEnty"
class="form-control input-md">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="timePrd">TimePrd</label>
<div class="col-md-4">
<input ng-model="project.timePrd" id="timePrd" name="timePrd" type="text" placeholder="TimePrd"
class="form-control input-md">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="fundAg">Fund Ag</label>
<div class="col-md-4">
<input ng-model="project.fundAg" id="fundAg" name="fundAg" type="text" placeholder="Fund Ag"
class="form-control input-md">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="abs">Abs</label>
<div class="col-md-4">
<input ng-model="project.abs" id="abs" name="abs" type="text" placeholder="Abs"
class="form-control input-md">
</div>
</div>
<!-- Button (Double) -->
<div class="form-group">
<label class="col-md-4 control-label" for="post"></label>
<div class="col-md-8">
<button type="submit" id="post" name="post" class="btn btn-success" ng-click="createProject()">Save
</button>
<button id="clear" name="clear" class="btn btn-warning" ng-click="resetProjectForm()">Clear</button>
</div>
</div>
<div class="alert alert-danger" role="alert" ng-show="postError != null">
{{postError}}
</div>
</form>
</div>
<div class="col-xs-12 col-md-6">
<h2>DataSet</h2>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-md-6">
<div class="alert alert-danger" role="alert" ng-show="listError != null">
{{listError}}
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="producer">Producer</label>
<div class="col-md-4">
<input ng-model="project.producer" id="producer" name="producer" type="text" placeholder="Producer" class="form-control input-md">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="authEnty">AuthEnty</label>
<div class="col-md-4">
<input ng-model="project.authEnty" id="authEnty" name="authEnty" type="text" placeholder="AuthEnty" class="form-control input-md">
</div>
<div ng-repeat="p in projects">
{{p.id}}<br/>
{{p.grantNo}}<br/>
{{p.titl}}<br/>
{{p.producer}}<br/>
{{p.authEnty}}<br/>
{{p.timePrd}}<br/>
{{p.fundAg}}<br/>
{{p.abs}}<br/>
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="timePrd">TimePrd</label>
<div class="col-md-4">
<input ng-model="project.timePrd" id="timePrd" name="timePrd" type="text" placeholder="TimePrd" class="form-control input-md">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="fundAg">Fund Ag</label>
<div class="col-md-4">
<input ng-model="project.fundAg" id="fundAg" name="fundAg" type="text" placeholder="Fund Ag" class="form-control input-md">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="abs">Abs</label>
<div class="col-md-4">
<input ng-model="project.abs" id="abs" name="abs" type="text" placeholder="Abs" class="form-control input-md">
</div>
</div>
<!-- Button (Double) -->
<div class="form-group">
<label class="col-md-4 control-label" for="post"></label>
<div class="col-md-8">
<button type="submit" id="post" name="post" class="btn btn-success" ng-click="create()">Save</button>
<button id="clear" name="clear" class="btn btn-warning">Clear</button>
</div>
</div>
<div class="col-xs-12 col-md-6">
<h3>DataSet Files</h3>
</div>
</fieldset>
</form>
</div>
'use strict';
/**
* Primary global application configuration file.
* This is where it is all "glued" together, more or less.
*/
var archivingPortalClient = angular.module('archivingPortalClient',
['ngRoute',
'ngAnimate',
......@@ -8,27 +12,28 @@ var archivingPortalClient = angular.module('archivingPortalClient',
'ngSanitize',
'ngResource',
'ngRoute',
'ui.bootstrap',
'archivingPortalClient.directives',
'archivingPortalClient.loginService',
'archivingPortalClient.userService',
'archivingPortalClient.nationService'
'archivingPortalClient.nationService',
'archivingPortalClient.projectService'
]);
archivingPortalClient.config(['$routeProvider','$httpProvider', function($routeProvider,$httpProvider) {
/**
* Define all routes, partials and controllers in the application.
* Every new "place" has to be added here for Angular to pick up on it.
*/
archivingPortalClient.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/', {
templateUrl: 'partials/main.html',
controller: MainController
controller: MainController,
});
$routeProvider.when('/project', {
templateUrl: 'partials/project.html',
controller: ProjectController
});
$routeProvider.when('/archive', {
templateUrl: 'partials/archive.html',
controller: ArchivingController
controller: ProjectController,
});
$routeProvider.otherwise({
......@@ -37,6 +42,10 @@ archivingPortalClient.config(['$routeProvider','$httpProvider', function($routeP
}]);
/**
* Redirect to login if 401 is returned by the service.
* A 401 means no access, and it is neccessary to re-authenticate.
*/
archivingPortalClient.factory('authHttpResponseInterceptor',['$q','$location','$log' ,function($q, $location, $log){
return {
response: function(response){
......@@ -51,13 +60,33 @@ archivingPortalClient.factory('authHttpResponseInterceptor',['$q','$location','$
$log.error("Response Error 401 @ ", rejection);
$location.path('/').search('returnTo', $location.path());
}
return $q.reject(rejection);
}
}
}]);
/**
* "hooks" into the $http service and provide extended functionality
* with responses sent from the server.
*/
archivingPortalClient.config(['$httpProvider',function($httpProvider) {
$httpProvider.interceptors.push('authHttpResponseInterceptor');
// Auth response interceptor
$httpProvider.interceptors.push('authHttpResponseInterceptor');
// General error interceptor.
$httpProvider.interceptors.push(function($q) {
return {
responseError: function(rejection) {
// Service offline
if(rejection.status == 0) {
window.location = "offline.html";
return;
}
return $q.reject(rejection);
}
};
});
}]);
archivingPortalClient.run(function ($rootScope) {
......@@ -67,9 +96,13 @@ archivingPortalClient.run(function ($rootScope) {
/**
* Intercept all requests.
* All requests will have their header modified with the Oauth2 access_token if
* one is available in the $rootScope. Note that this scope resets if you refresh.
* one is available in the $rootScope. Note that this scope resets on page refresh.
*/
archivingPortalClient.run(['$rootScope', '$injector', function($rootScope, $injector) {
archivingPortalClient.run(['$rootScope', '$injector', 'LoginService', function($rootScope, $injector, LoginService) {
LoginService.save({username: 'admin', password: 'password'}, function(data) {
$rootScope.oauth = data;
});
$injector.get("$http").defaults.transformRequest = function(data, headersGetter) {
if($rootScope.oauth) {
......
'use strict';
var ArchivingController = function($scope, $log, Nations) {
$scope.form = {};
};
......@@ -10,9 +10,8 @@ var MainController = function($scope, $log, $http, LoginService, $rootScope, Use
$scope.doLogin = function() {
LoginService.save({username: $scope.login.username, password: $scope.login.password}, function(data) {
$rootScope.oauth = data;
$scope.loggedIn = $rootScope.oauth != null;
$scope.loggedIn = $rootScope.oauth;
$scope.user = User.query();
});
};
};
......@@ -3,17 +3,33 @@
var ProjectController = function($scope, $log, $http) {
$scope.project = {};
$scope.projects = [];
$scope.create = function() {
$log.info(angular.toJson($scope.project));
$http.post($scope.portalApiUrl+'project/create', angular.toJson($scope.project))
$scope.createProject = function() {
$http.post($scope.portalApiUrl+'project/create', $scope.project)
.success(function(val) {
$log.info(val);
}).error(function () {
$scope.postError = "There are errors in your form.";
$log.error("Unable to post -> " + angular.toJson($scope.project));
});
};
};
$scope.resetProjectForm = function() {
$scope.project = {};
};
$scope.list = function() {
$http({method: 'GET', url: apiUrl+'project/list'}).
success(function (data) {
$scope.projects = data;
}).
error(function (data) {
$scope.listError = "Unable to fetch projects from server";
});
};
$scope.list();
};
'use strict';
var projectService = angular.module('archivingPortalClient.projectService', ['ngResource']);
......@@ -4,7 +4,7 @@ var userService = angular.module('archivingPortalClient.userService', ['ngResour
userService.factory('User', ['$resource',
function($resource) {
return $resource(apiUrl+'user/get', {}, {
return $resource(apiUrl+'user', {}, {
query:{
//params can go here if we got any.
}
......
$icon-font-path: "../bower_components/bootstrap/fonts/";
@import '../bower_components/bootswatch/cyborg/bootstrap.css';
\ No newline at end of file
@import '../bower_components/bootswatch/flatly/bootstrap.css';
......@@ -13,7 +13,8 @@
"angular-resource": "1.3.x",
"angular-route": "1.3.x",
"bootstrap": "3.3.x",
"bootswatch": "3.3.x"
"bootswatch": "3.3.x",
"angular-bootstrap": "0.12.x"
},
"devDependencies": {
"angular-mocks": "1.3.x"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment