Browse Source

Formatting.

pull/380/head
Sebastian Stehle 7 years ago
parent
commit
c2c3ff7374
  1. 34
      src/Squidex/app/features/administration/services/event-consumers.service.ts
  2. 50
      src/Squidex/app/features/administration/services/users.service.ts
  3. 50
      src/Squidex/app/shared/services/app-languages.service.ts
  4. 32
      src/Squidex/app/shared/services/apps.service.ts
  5. 150
      src/Squidex/app/shared/services/assets.service.ts
  6. 20
      src/Squidex/app/shared/services/auth.service.ts
  7. 60
      src/Squidex/app/shared/services/backups.service.ts
  8. 58
      src/Squidex/app/shared/services/clients.service.ts
  9. 70
      src/Squidex/app/shared/services/comments.service.ts
  10. 132
      src/Squidex/app/shared/services/contents.service.ts
  11. 42
      src/Squidex/app/shared/services/contributors.service.ts
  12. 2
      src/Squidex/app/shared/services/help.service.ts
  13. 24
      src/Squidex/app/shared/services/history.service.ts
  14. 16
      src/Squidex/app/shared/services/languages.service.ts
  15. 28
      src/Squidex/app/shared/services/news.service.ts
  16. 56
      src/Squidex/app/shared/services/plans.service.ts
  17. 52
      src/Squidex/app/shared/services/roles.service.ts
  18. 3
      src/Squidex/app/shared/services/rules.service.ts
  19. 8
      src/Squidex/app/shared/services/translations.service.ts
  20. 62
      src/Squidex/app/shared/services/usages.service.ts
  21. 38
      src/Squidex/app/shared/services/users.service.ts

34
src/Squidex/app/features/administration/services/event-consumers.service.ts

@ -62,12 +62,12 @@ export class EventConsumersService {
const url = this.apiUrl.buildUrl('/api/event-consumers');
return this.http.get<{ items: any[] } & Resource>(url).pipe(
map(({ items, _links }) => {
const eventConsumers = items.map(item => parseEventConsumer(item));
map(({ items, _links }) => {
const eventConsumers = items.map(item => parseEventConsumer(item));
return new EventConsumersDto(eventConsumers, _links);
}),
pretifyError('Failed to load event consumers. Please reload.'));
return new EventConsumersDto(eventConsumers, _links);
}),
pretifyError('Failed to load event consumers. Please reload.'));
}
public putStart(eventConsumer: Resource): Observable<EventConsumerDto> {
@ -76,10 +76,10 @@ export class EventConsumersService {
const url = this.apiUrl.buildUrl(link.href);
return this.http.request(link.method, url).pipe(
map(body => {
return parseEventConsumer(body);
}),
pretifyError('Failed to start event consumer. Please reload.'));
map(body => {
return parseEventConsumer(body);
}),
pretifyError('Failed to start event consumer. Please reload.'));
}
public putStop(eventConsumer: Resource): Observable<EventConsumerDto> {
@ -88,10 +88,10 @@ export class EventConsumersService {
const url = this.apiUrl.buildUrl(link.href);
return this.http.request(link.method, url).pipe(
map(body => {
return parseEventConsumer(body);
}),
pretifyError('Failed to stop event consumer. Please reload.'));
map(body => {
return parseEventConsumer(body);
}),
pretifyError('Failed to stop event consumer. Please reload.'));
}
public putReset(eventConsumer: Resource): Observable<EventConsumerDto> {
@ -100,10 +100,10 @@ export class EventConsumersService {
const url = this.apiUrl.buildUrl(link.href);
return this.http.request(link.method, url).pipe(
map(body => {
return parseEventConsumer(body);
}),
pretifyError('Failed to reset event consumer. Please reload.'));
map(body => {
return parseEventConsumer(body);
}),
pretifyError('Failed to reset event consumer. Please reload.'));
}
}

50
src/Squidex/app/features/administration/services/users.service.ts

@ -73,32 +73,32 @@ export class UsersService {
const url = this.apiUrl.buildUrl(`api/user-management?take=${take}&skip=${skip}&query=${query || ''}`);
return this.http.get<{ total: number, items: any[] } & Resource>(url).pipe(
map(({ total, items, _links }) => {
const users = items.map(item => parseUser(item));
map(({ total, items, _links }) => {
const users = items.map(item => parseUser(item));
return new UsersDto(total, users, _links);
}),
pretifyError('Failed to load users. Please reload.'));
return new UsersDto(total, users, _links);
}),
pretifyError('Failed to load users. Please reload.'));
}
public getUser(id: string): Observable<UserDto> {
const url = this.apiUrl.buildUrl(`api/user-management/${id}`);
return this.http.get(url).pipe(
map(body => {
return parseUser(body);
}),
pretifyError('Failed to load user. Please reload.'));
map(body => {
return parseUser(body);
}),
pretifyError('Failed to load user. Please reload.'));
}
public postUser(dto: CreateUserDto): Observable<UserDto> {
const url = this.apiUrl.buildUrl('api/user-management');
return this.http.post(url, dto).pipe(
map(body => {
return parseUser(body);
}),
pretifyError('Failed to create user. Please reload.'));
map(body => {
return parseUser(body);
}),
pretifyError('Failed to create user. Please reload.'));
}
public putUser(user: Resource, dto: UpdateUserDto): Observable<UserDto> {
@ -107,10 +107,10 @@ export class UsersService {
const url = this.apiUrl.buildUrl(link.href);
return this.http.request(link.method, url, { body: dto }).pipe(
map(body => {
return parseUser(body);
}),
pretifyError('Failed to update user. Please reload.'));
map(body => {
return parseUser(body);
}),
pretifyError('Failed to update user. Please reload.'));
}
public lockUser(user: Resource): Observable<UserDto> {
@ -119,10 +119,10 @@ export class UsersService {
const url = this.apiUrl.buildUrl(link.href);
return this.http.request(link.method, url).pipe(
map(body => {
return parseUser(body);
}),
pretifyError('Failed to load users. Please retry.'));
map(body => {
return parseUser(body);
}),
pretifyError('Failed to load users. Please retry.'));
}
public unlockUser(user: Resource): Observable<UserDto> {
@ -131,10 +131,10 @@ export class UsersService {
const url = this.apiUrl.buildUrl(link.href);
return this.http.request(link.method, url).pipe(
map(body => {
return parseUser(body);
}),
pretifyError('Failed to load users. Please retry.'));
map(body => {
return parseUser(body);
}),
pretifyError('Failed to load users. Please retry.'));
}
}

50
src/Squidex/app/shared/services/app-languages.service.ts

@ -74,23 +74,23 @@ export class AppLanguagesService {
const url = this.apiUrl.buildUrl(`api/apps/${appName}/languages`);
return HTTP.getVersioned(this.http, url).pipe(
mapVersioned(({ body }) => {
return parseLanguages(body);
}),
pretifyError('Failed to load languages. Please reload.'));
mapVersioned(({ body }) => {
return parseLanguages(body);
}),
pretifyError('Failed to load languages. Please reload.'));
}
public postLanguage(appName: string, dto: AddAppLanguageDto, version: Version): Observable<AppLanguagesDto> {
const url = this.apiUrl.buildUrl(`api/apps/${appName}/languages`);
return HTTP.postVersioned(this.http, url, dto, version).pipe(
mapVersioned(({ body }) => {
return parseLanguages(body);
}),
tap(() => {
this.analytics.trackEvent('Language', 'Added', appName);
}),
pretifyError('Failed to add language. Please reload.'));
mapVersioned(({ body }) => {
return parseLanguages(body);
}),
tap(() => {
this.analytics.trackEvent('Language', 'Added', appName);
}),
pretifyError('Failed to add language. Please reload.'));
}
public putLanguage(appName: string, resource: Resource, dto: UpdateAppLanguageDto, version: Version): Observable<AppLanguagesDto> {
@ -99,13 +99,13 @@ export class AppLanguagesService {
const url = this.apiUrl.buildUrl(link.href);
return HTTP.requestVersioned(this.http, link.method, url, version, dto).pipe(
mapVersioned(({ body }) => {
return parseLanguages(body);
}),
tap(() => {
this.analytics.trackEvent('Language', 'Updated', appName);
}),
pretifyError('Failed to change language. Please reload.'));
mapVersioned(({ body }) => {
return parseLanguages(body);
}),
tap(() => {
this.analytics.trackEvent('Language', 'Updated', appName);
}),
pretifyError('Failed to change language. Please reload.'));
}
public deleteLanguage(appName: string, resource: Resource, version: Version): Observable<AppLanguagesDto> {
@ -114,13 +114,13 @@ export class AppLanguagesService {
const url = this.apiUrl.buildUrl(link.href);
return HTTP.requestVersioned(this.http, link.method, url, version).pipe(
mapVersioned(({ body }) => {
return parseLanguages(body);
}),
tap(() => {
this.analytics.trackEvent('Language', 'Deleted', appName);
}),
pretifyError('Failed to add language. Please reload.'));
mapVersioned(({ body }) => {
return parseLanguages(body);
}),
tap(() => {
this.analytics.trackEvent('Language', 'Deleted', appName);
}),
pretifyError('Failed to add language. Please reload.'));
}
}

32
src/Squidex/app/shared/services/apps.service.ts

@ -86,25 +86,25 @@ export class AppsService {
const url = this.apiUrl.buildUrl('/api/apps');
return this.http.get<any[]>(url).pipe(
map(body => {
const apps = body.map(item => parseApp(item));
map(body => {
const apps = body.map(item => parseApp(item));
return apps;
}),
pretifyError('Failed to load apps. Please reload.'));
return apps;
}),
pretifyError('Failed to load apps. Please reload.'));
}
public postApp(dto: CreateAppDto): Observable<AppDto> {
const url = this.apiUrl.buildUrl('api/apps');
return this.http.post(url, dto).pipe(
map(body => {
return parseApp(body);
}),
tap(() => {
this.analytics.trackEvent('App', 'Created', dto.name);
}),
pretifyError('Failed to create app. Please reload.'));
map(body => {
return parseApp(body);
}),
tap(() => {
this.analytics.trackEvent('App', 'Created', dto.name);
}),
pretifyError('Failed to create app. Please reload.'));
}
public deleteApp(resource: Resource): Observable<any> {
@ -113,10 +113,10 @@ export class AppsService {
const url = this.apiUrl.buildUrl(link.href);
return this.http.request(link.method, url).pipe(
tap(() => {
this.analytics.trackEvent('App', 'Archived');
}),
pretifyError('Failed to archive app. Please reload.'));
tap(() => {
this.analytics.trackEvent('App', 'Archived');
}),
pretifyError('Failed to archive app. Please reload.'));
}
}

150
src/Squidex/app/shared/services/assets.service.ts

