Show read-only editor in versions (not actually versioning yet)
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
26e8d6ecd6
commit
ab811bb54c
@ -1,22 +0,0 @@
|
|||||||
import { NgModule } from '@angular/core';
|
|
||||||
import { CommonModule } from '@angular/common';
|
|
||||||
import { FormsModule } from '@angular/forms';
|
|
||||||
|
|
||||||
import { IonicModule } from '@ionic/angular';
|
|
||||||
|
|
||||||
import { EditorPageRoutingModule } from './editor-routing.module';
|
|
||||||
|
|
||||||
import { EditorPage } from './editor.page';
|
|
||||||
import {ComponentsModule} from '../../components/components.module';
|
|
||||||
|
|
||||||
@NgModule({
|
|
||||||
imports: [
|
|
||||||
CommonModule,
|
|
||||||
FormsModule,
|
|
||||||
IonicModule,
|
|
||||||
EditorPageRoutingModule,
|
|
||||||
ComponentsModule
|
|
||||||
],
|
|
||||||
declarations: [EditorPage]
|
|
||||||
})
|
|
||||||
export class EditorPageModule {}
|
|
@ -1,10 +0,0 @@
|
|||||||
export interface RedirectAction {
|
|
||||||
type: 'redirect';
|
|
||||||
args: {
|
|
||||||
destination: string
|
|
||||||
blank?: boolean
|
|
||||||
appUrl?: boolean
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Action = RedirectAction;
|
|
@ -1,27 +0,0 @@
|
|||||||
import { Injectable } from '@angular/core';
|
|
||||||
import { Action } from './action.types';
|
|
||||||
import {SessionService} from './session.service';
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root'
|
|
||||||
})
|
|
||||||
export class ActionsService {
|
|
||||||
constructor(
|
|
||||||
protected readonly session: SessionService,
|
|
||||||
) { }
|
|
||||||
|
|
||||||
async perform(action: Action) {
|
|
||||||
if ( action.type === 'redirect' ) {
|
|
||||||
let destination = action.args.destination;
|
|
||||||
if ( action.args.appUrl ) {
|
|
||||||
destination = this.session.buildAppUrl(destination);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( action.args.blank ) {
|
|
||||||
window.open(destination, '_blank');
|
|
||||||
} else {
|
|
||||||
window.location.href = destination;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
import {Host, Injectable} from '@angular/core';
|
|
||||||
import {Observable} from 'rxjs';
|
|
||||||
import PageRecord from '../structures/PageRecord';
|
|
||||||
import {ApiService} from './api.service';
|
|
||||||
import HostRecord from '../structures/HostRecord';
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root'
|
|
||||||
})
|
|
||||||
export class PageService {
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
protected api: ApiService,
|
|
||||||
) { }
|
|
||||||
|
|
||||||
load(id: string): Observable<PageRecord> {
|
|
||||||
return new Observable<PageRecord>(sub => {
|
|
||||||
this.api.get(`/page/${id}`).subscribe(response => {
|
|
||||||
if ( response.status === 200 ) {
|
|
||||||
sub.next(new PageRecord(response.data));
|
|
||||||
sub.complete();
|
|
||||||
} else {
|
|
||||||
throw new Error(response.message);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
save(page: PageRecord): Observable<PageRecord> {
|
|
||||||
return new Observable<PageRecord>(sub => {
|
|
||||||
this.api.post(`/page/${page.UUID}/save`, page.toSave()).subscribe(res => {
|
|
||||||
sub.next(new PageRecord(res.data));
|
|
||||||
sub.complete();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
get_nodes(page: PageRecord): Observable<Array<HostRecord>> {
|
|
||||||
return new Observable<Array<HostRecord>>(sub => {
|
|
||||||
this.api.get(`/page/${page.UUID}/nodes`).subscribe(res => {
|
|
||||||
const returns = [];
|
|
||||||
res.data.forEach(rec => {
|
|
||||||
const host = new HostRecord(rec.Value.Value);
|
|
||||||
host.load(rec);
|
|
||||||
returns.push(host);
|
|
||||||
});
|
|
||||||
|
|
||||||
sub.next(returns);
|
|
||||||
sub.complete();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
save_nodes(page: PageRecord, nodes: Array<HostRecord>): Observable<Array<HostRecord>> {
|
|
||||||
return new Observable<Array<HostRecord>>(sub => {
|
|
||||||
nodes = nodes.map(x => {
|
|
||||||
x.PageId = page.UUID;
|
|
||||||
return x.toSave();
|
|
||||||
});
|
|
||||||
|
|
||||||
this.api.post(`/page/${page.UUID}/nodes/save`, nodes).subscribe(res => {
|
|
||||||
const returns = [];
|
|
||||||
res.data.forEach(rec => {
|
|
||||||
const host = new HostRecord(rec.Value.Value);
|
|
||||||
host.load(rec);
|
|
||||||
returns.push(host);
|
|
||||||
});
|
|
||||||
|
|
||||||
sub.next(returns);
|
|
||||||
sub.complete();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in new issue