Browse Source

Url generation fixed.

pull/95/head
Sebastian Stehle 9 years ago
parent
commit
7737254efe
  1. 8
      src/Squidex/app/features/settings/pages/clients/client.component.html
  2. 34
      src/Squidex/app/features/settings/pages/clients/client.component.ts
  3. 4
      src/Squidex/app/shared/services/app-clients.service.ts
  4. 2
      src/Squidex/app/shared/services/contents.service.spec.ts
  5. 24
      src/Squidex/app/shared/services/contents.service.ts

8
src/Squidex/app/features/settings/pages/clients/client.component.html

@ -13,14 +13,14 @@
</div>
<div class="client-header">
<form *ngIf="isRenaming" class="form-inline" [formGroup]="renameForm" (ngSubmit)="rename()">
<form *ngIf="isRenaming" class="form-inline" [formGroup]="renameForm" (ngSubmit)="renaming.emit(renameForm.controls.name.value)">
<div class="form-group mr-1">
<sqx-control-errors for="name"></sqx-control-errors>
<input type="text" class="form-control client-name enabled" formControlName="name" maxlength="20" sqxFocusOnInit (keydown)="onKeyDown($event.keyCode)" />
</div>
<button type="submit" class="btn btn-primary" [disabled]="!renameForm.valid">Save</button>
<button type="submit" class="btn btn-primary" [disabled]="!renameForm.valid || !hasNewName">Save</button>
<button class="btn btn-link btn-decent btn-cancel" (click)="cancelRename()">
<i class="icon-close"></i>
@ -47,7 +47,7 @@
<tr>
<td>Client Id:</td>
<td>
<input readonly class="form-control" [attr.value]="clientId" #inputName />
<input readonly class="form-control" value="{{appName}}:{{client.id}}" #inputName />
</td>
<td>
<button type="button" class="btn btn-primary btn-link" [sqxCopy]="inputName">
@ -58,7 +58,7 @@
<tr>
<td>Client Secret:</td>
<td>
<input readonly class="form-control" [attr.value]="clientSecret" #inputSecret />
<input readonly class="form-control" [attr.value]="client.secret" #inputSecret />
</td>
<td>
<button type="button" class="btn btn-primary btn-link" [sqxCopy]="inputSecret">

34
src/Squidex/app/features/settings/pages/clients/client.component.ts

@ -42,23 +42,15 @@ export class ClientComponent {
public changing = new EventEmitter<boolean>();
@Input()
public client: AppClientDto;
public appName: string;
@Input()
public appName: string;
public client: AppClientDto;
public tokenDialog = new ModalView();
public get clientName(): string {
return this.client.name || this.client.id;
}
public get clientId(): string {
return this.appName + ':' + this.client.id;
}
public get clientSecret(): string {
return this.client.secret;
public get hasNewName() {
return this.renameForm.controls['name'].value !== this.client.name;
}
public renameForm: FormGroup =
@ -75,16 +67,12 @@ export class ClientComponent {
) {
}
public resetForm() {
this.renameForm.controls['name'].setValue(this.clientName);
}
public cancelRename() {
this.isRenaming = false;
}
public startRename() {
this.resetForm();
this.renameForm.controls['name'].setValue(this.client.name);
this.isRenaming = true;
}
@ -95,18 +83,6 @@ export class ClientComponent {
}
}
public rename() {
try {
const newName = this.renameForm.controls['name'].value;
if (newName !== this.clientName) {
this.renaming.emit(newName);
}
} finally {
this.isRenaming = false;
}
}
public createToken(client: AppClientDto) {
this.appClientsService.createToken(this.appName, client)
.subscribe(dto => {

4
src/Squidex/app/shared/services/app-clients.service.ts

@ -68,7 +68,7 @@ export class AppClientsService {
return items.map(item => {
return new AppClientDto(
item.id,
item.name,
item.name || response.id,
item.secret,
item.isReader);
});
@ -83,7 +83,7 @@ export class AppClientsService {
.map(response => {
return new AppClientDto(
response.id,
response.name,
response.name || response.id,
response.secret,
response.isReader);
})

2
src/Squidex/app/shared/services/contents.service.spec.ts

@ -151,7 +151,7 @@ describe('ContentsService', () => {
content = result;
});
const req = httpMock.expectOne('http://service/p/api/content/my-app/my-schema/content1?hidden=true');
const req = httpMock.expectOne('http://service/p/api/content/my-app/my-schema/content1');
expect(req.request.method).toEqual('GET');
expect(req.request.headers.get('If-Match')).toBe(version.value);

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

@ -49,30 +49,32 @@ export class ContentsService {
}
public getContents(appName: string, schemaName: string, take: number, skip: number, query?: string, ids?: string[]): Observable<ContentsDto> {
let fullQuery = query ? query.trim() : '';
const queryParts: string[] = [];
if (fullQuery.length > 0) {
if (fullQuery.indexOf('$filter') < 0 &&
fullQuery.indexOf('$search') < 0 &&
fullQuery.indexOf('$orderby') < 0) {
fullQuery = `&$search="${fullQuery}"`;
if (query && query.length > 0) {
if (query.indexOf('$filter') < 0 &&
query.indexOf('$search') < 0 &&
query.indexOf('$orderby') < 0) {
queryParts.push(`$search="${query.trim()}"`);
} else {
fullQuery = `&${fullQuery}`;
queryParts.push(`${query.trim()}`);
}
}
if (take > 0) {
fullQuery += `&$top=${take}`;
queryParts.push(`$top=${take}`);
}
if (skip > 0) {
fullQuery += `&$skip=${skip}`;
queryParts.push(`$skip=${skip}`);
}
if (ids && ids.length > 0) {
fullQuery += `&ids=${ids.join(',')}`;
queryParts.push(`ids=${ids.join(',')}`);
}
const fullQuery = queryParts.join('&');
const url = this.apiUrl.buildUrl(`/api/content/${appName}/${schemaName}?${fullQuery}`);
return HTTP.getVersioned(this.http, url)
@ -95,7 +97,7 @@ export class ContentsService {
}
public getContent(appName: string, schemaName: string, id: string, version?: Version): Observable<ContentDto> {
const url = this.apiUrl.buildUrl(`/api/content/${appName}/${schemaName}/${id}?hidden=true`);
const url = this.apiUrl.buildUrl(`/api/content/${appName}/${schemaName}/${id}`);
return HTTP.getVersioned(this.http, url, version)
.map(response => {

Loading…
Cancel
Save