@ -138,12 +138,12 @@ export class AssetsService {
const url = this.apiUrl.buildUrl(`api/apps/${appName}/assets?${fullQuery}`);
return this.http.get<{ total: number, items: any[] } & Resource>(url).pipe(
map(({ total, items, _links }) => {
const assets = items.map(item => parseAsset(item));
map(({ total, items, _links }) => {
const assets = items.map(item => parseAsset(item));
return new AssetsDto(total, assets, _links);
}),
pretifyError('Failed to load assets. Please reload.'));
return new AssetsDto(total, assets, _links);
}),
pretifyError('Failed to load assets. Please reload.'));
}
public uploadFile(appName: string, file: File): Observable<number | AssetDto> {
@ -152,45 +152,45 @@ export class AssetsService {
const req = new HttpRequest('POST', url, getFormData(file), { reportProgress: true });
return this.http.request(req).pipe(
filter(event =>
event.type === HttpEventType.UploadProgress ||
event.type === HttpEventType.Response),
map(event => {
if (event.type === HttpEventType.UploadProgress) {
const percentDone = event.total ? Math.round(100 * event.loaded / event.total) : 0;
return percentDone;
} else if (Types.is(event, HttpResponse)) {
return parseAsset(event.body);
} else {
throw 'Invalid';
}
}),
catchError((error: any) => {
if (Types.is(error, HttpErrorResponse) && error.status === 413) {
return throwError(new ErrorDto(413, 'Asset is too big.'));
} else {
return throwError(error);
}
}),
tap(value => {
if (!Types.isNumber(value)) {
this.analytics.trackEvent('Asset', 'Uploaded', appName);
}
}),
pretifyError('Failed to upload asset. Please reload.'));
filter(event =>
event.type === HttpEventType.UploadProgress ||
event.type === HttpEventType.Response),
map(event => {
if (event.type === HttpEventType.UploadProgress) {
const percentDone = event.total ? Math.round(100 * event.loaded / event.total) : 0;
return percentDone;
} else if (Types.is(event, HttpResponse)) {
return parseAsset(event.body);
} else {
throw 'Invalid';
}
}),
catchError((error: any) => {
if (Types.is(error, HttpErrorResponse) && error.status === 413) {
return throwError(new ErrorDto(413, 'Asset is too big.'));
} else {
return throwError(error);
}
}),
tap(value => {
if (!Types.isNumber(value)) {
this.analytics.trackEvent('Asset', 'Uploaded', appName);
}
}),
pretifyError('Failed to upload asset. Please reload.'));
}
public getAsset(appName: string, id: string): Observable<AssetDto> {
const url = this.apiUrl.buildUrl(`api/apps/${appName}/assets/${id}`);
return HTTP.getVersioned(this.http, url).pipe(
map(({ payload }) => {
const body = payload.body;
map(({ payload }) => {
const body = payload.body;
return parseAsset(body);
}),
pretifyError('Failed to load assets. Please reload.'));
return parseAsset(body);
}),
pretifyError('Failed to load assets. Please reload.'));
}
public replaceFile(appName: string, asset: Resource, file: File, version: Version): Observable<number | AssetDto> {
@ -201,33 +201,33 @@ export class AssetsService {
const req = new HttpRequest(link.method, url, getFormData(file), { headers: new HttpHeaders().set('If-Match', version.value), reportProgress: true });
return this.http.request(req).pipe(
filter(event =>
event.type === HttpEventType.UploadProgress ||
event.type === HttpEventType.Response),
map(event => {
if (event.type === HttpEventType.UploadProgress) {
const percentDone = event.total ? Math.round(100 * event.loaded / event.total) : 0;
return percentDone;
} else if (Types.is(event, HttpResponse)) {
return parseAsset(event.body);
} else {
throw 'Invalid';
}
}),
catchError(error => {
if (Types.is(error, HttpErrorResponse) && error.status === 413) {
return throwError(new ErrorDto(413, 'Asset is too big.'));
} else {
return throwError(error);
}
}),
tap(value => {
if (!Types.isNumber(value)) {
this.analytics.trackEvent('Analytics', 'Replaced', appName);
}
}),
pretifyError('Failed to replace asset. Please reload.'));
filter(event =>
event.type === HttpEventType.UploadProgress ||
event.type === HttpEventType.Response),
map(event => {
if (event.type === HttpEventType.UploadProgress) {
const percentDone = event.total ? Math.round(100 * event.loaded / event.total) : 0;
return percentDone;
} else if (Types.is(event, HttpResponse)) {
return parseAsset(event.body);
} else {
throw 'Invalid';
}
}),
catchError(error => {
if (Types.is(error, HttpErrorResponse) && error.status === 413) {
return throwError(new ErrorDto(413, 'Asset is too big.'));
} else {
return throwError(error);
}
}),
tap(value => {
if (!Types.isNumber(value)) {
this.analytics.trackEvent('Analytics', 'Replaced', appName);
}
}),
pretifyError('Failed to replace asset. Please reload.'));
}
public putAsset(appName: string, asset: Resource, dto: AnnotateAssetDto, version: Version): Observable<AssetDto> {
@ -236,13 +236,13 @@ export class AssetsService {
const url = this.apiUrl.buildUrl(link.href);
return HTTP.requestVersioned(this.http, link.method, url, version, dto).pipe(
map(({ payload }) => {
return parseAsset(payload.body);
}),
tap(() => {
this.analytics.trackEvent('Analytics', 'Updated', appName);
}),
pretifyError('Failed to update asset. Please reload.'));
map(({ payload }) => {
return parseAsset(payload.body);
}),
tap(() => {
this.analytics.trackEvent('Analytics', 'Updated', appName);
}),
pretifyError('Failed to update asset. Please reload.'));
}
public deleteAsset(appName: string, asset: Resource, version: Version): Observable<Versioned<any>> {
@ -251,10 +251,10 @@ export class AssetsService {
const url = this.apiUrl.buildUrl(link.href);
return HTTP.requestVersioned(this.http, link.method, url, version).pipe(
tap(() => {
this.analytics.trackEvent('Analytics', 'Deleted', appName);
}),
pretifyError('Failed to delete asset. Please reload.'));
tap(() => {
this.analytics.trackEvent('Analytics', 'Deleted', appName);
}),
pretifyError('Failed to delete asset. Please reload.'));
}
}

20
src/Squidex/app/shared/services/auth.service.ts

