diff --git a/circle.yml b/circle.yml index 112b236..770c4fd 100644 --- a/circle.yml +++ b/circle.yml @@ -10,7 +10,7 @@ general: dependencies: override: - npm install npm@latest -g - - npm install -g angular-cli@1.0.0-beta.20-4 + - npm install -g git+ssh://git@github.com/AnalogJ/angular-cli.git#AnalogJ-patch-1 - npm install test: diff --git a/package.json b/package.json index af0ed78..0e57592 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,6 @@ "@angular/platform-browser": "~2.1.0", "@angular/platform-browser-dynamic": "~2.1.0", "@angular/router": "~3.1.0", - "angular2-cookie": "^1.2.5", "angular2-infinite-scroll": "^0.2.6", "angular2-jwt": "^0.1.25", "angular2-moment": "^1.0.0-beta.rc.1", @@ -33,7 +32,7 @@ "devDependencies": { "@types/jasmine": "^2.2.30", "@types/node": "^6.0.42", - "angular-cli": "1.0.0-beta.20-4", + "angular-cli": "AnalogJ/angular-cli#AnalogJ-patch-1", "codelyzer": "1.0.0-beta.1", "jasmine-core": "2.4.1", "jasmine-spec-reporter": "2.5.0", diff --git a/src/app/app.module.ts b/src/app/app.module.ts index da33546..f11614b 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -18,7 +18,6 @@ import { ApiService } from './services/api.service' import { CacheService } from './services/cache.service' import { AuthGuard } from './services/auth-guard.service' import { provideAuth } from 'angular2-jwt'; -import { CookieService } from 'angular2-cookie/services/cookies.service'; import {MomentModule} from 'angular2-moment'; import { InfiniteScrollModule } from 'angular2-infinite-scroll'; @@ -61,7 +60,6 @@ import { InfiniteScrollModule } from 'angular2-infinite-scroll'; providers: [ ApiService, CacheService, - CookieService, AuthGuard, provideAuth({ globalHeaders: [{'Content-Type':'application/json'}] diff --git a/src/app/auth-callback/auth-callback.component.ts b/src/app/auth-callback/auth-callback.component.ts index 6bf159d..0eb838d 100644 --- a/src/app/auth-callback/auth-callback.component.ts +++ b/src/app/auth-callback/auth-callback.component.ts @@ -2,7 +2,6 @@ import { Component, OnInit, ViewChild, AfterViewInit } from '@angular/core'; import { ApiService } from '../services/api.service'; import { ActivatedRoute } from '@angular/router'; import { ModalDirective } from 'ng2-bootstrap/ng2-bootstrap'; -import { CookieService } from 'angular2-cookie/core'; import {Router} from '@angular/router' @Component({ @@ -15,7 +14,7 @@ export class AuthCallbackComponent implements AfterViewInit { successfulCallback = true - constructor(private apiService: ApiService, private router: Router, private cookieService:CookieService, private activatedRoute: ActivatedRoute) { } + constructor(private apiService: ApiService, private router: Router, private activatedRoute: ActivatedRoute) { } ngAfterViewInit() { this.childModal.show() @@ -30,7 +29,8 @@ export class AuthCallbackComponent implements AfterViewInit { data => { console.log(data) localStorage.setItem('id_token', data.token) //set the JWT token - this.cookieService.put('CAPSULECD_SERVICE_TYPE',data.service_type) + localStorage.setItem('service_type', data.service_type) + this.router.navigate(['/dashboard']) }, error => console.log(error) diff --git a/src/app/dashboard/dashboard.component.html b/src/app/dashboard/dashboard.component.html index 41dd2ee..2055b53 100644 --- a/src/app/dashboard/dashboard.component.html +++ b/src/app/dashboard/dashboard.component.html @@ -8,6 +8,16 @@

Dashboard

