diff --git a/src/Squidex/Areas/Api/Controllers/Languages/LanguagesController.cs b/src/Squidex/Areas/Api/Controllers/Languages/LanguagesController.cs
index 553124afb..77ca6fed2 100644
--- a/src/Squidex/Areas/Api/Controllers/Languages/LanguagesController.cs
+++ b/src/Squidex/Areas/Api/Controllers/Languages/LanguagesController.cs
@@ -15,7 +15,7 @@ using Squidex.Pipeline;
namespace Squidex.Areas.Api.Controllers.Languages
{
///
- /// Readonly API to the supported langauges.
+ /// Readonly API for supported languages.
///
[ApiExplorerSettings(GroupName = nameof(Languages))]
public sealed class LanguagesController : ApiController
diff --git a/src/Squidex/Areas/Api/Controllers/News/Models/FeatureDto.cs b/src/Squidex/Areas/Api/Controllers/News/Models/FeatureDto.cs
new file mode 100644
index 000000000..7f1897047
--- /dev/null
+++ b/src/Squidex/Areas/Api/Controllers/News/Models/FeatureDto.cs
@@ -0,0 +1,26 @@
+// ==========================================================================
+// Squidex Headless CMS
+// ==========================================================================
+// Copyright (c) Squidex UG (haftungsbeschraenkt)
+// All rights reserved. Licensed under the MIT license.
+// ==========================================================================
+
+using System.ComponentModel.DataAnnotations;
+
+namespace Squidex.Areas.Api.Controllers.News.Models
+{
+ public sealed class FeatureDto
+ {
+ ///
+ /// The name of the feature.
+ ///
+ [Required]
+ public string Name { get; set; }
+
+ ///
+ /// The description text.
+ ///
+ [Required]
+ public string Description { get; set; }
+ }
+}
diff --git a/src/Squidex/Areas/Api/Controllers/News/Models/FeaturesDto.cs b/src/Squidex/Areas/Api/Controllers/News/Models/FeaturesDto.cs
new file mode 100644
index 000000000..b0535aaa3
--- /dev/null
+++ b/src/Squidex/Areas/Api/Controllers/News/Models/FeaturesDto.cs
@@ -0,0 +1,26 @@
+// ==========================================================================
+// Squidex Headless CMS
+// ==========================================================================
+// Copyright (c) Squidex UG (haftungsbeschraenkt)
+// All rights reserved. Licensed under the MIT license.
+// ==========================================================================
+
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+
+namespace Squidex.Areas.Api.Controllers.News.Models
+{
+ public class FeaturesDto
+ {
+ ///
+ /// The latest features.
+ ///
+ [Required]
+ public List Features { get; set; }
+
+ ///
+ /// The recent version.
+ ///
+ public int Version { get; set; }
+ }
+}
diff --git a/src/Squidex/Areas/Api/Controllers/News/NewsController.cs b/src/Squidex/Areas/Api/Controllers/News/NewsController.cs
new file mode 100644
index 000000000..01d714501
--- /dev/null
+++ b/src/Squidex/Areas/Api/Controllers/News/NewsController.cs
@@ -0,0 +1,48 @@
+// ==========================================================================
+// Squidex Headless CMS
+// ==========================================================================
+// Copyright (c) Squidex UG (haftungsbeschraenkt)
+// All rights reserved. Licensed under the MIT license.
+// ==========================================================================
+
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc;
+using Squidex.Areas.Api.Controllers.News.Models;
+using Squidex.Areas.Api.Controllers.News.Service;
+using Squidex.Infrastructure.Commands;
+using Squidex.Pipeline;
+
+namespace Squidex.Areas.Api.Controllers.News
+{
+ ///
+ /// Readonly API for news items.
+ ///
+ [ApiExplorerSettings(GroupName = nameof(Languages))]
+ public sealed class NewsController : ApiController
+ {
+ private readonly FeaturesService featuresService = new FeaturesService();
+
+ public NewsController(ICommandBus commandBus)
+ : base(commandBus)
+ {
+ }
+
+ ///
+ /// Get all features since latest version.
+ ///
+ /// The latest received version.
+ ///
+ /// 200 => Latest features returned.
+ ///
+ [HttpGet]
+ [Route("news/features/")]
+ [ProducesResponseType(typeof(FeaturesDto), 200)]
+ [ApiPermission]
+ public async Task GetLanguages([FromQuery] int version = 0)
+ {
+ var features = await featuresService.GetFeaturesAsync(version);
+
+ return Ok(features);
+ }
+ }
+}
diff --git a/src/Squidex/Areas/Api/Controllers/News/Service/FeaturesService.cs b/src/Squidex/Areas/Api/Controllers/News/Service/FeaturesService.cs
new file mode 100644
index 000000000..050c738d8
--- /dev/null
+++ b/src/Squidex/Areas/Api/Controllers/News/Service/FeaturesService.cs
@@ -0,0 +1,50 @@
+// ==========================================================================
+// Squidex Headless CMS
+// ==========================================================================
+// Copyright (c) Squidex UG (haftungsbeschraenkt)
+// All rights reserved. Licensed under the MIT license.
+// ==========================================================================
+
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Squidex.Areas.Api.Controllers.News.Models;
+using Squidex.ClientLibrary;
+
+namespace Squidex.Areas.Api.Controllers.News.Service
+{
+ public sealed class FeaturesService
+ {
+ private const string AppName = "squidex-website";
+ private const string ClientId = "squidex-website:default";
+ private const string ClientSecret = "QGgqxd7bDHBTEkpC6fj8sbdPWgZrPrPfr3xzb3LKoec=";
+ private const int FeatureVersion = 1;
+ private static readonly QueryContext Flatten = QueryContext.Default.Flatten();
+ private readonly SquidexClient client;
+
+ public sealed class NewsEntity : SquidexEntityBase
+ {
+ }
+
+ public FeaturesService()
+ {
+ var clientManager = new SquidexClientManager("https://cloud.squidex.io", AppName, ClientId, ClientSecret);
+
+ client = clientManager.GetClient("feature-news");
+ }
+
+ public async Task GetFeaturesAsync(int version = 0)
+ {
+ var result = new FeaturesDto { Features = new List(), Version = FeatureVersion };
+
+ if (version < FeatureVersion)
+ {
+ var entities = await client.GetAsync(filter: $"data/version/iv ge ${version}", context: Flatten);
+
+ result.Features.AddRange(entities.Items.Select(x => x.Data));
+ }
+
+ return result;
+ }
+ }
+}
diff --git a/src/Squidex/app/features/administration/services/event-consumers.service.ts b/src/Squidex/app/features/administration/services/event-consumers.service.ts
index c768c9231..74de8309a 100644
--- a/src/Squidex/app/features/administration/services/event-consumers.service.ts
+++ b/src/Squidex/app/features/administration/services/event-consumers.service.ts
@@ -12,7 +12,6 @@ import { map } from 'rxjs/operators';
import {
ApiUrlConfig,
- HTTP,
Model,
pretifyError
} from '@app/shared';
@@ -44,13 +43,9 @@ export class EventConsumersService {
public getEventConsumers(): Observable {
const url = this.apiUrl.buildUrl('/api/event-consumers');
- return HTTP.getVersioned(this.http, url).pipe(
+ return this.http.get(url).pipe(
map(response => {
- const body = response.payload.body;
-
- const items: any[] = body;
-
- return items.map(item => {
+ return response.map(item => {
return new EventConsumerDto(
item.name,
item.isStopped,
@@ -65,21 +60,21 @@ export class EventConsumersService {
public putStart(name: string): Observable {
const url = this.apiUrl.buildUrl(`api/event-consumers/${name}/start`);
- return HTTP.putVersioned(this.http, url, {}).pipe(
+ return this.http.put(url, {}).pipe(
pretifyError('Failed to start event consumer. Please reload.'));
}
public putStop(name: string): Observable {
const url = this.apiUrl.buildUrl(`api/event-consumers/${name}/stop`);
- return HTTP.putVersioned(this.http, url, {}).pipe(
+ return this.http.put(url, {}).pipe(
pretifyError('Failed to stop event consumer. Please reload.'));
}
public putReset(name: string): Observable {
const url = this.apiUrl.buildUrl(`api/event-consumers/${name}/reset`);
- return HTTP.putVersioned(this.http, url, {}).pipe(
+ return this.http.put(url, {}).pipe(
pretifyError('Failed to reset event consumer. Please reload.'));
}
}
\ No newline at end of file
diff --git a/src/Squidex/app/features/administration/services/users.service.ts b/src/Squidex/app/features/administration/services/users.service.ts
index 7d92348c5..32152110b 100644
--- a/src/Squidex/app/features/administration/services/users.service.ts
+++ b/src/Squidex/app/features/administration/services/users.service.ts
@@ -12,7 +12,6 @@ import { map } from 'rxjs/operators';
import {
ApiUrlConfig,
- HTTP,
Model,
pretifyError
} from '@app/shared';
@@ -73,13 +72,9 @@ export class UsersService {
public getUsers(take: number, skip: number, query?: string): Observable {
const url = this.apiUrl.buildUrl(`api/user-management?take=${take}&skip=${skip}&query=${query || ''}`);
- return HTTP.getVersioned(this.http, url).pipe(
+ return this.http.get<{ total: number, items: any[] }>(url).pipe(
map(response => {
- const body = response.payload.body;
-
- const items: any[] = body.items;
-
- const users = items.map(item => {
+ const users = response.items.map(item => {
return new UserDto(
item.id,
item.email,
@@ -88,7 +83,7 @@ export class UsersService {
item.isLocked);
});
- return new UsersDto(body.total, users);
+ return new UsersDto(response.total, users);
}),
pretifyError('Failed to load users. Please reload.'));
}
@@ -96,16 +91,14 @@ export class UsersService {
public getUser(id: string): Observable {
const url = this.apiUrl.buildUrl(`api/user-management/${id}`);
- return HTTP.getVersioned(this.http, url).pipe(
+ return this.http.get(url).pipe(
map(response => {
- const body = response.payload.body;
-
return new UserDto(
- body.id,
- body.email,
- body.displayName,
- body.permissions,
- body.isLocked);
+ response.id,
+ response.email,
+ response.displayName,
+ response.permissions,
+ response.isLocked);
}),
pretifyError('Failed to load user. Please reload.'));
}
@@ -113,12 +106,10 @@ export class UsersService {
public postUser(dto: CreateUserDto): Observable {
const url = this.apiUrl.buildUrl('api/user-management');
- return HTTP.postVersioned(this.http, url, dto).pipe(
+ return this.http.post(url, dto).pipe(
map(response => {
- const body = response.payload.body;
-
return new UserDto(
- body.id,
+ response.id,
dto.email,
dto.displayName,
dto.permissions,
@@ -130,21 +121,21 @@ export class UsersService {
public putUser(id: string, dto: UpdateUserDto): Observable {
const url = this.apiUrl.buildUrl(`api/user-management/${id}`);
- return HTTP.putVersioned(this.http, url, dto).pipe(
+ return this.http.put(url, dto).pipe(
pretifyError('Failed to update user. Please reload.'));
}
public lockUser(id: string): Observable {
const url = this.apiUrl.buildUrl(`api/user-management/${id}/lock`);
- return HTTP.putVersioned(this.http, url, {}).pipe(
+ return this.http.put(url, {}).pipe(
pretifyError('Failed to load users. Please retry.'));
}
public unlockUser(id: string): Observable {
const url = this.apiUrl.buildUrl(`api/user-management/${id}/unlock`);
- return HTTP.putVersioned(this.http, url, {}).pipe(
+ return this.http.put(url, {}).pipe(
pretifyError('Failed to load users. Please retry.'));
}
}
\ No newline at end of file
diff --git a/src/Squidex/app/shared/internal.ts b/src/Squidex/app/shared/internal.ts
index a95ed3f7b..f35c73d9d 100644
--- a/src/Squidex/app/shared/internal.ts
+++ b/src/Squidex/app/shared/internal.ts
@@ -34,6 +34,7 @@ export * from './services/graphql.service';
export * from './services/help.service';
export * from './services/history.service';
export * from './services/languages.service';
+export * from './services/news.service';
export * from './services/plans.service';
export * from './services/rules.service';
export * from './services/schemas.service';
diff --git a/src/Squidex/app/shared/module.ts b/src/Squidex/app/shared/module.ts
index f7d6c9380..2e7a9c5e9 100644
--- a/src/Squidex/app/shared/module.ts
+++ b/src/Squidex/app/shared/module.ts
@@ -60,6 +60,7 @@ import {
MarkdownEditorComponent,
MustBeAuthenticatedGuard,
MustBeNotAuthenticatedGuard,
+ NewsService,
PatternsState,
PermissionDirective,
PlansService,
@@ -192,6 +193,7 @@ export class SqxSharedModule {
LoadLanguagesGuard,
MustBeAuthenticatedGuard,
MustBeNotAuthenticatedGuard,
+ NewsService,
PatternsState,
PlansService,
PlansState,
diff --git a/src/Squidex/app/shared/services/assets.service.ts b/src/Squidex/app/shared/services/assets.service.ts
index 68429ee8d..1f74a935a 100644
--- a/src/Squidex/app/shared/services/assets.service.ts
+++ b/src/Squidex/app/shared/services/assets.service.ts
@@ -128,8 +128,8 @@ export class AssetsService {
public getTags(appName: string): Observable<{ [name: string]: number }> {
const url = this.apiUrl.buildUrl(`api/apps/${appName}/assets/tags`);
- return this.http.get(url).pipe(
- map(response => response));
+ return HTTP.getVersioned(this.http, url).pipe(
+ map(response => response.payload.body));
}
public getAssets(appName: string, take: number, skip: number, query?: string, tags?: string[], ids?: string[]): Observable {
diff --git a/src/Squidex/app/shared/services/backups.service.ts b/src/Squidex/app/shared/services/backups.service.ts
index 68b8298a3..198db6775 100644
--- a/src/Squidex/app/shared/services/backups.service.ts
+++ b/src/Squidex/app/shared/services/backups.service.ts
@@ -63,11 +63,9 @@ export class BackupsService {
public getBackups(appName: string): Observable {
const url = this.apiUrl.buildUrl(`api/apps/${appName}/backups`);
- return this.http.get(url).pipe(
+ return this.http.get(url).pipe(
map(response => {
- const items: any[] = response;
-
- return items.map(item => {
+ return response.map(item => {
return new BackupDto(
item.id,
DateTime.parseISO_UTC(item.started),
@@ -83,16 +81,14 @@ export class BackupsService {
public getRestore(): Observable {
const url = this.apiUrl.buildUrl(`api/apps/restore`);
- return this.http.get(url).pipe(
+ return this.http.get(url).pipe(
map(response => {
- const body: any = response;
-
return new RestoreDto(
- body.url,
- DateTime.parseISO_UTC(body.started),
- body.stopped ? DateTime.parseISO_UTC(body.stopped) : null,
- body.status,
- body.log);
+ response.url,
+ DateTime.parseISO_UTC(response.started),
+ response.stopped ? DateTime.parseISO_UTC(response.stopped) : null,
+ response.status,
+ response.log);
}),
catchError(error => {
if (Types.is(error, HttpErrorResponse) && error.status === 404) {
diff --git a/src/Squidex/app/shared/services/comments.service.ts b/src/Squidex/app/shared/services/comments.service.ts
index ca93570f6..e60a44f32 100644
--- a/src/Squidex/app/shared/services/comments.service.ts
+++ b/src/Squidex/app/shared/services/comments.service.ts
@@ -15,7 +15,8 @@ import {
DateTime,
Model,
pretifyError,
- Version
+ Version,
+ HTTP
} from '@app/framework';
export class CommentsDto extends Model {
@@ -62,9 +63,9 @@ export class CommentsService {
public getComments(appName: string, commentsId: string, version: Version): Observable {
const url = this.apiUrl.buildUrl(`api/apps/${appName}/comments/${commentsId}?version=${version.value}`);
- return this.http.get(url).pipe(
+ return HTTP.getVersioned(this.http, url).pipe(
map(response => {
- const body: any = response;
+ const body: any = response.payload.body;
return new CommentsDto(
body.createdComments.map((item: any) => {
diff --git a/src/Squidex/app/shared/services/help.service.ts b/src/Squidex/app/shared/services/help.service.ts
index dd5e4a535..c141dae7b 100644
--- a/src/Squidex/app/shared/services/help.service.ts
+++ b/src/Squidex/app/shared/services/help.service.ts
@@ -8,7 +8,7 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable, of } from 'rxjs';
-import { catchError, map } from 'rxjs/operators';
+import { catchError } from 'rxjs/operators';
@Injectable()
export class HelpService {
@@ -21,9 +21,6 @@ export class HelpService {
const url = `https://raw.githubusercontent.com/Squidex/squidex-docs/master/${helpPage}.md`;
return this.http.get(url, { responseType: 'text' }).pipe(
- map((response: any) => {
- return response;
- }),
- catchError(error => of('')));
+ catchError(_ => of('')));
}
}
\ No newline at end of file
diff --git a/src/Squidex/app/shared/services/history.service.ts b/src/Squidex/app/shared/services/history.service.ts
index 0a3e14b0e..b2c00fbae 100644
--- a/src/Squidex/app/shared/services/history.service.ts
+++ b/src/Squidex/app/shared/services/history.service.ts
@@ -15,7 +15,6 @@ import { UsersProviderService } from './users-provider.service';
import {
ApiUrlConfig,
DateTime,
- HTTP,
pretifyError
} from '@app/framework';
@@ -82,13 +81,9 @@ export class HistoryService {
public getHistory(appName: string, channel: string): Observable {
const url = this.apiUrl.buildUrl(`api/apps/${appName}/history?channel=${channel}`);
- return HTTP.getVersioned(this.http, url).pipe(
+ return this.http.get(url).pipe(
map(response => {
- const body = response.payload.body;
-
- const items: any[] = body;
-
- return items.map(item => {
+ return response.map(item => {
return new HistoryEventDto(
item.eventId,
item.actor,
diff --git a/src/Squidex/app/shared/services/languages.service.ts b/src/Squidex/app/shared/services/languages.service.ts
index f396eba1a..d2af87541 100644
--- a/src/Squidex/app/shared/services/languages.service.ts
+++ b/src/Squidex/app/shared/services/languages.service.ts
@@ -35,11 +35,9 @@ export class LanguagesService {
public getLanguages(): Observable {
const url = this.apiUrl.buildUrl('api/languages');
- return HTTP.getVersioned(this.http, url).pipe(
+ return HTTP.getVersioned(this.http, url).pipe(
map(response => {
- const body = response.payload.body;
-
- const items: any[] = body;
+ const items: any[] = response.payload.body;
return items.map(item => {
return new LanguageDto(
diff --git a/src/Squidex/app/shared/services/news.service.spec.ts b/src/Squidex/app/shared/services/news.service.spec.ts
new file mode 100644
index 000000000..9e3be0005
--- /dev/null
+++ b/src/Squidex/app/shared/services/news.service.spec.ts
@@ -0,0 +1,66 @@
+/*
+ * Squidex Headless CMS
+ *
+ * @license
+ * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
+ */
+
+import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
+import { inject, TestBed } from '@angular/core/testing';
+
+import {
+ ApiUrlConfig,
+ FeatureDto,
+ FeaturesDto,
+ NewsService
+} from './../';
+
+describe('NewsService', () => {
+ beforeEach(() => {
+ TestBed.configureTestingModule({
+ imports: [
+ HttpClientTestingModule
+ ],
+ providers: [
+ NewsService,
+ { provide: ApiUrlConfig, useValue: new ApiUrlConfig('http://service/p/') }
+ ]
+ });
+ });
+
+ afterEach(inject([HttpTestingController], (httpMock: HttpTestingController) => {
+ httpMock.verify();
+ }));
+
+ it('should make get request to get features',
+ inject([NewsService, HttpTestingController], (newsService: NewsService, httpMock: HttpTestingController) => {
+
+ let features: FeaturesDto;
+
+ newsService.getFeatures().subscribe(result => {
+ features = result;
+ });
+
+ const req = httpMock.expectOne('http://service/p/api/news/features');
+
+ expect(req.request.method).toEqual('GET');
+ expect(req.request.headers.get('If-Match')).toBeNull();
+
+ req.flush({
+ version: 13,
+ features: [{
+ name: 'Feature1',
+ text: 'Feature Text1'
+ }, {
+ name: 'Feature2',
+ text: 'Feature Text2'
+ }]
+ });
+
+ expect(features!).toEqual(
+ new FeaturesDto([
+ new FeatureDto('Feature1', 'Feature Text1'),
+ new FeatureDto('Feature2', 'Feature Text2')
+ ], 13));
+ }));
+});
\ No newline at end of file
diff --git a/src/Squidex/app/shared/services/news.service.ts b/src/Squidex/app/shared/services/news.service.ts
new file mode 100644
index 000000000..816a45997
--- /dev/null
+++ b/src/Squidex/app/shared/services/news.service.ts
@@ -0,0 +1,64 @@
+/*
+ * Squidex Headless CMS
+ *
+ * @license
+ * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
+ */
+
+import { HttpClient } from '@angular/common/http';
+import { Injectable } from '@angular/core';
+import { Observable } from 'rxjs';
+import { map } from 'rxjs/operators';
+
+import {
+ ApiUrlConfig,
+ HTTP,
+ pretifyError
+} from '@app/framework';
+
+export class FeatureDto {
+ constructor(
+ public readonly name: string,
+ public readonly text: string
+ ) {
+ }
+}
+
+export class FeaturesDto {
+ constructor(
+ public readonly features: FeatureDto[],
+ public readonly version: number
+ ) {
+ }
+}
+
+@Injectable()
+export class NewsService {
+ constructor(
+ private readonly http: HttpClient,
+ private readonly apiUrl: ApiUrlConfig
+ ) {
+ }
+
+ public getFeatures(): Observable {
+ const url = this.apiUrl.buildUrl('api/news/features');
+
+ return HTTP.getVersioned(this.http, url).pipe(
+ map(response => {
+ const body = response.payload.body;
+
+ const items: any[] = body.features;
+
+ return new FeaturesDto(
+ items.map(item => {
+ return new FeatureDto(
+ item.name,
+ item.text
+ );
+ }),
+ body.version
+ );
+ }),
+ pretifyError('Failed to load features. Please reload.'));
+ }
+}
\ No newline at end of file
diff --git a/src/Squidex/app/shared/services/usages.service.ts b/src/Squidex/app/shared/services/usages.service.ts
index 81220db48..2ba97a36f 100644
--- a/src/Squidex/app/shared/services/usages.service.ts
+++ b/src/Squidex/app/shared/services/usages.service.ts
@@ -13,7 +13,6 @@ import { map } from 'rxjs/operators';
import {
ApiUrlConfig,
DateTime,
- HTTP,
pretifyError
} from '@app/framework';
@@ -72,11 +71,9 @@ export class UsagesService {
public getMonthCalls(app: string): Observable {
const url = this.apiUrl.buildUrl(`api/apps/${app}/usages/calls/month`);
- return HTTP.getVersioned(this.http, url).pipe(
+ return this.http.get(url).pipe(
map(response => {
- const body = response.payload.body;
-
- return new CurrentCallsDto(body.count, body.maxAllowed);
+ return new CurrentCallsDto(response.count, response.maxAllowed);
}),
pretifyError('Failed to load monthly api calls. Please reload.'));
}
@@ -84,11 +81,9 @@ export class UsagesService {
public getTodayStorage(app: string): Observable {
const url = this.apiUrl.buildUrl(`api/apps/${app}/usages/storage/today`);
- return HTTP.getVersioned(this.http, url).pipe(
+ return this.http.get(url).pipe(
map(response => {
- const body = response.payload.body;
-
- return new CurrentStorageDto(body.size, body.maxAllowed);
+ return new CurrentStorageDto(response.size, response.maxAllowed);
}),
pretifyError('Failed to load todays storage size. Please reload.'));
}
@@ -96,14 +91,12 @@ export class UsagesService {
public getCallsUsages(app: string, fromDate: DateTime, toDate: DateTime): Observable<{ [category: string]: CallsUsageDto[] }> {
const url = this.apiUrl.buildUrl(`api/apps/${app}/usages/calls/${fromDate.toUTCStringFormat('YYYY-MM-DD')}/${toDate.toUTCStringFormat('YYYY-MM-DD')}`);
- return HTTP.getVersioned(this.http, url).pipe(
+ return this.http.get(url).pipe(
map(response => {
- const body = response.payload.body;
-
const result: { [category: string]: CallsUsageDto[] } = {};
- for (let category of Object.keys(body)) {
- result[category] = body[category].map((item: any) => {
+ for (let category of Object.keys(response)) {
+ result[category] = response[category].map((item: any) => {
return new CallsUsageDto(
DateTime.parseISO_UTC(item.date),
item.count,
@@ -118,13 +111,9 @@ export class UsagesService {
public getStorageUsages(app: string, fromDate: DateTime, toDate: DateTime): Observable {
const url = this.apiUrl.buildUrl(`api/apps/${app}/usages/storage/${fromDate.toUTCStringFormat('YYYY-MM-DD')}/${toDate.toUTCStringFormat('YYYY-MM-DD')}`);
- return HTTP.getVersioned(this.http, url).pipe(
+ return this.http.get(url).pipe(
map(response => {
- const body = response.payload.body;
-
- const items: any[] = body;
-
- return items.map(item => {
+ return response.map(item => {
return new StorageUsageDto(
DateTime.parseISO_UTC(item.date),
item.count,
diff --git a/src/Squidex/app/shared/services/users.service.ts b/src/Squidex/app/shared/services/users.service.ts
index 4a513099d..c11889dde 100644
--- a/src/Squidex/app/shared/services/users.service.ts
+++ b/src/Squidex/app/shared/services/users.service.ts
@@ -10,11 +10,7 @@ import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
-import {
- ApiUrlConfig,
- HTTP,
- pretifyError
-} from '@app/framework';
+import { ApiUrlConfig, pretifyError } from '@app/framework';
export class UserDto {
constructor(
@@ -35,13 +31,9 @@ export class UsersService {
public getUsers(query?: string): Observable {
const url = this.apiUrl.buildUrl(`api/users?query=${query || ''}`);
- return HTTP.getVersioned(this.http, url).pipe(
+ return this.http.get(url).pipe(
map(response => {
- const body = response.payload.body;
-
- const items: any[] = body;
-
- return items.map(item => {
+ return response.map(item => {
return new UserDto(
item.id,
item.displayName);
@@ -53,13 +45,11 @@ export class UsersService {
public getUser(id: string): Observable {
const url = this.apiUrl.buildUrl(`api/users/${id}`);
- return HTTP.getVersioned(this.http, url).pipe(
+ return this.http.get(url).pipe(
map(response => {
- const body = response.payload.body;
-
return new UserDto(
- body.id,
- body.displayName);
+ response.id,
+ response.displayName);
}),
pretifyError('Failed to load user. Please reload.'));
}