@ -75,15 +75,15 @@ export class AuthService {
Log.logger = console;
this.userManager = new UserManager({
client_id: 'squidex-frontend',
scope: 'squidex-api openid profile email squidex-profile role permissions',
response_type: 'id_token token',
redirect_uri: apiUrl.buildUrl('login;'),
post_logout_redirect_uri: apiUrl.buildUrl('logout'),
silent_redirect_uri: apiUrl.buildUrl('client-callback-silent'),
popup_redirect_uri: apiUrl.buildUrl('client-callback-popup'),
authority: apiUrl.buildUrl('identity-server/'),
userStore: new WebStorageStateStore({ store: window.localStorage || window.sessionStorage }),
client_id: 'squidex-frontend',
scope: 'squidex-api openid profile email squidex-profile role permissions',
response_type: 'id_token token',
redirect_uri: apiUrl.buildUrl('login;'),
post_logout_redirect_uri: apiUrl.buildUrl('logout'),
silent_redirect_uri: apiUrl.buildUrl('client-callback-silent'),
popup_redirect_uri: apiUrl.buildUrl('client-callback-popup'),
authority: apiUrl.buildUrl('identity-server/'),
userStore: new WebStorageStateStore({ store: window.localStorage || window.sessionStorage }),
automaticSilentRenew: true
});
@ -103,7 +103,7 @@ export class AuthService {
}
public logoutRedirect() {
this.userManager.signoutRedirect();
this.userManager.signoutRedirect();
}
public loginRedirect() {

60
src/Squidex/app/shared/services/backups.service.ts

@ -85,51 +85,51 @@ export class BackupsService {
const url = this.apiUrl.buildUrl(`api/apps/${appName}/backups`);
return this.http.get<{ items: any[], _links: {} } & Resource>(url).pipe(
map(({ items, _links }) => {
const backups = items.map(item => parseBackup(item));
map(({ items, _links }) => {
const backups = items.map(item => parseBackup(item));
return new BackupsDto(backups, _links);
}),
pretifyError('Failed to load backups.'));
return new BackupsDto(backups, _links);
}),
pretifyError('Failed to load backups.'));
}
public getRestore(): Observable<RestoreDto | null> {
const url = this.apiUrl.buildUrl(`api/apps/restore`);
return this.http.get(url).pipe(
map(body => {
const restore = parseRestore(body);
return restore;
}),
catchError(error => {
if (Types.is(error, HttpErrorResponse) && error.status === 404) {
return of(null);
} else {
return throwError(error);
}
}),
pretifyError('Failed to load backups.'));
map(body => {
const restore = parseRestore(body);
return restore;
}),
catchError(error => {
if (Types.is(error, HttpErrorResponse) && error.status === 404) {
return of(null);
} else {
return throwError(error);
}
}),
pretifyError('Failed to load backups.'));
}
public postBackup(appName: string): Observable<any> {
const url = this.apiUrl.buildUrl(`api/apps/${appName}/backups`);
return this.http.post(url, {}).pipe(
tap(() => {
this.analytics.trackEvent('Backup', 'Started', appName);
}),
pretifyError('Failed to start backup.'));
tap(() => {
this.analytics.trackEvent('Backup', 'Started', appName);
}),
pretifyError('Failed to start backup.'));
}
public postRestore(dto: StartRestoreDto): Observable<any> {
const url = this.apiUrl.buildUrl(`api/apps/restore`);
return this.http.post(url, dto).pipe(
tap(() => {
this.analytics.trackEvent('Restore', 'Started');
}),
pretifyError('Failed to start restore.'));
tap(() => {
this.analytics.trackEvent('Restore', 'Started');
}),
pretifyError('Failed to start restore.'));
}
public deleteBackup(appName: string, resource: Resource): Observable<any> {
@ -138,10 +138,10 @@ export class BackupsService {
const url = this.apiUrl.buildUrl(link.href);
return this.http.request(link.method, url).pipe(
tap(() => {
this.analytics.trackEvent('Backup', 'Deleted', appName);
}),
pretifyError('Failed to delete backup.'));
tap(() => {
this.analytics.trackEvent('Backup', 'Deleted', appName);
}),
pretifyError('Failed to delete backup.'));
}
}

58
src/Squidex/app/shared/services/clients.service.ts

@ -80,23 +80,23 @@ export class ClientsService {
const url = this.apiUrl.buildUrl(`api/apps/${appName}/clients`);
return HTTP.getVersioned(this.http, url).pipe(
mapVersioned(({ body }) => {
return parseClients(body);
}),
pretifyError('Failed to load clients. Please reload.'));
mapVersioned(({ body }) => {
return parseClients(body);
}),
pretifyError('Failed to load clients. Please reload.'));
}
public postClient(appName: string, dto: CreateClientDto, version: Version): Observable<ClientsDto> {
const url = this.apiUrl.buildUrl(`api/apps/${appName}/clients`);
return HTTP.postVersioned(this.http, url, dto, version).pipe(
mapVersioned(({ body }) => {
return parseClients(body);
}),
tap(() => {
this.analytics.trackEvent('Client', 'Created', appName);
}),
pretifyError('Failed to add client. Please reload.'));
mapVersioned(({ body }) => {
return parseClients(body);
}),
tap(() => {
this.analytics.trackEvent('Client', 'Created', appName);
}),
pretifyError('Failed to add client. Please reload.'));
}
public putClient(appName: string, resource: Resource, dto: UpdateClientDto, version: Version): Observable<ClientsDto> {
@ -105,13 +105,13 @@ export class ClientsService {
const url = this.apiUrl.buildUrl(link.href);
return HTTP.requestVersioned(this.http, link.method, url, version, dto).pipe(
mapVersioned(({ body }) => {
return parseClients(body);
}),
tap(() => {
this.analytics.trackEvent('Client', 'Updated', appName);
}),
pretifyError('Failed to revoke client. Please reload.'));
mapVersioned(({ body }) => {
return parseClients(body);
}),
tap(() => {
this.analytics.trackEvent('Client', 'Updated', appName);
}),
pretifyError('Failed to revoke client. Please reload.'));
}
public deleteClient(appName: string, resource: Resource, version: Version): Observable<ClientsDto> {
@ -120,13 +120,13 @@ export class ClientsService {
const url = this.apiUrl.buildUrl(link.href);
return HTTP.requestVersioned(this.http, link.method, url, version).pipe(
mapVersioned(({ body }) => {
return parseClients(body);
}),
tap(() => {
this.analytics.trackEvent('Client', 'Deleted', appName);
}),
pretifyError('Failed to revoke client. Please reload.'));
mapVersioned(({ body }) => {
return parseClients(body);
}),
tap(() => {
this.analytics.trackEvent('Client', 'Deleted', appName);
}),
pretifyError('Failed to revoke client. Please reload.'));
}
public createToken(appName: string, client: ClientDto): Observable<AccessTokenDto> {
@ -141,10 +141,10 @@ export class ClientsService {
const url = this.apiUrl.buildUrl('identity-server/connect/token');
return this.http.post(url, body, options).pipe(
map((response: any) => {
return new AccessTokenDto(response.access_token, response.token_type);
}),
pretifyError('Failed to create token. Please retry.'));
map((response: any) => {
return new AccessTokenDto(response.access_token, response.token_type);
}),
pretifyError('Failed to create token. Please retry.'));
}
}

