Update to Angular 6
Fix little bug on last added query
This commit is contained in:
@@ -1,61 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
|
||||||
"project": {
|
|
||||||
"name": "dashboard"
|
|
||||||
},
|
|
||||||
"apps": [
|
|
||||||
{
|
|
||||||
"root": "src",
|
|
||||||
"outDir": "dist",
|
|
||||||
"assets": [
|
|
||||||
"assets",
|
|
||||||
"favicon.ico"
|
|
||||||
],
|
|
||||||
"index": "index.html",
|
|
||||||
"main": "main.ts",
|
|
||||||
"polyfills": "polyfills.ts",
|
|
||||||
"test": "test.ts",
|
|
||||||
"tsconfig": "tsconfig.app.json",
|
|
||||||
"testTsconfig": "tsconfig.spec.json",
|
|
||||||
"prefix": "app",
|
|
||||||
"styles": [
|
|
||||||
"styles.css",
|
|
||||||
"../node_modules/bootstrap/dist/css/bootstrap.min.css"
|
|
||||||
],
|
|
||||||
"scripts": [],
|
|
||||||
"environmentSource": "environments/environment.ts",
|
|
||||||
"environments": {
|
|
||||||
"dev": "environments/environment.ts",
|
|
||||||
"prod": "environments/environment.prod.ts"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"e2e": {
|
|
||||||
"protractor": {
|
|
||||||
"config": "./protractor.conf.js"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"lint": [
|
|
||||||
{
|
|
||||||
"project": "src/tsconfig.app.json",
|
|
||||||
"exclude": "**/node_modules/**"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"project": "src/tsconfig.spec.json",
|
|
||||||
"exclude": "**/node_modules/**"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"project": "e2e/tsconfig.e2e.json",
|
|
||||||
"exclude": "**/node_modules/**"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"test": {
|
|
||||||
"karma": {
|
|
||||||
"config": "./karma.conf.js"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"defaults": {
|
|
||||||
"styleExt": "css",
|
|
||||||
"component": {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
134
dashboard/angular.json
Normal file
134
dashboard/angular.json
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
{
|
||||||
|
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
||||||
|
"version": 1,
|
||||||
|
"newProjectRoot": "projects",
|
||||||
|
"projects": {
|
||||||
|
"dashboard": {
|
||||||
|
"root": "",
|
||||||
|
"sourceRoot": "src",
|
||||||
|
"projectType": "application",
|
||||||
|
"architect": {
|
||||||
|
"build": {
|
||||||
|
"builder": "@angular-devkit/build-angular:browser",
|
||||||
|
"options": {
|
||||||
|
"outputPath": "dist",
|
||||||
|
"index": "src/index.html",
|
||||||
|
"main": "src/main.ts",
|
||||||
|
"tsConfig": "src/tsconfig.app.json",
|
||||||
|
"polyfills": "src/polyfills.ts",
|
||||||
|
"assets": [
|
||||||
|
"src/assets",
|
||||||
|
"src/favicon.ico"
|
||||||
|
],
|
||||||
|
"styles": [
|
||||||
|
"src/styles.css",
|
||||||
|
"node_modules/bootstrap/dist/css/bootstrap.min.css"
|
||||||
|
],
|
||||||
|
"scripts": []
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"production": {
|
||||||
|
"optimization": true,
|
||||||
|
"outputHashing": "all",
|
||||||
|
"sourceMap": false,
|
||||||
|
"extractCss": true,
|
||||||
|
"namedChunks": false,
|
||||||
|
"aot": true,
|
||||||
|
"extractLicenses": true,
|
||||||
|
"vendorChunk": false,
|
||||||
|
"buildOptimizer": true,
|
||||||
|
"fileReplacements": [
|
||||||
|
{
|
||||||
|
"replace": "src/environments/environment.ts",
|
||||||
|
"with": "src/environments/environment.prod.ts"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"serve": {
|
||||||
|
"builder": "@angular-devkit/build-angular:dev-server",
|
||||||
|
"options": {
|
||||||
|
"browserTarget": "dashboard:build"
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"production": {
|
||||||
|
"browserTarget": "dashboard:build:production"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extract-i18n": {
|
||||||
|
"builder": "@angular-devkit/build-angular:extract-i18n",
|
||||||
|
"options": {
|
||||||
|
"browserTarget": "dashboard:build"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"test": {
|
||||||
|
"builder": "@angular-devkit/build-angular:karma",
|
||||||
|
"options": {
|
||||||
|
"main": "src/test.ts",
|
||||||
|
"karmaConfig": "./karma.conf.js",
|
||||||
|
"polyfills": "src/polyfills.ts",
|
||||||
|
"tsConfig": "src/tsconfig.spec.json",
|
||||||
|
"scripts": [],
|
||||||
|
"styles": [
|
||||||
|
"src/styles.css",
|
||||||
|
"node_modules/bootstrap/dist/css/bootstrap.min.css"
|
||||||
|
],
|
||||||
|
"assets": [
|
||||||
|
"src/assets",
|
||||||
|
"src/favicon.ico"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"lint": {
|
||||||
|
"builder": "@angular-devkit/build-angular:tslint",
|
||||||
|
"options": {
|
||||||
|
"tsConfig": [
|
||||||
|
"src/tsconfig.app.json",
|
||||||
|
"src/tsconfig.spec.json"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"**/node_modules/**"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"dashboard-e2e": {
|
||||||
|
"root": "",
|
||||||
|
"sourceRoot": "",
|
||||||
|
"projectType": "application",
|
||||||
|
"architect": {
|
||||||
|
"e2e": {
|
||||||
|
"builder": "@angular-devkit/build-angular:protractor",
|
||||||
|
"options": {
|
||||||
|
"protractorConfig": "./protractor.conf.js",
|
||||||
|
"devServerTarget": "dashboard:serve"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"lint": {
|
||||||
|
"builder": "@angular-devkit/build-angular:tslint",
|
||||||
|
"options": {
|
||||||
|
"tsConfig": [
|
||||||
|
"e2e/tsconfig.e2e.json"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"**/node_modules/**"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"defaultProject": "dashboard",
|
||||||
|
"schematics": {
|
||||||
|
"@schematics/angular:component": {
|
||||||
|
"prefix": "app",
|
||||||
|
"styleext": "css"
|
||||||
|
},
|
||||||
|
"@schematics/angular:directive": {
|
||||||
|
"prefix": "app"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,19 +4,19 @@
|
|||||||
module.exports = function (config) {
|
module.exports = function (config) {
|
||||||
config.set({
|
config.set({
|
||||||
basePath: '',
|
basePath: '',
|
||||||
frameworks: ['jasmine', '@angular/cli'],
|
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
||||||
plugins: [
|
plugins: [
|
||||||
require('karma-jasmine'),
|
require('karma-jasmine'),
|
||||||
require('karma-chrome-launcher'),
|
require('karma-chrome-launcher'),
|
||||||
require('karma-jasmine-html-reporter'),
|
require('karma-jasmine-html-reporter'),
|
||||||
require('karma-coverage-istanbul-reporter'),
|
require('karma-coverage-istanbul-reporter'),
|
||||||
require('@angular/cli/plugins/karma')
|
require('@angular-devkit/build-angular/plugins/karma')
|
||||||
],
|
],
|
||||||
client:{
|
client:{
|
||||||
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
||||||
},
|
},
|
||||||
coverageIstanbulReporter: {
|
coverageIstanbulReporter: {
|
||||||
reports: [ 'html', 'lcovonly' ],
|
dir: require('path').join(__dirname, 'coverage'), reports: [ 'html', 'lcovonly' ],
|
||||||
fixWebpackSourcePaths: true
|
fixWebpackSourcePaths: true
|
||||||
},
|
},
|
||||||
angularCli: {
|
angularCli: {
|
||||||
|
|||||||
@@ -12,24 +12,24 @@
|
|||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/animations": "5.2.9",
|
"@angular/animations": "6.0.3",
|
||||||
"@angular/common": "5.2.9",
|
"@angular/common": "6.0.3",
|
||||||
"@angular/compiler": "5.2.9",
|
"@angular/compiler": "6.0.3",
|
||||||
"@angular/core": "5.2.9",
|
"@angular/core": "6.0.3",
|
||||||
"@angular/forms": "5.2.9",
|
"@angular/forms": "6.0.3",
|
||||||
"@angular/http": "5.2.9",
|
"@angular/http": "6.0.3",
|
||||||
"@angular/platform-browser": "5.2.9",
|
"@angular/platform-browser": "6.0.3",
|
||||||
"@angular/platform-browser-dynamic": "5.2.9",
|
"@angular/platform-browser-dynamic": "6.0.3",
|
||||||
"@angular/router": "5.2.9",
|
"@angular/router": "6.0.3",
|
||||||
"core-js": "^2.4.1",
|
"core-js": "^2.4.1",
|
||||||
"rxjs": "^5.5.7",
|
"rxjs": "^6.2.0",
|
||||||
"zone.js": "^0.8.20",
|
"zone.js": "^0.8.26",
|
||||||
"bootstrap": "3.3.7"
|
"bootstrap": "3.3.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular/cli": "1.7.3",
|
"@angular/cli": "^6.0.7",
|
||||||
"@angular/compiler-cli": "5.2.9",
|
"@angular/compiler-cli": "6.0.3",
|
||||||
"@angular/language-service": "5.2.9",
|
"@angular/language-service": "6.0.3",
|
||||||
"@types/jasmine": "~2.5.53",
|
"@types/jasmine": "~2.5.53",
|
||||||
"@types/jasminewd2": "~2.0.2",
|
"@types/jasminewd2": "~2.0.2",
|
||||||
"@types/node": "~6.0.60",
|
"@types/node": "~6.0.60",
|
||||||
@@ -45,6 +45,7 @@
|
|||||||
"protractor": "~5.1.2",
|
"protractor": "~5.1.2",
|
||||||
"ts-node": "~3.2.0",
|
"ts-node": "~3.2.0",
|
||||||
"tslint": "~5.3.2",
|
"tslint": "~5.3.2",
|
||||||
"typescript": "2.6.2"
|
"typescript": "2.7.2",
|
||||||
|
"@angular-devkit/build-angular": "~0.6.6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpClient, HttpHeaders } from '@angular/common/http'
|
import { HttpClient, HttpHeaders } from '@angular/common/http'
|
||||||
|
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs';
|
||||||
import 'rxjs/add/operator/toPromise';
|
import { map } from 'rxjs/operators';
|
||||||
import 'rxjs/add/operator/map';
|
|
||||||
|
|
||||||
import { Song } from './model/song';
|
import { Song } from './model/song';
|
||||||
import { Album } from './model/album';
|
import { Album } from './model/album';
|
||||||
@@ -111,7 +110,9 @@ export class ElsService {
|
|||||||
} ],
|
} ],
|
||||||
'size': 5
|
'size': 5
|
||||||
}), {headers: this.headers})
|
}), {headers: this.headers})
|
||||||
.map(res => this.responseToSongs(res));
|
.pipe(
|
||||||
|
map(res => this.responseToSongs(res))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -146,7 +147,9 @@ export class ElsService {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}), {headers: this.headers})
|
}), {headers: this.headers})
|
||||||
.map(res => this.responseToAlbums(res));
|
.pipe(
|
||||||
|
map(res => this.responseToAlbums(res))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getMostPlayedArtistNaive(): Promise<Artist[]> {
|
getMostPlayedArtistNaive(): Promise<Artist[]> {
|
||||||
@@ -175,7 +178,9 @@ export class ElsService {
|
|||||||
],
|
],
|
||||||
'size': 100
|
'size': 100
|
||||||
}), {headers: this.headers})
|
}), {headers: this.headers})
|
||||||
.map(res => this.responseToArtists(res));
|
.pipe(
|
||||||
|
map(res => this.responseToArtists(res))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getAlbumSongs(albumName: string, from: number = 0): Observable<Song[]> {
|
getAlbumSongs(albumName: string, from: number = 0): Observable<Song[]> {
|
||||||
@@ -189,7 +194,9 @@ export class ElsService {
|
|||||||
'size': ElsService.DEFAULT_SIZE,
|
'size': ElsService.DEFAULT_SIZE,
|
||||||
'from': from
|
'from': from
|
||||||
}), {headers: this.headers})
|
}), {headers: this.headers})
|
||||||
.map(res => this.responseToSongs(res));
|
.pipe(
|
||||||
|
map(res => this.responseToSongs(res))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getGenreSongs(genreName: string, from: number = 0): Observable<Song[]> {
|
getGenreSongs(genreName: string, from: number = 0): Observable<Song[]> {
|
||||||
@@ -204,7 +211,9 @@ export class ElsService {
|
|||||||
'size': ElsService.DEFAULT_SIZE,
|
'size': ElsService.DEFAULT_SIZE,
|
||||||
'from': from
|
'from': from
|
||||||
}), {headers: this.headers})
|
}), {headers: this.headers})
|
||||||
.map(res => this.responseToSongs(res));
|
.pipe(
|
||||||
|
map(res => this.responseToSongs(res))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getArtistSongs(artistName: string, from: number = 0): Observable<Song[]> {
|
getArtistSongs(artistName: string, from: number = 0): Observable<Song[]> {
|
||||||
@@ -223,7 +232,9 @@ export class ElsService {
|
|||||||
'size': ElsService.DEFAULT_SIZE,
|
'size': ElsService.DEFAULT_SIZE,
|
||||||
'from': from
|
'from': from
|
||||||
}), {headers: this.headers})
|
}), {headers: this.headers})
|
||||||
.map(res => this.responseToSongs(res));
|
.pipe(
|
||||||
|
map(res => this.responseToSongs(res))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getAlbum(albumName: string): Observable<Album> {
|
getAlbum(albumName: string): Observable<Album> {
|
||||||
@@ -235,7 +246,9 @@ export class ElsService {
|
|||||||
},
|
},
|
||||||
'size': ElsService.DEFAULT_SIZE
|
'size': ElsService.DEFAULT_SIZE
|
||||||
}), {headers: this.headers})
|
}), {headers: this.headers})
|
||||||
.map(res => this.responseToOneTypedResult<Album>(res, albumName));
|
.pipe(
|
||||||
|
map(res => this.responseToOneTypedResult<Album>(res, albumName))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getArtist(artistName: string): Observable<Artist> {
|
getArtist(artistName: string): Observable<Artist> {
|
||||||
@@ -247,7 +260,9 @@ export class ElsService {
|
|||||||
},
|
},
|
||||||
'size': ElsService.DEFAULT_SIZE
|
'size': ElsService.DEFAULT_SIZE
|
||||||
}), {headers: this.headers})
|
}), {headers: this.headers})
|
||||||
.map(res => this.responseToOneTypedResult<Artist>(res, artistName));
|
.pipe(
|
||||||
|
map(res => this.responseToOneTypedResult<Artist>(res, artistName))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getGenres(ordering: string = 'desc'): Observable<Bucket[]> {
|
getGenres(ordering: string = 'desc'): Observable<Bucket[]> {
|
||||||
@@ -266,7 +281,9 @@ export class ElsService {
|
|||||||
},
|
},
|
||||||
'size': 0
|
'size': 0
|
||||||
}), {headers: this.headers})
|
}), {headers: this.headers})
|
||||||
.map(res => this.responseAggregationToBucket(res, 'genres'));
|
.pipe(
|
||||||
|
map(res => this.responseAggregationToBucket(res, 'genres'))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getGenreCount(): Observable<number> {
|
getGenreCount(): Observable<number> {
|
||||||
@@ -283,7 +300,9 @@ export class ElsService {
|
|||||||
},
|
},
|
||||||
'size': 0
|
'size': 0
|
||||||
}), {headers: this.headers})
|
}), {headers: this.headers})
|
||||||
.map(res => res.aggregations.genres.value);
|
.pipe(
|
||||||
|
map(res => res.aggregations.genres.value)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getLastAddedAlbums(month: number): Observable<Bucket[]> {
|
getLastAddedAlbums(month: number): Observable<Bucket[]> {
|
||||||
@@ -293,7 +312,7 @@ export class ElsService {
|
|||||||
'query': {
|
'query': {
|
||||||
'range' : {
|
'range' : {
|
||||||
'Date Added' : {
|
'Date Added' : {
|
||||||
'gte' : 'now-3M/d',
|
'gte' : 'now-' + month + 'M/d',
|
||||||
'lte' : 'now/d'
|
'lte' : 'now/d'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -316,7 +335,9 @@ export class ElsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}), {headers: this.headers})
|
}), {headers: this.headers})
|
||||||
.map(res => this.responseSubAggregationToBucket(res, 'date'));
|
.pipe(
|
||||||
|
map(res => this.responseSubAggregationToBucket(res, 'date'))
|
||||||
|
);
|
||||||
// TODO Take in consideration "sum_other_doc_count"
|
// TODO Take in consideration "sum_other_doc_count"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,15 +351,17 @@ export class ElsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}), {headers: this.headers})
|
}), {headers: this.headers})
|
||||||
.map(res => res.hits.hits)
|
.pipe(
|
||||||
.map((hits: Array<any>) => {
|
map(res => res.hits.hits),
|
||||||
|
map((hits: Array<any>) => {
|
||||||
// TODO Use a method (duplicated code ?)
|
// TODO Use a method (duplicated code ?)
|
||||||
const result: Array<Album> = [];
|
const result: Array<Album> = [];
|
||||||
hits.forEach((hit) => {
|
hits.forEach((hit) => {
|
||||||
result.push(hit._source);
|
result.push(hit._source);
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
});
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getCountArtistSong(artistName: string): Observable<number> {
|
getCountArtistSong(artistName: string): Observable<number> {
|
||||||
@@ -355,7 +378,9 @@ export class ElsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}), {headers: this.headers})
|
}), {headers: this.headers})
|
||||||
.map(res => res.count as number);
|
.pipe(
|
||||||
|
map(res => res.count as number)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Process a result to return just one result.
|
/** Process a result to return just one result.
|
||||||
|
|||||||
@@ -11,7 +11,8 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"test.ts"
|
"test.ts",
|
||||||
|
"polyfills.ts"
|
||||||
],
|
],
|
||||||
"include": [
|
"include": [
|
||||||
"**/*.spec.ts",
|
"**/*.spec.ts",
|
||||||
|
|||||||
@@ -14,8 +14,7 @@
|
|||||||
"eofline": true,
|
"eofline": true,
|
||||||
"forin": true,
|
"forin": true,
|
||||||
"import-blacklist": [
|
"import-blacklist": [
|
||||||
true,
|
true
|
||||||
"rxjs"
|
|
||||||
],
|
],
|
||||||
"import-spacing": true,
|
"import-spacing": true,
|
||||||
"indent": [
|
"indent": [
|
||||||
|
|||||||
Reference in New Issue
Block a user