Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into helm-hub
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-cox committed Sep 8, 2020
2 parents 559ecc4 + aa675d3 commit 1744b9a
Show file tree
Hide file tree
Showing 40 changed files with 2,957 additions and 1,948 deletions.
12 changes: 12 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,18 @@
"tsConfig": "src/frontend/packages/suse-extensions/tsconfig.spec.json",
"karmaConfig": "src/frontend/packages/suse-extensions/karma.conf.js"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.json"
],
"tslintConfig": "src/frontend/packages/suse-extensions/tslint.json",
"files": [
"src/frontend/packages/suse-extensions/src/**/*.ts"
]
}
}
}
}
Expand Down
4,448 changes: 2,682 additions & 1,766 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"devDependencies": {
"@angular-builders/custom-webpack": "^9.1.0",
"@angular-devkit/architect": "^0.901.7",
"@angular-devkit/build-angular": "~0.901.5",
"@angular-devkit/build-angular": "^0.901.12",
"@angular-devkit/build-ng-packagr": "~0.901.5",
"@angular-devkit/core": "^9.1.7",
"@angular-devkit/schematics": "^9.1.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,29 @@
<div class="chartInfo__home" *ngIf="chart.attributes.home">
<h1>Home</h1>
<div>
<a href="{{ chart.attributes.home }}" target="_blank">{{chart.attributes.home}}</a>
<a class="chartInfo__link" href="{{ chart.attributes.home }}" target="_blank">{{chart.attributes.home}}</a>
</div>
</div>
<div class="chartInfo__maintainers" *ngIf="maintainers.length">
<h1>Maintainers</h1>
<div *ngFor="let maintainer of maintainers">
<a href="{{ maintainerUrl(maintainer) }}" target="_blank">{{ maintainer.name }}</a>
<a href="{{ maintainerUrl(maintainer) }}" class="chartInfo__link" target="_blank">{{ maintainer.name }}</a>
</div>
</div>
<div class="chartInfo__related" *ngIf="sources.length">
<h1>Related</h1>
<div *ngFor="let source of sources">
<a href="{{ source }}" class="chartInfo__related-link" target="_blank">{{ source }}</a>
<a href="{{ source }}" class="chartInfo__link" target="_blank">{{ source }}</a>
</div>
</div>
<div class="chartInfo__related" *ngIf="schema">
<h1>Schema</h1>
<div class="chartInfo__link">This chart contains a values schema</div>
</div>
<div class="chartInfo__related" *ngIf="currentVersion">
<h1>Chart</h1>
<div *ngFor="let url of currentVersion.attributes.urls">
<a href="{{ url }}" class="chartInfo__link" target="_blank">{{ url }}</a>
</div>
</div>
</mat-card>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.chartInfo {

h1 {
font-size: 18px;
font-size: 16px;
}

app-panel {
Expand All @@ -15,17 +15,14 @@
}
}

&__related {
max-width: 280px;
}

&__related-link {
&__link {
font-size: 14px;
}

&__properties {
overflow: auto;
display: block;
margin-bottom: 2em;
max-width: 260px;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Component, Input, OnInit } from '@angular/core';
import { of } from 'rxjs';
import { catchError, first } from 'rxjs/operators';

import { Chart } from '../../shared/models/chart';
import { ChartVersion } from '../../shared/models/chart-version';
Expand All @@ -12,8 +14,22 @@ import { ChartsService } from '../../shared/services/charts.service';
})
export class ChartDetailsInfoComponent implements OnInit {
@Input() chart: Chart;
@Input() currentVersion: ChartVersion;
versions: ChartVersion[];
schema: any = null;

_currentVersion: ChartVersion;

get currentVersion(): ChartVersion {
return this._currentVersion;
}

@Input() set currentVersion (version: ChartVersion) {
this._currentVersion = version;
if (version) {
this.getSchema(this._currentVersion);
}
}

constructor(private chartsService: ChartsService) { }

ngOnInit() {
Expand Down Expand Up @@ -52,4 +68,14 @@ export class ChartDetailsInfoComponent implements OnInit {
repoURL === 'https://kubernetes-charts-incubator.storage.googleapis.com'
);
}

private getSchema(currentVersion: ChartVersion) {
this.chartsService.getChartSchema(currentVersion).pipe(
first(),
catchError(() => of(null))
).subscribe(schema => {
this.schema = schema;
});
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
<div class="chart-details-usage__install">
<button class="chart-details-usage__install-btn" color="primary" mat-button mat-raised-button
[routerLink]="installUrl">Install Chart</button>
</div>
<button *ngIf="endpointsService.hasConnectedEndpointType('k8s') | async; else nok8s"
class="chart-details-usage__install-btn" color="primary" mat-button mat-raised-button
routerLink="/monocular/install/{{chart.id}}/{{currentVersion}}">Install Chart</button>
</div>

<!-- If there are no Kubernetes endpoints connected, show a disabled button with a tool tip-->
<ng-template #nok8s>
<div matTooltip="Add a Kubernetes endpoint to install charts">
<button disabled="true" class="chart-details-usage__install-btn" color="primary" mat-button
mat-raised-button>Install Chart</button>
</div>
</ng-template>
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
.versions {

h1 {
font-size: 18px;
font-size: 16px;
margin-top: 0;
}
.more-link {
cursor: pointer;
font-size: 14px;
margin-top: .5em;

&:hover {
text-decoration: underline;
}
}
}

Expand All @@ -23,6 +29,8 @@
}

.version {
font-size: 14px;

&__table {
display: table;
width: 100%;
Expand All @@ -32,11 +40,12 @@
}
&__cell {
display: table-cell;
font-size: 14px;
}
}

.app-version {
h1 {
font-size: 18px;
font-size: 16px;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { getMonocularEndpoint } from '../stratos-monocular.helper';
selector: 'app-chart-item',
templateUrl: './chart-item.component.html',
styleUrls: ['./chart-item.component.scss'],
/* tslint:disable-next-line:use-input-property-decorator */
/* tslint:disable-next-line:no-inputs-metadata-property */
inputs: ['chart', 'showVersion', 'showDescription']
})
export class ChartItemComponent implements OnInit {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { Component } from '@angular/core';
selector: 'app-list-filters',
templateUrl: './list-filters.component.html',
styleUrls: ['./list-filters.component.scss'],
/* tslint:disable-next-line:use-input-property-decorator */
/* tslint:disable-next-line:no-inputs-metadata-property */
inputs: ['filters']
})

