You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rave.apache.org by er...@apache.org on 2013/08/14 19:39:24 UTC
svn commit: r1513971 - in
/rave/branches/angular/rave-portal-resources/src/main/webapp:
WEB-INF/jsp/views/ static/html/portal/ static/script/common/resources/
static/script/portal/ static/script/portal/controllers/
Author: erinnp
Date: Wed Aug 14 17:39:23 2013
New Revision: 1513971
URL: http://svn.apache.org/r1513971
Log:
Added routing and directory structure
Added:
rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/index_sample.html
- copied unchanged from r1513242, rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/index.html
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/index.js
- copied, changed from r1513663, rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/resources.js
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/pages_for_render_resource.js
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/controllers/
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/controllers/MainCtrl.js
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/controllers/index.js
- copied, changed from r1513663, rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/controllers.js
Removed:
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/resources.js
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/controllers.js
Modified:
rave/branches/angular/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/angular.jsp
rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/index.html
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/portal.js
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/routes.js
Modified: rave/branches/angular/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/angular.jsp
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/angular.jsp?rev=1513971&r1=1513970&r2=1513971&view=diff
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/angular.jsp (original)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/angular.jsp Wed Aug 14 17:39:23 2013
@@ -51,5 +51,7 @@
</div>
+<%--<div ng-view></div>--%>
+
</body>
</html>
\ No newline at end of file
Modified: rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/index.html
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/index.html?rev=1513971&r1=1513970&r2=1513971&view=diff
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/index.html (original)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/index.html Wed Aug 14 17:39:23 2013
@@ -1,159 +1,5 @@
-<div class="navbar">
- <div class="navbar-inner">
- <div class="container">
- <a class="brand"><span ng-show="user.username">Hello {{user.username}}. </span>Welcome to Rave!</a>
- <ul class="nav pull-right">
- <li ng-show="user.username"><a href="/portal/app/person/id/1">{{user.username}}'s Profile</a>
- </li>
- <li ng-show="user.username"><a href="/portal/app/store">Widget Store</a></li>
- <li ng-show="user.admin"><a href="/portal/app/admin">Admin Interface</a></li>
- <li ng-show="user.username"><a ng-click="logout()" href="#">Logout</a></li>
- <li ng-hide="user.username"><a ng-click="login()" href="#">Login/Register</a></li>
- </ul>
- </div>
- </div>
-</div>
-<div class="logo-wrapper"></div>
-<div id="pageContent" class="container-fluid" ng-view></div>
+Hello World.
-<div rave-register-view="dialog" dialog class="modal fade">
- <div class="modal-header">
- <a class="close" data-dismiss="modal">×</a>
- </div>
- <div class="modal-body">
- <div rave-render-widget="regionWidget"></div>
- </div>
-</div>
-
-<div rave-register-view="modal_dialog" dialog="{keyboard: false, backdrop: 'static'}" class="modal fade">
- <div class="modal-header">
- <a class="close" data-dismiss="modal">×</a>
- </div>
- <div class="modal-body">
- <div rave-render-widget="regionWidget"></div>
- </div>
-</div>
-
-<div rave-register-view="sidebar">
- <div class="modal-backdrop fade in" ng-show="isOpen"></div>
- <div class="popup slideout" ng-class="{'shown':isOpen}">
- <a class="close" ng-click="close()">×</a>
-
- <div rave-render-widget="regionWidget" class="slideout-content"></div>
- </div>
-</div>
-
-<div rave-register-view="canvas">
- <div class="modal-backdrop fade in"></div>
- <div class="widget-wrapper-canvas">
- <div class="widget-title-bar widget-title-bar-draggable">
- <div class="widget-title">
- {{regionWidget.widgetUrl}}
- </div>
- <div class="widget-toolbar ">
- <span class="widget-toolbar-btn" ng-click="minimize()">
- <i class="icon-resize-small"></i>
- </span>
- </div>
- </div>
- <div class="widget">
- <div rave-render-widget="regionWidget"></div>
- </div>
- </div>
-</div>
-
-<div class="widget-wrapper" rave-register-view="home" >
- <div class="widget-title-bar widget-title-bar-draggable" ng-controller="WidgetController">
- <div class="widget-toolbar-toggle-collapse" title="Collapse/Restore Widget">
- <i ng-class="{'icon-chevron-down':!regionWidget.collapsed, 'icon-chevron-up':regionWidget.collapsed}"
- ng-click="toggleCollapse()"></i>
- </div>
- <div class="widget-title">
- {{regionWidget.widgetUrl}}
- </div>
- <div class="widget-toolbar ">
- <div class="dropdown widget-menu-wrapper" style="">
- <a class="dropdown-toggle" data-toggle="dropdown">
- <i class="icon-cog"></i>
- </a>
- <ul class="dropdown-menu widget-menu">
- <li ng-class="{'menu-item-disabled':menu.editPrefs.disable}">
- <a ng-click="togglePrefs()">
- Edit Preferences
- </a>
- </li>
- <li>
- <a ng-click="maximize()">
- Maximize
- </a>
- </li>
- <li ng-class="{'menu-item-disabled':menu.move.disable}">
- <a ng-click="moveToPage()">
- Move to Page
- </a>
- </li>
- <li>
- <a ng-click="delete()">
- Delete Widget
- </a>
- </li>
- <li class="divider"></li>
- <li>
- <a>
- About this Widget
- </a>
- </li>
- <li>
- <a>
- Comment on this Widget
- </a>
- </li>
- <li>
- <a>
- Rate this Widget
- </a>
- </li>
- </ul>
- </div>
-<span class="widget-toolbar-btn widget-toolbar-btn-min">
-<i class="icon-resize-small"></i>
-</span>
- </div>
- </div>
-
- <div class="widget-prefs" ng-show="showPrefs">
- <form class="form-horizontal" ng-submit="savePrefs()">
- <div class="control-group" ng-repeat="pref in regionWidgetPrefs" ng-hide="pref.dataType=='HIDDEN'">
- <label class="control-label"
- for="{{regionWidget.id}}-{{pref.name}}">{{pref.displayName}}</label>
-
- <div class="controls" ng-switch="pref.dataType">
- <div ng-switch-when="STRING">
- <input type="text" id="{{regionWidget.id}}-{{pref.name}}" ng-model="pref.value">
- </div>
- <div ng-switch-when="BOOL">
- <input type="checkbox" id="{{regionWidget.id}}-{{pref.name}}" ng-model="pref.value">
- </div>
- <div ng-switch-when="ENUM">
- <select id="{{regionWidget.id}}-{{pref.name}}" ng-model="pref.value"
- ng-options="o.value as o.displayValue for o in pref.orderedEnumValues"></select>
- </div>
- <div ng-switch-when="LIST">
- <textarea type="text" id="{{regionWidget.id}}-{{pref.name}}" ng-model="pref.value">
- </textarea>
- </div>
- <div ng-switch-when="hidden">
- <input type="hidden" ng-model="pref.value">
- </div>
- </div>
- </div>
- <div class="form-actions">
- <button type="button" ng-click="togglePrefs()" class="btn">Cancel</button>
- <button type="submit" class="btn btn-primary">Save changes</button>
- </div>
- </form>
- </div>
- <div class="widget" ng-hide="regionWidget.collapsed">
- <div rave-render-widget="regionWidget"></div>
- </div>
+<div>
+ <div ng-include="/portal/static/html/portal/tabs.html"></div>
</div>
\ No newline at end of file
Copied: rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/index.js (from r1513663, rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/resources.js)
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/index.js?p2=rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/index.js&p1=rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/resources.js&r1=1513663&r2=1513971&rev=1513971&view=diff
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/resources.js (original)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/index.js Wed Aug 14 17:39:23 2013
@@ -17,24 +17,31 @@
* under the License.
*/
-define(['common/resources/category_resources', 'common/resources/page_resources', 'common/resources/person_resources', 'common/resources/region_resources', 'common/resources/region_widget_resources', 'common/resources/user_resources', 'underscore'],
- function(category, page, person, region, regionWidget, user, _) {
+define(['angular', './category_resources', './page_resources', './pages_for_render_resource',
+ './person_resources', './region_resources', './region_widget_resources', './user_resources',
+ 'underscore', 'angularResource'],
+ function (angular, category, page, pageForRender, person, region, regionWidget, user, _) {
'use strict';
- var servicesModule = angular.module('common.resources', ['ngResource'], ['$httpProvider', function($httpProvider){
- $httpProvider.defaults.transformResponse.push(function(data, headers) {
- return data.data;
+ var servicesModule = angular.module('common.resources', ['ngResource'], ['$httpProvider', function ($httpProvider) {
+ $httpProvider.defaults.transformResponse.push(function (data, headers) {
+ if(headers('CONTENT-TYPE') === 'application/json' && data.data) {
+ return data.data;
+ }
+ else {
+ return data;
+ }
});
}]);
//Array of services
- //For any common services added, they must be requried in this file and added
+ //For any common services added, they must be required in this file and added
//to the array below.
- var services = [category, page, person, region, regionWidget, user];
+ var services = [category, page, pageForRender, person, region, regionWidget, user];
//Loop through array to add services
- _.each(services, function(e, i){
+ _.each(services, function (e, i) {
//Loop through each service on the object adding it to the serviceModule
- _.each(e, function(service, name){
+ _.each(e, function (service, name) {
servicesModule.factory(name, service);
})
})
Added: rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/pages_for_render_resource.js
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/pages_for_render_resource.js?rev=1513971&view=auto
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/pages_for_render_resource.js (added)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/pages_for_render_resource.js Wed Aug 14 17:39:23 2013
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+define([], function(){
+ var pageResource = ['$resource', function($resource){
+ return $resource('/portal/api/rest/pages/render/:context/:identifier/:id');
+ }];
+
+ return {
+ PagesForRender: pageResource
+ }
+})
+
Added: rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/controllers/MainCtrl.js
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/controllers/MainCtrl.js?rev=1513971&view=auto
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/controllers/MainCtrl.js (added)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/controllers/MainCtrl.js Wed Aug 14 17:39:23 2013
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+define([], function () {
+ return ['$route', '$scope', function ($route, $scope) {
+ $scope.pages = [];
+ console.log('holler!');
+ }]
+});
\ No newline at end of file
Copied: rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/controllers/index.js (from r1513663, rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/controllers.js)
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/controllers/index.js?p2=rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/controllers/index.js&p1=rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/controllers.js&r1=1513663&r2=1513971&rev=1513971&view=diff
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/controllers.js (original)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/controllers/index.js Wed Aug 14 17:39:23 2013
@@ -17,8 +17,10 @@
* under the License.
*/
-define(['angular'], function (angular) {
+define(['angular', './MainCtrl'], function (angular, MainCtrl) {
var controllers = angular.module('portal.controllers', []);
+ controllers.controller('MainCtrl', MainCtrl);
+
return controllers;
});
\ No newline at end of file
Modified: rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/portal.js
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/portal.js?rev=1513971&r1=1513970&r2=1513971&view=diff
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/portal.js (original)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/portal.js Wed Aug 14 17:39:23 2013
@@ -17,6 +17,6 @@
* under the License.
*/
-define(['angular', './routes', './controllers'], function (angular) {
+define(['angular', './routes', './controllers/index'], function (angular) {
return angular.module('portal', ['portal.routes', 'portal.controllers']);
});
\ No newline at end of file
Modified: rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/routes.js
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/routes.js?rev=1513971&r1=1513970&r2=1513971&view=diff
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/routes.js (original)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/routes.js Wed Aug 14 17:39:23 2013
@@ -17,38 +17,56 @@
* under the License.
*/
-define(['angular'], function () {
- var router = angular.module('portal.routes', []);
+define(['angular', '../common/resources/index'], function (angular) {
+ var router = angular.module('portal.routes', ['common.resources']);
router.config(['$routeProvider', '$locationProvider', '$httpProvider',
function ($routeProvider, $locationProvider, $httpProvider) {
+ var getPages = ['PagesForRender', '$q', '$rootScope', function (PagesForRender, $q, $rootScope) {
+ var deferred = $q.defer();
+
+ if($rootScope.pages) {
+ deferred.resolve($rootScope.pages);
+ } else {
+ PagesForRender.query({
+ context: 'portal',
+ identifier: '@self'
+ }, function(data){
+ deferred.resolve(data);
+ });
+ }
+
+ return deferred.promise;
+ }]
+
$routeProvider
.when('/', {
- controller: 'TabsController',
+ controller: 'MainCtrl',
resolve: {
- pages: ['PagesService', function (PagesService) {
- return PagesService.get('portal', '@self');
- }]
+ pages: getPages
},
templateUrl: "/portal/static/html/portal/tabs.html"
})
.when('/:tabId', {
controller: 'TabsController',
resolve: {
- pages: ['PagesService', function (PagesService) {
- return PagesService.get('portal', '@self');
- }]
+ pages: getPages
},
templateUrl: "/portal/static/html/portal/tabs.html"
})
.otherwise({ templateUrl: '/portal/static/html/portal/404.html'});
$locationProvider.html5Mode(true);
-
-
}
]);
+ router.run(['$route', '$rootScope', function($route, $rootScope) {
+ $rootScope.$on('$routeChangeSuccess', function(evt, curr, prev){
+ $rootScope.pages = curr.locals.pages;
+ $rootScope.currentPageId = curr.params.tabId || $rootScope.pages[0].id;
+ });
+ }]);
+
return router;
});
\ No newline at end of file