Browse Source

Closes: #68

Closes: #69
Closes: #67
pull/65/merge
Sebastian Stehle 9 years ago
parent
commit
edfa0d4471
  1. 2
      src/Squidex.Domain.Apps.Read.MongoDb/Contents/Visitors/EdmModelExtensions.cs
  2. 18
      src/Squidex/app/features/api/pages/graphql/graphql-page.component.ts
  3. 2
      src/Squidex/app/features/content/pages/content/content-field.component.html
  4. 8
      src/Squidex/app/features/content/pages/content/content-field.component.ts
  5. 4
      src/Squidex/app/features/content/pages/contents/contents-page.component.html
  6. 8
      src/Squidex/app/features/content/pages/contents/contents-page.component.ts
  7. 5
      src/Squidex/app/features/content/shared/content-item.component.ts
  8. 2
      src/Squidex/app/features/content/shared/references-editor.component.html
  9. 8
      src/Squidex/app/features/content/shared/references-editor.component.ts
  10. 11
      src/Squidex/app/features/dashboard/pages/dashboard-page.component.ts
  11. 10
      src/Squidex/app/features/schemas/pages/schemas/schema-form.component.html
  12. 1
      src/Squidex/app/shared/declarations-base.ts
  13. 2
      src/Squidex/app/shared/module.ts
  14. 27
      src/Squidex/app/shared/services/graphql.service.ts

2
src/Squidex.Domain.Apps.Read.MongoDb/Contents/Visitors/EdmModelExtensions.cs

