Skip to content

Commit

Permalink
fix(image-builder): image builder fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jkuri committed Oct 3, 2017
1 parent ca25a32 commit ac6f5f0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion e2e/150_images.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Images', () => {
before(() => login().then(() => browser.waitForAngularEnabled(false)));
after(() => logout().then(() => browser.waitForAngularEnabled(true)));

it('should go to images and see no images', () => {
xit('should go to images and see no images', () => {
return browser.get('/images')
.then((): any => browser.wait(() => element(by.css(`[name="tab-images"]`)).isPresent()))
.then((): any => browser.wait(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/api/image-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface ImageBuildOutput {
}

export const imageBuilder: Subject<ImageBuildOutput> = new Subject();
imageBuilder.share();
export const imageBuilderObs = imageBuilder.share();

export function buildDockerImage(data: ImageData): void {
prepareDirectory(data).then(() => {
Expand Down
14 changes: 12 additions & 2 deletions src/api/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
stopBuild,
terminalEvents
} from './process-manager';
import { imageBuilder, buildDockerImage } from './image-builder';
import { imageBuilderObs, buildDockerImage } from './image-builder';
import { getConfig } from './utils';
import * as https from 'https';
import * as http from 'http';
Expand Down Expand Up @@ -64,6 +64,9 @@ export class SocketServer {
// send client latest status about jobs
jobEvents.subscribe(event => conn.next(event));

// image builder subscription
let imageBuilderSub: Subscription;

conn.subscribe(event => {
if (event.type === 'disconnected') {
const index = this.clients.findIndex(client => client.connection === conn);
Expand Down Expand Up @@ -91,12 +94,19 @@ export class SocketServer {
break;

case 'subscribeToImageBuilder': {
imageBuilder.subscribe(event => {
imageBuilderSub = imageBuilderObs.subscribe(event => {
conn.next({ type: 'imageBuildProgress', data: event });
});
}
break;

case 'unsubscribeFromImageBuilder': {
if (imageBuilderSub) {
imageBuilderSub.unsubscribe();
}
}
break;

case 'stopBuild':
stopBuild(event.data.buildId)
.then(() => {
Expand Down
2 changes: 2 additions & 0 deletions src/app/components/app-images/app-images.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ export class AppImagesComponent implements OnInit, OnDestroy {
if (this.sub) {
this.sub.unsubscribe();
}

this.socketService.emit({ type: 'unsubscribeFromImageBuilder' });
}

buildImage(): void {
Expand Down

0 comments on commit ac6f5f0

Please sign in to comment.