diff --git a/src/app/app.module.ts b/src/app/app.module.ts index d2bc8278..edbe9689 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -19,13 +19,11 @@ import { MockAuthenticationService } from './shared/mock-auth.service'; // Imports stackdetailsmodule import { StackDetailsModule } from './stack/stack-details/stack-details.module'; -import { UserIntentModule } from './user-intent/user-intent.module'; @NgModule({ imports: [ BrowserModule, StackDetailsModule, - // UserIntentModule, FormsModule, AppRoutingModule ], diff --git a/src/app/app.routing.ts b/src/app/app.routing.ts index 4893b274..6c4f0065 100644 --- a/src/app/app.routing.ts +++ b/src/app/app.routing.ts @@ -2,12 +2,10 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { AppComponent } from './app.component'; -// import { UserIntentComponent } from './user-intent/user-intent.component'; const routes: Routes = [ { path: 'analyze/:id', component: AppComponent }, - { path: '', component: AppComponent }, - // { path: 'user-intent/:id', component: UserIntentComponent } + { path: '', component: AppComponent } ]; @NgModule({ diff --git a/src/app/stack/stack-report-inshort/stack-report-inshort-component.spec.ts b/src/app/stack/stack-report-inshort/stack-report-inshort-component.spec.ts deleted file mode 100644 index f313e56d..00000000 --- a/src/app/stack/stack-report-inshort/stack-report-inshort-component.spec.ts +++ /dev/null @@ -1,42 +0,0 @@ -import {async, ComponentFixture, TestBed} from '@angular/core/testing'; -import {TabsModule} from 'ngx-bootstrap'; -import {StackReportInShortComponent} from './stack-report-inshort.component'; -import {ChartModule} from '../utils/chart/chart.module'; -import {StackDetailsModule} from '../stack-details/stack-details.module'; -import {StackAnalysesService} from '../stack-analyses.service'; -import {AuthenticationService} from 'ngx-login-client'; -import { MockAuthenticationService } from '../../shared/mock-auth.service'; - -describe ('StackReportInShortComponent', () => { - let component: StackReportInShortComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ - ChartModule, - StackDetailsModule, - TabsModule.forRoot() - ], - providers: [ - StackAnalysesService, - { - provide: AuthenticationService, useClass: MockAuthenticationService - } - ], - declarations: [ - StackReportInShortComponent - ] - }).compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(StackReportInShortComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/stack/stack-report-inshort/stack-report-inshort.component.html b/src/app/stack/stack-report-inshort/stack-report-inshort.component.html deleted file mode 100644 index 6eef5a89..00000000 --- a/src/app/stack/stack-report-inshort/stack-report-inshort.component.html +++ /dev/null @@ -1,125 +0,0 @@ -
-
- - - - -
-
- Components [Total: {{stackLevel && stackLevel.analyzed_dependencies && stackLevel.analyzed_dependencies.length}} components | Analyzed: {{stackLevel && stackLevel.dependencies && stackLevel.dependencies.length}} | Unknown: {{stackLevel && stackLevel.unknown_dependencies && stackLevel.unknown_dependencies.length}}] -
-
-
-
-

- Security Alert -

-
-
-
- {{securityInfo.cve && securityInfo.cve.CVE}} - -
-
-
- {{securityInfo.cve && securityInfo.cve.CVSS}} out of 10 -
-
-
- -
-
-
-
-
No CVEs
-
-
-
-
-
-

- Usage Outliers -

-
-
-
- Components not used together -
-
- {{stackLevelOutliers && stackLevelOutliers.usage && stackLevelOutliers.usage.length}} -
-
-
- All the components in your stack work well with each other -
-
-
-
-
-
-

- Licenses -

