<br/>
<style>
+ #admin-workstation-container .row {
+ margin-top: 5px;
+ }
#admin-workstation-container .new-entry {
margin-top: 10px;
padding-top: 10px;
<div class="row">
<div class="col-md-6">
- <div class="checkbox">
- <label>
- <input type="checkbox" ng-class="{disabled : !userHasAdminPerm}"
- ng-model="usesWorkstation" ng-change="updateHatchRequired()">
-[% l('This workstation requires a workstation name?') %]
- </label>
+ [% l('Registered Workstations') %]
+ </div>
+ </div>
+ <div class="row">
+ <div class="col-md-6">
+ <div class="input-group">
+ <select class="form-control" ng-model="selectedWS">
+ <option ng-repeat="ws in workstations" value="{{ws.id}}"
+ ng-selected="ws.id == defaultWS.id">
+ {{getWSLabel(ws)}}
+ </option>
+ </select>
+ <div class="input-group-btn">
+ <button class="btn btn-default">
+ [% l('Login') %]
+ </button>
+ </div>
+ <div class="input-group-btn">
+ <button class="btn btn-default" ng-click="setDefaultWS()">
+ [% l('Set as Default') %]
+ </button>
+ </div>
+ <div class="input-group-btn">
+ <button class="btn btn-default btn-warning">
+ [% l('Delete') %]
+ </button>
+ </div>
</div>
</div>
</div>
+
+ <div class="row new-entry">
+ <div class="col-md-6">
+ [% l('Register a New Workstation') %]
+ </div>
+ </div>
<div class="row">
<div class="col-md-6">
- <input type='text' class='form-control'
- ng-disabled="!userHasAdminPerm || !usesWorkstation"
- title="[% l('Workstation Name') %]"
- placeholder="[% l('Workstation Name') %]"
- ng-change='updateWorkstation()' ng-model='workstationName'/>
+ <div class="input-group">
+ <div class="input-group-btn">
+ <eg-org-selector
+ selected="contextOrg"
+ org-changed="wsOrgChanged">
+ </eg-org-selector>
+ </div>
+ <input type='text' class='form-control'
+ title="[% l('Workstation Name') %]"
+ placeholder="[% l('Workstation Name') %]"
+ ng-model='newWSName'/>
+ <div class="input-group-btn">
+ <button class="btn btn-default" ng-click="registerWS()">
+ [% l('Register') %]
+ </button>
+ </div>
+ </div>
</div>
</div>
*/
angular.module('egWorkstationAdmin',
- ['ngRoute', 'ui.bootstrap', 'egCoreMod', 'egUiMod','egUserMod'])
+ ['ngRoute', 'ui.bootstrap', 'egCoreMod', 'egUiMod'])
.config(['$routeProvider','$locationProvider','$compileProvider',
function($routeProvider , $locationProvider , $compileProvider) {
}])
.controller('SplashCtrl',
- ['$scope','egPrintStore','egUser','egEnv','egAuth',
-function($scope , egPrintStore , egUser , egEnv , egAuth) {
+ ['$scope','egPrintStore','egAuth','egOrg','egPerm','egEvent','egNet','egAppStrings',
+function($scope , egPrintStore , egAuth , egOrg , egPerm , egEvent , egNet , egAppStrings) {
+
+ var permMap = {};
+ var wsPerms = [
+ 'ADMIN_WORKSTATION', //FIXME: create
+ 'REGISTER_WORKSTATION',
+ 'UPDATE_WORKSTATION',
+ 'DELETE_WORKSTATION'
+ ]
$scope.userHasAdminPerm = false;
- egUser.hasPermHere('ADMIN_WORKSTATION')
- .then(function(bool) { $scope.userHasAdminPerm = bool });
+ egPerm.hasPermAt(wsPerms)
+ .then(function(permMap) {
+ //$scope.userHasAdminPerm = bool
+ });
- var workstation;
- if (egEnv.aws) { // TODO: move this to egAuth
- workstation = egEnv.aws.map[egAuth.user().wsid()];
+ // fetch the stored WS info
+ egPrintStore.getItem('eg.conf.workstation.all')
+ .then(function(all) {
+ $scope.workstations = all || [];
+ return egPrintStore.getItem('eg.conf.workstation.default');
+ })
+ .then(function(def) {
+ console.log('loaded default WS ' + ws);
+ $scope.defaultWS = def
+ });
- // strip the org unit component of the name
- $scope.workstationName = workstation.name().split(/-/)[1];
+ if (ws = egAuth.workstation()) {
+ $scope.activeWS = ws;
+ $scope.contextOrg = egOrg.get(ws.owning_lib);
}
-
- $scope.hatchURL = egPrintStore.hatchURL();
- $scope.hatchRequired =
- egPrintStore.getLocalItem('eg.conf.hatch.required');
- $scope.updateHatchRequired = function() {
- egPrintStore.setLocalItem(
- 'eg.conf.hatch.required', $scope.hatchRequired);
+ $scope.getWSLabel = function(ws) {
+ return ws.name; // FIXME: appstrings
}
- $scope.updateHatchURL = function() {
- egPrintStore.setLocalItem(
- 'eg.conf.hatch.url', $scope.hatchURL);
+ $scope.setDefaultWS = function() {
+ console.log('selected ' + $scope.selectedWS);
+ var ws = $scope.workstations.filter(
+ function(w) { return w.id == $scope.selectedWS })[0];
+ egPrintStore.setItem(
+ 'eg.conf.workstation.default',
+ // avoid storing angular $$hashkey
+ {id : ws.id, name : ws.name, owning_lib : ws.owning_lib})
+ .then(function() { $scope.defaultWS = ws });
+ }
+
+ $scope.registerWS = function() {
+ var newName = $scope.contextOrg.shortname() + '-' + $scope.newWSName;
+ egNet.request(
+ 'open-ils.actor',
+ 'open-ils.actor.workstation.register',
+ egAuth.token(), newName, $scope.contextOrg.id())
+ .then(function(resp) {
+ var evt = egEvent.parse(resp);
+ if (evt) {
+ if (evt.textcode == 'WORKSTATION_NAME_EXISTS') {
+ // TODO: override call
+ } else {
+ // TODO: improvide permission error display
+ alert(evt);
+ }
+ } else if (resp) {
+ $scope.workstations.push(
+ { id : resp,
+ name : newName,
+ owning_lib : $scope.contextOrg.id()
+ }
+ );
+ return egPrintStore.setItem(
+ 'eg.conf.workstation.all', $scope.workstations);
+ }
+ });
+ }
+
+ $scope.wsOrgChanged = function(org) {
+ $scope.contextOrg = org;
}
$scope.updateUsesWorkstation = function() {
*/
}
+ // ---------------------
+ // Hatch Configs
+ $scope.hatchURL = egPrintStore.hatchURL();
+ $scope.hatchRequired =
+ egPrintStore.getLocalItem('eg.conf.hatch.required');
+ $scope.updateHatchRequired = function() {
+ egPrintStore.setLocalItem(
+ 'eg.conf.hatch.required', $scope.hatchRequired);
+ }
+
+ $scope.updateHatchURL = function() {
+ egPrintStore.setLocalItem(
+ 'eg.conf.hatch.url', $scope.hatchURL);
+ }
}])
.controller('PrintingCtrl',
}])
.controller('StoredPrefsCtrl',
- ['$scope','egUser','egPrintStore','egConfirmDialog','egAppStrings','$q',
-function($scope , egUser , egPrintStore , egConfirmDialog , egAppStrings , $q) {
+ ['$scope','$q','egAuth','egPrintStore','egConfirmDialog','egAppStrings','egPerm',
+function($scope , $q , egAuth , egPrintStore , egConfirmDialog , egAppStrings , egPerm) {
console.log('StoredPrefsCtrl');
$scope.setContext = function(ctx) {
// grab the edit perm
$scope.userHasDeletePerm = false;
- egUser.hasPermHere('ADMIN_WORKSTATION')
+ egPerm.hasPermHere('ADMIN_WORKSTATION')
.then(function(bool) { $scope.userHasDeletePerm = bool });
// fetch the keys
/* inject services into our controller. Spelling them
* out like this allows the auto-magic injector to work
* even if the code has been minified */
- ['$scope', '$location', '$window', 'egAuth',
- function($scope, $location, $window, egAuth) {
+ ['$scope','$location','$window','egAuth','egPrintStore',
+ function($scope , $location , $window , egAuth , egPrintStore) {
$scope.focusMe = true;
- // for now, workstations may be passed in via URL param
- $scope.args = {workstation : $location.search().ws};
+ egPrintStore.getItem('eg.conf.workstation.all')
+ .then(function(all) {
+ $scope.workstations = ['abc', 'dev', 'foo']; // TODO
+ if (all && all.length) {
+ $scope.workstations = all.map(function(a) { return a.name });
+
+ if (ws = $location.search().ws) {
+ // user requested a workstation via URL
+ var match = all.filter(
+ function(w) {return ws == w.name} )[0];
+
+ if (match) {
+ // requested WS registered on this client
+ $scope.args = {workstation : match.name};
+ } else {
+ // the requested WS is not registered on this client
+ $scope.wsNotRegistered = true;
+ }
+ } else {
+ // no workstation requested; use the default
+ egPrintStore.get('eg.conf.workstation.all.default')
+ .then(function(ws) {
+ $scope.args = {workstation : ws.name}
+ });
+ }
+ }
+ })
$scope.login = function(args) {
args.type = 'staff';