mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[ADF-3299] and [ADF-3300] upgrade to Angular and Material 6 (#3579)
* upgrade to HttpClient * upgrade to Renderer2 * upgrade Document reference * remove useless test with deprecated ReflectiveInjector * upgrade to latest typescript * upgrade libs * upgrade package scripts * remove rxjs blacklists and duplicate rules * add rxjs compat to help with migration * fix breaking changes * fix breaking changes in material * fix breaking changes (material 6) * upgrade rxjs, ngx-translate and flex layout * update unit tests * restore providers * upgrade deprecated Observable.error * rebase fix first configuration problems * fix style issues commented * fix core build * fix lib template errors * move lib test execution in angular.json * ignore * karma conf files * fix import statement test * single run option * update packages reporter * restore report * increase timeout * improve karma conf test configuration * fix test issues about lint * fix test analytics * fix process service test * content service fix test * fix logout directive test * fix core test * fix build * update node-sass to latest * update angular cli dependencies * improve build script create directorites and move files only if previous command succeded * upgrade individual libs to 6.0 * remove old webpack files * revert sass change * fix type issues fix style issues * fix tslint demo shell issue * fix peerdependencies * fix test e2e BC * package upate * fix style import issue * extract-text-webpack-plugin beta * fix test dist build command * remove alpha js-api * fix tslint issue add banner tslint rule * upload service fix * change BC script * fix test dist script * increase demo shell timeout test * verbose copy * path absolute * fix script bc * fix copy part * fix path warning fix monaco editor * remove duplicate header * remove unused import * fix align and check ago tests * add missing import * fix notification button selector * [ANGULAR6] fixed core tests * fix CS test * fix cs test step 2 * increase travis_wait for dist * fix attachment PS * fix checklist test * use pdf min
This commit is contained in:
committed by
Eugenio Romano
parent
c510ec864d
commit
6b24bfb1d4
@@ -19,7 +19,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { LikeComponent } from './like.component';
|
||||
import { setupTestBed } from '../../core/testing';
|
||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { of } from 'rxjs';
|
||||
import { RatingService } from './services/rating.service';
|
||||
|
||||
describe('Like component', () => {
|
||||
@@ -36,7 +36,7 @@ describe('Like component', () => {
|
||||
beforeEach(async(() => {
|
||||
service = TestBed.get(RatingService);
|
||||
|
||||
spyOn(service, 'getRating').and.returnValue(Observable.of({
|
||||
spyOn(service, 'getRating').and.returnValue(of({
|
||||
entry: {
|
||||
id: 'likes',
|
||||
aggregate: { numberOfRatings: 2 }
|
||||
@@ -60,7 +60,7 @@ describe('Like component', () => {
|
||||
}));
|
||||
|
||||
it('should increase the number of likes when clicked', async(() => {
|
||||
spyOn(service, 'postRating').and.returnValue(Observable.of({
|
||||
spyOn(service, 'postRating').and.returnValue(of({
|
||||
entry: {
|
||||
id: 'likes',
|
||||
aggregate: { numberOfRatings: 3 }
|
||||
@@ -77,7 +77,7 @@ describe('Like component', () => {
|
||||
}));
|
||||
|
||||
it('should decrease the number of likes when clicked and is already liked', async(() => {
|
||||
spyOn(service, 'deleteRating').and.returnValue(Observable.of('');
|
||||
spyOn(service, 'deleteRating').and.returnValue(of(''));
|
||||
|
||||
component.isLike = true;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { RatingComponent } from './rating.component';
|
||||
import { setupTestBed } from '../../core/testing';
|
||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { of } from 'rxjs';
|
||||
import { RatingService } from './services/rating.service';
|
||||
|
||||
describe('Rating component', () => {
|
||||
@@ -51,7 +51,7 @@ describe('Rating component', () => {
|
||||
describe('Rendering tests', () => {
|
||||
|
||||
it('should rating component should be present', (done) => {
|
||||
spyOn(service, 'getRating').and.returnValue(Observable.of({
|
||||
spyOn(service, 'getRating').and.returnValue(of({
|
||||
entry: {
|
||||
id: 'fiveStar',
|
||||
aggregate: {
|
||||
@@ -70,7 +70,7 @@ describe('Rating component', () => {
|
||||
});
|
||||
|
||||
it('should the star rating filled with the right grey/colored star', (done) => {
|
||||
spyOn(service, 'getRating').and.returnValue(Observable.of({
|
||||
spyOn(service, 'getRating').and.returnValue(of({
|
||||
entry: {
|
||||
id: 'fiveStar',
|
||||
aggregate: {
|
||||
@@ -92,7 +92,7 @@ describe('Rating component', () => {
|
||||
});
|
||||
|
||||
it('should click on a star change your vote', (done) => {
|
||||
spyOn(service, 'getRating').and.returnValue(Observable.of({
|
||||
spyOn(service, 'getRating').and.returnValue(of({
|
||||
'entry': {
|
||||
myRating: 1,
|
||||
'ratedAt': '2017-04-06T14:34:28.061+0000',
|
||||
@@ -101,7 +101,7 @@ describe('Rating component', () => {
|
||||
}
|
||||
}));
|
||||
|
||||
spyOn(service, 'postRating').and.returnValue(Observable.of({
|
||||
spyOn(service, 'postRating').and.returnValue(of({
|
||||
'entry': {
|
||||
'myRating': 3,
|
||||
'ratedAt': '2017-04-06T14:36:40.731+0000',
|
||||
|
||||
@@ -19,8 +19,8 @@ import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Response } from '@angular/http';
|
||||
import { RatingBody } from 'alfresco-js-api';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import 'rxjs/add/observable/throw';
|
||||
import { from, throwError } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
@Injectable()
|
||||
export class RatingService {
|
||||
@@ -35,9 +35,10 @@ export class RatingService {
|
||||
* @returns The rating value
|
||||
*/
|
||||
getRating(nodeId: string, ratingType: any): any {
|
||||
return Observable.fromPromise(this.apiService.getInstance().core.ratingsApi.getRating(nodeId, ratingType))
|
||||
.map(res => res)
|
||||
.catch(this.handleError);
|
||||
return from(this.apiService.getInstance().core.ratingsApi.getRating(nodeId, ratingType))
|
||||
.pipe(
|
||||
catchError(this.handleError)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,9 +53,10 @@ export class RatingService {
|
||||
'id': ratingType,
|
||||
'myRating': vote
|
||||
};
|
||||
return Observable.fromPromise(this.apiService.getInstance().core.ratingsApi.rate(nodeId, ratingBody))
|
||||
.map(res => res)
|
||||
.catch(this.handleError);
|
||||
return from(this.apiService.getInstance().core.ratingsApi.rate(nodeId, ratingBody))
|
||||
.pipe(
|
||||
catchError(this.handleError)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,13 +66,14 @@ export class RatingService {
|
||||
* @returns Null response indicating that the operation is complete
|
||||
*/
|
||||
deleteRating(nodeId: string, ratingType: any): any {
|
||||
return Observable.fromPromise(this.apiService.getInstance().core.ratingsApi.removeRating(nodeId, ratingType))
|
||||
.map(res => res)
|
||||
.catch(this.handleError);
|
||||
return from(this.apiService.getInstance().core.ratingsApi.removeRating(nodeId, ratingType))
|
||||
.pipe(
|
||||
catchError(this.handleError)
|
||||
);
|
||||
}
|
||||
|
||||
private handleError(error: Response): any {
|
||||
console.error(error);
|
||||
return Observable.throw(error || 'Server error');
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user