70
src/Squidex/app/shared/services/comments.service.ts

@ -56,58 +56,58 @@ export class CommentsService {
const url = this.apiUrl.buildUrl(`api/apps/${appName}/comments/${commentsId}?version=${version.value}`);
return this.http.get<any>(url).pipe(
map(body => {
const comments = new CommentsDto(
body.createdComments.map((item: any) => {
return new CommentDto(
item.id,
DateTime.parseISO_UTC(item.time),
item.text,
item.user);
}),
body.updatedComments.map((item: any) => {
return new CommentDto(
item.id,
DateTime.parseISO_UTC(item.time),
item.text,
item.user);
}),
body.deletedComments,
new Version(body.version)
);
return comments;
}),
pretifyError('Failed to load comments.'));
map(body => {
const comments = new CommentsDto(
body.createdComments.map((item: any) => {
return new CommentDto(
item.id,
DateTime.parseISO_UTC(item.time),
item.text,
item.user);
}),
body.updatedComments.map((item: any) => {
return new CommentDto(
item.id,
DateTime.parseISO_UTC(item.time),
item.text,
item.user);
}),
body.deletedComments,
new Version(body.version)
);
return comments;
}),
pretifyError('Failed to load comments.'));
}
public postComment(appName: string, commentsId: string, dto: UpsertCommentDto): Observable<CommentDto> {
const url = this.apiUrl.buildUrl(`api/apps/${appName}/comments/${commentsId}`);
return this.http.post<any>(url, dto).pipe(
map(body => {
const comment = new CommentDto(
body.id,
DateTime.parseISO_UTC(body.time),
body.text,
body.user);
return comment;
}),
pretifyError('Failed to create comment.'));
map(body => {
const comment = new CommentDto(
body.id,
DateTime.parseISO_UTC(body.time),
body.text,
body.user);
return comment;
}),
pretifyError('Failed to create comment.'));
}
public putComment(appName: string, commentsId: string, commentId: string, dto: UpsertCommentDto): Observable<any> {
const url = this.apiUrl.buildUrl(`api/apps/${appName}/comments/${commentsId}/${commentId}`);
return this.http.put(url, dto).pipe(
pretifyError('Failed to update comment.'));
pretifyError('Failed to update comment.'));
}
public deleteComment(appName: string, commentsId: string, commentId: string): Observable<any> {
const url = this.apiUrl.buildUrl(`api/apps/${appName}/comments/${commentsId}/${commentId}`);
return this.http.delete(url).pipe(
pretifyError('Failed to delete comment.'));
pretifyError('Failed to delete comment.'));
}
}

132
src/Squidex/app/shared/services/contents.service.ts

