-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dnn-sxc-angular improvements api, query, sxc -> sxcApp, added utils
- Loading branch information
1 parent
3e9cd24
commit ae9bb03
Showing
8 changed files
with
76 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
projects/dnn-sxc-angular/projects/dnn-sxc-angular/src/lib/sxc/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export * from './api'; | ||
export * from './data'; | ||
export * from './sxc-data'; | ||
export * from './sxc-app'; | ||
export * from './query'; | ||
export * from './metadata-for'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
projects/dnn-sxc-angular/projects/dnn-sxc-angular/src/lib/sxc/sxc-app.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Api } from './api'; | ||
import { Data } from './data'; | ||
import { HttpClient } from '@angular/common/http'; | ||
import { Injectable } from '@angular/core'; | ||
import { Query } from './query'; | ||
|
||
/** | ||
* 2sxc data provider | ||
* gives you access to content and query streams using the content$ and query$ commands | ||
* you can also use the content and query managers, but these are currently not so useful. | ||
* | ||
* @export | ||
* @class SxcData | ||
*/ | ||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class SxcApp { | ||
constructor( | ||
private http: HttpClient, | ||
) { } | ||
|
||
/** | ||
* Cet a content manager object for a specific ContentType | ||
* @param contentType name of the content-type | ||
* @returns a query object with .getAll(), .getOne(), .create(), .update(), .delete() | ||
*/ | ||
public data<T>(contentType: string): Data<T> { | ||
return new Data<T>(this.http, contentType); | ||
} | ||
|
||
/** | ||
* get a query object to then start queries | ||
* @param name the query name | ||
* @returns a query object with .getAll(), .getStreams(), .getStream() | ||
*/ | ||
public query<T>(name: string) { | ||
return new Query<T>(this.http, name); | ||
} | ||
|
||
/** | ||
* get an api object to then start api-calls | ||
* @param controller the api controller | ||
* @returns an API object with .url(), .get<T>(), .post<T>(), .put<T>(), .delete<T>() method | ||
*/ | ||
public api(controller: string): Api { | ||
return new Api(this.http, controller); | ||
} | ||
} |
72 changes: 0 additions & 72 deletions
72
projects/dnn-sxc-angular/projects/dnn-sxc-angular/src/lib/sxc/sxc-data.ts
This file was deleted.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
projects/dnn-sxc-angular/projects/dnn-sxc-angular/src/utils/params.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { HttpParams } from '@angular/common/http'; | ||
|
||
export function getHttpParams(params: HttpParams | string) { | ||
return typeof(params) !== 'string' ? params : new HttpParams({fromString: params}); | ||
} |