Skip to content

Commit 4979c45

Browse files
committed
added alert support to all panels. Removed cookieservice (angular2-cookie). Storing service_type inside localStorage. Using my branch of angular-cli until angular/angular-cli#3201 is merged.
1 parent 13bacbe commit 4979c45

15 files changed

+131
-38
lines changed

circle.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ general:
1010
dependencies:
1111
override:
1212
- npm install npm@latest -g
13-
- npm install -g angular-cli@1.0.0-beta.20-4
13+
- npm install -g git+ssh://[email protected]/AnalogJ/angular-cli.git#AnalogJ-patch-1
1414
- npm install
1515

1616
test:

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"@angular/platform-browser": "~2.1.0",
2121
"@angular/platform-browser-dynamic": "~2.1.0",
2222
"@angular/router": "~3.1.0",
23-
"angular2-cookie": "^1.2.5",
2423
"angular2-infinite-scroll": "^0.2.6",
2524
"angular2-jwt": "^0.1.25",
2625
"angular2-moment": "^1.0.0-beta.rc.1",
@@ -33,7 +32,7 @@
3332
"devDependencies": {
3433
"@types/jasmine": "^2.2.30",
3534
"@types/node": "^6.0.42",
36-
"angular-cli": "1.0.0-beta.20-4",
35+
"angular-cli": "AnalogJ/angular-cli#AnalogJ-patch-1",
3736
"codelyzer": "1.0.0-beta.1",
3837
"jasmine-core": "2.4.1",
3938
"jasmine-spec-reporter": "2.5.0",

src/app/app.module.ts

-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { ApiService } from './services/api.service'
1818
import { CacheService } from './services/cache.service'
1919
import { AuthGuard } from './services/auth-guard.service'
2020
import { provideAuth } from 'angular2-jwt';
21-
import { CookieService } from 'angular2-cookie/services/cookies.service';
2221
import {MomentModule} from 'angular2-moment';
2322
import { InfiniteScrollModule } from 'angular2-infinite-scroll';
2423

@@ -61,7 +60,6 @@ import { InfiniteScrollModule } from 'angular2-infinite-scroll';
6160
providers: [
6261
ApiService,
6362
CacheService,
64-
CookieService,
6563
AuthGuard,
6664
provideAuth({
6765
globalHeaders: [{'Content-Type':'application/json'}]

src/app/auth-callback/auth-callback.component.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Component, OnInit, ViewChild, AfterViewInit } from '@angular/core';
22
import { ApiService } from '../services/api.service';
33
import { ActivatedRoute } from '@angular/router';
44
import { ModalDirective } from 'ng2-bootstrap/ng2-bootstrap';
5-
import { CookieService } from 'angular2-cookie/core';
65
import {Router} from '@angular/router'
76

87
@Component({
@@ -15,7 +14,7 @@ export class AuthCallbackComponent implements AfterViewInit {
1514

1615
successfulCallback = true
1716

18-
constructor(private apiService: ApiService, private router: Router, private cookieService:CookieService, private activatedRoute: ActivatedRoute) { }
17+
constructor(private apiService: ApiService, private router: Router, private activatedRoute: ActivatedRoute) { }
1918

2019
ngAfterViewInit() {
2120
this.childModal.show()
@@ -30,7 +29,8 @@ export class AuthCallbackComponent implements AfterViewInit {
3029
data => {
3130
console.log(data)
3231
localStorage.setItem('id_token', data.token) //set the JWT token
33-
this.cookieService.put('CAPSULECD_SERVICE_TYPE',data.service_type)
32+
localStorage.setItem('service_type', data.service_type)
33+
3434
this.router.navigate(['/dashboard'])
3535
},
3636
error => console.log(error)

src/app/dashboard/dashboard.component.html

+10
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ <h2 class="title">Dashboard</h2>
88
<div class="description">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.</div>
99
</div>
1010
</div>
11+
12+
<div class="row">
13+
<div class="col-lg-10 col-lg-offset-1">
14+
<alert *ngFor="let alert of alerts;let i = index" [type]="alert.type" dismissible="true" (close)="closeAlert(i)">
15+
<div class="title">{{ alert?.title}}</div>
16+
{{ alert?.msg }}
17+
</alert>
18+
</div>
19+
</div>
20+
1121
<div class="row">
1222
<div class="col-md-3" style="margin-bottom: 50px;">
1323

src/app/dashboard/dashboard.component.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Component, OnInit } from '@angular/core';
22
import { Project } from '../models/project'
33
import { ApiService } from '../services/api.service';
4+
import {Alert} from '../models/alert'
45

56
@Component({
67
selector: 'app-dashboard',
@@ -15,7 +16,7 @@ export class DashboardComponent implements OnInit {
1516
projects: Project[] = [];
1617
selectedProject: Project = new Project();
1718
projectPullRequests = []
18-
19+
alerts: Alert[] = [];
1920

2021
constructor(private apiService: ApiService) { }
2122

@@ -27,7 +28,7 @@ export class DashboardComponent implements OnInit {
2728
this.selectedProject = this.projects[0]
2829
this.getProjectPullRequests()
2930
},
30-
error => console.log(error),
31+
error => this.alerts.push(new Alert('Error retrieving projects', error.message)),
3132
() => this.loading.projects = false
3233
)
3334
}
@@ -39,10 +40,13 @@ export class DashboardComponent implements OnInit {
3940
console.log(data);
4041
this.projectPullRequests = data;
4142
},
42-
error => console.log(error),
43+
error => this.alerts.push(new Alert('Error retrieving pull requests', error.message)),
4344
() => this.loading.pullrequests[this.selectedProject.RepoId] = false
4445
)
4546
}
47+
closeAlert(i:number):void {
48+
this.alerts.splice(i, 1);
49+
}
4650

4751
showProject(project:Project){
4852
this.selectedProject = project;

src/app/models/alert.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const enum AlertType {
2+
failure,
3+
success
4+
}
5+
export class Alert {
6+
type: AlertType = AlertType.failure
7+
title: string = ''
8+
msg: string = ''
9+
closable: boolean = true
10+
11+
constructor(title: string, msg: string, type?:AlertType) {
12+
this.title = title;
13+
this.msg = msg;
14+
if(type){this.type = type}
15+
}
16+
}

src/app/project-create/project-create.component.html

+10
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ <h2 class="title">Create Project</h2>
88
<div class="description">Praesent at vestibulum tortor. Praesent condimentum efficitur massa, nec congue sem dapibus sed. Sed eget justo at erat suscipit tristique sit.</div>
99
</div>
1010
</div>
11+
12+
<div class="row">
13+
<div class="col-lg-10 col-lg-offset-1">
14+
<alert *ngFor="let alert of alerts;let i = index" [type]="alert.type" dismissible="true" (close)="closeAlert(i)">
15+
<div class="title">{{ alert?.title}}</div>
16+
{{ alert?.msg }}
17+
</alert>
18+
</div>
19+
</div>
20+
1121
<div class="row">
1222
<div class="col-lg-offset-2 col-lg-8">
1323
<div class="blog-post style-3">

src/app/project-create/project-create.component.ts

+11-5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { AppSettings } from '../app-settings'
55
import {Organization} from "../models/organization";
66
import {Repository} from "../models/repository";
77
import {Router} from '@angular/router'
8+
import {Alert} from '../models/alert'
89

910
@Component({
1011
selector: 'app-project-create',
@@ -22,8 +23,10 @@ export class ProjectCreateComponent implements OnInit {
2223
fetchOrgRepos: false,
2324
createProject: false
2425
}
26+
alerts: Alert[] = [];
2527

26-
constructor(private apiService: ApiService, private router: Router) { }
28+
29+
constructor(private apiService: ApiService, private router: Router) { }
2730

2831
ngOnInit() {
2932
this.apiService.fetchOrgs()
@@ -34,11 +37,14 @@ export class ProjectCreateComponent implements OnInit {
3437
this.selectedOrgIndex = 0
3538
this.fetchSelectedOrgRepos()
3639
},
37-
error => console.log(error),
40+
error => this.alerts.push(new Alert('Error retrieving organizations', error.message)),
3841
() => this.loading.fetchOrgs = false
3942
);
4043

4144
}
45+
closeAlert(i:number):void {
46+
this.alerts.splice(i, 1);
47+
}
4248

4349
resetPagination(){
4450
this.orgReposPage = 1; //this is the starting page when retriving repos from the api
@@ -56,7 +62,7 @@ export class ProjectCreateComponent implements OnInit {
5662
console.log(data)
5763
this.orgRepos = data;
5864
},
59-
error => console.log(error),
65+
error => this.alerts.push(new Alert('Error retrieving organization repositories', error.message)),
6066
() => this.loading.fetchOrgRepos = false
6167
);
6268
}
@@ -78,7 +84,7 @@ export class ProjectCreateComponent implements OnInit {
7884
this.orgRepos = this.orgRepos.concat(data);
7985
}
8086
},
81-
error => console.log(error),
87+
error => this.alerts.push(new Alert('Error retrieving organization repositories', error.message)),
8288
() => this.loading.fetchOrgRepos = false
8389
);
8490

@@ -109,7 +115,7 @@ export class ProjectCreateComponent implements OnInit {
109115
this.router.navigate([`/project/${this.apiService.serviceType()}/${orgId}/${repoId}/edit`])
110116

111117
},
112-
error => console.log(error),
118+
error => this.alerts.push(new Alert('Error creating new project', error.message)),
113119
() => this.loading.createProject = false
114120
);
115121
}

src/app/project-deploy/project-deploy.component.html

+10
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ <h2 class="title">Create Release</h2>
88
<div class="description">Praesent at vestibulum tortor. Praesent condimentum efficitur massa, nec congue sem dapibus sed. Sed eget justo at erat suscipit tristique sit.</div>
99
</div>
1010
</div>
11+
12+
<div class="row">
13+
<div class="col-lg-10 col-lg-offset-1">
14+
<alert *ngFor="let alert of alerts;let i = index" [type]="alert.type" dismissible="true" (close)="closeAlert(i)">
15+
<div class="title">{{ alert?.title}}</div>
16+
{{ alert?.msg }}
17+
</alert>
18+
</div>
19+
</div>
20+
1121
<div class="row">
1222

1323
<div class="col-md-8 col-md-offset-2 wow fadeInRight" data-wow-delay="0.3s">

src/app/project-deploy/project-deploy.component.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ActivatedRoute } from '@angular/router';
22
import { Component, OnInit } from '@angular/core';
33
import { ApiService } from '../services/api.service';
4+
import {Alert} from '../models/alert'
45

56

67
@Component({
@@ -15,6 +16,7 @@ export class ProjectDeployComponent implements OnInit {
1516
projectData: any = {};
1617
projectSecrets: any = {};
1718
pullRequest: any = {};
19+
alerts: Alert[] = [];
1820

1921
loading = {
2022
project: true,
@@ -39,7 +41,7 @@ export class ProjectDeployComponent implements OnInit {
3941
this.versionIncr = this.projectData.versionIncr || this.versionIncr
4042

4143
},
42-
error => console.log(error),
44+
error => this.alerts.push(new Alert('Error retrieving project', error.message)),
4345
() => this.loading.project = false
4446
);
4547

@@ -49,11 +51,13 @@ export class ProjectDeployComponent implements OnInit {
4951
console.log(data)
5052
this.pullRequest = data
5153
},
52-
error => console.log(error),
54+
error => this.alerts.push(new Alert('Error retrieving pull request', error.message)),
5355
() => this.loading.pullRequest = false
5456
);
5557
}
56-
58+
closeAlert(i:number):void {
59+
this.alerts.splice(i, 1);
60+
}
5761
createRelease(){
5862
//TODO: this function should also send version increment & custom changelog.
5963
this.loading.createRelease = true;
@@ -63,7 +67,7 @@ export class ProjectDeployComponent implements OnInit {
6367
console.log(data)
6468
//todo change path.
6569
},
66-
error => console.log(error),
70+
error => this.alerts.push(new Alert('Error creating new release', error.message)),
6771
() => this.loading.createRelease = false
6872
);
6973
}

src/app/project-edit/project-edit.component.html

+10-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,19 @@ <h2 class="title">Edit {{orgId + '/' + repoId}}</h2>
88
<div class="description">Praesent at vestibulum tortor. Praesent condimentum efficitur massa, nec congue sem dapibus sed. Sed eget justo at erat suscipit tristique sit.</div>
99
</div>
1010
</div>
11-
<div class="row">
1211

13-
<div class="col-md-8 col-md-offset-2 wow fadeInRight" data-wow-delay="0.3s">
12+
<div class="row">
13+
<div class="col-lg-10 col-lg-offset-1">
14+
<alert *ngFor="let alert of alerts;let i = index" [type]="alert.type" dismissible="true" (close)="closeAlert(i)">
15+
<div class="title">{{ alert?.title}}</div>
16+
{{ alert?.msg }}
17+
</alert>
18+
</div>
19+
</div>
1420

1521

22+
<div class="row">
23+
<div class="col-md-8 col-md-offset-2 wow fadeInRight" data-wow-delay="0.3s">
1624
<div class="typography-article">
1725
<h4>Project Settings
1826
<span *ngIf="loading.project" class="glyphicon glyphicon-repeat ml-10 fast-right-spinner"></span>

src/app/project-edit/project-edit.component.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Component, OnInit } from '@angular/core';
33
import { ApiService } from '../services/api.service';
44
import { AppSettings } from '../app-settings'
55
import { Observable } from 'rxjs/Observable';
6+
import {Alert} from '../models/alert'
67

78
@Component({
89
selector: 'app-project-edit',
@@ -22,6 +23,7 @@ export class ProjectEditComponent implements OnInit {
2223
secretName: string = '';
2324
secretValue: string = '';
2425

26+
alerts: Alert[] = [];
2527
loading = {
2628
project: true,
2729
saveSettings: false,
@@ -44,7 +46,7 @@ export class ProjectEditComponent implements OnInit {
4446
this.projectSecrets = data.Secrets || this.projectSecrets;
4547
this.projectSecretsKeys = Object.keys(this.projectSecrets)
4648
},
47-
error => console.log(error),
49+
error => this.alerts.push(new Alert('Error retrieving project', error.message)),
4850
() => this.loading.project = false
4951
);
5052

@@ -57,6 +59,9 @@ export class ProjectEditComponent implements OnInit {
5759
//TODO: add method to autocomplete docker image lookup
5860
//TODO: add help text with common secrets for each image/package type
5961
//TODO: add delete method for secrets.
62+
closeAlert(i:number):void {
63+
this.alerts.splice(i, 1);
64+
}
6065

6166
packageTypeChanged = function(){
6267
this.projectData.dockerImage = this.defaultSettings[this.projectData.packageType].image
@@ -79,7 +84,7 @@ export class ProjectEditComponent implements OnInit {
7984
data => {
8085
console.log(data)
8186
},
82-
error => console.log(error),
87+
error => this.alerts.push(new Alert('Error updating project', error.message)),
8388
() => this.loading.saveSettings = false
8489
);
8590
}
@@ -98,7 +103,7 @@ export class ProjectEditComponent implements OnInit {
98103
this.secretName = '';
99104
this.secretValue = '';
100105
},
101-
error => console.log(error),
106+
error => this.alerts.push(new Alert('Error updating project secrets', error.message)),
102107
() => this.loading.addSecret = false
103108
);
104109
}

0 commit comments

Comments
 (0)