export class ListFiltersComponent {
public filters: { title: string, items: Array<{}> }[] = [];
public filters: { title: string, items: Array<{}>, }[] = [];
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Component, Input } from '@angular/core';
selector: 'app-list-item',
templateUrl: './list-item.component.html',
styleUrls: ['./list-item.component.scss'],
/* tslint:disable-next-line:use-input-property-decorator */
/* tslint:disable-next-line:no-inputs-metadata-property */
inputs: ['detailUrl']
})
export class ListItemComponent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Component } from '@angular/core';
selector: 'app-loader',
templateUrl: './loader.component.html',
styleUrls: ['./loader.component.scss'],
/* tslint:disable-next-line:use-input-property-decorator */
/* tslint:disable-next-line:no-inputs-metadata-property */
inputs: ['loading']
})
export class LoaderComponent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Component } from '@angular/core';
selector: 'app-panel',
templateUrl: './panel.component.html',
styleUrls: ['./panel.component.scss'],
/* tslint:disable-next-line:use-input-property-decorator */
/* tslint:disable-next-line:no-inputs-metadata-property */
inputs: ['title', 'background', 'container', 'border']
})
export class PanelComponent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class ChartVersionAttributes {
icons: ChartVersionIcon[];
readme: string;
version: string;
schema?: string;
/* tslint:disable-next-line:variable-name */
app_version: string;
urls: string[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,19 @@ export class ChartsService {
responseType: 'text'
});
}