@ -137,45 +137,45 @@ export class ContentsService {
const url = this.apiUrl.buildUrl(`/api/content/${appName}/${schemaName}?${fullQuery}`);
return this.http.get<{ total: number, items: [], statuses: StatusInfo[] } & Resource>(url).pipe(
map(({ total, items, statuses, _links }) => {
const contents = items.map(x => parseContent(x));
map(({ total, items, statuses, _links }) => {
const contents = items.map(x => parseContent(x));
return new ContentsDto(statuses, total, contents, _links);
}),
pretifyError('Failed to load contents. Please reload.'));
return new ContentsDto(statuses, total, contents, _links);
}),
pretifyError('Failed to load contents. Please reload.'));
}
public getContent(appName: string, schemaName: string, id: string): Observable<ContentDto> {
const url = this.apiUrl.buildUrl(`/api/content/${appName}/${schemaName}/${id}`);
return HTTP.getVersioned(this.http, url).pipe(
map(({ payload }) => {
return parseContent(payload.body);
}),
pretifyError('Failed to load content. Please reload.'));
map(({ payload }) => {
return parseContent(payload.body);
}),
pretifyError('Failed to load content. Please reload.'));
}
public getVersionData(appName: string, schemaName: string, id: string, version: Version): Observable<Versioned<any>> {
const url = this.apiUrl.buildUrl(`/api/content/${appName}/${schemaName}/${id}/${version.value}`);
return HTTP.getVersioned(this.http, url).pipe(
mapVersioned(({ body }) => {
return body;
}),
pretifyError('Failed to load data. Please reload.'));
mapVersioned(({ body }) => {
return body;
}),
pretifyError('Failed to load data. Please reload.'));
}
public postContent(appName: string, schemaName: string, dto: any, publish: boolean): Observable<ContentDto> {
const url = this.apiUrl.buildUrl(`/api/content/${appName}/${schemaName}?publish=${publish}`);
return HTTP.postVersioned(this.http, url, dto).pipe(
map(({ payload }) => {
return parseContent(payload.body);
}),
tap(() => {
this.analytics.trackEvent('Content', 'Created', appName);
}),
pretifyError('Failed to create content. Please reload.'));
map(({ payload }) => {
return parseContent(payload.body);
}),
tap(() => {
this.analytics.trackEvent('Content', 'Created', appName);
}),
pretifyError('Failed to create content. Please reload.'));
}
public putContent(appName: string, resource: Resource, dto: any, version: Version): Observable<ContentDto> {
@ -184,13 +184,13 @@ export class ContentsService {
const url = this.apiUrl.buildUrl(link.href);
return HTTP.putVersioned(this.http, url, dto, version).pipe(
map(({ payload }) => {
return parseContent(payload.body);
}),
tap(() => {
this.analytics.trackEvent('Content', 'Updated', appName);
}),
pretifyError('Failed to update content. Please reload.'));
map(({ payload }) => {
return parseContent(payload.body);
}),
tap(() => {
this.analytics.trackEvent('Content', 'Updated', appName);
}),
pretifyError('Failed to update content. Please reload.'));
}
public patchContent(appName: string, resource: Resource, dto: any, version: Version): Observable<ContentDto> {
@ -199,13 +199,13 @@ export class ContentsService {
const url = this.apiUrl.buildUrl(link.href);
return HTTP.requestVersioned(this.http, link.method, url, version, dto).pipe(
map(({ payload }) => {
return parseContent(payload.body);
}),
tap(() => {
this.analytics.trackEvent('Content', 'Updated', appName);
}),
pretifyError('Failed to update content. Please reload.'));
map(({ payload }) => {
return parseContent(payload.body);
}),
tap(() => {
this.analytics.trackEvent('Content', 'Updated', appName);
}),
pretifyError('Failed to update content. Please reload.'));
}
public discardDraft(appName: string, resource: Resource, version: Version): Observable<ContentDto> {
@ -214,13 +214,13 @@ export class ContentsService {
const url = this.apiUrl.buildUrl(link.href);
return HTTP.requestVersioned(this.http, link.method, url, version, {}).pipe(
map(({ payload }) => {
return parseContent(payload.body);
}),
tap(() => {
this.analytics.trackEvent('Content', 'Discarded', appName);
}),
pretifyError('Failed to discard draft. Please reload.'));
map(({ payload }) => {
return parseContent(payload.body);
}),
tap(() => {
this.analytics.trackEvent('Content', 'Discarded', appName);
}),
pretifyError('Failed to discard draft. Please reload.'));
}
public proposeDraft(appName: string, resource: Resource, dto: any, version: Version): Observable<ContentDto> {
@ -229,13 +229,13 @@ export class ContentsService {
const url = this.apiUrl.buildUrl(link.href);
return HTTP.putVersioned(this.http, url, dto, version).pipe(
map(({ payload }) => {
return parseContent(payload.body);
}),
tap(() => {
this.analytics.trackEvent('Content', 'Updated', appName);
}),
pretifyError('Failed to propose draft. Please reload.'));
map(({ payload }) => {
return parseContent(payload.body);
}),
tap(() => {
this.analytics.trackEvent('Content', 'Updated', appName);
}),
pretifyError('Failed to propose draft. Please reload.'));
}
public publishDraft(appName: string, resource: Resource, dueTime: string | null, version: Version): Observable<ContentDto> {
@ -244,13 +244,13 @@ export class ContentsService {
const url = this.apiUrl.buildUrl(link.href);
return HTTP.requestVersioned(this.http, link.method, url, version, { status: 'Published', dueTime }).pipe(
map(({ payload }) => {
return parseContent(payload.body);
}),
tap(() => {
this.analytics.trackEvent('Content', 'Discarded', appName);
}),
pretifyError('Failed to publish draft. Please reload.'));
map(({ payload }) => {
return parseContent(payload.body);
}),
tap(() => {
this.analytics.trackEvent('Content', 'Discarded', appName);
}),
pretifyError('Failed to publish draft. Please reload.'));
}
public putStatus(appName: string, resource: Resource, status: string, dueTime: string | null, version: Version): Observable<ContentDto> {
@ -259,13 +259,13 @@ export class ContentsService {
const url = this.apiUrl.buildUrl(link.href);
return HTTP.requestVersioned(this.http, link.method, url, version, { status, dueTime }).pipe(
map(({ payload }) => {
return parseContent(payload.body);
}),
tap(() => {
this.analytics.trackEvent('Content', 'Archived', appName);
}),
pretifyError(`Failed to ${status} content. Please reload.`));
map(({ payload }) => {
return parseContent(payload.body);
}),
tap(() => {
this.analytics.trackEvent('Content', 'Archived', appName);
}),
pretifyError(`Failed to ${status} content. Please reload.`));
}
public deleteContent(appName: string, resource: Resource, version: Version): Observable<Versioned<any>> {
@ -274,10 +274,10 @@ export class ContentsService {
const url = this.apiUrl.buildUrl(link.href);
return HTTP.requestVersioned(this.http, link.method, url, version).pipe(
tap(() => {
this.analytics.trackEvent('Content', 'Deleted', appName);
}),
pretifyError('Failed to delete content. Please reload.'));
tap(() => {
this.analytics.trackEvent('Content', 'Deleted', appName);
}),
pretifyError('Failed to delete content. Please reload.'));
}
}

42
src/Squidex/app/shared/services/contributors.service.ts

@ -50,7 +50,7 @@ export class ContributorDto {
}
}
export interface AssignContributorDto {
export interface AssignContributorDto {
readonly contributorId: string;
readonly role: string;
readonly invite?: boolean;
@ -69,23 +69,23 @@ export class ContributorsService {
const url = this.apiUrl.buildUrl(`api/apps/${appName}/contributors`);
return HTTP.getVersioned(this.http, url).pipe(
mapVersioned(({ body }) => {
return parseContributors(body);
}),
pretifyError('Failed to load contributors. Please reload.'));
mapVersioned(({ body }) => {
return parseContributors(body);
}),
pretifyError('Failed to load contributors. Please reload.'));
}
public postContributor(appName: string, dto: AssignContributorDto, version: Version): Observable<ContributorsDto> {
const url = this.apiUrl.buildUrl(`api/apps/${appName}/contributors`);
return HTTP.postVersioned(this.http, url, dto, version).pipe(
mapVersioned(({ body }) => {
return parseContributors(body);
}),
tap(() => {
this.analytics.trackEvent('Contributor', 'Configured', appName);
}),
pretifyError('Failed to add contributors. Please reload.'));
mapVersioned(({ body }) => {
return parseContributors(body);
}),
tap(() => {
this.analytics.trackEvent('Contributor', 'Configured', appName);
}),
pretifyError('Failed to add contributors. Please reload.'));
}
public deleteContributor(appName: string, resource: Resource, version: Version): Observable<ContributorsDto> {
@ -94,15 +94,15 @@ export class ContributorsService {
const url = this.apiUrl.buildUrl(link.href);
return HTTP.requestVersioned(this.http, link.method, url, version).pipe(
mapVersioned(payload => {
const body = payload.body;
return parseContributors(body);
}),
tap(() => {
this.analytics.trackEvent('Contributor', 'Deleted', appName);
}),
pretifyError('Failed to delete contributors. Please reload.'));
mapVersioned(payload => {
const body = payload.body;
return parseContributors(body);
}),
tap(() => {
this.analytics.trackEvent('Contributor', 'Deleted', appName);
}),
pretifyError('Failed to delete contributors. Please reload.'));
}
}

