Skip to content

Commit

Permalink
feat(apps page): adds a new apps page
Browse files Browse the repository at this point in the history
this new page shows a summary of all the apps in each environment, the version, numnber of pods and their states and the links to test out the apps in a single, simple view that folks can use to keep an eye on things fabric8-ui#454
  • Loading branch information
jstrachan committed May 2, 2017
1 parent d720914 commit 1772e56
Show file tree
Hide file tree
Showing 24 changed files with 834 additions and 6 deletions.
1 change: 1 addition & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export { SpaceNamespace } from './src/app/kubernetes/ui/environment/space-namespace';
export { EnvironmentListPageComponent } from './src/app/kubernetes/ui/environment/list-page/list-page.environment.component';
export { EnvironmentModule } from './src/app/kubernetes/ui/environment/environment.module';
export { AppModule } from './src/app/kubernetes/ui/app/app.module';
export { PipelineStatusComponent } from './src/app/kubernetes/components/pipeline-status/pipeline-status.component';
export { PodPhaseIconComponent } from './src/app/kubernetes/components/pod-phase-icon/pod-phase-icon.component';
export { KubernetesLabelsComponent } from './src/app/kubernetes/components/k8s-labels/k8s-labels.component';
Expand Down
2 changes: 1 addition & 1 deletion src/app/kubernetes/model/build.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as jsyaml from "js-yaml";
const serviceEnvironmentsAnnotationPrefix = "environment.services.fabric8.io/";


