</div><!-- /input-group -->
</div><!-- col -->
<div class="col-md-6">
- <button type="button"
- ng-click="configurePrinter()"
- ng-class="{disabled : actionPending}"
- class="btn btn-default btn-success">
- [% l('Configure Printer') %]
- </button>
+ <div class="input-group">
+ <div class="input-group-btn">
+ <button type="button"
+ ng-click="configurePrinter()"
+ ng-class="{disabled : actionPending || !printers[0]}"
+ class="btn btn-default btn-success">
+ [% l('Configure Printer') %]
+ </button>
+ <button type="button"
+ ng-click="resetConfig()"
+ ng-class="{disabled : actionPending}"
+ class="btn btn-default btn-warning">
+ [% l('Reset Configuration') %]
+ </button>
+ </div>
+ </div>
</div>
</div><!-- row -->
<div class="row" ng-hide="isTestView">
<li>{{messages[0]}}</li>
<li>
<span
+ ng-click="hatchConnect()"
title="[% l('Print/Store Connection Status') %]"
class="glyphicon glyphicon-transfer"
ng-class="{'status-bar-connected' : hatchConnected()}">
.then(function(config) {
$scope.printConfig = config;
+ if (!$scope.defaultPrinter) return;
+
// apply the default printer to every context which has
// no printer configured.
angular.forEach(
}
}
);
-
- console.log("CONFIGS : " +
- JSON.stringify($scope.printConfig, undefined, 2));
});
$scope.printerConfString = function() {
$scope.printConfig[$scope.context], undefined, 2);
}
+ $scope.resetConfig = function() {
+ $scope.printConfig[$scope.context] = {
+ context : $scope.context
+ }
+
+ if ($scope.defaultPrinter) {
+ $scope.printConfig[$scope.context].printer =
+ $scope.defaultPrinter.name;
+ }
+ }
+
$scope.configurePrinter = function() {
$scope.actionPending = true;
egPrintStore.configurePrinter(
if (key.match(/deferred/)) return;
msg2[key] = val;
});
+ console.debug("sending '" + msg.action + "' command to Hatch");
service.socket.send(JSON.stringify(msg2));
}
// Otherwise handle the request locally.
service.dispatchRequest = function(msg) {
- msg.msgid = '' + (service.msgId++);
+ msg.msgid = service.msgId++;
msg.deferred = $q.defer();
service.messages[msg.msgid] = msg;
// it from our tracked requests.
service.resolveRequest = function(msg) {
+ if (!service.messages[msg.msgid]) {
+ console.warn('no cached message for '
+ + msg.msgid + ' : ' + JSON.stringify(msg, null, 2));
+ }
+
// for requests sent through Hatch, only the cached
// request will have the original promise attached
msg.deferred = service.messages[msg.msgid].deferred;
// resolve / reject
if (msg.error) {
- console.error("egPrintStore command failed : " + msg.error);
+ console.error("egPrintStore command failed : "
+ + JSON.stringify(msg.error, null, 2));
msg.deferred.reject(msg.error);
} else {
- console.debug("egPrintStore command succeeded : " + msg.content);
msg.deferred.resolve(msg.content);
}
}
service.hatchAvailable = true;
if (service.onHatchOpen)
service.onHatchOpen();
- angular.forEach(service.pending, function(msg) {
+ while ( (msg = service.pending.shift()) ) {
service.sendToHatch(msg);
- });
+ };
}
service.socket.onclose = function() {
return;
}
- console.debug('Hatch says ' + msgStr);
var msgObj = JSON.parse(msgStr);
+ console.debug('Hatch says ' + JSON.stringify(msgObj, null, 2));
service.resolveRequest(msgObj);
}
}
$scope.$apply();
}
+ $scope.hatchConnect = function() {
+ egPrintStore.hatchConnect();
+ }
+
$rootScope.$on('egStatusBarMessage', function(evt, args) {
$scope.messages.unshift(args.message);