diff --git a/workplace/src/app/app.component.ts b/workplace/src/app/app.component.ts index 82b867fb4..697b9380a 100644 --- a/workplace/src/app/app.component.ts +++ b/workplace/src/app/app.component.ts @@ -1,16 +1,15 @@ -import { Component, Input } from '@angular/core'; -import { DataService } from './services/data.service'; -import { RestConnectorService } from './services/rest-connector.service'; -import { environment } from '../environments/environment'; +import {Component} from '@angular/core'; +import {DataService} from './services/data.service'; +import {environment} from '../environments/environment'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'], - providers: [ DataService, RestConnectorService ] + providers: [DataService] }) export class AppComponent { - + workplaceUrl: string = environment.taskanaWorkplaceUrl; adminUrl: string = environment.taskanaAdminUrl; monitorUrl: string = environment.taskanaMonitorUrl; diff --git a/workplace/src/app/app.module.ts b/workplace/src/app/app.module.ts index 037125246..9830e6199 100644 --- a/workplace/src/app/app.module.ts +++ b/workplace/src/app/app.module.ts @@ -1,22 +1,23 @@ -import { BrowserModule } from '@angular/platform-browser'; -import { NgModule } from '@angular/core'; -import { FormsModule } from '@angular/forms'; -import { HttpModule } from '@angular/http'; -import { Ng2AutoCompleteModule } from 'ng2-auto-complete'; -import { HttpClientModule } from '@angular/common/http'; -import { AngularSvgIconModule } from 'angular-svg-icon'; +import {BrowserModule} from '@angular/platform-browser'; +import {NgModule} from '@angular/core'; +import {FormsModule} from '@angular/forms'; +import {Ng2AutoCompleteModule} from 'ng2-auto-complete'; +import {HttpClientModule} from '@angular/common/http'; +import {AngularSvgIconModule} from 'angular-svg-icon'; -import { AppComponent } from './app.component'; -import { AppRoutingModule } from './app-routing.module'; -import { AlertModule } from 'ngx-bootstrap'; -import { SelectorComponent } from './workbasket-selector/workbasket-selector.component'; -import { TasklistComponent } from './tasklist/tasklist.component'; -import { TaskdetailsComponent } from './taskdetails/taskdetails.component'; +import {AppComponent} from './app.component'; +import {AppRoutingModule} from './app-routing.module'; +import {AlertModule} from 'ngx-bootstrap'; +import {SelectorComponent} from './workbasket-selector/workbasket-selector.component'; +import {TasklistComponent} from './tasklist/tasklist.component'; +import {TaskdetailsComponent} from './taskdetails/taskdetails.component'; -import { OrderTasksByPipe } from './util/orderTasksBy.pipe'; +import {OrderTasksByPipe} from './util/orderTasksBy.pipe'; -import { TaskComponent } from './task/task.component'; -import { TasksComponent } from './tasks/tasks.component'; +import {TaskComponent} from './task/task.component'; +import {TasksComponent} from './tasks/tasks.component'; +import {TaskService} from './services/task.service'; +import {WorkbasketService} from './services/workbasket.service'; @NgModule({ @@ -32,14 +33,18 @@ import { TasksComponent } from './tasks/tasks.component'; imports: [ BrowserModule, FormsModule, - HttpModule, AlertModule.forRoot(), Ng2AutoCompleteModule, AppRoutingModule, HttpClientModule, AngularSvgIconModule ], - providers: [HttpClientModule], + providers: [ + HttpClientModule, + TaskService, + WorkbasketService + ], bootstrap: [AppComponent] }) -export class AppModule { } +export class AppModule { +} diff --git a/workplace/src/app/model/classification.ts b/workplace/src/app/model/classification.ts new file mode 100644 index 000000000..f666e0a56 --- /dev/null +++ b/workplace/src/app/model/classification.ts @@ -0,0 +1,15 @@ +import {Links} from './links'; + +export class Classification { + constructor(public classificationId: string, + public key: string, + public category: string, + public type: string, + public domain: string, + public name: string, + public parentId: string, + public priority: number, + public serviceLevel: string, + public _links: Links = new Links()) { + } +} diff --git a/workplace/src/app/model/links.ts b/workplace/src/app/model/links.ts new file mode 100644 index 000000000..b13b35cd4 --- /dev/null +++ b/workplace/src/app/model/links.ts @@ -0,0 +1,8 @@ +export class Links { + constructor( + public self: { 'href': string } = undefined, + public distributionTargets: { 'href': string } = undefined, + public accessItems: { 'href': string } = undefined, + public allWorkbasketUrl: { 'href': string } = undefined + ) { } +} diff --git a/workplace/src/app/model/task.ts b/workplace/src/app/model/task.ts index 84caba98d..e2e6eebcd 100644 --- a/workplace/src/app/model/task.ts +++ b/workplace/src/app/model/task.ts @@ -1,38 +1,26 @@ +import {Classification} from './classification'; +import {Workbasket} from './workbasket'; + export class Task { - - id: string; - created: any; - claimed: any; - completed: any; - modified: any; - planned: any; - due: any; - name: string; - description: string; - priority: number; - state: string; - type: string; - workbasket: string; - owner: string; - - static create(data) { - return new Task(data); - } - - constructor(data) { - this.id = data.id; - this.created = data.created; - this.claimed = data.claimed; - this.completed = data.completed; - this.modified = data.modified; - this.planned = data.planned; - this.due = data.due; - this.name = data.name; - this.description = data.description; - this.priority = data.priority; - this.state = data.state; - this.type = data.type; - this.workbasket = data.workbasket; - this.owner = data.owner; + constructor(public businessProcessId: string, + public parentBusinessProcessId: string, + public owner: string, + public taskId: string, + public created: string, // ISO-8601 + public claimed: string, // ISO-8601 + public completed: string, // ISO-8601 + public modified: string, // ISO-8601 + public planned: string, // ISO-8601 + public due: string, // ISO-8601 + public name: string, + public creator: string, + public description: string, + public note: string, + public state: any, + public isRead: boolean, + public isTransferred: boolean, + public priority: number, + public classificationSummaryResource: Classification, + public workbasketSummaryResource: Workbasket) { } } diff --git a/workplace/src/app/model/workbasket.ts b/workplace/src/app/model/workbasket.ts index 9f4a63e00..6c9270b60 100644 --- a/workplace/src/app/model/workbasket.ts +++ b/workplace/src/app/model/workbasket.ts @@ -1,8 +1,23 @@ +import {Links} from './links'; + export class Workbasket { - key: string; - created: string; - modified: string; - name: string; - description: string; - owner: string; + + constructor(public workbasketId: string, + public created: string = undefined, + public key: string = undefined, + public domain: string = undefined, + public modified: string = undefined, + public name: string = undefined, + public description: string = undefined, + public owner: string = undefined, + public custom1: string = undefined, + public custom2: string = undefined, + public custom3: string = undefined, + public custom4: string = undefined, + public orgLevel1: string = undefined, + public orgLevel2: string = undefined, + public orgLevel3: string = undefined, + public orgLevel4: string = undefined, + public _links: Links = new Links()) { + } } diff --git a/workplace/src/app/services/rest-connector.service.spec.ts b/workplace/src/app/services/rest-connector.service.spec.ts deleted file mode 100644 index e8e748bbf..000000000 --- a/workplace/src/app/services/rest-connector.service.spec.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { TestBed, inject } from '@angular/core/testing'; - -import { RestConnectorService } from './rest-connector.service'; - -describe('RestConnectorService', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - providers: [RestConnectorService] - }); - }); - - it('should be created', inject([RestConnectorService], (service: RestConnectorService) => { - expect(service).toBeTruthy(); - })); -}); diff --git a/workplace/src/app/services/rest-connector.service.ts b/workplace/src/app/services/rest-connector.service.ts deleted file mode 100644 index 5144965ac..000000000 --- a/workplace/src/app/services/rest-connector.service.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { Injectable } from '@angular/core'; -import { Headers, RequestOptions, Http, Response } from '@angular/http'; - -import { Workbasket } from '../model/workbasket'; -import { Task } from '../model/task'; -import { environment } from '../../environments/environment'; -import { Observable } from 'rxjs/Observable'; - -@Injectable() -export class RestConnectorService { - - constructor(private http: Http) { } - - getAllWorkBaskets(): Observable { - return this.http.get(environment.taskanaRestUrl + '/v1/workbaskets?requiredPermission=OPEN', this.createAuthorizationHeader()) - .map(res => res.json()); - } - - findTaskWithWorkbaskets(basketKey: string): Observable { - return this.http.get(environment.taskanaRestUrl + '/v1/tasks?workbasketkey=' - + basketKey + '&state=READY&state=CLAIMED', this.createAuthorizationHeader()) - .map(res => res.json()); - } - - getTask(id: string): Observable { - return this.http.get(environment.taskanaRestUrl + '/v1/tasks/' + id, this.createAuthorizationHeader()) - .map(res => res.json()); - } - - completeTask(id: string): Observable { - return this.http.post(environment.taskanaRestUrl + '/v1/tasks/' + id + '/complete', '', this.createAuthorizationHeader()) - .map(res => res.json()); - } - - claimTask(id: string): Observable { - return this.http.post(environment.taskanaRestUrl + '/v1/tasks/' + id + '/claim', 'test', this.createAuthorizationHeader()) - .map(res => res.json()); - } - - transferTask(taskId: string, workbasketKey: string) { - return this.http.post(environment.taskanaRestUrl + '/v1/tasks/' + taskId - + '/transfer/' + workbasketKey, '', this.createAuthorizationHeader()) - .map(res => res.json()); - } - - private createAuthorizationHeader() { - const headers: Headers = new Headers(); - headers.append('Authorization', 'Basic dXNlcl8xXzE6dXNlcl8xXzE='); - - return new RequestOptions({ headers: headers }); - } -} diff --git a/workplace/src/app/services/task.service.ts b/workplace/src/app/services/task.service.ts new file mode 100644 index 000000000..6a8d94358 --- /dev/null +++ b/workplace/src/app/services/task.service.ts @@ -0,0 +1,42 @@ +import {Task} from '../model/task'; +import {Observable} from 'rxjs/Observable'; +import {HttpClient, HttpHeaders} from '@angular/common/http'; +import {Injectable} from '@angular/core'; +import {environment} from '../../environments/environment'; + +@Injectable() +export class TaskService { + url = environment.taskanaRestUrl + '/v1/tasks'; + + httpOptions = { + headers: new HttpHeaders({ + 'Content-Type': 'application/hal+json', + 'Authorization': 'Basic dXNlcl8xXzE6dXNlcl8xXzE', + 'user': 'user_1_1' + }) + }; + + constructor(private httpClient: HttpClient) { + } + + findTaskWithWorkbaskets(basketKey: string): Observable { + return this.httpClient.get(this.url + '?workbasketId=' + basketKey, this.httpOptions); + } + + getTask(id: string): Observable { + return this.httpClient.get(this.url + '/' + id, this.httpOptions); + } + + completeTask(id: string): Observable { + return this.httpClient.post(this.url + '/' + id + '/complete', '', this.httpOptions); + } + + claimTask(id: string): Observable { + return this.httpClient.post(this.url + '/' + id + '/claim', 'test', this.httpOptions); + } + + transferTask(taskId: string, workbasketKey: string): Observable { + return this.httpClient.post(this.url + '/' + taskId + + '/transfer/' + workbasketKey, '', this.httpOptions); + } +} diff --git a/workplace/src/app/services/workbasket.service.ts b/workplace/src/app/services/workbasket.service.ts new file mode 100644 index 000000000..d2ee96604 --- /dev/null +++ b/workplace/src/app/services/workbasket.service.ts @@ -0,0 +1,25 @@ +import {Injectable} from '@angular/core'; + +import {Workbasket} from '../model/workbasket'; +import {environment} from '../../environments/environment'; +import {Observable} from 'rxjs/Observable'; +import {HttpClient, HttpHeaders} from '@angular/common/http'; + +@Injectable() +export class WorkbasketService { + url = environment.taskanaRestUrl + '/v1/workbaskets'; + + httpOptions = { + headers: new HttpHeaders({ + 'Content-Type': 'application/hal+json', + 'Authorization': 'Basic VEVBTUxFQURfMTpURUFNTEVBRF8x' + }) + }; + + constructor(private httpClient: HttpClient) { + } + + getAllWorkBaskets(): Observable { + return this.httpClient.get(this.url + '?required-permission=OPEN', this.httpOptions); + } +} diff --git a/workplace/src/app/task/task.component.ts b/workplace/src/app/task/task.component.ts index 45a46f1da..7c75fca94 100644 --- a/workplace/src/app/task/task.component.ts +++ b/workplace/src/app/task/task.component.ts @@ -1,9 +1,10 @@ -import { Component, OnInit } from '@angular/core'; -import { Router, ActivatedRoute } from '@angular/router'; -import { Task } from '../model/task'; -import { RestConnectorService } from '../services/rest-connector.service'; -import { Workbasket } from '../model/workbasket'; -import { SafeResourceUrl, DomSanitizer} from '@angular/platform-browser'; +import {Component, OnInit} from '@angular/core'; +import {ActivatedRoute, Router} from '@angular/router'; +import {Task} from '../model/task'; +import {Workbasket} from '../model/workbasket'; +import {DomSanitizer, SafeResourceUrl} from '@angular/platform-browser'; +import {TaskService} from '../services/task.service'; +import {WorkbasketService} from '../services/workbasket.service'; @Component({ @@ -15,32 +16,35 @@ export class TaskComponent implements OnInit { task: Task = null; link: SafeResourceUrl = this.sanitizer.bypassSecurityTrustResourceUrl('https://duckduckgo.com/?q='); - autoCompleteData: string[] = new Array; + autoCompleteData: string[] = []; workbasket: string = null; workbasketKey: string; workbaskets: Workbasket[]; private sub: any; - constructor(private restConnectorService: RestConnectorService, - private route: ActivatedRoute, private router: Router, - private sanitizer: DomSanitizer) { } + constructor(private taskService: TaskService, + private workbasketService: WorkbasketService, + private route: ActivatedRoute, + private router: Router, + private sanitizer: DomSanitizer) { + } ngOnInit() { - const id = this.route.snapshot.params['id']; - this.restConnectorService.getTask(id).subscribe( - t => { - this.task = t; - this.link = this.sanitizer.bypassSecurityTrustResourceUrl('https://duckduckgo.com/?q=' + this.task.name ); - this.restConnectorService.getAllWorkBaskets().subscribe( w => { - this.workbaskets = w; - this.workbaskets.forEach(workbasket => { - if (workbasket.key !== this.task.workbasket) { - this.autoCompleteData.push(workbasket.name); - } - }); - }); - }); + const id = this.route.snapshot.params['id']; + this.taskService.getTask(id).subscribe( + t => { + this.task = t; + this.link = this.sanitizer.bypassSecurityTrustResourceUrl('https://duckduckgo.com/?q=' + this.task.name); + this.workbasketService.getAllWorkBaskets().subscribe(w => { + this.workbaskets = w['_embedded']['workbaskets']; + this.workbaskets.forEach(workbasket => { + if (workbasket.key !== this.task.workbasketSummaryResource.key) { + this.autoCompleteData.push(workbasket.name); + } + }); + }); + }); } transferTask() { @@ -50,19 +54,23 @@ export class TaskComponent implements OnInit { this.workbasketKey = workbasket.key; } }); - this.restConnectorService.transferTask(this.task.id, this.workbasketKey).subscribe( - task => {this.task = task}); + this.taskService.transferTask(this.task.taskId, this.workbasketKey).subscribe( + task => { + this.task = task + }); this.router.navigate(['tasks/']); } } - cancelTask() { - this.router.navigate(['tasks/']); - } + cancelTask() { + this.router.navigate(['tasks/']); + } - completeTask() { - this.restConnectorService.completeTask(this.task.id).subscribe( - task => {this.task = task}); - this.router.navigate(['tasks/']); - } + completeTask() { + this.taskService.completeTask(this.task.taskId).subscribe( + task => { + this.task = task + }); + this.router.navigate(['tasks/']); + } } diff --git a/workplace/src/app/taskdetails/taskdetails.component.html b/workplace/src/app/taskdetails/taskdetails.component.html index 8fc4961ac..a0f88b754 100644 --- a/workplace/src/app/taskdetails/taskdetails.component.html +++ b/workplace/src/app/taskdetails/taskdetails.component.html @@ -1,6 +1,6 @@
- Details for task '{{ task.name }}' (ID={{ task.id }}) + Details for task '{{ task.name }}' (ID={{ task.taskId }})

{{ task.description }}

@@ -13,7 +13,6 @@

Due Date: {{ task.due | date:'medium' }}

Priority: {{ task.priority }}

State: {{ task.state }}

-

Type: {{ task.type }}

-

Workbasket: {{ task.workbasket }}

+

Workbasket: {{ task.workbasketSummaryResource.workbasketId }}

diff --git a/workplace/src/app/tasklist/tasklist.component.html b/workplace/src/app/tasklist/tasklist.component.html index 52dc367ab..541cbe192 100644 --- a/workplace/src/app/tasklist/tasklist.component.html +++ b/workplace/src/app/tasklist/tasklist.component.html @@ -1,27 +1,29 @@ - - - - - - - - + + + + + + + + - + -
IDNameDue DatePriorityStateActions
IDNameDue DatePriorityStateActions
{{ task.id }}{{ task.taskId }} {{ task.name }} {{ task.due | date:'medium' }} {{ task.priority }} {{ task.state }} - -
\ No newline at end of file + diff --git a/workplace/src/app/tasklist/tasklist.component.ts b/workplace/src/app/tasklist/tasklist.component.ts index 34769d5f8..5a69752c6 100644 --- a/workplace/src/app/tasklist/tasklist.component.ts +++ b/workplace/src/app/tasklist/tasklist.component.ts @@ -1,7 +1,7 @@ -import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; -import { Task } from '../model/task'; -import { Router } from '@angular/router'; -import { RestConnectorService } from '../services/rest-connector.service'; +import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; +import {Task} from '../model/task'; +import {Router} from '@angular/router'; +import {TaskService} from '../services/task.service'; @Component({ selector: 'tasklist', @@ -17,7 +17,7 @@ export class TasklistComponent implements OnInit { @Input() tasks: Task[]; - constructor(private restConnectorService: RestConnectorService, private router: Router) { + constructor(private taskService: TaskService, private router: Router) { this.columnForOrdering = 'id'; // default: order tasks by id } @@ -33,7 +33,7 @@ export class TasklistComponent implements OnInit { } openTask(id: string) { - this.restConnectorService.claimTask(id).subscribe(); + this.taskService.claimTask(id).subscribe(); this.router.navigate(['tasks/', id]); } } diff --git a/workplace/src/app/tasks/tasks.component.html b/workplace/src/app/tasks/tasks.component.html index 234b0d924..76d6a5bad 100644 --- a/workplace/src/app/tasks/tasks.component.html +++ b/workplace/src/app/tasks/tasks.component.html @@ -1,13 +1,14 @@
- +
- + +
-
\ No newline at end of file + diff --git a/workplace/src/app/tasks/tasks.component.scss b/workplace/src/app/tasks/tasks.component.scss index e69de29bb..7364a5ab6 100644 --- a/workplace/src/app/tasks/tasks.component.scss +++ b/workplace/src/app/tasks/tasks.component.scss @@ -0,0 +1,12 @@ +.overlay { + width: 100vw; + height: 100vh; + position: fixed; + top: 0; + left: 0; + display: none; +} + +.overlayActive { + display: block; +} diff --git a/workplace/src/app/tasks/tasks.component.ts b/workplace/src/app/tasks/tasks.component.ts index dec327389..bb5150c3a 100644 --- a/workplace/src/app/tasks/tasks.component.ts +++ b/workplace/src/app/tasks/tasks.component.ts @@ -1,6 +1,5 @@ -import { Component, Input } from '@angular/core'; -import { Task } from '../model/task'; -import { environment } from '../../environments/environment'; +import {Component, Input} from '@angular/core'; +import {Task} from '../model/task'; @Component({ selector: 'app-tasks', @@ -9,6 +8,8 @@ import { environment } from '../../environments/environment'; }) export class TasksComponent { + taskDetailEnabled: boolean; + @Input() tasks: Task[]; @@ -20,6 +21,7 @@ export class TasksComponent { } selectTask(task: Task) { + this.taskDetailEnabled = true; this.task = task; } diff --git a/workplace/src/app/workbasket-selector/workbasket-selector.component.html b/workplace/src/app/workbasket-selector/workbasket-selector.component.html index de7e3be0c..1842c6a2f 100644 --- a/workplace/src/app/workbasket-selector/workbasket-selector.component.html +++ b/workplace/src/app/workbasket-selector/workbasket-selector.component.html @@ -1,9 +1,11 @@
- + - +
@@ -12,4 +14,3 @@
- \ No newline at end of file diff --git a/workplace/src/app/workbasket-selector/workbasket-selector.component.ts b/workplace/src/app/workbasket-selector/workbasket-selector.component.ts index e501e4d2c..c75f3acdb 100644 --- a/workplace/src/app/workbasket-selector/workbasket-selector.component.ts +++ b/workplace/src/app/workbasket-selector/workbasket-selector.component.ts @@ -1,8 +1,9 @@ -import { Component, OnInit, Output, EventEmitter } from '@angular/core'; -import { RestConnectorService } from '../services/rest-connector.service'; -import { DataService } from '../services/data.service'; -import { Task } from '../model/task'; -import { Workbasket } from '../model/workbasket'; +import {Component, EventEmitter, OnInit, Output} from '@angular/core'; +import {DataService} from '../services/data.service'; +import {Task} from '../model/task'; +import {Workbasket} from '../model/workbasket'; +import {TaskService} from '../services/task.service'; +import {WorkbasketService} from '../services/workbasket.service'; @Component({ selector: 'workbasket-selector', @@ -11,18 +12,23 @@ import { Workbasket } from '../model/workbasket'; }) export class SelectorComponent implements OnInit { - @Output() tasks = new EventEmitter(); + @Output('tasks') tasksEmitter = new EventEmitter(); - autoCompleteData: string[] = new Array; + tasks: Task[] = []; + + autoCompleteData: string[] = []; result: string; resultKey: string; workbaskets: Workbasket[]; - constructor(private restConnectorService: RestConnectorService, private dataService: DataService) { } + constructor(private taskService: TaskService, + private workbasketService: WorkbasketService, + private dataService: DataService) { + } ngOnInit() { - this.restConnectorService.getAllWorkBaskets().subscribe( w => { - this.workbaskets = w; + this.workbasketService.getAllWorkBaskets().subscribe(w => { + this.workbaskets = w['_embedded']['workbaskets']; this.workbaskets.forEach(workbasket => { this.autoCompleteData.push(workbasket.name); }); @@ -37,17 +43,20 @@ export class SelectorComponent implements OnInit { if (this.workbaskets) { this.workbaskets.forEach(workbasket => { if (workbasket.name === this.result) { - this.resultKey = workbasket.key; + this.resultKey = workbasket.workbasketId; } }); this.getTasks(this.resultKey); this.dataService.workbasketKey = this.resultKey; this.dataService.workbasketName = this.result; + this.tasksEmitter.emit(this.tasks); } } getTasks(workbasketKey: string) { - this.restConnectorService.findTaskWithWorkbaskets(workbasketKey).subscribe( - tasks2 => {this.tasks.next(tasks2)}); + this.taskService.findTaskWithWorkbaskets(workbasketKey).subscribe( + tasks2 => { + tasks2['_embedded']['tasks'].forEach(e => this.tasks.push(e)); + }); } }