2
src/Squidex/app/shared/services/help.service.ts

@ -21,6 +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(
catchError(() => of('')));
catchError(() => of('')));
}
}

24
src/Squidex/app/shared/services/history.service.ts

@ -82,17 +82,17 @@ export class HistoryService {
const url = this.apiUrl.buildUrl(`api/apps/${appName}/history?channel=${channel}`);
return this.http.get<any[]>(url).pipe(
map(body => {
const history = body.map(item =>
new HistoryEventDto(
item.eventId,
item.actor,
item.message,
item.version,
DateTime.parseISO_UTC(item.created)));
return history;
}),
pretifyError('Failed to load history. Please reload.'));
map(body => {
const history = body.map(item =>
new HistoryEventDto(
item.eventId,
item.actor,
item.message,
item.version,
DateTime.parseISO_UTC(item.created)));
return history;
}),
pretifyError('Failed to load history. Please reload.'));
}
}

16
src/Squidex/app/shared/services/languages.service.ts

@ -32,14 +32,14 @@ export class LanguagesService {
const url = this.apiUrl.buildUrl('api/languages');
return this.http.get<any[]>(url).pipe(
map(body => {
const languages = body.map(item =>
new LanguageDto(
item.iso2Code,
item.englishName));
map(body => {
const languages = body.map(item =>
new LanguageDto(
item.iso2Code,
item.englishName));
return languages;
}),
pretifyError('Failed to load languages. Please reload.'));
return languages;
}),
pretifyError('Failed to load languages. Please reload.'));
}
}

28
src/Squidex/app/shared/services/news.service.ts

@ -40,19 +40,19 @@ export class NewsService {
const url = this.apiUrl.buildUrl(`api/news/features?version=${version}`);
return this.http.get<any>(url).pipe(
map(body => {
const items: any[] = body.features;
const features = new FeaturesDto(
items.map(item =>
new FeatureDto(
item.name,
item.text)
),
body.version);
return features;
}),
pretifyError('Failed to load features. Please reload.'));
map(body => {
const items: any[] = body.features;
const features = new FeaturesDto(
items.map(item =>
new FeatureDto(
item.name,
item.text)
),
body.version);
return features;
}),
pretifyError('Failed to load features. Please reload.'));
}
}

56
src/Squidex/app/shared/services/plans.service.ts

@ -62,42 +62,42 @@ export class PlansService {
const url = this.apiUrl.buildUrl(`api/apps/${appName}/plans`);
return HTTP.getVersioned(this.http, url).pipe(
mapVersioned(({ body }) => {
const items: any[] = body.plans;
mapVersioned(({ body }) => {
const items: any[] = body.plans;
const { hasPortal, currentPlanId, planOwner } = body;
const { hasPortal, currentPlanId, planOwner } = body;
const plans = {
currentPlanId,
planOwner,
plans: items.map(item =>
new PlanDto(
item.id,
item.name,
item.costs,
item.yearlyId,
item.yearlyCosts,
item.maxApiCalls,
item.maxAssetSize,
item.maxContributors)),
hasPortal
};
const plans = {
currentPlanId,
planOwner,
plans: items.map(item =>
new PlanDto(
item.id,
item.name,
item.costs,
item.yearlyId,
item.yearlyCosts,
item.maxApiCalls,
item.maxAssetSize,
item.maxContributors)),
hasPortal
};
return plans;
}),
pretifyError('Failed to load plans. Please reload.'));
return plans;
}),
pretifyError('Failed to load plans. Please reload.'));
}
public putPlan(appName: string, dto: ChangePlanDto, version: Version): Observable<Versioned<PlanChangedDto>> {
const url = this.apiUrl.buildUrl(`api/apps/${appName}/plan`);
return HTTP.putVersioned(this.http, url, dto, version).pipe(
mapVersioned(payload => {
return <PlanChangedDto>payload.body;
}),
tap(() => {
this.analytics.trackEvent('Plan', 'Changed', appName);
}),
pretifyError('Failed to change plan. Please reload.'));
mapVersioned(payload => {
return <PlanChangedDto>payload.body;
}),
tap(() => {
this.analytics.trackEvent('Plan', 'Changed', appName);
}),
pretifyError('Failed to change plan. Please reload.'));
}
}

52
src/Squidex/app/shared/services/roles.service.ts

@ -72,23 +72,23 @@ export class RolesService {
const url = this.apiUrl.buildUrl(`api/apps/${appName}/roles`);
return HTTP.getVersioned(this.http, url).pipe(
mapVersioned(({ body }) => {
return parseRoles(body);
}),
pretifyError('Failed to load roles. Please reload.'));
mapVersioned(({ body }) => {
return parseRoles(body);
}),
pretifyError('Failed to load roles. Please reload.'));
}
public postRole(appName: string, dto: CreateRoleDto, version: Version): Observable<RolesDto> {
const url = this.apiUrl.buildUrl(`api/apps/${appName}/roles`);
return HTTP.postVersioned(this.http, url, dto, version).pipe(
mapVersioned(({ body }) => {
return parseRoles(body);
}),
tap(() => {
this.analytics.trackEvent('Role', 'Created', appName);
}),
pretifyError('Failed to add role. Please reload.'));
mapVersioned(({ body }) => {
return parseRoles(body);
}),
tap(() => {
this.analytics.trackEvent('Role', 'Created', appName);
}),
pretifyError('Failed to add role. Please reload.'));
}
public putRole(appName: string, resource: Resource, dto: UpdateRoleDto, version: Version): Observable<RolesDto> {
@ -97,13 +97,13 @@ export class RolesService {
const url = this.apiUrl.buildUrl(link.href);
return HTTP.requestVersioned(this.http, link.method, url, version, dto).pipe(
mapVersioned(({ body }) => {
return parseRoles(body);
}),
tap(() => {
this.analytics.trackEvent('Role', 'Updated', appName);
}),
pretifyError('Failed to revoke role. Please reload.'));
mapVersioned(({ body }) => {
return parseRoles(body);
}),
tap(() => {
this.analytics.trackEvent('Role', 'Updated', appName);
}),
pretifyError('Failed to revoke role. Please reload.'));
}
public deleteRole(appName: string, resource: Resource, version: Version): Observable<RolesDto> {
@ -112,20 +112,20 @@ export class RolesService {
const url = this.apiUrl.buildUrl(link.href);
return HTTP.requestVersioned(this.http, link.method, url, version).pipe(
mapVersioned(({ body }) => {
return parseRoles(body);
}),
tap(() => {
this.analytics.trackEvent('Role', 'Deleted', appName);
}),
pretifyError('Failed to revoke role. Please reload.'));
mapVersioned(({ body }) => {
return parseRoles(body);
}),
tap(() => {
this.analytics.trackEvent('Role', 'Deleted', appName);
}),
pretifyError('Failed to revoke role. Please reload.'));
}
public getPermissions(appName: string): Observable<string[]> {
const url = this.apiUrl.buildUrl(`api/apps/${appName}/roles/permissions`);
return this.http.get<string[]>(url).pipe(
pretifyError('Failed to load permissions. Please reload.'));
pretifyError('Failed to load permissions. Please reload.'));
}
}

