Advertisement
Guest User

Untitled

a guest
Sep 7th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.10 KB | None | 0 0
  1. import { Component, ChangeDetectionStrategy, OnInit, ViewChild, AfterViewInit} from '@angular/core';
  2. import {Router} from "@angular/router";
  3. import {ApiService} from "../api.service";
  4. import {SchedulerDataService} from "./schedulerData.service";
  5. import {DayPilot, DayPilotSchedulerComponent} from 'daypilot-pro-angular';
  6.  
  7. declare var swal: any;
  8. declare var $: any;
  9.  
  10. interface FileReaderEventTarget extends EventTarget {
  11. result: string
  12. }
  13.  
  14. interface FileReaderEvent extends Event {
  15. target: FileReaderEventTarget;
  16.  
  17. getMessage(): string;
  18. }
  19.  
  20. @Component({
  21. selector: 'scheduler-component',
  22. moduleId: module.id,
  23. changeDetection: ChangeDetectionStrategy.OnPush,
  24. templateUrl: 'dashboard.component.html'
  25. })
  26.  
  27. export class DashboardComponent implements OnInit, AfterViewInit {
  28. public cars: any;
  29. @ViewChild('scheduler')
  30. scheduler: DayPilotSchedulerComponent;
  31.  
  32. events: any[] = [
  33. {
  34. "id": 1,
  35. "resource": "R1",
  36. "start": "2018-09-12T00:00:00",
  37. "end": "2018-09-24T00:00:00",
  38. "text": "Event 1"
  39. },
  40. {
  41. "id": 2,
  42. "resource": "R2",
  43. "start": "2018-09-09T00:00:00",
  44. "end": "2018-09-17T00:00:00",
  45. "text": "Event 2"
  46. }
  47. ];
  48.  
  49. config: any = {
  50. locale: "en-us",
  51. cellWidthSpec: "Fixed",
  52. cellWidth: 40,
  53. crosshairType: "Header",
  54. timeHeaders: [{"groupBy":"Month"},{"groupBy":"Day","format":"d"}],
  55. scale: "Day",
  56. days: DayPilot.Date.today().daysInMonth(),
  57. startDate: DayPilot.Date.today().firstDayOfMonth(),
  58. showNonBusiness: true,
  59. businessWeekends: false,
  60. floatingEvents: true,
  61. eventHeight: 30,
  62. eventMovingStartEndEnabled: false,
  63. eventResizingStartEndEnabled: false,
  64. timeRangeSelectingStartEndEnabled: false,
  65. groupConcurrentEvents: false,
  66. eventStackingLineHeight: 100,
  67. allowEventOverlap: true,
  68. timeRangeSelectedHandling: "Enabled",
  69. onTimeRangeSelected: function (args) {
  70. var dp = this;
  71. DayPilot.Modal.prompt("Create a new event:", "Event 1").then(function(modal) {
  72. dp.clearSelection();
  73. if (!modal.result) { return; }
  74. dp.events.add(new DayPilot.Event({
  75. start: args.start,
  76. end: args.end,
  77. id: DayPilot.guid(),
  78. resource: args.resource,
  79. text: modal.result
  80. }));
  81. });
  82. },
  83.  
  84. resources: [
  85. {
  86. "name": "Resource 1",
  87. "id": "R1"
  88. },
  89. {
  90. "name": "Resource 2",
  91. "id": "R2"
  92. }
  93. ]
  94. };
  95.  
  96. constructor(private ds: SchedulerDataService, public router: Router, public service: ApiService) {
  97. this.service.getCars('114').then(data => {
  98. this.cars = data.items;
  99. console.log("auto", this.cars);
  100.  
  101. });
  102. }
  103.  
  104. ngAfterViewInit(): void {
  105. }
  106.  
  107. /* public cars: any;
  108. public carProva = "Fiat Panda";
  109.  
  110. @ViewChild("scheduler")
  111. scheduler: DayPilotSchedulerComponent;
  112.  
  113. config: any = {
  114. locale: "it-it",
  115. cellWidthSpec: "Auto",
  116. crosshairType: "Header",
  117. timeHeaders: [{"groupBy":"Month"},{"groupBy":"Day","format":"d"},{"groupBy":"Cell","format":"tt"}],
  118. scale: "CellDuration",
  119. cellDuration: 720,
  120. days: 32,
  121. startDate: new Date(Date.now()),
  122. showNonBusiness: true,
  123. businessWeekends: false,
  124. floatingEvents: false,
  125. eventHeight: 30,
  126. eventMovingStartEndEnabled: false,
  127. eventResizingStartEndEnabled: false,
  128. timeRangeSelectingStartEndEnabled: false,
  129. groupConcurrentEvents: false,
  130. eventStackingLineHeight: 100,
  131. allowEventOverlap: false,
  132. timeRangeSelectedHandling: "Disabled",
  133. eventMoveHandling: "Disabled",
  134. eventResizeHandling: "Disabled",
  135. eventDeleteHandling: "Disabled",
  136. eventClickHandling: "Enabled",
  137. onEventClicked: function (args) {
  138. this.message("Event clicked");
  139. },
  140. eventHoverHandling: "Disabled",
  141. resources: [
  142. {
  143. "name": this.carProva,
  144. "id": "R1"
  145. },
  146. {
  147. "name": "Resource 2",
  148. "id": "R2"
  149. }
  150. ],
  151. events: [
  152. {
  153. "id": 1,
  154. "resource": "R1",
  155. "start": "2018-09-04T00:00:00",
  156. "end": "2018-09-16T00:00:00",
  157. "text": this.carProva,
  158. "bubbleHtml": "<div style='font-weight:bold'>Event Details</div><div>Scheduler Event 1</div>"
  159. },
  160. {
  161. "id": 2,
  162. "resource": "R2",
  163. "start": "2018-09-06T00:00:00",
  164. "end": "2018-09-11T00:00:00",
  165. "text": "Event 2"
  166. }
  167. ]
  168. // events: [
  169. // {
  170. // "id": 1,
  171. // "resource": "R1",
  172. // "start": "2018-09-15T10:00:00",
  173. // "end": "2018-09-25T16:00:00",
  174. // "text": "Event 1"
  175. // },
  176. // {
  177. // "id": 2,
  178. // "resource": "R2",
  179. // "start": "2018-09-06T00:00:00",
  180. // "end": "2018-09-11T00:00:00",
  181. // "text": "Event 2"
  182. // }]
  183. };
  184.  
  185. constructor(private ds: SchedulerDataService, public router: Router, public service: ApiService) {
  186. this.service.getCars('114').then( data => {
  187. this.cars = data.items;
  188. console.log("auto", this.cars);
  189.  
  190. });
  191. }*/
  192.  
  193.  
  194. newCar(){
  195. this.router.navigate(['/newcar']);
  196.  
  197. }
  198. newBooking(){
  199. console.log("click");
  200. this.router.navigate(['/newbooking']);
  201.  
  202. }
  203.  
  204. ngOnInit(){
  205.  
  206. }
  207. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement