Skip to content

Commit

Permalink
11.0 Conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Attila Németh committed Dec 31, 2020
2 parents b069aa5 + 683c5db commit 016c18a
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 9 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Drupal

This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.12.
[![GitHub release](https://img.shields.io/github/release/attus74/drupal.svg)](https://GitHub.com/attus74/drupal/releases/)

## A library for Angular-Drupal Communication

Expand Down Expand Up @@ -77,5 +77,10 @@ export class MyComponent implements OnInit {
return this.drupal.get(path, options);
}

loginUser(username: string, password: string): void {
// There is no direct answer, but you can subscribe the result, see getUserLoginStatus()
this.drupal.login(username, password);
}

}
```
```
23 changes: 21 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
{
"name": "@attus/drupal",
"version": "11.0.0",
"description": "Drupal Service",
"homepage": "https://github.com/attus74/drupal",
"author": "Attila Németh",
"repository": {
"type": "git",
"url": "git+https://github.com/attus74/drupal.git"
},
"peerDependencies": {
"@angular/common": "^11.0",
"@angular/core": "^11.0"
},
"dependencies": {
"tslib": "^1.10.0"
}
}
},
"bugs": {
"url": "https://github.com/attus74/drupal/issues"
},
"main": "karma.conf.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"Drupal",
"Angular"
],
"license": "GPL-3.0"
}
7 changes: 4 additions & 3 deletions src/lib/drupal.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { HttpClientModule } from '@angular/common/http';
import { DrupalComponent } from './drupal.component';
import { DrupalService } from './drupal.service';


@NgModule({
declarations: [DrupalComponent],
imports: [
Expand All @@ -13,8 +12,10 @@ import { DrupalService } from './drupal.service';
DrupalService,
{
provide: APP_INITIALIZER,
useFactory: (drupal: DrupalService) => {
return () => drupal.initialize()
useFactory: function(drupal: DrupalService) {
return function() {
drupal.initialize();
}
},
deps: [DrupalService],
multi: true
Expand Down
12 changes: 10 additions & 2 deletions src/lib/drupal.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class DrupalService {

async initialize(): Promise<any> {
console.info('Drupal Service wurde initialisiert');
this.refreshToken();
return this.refreshToken();
}

login(username: string, password: string): void {
Expand Down Expand Up @@ -64,7 +64,7 @@ export class DrupalService {

get(path: string, options: DrupalHttpOptions): Observable<any> {
return this.http.get(this.drupalConfig.url + '/' + path, options).pipe(
retry(3),
retry(5),
timeout(8000),
catchError(this.formatErrors),
);
Expand All @@ -78,6 +78,14 @@ export class DrupalService {
);
}

patch(path: string, data: any, options?: DrupalHttpOptions): Observable<any> {
return this.http.patch(this.drupalConfig.url + '/' + path, data, options).pipe(
retry(3),
timeout(24000),
catchError(this.formatErrors),
);
}

private refreshToken(): void {
this.tokenService.getRefreshToken().then(token => {
if (token === null) {
Expand Down
4 changes: 4 additions & 0 deletions src/lib/model/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export class DrupalHttpOptions {
this.headers = this.headers.set(name, value);
}

setJsonApiHeaders(): void {
this.headers = this.headers.set('Content-Type', 'application/vnd.api+json');
}

setParam(name: string, value: any): void {
if (this.params === null) {
this.params = new HttpParams();
Expand Down

0 comments on commit 016c18a

Please sign in to comment.