Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
rkorszun committed Feb 1, 2018
2 parents 5038d3b + 1af0470 commit 6c4f958
Show file tree
Hide file tree
Showing 20 changed files with 179 additions and 113 deletions.
9 changes: 1 addition & 8 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
<app-toolbar></app-toolbar>
<router-outlet></router-outlet>
<div id="default-notification">
<span>{{ toasterService.toasterText }}</span>
<div class="close">
<button (click)="toasterService.hideToaster()">
<span class="trec-icon-close"></span>
</button>
</div>
</div>
<app-toaster></app-toaster>
67 changes: 0 additions & 67 deletions src/app/app.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,70 +5,3 @@ $fa-font-path: "../../node_modules/font-awesome/fonts";
body {
background-color: $dark;
}

#default-notification, .default-notification {
visibility: hidden;
position: fixed;
bottom: 0;
right: 0;
left: 0;
width: 100%;
padding: 19px 19px 16px;
color: $white;
text-align: left;
box-sizing: border-box;
z-index: 99999;
&--default {
background-color: $font-grey;
}
&--success {
background-color: $notification-green;
}
&--error {
background-color: $input-error;
}
&.show {
visibility: visible;
-webkit-animation: fadein 0.5s, fadeout 0.5s 5.2s;
animation: fadein 0.5s, fadeout 0.5s 5.2s;
}
span {
color: $white;
font-family: 'Montserrat', sans-serif;
font-size: 12px;
line-height: 12px;
letter-spacing: 1px;
}
.close {
position: absolute;
top: 16px;
right: 13px;
button {
padding: 0;
background: transparent;
color: $white;
border: 0;
outline: none;
cursor: pointer;
span {
font-size: 22px;
}
}
}
@-webkit-keyframes fadein {
from {bottom: -55px; }
to {bottom: 0; }
}
@keyframes fadein {
from {bottom: -55px; }
to {bottom: 0; }
}
@-webkit-keyframes fadeout {
from {bottom: 0; }
to {bottom: -55px; }
}
@keyframes fadeout {
from {bottom: 0; }
to {bottom: -55px; }
}
}
2 changes: 0 additions & 2 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ export class AppComponent {
) {
if (electronService.isElectron()) {
console.log('Mode electron');
// Check if electron is correctly injected (see externals in webpack.config.js)
console.log('c', electronService.ipcRenderer);
// Check if nodeJs childProcess is correctly injected (see externals in webpack.config.js)
console.log('c', electronService.childProcess);
} else {
console.log('Mode web');
Expand Down
4 changes: 3 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { SwitchAccountComponent } from './components/accounts/switch-account/swi
import { MenuService } from './services/menu.service';
import { Nl2brPipe } from 'app/pipes/nl2br.pipe';
import { LoadingSpinnerComponent } from './components/loading-spinner/loading-spinner.component';
import { ToasterComponent } from './components/toaster/toaster.component';

@NgModule({
declarations: [
Expand All @@ -58,7 +59,8 @@ import { LoadingSpinnerComponent } from './components/loading-spinner/loading-sp
LicensesComponent,
ToolbarComponent,
SwitchAccountComponent,
LoadingSpinnerComponent
LoadingSpinnerComponent,
ToasterComponent
],
imports: [
BrowserModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class AddAccountComponent implements OnInit {
rAccount.token = this.token;
rAccount.url = this.youTrackUrl;
if (!window.navigator.onLine) {
this.toasterService.showToaster("No internet connection", "error")
this.toasterService.error("No internet connection")
} else {
this.apiService.getCurrentUser(rAccount).then(
(data) => {
Expand All @@ -83,7 +83,7 @@ export class AddAccountComponent implements OnInit {
}
}, (error) => {
this.errorUrlOrToken()
this.toasterService.showToaster("Error eccoured! Incorrect URL or token", 'error')
this.toasterService.error("Error occoured! Incorrect URL or token")
this.loader = false;
}
)
Expand All @@ -97,7 +97,7 @@ export class AddAccountComponent implements OnInit {
public errorName() {
let url = document.getElementById('add-account__name')
url.className += " add-account__name--error"
this.toasterService.showToaster("Error eccoured! The name must be longer than 3 characters.", 'error')
this.toasterService.error("Error occoured! The name must be longer than 3 characters.")
}

public clearErrorUrlOrToken() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Router, ActivatedRoute } from '@angular/router';

import { DatabaseService } from '../../../services/database.service'
import { ToasterService } from '../../../services/toaster.service'
import { RemoteAccount } from 'app/models/RemoteAccount';
import { ApiService } from 'app/services/api.service';

@Component({
selector: 'app-change-account-token',
Expand All @@ -18,7 +20,8 @@ export class ChangeAccountTokenComponent implements OnInit {
public activatedRoute: ActivatedRoute,
public router: Router,
public databaseService: DatabaseService,
public toasterService: ToasterService
public toasterService: ToasterService,
public api: ApiService
) { }

ngOnInit() {
Expand All @@ -32,11 +35,20 @@ export class ChangeAccountTokenComponent implements OnInit {
}

changeToken(accountId, newToken) {
this.databaseService.changeAccountToken(accountId, newToken).then(data => {
this.toasterService.showToaster('Token has been changed successfully', 'success')
this.goBack()
}, err => {
console.log(err)
let rAccount = new RemoteAccount()
rAccount.name = this.accountName
rAccount.url = this.accountUrl
rAccount.token = newToken
this.api.getCurrentUser(rAccount).then((res) => {
this.databaseService.changeAccountToken(accountId, newToken).then(data => {
this.toasterService.success('Token has been changed successfully')
this.goBack()
}, err => {
console.log(err)
this.toasterService.error('An error occoured!')
})
}, (err) => {
this.toasterService.error('An error occoured! This token doesn\'t match any account')
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ export class EditAccountComponent implements OnInit {

editNameOrUrl(account) {
this.databaseService.editAccount(account).then(data => {
this.toasterService.showToaster('Account updated!', "success")
this.toasterService.success('Account updated!')
}, err => {
this.toasterService.showToaster('An error occured!', "error")
this.toasterService.error('An error occured!')
})
}

Expand All @@ -88,9 +88,9 @@ export class EditAccountComponent implements OnInit {
public removeAccount(id) {
this.databaseService.deleteAccount(id).then(data => {
this.router.navigate(['/accounts'])
this.toasterService.showToaster('Account removed!', "success")
this.toasterService.success('Account removed!')
}, err => {
this.toasterService.showToaster('An error occured!', "error")
this.toasterService.error('An error occured!')
})
this.hideModal()
}
Expand Down Expand Up @@ -124,10 +124,10 @@ export class EditAccountComponent implements OnInit {
agile.checked == true? agile.checked = 1 : agile.checked = 0
this.databaseService.updateBoardVisibility(this.editingAccount.id, agile.name, agile.checked).then(data => {
if (data) {
this.toasterService.showToaster('Your changes have been saved!', "success")
this.toasterService.success('Your changes have been saved!')
}
}, err => {
this.toasterService.showToaster('An error occured!', "error")
this.toasterService.error('An error occured!')
})
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class BoardsChoiceComponent implements OnInit {
})
})
if (this.justLoggedIn) {
this.toasterService.showToaster("Account " + this.accountName + " is synced!", "success")
this.toasterService.success("Account " + this.accountName + " is synced!")
}
}
)
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/edit-board/edit-board.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ export class EditBoardComponent implements OnInit {
updateStatesColors(boardStates) {
for (let i = 0; i < boardStates.length; i++) {
if (!/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(boardStates[i].hexColor)) {
this.toasterService.showToaster('It isn\'t hex format!', 'error')
this.toasterService.error('It isn\'t hex format!')
return false
}
}
boardStates.forEach((state) => {
this.databaseService.changeBoardStates(state.accountId, state.boardName, state.state, state.hexColor).then(data => {
this.toasterService.showToaster('Color has been changed!', 'success')
this.toasterService.success('Color has been changed!')
})
})
this.goBack()
Expand Down
8 changes: 8 additions & 0 deletions src/app/components/toaster/toaster.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div id="default-notification">
<span>{{ toasterService.toasterText }}</span>
<div class="close">
<button (click)="toasterService.hideToaster()">
<span class="trec-icon-close"></span>
</button>
</div>
</div>
68 changes: 68 additions & 0 deletions src/app/components/toaster/toaster.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
@import "../../theme/colors.scss";

#default-notification, .default-notification {
visibility: hidden;
position: fixed;
bottom: 0;
right: 0;
left: 0;
width: 100%;
color: $white;
text-align: left;
box-sizing: border-box;
z-index: 99999;
padding: 19px 19px 16px;
&--default {
background-color: $font-grey;
}
&--success {
background-color: $notification-green;
}
&--error {
background-color: $input-error;
}
&.show {
visibility: visible;
-webkit-animation: fadein 0.5s, fadeout 0.5s 5.2s;
animation: fadein 0.5s, fadeout 0.5s 5.2s;
}
span {
color: $white;
font-family: 'Montserrat', sans-serif;
font-size: 12px;
line-height: 12px;
letter-spacing: 1px;
}
.close {
position: absolute;
top: 16px;
right: 13px;
button {
padding: 0;
background: transparent;
color: $white;
border: 0;
outline: none;
cursor: pointer;
span {
font-size: 22px;
}
}
}
@-webkit-keyframes fadein {
from {bottom: -55px; }
to {bottom: 0; }
}
@keyframes fadein {
from {bottom: -55px; }
to {bottom: 0; }
}
@-webkit-keyframes fadeout {
from {bottom: 0; }
to {bottom: -55px; }
}
@keyframes fadeout {
from {bottom: 0; }
to {bottom: -55px; }
}
}
25 changes: 25 additions & 0 deletions src/app/components/toaster/toaster.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { ToasterComponent } from './toaster.component';

describe('ToasterComponent', () => {
let component: ToasterComponent;
let fixture: ComponentFixture<ToasterComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ToasterComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(ToasterComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
19 changes: 19 additions & 0 deletions src/app/components/toaster/toaster.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Component, OnInit } from '@angular/core';
import { ToasterService } from 'app/services/toaster.service';

@Component({
selector: 'app-toaster',
templateUrl: './toaster.component.html',
styleUrls: ['./toaster.component.scss']
})
export class ToasterComponent implements OnInit {

constructor(
public toasterService: ToasterService
) { }

ngOnInit() {
}


}
2 changes: 1 addition & 1 deletion src/app/components/workspace/boards/boards.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class BoardsComponent implements OnInit {

ngOnInit() {
if (!window.navigator.onLine) {
this.toasterService.showToaster("No internet connection", "error")
this.toasterService.error("No internet connection")
} else {
this.init()
}
Expand Down
Loading

0 comments on commit 6c4f958

Please sign in to comment.