Subscriber portal dev environment ready
diff --git a/views/ngXosViews/subscriberPortal/src/app/view/user/ratingPanel.html b/views/ngXosViews/subscriberPortal/src/app/view/user/ratingPanel.html
new file mode 100644
index 0000000..04ee430
--- /dev/null
+++ b/views/ngXosViews/subscriberPortal/src/app/view/user/ratingPanel.html
@@ -0,0 +1,22 @@
+<!--Partial HTML for rating panel directive-->
+<div id="rating-panel">
+ <div ng-cloak class="ng-hide ng-cloak panel" ng-show="ratingsShown">
+ <table>
+ <tr>
+ <th class="title">Category</th>
+ <th ng-repeat="rating in level_order">{{rating}}</th>
+ </tr>
+ <tr ng-repeat="cat in category_order">
+ <td class="title">{{cat}}</td>
+ <td ng-repeat="r in level_order">
+ <div ng-if="prohibitedSites[r][cat]">
+ <icon size="15" id="xMark"></icon>
+ </div>
+ <div ng-if="!prohibitedSites[r][cat]">
+ <icon size="15" id="checkMark"></icon>
+ </div>
+ </td>
+ </tr>
+ </table>
+ </div>
+</div>
\ No newline at end of file
diff --git a/views/ngXosViews/subscriberPortal/src/app/view/user/user.css b/views/ngXosViews/subscriberPortal/src/app/view/user/user.css
new file mode 100644
index 0000000..8539238
--- /dev/null
+++ b/views/ngXosViews/subscriberPortal/src/app/view/user/user.css
@@ -0,0 +1,180 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed 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.
+ */
+
+#user div {
+ padding-top: 2%;
+}
+
+#user div.main-left {
+ width: 98%;
+ padding-left: 1%;
+}
+#user div.main-left.family {
+ width: 62%;
+ padding-left: 1%;
+}
+
+#user div.main-right {
+ width: 0;
+}
+#user div.main-right.family {
+ width: 37%;
+}
+
+#user table.user-info,
+#user table.user-form {
+ float: left;
+ width: 100%;
+}
+
+#user table.user-info th,
+#user table.user-form th {
+ text-align: left;
+ padding: 2% 1%;
+}
+
+#user span.help:hover {
+ cursor: pointer;
+ color: #CE5650;
+}
+
+#user div.main-left.family table.user-info th,
+#user div.main-right.family table.user-form th {
+ padding: 17px;
+}
+
+#user div.main-left.family table.user-info td,
+#user div.main-right.family table.user-form td {
+ padding: 10px;
+ height: 23px;
+}
+#user table.user-info td {
+ padding: 1%;
+}
+
+#user table.user-form td {
+ border-left: 1px solid #CE5650;
+}
+
+#user table.user-form td.buttons {
+ text-align: right;
+ border: none;
+}
+
+#user table.user-form tr.options td {
+ padding-left: 5%;
+}
+
+#user select,
+#user select:focus {
+ border: none;
+}
+
+#user select {
+ font-size: 95%;
+}
+
+#user option,
+#user option:focus {
+ border: none;
+}
+
+#user option[selected] {
+ background-color: rgb(122, 188, 229);
+}
+
+#user label {
+ font-weight: bold;
+ display: block;
+ text-align: center;
+ padding: 5%;
+}
+
+#user input[type="button"],
+#user input[type="reset"] {
+ width: 30%;
+}
+
+#user td.buttons div {
+ display: inline;
+}
+#user td.buttons svg {
+ vertical-align: middle;
+}
+
+#rating-panel th,
+#rating-panel td {
+ text-align: center;
+ padding: 1%;
+ font-weight: lighter;
+}
+
+#rating-panel th.title,
+#rating-panel td.title {
+ width: 125px;
+ text-align: left;
+}
+
+#rating-panel th {
+ background-color: white;
+ padding-top: 3%;
+ border-bottom: 1px solid #CE5650;
+ color: #3C3C3C;
+ font-weight: normal;
+}
+
+#rating-panel tr th:first-child,
+#rating-panel tr td:first-child {
+ padding-left: 5%;
+}
+#rating-panel tr th:last-child,
+#rating-panel tr td:last-child {
+ padding-right: 5%;
+}
+
+div#rating-panel {
+ position: relative;
+ pointer-events: none;
+}
+
+#rating-panel div.ng-hide-add.ng-hide-add-active,
+#rating-panel div.ng-hide-remove.ng-hide-remove-active {
+ -webkit-transition: all linear 0.75s;
+ transition: all linear 0.75s;
+}
+
+#rating-panel div.panel {
+ position: absolute;
+ top: 0;
+ left: -6%;
+ height: 545px;
+ overflow: auto;
+ padding: 0;
+ pointer-events: auto;
+ box-shadow: 0 3px 23px 7px rgb(118, 118, 118);
+ border-radius: 3px;
+}
+#rating-panel table {
+ table-layout: fixed;
+ width: 500px;
+ background-color: white;
+ opacity: 1;
+}
+
+#rating-panel div.ng-hide {
+ opacity: 0;
+ left: -55%;
+}
diff --git a/views/ngXosViews/subscriberPortal/src/app/view/user/user.html b/views/ngXosViews/subscriberPortal/src/app/view/user/user.html
new file mode 100644
index 0000000..d8a0620
--- /dev/null
+++ b/views/ngXosViews/subscriberPortal/src/app/view/user/user.html
@@ -0,0 +1,60 @@
+<!-- Users page partial html -->
+<div class="container">
+ <div id="user">
+ <div class="main-left" ng-class="{family: isFamily}">
+ <table class="user-info">
+ <tr>
+ <th class="user-pic"></th>
+ <th>Name</th>
+ <th>Last Login</th>
+ </tr>
+ <tr ng-repeat="user in users" class="fadein">
+ <td class="user-pic">
+ <img ng-src="{{'/imgs/' + user.icon_id + '.jpg'}}">
+ </td>
+ <td>{{user.name}}</td>
+ <td>{{shared.userActivity[user.id]}}</td>
+ </tr>
+ </table>
+ </div>
+
+ <div class="main-right" ng-class="{family: isFamily}">
+ <form ng-if="isFamily"
+ name="changeLevels">
+ <table class="user-form">
+ <tr>
+ <th>
+ Select Site Rating
+ <span class="help"
+ ng-click="showRatings()"> (?)</span>
+ </th>
+ </tr>
+ <tr ng-repeat="user in users" class="options">
+ <td>
+ <select ng-init="newLevels[user.id]=user.profile.url_filter.level"
+ ng-model="newLevels[user.id]"
+ ng-options="l for l in levels">
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td class="buttons">
+ <div ng-show="showCheck">
+ <icon size="20px" id="checkMark"></icon>
+ </div>
+ <input type="reset" value="Cancel"
+ ng-click="cancelChanges(changeLevels)"
+ ng-disabled="changeLevels.$pristine">
+ <input type="button" value="Apply"
+ ng-click="applyChanges(changeLevels)"
+ ng-disabled="changeLevels.$pristine">
+ </td>
+ </tr>
+ </table>
+ </form>
+ </div>
+ <div ng-if="isFamily">
+ <ratings-panel></ratings-panel>
+ </div>
+ </div>
+</div>
\ No newline at end of file
diff --git a/views/ngXosViews/subscriberPortal/src/app/view/user/user.js b/views/ngXosViews/subscriberPortal/src/app/view/user/user.js
new file mode 100644
index 0000000..bb44fec
--- /dev/null
+++ b/views/ngXosViews/subscriberPortal/src/app/view/user/user.js
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed 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.
+ */
+
+(function () {
+ 'use strict';
+
+ var bundleUrlSuffix = '/rs/bundle',
+ userUrlSuffix = '/rs/users',
+ family = 'family',
+ url_filter = 'url_filter';
+
+ angular.module('cordUser', [])
+ .controller('CordUserCtrl', ['$log', '$scope', '$resource', '$timeout',
+ function ($log, $scope, $resource, $timeout) {
+ var BundleData, bundleResource;
+ $scope.page.curr = 'user';
+ $scope.isFamily = false;
+ $scope.newLevels = {};
+ $scope.showCheck = false;
+ $scope.ratingsShown = false;
+
+ // === Get data functions ---
+
+ BundleData = $resource($scope.shared.url + bundleUrlSuffix);
+ bundleResource = BundleData.get({},
+ // success
+ function () {
+ var result;
+ $scope.isFamily = (bundleResource.bundle.id === family);
+ if ($scope.isFamily) {
+ result = $.grep(
+ bundleResource.bundle.functions,
+ function (elem) {
+ if (elem.id === url_filter) { return true; }
+ }
+ );
+ $scope.levels = result[0].params.levels;
+ }
+ },
+ // error
+ function () {
+ $log.error('Problem with resource', bundleResource);
+ }
+ );
+
+ function getUsers(url) {
+ var UserData, userResource;
+ UserData = $resource(url);
+ userResource = UserData.get({},
+ // success
+ function () {
+ $scope.users = userResource.users;
+ },
+ // error
+ function () {
+ $log.error('Problem with resource', userResource);
+ }
+ );
+ }
+
+ getUsers($scope.shared.url + userUrlSuffix);
+
+ // === Form functions ---
+
+ function levelUrl(id, level) {
+ return $scope.shared.url +
+ userUrlSuffix + '/' + id + '/apply/url_filter/level/' + level;
+ }
+
+ $scope.applyChanges = function (changeLevels) {
+ var requests = [];
+
+ if ($scope.users) {
+ $.each($scope.users, function (index, user) {
+ var id = user.id,
+ level = user.profile.url_filter.level;
+ if ($scope.newLevels[id] !== level) {
+ requests.push(levelUrl(id, $scope.newLevels[id]));
+ }
+ });
+
+ $.each(requests, function (index, req) {
+ getUsers(req);
+ });
+ }
+ changeLevels.$setPristine();
+ $scope.showCheck = true;
+ $timeout(function () {
+ $scope.showCheck = false;
+ }, 3000);
+ };
+
+ $scope.cancelChanges = function (changeLevels) {
+ if ($scope.users) {
+ $.each($scope.users, function (index, user) {
+ $scope.newLevels[user.id] = user.profile.url_filter.level;
+ });
+ }
+ changeLevels.$setPristine();
+ $scope.showCheck = false;
+ };
+
+ $scope.showRatings = function () {
+ $scope.ratingsShown = !$scope.ratingsShown;
+ };
+
+ $log.debug('Cord User Ctrl has been created.');
+ }])
+
+ .directive('ratingsPanel', ['$log', function ($log) {
+ return {
+ templateUrl: 'app/view/user/ratingPanel.html',
+ link: function (scope, elem, attrs) {
+ function fillSubMap(order, bool) {
+ var result = {};
+ $.each(order, function (index, cat) {
+ result[cat] = bool;
+ });
+ return result;
+ }
+ function processSubMap(prhbSites) {
+ var result = {};
+ $.each(prhbSites, function (index, cat) {
+ result[cat] = true;
+ });
+ return result;
+ }
+
+ function preprocess(data, order) {
+ return {
+ ALL: fillSubMap(order, false),
+ G: processSubMap(data.G),
+ PG: processSubMap(data.PG),
+ PG_13: processSubMap(data.PG_13),
+ R: processSubMap(data.R),
+ NONE: fillSubMap(order, true)
+ };
+ }
+
+ $.getJSON('/app/data/pc_cats.json', function (data) {
+ scope.level_order = data.level_order;
+ scope.category_order = data.category_order;
+ scope.prohibitedSites = preprocess(
+ data.prohibited, data.category_order
+ );
+ scope.$apply();
+ });
+ }
+ };
+ }]);
+
+}());