Tonsequat in erat ut, congue bibendum nulla. Suspendisse id pharetra lacus, et hendrerit mi. Praesent at vestibulum tortor. Praesent condimentum efficitur massa pharetra dolor sed.
+ +
+
+ +
{{ alert?.title}}
+ {{ alert?.msg }} +
+
+
+
diff --git a/src/app/dashboard/dashboard.component.ts b/src/app/dashboard/dashboard.component.ts index 22a7f28..6d4b6b9 100644 --- a/src/app/dashboard/dashboard.component.ts +++ b/src/app/dashboard/dashboard.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { Project } from '../models/project' import { ApiService } from '../services/api.service'; +import {Alert} from '../models/alert' @Component({ selector: 'app-dashboard', @@ -15,7 +16,7 @@ export class DashboardComponent implements OnInit { projects: Project[] = []; selectedProject: Project = new Project(); projectPullRequests = [] - + alerts: Alert[] = []; constructor(private apiService: ApiService) { } @@ -27,7 +28,7 @@ export class DashboardComponent implements OnInit { this.selectedProject = this.projects[0] this.getProjectPullRequests() }, - error => console.log(error), + error => this.alerts.push(new Alert('Error retrieving projects', error.message)), () => this.loading.projects = false ) } @@ -39,10 +40,13 @@ export class DashboardComponent implements OnInit { console.log(data); this.projectPullRequests = data; }, - error => console.log(error), + error => this.alerts.push(new Alert('Error retrieving pull requests', error.message)), () => this.loading.pullrequests[this.selectedProject.RepoId] = false ) } + closeAlert(i:number):void { + this.alerts.splice(i, 1); + } showProject(project:Project){ this.selectedProject = project; diff --git a/src/app/models/alert.ts b/src/app/models/alert.ts new file mode 100644 index 0000000..bfc38a1 --- /dev/null +++ b/src/app/models/alert.ts @@ -0,0 +1,16 @@ +const enum AlertType { + failure, + success +} +export class Alert { + type: AlertType = AlertType.failure + title: string = '' + msg: string = '' + closable: boolean = true + + constructor(title: string, msg: string, type?:AlertType) { + this.title = title; + this.msg = msg; + if(type){this.type = type} + } +} diff --git a/src/app/project-create/project-create.component.html b/src/app/project-create/project-create.component.html index eb337cf..e65fb6a 100644 --- a/src/app/project-create/project-create.component.html +++ b/src/app/project-create/project-create.component.html @@ -8,6 +8,16 @@

Create Project

Praesent at vestibulum tortor. Praesent condimentum efficitur massa, nec congue sem dapibus sed. Sed eget justo at erat suscipit tristique sit.
+ +
+
+ +
{{ alert?.title}}
+ {{ alert?.msg }} +
+
+
+
diff --git a/src/app/project-create/project-create.component.ts b/src/app/project-create/project-create.component.ts index b9c11d3..50f54e8 100644 --- a/src/app/project-create/project-create.component.ts +++ b/src/app/project-create/project-create.component.ts @@ -5,6 +5,7 @@ import { AppSettings } from '../app-settings' import {Organization} from "../models/organization"; import {Repository} from "../models/repository"; import {Router} from '@angular/router' +import {Alert} from '../models/alert' @Component({ selector: 'app-project-create', @@ -22,8 +23,10 @@ export class ProjectCreateComponent implements OnInit { fetchOrgRepos: false, createProject: false } + alerts: Alert[] = []; - constructor(private apiService: ApiService, private router: Router) { } + + constructor(private apiService: ApiService, private router: Router) { } ngOnInit() { this.apiService.fetchOrgs() @@ -34,11 +37,14 @@ export class ProjectCreateComponent implements OnInit { this.selectedOrgIndex = 0 this.fetchSelectedOrgRepos() }, - error => console.log(error), + error => this.alerts.push(new Alert('Error retrieving organizations', error.message)), () => this.loading.fetchOrgs = false ); } + closeAlert(i:number):void { + this.alerts.splice(i, 1); + } resetPagination(){ this.orgReposPage = 1; //this is the starting page when retriving repos from the api @@ -56,7 +62,7 @@ export class ProjectCreateComponent implements OnInit { console.log(data) this.orgRepos = data; }, - error => console.log(error), + error => this.alerts.push(new Alert('Error retrieving organization repositories', error.message)), () => this.loading.fetchOrgRepos = false ); } @@ -78,7 +84,7 @@ export class ProjectCreateComponent implements OnInit { this.orgRepos = this.orgRepos.concat(data); } }, - error => console.log(error), + error => this.alerts.push(new Alert('Error retrieving organization repositories', error.message)), () => this.loading.fetchOrgRepos = false ); @@ -109,7 +115,7 @@ export class ProjectCreateComponent implements OnInit { this.router.navigate([`/project/${this.apiService.serviceType()}/${orgId}/${repoId}/edit`]) }, - error => console.log(error), + error => this.alerts.push(new Alert('Error creating new project', error.message)), () => this.loading.createProject = false ); } diff --git a/src/app/project-deploy/project-deploy.component.html b/src/app/project-deploy/project-deploy.component.html index 80dd6a3..5243f02 100644 --- a/src/app/project-deploy/project-deploy.component.html +++ b/src/app/project-deploy/project-deploy.component.html @@ -8,6 +8,16 @@

Create Release

Praesent at vestibulum tortor. Praesent condimentum efficitur massa, nec congue sem dapibus sed. Sed eget justo at erat suscipit tristique sit.
+ +
+
+ +
{{ alert?.title}}
+ {{ alert?.msg }} +
+
+
+
diff --git a/src/app/project-deploy/project-deploy.component.ts b/src/app/project-deploy/project-deploy.component.ts index d57887d..3a3c9a7 100644 --- a/src/app/project-deploy/project-deploy.component.ts +++ b/src/app/project-deploy/project-deploy.component.ts @@ -1,6 +1,7 @@ import { ActivatedRoute } from '@angular/router'; import { Component, OnInit } from '@angular/core'; import { ApiService } from '../services/api.service'; +import {Alert} from '../models/alert' @Component({ @@ -15,6 +16,7 @@ export class ProjectDeployComponent implements OnInit { projectData: any = {}; projectSecrets: any = {}; pullRequest: any = {}; + alerts: Alert[] = []; loading = { project: true, @@ -39,7 +41,7 @@ export class ProjectDeployComponent implements OnInit { this.versionIncr = this.projectData.versionIncr || this.versionIncr }, - error => console.log(error), + error => this.alerts.push(new Alert('Error retrieving project', error.message)), () => this.loading.project = false ); @@ -49,11 +51,13 @@ export class ProjectDeployComponent implements OnInit { console.log(data) this.pullRequest = data }, - error => console.log(error), + error => this.alerts.push(new Alert('Error retrieving pull request', error.message)), () => this.loading.pullRequest = false ); } - + closeAlert(i:number):void { + this.alerts.splice(i, 1); + } createRelease(){ //TODO: this function should also send version increment & custom changelog. this.loading.createRelease = true; @@ -63,7 +67,7 @@ export class ProjectDeployComponent implements OnInit { console.log(data) //todo change path. }, - error => console.log(error), + error => this.alerts.push(new Alert('Error creating new release', error.message)), () => this.loading.createRelease = false ); } diff --git a/src/app/project-edit/project-edit.component.html b/src/app/project-edit/project-edit.component.html index 4c95ce0..eeb83f8 100644 --- a/src/app/project-edit/project-edit.component.html +++ b/src/app/project-edit/project-edit.component.html @@ -8,11 +8,19 @@

Edit {{orgId + '/' + repoId}}

Praesent at vestibulum tortor. Praesent condimentum efficitur massa, nec congue sem dapibus sed. Sed eget justo at erat suscipit tristique sit.
-
-
+
+
+ +
{{ alert?.title}}
+ {{ alert?.msg }} +
+
+
+
+

Project Settings diff --git a/src/app/project-edit/project-edit.component.ts b/src/app/project-edit/project-edit.component.ts index c140d36..6bab5cb 100644 --- a/src/app/project-edit/project-edit.component.ts +++ b/src/app/project-edit/project-edit.component.ts @@ -3,6 +3,7 @@ import { Component, OnInit } from '@angular/core'; import { ApiService } from '../services/api.service'; import { AppSettings } from '../app-settings' import { Observable } from 'rxjs/Observable'; +import {Alert} from '../models/alert' @Component({ selector: 'app-project-edit', @@ -22,6 +23,7 @@ export class ProjectEditComponent implements OnInit { secretName: string = ''; secretValue: string = ''; + alerts: Alert[] = []; loading = { project: true, saveSettings: false, @@ -44,7 +46,7 @@ export class ProjectEditComponent implements OnInit { this.projectSecrets = data.Secrets || this.projectSecrets; this.projectSecretsKeys = Object.keys(this.projectSecrets) }, - error => console.log(error), + error => this.alerts.push(new Alert('Error retrieving project', error.message)), () => this.loading.project = false ); @@ -57,6 +59,9 @@ export class ProjectEditComponent implements OnInit { //TODO: add method to autocomplete docker image lookup //TODO: add help text with common secrets for each image/package type //TODO: add delete method for secrets. + closeAlert(i:number):void { + this.alerts.splice(i, 1); + } packageTypeChanged = function(){ this.projectData.dockerImage = this.defaultSettings[this.projectData.packageType].image @@ -79,7 +84,7 @@ export class ProjectEditComponent implements OnInit { data => { console.log(data) }, - error => console.log(error), + error => this.alerts.push(new Alert('Error updating project', error.message)), () => this.loading.saveSettings = false ); } @@ -98,7 +103,7 @@ export class ProjectEditComponent implements OnInit { this.secretName = ''; this.secretValue = ''; }, - error => console.log(error), + error => this.alerts.push(new Alert('Error updating project secrets', error.message)), () => this.loading.addSecret = false ); } diff --git a/src/app/services/api.service.ts b/src/app/services/api.service.ts index af114d1..72cd4d4 100644 --- a/src/app/services/api.service.ts +++ b/src/app/services/api.service.ts @@ -3,12 +3,11 @@ import { AuthHttp, tokenNotExpired } from 'angular2-jwt'; import { Http, Response, Headers, RequestOptions, URLSearchParams} from '@angular/http'; import { Observable } from 'rxjs/Observable'; import {AppSettings} from '../app-settings'; -import { CookieService } from 'angular2-cookie/core'; import { CacheService } from '../services/cache.service' @Injectable() export class ApiService { - constructor(public authHttp: AuthHttp, private http: Http, private cookieService: CookieService, private cacheService: CacheService) { } + constructor(public authHttp: AuthHttp, private http: Http, private cacheService: CacheService) { } //Helper functions private extractData(res: Response) { @@ -37,8 +36,9 @@ export class ApiService { loggedIn() { return tokenNotExpired(); } - serviceType(){ - return this.cookieService.get('CAPSULECD_SERVICE_TYPE') + serviceType(): string{ + return localStorage.getItem('service_type') + } authConnect(serviceType): Observable { @@ -87,7 +87,7 @@ export class ApiService { } getProject(orgId:string, repoId:string): Observable { - var url = `${AppSettings.API_ENDPOINT}/project/${this.cookieService.get('CAPSULECD_SERVICE_TYPE')}/${orgId}/${repoId}` + var url = `${AppSettings.API_ENDPOINT}/project/${this.serviceType()}/${orgId}/${repoId}` var cacheKey = this.cacheKey('GET', url); return this.cacheService.get(cacheKey) || this.cacheService.put(cacheKey, this.authHttp.get(url) .map(this.extractData) @@ -95,24 +95,24 @@ export class ApiService { } createProject(orgId:string, repoId:string){ - return this.authHttp.post(`${AppSettings.API_ENDPOINT}/project/${this.cookieService.get('CAPSULECD_SERVICE_TYPE')}/${orgId}/${repoId}`, {}) + return this.authHttp.post(`${AppSettings.API_ENDPOINT}/project/${this.serviceType()}/${orgId}/${repoId}`, {}) .map(this.extractData) .catch(this.handleError); } editProject(orgId:string, repoId:string, payload: any): Observable { - return this.authHttp.put(`${AppSettings.API_ENDPOINT}/project/${this.cookieService.get('CAPSULECD_SERVICE_TYPE')}/${orgId}/${repoId}`, payload) + return this.authHttp.put(`${AppSettings.API_ENDPOINT}/project/${this.serviceType()}/${orgId}/${repoId}`, payload) .map(this.extractData) .catch(this.handleError); } deleteProject(orgId:string, repoId:string): Observable { - return this.authHttp.delete(`${AppSettings.API_ENDPOINT}/process/${this.cookieService.get('CAPSULECD_SERVICE_TYPE')}/${orgId}/${repoId}`) + return this.authHttp.delete(`${AppSettings.API_ENDPOINT}/process/${this.serviceType()}/${orgId}/${repoId}`) .map(this.extractData) .catch(this.handleError); } deployProject(orgId:string, repoId:string, prNumber:number, settings?: any): Observable{ - return this.authHttp.post(`${AppSettings.API_ENDPOINT}/process/${this.cookieService.get('CAPSULECD_SERVICE_TYPE')}/${orgId}/${repoId}/${prNumber}`, settings || {}) + return this.authHttp.post(`${AppSettings.API_ENDPOINT}/process/${this.serviceType()}/${orgId}/${repoId}/${prNumber}`, settings || {}) .map(this.extractData) .catch(this.handleError); } @@ -120,7 +120,7 @@ export class ApiService { fetchOrgs(page?:number): Observable{ let params: URLSearchParams = new URLSearchParams(); params.set('page', (page || 0).toString()); - var url = `${AppSettings.API_ENDPOINT}/fetch/${this.cookieService.get('CAPSULECD_SERVICE_TYPE')}/orgs`; + var url = `${AppSettings.API_ENDPOINT}/fetch/${this.serviceType()}/orgs`; var cacheKey = this.cacheKey('GET', url, params); return this.cacheService.get(cacheKey) || this.cacheService.put(cacheKey, this.authHttp.get(url,{ search: params }) @@ -131,7 +131,7 @@ export class ApiService { fetchOrgRepos(orgId:string, page?:number): Observable{ let params: URLSearchParams = new URLSearchParams(); params.set('page', (page || 0).toString()) - var url = `${AppSettings.API_ENDPOINT}/fetch/${this.cookieService.get('CAPSULECD_SERVICE_TYPE')}/orgs/${orgId}/repos` + var url = `${AppSettings.API_ENDPOINT}/fetch/${this.serviceType()}/orgs/${orgId}/repos` var cacheKey = this.cacheKey('GET', url, params); return this.cacheService.get(cacheKey) || this.cacheService.put(cacheKey, this.authHttp.get(url,{ search: params }) @@ -143,7 +143,7 @@ export class ApiService { fetchOrgRepoPullRequests(orgId:string, repoId:string, page?:number): Observable{ let params: URLSearchParams = new URLSearchParams(); params.set('page', (page || 0).toString()) - var url = `${AppSettings.API_ENDPOINT}/fetch/${this.cookieService.get('CAPSULECD_SERVICE_TYPE')}/orgs/${orgId}/repos/${repoId}/pullrequests` + var url = `${AppSettings.API_ENDPOINT}/fetch/${this.serviceType()}/orgs/${orgId}/repos/${repoId}/pullrequests` var cacheKey = this.cacheKey('GET', url, params); return this.cacheService.get(cacheKey) || this.cacheService.put(cacheKey, this.authHttp.get(url,{ search: params }) @@ -152,7 +152,7 @@ export class ApiService { } fetchOrgRepoPullRequest(orgId:string, repoId:string, prNumber:number): Observable{ - var url = `${AppSettings.API_ENDPOINT}/fetch/${this.cookieService.get('CAPSULECD_SERVICE_TYPE')}/orgs/${orgId}/repos/${repoId}/pullrequests/${prNumber}` + var url = `${AppSettings.API_ENDPOINT}/fetch/${this.serviceType()}/orgs/${orgId}/repos/${repoId}/pullrequests/${prNumber}` var cacheKey = this.cacheKey('GET', url); return this.cacheService.get(cacheKey) || this.cacheService.put(cacheKey, this.authHttp.get(url) diff --git a/src/styles.css b/src/styles.css index 461a26b..5e46db7 100644 --- a/src/styles.css +++ b/src/styles.css @@ -94,6 +94,29 @@ -webkit-backface-visibility: hidden; } +/*-------------------------------------------------------------------------------------------------------------------------------*/ +/* All - Alert */ +/*-------------------------------------------------------------------------------------------------------------------------------*/ + +.alert{font-size: 14px; line-height: 24px; position: relative; margin-bottom: 30px; + border-radius:0px; +} +.alert .title { + font-size: 12px; + line-height: 16px; + padding-bottom: 10px; + text-transform: uppercase; + font-family: 'bold'; + position: relative; +} +.alert.alert-0{background: #fbc011; color: rgba(255, 255, 255, 0.8); box-shadow: 3px 4px 10px rgba(0,0,0,.1); padding: 30px;} +.alert.alert-0:before{width: 5px; height: 100%; position: absolute; left: 0; top: 0; content: ""; background: #daa508;} +.alert.alert-1{background: #222; color: #c9c9c9; box-shadow: 3px 4px 10px rgba(0,0,0,.1); padding: 30px;} +.alert.alert-1:before{width: 5px; height: 100%; position: absolute; left: 0; top: 0; content: ""; background: #000;} +.alert.alert-2{background: #fff; border: 5px #fbc011 solid; color: #fbc011; padding: 25px;} +.alert .close{opacity: 90; position: absolute; top: 10px; right: 10px; font-size: 25px; width: 20px; line-height: 20px; text-align: center; cursor: pointer; font-family: 'bold';} + + /*-------------------------------------------------------------------------------------------------------------------------------*/ /* All - Spinner */ /*-------------------------------------------------------------------------------------------------------------------------------*/