browser staff : new stored settings admin page
authorBill Erickson <berick@esilibrary.com>
Thu, 24 Apr 2014 15:10:25 +0000 (11:10 -0400)
committerBill Erickson <berick@esilibrary.com>
Thu, 24 Apr 2014 15:10:28 +0000 (11:10 -0400)
Page lets staff view and delete stored preferences.

TODO: permission

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/staff/admin/workstation/index.tt2
Open-ILS/src/templates/staff/admin/workstation/t_splash.tt2
Open-ILS/src/templates/staff/admin/workstation/t_stored_prefs.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/css/style.css.tt2
Open-ILS/web/js/ui/default/staff/admin/workstation/app.js
Open-ILS/web/js/ui/default/staff/services/printstore.js

index d20444f..a33adde 100644 (file)
@@ -8,6 +8,13 @@
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/services/grid.js"></script>
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/services/ui.js"></script>
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/admin/workstation/app.js"></script>
+<script>
+angular.module('egCoreMod')
+.factory('egAppStrings', function() {return {
+PREFS_REMOVE_KEY_CONFIRM : 
+  '[% l('Delete content for key "[_1]"?', '{{deleteKey}}') %]'
+}});
+</script>
 [% END %]
 
 <div ng-view></div>
index ceb3cab..0f91ec4 100644 (file)
         </div>
         <div class="panel-body">
           <div>
+            <span class="glyphicon glyphicon-info-sigh"></span>
+            <a target="_self" href="./admin/workstation/stored_prefs">
+              [% l('Stored Preferences') %]
+            </a>
           </div>
         </div>
       </div>
diff --git a/Open-ILS/src/templates/staff/admin/workstation/t_stored_prefs.tt2 b/Open-ILS/src/templates/staff/admin/workstation/t_stored_prefs.tt2
new file mode 100644 (file)
index 0000000..48ceea5
--- /dev/null
@@ -0,0 +1,39 @@
+<style>
+  /* TODO */
+  #stored-prefs-container .selected {
+    background-color: #F5F5F5;   
+  }
+  #stored-prefs-container .row {
+    padding-top: 10px;
+  }
+</style>
+<div class="container" id="stored-prefs-container">
+  <div class="row">
+
+    <!-- key list -->
+    <div class="col-md-4">
+      <div class="row" ng-repeat="key in keys">
+        <div class="col-md-1">{{$index + 1}}.</div>
+        <div class="col-md-8 stored-prefs-key" 
+          ng-class="{selected : currentKey == key}">
+          <a href='' ng-click="selectKey(key)">{{key}}</a>
+        </div>
+        <div class="col-md-1">
+          <!-- padding to give the buttom some overflow space -->
+        </div>
+        <div class="col-md-1" class="stored-prefs-remove-button">
+          <button class="btn btn-default btn-danger"
+            ng-click="removeKey(key)" title="[% l('Remove Item') %]">
+            <span class="glyphicon glyphicon-remove"></span>
+          </button>
+        </div>
+      </div><!-- row -->
+    </div><!-- col -->
+
+    <!-- content -->
+    <div class="col-md-8">
+      <pre>{{getCurrentKeyContent()}}</pre>
+    </div>
+
+  </div><!-- row -->
+</div><!-- container -->
index 9f55306..e9ebdf2 100644 (file)
@@ -59,6 +59,7 @@
  * version 0.6.0 look right with Bootstrap CSS 3.0
  */
 .nav, .pagination, .carousel a { cursor: pointer; }
+/*
 .modal {
     display: block;
     height: 0;
@@ -74,6 +75,7 @@
     display: table;
     content: " ";
 }
+*/
 
 /* --------------------------------------------------------------------------
 /* Form Validation CSS - http://docs.angularjs.org/guide/forms
index d2872be..265823a 100644 (file)
@@ -4,7 +4,8 @@
  * Splash Page
  */
 
-angular.module('egWorkstationAdmin', ['ngRoute', 'ui.bootstrap', 'egCoreMod', 'egUiMod'])
+angular.module('egWorkstationAdmin', 
+    ['ngRoute', 'ui.bootstrap', 'egCoreMod', 'egUiMod'])
 
 .config(['$routeProvider','$locationProvider','$compileProvider', 
  function($routeProvider , $locationProvider , $compileProvider) {
@@ -19,6 +20,13 @@ angular.module('egWorkstationAdmin', ['ngRoute', 'ui.bootstrap', 'egCoreMod', 'e
         resolve : resolver
     });
 
+    $routeProvider.when('/admin/workstation/stored_prefs', {
+        templateUrl: './admin/workstation/t_stored_prefs',
+        controller: 'StoredPrefsCtrl',
+        resolve : resolver
+    });
+
+
     // default page 
     $routeProvider.otherwise({
         templateUrl : './admin/workstation/t_splash',
@@ -137,6 +145,7 @@ function($scope , egPrintStore) {
                 $scope.context, 
                 $scope.contentType, 
                 $scope.textPrintContent,
+                null,
                 withDialog
             );
         } else {
@@ -157,3 +166,54 @@ function($scope , egPrintStore) {
     $scope.setContentType('text/plain');
 
 }])
+
+.controller('StoredPrefsCtrl',
+       ['$scope','egPrintStore','egConfirmDialog','egAppStrings',
+function($scope , egPrintStore , egConfirmDialog , egAppStrings) {
+    console.log('StoredPrefsCtrl');
+
+    function refreshKeys() {
+        egPrintStore.getKeys()
+        .then(function(keys) { $scope.keys = keys.sort() })
+    }
+    refreshKeys();
+
+    $scope.selectKey = function(key) {
+        $scope.currentKey = key;
+        $scope.currentKeyContent = null;
+        egPrintStore.getItem(key)
+        .then(function(content) {
+            $scope.currentKeyContent = content
+        });
+    }
+
+    $scope.getCurrentKeyContent = function() {
+        try {
+            // if the content is JSON-encoded (most), re-stringify
+            // with the pretty printer.
+            return JSON.stringify($scope.currentKeyContent, null, 2);
+        } catch(E) {
+            // otherwise, return the bare value
+            return $scope.currentKeyContent;
+        }
+    }
+
+    $scope.removeKey = function(key) {
+        egConfirmDialog.open(
+            egAppStrings.PREFS_REMOVE_KEY_CONFIRM, '',
+            {   deleteKey : key,
+                ok : function() {
+                    egPrintStore.removeItem(key)
+                    .then(function() { 
+                        // delete succeeded, remove item from list
+                        $scope.keys = $scope.keys.filter(
+                            function(k) { return k != key }
+                        );
+                    });
+                },
+                cancel : function() {} // user canceled, nothing to do
+            }
+        );
+    }
+}])
+
index f0de9e3..c53a2f0 100644 (file)
@@ -42,6 +42,7 @@ angular.module('egCoreMod')
             msg2[key] = val;
         });
         console.debug("sending '" + msg.action + "' command to Hatch");
+        console.debug("sending to Hatch: " + JSON.stringify(msg2,null,2));
         service.socket.send(JSON.stringify(msg2));
     }