Guest User

Untitled

a guest
May 20th, 2018
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. import { Injectable, NgModule } from '@angular/core';
  2. import { BehaviorSubject } from 'rxjs/BehaviorSubject';
  3. import { Observable } from "rxjs/Observable";
  4. import { Http, Response } from '@angular/http';
  5. import { PapaParseModule } from 'ngx-papaparse';
  6.  
  7. import { PapaParseService } from 'ngx-papaparse';
  8.  
  9. import { Capcaleres } from "../assets/models/Capcaleres.Model";
  10.  
  11. @Injectable()
  12. export class DataService {
  13. private csvData: any[] = [];
  14. private Papa: any = null;
  15.  
  16. constructor(private http: Http, private papa: PapaParseService) {
  17. this.Papa = papa;
  18. }
  19.  
  20.  
  21. public cargarFitxer(obj: any): any
  22. {
  23.  
  24. debugger;
  25.  
  26. // preparo la url
  27. var url: string = "../../assets/assets/{0}/{1}/data.csv";
  28. var clase: any = obj;
  29. var nomClase: string = clase.constructor.name.toLowerCase();
  30. var manteniments: string[] = [
  31. "capcaleres",
  32. "idiomes",
  33. "llenguatgesprogramacio",
  34. "nivells",
  35. "posicions",
  36. "tipusempresa"
  37. ];
  38.  
  39.  
  40. var tipus = (manteniments.find(x => x === nomClase)) ? "manteniments" : "llogica";
  41.  
  42. url = url.replace("{0}", tipus);
  43. url = url.replace("{1}", nomClase);
  44.  
  45. debugger;
  46. // recullo la informació.
  47.  
  48.  
  49. this.Papa.parse(url, {
  50. worker: false,
  51. download: true,
  52.  
  53. complete: function () {
  54. console.log("All done!");
  55. debugger;
  56. }
  57. });
  58.  
  59. }
  60. }
  61.  
  62. {
  63. "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  64. "project": {
  65. "name": "admin-angular"
  66. },
  67. "apps": [
  68. {
  69. "root": "src",
  70. "outDir": "dist",
  71. "assets": [
  72. "assets",
  73. "favicon.ico",
  74. "data.csv"
  75. ],
  76. "index": "index.html",
  77. "main": "main.ts",
  78. "polyfills": "polyfills.ts",
  79. "test": "test.ts",
  80. "tsconfig": "tsconfig.app.json",
  81. "testTsconfig": "tsconfig.spec.json",
  82. "prefix": "app",
  83. "styles": [
  84. "styles.css",
  85. "../src/assets/scss/style.scss"
  86. ],
  87. "scripts": [
  88. "../node_modules/jquery/dist/jquery.min.js",
  89. "../node_modules/pace-js/pace.min.js"
  90. ],
  91. "environmentSource": "environments/environment.ts",
  92. "environments": {
  93. "dev": "environments/environment.ts",
  94. "prod": "environments/environment.prod.ts"
  95. }
  96. }
  97. ],
  98. "e2e": {
  99. "protractor": {
  100. "config": "./protractor.conf.js"
  101. }
  102. },
  103. "lint": [
  104. {
  105. "project": "src/tsconfig.app.json",
  106. "exclude": "**/node_modules/**"
  107. },
  108. {
  109. "project": "src/tsconfig.spec.json",
  110. "exclude": "**/node_modules/**"
  111. },
  112. {
  113. "project": "e2e/tsconfig.e2e.json",
  114. "exclude": "**/node_modules/**"
  115. }
  116. ],
  117. "test": {
  118. "karma": {
  119. "config": "./karma.conf.js"
  120. }
  121. },
  122. "defaults": {
  123. "styleExt": "css",
  124. "component": {}
  125. }
  126. }
Add Comment
Please, Sign In to add comment