/**
* Get a chart's Schema using the API
*
* @param repo Repository name
* @param chartName Chart name
* @param version Chart version
* @return An observable that will be the json schema
*/
getChartSchema(chartVersion: ChartVersion): Observable<any> {
return this.http.get(`${this.hostname}${chartVersion.attributes.schema}`);
}

/**
* Get chart versions using the API
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ import { ApiRequestTypes } from '../../../../../store/src/reducers/api-request-r
import { endpointOfTypeSelector } from '../../../../../store/src/selectors/endpoint.selectors';
import { NormalizedResponse } from '../../../../../store/src/types/api.types';
import {
EntityRequestAction,
StartRequestAction,
WrapperRequestActionFailed,
WrapperRequestActionSuccess,
EntityRequestAction,
StartRequestAction,
WrapperRequestActionFailed,
WrapperRequestActionSuccess,
} from '../../../../../store/src/types/request.types';
import { helmEntityCatalog } from '../helm-entity-catalog';
import { getHelmVersionId, getMonocularChartId, HELM_ENDPOINT_TYPE, HELM_HUB_ENDPOINT_TYPE } from '../helm-entity-factory';
import { Chart } from '../monocular/shared/models/chart';
import {
GET_HELM_VERSIONS,
GET_MONOCULAR_CHARTS,
GetHelmVersions,
GetMonocularCharts,
HELM_INSTALL,
HELM_SYNCHRONISE,
HelmInstall,
HelmSynchronise,
GET_HELM_VERSIONS,
GET_MONOCULAR_CHARTS,
GetHelmVersions,
GetMonocularCharts,
HELM_INSTALL,
HELM_SYNCHRONISE,
HelmInstall,
HelmSynchronise,
} from './helm.actions';
import { HelmVersion } from './helm.types';

Expand Down Expand Up @@ -251,36 +251,7 @@ export class HelmEffects {
})
);


private makeRequest(
action: EntityRequestAction,
url: string,
mapResult: (response: any) => NormalizedResponse,
endpointIds: string[]
): Observable<Action> {
this.store.dispatch(new StartRequestAction(action));
const requestArgs = {
headers: null,
params: null
};
return this.httpClient.get(url, requestArgs).pipe(
mergeMap((response: any) => [new WrapperRequestActionSuccess(mapResult(response), action)]),
catchError(error => {
const { status, message } = HelmEffects.createHelmError(error);
return [
new WrapperRequestActionFailed(message, action, 'fetch', {
endpointIds,
url: error.url || url,
eventCode: status,
message,
error
})
];
})
);
}

static createHelmErrorMessage(err: any): string {
private static createHelmErrorMessage(err: any): string {
if (err) {
if (err.error && err.error.message) {
// Kube error
Expand All @@ -296,7 +267,7 @@ export class HelmEffects {
return 'Helm API request error';
}

static createHelmError(err: any): { status: string, message: string, } {
public static createHelmError(err: any): { status: string, message: string; } {
let unwrapped = err;
if (err.error) {
unwrapped = err.error;
Expand All @@ -315,6 +286,34 @@ export class HelmEffects {
};
}

private makeRequest(
action: EntityRequestAction,
url: string,
mapResult: (response: any) => NormalizedResponse,
endpointIds: string[]
): Observable<Action> {
this.store.dispatch(new StartRequestAction(action));
const requestArgs = {
headers: null,
params: null
};
return this.httpClient.get(url, requestArgs).pipe(
mergeMap((response: any) => [new WrapperRequestActionSuccess(mapResult(response), action)]),
catchError(error => {
const { status, message } = HelmEffects.createHelmError(error);
return [
new WrapperRequestActionFailed(message, action, 'fetch', {
endpointIds,
url: error.url || url,
eventCode: status,
message,
error
})
];
})
);
}

private checkSyncStatus() {
// Dispatch request
const url = `/pp/${this.proxyAPIVersion}/chartrepos/status`;
Expand Down
Loading

0 comments on commit 1744b9a

Please sign in to comment.