diff options
Diffstat (limited to 'plugins/org.eclipse.osee.web.ui')
6 files changed, 232 insertions, 10 deletions
diff --git a/plugins/org.eclipse.osee.web.ui/src/dispo/js/userController.js b/plugins/org.eclipse.osee.web.ui/src/dispo/js/userController.js index 00037c80f3f..9ee3d7c5302 100644 --- a/plugins/org.eclipse.osee.web.ui/src/dispo/js/userController.js +++ b/plugins/org.eclipse.osee.web.ui/src/dispo/js/userController.js @@ -38,7 +38,7 @@ app.controller('userController', [ }; // if this is a search result view, populate program, set and items from parent scope - if(window.opener != null) { + if(window.opener != null && window.opener.$windowScope != undefined) { $scope.programs = window.opener.$windowScope.programs; $scope.sets = window.opener.$windowScope.sets; $scope.programSelection = window.opener.$windowScope.programSelection; diff --git a/plugins/org.eclipse.osee.web.ui/src/libs/js/oseeAuth/oseeAuth.js b/plugins/org.eclipse.osee.web.ui/src/libs/js/oseeAuth/oseeAuth.js index 11d17e4ade6..d610d5b77e4 100644 --- a/plugins/org.eclipse.osee.web.ui/src/libs/js/oseeAuth/oseeAuth.js +++ b/plugins/org.eclipse.osee.web.ui/src/libs/js/oseeAuth/oseeAuth.js @@ -17,8 +17,7 @@ directives.directive('osee', [ 'Endpoint', '$localStorage', '$sessionStorage', - '$cookieStore', - function($rootScope, $compile, $http, $location, $templateCache, AccessToken, Profile, Endpoint, $localStorage, $sessionStorage, $cookieStore) { + function($rootScope, $compile, $http, $location, $templateCache, AccessToken, Profile, Endpoint, $localStorage, $sessionStorage) { var definition = { restrict : 'E', replace : true, @@ -145,8 +144,9 @@ directives.directive('osee', [ scope.$on("oauth:authorized", function(event, token) { Profile.find(scope.profileUri).success(function(response) { + $localStorage.uuid = response.accountId; + $localStorage.guid = response.guid; scope.profile = response; - $cookieStore.put("name", scope.profile.name); }); if($localStorage.continueTo) { // Change the state to the continueTo we caught when User first tried to get into page @@ -155,14 +155,14 @@ directives.directive('osee', [ } }) scope.$on("oauth:logout", function() { + $localStorage.uuid = 1896; scope.profile = scope.anonymousUser; - $cookieStore.put("name", scope.profile.name); AccessToken.destroy(); $location.path("/"); }) scope.$on("oauth:denied", function(event, token) { + $localStorage.uuid = 1896; scope.profile = scope.anonymousUser; - $cookieStore.put("name", scope.profile.name); AccessToken.destroy(); }); diff --git a/plugins/org.eclipse.osee.web.ui/src/osee/js/meController.js b/plugins/org.eclipse.osee.web.ui/src/osee/js/meController.js new file mode 100644 index 00000000000..10507f6061a --- /dev/null +++ b/plugins/org.eclipse.osee.web.ui/src/osee/js/meController.js @@ -0,0 +1,154 @@ +app.controller('meController', [ + '$scope', + '$localStorage', + '$modal', + 'Preferences', + 'uiGridConstants', + function($scope, $localStorage, $modal, Preferences, uiGridConstants) { + $scope.editLinks = false; + + $scope.editItem = function(item, key) { + if(item.url.match(/http.*/) == null) { + item.url = "http://" + item.url; + } + Preferences.update({ + id: $localStorage.guid, + key: key, + itemId: item.id, + }, item, function() { + }, function(data) { + alert("Could not make change, please try refreshing"); + }); + } + + + $scope.deleteLink = function(item) { + var newLink = {}; + var key = "links"; + Preferences.update({ + id: $localStorage.guid, + key: key, + itemId: item.id, + }, newLink, function() { + $scope.getPreferences(); + }, function(data) { + alert("Could not make change, please try refreshing"); + }); + } + + var clickCellTmpl = '<a href="{{ COL_FIELD }}" target="_blank">{{ COL_FIELD }}</a>' + var dellCellTmpl = '<button width="35px" class="btn btn-default btn-sm setDelete" ng-show="!readOnly" ng-click="grid.appScope.deleteLink(row.entity)">X</button>'; + + $scope.defaultGridOptions = { + data: 'defaultLinks', + columnDefs: [ + {field: 'name', displayName: 'Name'}, + {field: 'url', displayName: 'URL', cellTemplate: clickCellTmpl} + ], + onRegisterApi: function( gridApi ) { + $scope.gridApi = gridApi; + gridApi.edit.on.afterCellEdit($scope,function(rowEntity, colDef, newValue, oldValue){ + this.grid.appScope.editItem(null); + }); + } + + }; + + $scope.personalColumns = [ + {field: 'name', displayName: 'Name', cellEditableCondition: function( $scope ) { + return $scope.$parent.$parent.grid.appScope.editLinks; }}, + {field: 'url', displayName: 'URL', cellTemplate: clickCellTmpl, cellEditableCondition: function( $scope ) { + return $scope.$parent.$parent.grid.appScope.editLinks; }}, + {field: 'delete', width: 35, displayName: 'X', enableCellEdit: false, cellTemplate: dellCellTmpl, enableColumnMenu: false, visible: false} + ]; + + $scope.personalGridOptions = { + data: 'personalLinks', + columnDefs: $scope.personalColumns, + onRegisterApi: function( gridApi ) { + $scope.gridApi = gridApi; + gridApi.edit.on.afterCellEdit($scope,function(rowEntity, colDef, newValue, oldValue){ + if(newValue != oldValue) { + this.grid.appScope.editItem(rowEntity, 'links'); + } + }); + } + + }; + + $scope.toggleEditLinks = function() { + $scope.editLinks = !$scope.editLinks; + $scope.personalColumns[2].visible = !($scope.personalColumns[2].visible || $scope.personalColumns[2].visible === undefined); + $scope.gridApi.core.notifyDataChange(uiGridConstants.dataChange.COLUMN); + } + + $scope.getDefaultPreferences = function() { + Preferences.get({ + id: 'AAABDi35uzwAxJLISLBZdA' + }, function(data) { + $scope.defaultLinks = Object.keys(data.links).map(function (key) {return data.links[key]}); + }); + } + $scope.getDefaultPreferences(); + + $scope.getPreferences = function() { + Preferences.get({ + id: $localStorage.guid + }, function(data) { + $scope.personalLinks = Object.keys(data.links).map(function (key) {return data.links[key]}); + }); + } + $scope.getPreferences(); + + $scope.createNewLink = function(name, url) { + var newLink = {}; + newLink.name = name; + if(url.match(/http.*/) == null) { + url = "http://" + url; + } + newLink.url = url; + var key = "links"; + + Preferences.update({ + id: $localStorage.guid, + key: key, + itemId: null, + }, newLink, function() { + $scope.getPreferences(); + }, function(data) { + alert("Could not make change, please try refreshing"); + }); + } + + + // Create Set Modal + $scope.showCreateLinkModal = function() { + var modalInstance = $modal.open({ + templateUrl: 'popup.html', + controller: CreateSetModalCtrl, + size: 'sm', + windowClass: 'createSetModal' + }); + + modalInstance.result.then(function(inputs) { + $scope.createNewLink(inputs.name, inputs.url); + }); + } + + var CreateSetModalCtrl = function($scope, $modalInstance) { + $scope.linkName = ""; + $scope.linkUrl = ""; + + $scope.ok = function() { + var inputs = {}; + inputs.name = this.linkName; + inputs.url = this.linkUrl; + $modalInstance.close(inputs); + }; + + $scope.cancel = function() { + $modalInstance.dismiss('cancel'); + }; + }; + + }]);
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.web.ui/src/osee/js/oseeApp.js b/plugins/org.eclipse.osee.web.ui/src/osee/js/oseeApp.js index f372f43d849..15329f665ce 100644 --- a/plugins/org.eclipse.osee.web.ui/src/osee/js/oseeApp.js +++ b/plugins/org.eclipse.osee.web.ui/src/osee/js/oseeApp.js @@ -1,6 +1,6 @@ -var app = angular.module('oseeApp', ['oauth', 'oseeProvider', 'ngRoute', 'aLinkRewrite']); +var app = angular.module('oseeApp', ['oauth', 'ngResource', 'ui.bootstrap', 'oseeProvider', 'ngRoute', 'aLinkRewrite', 'ui.grid', 'ui.grid.edit']); -+app.config(['$routeProvider', +app.config(['$routeProvider', function($routeProvider) { $routeProvider.when('/', { @@ -15,6 +15,9 @@ var app = angular.module('oseeApp', ['oauth', 'oseeProvider', 'ngRoute', 'aLinkR }).when('/contactUs', { templateUrl: '../views/contactUs.html', controller: 'indexController' + }).when('/me', { + templateUrl: '../views/me.html', + controller: 'meController' }).when('/redirect', { templateUrl: '../views/home.html', controller: 'indexController' @@ -23,4 +26,20 @@ var app = angular.module('oseeApp', ['oauth', 'oseeProvider', 'ngRoute', 'aLinkR redirectTo: "/" }); } - ]);
\ No newline at end of file + ]); + +app.provider('Preferences', function() { + this.$get = ['$resource', + function($resource) { + var Preferences = $resource('/accounts/preferences/:id', {}, { + update: { + method: 'PUT', + headers: { + "Accept": "application/json" + } + } + }); + return Preferences; + } + ]; +});
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.web.ui/src/osee/ui/index.html b/plugins/org.eclipse.osee.web.ui/src/osee/ui/index.html index 6a5bf7e8dcf..5123e811271 100644 --- a/plugins/org.eclipse.osee.web.ui/src/osee/ui/index.html +++ b/plugins/org.eclipse.osee.web.ui/src/osee/ui/index.html @@ -10,6 +10,8 @@ </meta> <link rel="stylesheet" href="/ajax/libs/bootstrap/3.3.2/css/bootstrap.min.css"> </link> + <link rel="stylesheet" href="/ajax/libs/ui-grid/3.0.1/ui-grid.css"> + </link> <script src="/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script src="/ajax/libs/angularjs/1.3.11/angular.js"></script> <script src="/ajax/libs/angularjs/1.3.11/angular-route.min.js"></script> @@ -20,7 +22,9 @@ <script src="/ajax/libs/oauth-ng/0.3.8/oauth-ng.js"></script> <script src="/libs/js/oseeAuth/oseeAuth.js"></script> <script src="/libs/js/support/linkRewrite.js"></script> + <script src="/ajax/libs/ui-grid/3.0.1/ui-grid.js"></script> <script src="../js/oseeApp.js"></script> + <script src="../js/meController.js"></script> <link rel="icon" type="image/x-icon" href="images/osee.ico" /> <link rel="shortcut icon" type="image/x-icon" href="/libs/images/osee.ico" /> <title>OSEE</title> @@ -38,7 +42,7 @@ app.controller("indexController", [ "$scope", '$location', '$window', function($scope, $location, $window) { - $scope.links = [ { ref: '', name: 'Home'}, { ref: 'about', name: 'About'}, { ref: 'wiki', name: 'Wiki'}, { ref: 'contactUs', name: 'Contact Us'}]; + $scope.links = [ { ref: '', name: 'Home'}, { ref: 'me', name: 'Me'},{ ref: 'about', name: 'About'}, { ref: 'wiki', name: 'Wiki'}, { ref: 'contactUs', name: 'Contact Us'}]; }]); </script> </html>
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.web.ui/src/osee/views/me.html b/plugins/org.eclipse.osee.web.ui/src/osee/views/me.html new file mode 100644 index 00000000000..1efa6bb530c --- /dev/null +++ b/plugins/org.eclipse.osee.web.ui/src/osee/views/me.html @@ -0,0 +1,45 @@ + <div class="container-fluid" id="content"> + <div class="row"> + <div class="col-md-7"> + <div class="row"> + <div class="col-md-5"> + <h5>DEFAULT</h5> + </div> + </div> + <div class="gridStyle" ui-grid="defaultGridOptions" ui-grid-edit class="grid"></div> + <div class="row" id="personalDiv"> + <div class="col-md-1"> + <h5>PERSONAL</h5> + </div> + <div class="col-md-2 col-md-offset-8"> + <button ng-click="showCreateLinkModal()" ng-show="editLinks" ng-class="{'btn active btn-primary': true}">NEW</button> + </div> + <div class="col-md-1 col-md-offset-0"> + <button ng-click="toggleEditLinks()" ng-class="{'btn pull-right active': true, 'btn-primary': !editLinks, 'btn-info': editLinks}">EDIT</button> + </div> + </div> + <div class="gridStyle" external-scopes="externalScope" ui-grid="personalGridOptions" ui-grid-edit class="grid"></div> + </div> + </div> +</div> + +<!-- definitions for modal forms --> +<script type="text/ng-template" id="popup.html"> + <div class="modal-header"> + <h3 class="modal-title">Create Link</h3> + </div> + <div class="modal-body" style="height: 300px; overflow: auto;"> + <div class="form-group"> + <label for="linkNameInput">Set Name</label> + <input ng-model="linkName" class="form-control" name="linkName" placeholder="Enter Link Name" required> + </div> + <div class="form-group"> + <label for="setLinkUrl">Path</label> + <input ng-model="linkUrl" class="form-control" name="linkUrl" placeholder="Enter Link URL" required> + </div> + <div class="modal-footer"> + <button class="btn btn-primary" ng-click="ok()">OK</button> + <button class="btn btn-warning" ng-click="cancel()">Cancel</button> + </div> + + </script>
\ No newline at end of file |