Started adding some oauth2 stuff and a simple form to post projects to the server

parent 22d135fe
......@@ -31,6 +31,22 @@ Then issue the following command (still in the project root)
> gulp serve
Use curl to get a token:
> curl -X POST -vu html5-archivingportal:123456 http://localhost:8080/oauth/token -H "Accept: application/json" -d "password=password&username=admin&grant_type=password&scope=write&client_secret=123456&client_id=html5-archivingportal"
{
"access_token" : "36028ad3-9237-450a-8d4f-7e394408211b",
"token_type" : "bearer",
"refresh_token" : "e928973d-a77a-4a12-9c38-779056719222",
"expires_in" : 43199,
"scope" : "write"
* Connection #0 to host localhost left intact
}
For now we have to cheat some. "access_token" can be copy pasted into archivingPortalClient.js.
Replace ACCESS_TOKEN.
> Line 42: headersGetter()['Authorization'] = "Bearer ACCESS_TOKEN";
Packing the application
-----------------------
To package the application for release, simply (again in the project root), issue
......
<!doctype html>
<html class="no-js" ng-app="archivingPortalClient">
<head>
<meta charset="utf-8">
<title>Archiving Portal<</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<meta charset="utf-8">
<title>Archiving Portal<</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<base href="/">
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<!-- build:css({.tmp,app}) styles/main.css -->
<link rel="stylesheet" href="styles/main.css">
<!-- endbuild -->
<!-- build:css({.tmp,app}) styles/main.css -->
<link rel="stylesheet" href="styles/main.css">
<!-- endbuild -->
<!-- build:js scripts/modernizr.js -->
<script src="bower_components/modernizr/modernizr.js"></script>
<!-- endbuild -->
<!-- build:js scripts/modernizr.js -->
<script src="bower_components/modernizr/modernizr.js"></script>
<!-- endbuild -->
</head>
<body>
<div class="container">
<nav class="navbar navbar-static-top navbar-inverse">
<div class="navbar-header">
<a class="navbar-brand" href="#">Archiving Portal</a>
</div>
<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">
<ul class="nav navbar-nav">
<li class="active"><a ng-href="#">Home</a></li>
<li><a ng-href="#/archive">Send Schema</a></li>
</ul>
</div>
</nav>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-6">
<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="#/project">Project</a></li>
</ul>
</div>
</nav>
<div ng-view></div>
<div ng-view></div>
<hr/>
<div class="footer">
<p>Archiving Portal | NSD © 2014</p>
</div>
<hr/>
<div class="footer">
<p>Archiving Portal | NSD © 2014</p>
</div>
</div>
......@@ -62,6 +64,7 @@
<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 -->
<!-- endbuild -->
......
<div class="container">
{{nations}}
<div class="alert alert-info">
Username: user<br/>
Password: password
</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>
<!-- 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>
<!-- 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>
</fieldset>
</form>
'use strict';
var archivingPortalClient = angular.module('archivingPortalClient',
['ngRoute',
'ngAnimate',
'ngCookies',
'ngTouch',
'ngSanitize',
'ngResource',
'ngRoute',
'archivingPortalClient.directives',
'archivingPortalClient.nationServices'
]);
['ngRoute',
'ngAnimate',
'ngCookies',
'ngTouch',
'ngSanitize',
'ngResource',
'ngRoute',
'archivingPortalClient.directives',
'archivingPortalClient.nationServices'
]);
archivingPortalClient.config(['$routeProvider', function ($routeProvider) {
$routeProvider.when('/', {
templateUrl: 'partials/main.html',
controller: MainController
});
$routeProvider.when('/', {
templateUrl: 'partials/main.html',
controller: MainController
});
$routeProvider.when('/project', {
templateUrl: 'partials/project.html',
controller: ProjectController
});
$routeProvider.when('/archive', {
templateUrl: 'partials/archive.html',
controller: ArchivingController
});
$routeProvider.otherwise({
redirectTo: '404.html'
});
$routeProvider.otherwise({
redirectTo: '404.html'
});
}]);
archivingPortalClient.run(['$rootScope', '$injector', function($rootScope, $injector) {
$injector.get("$http").defaults.transformRequest = function(data, headersGetter) {
headersGetter()['Authorization'] = "Bearer ACCESS_TOKEN";
if (data) {
return angular.toJson(data);
}
};
}]);
archivingPortalClient.run(function ($rootScope) {
$rootScope.portalApiUrl = "http://localhost:8080/";
});
/**
* Html5 mode:
*
* To avoid ugly links
* https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-configure-your-server-to-work-with-html5mode
*
* archivingPortalClient.config(['$routeProvider', function ($routeProvider, $locationProvider) {...
* $locationProvider.html5Mode(true);
*/
'use strict';
var MainController = function($scope, $log, Nations) {
var MainController = function() {
$scope.nations = Nations.query();
$log.info($scope.nations);
};
'use strict';
var ProjectController = function($scope, $log, $http) {
$scope.project = {};
$scope.dataSet = {};
$scope.dataSetFile = {};
$scope.create = function() {
$http.post($scope.portalApiUrl+'project/create', angular.toJson($scope.project))
.success(function() {
}).error(function () {
$log.error("Unable to post -> " + angular.toJson($scope.project));
});
}
};
......@@ -18,4 +18,4 @@ appDirectives.directive('formatDate', function() {
});
}
}
});
\ No newline at end of file
});
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