3
src/Squidex/app/shared/services/rules.service.ts

@ -41,7 +41,8 @@ export const ALL_TRIGGERS = {
description: 'When a schema definition has been created, updated, published or deleted...',
display: 'Schema changed',
iconColor: '#3389ff',
iconCode: 'schemas'},
iconCode: 'schemas'
},
'Usage': {
description: 'When monthly API calls exceed a specified limit for one time a month...',
display: 'Usage exceeded',

8
src/Squidex/app/shared/services/translations.service.ts

@ -38,9 +38,9 @@ export class TranslationsService {
const url = this.apiUrl.buildUrl(`api/apps/${appName}/translations`);
return this.http.post<any>(url, request).pipe(
map(body => {
return new TranslationDto(body.result, body.text);
}),
pretifyError('Failed to translate text. Please reload.'));
map(body => {
return new TranslationDto(body.result, body.text);
}),
pretifyError('Failed to translate text. Please reload.'));
}
}

62
src/Squidex/app/shared/services/usages.service.ts

@ -72,55 +72,55 @@ export class UsagesService {
const url = this.apiUrl.buildUrl(`api/apps/${app}/usages/calls/month`);
return this.http.get<any>(url).pipe(
map(body => {
return new CurrentCallsDto(body.count, body.maxAllowed);
}),
pretifyError('Failed to load monthly api calls. Please reload.'));
map(body => {
return new CurrentCallsDto(body.count, body.maxAllowed);
}),
pretifyError('Failed to load monthly api calls. Please reload.'));
}
public getTodayStorage(app: string): Observable<CurrentStorageDto> {
const url = this.apiUrl.buildUrl(`api/apps/${app}/usages/storage/today`);
return this.http.get<any>(url).pipe(
map(body => {
return new CurrentStorageDto(body.size, body.maxAllowed);
}),
pretifyError('Failed to load todays storage size. Please reload.'));
map(body => {
return new CurrentStorageDto(body.size, body.maxAllowed);
}),
pretifyError('Failed to load todays storage size. Please reload.'));
}
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 this.http.get<any>(url).pipe(
map(body => {
const usages: { [category: string]: CallsUsageDto[] } = {};
for (let category of Object.keys(body)) {
usages[category] = body[category].map((item: any) =>
new CallsUsageDto(
DateTime.parseISO_UTC(item.date),
item.count,
item.averageMs));
}
return usages;
}),
pretifyError('Failed to load calls usage. Please reload.'));
map(body => {
const usages: { [category: string]: CallsUsageDto[] } = {};
for (let category of Object.keys(body)) {
usages[category] = body[category].map((item: any) =>
new CallsUsageDto(
DateTime.parseISO_UTC(item.date),
item.count,
item.averageMs));
}
return usages;
}),
pretifyError('Failed to load calls usage. Please reload.'));
}
public getStorageUsages(app: string, fromDate: DateTime, toDate: DateTime): Observable<StorageUsageDto[]> {
const url = this.apiUrl.buildUrl(`api/apps/${app}/usages/storage/${fromDate.toUTCStringFormat('YYYY-MM-DD')}/${toDate.toUTCStringFormat('YYYY-MM-DD')}`);
return this.http.get<any[]>(url).pipe(
map(body => {
const usages = body.map(item =>
new StorageUsageDto(
DateTime.parseISO_UTC(item.date),
item.count,
item.size));
map(body => {
const usages = body.map(item =>
new StorageUsageDto(
DateTime.parseISO_UTC(item.date),
item.count,
item.size));
return usages;
}),
pretifyError('Failed to load storage usage. Please reload.'));
return usages;
}),
pretifyError('Failed to load storage usage. Please reload.'));
}
}

38
src/Squidex/app/shared/services/users.service.ts

@ -44,38 +44,38 @@ export class UsersService {
const url = this.apiUrl.buildUrl(`api/users?query=${query || ''}`);
return this.http.get<any[]>(url).pipe(
map(body => {
const users = body.map(item =>
new UserDto(
item.id,
item.displayName));
map(body => {
const users = body.map(item =>
new UserDto(
item.id,
item.displayName));
return users;
}),
pretifyError('Failed to load users. Please reload.'));
return users;
}),
pretifyError('Failed to load users. Please reload.'));
}
public getUser(id: string): Observable<UserDto> {
const url = this.apiUrl.buildUrl(`api/users/${id}`);
return this.http.get<any>(url).pipe(
map(body => {
const user = new UserDto(
body.id,
body.displayName);
map(body => {
const user = new UserDto(
body.id,
body.displayName);
return user;
}),
pretifyError('Failed to load user. Please reload.'));
return user;
}),
pretifyError('Failed to load user. Please reload.'));
}
public getResources(): Observable<ResourcesDto> {
const url = this.apiUrl.buildUrl(`api`);
return this.http.get<{ _links: {} }>(url).pipe(
map(({ _links }) => {
return new ResourcesDto(_links);
}),
pretifyError('Failed to load user. Please reload.'));
map(({ _links }) => {
return new ResourcesDto(_links);
}),
pretifyError('Failed to load user. Please reload.'));
}
}
Loading…
Cancel
Save