Skip to content

Commit

Permalink
Merge pull request #222 from anapolg/master
Browse files Browse the repository at this point in the history
Menu features and fixes
  • Loading branch information
anapolg authored Sep 13, 2018
2 parents 4fca212 + 37e4331 commit b2a2426
Show file tree
Hide file tree
Showing 17 changed files with 86 additions and 43 deletions.
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,15 @@ COPY --from=0 /build/dist/ /usr/share/nginx/html
# Set nginx configuration from app files
COPY ./nginx-custom.conf /etc/nginx/conf.d/default.conf

# Enable selected environment
COPY src/config-sp.json /usr/share/nginx/html/
COPY src/config-vnv.json /usr/share/nginx/html/
COPY src/config.json /usr/share/nginx/html/
COPY src/entrypoint.sh /


ENV PLATFORM sp
CMD ["/entrypoint.sh"]

# Expose application port
EXPOSE 4200
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pipeline {
sh 'git clone https://github.com/sonata-nfv/tng-devops.git'
dir(path: 'tng-devops') {
sh 'ansible-playbook roles/sp.yml -i environments -e "target=pre-int-sp component=portal"'
sh 'ansible-playbook roles/sp.yml -i environments -e "target=pre-int-vnv component=portal"'
sh 'ansible-playbook roles/vnv.yml -i environments -e "target=pre-int-vnv component=portal"'
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@

import { Component, ViewEncapsulation } from "@angular/core";

import { environment } from "../environments/environment";

@Component({
selector: "app-root",
templateUrl: "./app.component.html",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ app-runtime-policies {
to right,
$basic-background-color 1%,
$table-underline-color 1%,
$table-underline-color 91%,
$basic-background-color 91%,
$table-underline-color 88%,
$basic-background-color 88%,
$basic-background-color 100%
);
}
Expand All @@ -67,23 +67,13 @@ app-runtime-policies {
background-color: $primary-color-light;
}

.mat-cell:nth-child(3),
.mat-header-cell:nth-child(3) {
width: 5%;
}

.mat-cell:nth-child(5),
.mat-header-cell:nth-child(5) {
.mat-cell:nth-child(6),
.mat-header-cell:nth-child(6) {
width: 5%;
}

.mat-cell:nth-child(7),
.mat-header-cell:nth-child(7) {
width: 70px;
}

.mat-cell:nth-child(8),
.mat-header-cell:nth-child(8) {
width: 25px;
}
}
2 changes: 1 addition & 1 deletion src/app/service-platform/service-platform.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ export class ServicePlatformService {
resolve();
})
.catch(err => {
if (err.status == 500) {
if (err.status == 500 || err.status == 504) {
resolve();
} else {
reject("There was an error while trying to instantiate this slice");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { CommonService } from "../../shared/services/common/common.service";
})
export class SlicesInstancesDetailComponent implements OnInit {
loading: boolean;
uuid: string;
detail = {};

constructor(
Expand All @@ -25,6 +26,7 @@ export class SlicesInstancesDetailComponent implements OnInit {

ngOnInit() {
this.route.params.subscribe(params => {
this.uuid = params["id"];
this.requestSliceInstance(params["id"]);
});
}
Expand Down Expand Up @@ -57,10 +59,13 @@ export class SlicesInstancesDetailComponent implements OnInit {
let action = "Terminate";

this.dialogData.openDialog(title, content, action, () => {
this.commonService.openSnackBar("Terminating instance...", "");

this.servicePlatformService
.postOneSliceInstanceTermination(this.detail["uuid"])
.then(response => {
this.commonService.openSnackBar(response, "");
// this.commonService.openSnackBar(response, "");
// this.requestSliceInstance(this.uuid);
})
.catch(err => {
this.commonService.openSnackBar(err, "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ <h2 class="subsectionTitle">Slice Instances</h2>
<th mat-header-cell *matHeaderCellDef>
</th>
<td mat-cell *matCellDef="let element" (click)="stopInstance(element)" (click)="$event.stopPropagation()">
<button *ngIf="element.state.toUpperCase() != 'TERMINATED' && element.state != 'ERROR'" class="actions"
<button *ngIf="element.state.toUpperCase() != 'TERMINATED' && element.state.toUpperCase() != 'ERROR'" class="actions"
mat-button matTooltip="Terminate">
<i class="wui wui-stop-alt"></i>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,13 @@ export class SlicesInstancesComponent implements OnInit, OnDestroy {
let action = "Terminate";

this.dialogData.openDialog(title, content, action, () => {
this.commonService.openSnackBar("Terminating instance...", "");

this.servicePlatformService
.postOneSliceInstanceTermination(item.uuid)
.then(response => {
this.commonService.openSnackBar(response, "");
this.requestInstances();
// this.commonService.openSnackBar(response, "");
// this.requestInstances();
})
.catch(err => {
this.commonService.openSnackBar(err, "");
Expand Down
11 changes: 7 additions & 4 deletions src/app/shared/directives/feature-available.directive.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import { Directive, ElementRef, Input } from "@angular/core";
import { environment } from "../../../environments/environment";
import { ConfigService } from "../services/config/config.service";

@Directive({
selector: "[ifFeatureAvailable]"
})
export class FeatureAvailableDirective {
@Input("ifFeatureAvailable") service: string;
@Input("ifFeatureAvailable")
service: string;
_element: ElementRef;
constructor(el: ElementRef) {
constructor(el: ElementRef, private configService: ConfigService) {
this._element = el;
}

ngOnInit() {
const isServiceAvailable =
environment.features_available.indexOf(this.service.toUpperCase()) > -1
this.configService.features_available.indexOf(
this.service.toUpperCase()
) > -1
? true
: false;
if (!isServiceAvailable) {
Expand Down
25 changes: 22 additions & 3 deletions src/app/shared/services/config/config.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Injectable } from "@angular/core";
import { HttpClient, HttpErrorResponse } from "@angular/common/http";

import { Config } from "./config";

@Injectable()
export class ConfigService {
export class ConfigService extends Config {
baseSP: string = window.location.origin + "/api/v3/";
baseVNV: string = window.location.origin + "/api/v3/";
register: string = "users/";
Expand All @@ -27,12 +30,28 @@ export class ConfigService {
runtimePoliciesDefault: string = "policies/default/";
runtimePoliciesActions: string = "policies/actions";

constructor() {}
private configFile = "./config.json";

constructor(private http: HttpClient) {
super();
}

init() {
init(): Promise<Config> {
if (window.location.origin.includes("localhost")) {
this.baseSP = "http://pre-int-sp-ath.5gtango.eu:32002/api/v3/";
this.baseVNV = "http://pre-int-vnv-bcn.5gtango.eu:32002/api/v3/";
}

return new Promise<Config>((resolve, reject) => {
this.http.get(this.configFile).subscribe(
response => {
Object.assign(this, response as Config);
resolve(this);
},
(error: HttpErrorResponse) => {
reject(error.error);
}
);
});
}
}
3 changes: 3 additions & 0 deletions src/app/shared/services/config/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export class Config {
features_available: Array<string>;
}
3 changes: 3 additions & 0 deletions src/config-sp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"features_available": ["DASHBOARD", "SERVICE PLATFORM", "SERVICE MANAGEMENT"]
}
3 changes: 3 additions & 0 deletions src/config-vnv.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"features_available": ["DASHBOARD", "VALIDATION"]
}
8 changes: 8 additions & 0 deletions src/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"features_available": [
"DASHBOARD",
"VALIDATION",
"SERVICE PLATFORM",
"SERVICE MANAGEMENT"
]
}
11 changes: 11 additions & 0 deletions src/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
case $PLATFORM in
"sp")
mv /usr/share/nginx/html/config-sp.json /usr/share/nginx/html/config.json
;;
"vnv")
mv /usr/share/nginx/html/config-vnv.json /usr/share/nginx/html/config.json
;;
esac

exec $(which nginx) -c /etc/nginx/nginx.conf -g "daemon off;"
8 changes: 1 addition & 7 deletions src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
export const environment = {
production: true,
features_available: [
"DASHBOARD",
"VALIDATION",
"SERVICE PLATFORM",
"SERVICE MANAGEMENT"
]
production: true
};
8 changes: 1 addition & 7 deletions src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,5 @@
// The list of which env maps to which file can be found in `.angular-cli.json`.

export const environment = {
production: false,
features_available: [
"DASHBOARD",
"VALIDATION",
"SERVICE PLATFORM",
"SERVICE MANAGEMENT"
]
production: false
};

0 comments on commit b2a2426

Please sign in to comment.