Skip to content

Commit

Permalink
Merge cd6748c into 60d2bf8
Browse files Browse the repository at this point in the history
  • Loading branch information
hartra344 committed Apr 12, 2018
2 parents 60d2bf8 + cd6748c commit 63fe2a2
Show file tree
Hide file tree
Showing 41 changed files with 738 additions and 212 deletions.
10 changes: 10 additions & 0 deletions client/.angular-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@
}
],
"test": {
"codeCoverage": {
"exclude": [
"src/polyfills/*",
"**/test.ts",
"src/**/*.mock.ts",
"src/**/*.spec.ts",
"src/app/shared/**/*.ts",
"src/app/pickers/microsoft-graph/microsoft-graph-helper.ts"
]
},
"karma": {
"config": "./karma.conf.js"
}
Expand Down
3 changes: 3 additions & 0 deletions client/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ module.exports = function (config) {
junitReporter: {
useBrowserName: false,
},
coveragePreprocessor: {
exclude: [ "src/polyfills/*" ]
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/shared/models/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ export class DeploymentCenterConstants {
public static bitbucketUrl = 'https://bitbucket.org';
public static dropboxApiUrl = 'https://api.dropboxapi.com/2';
public static dropboxUri = 'https://www.dropbox.com/home/Apps/Azure';
public static onedriveApiUri = 'https://api.onedrive.com/v1.0/drive/special/approot:';
public static onedriveApiUri = 'https://api.onedrive.com/v1.0/drive/special/approot';
public static vstsProfileUri = 'https://app.vssps.visualstudio.com/_apis/profile/profiles/me';
public static vstsProjectsApi = 'https://{0}.visualstudio.com/DefaultCollection/_apis/projects?includeCapabilities=true';
public static vstsRegionsApi = 'https://app.vssps.visualstudio.com/_apis/commerce/regions';
Expand Down
1 change: 1 addition & 0 deletions client/src/app/shared/models/portal-resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1006,5 +1006,6 @@
public static pricingTier: string = "pricingTier";
public static deploymentCenterTitle: string = "deploymentCenterTitle";
public static deploymentCenterDesc: string = "deploymentCenterDesc";
public static notAuthorized: string = "notAuthorized";
public static monitorHostFetchFailed: string = "monitorHostFetchFailed";
}
10 changes: 1 addition & 9 deletions client/src/app/shared/services/arm-embedded.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ArmService } from './arm.service';

@Injectable()
export class ArmEmbeddedService extends ArmService {
public static url = ArmEmbeddedService.getRPUrl();
public static url = ArmService.getRPUrl();

public websiteApiVersion = '2018-02-01-preview';

Expand All @@ -28,14 +28,6 @@ export class ArmEmbeddedService extends ArmService {
'/api/'
];

// eventually move to sever
public static getRPUrl(): string {
if (window.location.host.indexOf('next') !== -1 || window.location.host.indexOf('localhost') !== -1) {
return 'https://blueridge-tip1-rp-westus.azurewebsites.net';
}
return 'https://blueridge-rp-westus.azurewebsites.net';
}

constructor(http: Http,
userService: UserService,
aiService: AiService,
Expand Down
15 changes: 11 additions & 4 deletions client/src/app/shared/services/arm.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ArmEmbeddedService } from './arm-embedded.service';
import { PortalService } from './portal.service';
import { ArmServiceHelper } from './arm.service-helper';
import { Injectable } from '@angular/core';
Expand Down Expand Up @@ -33,7 +32,7 @@ export class ArmService {
_portalService: PortalService,
protected _aiService: AiService) {

this.armUrl = _portalService.isEmbeddedFunctions ? ArmEmbeddedService.url : ArmServiceHelper.armEndpoint;
this.armUrl = _portalService.isEmbeddedFunctions ? ArmService.getRPUrl() : ArmServiceHelper.armEndpoint;

_userService.getStartupInfo()
.subscribe(info => {
Expand Down Expand Up @@ -97,12 +96,12 @@ export class ArmService {

getArmUrl(resourceId: string, apiVersion?: string) {
const url = `${this.armUrl}${resourceId}`;
if(apiVersion){
if (apiVersion) {
return this._updateQueryString(
url,
'api-version',
apiVersion ? apiVersion : this.websiteApiVersion);
} else{
} else {
return url;
}
}
Expand All @@ -117,4 +116,12 @@ export class ArmService {
return uri + separator + key + '=' + value;
}
}

// tslint:disable-next-line:member-ordering
public static getRPUrl(): string {
if (window.location.host.indexOf('next') !== -1 || window.location.host.indexOf('localhost') !== -1) {
return 'https://blueridge-tip1-rp-westus.azurewebsites.net';
}
return 'https://blueridge-rp-westus.azurewebsites.net';
}
}
6 changes: 5 additions & 1 deletion client/src/app/shared/services/broadcast.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ export class BroadcastService {
}

return subject
.do(e => this._logService.verbose(LogCategories.broadcastService, BroadcastEvent[e.eventType]))
.do(e => {
if (this._logService) {
this._logService.verbose(LogCategories.broadcastService, BroadcastEvent[e.eventType]);
}
})
.map(e => <T>e.obj);
}

Expand Down
111 changes: 111 additions & 0 deletions client/src/app/shared/test-mocks/log.service.mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import { Injectable } from '@angular/core';
import { Url } from 'app/shared/Utilities/url';

export enum LogLevel {
error,
warning,
debug,
verbose
}

export type LogLevelString = 'error' | 'warning' | 'debug' | 'verbose';

@Injectable()
export class MockLogService {

private _logLevel: LogLevel;
private _categories: string[];

constructor() {
const levelStr = Url.getParameterByName(null, 'appsvc.log.level');

if (levelStr) {
try {
this._logLevel = LogLevel[levelStr];
} catch (e) {
this._logLevel = LogLevel.warning;
}
} else {
this._logLevel = LogLevel.warning;
}

this._categories = Url.getParameterArrayByName(null, 'appsvc.log.category');
}

public error(category: string, id: string, data: any) {
if (!category || !id || !data) {
throw Error('You must provide a category, id, and data');
}
if (this._shouldLog(category, LogLevel.error)) {
console.error(`[${category}] - ${data}`);
}
}

public warn(category: string, id: string, data: any) {
if (!category || !id || !data) {
throw Error('You must provide a category, id, and data');
}

if (this._shouldLog(category, LogLevel.warning)) {
console.log(`%c[${category}] - ${data}`, 'color: #ff8c00');
}
}

public debug(category: string, data: any) {
if (!category || !data) {
throw Error('You must provide a category and data');
}

if (this._shouldLog(category, LogLevel.debug)) {
console.log(`${this._getTime()} %c[${category}] - ${data}`, 'color: #0058ad');
}
}

public verbose(category: string, data: any) {
if (!category || !data) {
throw Error('You must provide a category and data');
}

if (this._shouldLog(category, LogLevel.verbose)) {
console.log(`${this._getTime()} [${category}] - ${data}`);
}
}

public log(level: LogLevel, category: string, data: any, id?: string) {
if (!id && (level === LogLevel.error || level === LogLevel.warning)) {
throw Error('Error and Warning log levels require an id');
}

if (level === LogLevel.error) {
this.error(category, id, data);
} else if (level === LogLevel.warning) {
this.warn(category, id, data);
} else if (level === LogLevel.debug) {
this.debug(category, data);
} else {
this.verbose(category, data);
}
}

private _shouldLog(category: string, logLevel: LogLevel) {

if (logLevel <= this._logLevel) {
if (logLevel === LogLevel.error || logLevel === LogLevel.warning) {
return true;
} else if (this._categories.length > 0 && this._categories.find(c => c.toLowerCase() === category.toLowerCase())) {
return true;
} else if (this._categories.length === 0) {
return true;
} else {
return false;
}
}

return false;
}

private _getTime() {
const now = new Date();
return now.toISOString();
}
}
13 changes: 13 additions & 0 deletions client/src/app/site/deployment-center/Models/ProviderCard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { sourceControlProvider } from '../deployment-center-setup/wizard-logic/deployment-center-setup-models';

export interface ProviderCard {
id: sourceControlProvider;
name: string;
icon: string;
color: string;
barColor: string;
description: string;
authorizedStatus: 'loadingAuth' | 'notAuthorized' | 'authorized' | 'none';
authenticatedId?: string;
manual?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ export class DeploymentCenterSetupComponent implements OnChanges {
sourceControlProvider !== 'dropbox' &&
sourceControlProvider !== 'bitbucket' &&
sourceControlProvider !== 'ftp' &&
sourceControlProvider !== 'webdeploy'
sourceControlProvider !== 'webdeploy' &&
sourceControlProvider !== 'zip'
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="selectionContainer">
<div class="cardContainer" *ngFor="let card of providerCards" (click)="chooseBuildProvider(card)">
<div class="cardContainer" *ngFor="let card of providerCards" (click)="chooseBuildProvider(card)" id="{{card.id}}">
<div class="headerBox" [style.background-color]="card.barColor">
<img [src]="card.icon" [style.background-color]="card.color" /> {{card.name}} <img *ngIf="wizard?.wizardValues?.buildProvider === card.id"
style="float:right" src="image/success-blue.svg">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { StepBuildProviderComponent } from './step-build-provider.component';
import { ComponentFixture, fakeAsync, TestBed, async, tick } from '@angular/core/testing';
import { TranslateModule } from '@ngx-translate/core';
import { DeploymentCenterStateManager } from '../wizard-logic/deployment-center-state-manager';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/distinctUntilChanged';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/filter';
import 'rxjs/add/operator/first';
import 'rxjs/add/observable/forkJoin';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/merge';
import 'rxjs/add/operator/mergeMap';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/retry';
import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/take';
import 'rxjs/add/operator/takeUntil';
import 'rxjs/add/observable/timer';
import 'rxjs/add/observable/throw';
import 'rxjs/add/observable/zip';
import 'rxjs/add/operator/concatMap';
import 'rxjs/observable/interval';
import { Injectable } from '@angular/core';
import { By } from '@angular/platform-browser';
describe('StepBuildProviderComponent', () => {
let buildStepTest: StepBuildProviderComponent;
let testFixture: ComponentFixture<StepBuildProviderComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [StepBuildProviderComponent],
providers: [DeploymentCenterStateManager],
imports: [TranslateModule.forRoot()]
})
.overrideComponent(StepBuildProviderComponent, {
set: {
providers: [
{ provide: DeploymentCenterStateManager, useClass: MockDeploymentCenterStateManager }
]
}
}).compileComponents();
}));

beforeEach(() => {
testFixture = TestBed.createComponent(StepBuildProviderComponent);
buildStepTest = testFixture.componentInstance;
testFixture.detectChanges();
});

describe('init', () => {
it('should create', fakeAsync(() => {
expect(buildStepTest).toBeTruthy();
}));

it('should start with kudu', fakeAsync(() => {
expect(buildStepTest.wizard.wizardValues.buildProvider).toBe('kudu');
}));
it('should change to vsts', fakeAsync(() => {
const vstsCard = testFixture.debugElement.query(By.css('#vsts')).nativeElement;
vstsCard.click();
tick();
expect(buildStepTest.wizard.wizardValues.buildProvider).toBe('vsts');
}));
});
});

@Injectable()
class MockDeploymentCenterStateManager {
public wizardValues = {
buildProvider: 'kudu'
};
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Component } from '@angular/core';
import { ProviderCard } from 'app/site/deployment-center/deployment-center-setup/step-source-control/step-source-control.component';
import { DeploymentCenterStateManager } from 'app/site/deployment-center/deployment-center-setup/wizard-logic/deployment-center-state-manager';
import { TranslateService } from '@ngx-translate/core';
import { PortalResources } from '../../../../shared/models/portal-resources';
import { ProviderCard } from '../../Models/ProviderCard';

@Component({
selector: 'app-step-build-provider',
Expand Down Expand Up @@ -31,9 +31,7 @@ export class StepBuildProviderComponent {
}
];

public selectedProvider: ProviderCard = null;

constructor(public wizard: DeploymentCenterStateManager, private _translateService: TranslateService) {}
constructor(public wizard: DeploymentCenterStateManager, private _translateService: TranslateService) { }

chooseBuildProvider(card: ProviderCard) {
const currentFormValues = this.wizard.wizardValues;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
<div class="settings-group-wrapper">

<h3 class="first-config-heading">Summary</h3>

<div class="settings-wrapper">
<div class="setting-wrapper" *ngFor="let item of summaryItems">
<div class="setting-label">{{item.name}}
</div>
<div class="setting-control-container">
{{item.value}}
</div>
</div>

</div>

<h3 id="step-complete-summary-heading" class="first-config-heading">{{'summary' | translate}}</h3>
<pre>
{{wizard?.wizardValues | json}}
</pre>
</div>
<div class="footer">
<button type="button" class="custom-button form-button" previousStep>{{'back' | translate}}</button>
<button type="button" class="custom-button form-button" (click)="Save()">{{'finish' | translate}}</button>
<button id="step-complete-back-button" type="button" class="custom-button form-button" previousStep>{{'back' | translate}}</button>
<button id="step-complete-finish-button" type="button" class="custom-button form-button" (click)="Save()">{{'finish' | translate}}</button>
<button id="step-complete-show-dashboard-button" type="button" *ngIf="showDashboard" class="custom-button form-button" (click)="ShowDashboard()">{{'showDashboard' | translate}}</button>
</div>

0 comments on commit 63fe2a2

Please sign in to comment.