Skip to content

Commit

Permalink
0.0.7-beta - Manage buttons moved to service
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno Vale committed Apr 30, 2018
1 parent 77c0136 commit 7fc0358
Show file tree
Hide file tree
Showing 35 changed files with 161 additions and 143 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

The Swarm Manager is a web application to manage [docker swarms](https://docs.docker.com/engine/swarm/). The goal of this web app is to support all swarm configurations that the docker CLI supports and to add new functionalities like audit logs, user management and others.

Demo version running on https://swarmmanager.swarmbit.co.uk . The user is *admin* and password *administrator* .

Here you can find all the instructions needed to run the Swarm Manager development environment.

## Dependencies
Expand Down Expand Up @@ -39,12 +41,12 @@ Login with username *admin* and password *administrator*.
Available tags can be found here: https://hub.docker.com/r/swarmbit/swarmmanager/tags/
* Star swarm manager, this command does not persist data.
```
$ docker run --name swarmmanager -p 3000:3080 -v /var/run/docker.sock:/var/run/docker.sock -d swarmbit/swarmmanager:0.0.6-beta
$ docker run --name swarmmanager -p 3000:3080 -v /var/run/docker.sock:/var/run/docker.sock -d swarmbit/swarmmanager:0.0.7-beta
```

* Start swarm manage with configuration and data directory.
```
$ docker run --name swarmmanager -p 80:3080 -p 443:3443 -e HTTPS=true -e DBPASS=password -v /var/run/docker.sock:/var/run/docker.sock -v /opt/swarmmanager/data:/data -v /opt/swarmmanager/config:/config -d swarmbit/swarmmanager:0.0.6-beta
$ docker run --name swarmmanager -p 80:3080 -p 443:3443 -e HTTPS=true -e DBPASS=password -v /var/run/docker.sock:/var/run/docker.sock -v /opt/swarmmanager/data:/data -v /opt/swarmmanager/config:/config -d swarmbit/swarmmanager:0.0.7-beta
```
* Swarm manager stores data /swarmmanagercontroller/data and reads the configuration from /config.
* Hosts directories can be mounted to persist data and to add configuration to swarm manager.
Expand All @@ -66,7 +68,7 @@ spring.data.mongodb.database=swarmmanager
```
* Run light image
```
$ docker run --name swarmmanagerlight -p 80:3080 -v /var/run/docker.sock:/var/run/docker.sock -v /opt/swarmmanager/config:/config -d swarmbit/swarmmanagerlight:0.0.6-beta
$ docker run --name swarmmanagerlight -p 80:3080 -v /var/run/docker.sock:/var/run/docker.sock -v /opt/swarmmanager/config:/config -d swarmbit/swarmmanagerlight:0.0.7-beta
```

## Project Maintainers
Expand Down
2 changes: 1 addition & 1 deletion mongo/createSwarmManagerDB.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ swarmmanagerDB.createUser(
);

swarmmanagerDB = conn.getDB("swarmmanager");
swarmmanagerDB.auth("swarmmanager", "swarmmanager");
swarmmanagerDB.auth("swarmmanager", "-DBPASS-");
swarmmanagerDB.createCollection("users");
swarmmanagerDB.createCollection("usersData");
swarmmanagerDB.users.insert({
Expand Down
2 changes: 1 addition & 1 deletion swarmmanagercontroller/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>co.uk.swarmbit</groupId>
<artifactId>swarmmanagercontroller</artifactId>
<version>0.0.6-beta</version>
<version>0.0.7-beta</version>
<packaging>jar</packaging>

<name>Swarm Manager Controller</name>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
logging.level.co.uk.swarmbit=DEBUG
logging.file=swarmmanagercontroller.log
logging.level.co.uk.swarmbit=INFO
logging.file=/logs/swarmmanagercontroller.log
spring.data.mongodb.host=127.0.0.1
spring.data.mongodb.port=27017
spring.data.mongodb.username=swarmmanager
Expand Down
2 changes: 1 addition & 1 deletion swarmmanagerfrontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swarmmanagerfrontend",
"version": "0.0.6-beta",
"version": "0.0.7-beta",
"license": "GNU GENERAL PUBLIC LICENSE",
"scripts": {
"ng": "ng",
Expand Down
4 changes: 2 additions & 2 deletions swarmmanagerfrontend/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import 'hammerjs';
import { HammerGestureConfig, HAMMER_GESTURE_CONFIG } from '@angular/platform-browser';
import { DockerNetworksService } from './services/docker/networks/docker.networks.service';
import { SnackbarService } from './services/snackbar/snackbar.service';
import { ListControlBarComponent } from './components/list.control.bar/list.control.bar.component';
import { ControlBarComponent } from './components/control.bar/control.bar.component';
import { ListContainerComponent } from './components/list.container/list.container.component';
import { DockerNodesService } from './services/docker/nodes/docker.nodes.service';
import { ManageNetworkView } from './views/networks/manage/manage.network.view';
Expand Down Expand Up @@ -81,7 +81,7 @@ export class HammerConfig extends HammerGestureConfig {
ProgressBarComponent,
ShellComponent,
UserComponent,
ListControlBarComponent,
ControlBarComponent,
ListContainerComponent,
ConfirmationDialogComponent,
CleanServiceImagePipe,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

import { Component } from '@angular/core';

@Component({
selector: 'app-control-bar',
styleUrls: ['control.bar.component.scss'],
templateUrl: 'control.bar.component.html'
})
export class ControlBarComponent {
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class ShellComponent implements OnInit, OnDestroy {

goBack() {
if (this.headerInfo && this.headerInfo.backArrow) {
this.router.navigate([this.browserService.getBackUrl()]);
this.router.navigate([this.browserService.goBack()]);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ export class DockerNetworkResolver implements Resolve<DockerNetwork> {
observer.next(dockerNetwork);
observer.complete();
}, (err: any) => {
const backUrl = this.browserService.getBackUrl();
if (backUrl) {
this.router.navigate([backUrl]);
if (!this.browserService.cannotGoBack()) {
this.router.navigate([this.browserService.goBack()]);
} else {
this.router.navigate(['networks']);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,30 @@ export class DockerServiceLogsResolver implements Resolve<DockerServiceLogs> {
}

getLogs(route, observer): void {
const name = route.params[ 'name' ];
this.swarmService.getSelectedSwarm().toPromise().then(() => {
if (this.swarmService.equalsOrGreaterThenVersion29()) {
this.dockerServicesService.getServiceLogs(route.params[ 'name' ]).subscribe(
this.dockerServicesService.getServiceLogs(name).subscribe(
(dockerServiceLogs: DockerServiceLogs) => {
observer.next(dockerServiceLogs);
observer.complete();
}, () => {
observer.complete();
const backUrl = this.browserService.getBackUrl();
const backUrl = this.browserService.getCurrentUrl();
if (backUrl) {
this.router.navigate([backUrl]);
this.router.navigate([this.browserService.getCurrentUrl()]);
} else {
this.router.navigate(['services']);
this.router.navigate(['services/' + name]);
}
}
);
} else {
observer.complete();
const backUrl = this.browserService.getCurrentUrl();
if (backUrl) {
this.router.navigate([backUrl]);
this.router.navigate([this.browserService.getCurrentUrl()]);
} else {
this.router.navigate(['services']);
this.router.navigate(['services/' + name]);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ export class DockerServiceStateResolver implements Resolve<DockerServiceState> {
}

private getServiceState(route, observer): void {
this.dockerServicesService.getServiceState(route.params['name']).subscribe(
const name = route.params['name'];
this.dockerServicesService.getServiceState(name).subscribe(
(state: DockerServiceState) => {
observer.next(state);
observer.complete();
}, (err: any) => {
const backUrl = this.browserService.getCurrentUrl();
if (backUrl) {
this.router.navigate([backUrl]);
if (!this.browserService.cannotGoBack()) {
this.router.navigate([this.browserService.goBack()]);
} else {
this.router.navigate(['services']);
this.router.navigate(['services/' + name]);
}
observer.complete();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { DockerServicePort } from './docker.service.port';
import { DockerServiceTask } from './docker.service.task';
export class DockerServiceState {
tasks: DockerServiceTask[];
Expand Down
40 changes: 26 additions & 14 deletions swarmmanagerfrontend/src/app/services/utils/browser.service.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,54 @@
import { Injectable } from '@angular/core';
import { NavigationEnd, NavigationStart, Router } from '@angular/router';
import { NavigationEnd, Router } from '@angular/router';

@Injectable()
export class BrowserService {

private backUrl: string;
private currentUrl: string;
private backEnabled: boolean;
private goingBack = false;
private history = [];

constructor(private router: Router) {
this.router.events
.subscribe(event => {
if (event instanceof NavigationEnd) {
if (this.currentUrl != null) {
this.backUrl = this.currentUrl;
this.currentUrl = event.url;
if (!this.goingBack) {
this.history.push(event.url);
} else {
this.currentUrl = event.url;
this.history.pop();
this.goingBack = false;
}
}
});
}

cannotGoBack(): boolean {
return this.backUrl == null;
return this.history.length == 1;
}

getBackUrl(): string {
return this.backUrl;
goBack(): string {
this.goingBack = true;
if (this.history.length > 1) {
return this.history[this.history.length - 2];
}
return null;
}

getPreviousUrl(): string {
if (this.history.length > 1) {
return this.history[this.history.length - 2];
}
return null;
}

getCurrentUrl(): string {
return this.currentUrl;
if (this.history.length > 0) {
return this.history[this.history.length - 1];
}
return null;
}

reset(): void {
this.currentUrl = null;
this.backUrl = null;
this.history = [];
}

}
8 changes: 3 additions & 5 deletions swarmmanagerfrontend/src/app/views/base.view.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BrowserService } from './../services/utils/browser.service';
import { BrowserService } from '../services/utils/browser.service';
import { HeaderService } from '../services/header/header.service';
import { HeaderInfo } from '../services/header/header.info';
import { BackArrow } from '../services/header/back.arrow';
Expand All @@ -8,7 +8,6 @@ import { UserService } from '../services/user/user.service';
import { OnDestroy } from '@angular/core';
import { Subscription } from 'rxjs/Subscription';
import { ActivatedRoute } from '@angular/router';
import { browser } from 'protractor';

export class BaseView implements OnDestroy {

Expand Down Expand Up @@ -77,9 +76,8 @@ export class BaseView implements OnDestroy {
}

goBack(router, page): void {
const backUrl = this.browser.getBackUrl;
if (backUrl) {
router.navigate([backUrl]);
if (!this.browser.cannotGoBack()) {
router.navigate([this.browser.goBack()]);
} else {
router.navigate([page]);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<app-list-control-bar>
<app-control-bar>
<div class="config">
<button [routerLink]="'/' + objectType() + '/create'" mat-raised-button color="primary" *ngIf="user.isUser()">{{getCreateButtonText()}}</button>
<button mat-raised-button color="primary" (click)="refreshFunction()">{{getRefreshButtonText()}}</button>
Expand All @@ -12,7 +12,7 @@
<mat-hint>{{getFilterMessage()}}</mat-hint>
</mat-form-field>
</div>
</app-list-control-bar>
</app-control-bar>
<app-list-container>
<mat-card class="config-card" *ngFor="let object of getObjects()">
<mat-card-content>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
<form class="sm-form" [formGroup]="form" (ngSubmit)="create()">
<app-control-bar>
<button mat-raised-button color="primary" *ngIf="!isDetails && user.isUser()" (click)="create()">Create</button>
<button mat-raised-button color="primary" *ngIf="isDetails && user.isUser()" type="button" (click)="openDialog()">Remove</button>
</app-control-bar>
<form class="sm-form" [formGroup]="form" style="padding-top: 1rem">
<div class="sm-form-row" *ngIf="formInvalid">
<div class="sm-form-field extra-big sm-form-submit">
<div class="sm-form-error">
<mat-error>{{formErrorMessage}}</mat-error>
</div>
</div>
</div>
<div class="sm-form-row">
<!-- Required -->
<mat-form-field class="sm-form-field big">
Expand Down Expand Up @@ -94,13 +105,4 @@
</button>
</div>
</mat-expansion-panel>
<div class="sm-form-row">
<div class="sm-form-field extra-big sm-form-submit">
<button mat-raised-button color="primary" *ngIf="!isDetails && user.isUser()">Create</button>
<button mat-raised-button color="primary" *ngIf="isDetails && user.isUser()" type="button" (click)="openDialog()">Remove</button>
<div class="sm-form-error">
<mat-error *ngIf="formInvalid">{{formErrorMessage}}</mat-error>
</div>
</div>
</div>
</form>
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
<form class="sm-form" [formGroup]="networkForm" (ngSubmit)="createNetwork()">
<app-control-bar>
<button mat-raised-button color="primary" *ngIf="!isDetails && user.isUser()" (click)="createNetwork()">Create</button>
<button mat-raised-button color="primary" *ngIf="isDetails && user.isUser()" type="button" (click)="openDialog()">Remove</button>
</app-control-bar>
<form class="sm-form" style="padding-top: 1rem" [formGroup]="networkForm">
<div class="sm-form-row" *ngIf="formInvalid">
<div class="sm-form-field extra-big sm-form-submit">
<div class="sm-form-error">
<mat-error>{{formErrorMessage}}</mat-error>
</div>
</div>
</div>
<div class="sm-form-row">
<!-- Required -->
<mat-form-field class="sm-form-field big">
Expand Down Expand Up @@ -138,13 +149,4 @@
<mat-slide-toggle formControlName="attachable">Attachable</mat-slide-toggle>
</div>
</div>
<div class="sm-form-row">
<div class="sm-form-field extra-big sm-form-submit">
<button mat-raised-button color="primary" *ngIf="!isDetails && user.isUser()">Create</button>
<button mat-raised-button color="primary" *ngIf="isDetails && user.isUser()" type="button" (click)="openDialog()">Remove</button>
<div class="sm-form-error">
<mat-error *ngIf="formInvalid">{{formErrorMessage}}</mat-error>
</div>
</div>
</div>
</form>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, NgZone} from '@angular/core';
import { Component } from '@angular/core';
import { HeaderService } from '../../../services/header/header.service';
import { DockerSwarmService } from '../../../services/docker/swarms/docker.swarms.service';
import { UserService } from '../../../services/user/user.service';
Expand Down Expand Up @@ -55,6 +55,7 @@ export class ManageNetworkView extends BaseView {
}

initCreateForm(dockerNetwork ?: DockerNetwork): void {
this.formInvalid = false;
if (!dockerNetwork && this.isDetails) {
this.subscriptions.push(this.route.data
.subscribe(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<app-list-control-bar>
<app-control-bar>
<div class="network">
<button routerLink="/networks/create" mat-raised-button color="primary" *ngIf="user.isUser()">Create Network</button>
<button mat-raised-button color="primary" (click)="refreshNetworks()">Refresh Networks List</button>
Expand All @@ -12,7 +12,7 @@
<mat-hint>Filter by network name</mat-hint>
</mat-form-field>
</div>
</app-list-control-bar>
</app-control-bar>
<app-list-container>
<mat-card class="network-card" *ngFor="let network of getNetworks()">
<mat-card-content>
Expand Down
Loading

0 comments on commit 7fc0358

Please sign in to comment.