-
-
-
- Out of date -
-
- {{licenseOutliers}} -
-
-
-
- Conflicts -
-
- - {{stackLevel && stackLevel.license_analysis && stackLevel.license_analysis.status && stackLevel.license_analysis.status.toLowerCase() === 'stacklicenseconflict' ? 'YES' : 'NO'}} - -
-
-
-
- -
-
-
-
-
-
-
-
- {{recommendations && recommendations.alternate && recommendations.alternate.length}} alternate components match your stack composition and may be more appropriate. -
-
- {{recommendations && recommendations.companion && recommendations.companion.length}} additional components are often used by similar stacks. -
-
-
- - -
-
-
-
-
-
- -
-
-
- {{error.title}} -
-
diff --git a/src/app/stack/stack-report-inshort/stack-report-inshort.component.less b/src/app/stack/stack-report-inshort/stack-report-inshort.component.less deleted file mode 100644 index 91838eaf..00000000 --- a/src/app/stack/stack-report-inshort/stack-report-inshort.component.less +++ /dev/null @@ -1,183 +0,0 @@ -.stack-report-inshort { - .error-class { - position: relative; - margin-top: 100px; - text-align: center; - } - .center-text { - margin: 0 auto; - text-align: center; - } - .active-menu-item { - .nav-link { - &.active { - color: #000; - font-weight: bold; - } - } - } - .pre-loader { - position: absolute; - top: 0; - left: 0; - bottom: 0; - right: 0; - background: rgba(255, 255, 255, .5); - z-index: 99; - .pre-loader-spinner { - top: 50%; - } - } - .stack-report-snippet { - .findings-inshort { - font-size: 12px; - margin: 10px; - } - .summary-inshort { - display: flex; - .stat-box { - display: flex; - flex-direction: column; - height: 150px; - h3 { - background: #ededed; - margin: 0; - height: 40px; - padding: 5px; - flex: 1; - display: flex; - align-items: center; - span { - font-size: 12px; - font-weight: bold; - } - p { - margin: 0 0 0 10px; - font-size: 10px; - } - } - .stat-content { - align-items: center; - display: flex; - flex: 4; - .flex-1 { - flex: 1; - } - .flex-2 { - flex: 2; - } - &.usage-outlier { - flex: 4; - justify-content: center; - padding: 0 10px; - } - &.chart-area { - text-align: center; - flex: 4; - .c3-chart-arcs-title { - font-size: 10px; - } - f8-chart { - margin: 0 auto; - } - } - .metric { - height: 40px; - display: flex; - align-items: center; - font-size: 25px; - color: #8f8f8f; - font-weight: bold; - span { - margin: 0 auto; - } - } - .metric-desc { - font-size: 14px; - } - } - } - &:after { - content: ''; - display: block; - float: none; - clear: both; - } - .width-20 { - width: 20%; - } - .width-40 { - width: 40%; - } - .stat-container { - margin: 10px 5px; - border: 1px solid #ccc; - border-radius: 5px; - flex: 1; - &.outlier-stat { - flex: 2; - } - &.stack-license-stat { - flex: 3; - } - &.security-issues-stat { - .cve-message { - font-size: 12px; - color: #777; - font-weight: 100; - } - .cvss-id { - font-size: 10px; - font-weight: 100; - margin-top: 5px; - i { - font-size: 12px; - cursor: pointer; - color: #ff7f0e; - &.warning-red-color:before { - color: #c00; - } - } - } - .cvss-data { - margin-top: 10px; - &>div { - position: relative; - .cvss-score { - font-size: 12px; - font-weight: 100; - } - .cvss-score-label { - font-size: 12px; - font-weight: 100; - bottom: 6px; - .label-1 { - font-size: 12px; - } - } - } - } - .progress-bar { - cursor: pointer; - } - } - align-items: stretch; - } - } - .recommendations-inshort { - .recommendation-components { - &:before { - content: ''; - width: 10px; - height: 10px; - display: inline-block; - background: #000; - margin-left: 5px; - } - } - } - } - .show-full-report { - margin: 10px 0 10px 10px; - } -} diff --git a/src/app/stack/stack-report-inshort/stack-report-inshort.component.ts b/src/app/stack/stack-report-inshort/stack-report-inshort.component.ts deleted file mode 100644 index de43a239..00000000 --- a/src/app/stack/stack-report-inshort/stack-report-inshort.component.ts +++ /dev/null @@ -1,248 +0,0 @@ -import {Component, Input, OnChanges, ViewEncapsulation} from '@angular/core'; -import {Observable} from 'rxjs/Observable'; -import {StackAnalysesService} from '../stack-analyses.service'; -import {getStackReportModel} from '../utils/stack-api-utils'; - -import {StackReportModel, ResultInformationModel, UserStackInfoModel, RecommendationsModel, ComponentInformationModel} from '../models/stack-report.model'; - -@Component({ - selector: 'stack-report-inshort', - providers: [StackAnalysesService], - encapsulation: ViewEncapsulation.None, - styleUrls: ['./stack-report-inshort.component.less'], - templateUrl: './stack-report-inshort.component.html' -}) - -export class StackReportInShortComponent implements OnChanges { - @Input() stackUrl; - @Input() repoInfo; - @Input() buildNumber; - @Input() appName; - - public tabs: Array = []; - public result: StackReportModel; - public stackLevel: UserStackInfoModel; - public recommendations: RecommendationsModel; - public licenseInfo: any; - public securityInfo: any; - public stackLevelOutliers: any; - public dataLoaded: boolean = false; - public error: any; - public licenseOutliers: number = 0; - - private cache: string = ''; - - constructor(private stackAnalysisService: StackAnalysesService) {} - - ngOnChanges(): void { - if (this.stackUrl && this.stackUrl !== this.cache) { - this.cache = this.stackUrl; - this.dataLoaded = false; - this.stackAnalysisService - .getStackAnalyses(this.stackUrl) - .subscribe((data) => { - if (data && (!data.hasOwnProperty('error') && Object.keys(data).length !== 0)) { - let resultInformation: Observable = getStackReportModel(data); - if (resultInformation) { - resultInformation.subscribe((response) => { - this.result = response; - this.buildReportInShort(); - }); - } - } else { - // Handle Errors here 'API error' - this.handleError({ - title: data.error - }); - } - }, error => { - // Handle server errors here - this.handleError({ - title: 'Something unexpected happened' - }); - }); - } else { - - } - } - - public handleError(error: any): void { - this.error = error; - this.dataLoaded = true; - } - - public tabSelection(tab: any): void { - tab['active'] = true; - let currentIndex: number = tab['index']; - this.stackLevel = tab.content.user_stack_info; - this.recommendations = tab.content.recommendation; - if (this.recommendations) { - this.stackLevelOutliers = { - 'usage': this.recommendations.usage_outliers - }; - } - this.handleLicenseInformation(this.stackLevel); - this.handleSecurityInformation(this.stackLevel); - } - - private sortChartColumnData(array: Array>): Array> { - return array.sort((a, b) => { - if (a[1] === b[1]) { - return 0; - } - return a[1] > b[1] ? -1 : 1; - }); - } - - private handleSecurityInformation(tab: UserStackInfoModel): void { - let dependencies: Array = tab.dependencies; - let security: Array = []; - let temp: Array = []; - - dependencies.forEach((dependency) => { - security = dependency.security; - if (security.length > 0) { - let max: any = security.reduce((a, b) => { - return parseFloat(a['CVSS']) < parseFloat(b['CVSS']) ? b : a; - }); - temp.push({ - name: dependency.name, - cve: max - }); - } - }); - if (temp.length > 0) { - let final: any = temp.reduce((a, b) => { - return parseFloat(a['cve']['CVSS']) < parseFloat(b['cve']['CVSS']) ? b : a; - }); - let cvssValue: number = final.cve.CVSS; - let indicator: number; - let iconClass: string = 'fa fa-shield'; - let displayClass: string = 'progress-bar-warning'; - - if (cvssValue < 0) { - indicator = -1; - } - if (cvssValue >= 7.0) { - indicator = cvssValue; - iconClass = 'fa fa-shield'; - displayClass = 'progress-bar-danger'; - } - this.securityInfo = { - name: final.name, - cve: final.cve, - percentage: final.cve.CVSS * 10, - status: final.cve.CVSS < 7 ? 'moderate' : 'critical', - iconClass: iconClass, - displayClass: displayClass - }; - } - } - - private handleLicenseInformation(tab: UserStackInfoModel): void { - - let licenses: any = {}; - let columnData: Array> = []; - let columnDataLength: number = 0; - let otherLicensesArray: Array = []; - let otherLicensesRatio: any = 0; - - let temp: Array = []; - this.licenseOutliers = 0; - tab.dependencies.forEach((t) => { - t.licenses.forEach((license) => { - if (!licenses[license]) { - licenses[license] = 1; - } else { - ++ licenses[license]; - } - }); - if (t.license_analysis && t.license_analysis.status && t.license_analysis.status.toLowerCase() === 'unknown') { - ++ this.licenseOutliers; - } - }); - for (let i in licenses) { - if (licenses.hasOwnProperty(i)) { - // Push names and count to be in this structure ['Name', 20] for C3 - temp = []; - temp.push(i); - temp.push(licenses[i]); - columnData.push(temp); - } - } - // sort the data array by license count - columnData = this.sortChartColumnData(columnData); - columnDataLength = columnData ? columnData.length : 0; - if (columnDataLength > 4) { - for (let i = 3; i < columnDataLength; i++) { - otherLicensesArray.push(columnData[i][0]); - otherLicensesRatio += columnData[i][1]; - } - columnData.splice(4); - columnData[3][0] = 'Others'; - columnData[3][1] = otherLicensesRatio; - } - this.licenseInfo = { - data: { - columns: columnData, - type: 'donut', - labels: false - }, - chartOptions: { - size: { - height: 100, - width: 100 - }, - donut: { - width: 13, - label: { - show: false - }, - title: columnDataLength + ' Licenses' - } - }, - configs: { - legend: { - show: false - }, - tooltip: { - format: { - name: (name, ratio, id, index) => { - if (name === 'Others') { - return otherLicensesArray.toString(); - } - return name; - }, - value: (value, ratio, id, index) => { - return (ratio * 100).toFixed(2) + '%'; - } - } - } - } - }; - } - - private resetFields(): void { - this.securityInfo = null; - this.stackLevelOutliers = null; - this.stackLevel = null; - } - - private buildReportInShort(): void { - this.resetFields(); - let resultInformation: Array = this.result.result; - if (resultInformation && resultInformation.length > 0) { - resultInformation.forEach((one: ResultInformationModel, index: number) => { - this.tabs[index] = { - title: one.manifest_file_path, - content: one, - index: index - }; - }); - if (this.tabs[0]) this.tabs[0]['active'] = true; - this.tabSelection(this.tabs[0]); - this.dataLoaded = true; - this.error = null; - } - } -} diff --git a/src/app/stack/stack-report-inshort/stack-report-inshort.module.ts b/src/app/stack/stack-report-inshort/stack-report-inshort.module.ts deleted file mode 100644 index 1badf666..00000000 --- a/src/app/stack/stack-report-inshort/stack-report-inshort.module.ts +++ /dev/null @@ -1,20 +0,0 @@ -import {NgModule} from '@angular/core'; -import {CommonModule} from '@angular/common'; - -import {TabsModule} from 'ngx-bootstrap'; -import {ChartModule} from '../utils/chart/chart.module'; -import {StackDetailsModule} from '../stack-details/stack-details.module'; -import {StackReportInShortComponent} from './stack-report-inshort.component'; - -@NgModule({ - imports: [ - CommonModule, - ChartModule, - StackDetailsModule, - TabsModule.forRoot() - ], - declarations: [StackReportInShortComponent], - exports: [StackReportInShortComponent] -}) - -export class StackReportInShortModule {} diff --git a/src/app/stack/utils/chart/chart-component.ts b/src/app/stack/utils/chart/chart-component.ts deleted file mode 100644 index ddf1557d..00000000 --- a/src/app/stack/utils/chart/chart-component.ts +++ /dev/null @@ -1,163 +0,0 @@ -import { - Component, - ElementRef, - ViewEncapsulation -} from '@angular/core'; - -import * as c3 from 'c3'; -// require('../../node_modules/c3/c3'); - -/** - * - * This chart uses C3 for generating and rendering charts. - * - * Minimum Requirements: - * C3, D3 (As C3 internally uses D3) - * - * Usage: - * eg.) - * - * 1. MultiLine chart takes the parameters - * a. data of c3 configuration - */ -@Component({ - selector: 'f8-chart', - template: ``, - encapsulation: ViewEncapsulation.None, - inputs: ['data', 'chartOptions', 'configs'], - styles: [ - `.ng2-c3 { - display:block; // This is required for proper positioning of tooltip - } - ` - ] -}) -export class ChartComponent { - - // All Inputs for this component declaration - private data: any; // Configuration for series to be used for generating C3 has to be here - private chartOptions: any; - // Includes all the configurations for the chart and also individual chart configurations - private element: HTMLElement; // Element to which the chart has to be attached to - private configs: any; - - // Below configs have been captured from C3 Reference Doc's Need - // to be updated if in case c3 includes new options - private c3Configs: Array = [ - 'axis', - 'tooltip', - 'grid', - 'legend', - 'zoom', - 'regions', - 'subchart' - ]; - - /** - * Below options have been captured from C3 Reference Doc's - * This doesnot include call back methods those options would be captured seperately - */ - private c3Options: Array = [ - 'size', - 'padding', - 'color', - 'interaction', - 'transition', - 'point', - 'line', - 'area', - 'bar', - 'pie', - 'donut', - 'gauge', - 'oninit', - 'onrendered', - 'onmouseover', - 'onmouseout', - 'onresize', - 'onresized' - ]; - - - constructor(elementReference: ElementRef) { - this.element = elementReference.nativeElement; - // Adding the below line to specify CSS for the ng2-c3 selector - this.element.className += ' ng2-c3'; - } - - // Checks for the changes made in the data and re-renders the charts accordingly - public ngOnChanges(): void { - try { - this.__render(this.data, this.chartOptions, this.configs); - } catch (err) { - console.log(err); - } - } - - private __render(inputData: any, chartOptionsData: any, chartConfigsData: any): void { - let _this: ChartComponent = this; - if (this.isValid(inputData)) { - - let c3InputData: any = {}; - - c3InputData['bindto'] = _this.element; - c3InputData['data'] = inputData; - - - /** - * Options for the charts provided - * Options listed like axis, tooltip, grid, legend, zoom , point - * Individual options are parsed and set in c3InputData Json - * to be provided to c3 - */ - if (this.isValid(chartConfigsData)) { - this.updateIfValidInput(chartConfigsData, c3InputData, this.c3Configs); - } - - /* - * Chart Configuration could have multiple Options - * Size, padding, color Pattern, Transition - * Some callback initializers like OnInit, Onrendered, OnMouseOver, OnMouseOut - * - */ - - if (this.isValid(chartOptionsData)) { - this.updateIfValidInput(chartOptionsData, c3InputData, this.c3Options); - } - - /** - * Should find a way to check for proper inputs - * if(!this.isValidInput(c3InputData)) { - * throw new Error('Invalid Configuration passed'); - * } - * - */ - c3.generate(c3InputData); - // Generates the C3 chart for the given configuration - // and places it inside the directive's element. - } - - } - - // A utility method to check if a provided value is valid - private isValid(randomInput: any): boolean { - return randomInput !== undefined && randomInput !== null; - } - - /** - * A utility method to traverse through teh input map, checks with the given config - * Updates the output map if input is present in config - * skips the field if the given input is not present in config map - * - */ - private updateIfValidInput(inputMap: any, outputMap: any, config: Array) { - for (let key in inputMap) { - if (inputMap.hasOwnProperty(key)) { - let isValidOption = config.indexOf(key); - if (isValidOption >= 0) { - outputMap[key] = inputMap[key]; - } - } - } - } -} diff --git a/src/app/stack/utils/chart/chart.module.ts b/src/app/stack/utils/chart/chart.module.ts deleted file mode 100644 index 7fad3281..00000000 --- a/src/app/stack/utils/chart/chart.module.ts +++ /dev/null @@ -1,13 +0,0 @@ -import {NgModule} from '@angular/core'; - -import {ChartComponent} from './chart-component'; - -@NgModule({ - declarations: [ - ChartComponent - ], - exports: [ - ChartComponent - ] -}) -export class ChartModule {} diff --git a/src/app/stack/utils/sentiment/sentiment.component.html b/src/app/stack/utils/sentiment/sentiment.component.html deleted file mode 100644 index d43d0288..00000000 --- a/src/app/stack/utils/sentiment/sentiment.component.html +++ /dev/null @@ -1 +0,0 @@ -
diff --git a/src/app/stack/utils/sentiment/sentiment.component.scss b/src/app/stack/utils/sentiment/sentiment.component.scss deleted file mode 100644 index ba88ac35..00000000 --- a/src/app/stack/utils/sentiment/sentiment.component.scss +++ /dev/null @@ -1,11 +0,0 @@ -.sentiment { - width: 20px; - height: 20px; - margin: 0 auto; - &:after { - content: ''; - display: block; - float: none; - clear: both; - } -} diff --git a/src/app/stack/utils/sentiment/sentiment.component.ts b/src/app/stack/utils/sentiment/sentiment.component.ts deleted file mode 100644 index c0aa17bb..00000000 --- a/src/app/stack/utils/sentiment/sentiment.component.ts +++ /dev/null @@ -1,46 +0,0 @@ -import {Component, Input, OnChanges} from '@angular/core'; - -@Component({ - selector: 'sentiment', - templateUrl: './sentiment.component.html', - styleUrls: ['sentiment.component.scss'] -}) -export class SentimentComponent implements OnChanges { - @Input() score: number; - public metric: any = {}; - public gaugeChart: any = {}; - - private threshold: any = { - start: -0.3, - end: 0.3 - }; - - private sentimentColors: any = { - 'SAD': 'cf2a0e', - 'HAPPY': '368a55', - 'NORMAL': 'bdcf0e' - }; - - ngOnChanges(): void { - if (this.score) { - this.metric['feeling'] = this.getStatus(this.score); - } - } - - public getSentimentWidth(): string { - if (this.score === 0) return '50%'; - if (this.score < 0) return (50 - (-1 * this.score * 10 * 5)) + '%'; - return (50 + (this.score * 10 * 5)) + '%'; - } - - public getSentimentBackground(): string { - return '#' + this.sentimentColors[this.getStatus(this.score)] || '000'; - } - - getStatus(score: any): string { - score = Number(score); - if (score < this.threshold['start']) return 'SAD'; - if (score > this.threshold['end']) return 'HAPPY'; - return 'NORMAL'; - } -} diff --git a/src/app/stack/utils/sentiment/sentiment.module.ts b/src/app/stack/utils/sentiment/sentiment.module.ts deleted file mode 100644 index 366657f9..00000000 --- a/src/app/stack/utils/sentiment/sentiment.module.ts +++ /dev/null @@ -1,17 +0,0 @@ -import {NgModule} from '@angular/core'; -import {CommonModule} from '@angular/common'; - -import {SentimentComponent} from './sentiment.component'; - -@NgModule({ - imports: [ - CommonModule - ], - declarations: [ - SentimentComponent - ], - exports: [ - SentimentComponent - ] -}) -export class SentimentModule {} diff --git a/src/app/stack/utils/trigger-filter/trigger-filter.component.html b/src/app/stack/utils/trigger-filter/trigger-filter.component.html deleted file mode 100644 index 7616a617..00000000 --- a/src/app/stack/utils/trigger-filter/trigger-filter.component.html +++ /dev/null @@ -1,3 +0,0 @@ - - {{message}} - diff --git a/src/app/stack/utils/trigger-filter/trigger-filter.component.scss b/src/app/stack/utils/trigger-filter/trigger-filter.component.scss deleted file mode 100644 index 9497a7ed..00000000 --- a/src/app/stack/utils/trigger-filter/trigger-filter.component.scss +++ /dev/null @@ -1,4 +0,0 @@ -.filter-by { - display: inline-block; - color: #0088ce; -} diff --git a/src/app/stack/utils/trigger-filter/trigger-filter.component.ts b/src/app/stack/utils/trigger-filter/trigger-filter.component.ts deleted file mode 100644 index 8b0d229f..00000000 --- a/src/app/stack/utils/trigger-filter/trigger-filter.component.ts +++ /dev/null @@ -1,23 +0,0 @@ -import {Component, Input, Output, EventEmitter, OnChanges} from '@angular/core'; - -@Component({ - selector: 'trigger-filter', - templateUrl: './trigger-filter.component.html', - styleUrls: ['./trigger-filter.component.scss'], -}) -export class TriggerFilterComponent implements OnChanges { - @Input() message: string; - @Input() filterBy: string; - - @Output() filter: EventEmitter = new EventEmitter(); - - ngOnChanges(): void { - - } - - handleClick(): void { - this.filter.emit({ - filterBy: this.filterBy - }); - } -} diff --git a/src/app/user-intent/user-intent-view/user-intent-view.component.html b/src/app/user-intent/user-intent-view/user-intent-view.component.html deleted file mode 100644 index ab23db6c..00000000 --- a/src/app/user-intent/user-intent-view/user-intent-view.component.html +++ /dev/null @@ -1,49 +0,0 @@ -
-
-
-
-
-
-
-

Your stack is being analyzed...

-

Meanwhile, can you help us improve our recommendations by providing appropriate tags for this component

-
-
- - {{modelContent.artifactId}} -
- -
- - {{modelContent.groupId}} -
- -
- - {{modelContent.name}} -
- -
- -
- - - - -
- -
- -
- - View stack report - -
-
-
-
-
-
-
diff --git a/src/app/user-intent/user-intent-view/user-intent-view.component.less b/src/app/user-intent/user-intent-view/user-intent-view.component.less deleted file mode 100644 index fd615b77..00000000 --- a/src/app/user-intent/user-intent-view/user-intent-view.component.less +++ /dev/null @@ -1,32 +0,0 @@ -.launch-pad { - margin: 1% auto; - margin-bottom: 1%; -} - -.user-intent-row { - text-align: center; -} - -.btn-ctrls { - padding: 20px; -} - -.form-user-intent { - padding: 10px; -} - -.ng2-dropdown-menu { - z-index: 99999; -} - -.user-intent-desp { - font-size: 15px; - color: #aaa; -} - -.user-intent-box { - border: 1px solid #ccc; - margin-top: 10%; - margin-bottom: 10%; - box-shadow: 10px 5px 30px 5px #aaa; -} diff --git a/src/app/user-intent/user-intent-view/user-intent-view.component.ts b/src/app/user-intent/user-intent-view/user-intent-view.component.ts deleted file mode 100644 index 69baf669..00000000 --- a/src/app/user-intent/user-intent-view/user-intent-view.component.ts +++ /dev/null @@ -1,125 +0,0 @@ -import { Component,Input, OnInit } from '@angular/core'; -import { ActivatedRoute, ParamMap, Router } from '@angular/router'; -import { Observable } from 'rxjs/Observable'; - -import { UserIntentService } from '../user-intent.service'; - -@Component({ - selector: 'f8-user-intent-view', - templateUrl: './user-intent-view.component.html', - providers: [UserIntentService], - styleUrls: ['./user-intent-view.component.less'] -}) - -export class UserIntentViewComponent implements OnInit { - @Input() gatewayConfig; - - public masterTagList:any; - public modelContent:any = {}; - public addedTags:any; - - constructor(private route: Router, private userIntentService: UserIntentService) { - window.onhashchange = () => { - this.onAppLoad(); - }; - } - - onAppLoad(): void { - this.addedTags = []; - this.addMasterTagList(); - this.getUnknownComponentEcosystem(); - } - - - ngOnInit(): void { - this.onAppLoad(); - } - - addMasterTagList(): void { - let masterTagListData: Observable = this.userIntentService - .getMasterTagList('maven', this.gatewayConfig); - - if (masterTagListData) { - masterTagListData.subscribe((data) => { - if(data && data.hasOwnProperty("tag_list") && data.tag_list.length){ - this.masterTagList = data.tag_list; - console.log("successfully fetched master taglist") - } else{ - console.log("master taglist is not proper"); - } - }, - error => { - console.log("something unexpected happened while fetching master taglist"); - }); - } - } - - getUnknownComponentEcosystem(): void { - let nextCompToTagData: Observable = this.userIntentService - .getNextComponent('maven', this.gatewayConfig); - - if (nextCompToTagData) { - nextCompToTagData.subscribe((data) => { - if(data){ - let compData = data.split(":"); - this.modelContent["artifactId"] = compData[0]; - this.modelContent["groupId"] = compData[1]; - this.modelContent["name"] = data; - console.log("successfully fetched next component") - } else{ - console.log("Next component is not proper"); - } - }, - error => { - console.log("something unexpected happened while fetching next component"); - }); - } - } - - addTagComponent(): void { - let userIntentData: any = { - "ecosystem": "maven", - "component": "", - "tags": [] - }; - for(var i =0;i = this.userIntentService - .submitUserIntent(userIntentData, this.gatewayConfig); - - if (setTagUserIntentData) { - setTagUserIntentData.subscribe((data) => { - if(data){ - console.log("successfully set tags"); - this.moveStackReport(); - } else{ - console.log("Looks like tags are not proper"); - } - }, - error => { - console.log("something unexpected happened while setting tags"); - }); - } - } - - moveStackReport(ev?:Event): void { - if(ev){ - ev.preventDefault(); - } - let api_data: any = {}; - if(this.gatewayConfig){ - api_data["access_token"] = this.gatewayConfig.access_token; - api_data["route_config"] = this.gatewayConfig.config; - let api_param = this.gatewayConfig.stack_id +"?"+ JSON.stringify(api_data); - console.log("move to stack report!!"+ api_param); - this.route.navigate(['/analyze/' + this.gatewayConfig.stack_id] ,{ queryParams: {api_data: JSON.stringify(api_data) }}); - } - } - -} diff --git a/src/app/user-intent/user-intent.component.html b/src/app/user-intent/user-intent.component.html deleted file mode 100644 index 394fd9f2..00000000 --- a/src/app/user-intent/user-intent.component.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/app/user-intent/user-intent.component.less b/src/app/user-intent/user-intent.component.less deleted file mode 100644 index fe637c93..00000000 --- a/src/app/user-intent/user-intent.component.less +++ /dev/null @@ -1,8 +0,0 @@ -.launch-pad { - margin: 1% auto; - margin-bottom: 1%; -} - -.ng2-dropdown-menu { - z-index: 9999; -} diff --git a/src/app/user-intent/user-intent.component.ts b/src/app/user-intent/user-intent.component.ts deleted file mode 100644 index a9fe829a..00000000 --- a/src/app/user-intent/user-intent.component.ts +++ /dev/null @@ -1,94 +0,0 @@ -import { Component, OnInit, ViewEncapsulation } from '@angular/core'; -import { ActivatedRoute, ParamMap } from '@angular/router'; - -@Component({ - selector: 'f8-user-intent', - templateUrl: './user-intent.component.html', - encapsulation: ViewEncapsulation.None, - styleUrls: ['./user-intent.component.less'] -}) - -export class UserIntentComponent implements OnInit { - public stackUrl: string; - public apiData: any = {}; - public gateway: any = {}; - public label: string; - public tokenApi: string; - public routerLink: string; - - constructor(private route: ActivatedRoute) { - this.route.paramMap.subscribe((params) => { - this.label = params.get('id'); - }); - window.onhashchange = () => { - let url: string = location.hash; - let id: string = url.replace('#/user-intent/', ''); - let splitParams: Array = id.split('?'); - this.label = splitParams[0]; - this.onAppLoad(); - }; - } - - onAppLoad(): void { - let url: string = location.hash; - let id: string = url.replace('#/user-intent/', ''); - let splitParams: Array = id.split('?'); - if (splitParams && splitParams.length > 1) { - this.apiData = decodeURIComponent(splitParams[1].split('api_data=')[1]); - try { - this.apiData = JSON.parse(this.apiData); - } catch (err) { - console.log('Error parsing JSON'); - } - if (this.apiData) { - this.changeLabel(); - } - } - } - - changeLabel(): void { - console.log(this.label); - if (this.label && this.label.trim() !== '') { - this.routerLink = '/user-intent/' + this.label; - // this.gateway['user_key'] = this.apiData['user_key']; - this.gateway['access_token'] = this.apiData['access_token']; - this.gateway['config'] = this.apiData['route_config']; - this.gateway['stack_id'] = this.label - if(this.apiData['show_modal']){ - this.gateway['modal'] = this.apiData['show_modal']; - } - - // { - // "route_config": { - // "api_url": "" - // } - // } - - // In case of 3 scale - // { - // "route_config": { - // "api_url": "", - // "user_key": "" - // } - // } - if (this.gateway['config'] && this.gateway['config']['api_url']) { - let apiHost: string = this.gateway['config']['api_url']; - if (apiHost.charAt(apiHost.length - 1) !== '/') { - apiHost += '/'; - this.gateway['config']['api_url'] = apiHost; - } - this.stackUrl = apiHost + 'api/v1/stack-analyses/' + this.label; - console.log('========================='); - console.log(this.gateway); - console.log(this.stackUrl); - console.log('========================='); - } - } - } - - ngOnInit(): void { - this.onAppLoad(); - } - - -} diff --git a/src/app/user-intent/user-intent.module.ts b/src/app/user-intent/user-intent.module.ts deleted file mode 100644 index b995c735..00000000 --- a/src/app/user-intent/user-intent.module.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { HttpModule } from '@angular/http'; -import { FormsModule } from '@angular/forms'; -import { TagInputModule } from 'ngx-chips'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; // this is needed! - - -import { UserIntentComponent } from './user-intent.component'; -import { UserIntentViewComponent } from './user-intent-view/user-intent-view.component'; - -@NgModule({ - imports: [ - CommonModule, - HttpModule, - FormsModule, - TagInputModule, - BrowserAnimationsModule - ], - declarations: [ - UserIntentComponent, - UserIntentViewComponent - ], - exports: [ - UserIntentComponent - ], - providers: [ ], - schemas: [CUSTOM_ELEMENTS_SCHEMA] -}) - -export class UserIntentModule { - constructor() {} -} diff --git a/src/app/user-intent/user-intent.service.ts b/src/app/user-intent/user-intent.service.ts deleted file mode 100644 index a01c5a55..00000000 --- a/src/app/user-intent/user-intent.service.ts +++ /dev/null @@ -1,98 +0,0 @@ -import { Injectable } from '@angular/core'; -import { Http, Response, Headers, RequestOptions } from '@angular/http'; -import { Observable } from 'rxjs/Observable'; -import 'rxjs/add/operator/catch'; -import 'rxjs/add/operator/map'; - -@Injectable() -export class UserIntentService { - constructor(private http: Http) {} - - /** - * @method POST - * @description save user tags for a component - */ - public submitUserIntent(userIntentData: any, params?: any): Observable { - let url: string = 'api/v1/set-tags'; - if (params) { - if (params['access_token']) { - if (params['config'] && params['config']['api_url']) { - url = params['config']['api_url'] + url; - let headers: Headers = new Headers({'Content-Type': 'application/json'}); - headers.append('Authorization', 'Bearer ' + params['access_token']); - return this.http - .post(url, JSON.stringify(userIntentData), { - headers: headers - }) - .map(this.extractData) - .catch(this.handleError); - } - } - } - } - - /** - * @method GET - * @description get unknown component to be tagged - */ - public getNextComponent(ecosystem: any, params?: any): Observable { - let url: string = 'api/v1/get-next-component'; - if (params) { - if (params['access_token']) { - if (params['config'] && params['config']['api_url']) { - url = params['config']['api_url'] + url; - let headers: Headers = new Headers(); - headers.append('Authorization', 'Bearer ' + params['access_token']); - return this.http - .post(url+"/"+ecosystem, null, { - headers:headers - }) - .map(this.extractData) - .catch(this.handleError); - } - } - } - } - - /** - * @method GET - * @description get master taglist for ecosystem - */ - public getMasterTagList(ecosystem: any, params?: any): Observable { - let url: string = 'api/v1/master-tags'; - if (params) { - if (params['access_token']) { - if (params['config'] && params['config']['api_url']) { - url = params['config']['api_url'] + url; - let headers: Headers = new Headers({'Content-Type': 'application/json'}); - headers.append('Authorization', 'Bearer ' + params['access_token']); - return this.http - .get(url+"/"+ecosystem, { - headers:headers - }) - .map(this.extractData) - .catch(this.handleError); - } - } - } - } - - private extractData(res: Response) { - let body = res.json(); - return body || {}; - } - - private handleError(error: Response | any) { - // In a real world app, we might use a remote logging infrastructure - let errMsg: string; - if (error instanceof Response) { - const body = error.json() || ''; - const err = body.error || JSON.stringify(body); - errMsg = `${error.status} - ${error.statusText || ''} ${err}`; - } else { - errMsg = error.message ? error.message : error.toString(); - } - console.error(errMsg); - return Observable.throw(errMsg); - } -}