@ -17,6 +17,8 @@ namespace Squidex.Domain.Apps.Read.MongoDb.Contents.Visitors
{
public static ODataUriParser ParseQuery(this IEdmModel model, string query)
{
query = query ?? string.Empty;
var path = model.EntityContainer.EntitySets().First().Path.Path.Split('.').Last();
if (query.StartsWith("?"))

18
src/Squidex/app/features/api/pages/graphql/graphql-page.component.ts

@ -6,7 +6,6 @@
*/
import { Component, ElementRef, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
@ -16,9 +15,10 @@ const GraphiQL = require('graphiql');
/* tslint:disable:use-view-encapsulation */
import {
ApiUrlConfig,
AppComponentBase,
AppsStoreService,
GraphQlService,
LocalStoreService,
NotificationService
} from 'shared';
@ -33,8 +33,8 @@ export class GraphQLPageComponent extends AppComponentBase implements OnInit {
public graphiQLContainer: ElementRef;
constructor(apps: AppsStoreService, notifications: NotificationService,
private readonly apiUrl: ApiUrlConfig,
private readonly http: HttpClient
private readonly graphQlService: GraphQlService,
private readonly localStoreService: LocalStoreService
) {
super(notifications, apps);
}
@ -42,7 +42,13 @@ export class GraphQLPageComponent extends AppComponentBase implements OnInit {
public ngOnInit() {
ReactDOM.render(
React.createElement(GraphiQL, {
fetcher: (params: any) => this.request(params)
fetcher: (params: any) => {
return this.request(params);
},
onEditQuery: (query: string) => {
this.localStoreService.set('graphiQlQuery', query);
},
query: this.localStoreService.get('graphiQlQuery')
}),
this.graphiQLContainer.nativeElement
);
@ -50,7 +56,7 @@ export class GraphQLPageComponent extends AppComponentBase implements OnInit {
private request(params: any) {
return this.appNameOnce()
.switchMap(app => this.http.post(this.apiUrl.buildUrl(`api/content/${app}/graphql`), params))
.switchMap(app => this.graphQlService.query(app, params))
.toPromise();
}
}

2
src/Squidex/app/features/content/pages/content/content-field.component.html

@ -93,7 +93,7 @@
<sqx-assets-editor [formControlName]="partition"></sqx-assets-editor>
</div>
<div *ngSwitchCase="'References'">
<sqx-references-editor [formControlName]="partition" [languageCode]="partition" [schemaId]="field.properties.schemaId"></sqx-references-editor>
<sqx-references-editor [formControlName]="partition" [languageCode]="selectFieldLanguage(partition)" [schemaId]="field.properties.schemaId"></sqx-references-editor>
</div>
</div>
</div>

8
src/Squidex/app/features/content/pages/content/content-field.component.ts

@ -16,6 +16,8 @@ import { AppLanguageDto, FieldDto } from 'shared';
templateUrl: './content-field.component.html'
})
export class ContentFieldComponent implements OnInit {
private masterLanguageCode: string;
@Input()
public field: FieldDto;
@ -36,6 +38,8 @@ export class ContentFieldComponent implements OnInit {
}
public ngOnInit() {
this.masterLanguageCode = this.languages.find(l => l.isMaster).iso2Code;
if (this.field.isDisabled) {
this.fieldForm.disable();
}
@ -48,5 +52,9 @@ export class ContentFieldComponent implements OnInit {
this.fieldPartition = 'iv';
}
}
public selectFieldLanguage(partition: string) {
return partition === 'iv' ? this.masterLanguageCode : partition;
}
}

4
src/Squidex/app/features/content/pages/contents/contents-page.component.html

@ -69,7 +69,7 @@
<tbody *ngIf="!isReadOnly">
<ng-template ngFor let-content [ngForOf]="contentItems">
<tr [sqxContent]="content" [routerLink]="[content.id]" routerLinkActive="active"
[language]="languageSelected"
[languageCode]="languageSelected.iso2Code"
[schemaFields]="contentFields"
[schema]="schema"
(unpublishing)="unpublishContent(content)"
@ -82,7 +82,7 @@
<tbody *ngIf="isReadOnly">
<ng-template ngFor let-content [ngForOf]="contentItems">
<tr [sqxContent]="content" dnd-draggable [dragData]="dropData(content)"
[language]="languageSelected"
[languageCode]="languageSelected.iso2Code"
[schemaFields]="contentFields"
[schema]="schema"
isReadOnly="true"></tr>

8
src/Squidex/app/features/content/pages/contents/contents-page.component.ts

@ -163,11 +163,15 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy
private loadFields() {
this.contentFields = this.schema.fields.filter(x => x.properties.isListField);
this.columnWidth = 100 / this.contentFields.length;
if (this.contentFields.length === 0 && this.schema.fields.length > 0) {
this.contentFields = [this.schema.fields[0]];
}
if (this.contentFields.length > 0) {
this.columnWidth = 100 / this.contentFields.length;
} else {
this.columnWidth = 100;
}
}
public load(showInfo = false) {

5
src/Squidex/app/features/content/shared/content-item.component.ts

@ -9,7 +9,6 @@ import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angu
import {
AppComponentBase,
AppLanguageDto,
AppsStoreService,
ContentDto,
fadeAnimation,
@ -42,7 +41,7 @@ export class ContentItemComponent extends AppComponentBase implements OnInit, On
public deleting = new EventEmitter<ContentDto>();
@Input()
public language: AppLanguageDto;
public languageCode: string;
@Input()
public schemaFields: FieldDto[];
@ -88,7 +87,7 @@ export class ContentItemComponent extends AppComponentBase implements OnInit, On
if (contentField) {
if (field.partitioning === 'language') {
return field.formatValue(contentField[this.language.iso2Code]);
return field.formatValue(contentField[this.languageCode]);
} else {
return field.formatValue(contentField['iv']);
}

2
src/Squidex/app/features/content/shared/references-editor.component.html

@ -20,7 +20,7 @@
<tbody dnd-sortable-container [sortableData]="contentItems.mutableValues">
<ng-template ngFor let-content let-i="index" [ngForOf]="contentItems">
<tr [sqxContent]="content" dnd-sortable [sortableIndex]="i" (sqxSorted)="onContentsSorted($event)"
[language]="languageSelected"
[languageCode]="languageCode"
[schemaFields]="contentFields"
[schema]="schema"
(deleting)="onContentRemoving(content)"

8
src/Squidex/app/features/content/shared/references-editor.component.ts

@ -145,10 +145,14 @@ export class ReferencesEditorComponent extends AppComponentBase implements Contr
private loadFields() {
this.contentFields = this.schema.fields.filter(x => x.properties.isListField);
this.columnWidth = 100 / this.contentFields.length;
if (this.contentFields.length === 0 && this.schema.fields.length > 0) {
this.contentFields = [this.schema.fields[0]];
}
if (this.contentFields.length > 0) {
this.columnWidth = 100 / this.contentFields.length;
} else {
this.columnWidth = 100;
}
}
}

11
src/Squidex/app/features/dashboard/pages/dashboard-page.component.ts

@ -5,8 +5,7 @@
* Copyright (c) Sebastian Stehle. All rights reserved
*/
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Subscription} from 'rxjs';
import { Component, OnInit } from '@angular/core';
import {
AppComponentBase,
@ -29,9 +28,7 @@ declare var _urq: any;
fadeAnimation
]
})
export class DashboardPageComponent extends AppComponentBase implements OnInit, OnDestroy {
private authenticationSubscription: Subscription;
export class DashboardPageComponent extends AppComponentBase implements OnInit {
public profileDisplayName = '';
public chartStorageCount: any;
@ -71,10 +68,6 @@ export class DashboardPageComponent extends AppComponentBase implements OnInit,
super(notifications, apps);
}
public ngOnDestroy() {
this.authenticationSubscription.unsubscribe();
}
public ngOnInit() {
this.appName()
.switchMap(app => this.usagesService.getTodayStorage(app))

10
src/Squidex/app/features/schemas/pages/schemas/schema-form.component.html

@ -20,6 +20,11 @@
</small>
</div>
<div class="form-group clearfix">
<button type="reset" class="float-left btn btn-secondary" (click)="cancel()">Cancel</button>
<button type="submit" class="float-right btn btn-success">Create</button>
</div>
<div>
<button class="btn btn-sm btn-link" (click)="toggleImport()" [class.hidden]="showImport">
Import schema
@ -30,9 +35,4 @@
<sqx-json-editor *ngIf="showImport" formControlName="import"></sqx-json-editor>
</div>
<div class="form-group clearfix">
<button type="reset" class="float-left btn btn-secondary" (click)="cancel()">Cancel</button>
<button type="submit" class="float-right btn btn-success">Create</button>
</div>
</form>

1
src/Squidex/app/shared/declarations-base.ts

@ -25,6 +25,7 @@ export * from './services/assets.service';
export * from './services/auth.service';
export * from './services/contents.service';
export * from './services/event-consumers.service';
export * from './services/graphql.service';
export * from './services/help.service';
export * from './services/history.service';
export * from './services/languages.service';

2
src/Squidex/app/shared/module.ts

@ -26,6 +26,7 @@ import {
ContentsService,
EventConsumersService,
HelpComponent,
GraphQlService,
HelpService,
HistoryComponent,
HistoryService,
@ -106,6 +107,7 @@ export class SqxSharedModule {
AuthService,
ContentsService,
EventConsumersService,
GraphQlService,
HelpService,
HistoryService,
LanguagesService,

27
src/Squidex/app/shared/services/graphql.service.ts

@ -0,0 +1,27 @@
/*
* Squidex Headless CMS
*
* @license
* Copyright (c) Sebastian Stehle. All rights reserved
*/
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { ApiUrlConfig } from 'framework';
@Injectable()
export class GraphQlService {
constructor(
private readonly http: HttpClient,
private readonly apiUrl: ApiUrlConfig
) {
}
public query(appName: string, params: any): Observable<any> {
const url = this.apiUrl.buildUrl(`api/content/${appName}/graphql`)
return this.http.post(url, params);
}
}
Loading…
Cancel
Save