}
}
+ // Returns promise of null if Hatch is not available.
+ hostname(): Promise<string> {
+ const msg = new HatchMessage({action: 'hostname'});
+ return this.sendRequest(msg).then(
+ (m: HatchMessage) => m.response,
+ (err) => null
+ );
+ }
+
getItem(key: string): Promise<any> {
const msg = new HatchMessage({action: 'get', key: key});
return this.sendRequest(msg).then((m: HatchMessage) => m.response);
import {OrgService} from '@eg/core/org.service';
import {EventService} from '@eg/core/event.service';
import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component';
+import {HatchService} from '@eg/core/hatch.service';
// Slim version of the WS that's stored in the cache.
interface Workstation {
private store: StoreService,
private auth: AuthService,
private org: OrgService,
+ private hatch: HatchService,
private perm: PermService
) {}
.then(wsList => {
this.workstations = wsList || [];
- return this.store.getDefaultWorkstation();
- }).then(def => {
+ // Populate the new WS name field with the hostname when available.
+ return this.setNewName();
+
+ }).then(
+ ok => this.store.getDefaultWorkstation()
+
+ ).then(def => {
this.defaultName = def;
this.selectedName = this.auth.workstation() || this.defaultName;
const rm = this.route.snapshot.paramMap.get('remove');
this.workstations = this.workstations.filter(w => w.name !== name);
this.store.setWorkstations(this.workstations);
+ }
- if (this.defaultName === name) {
- this.defaultName = null;
- this.store.removeWorkstations();
- }
+ setNewName() {
+ this.hatch.hostname().then(name => this.newName = name || '');
}
canDeleteSelected(): boolean {
console.log('set context org to ' + $scope.contextOrg);
+ egCore.hatch.hostname().then(function(name) {
+ $scope.newWSName = name || '';
+ });
+
// fetch workstation reg perms
egCore.perm.hasPermAt('REGISTER_WORKSTATION', true)
.then(function(orgList) {
return deferred.promise;
}
+ service.hostname = function() {
+ if (service.hatchAvailable) {
+ return service.attemptHatchDelivery({action : 'hostname'})
+ .then(
+ function(name) { return name; },
+ // Gracefully handle case where Hatch has not yet been
+ // updated to include the hostname command.
+ function() {return null}
+ );
+ }
+ return $q.when(null);
+ }
+
// The only requirement for opening Hatch is that the DOM be loaded.
// Open the connection now so its state will be immediately available.
service.openHatch();