function sortedKeys(map: Map<String,any>): string[] {
export function sortedKeys(map: Map<String,any>): string[] {
let answer = [];
for (let key in map) {
answer.push(key);
Expand Down
2 changes: 2 additions & 0 deletions src/app/kubernetes/model/kubernetesresource.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { currentOAuthConfig } from '../store/oauth-config-store';
export class KubernetesResource implements BaseEntity {
id: string;
name: string;
version: string;
namespace: string;
description: string;
icon: string;
Expand Down Expand Up @@ -50,6 +51,7 @@ export class KubernetesResource implements BaseEntity {
this.creationTimestamp = metadata.creationTimestamp;
this.labels = metadata.labels || new Map<string, string>();
this.annotations = metadata.annotations || new Map<string, string>();
this.version = this.labels["version"] || "";
this.icon = this.annotations['fabric8.io/iconUrl'] || this.defaultIconUrl();

// TODO any other annotations we should look for?
Expand Down
29 changes: 29 additions & 0 deletions src/app/kubernetes/model/scalableresource.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,23 @@ export class ScalableResource extends KubernetesSpecResource {
availableReplicas: number;
unavailableReplicas: number;
updatedReplicas: number;
statusReplicas: number;

/**
* How many replicas are terminating?
*/
public terminatingReplicas: number;

/**
* How many replicas are starting up?
*/
public startingReplicas: number;

/**
* If there are no running, starting or terminating pods
*/
public emptyReplicas: boolean;


updateResource(resource) {
resource.spec = this.spec;
Expand All @@ -18,11 +35,23 @@ export class ScalableResource extends KubernetesSpecResource {
this.availableReplicas = 0;
this.unavailableReplicas = 0;
this.updatedReplicas = 0;
this.statusReplicas = 0;
let status = this.status;
if (status) {
this.availableReplicas = status.availableReplicas || 0;
this.unavailableReplicas = status.unavailableReplicas || 0;
this.updatedReplicas = status.updatedReplicas || 0;
this.statusReplicas = status.replicas || 0;
}

this.terminatingReplicas = this.availableReplicas - this.replicas;
if (this.terminatingReplicas < 0) {
this.terminatingReplicas = 0;
}
this.startingReplicas = this.replicas - this.availableReplicas;
if (this.startingReplicas < 0) {
this.startingReplicas = 0;
}
this.emptyReplicas = !(this.availableReplicas || this.startingReplicas || this.terminatingReplicas);
}
}
3 changes: 3 additions & 0 deletions src/app/kubernetes/model/space.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ export class Spaces extends Array<Space>{
systemNamespaces = new Array<Space>();
}

export function createEmptySpace(): Space {
return new Space(null, new Namespaces(), null);
}

export function asSpaces(spaces: Space[]): Spaces {
var answer = new Spaces();
Expand Down
2 changes: 2 additions & 0 deletions src/app/kubernetes/support/abstract-watch.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export class AbstractWatchComponent implements OnDestroy {
watch.close();
}
}
this.watchCache.clear();
this.listObservableCache.clear();
}

protected listAndWatchServices(namespace: string, serviceService: ServiceService, routeService: RouteService): Observable<Services> {
Expand Down
24 changes: 24 additions & 0 deletions src/app/kubernetes/ui/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {NgModule} from "@angular/core";
import {RouterModule, Routes} from "@angular/router";
import {AppListPageComponent} from "./list-page/list-page.app.component";

const routes: Routes = [
{
path: '',
component: AppListPageComponent,
// Can't use lazy loading here as we need to import in to another module, and that doesn't work yet
children: [
],
},
];

@NgModule({
imports: [
RouterModule.forChild(routes),
],
exports: [
RouterModule,
],
})
export class AppRoutingModule {
}
65 changes: 65 additions & 0 deletions src/app/kubernetes/ui/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import {ServiceModule} from "./../service/service.module";
import {ReplicaSetModule} from "./../replicaset/replicaset.module";
import {PodModule} from "./../pod/pod.module";
import {EventModule} from "./../event/event.module";
import {ConfigMapModule} from "./../configmap/configmap.module";
import {DeploymentModule} from "./../deployment/deployment.module";
import {ConfigMapStore} from "./../../store/configmap.store";
import {NamespaceStore} from "./../../store/namespace.store";
import {NgModule} from "@angular/core";
import {DropdownConfig, DropdownModule} from "ng2-bootstrap";
import {CommonModule} from "@angular/common";
import {FormsModule} from "@angular/forms";
import {RouterModule} from "@angular/router";
import {ModalModule} from "ng2-modal";
import {ToolbarModule} from "ngx-widgets";
import {Fabric8CommonModule} from "../../../common/common.module";
import {MomentModule} from "angular2-moment";
import {KubernetesComponentsModule} from "../../components/components.module";
import {ConfigMapService} from "../../service/configmap.service";
import {NamespaceScope} from "../../service/namespace.scope";
import {NamespaceService} from "../../service/namespace.service";
import {AppListPageComponent} from "./list-page/list-page.app.component";
import {AppListComponent} from "./list/list.app.component";
import {AppListToolbarComponent} from "./list-toolbar/list-toolbar.app.component";
import {AppRoutingModule} from "./app-routing.module";

@NgModule({
imports: [
CommonModule,
DropdownModule,
FormsModule,
ModalModule,
MomentModule,
RouterModule,
Fabric8CommonModule,
KubernetesComponentsModule,
ToolbarModule,
// Our Routing MUST go before the other Kuberenetes UI modules, so our routes take precedence
AppRoutingModule,
DeploymentModule,
ConfigMapModule,
EventModule,
PodModule,
ReplicaSetModule,
ServiceModule,
],
declarations: [
AppListPageComponent,
AppListToolbarComponent,
AppListComponent,
],
providers: [
DropdownConfig,
NamespaceStore,
ConfigMapService,
ConfigMapStore,
NamespaceScope,
NamespaceService,
],
exports: [
AppListPageComponent,
],
})
export class AppModule {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class="container-fluid">
<div class='environments list'>
<fabric8-apps-list-toolbar></fabric8-apps-list-toolbar>
<fabric8-apps-list [apps]="apps | async" [space]="space | async" [loading]="loading | async"></fabric8-apps-list>
</div>
</div>
Empty file.
Loading

0 comments on commit 1772e56

Please sign in to comment.