progress
This commit is contained in:
parent
8ecb036b1d
commit
d70253d6a6
33 changed files with 201 additions and 81 deletions
|
@ -84,7 +84,6 @@ export class App {
|
||||||
}
|
}
|
||||||
|
|
||||||
async appStartController() {
|
async appStartController() {
|
||||||
console.log(App.staticFilesStoreDir());
|
|
||||||
if (await dirIsExists(App.staticFilesStoreDir())) {
|
if (await dirIsExists(App.staticFilesStoreDir())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ export class CrudController<V, D> extends CoreHttpController<V> {
|
||||||
|
|
||||||
constructor(routerModel: IRouteModel) {
|
constructor(routerModel: IRouteModel) {
|
||||||
super(routerModel);
|
super(routerModel);
|
||||||
this.url = "/" + routerModel.url;
|
this.mainURL = "/" + routerModel.url;
|
||||||
this.validationModel = routerModel.validationModel;
|
this.validationModel = routerModel.validationModel;
|
||||||
this.dataBaseModel = routerModel.databaseModel;
|
this.dataBaseModel = routerModel.databaseModel;
|
||||||
this.init();
|
this.init();
|
||||||
|
|
|
@ -3,16 +3,33 @@ import { Result } from "../helper/result";
|
||||||
import { Router, Request, Response } from "express";
|
import { Router, Request, Response } from "express";
|
||||||
import { IRouteModel, Routes } from "../interfaces/router";
|
import { IRouteModel, Routes } from "../interfaces/router";
|
||||||
|
|
||||||
export type CallBackFunction<T> = (a: T) => Promise<Result<any, any>>;
|
type Method =
|
||||||
|
| "all"
|
||||||
|
| "get"
|
||||||
|
| "post"
|
||||||
|
| "put"
|
||||||
|
| "delete"
|
||||||
|
| "patch"
|
||||||
|
| "options"
|
||||||
|
| "head";
|
||||||
|
|
||||||
|
export type CallbackStrategyWithValidationModel<T> = (
|
||||||
|
a: T
|
||||||
|
) => Promise<Result<any, any>>;
|
||||||
|
// TODO(IDOTSUDO):NEED IMPLEMENTS
|
||||||
|
// interface ISubSetFeatureRouter<T>{
|
||||||
|
// method:Method,
|
||||||
|
// fn:CallbackStrategyWithValidationModel<T>
|
||||||
|
// }
|
||||||
|
|
||||||
abstract class ICoreHttpController {
|
abstract class ICoreHttpController {
|
||||||
abstract url: string;
|
abstract mainURL: string;
|
||||||
public router = Router();
|
public router = Router();
|
||||||
abstract call(): Routes;
|
abstract call(): Routes;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CoreHttpController<V> implements ICoreHttpController {
|
export class CoreHttpController<V> implements ICoreHttpController {
|
||||||
url: string;
|
mainURL: string;
|
||||||
validationModel: any;
|
validationModel: any;
|
||||||
|
|
||||||
routes = {
|
routes = {
|
||||||
|
@ -25,35 +42,34 @@ export class CoreHttpController<V> implements ICoreHttpController {
|
||||||
public router = Router();
|
public router = Router();
|
||||||
|
|
||||||
constructor(routerModel: IRouteModel) {
|
constructor(routerModel: IRouteModel) {
|
||||||
this.url = "/" + routerModel.url;
|
this.mainURL = "/" + routerModel.url;
|
||||||
this.validationModel = routerModel.validationModel;
|
this.validationModel = routerModel.validationModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
call(): Routes {
|
call(): Routes {
|
||||||
if (this.routes["POST"] != null) {
|
if (this.routes["POST"] != null) {
|
||||||
|
|
||||||
this.router.post(
|
this.router.post(
|
||||||
this.url,
|
this.mainURL,
|
||||||
validationModelMiddleware(this.validationModel),
|
validationModelMiddleware(this.validationModel),
|
||||||
(req, res) =>
|
(req, res) =>
|
||||||
this.requestResponseController<V>(req, res, this.routes["POST"])
|
this.requestResponseController<V>(req, res, this.routes["POST"])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (this.routes["DELETE"] != null) {
|
if (this.routes["DELETE"] != null) {
|
||||||
this.router.delete(this.url, (req, res) =>
|
this.router.delete(this.mainURL, (req, res) =>
|
||||||
this.requestResponseController<V>(req, res, this.routes["DELETE"])
|
this.requestResponseController<V>(req, res, this.routes["DELETE"])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (this.routes["PUT"] != null) {
|
if (this.routes["PUT"] != null) {
|
||||||
this.router.put(
|
this.router.put(
|
||||||
this.url,
|
this.mainURL,
|
||||||
validationModelMiddleware(this.validationModel),
|
validationModelMiddleware(this.validationModel),
|
||||||
(req, res) =>
|
(req, res) =>
|
||||||
this.requestResponseController<V>(req, res, this.routes["PUT"])
|
this.requestResponseController<V>(req, res, this.routes["PUT"])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (this.routes["GET"] != null) {
|
if (this.routes["GET"] != null) {
|
||||||
this.router.get(this.url, (req, res) =>
|
this.router.get(this.mainURL, (req, res) =>
|
||||||
this.requestResponseController<V>(req, res, this.routes["GET"])
|
this.requestResponseController<V>(req, res, this.routes["GET"])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -62,18 +78,17 @@ export class CoreHttpController<V> implements ICoreHttpController {
|
||||||
router: this.router,
|
router: this.router,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public put(usecase: CallBackFunction<V>) {
|
public put(usecase: CallbackStrategyWithValidationModel<V>) {
|
||||||
this.routes["PUT"] = usecase;
|
this.routes["PUT"] = usecase;
|
||||||
}
|
}
|
||||||
public delete(usecase: CallBackFunction<V>) {
|
public delete(usecase: CallbackStrategyWithValidationModel<V>) {
|
||||||
this.routes["DELETE"] = usecase;
|
this.routes["DELETE"] = usecase;
|
||||||
}
|
}
|
||||||
public async requestResponseController<T>(
|
public async requestResponseController<T>(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response,
|
res: Response,
|
||||||
usecase: CallBackFunction<T>
|
usecase: CallbackStrategyWithValidationModel<T>
|
||||||
) {
|
) {
|
||||||
|
|
||||||
let payload = null;
|
let payload = null;
|
||||||
|
|
||||||
if (req["model"] != undefined) {
|
if (req["model"] != undefined) {
|
||||||
|
@ -98,11 +113,11 @@ export class CoreHttpController<V> implements ICoreHttpController {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
public post(usecase: CallBackFunction<V>) {
|
public post(usecase: CallbackStrategyWithValidationModel<V>) {
|
||||||
this.routes["POST"] = usecase;
|
this.routes["POST"] = usecase;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get(usecase: CallBackFunction<V>) {
|
public get(usecase: CallbackStrategyWithValidationModel<V>) {
|
||||||
this.routes["GET"] = usecase;
|
this.routes["GET"] = usecase;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
// import { RequestHandler } from "express";
|
import { RequestHandler } from "express";
|
||||||
|
|
||||||
// export const validationMiddleware = (
|
export const validationMiddleware = (
|
||||||
// type: any,
|
type: any,
|
||||||
// value = 'body',
|
value = "body",
|
||||||
// skipMissingProperties = false,
|
skipMissingProperties = false,
|
||||||
// whitelist = true,
|
whitelist = true,
|
||||||
// forbidNonWhitelisted = true,
|
forbidNonWhitelisted = true
|
||||||
// ): RequestHandler => {
|
): RequestHandler => {
|
||||||
|
// TODO:(IDONTSUDO) need TOKEN
|
||||||
|
// return nextTick
|
||||||
// }
|
return (req, res, next) => {
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
export enum EventsFileChanger {
|
export enum EventsFileChanger {
|
||||||
remove = "remove",
|
|
||||||
update = "update",
|
update = "update",
|
||||||
delete = "delete",
|
delete = "delete",
|
||||||
create = "create",
|
create = "create",
|
||||||
|
@ -18,6 +17,7 @@ export class MetaDataFileManagerModel {
|
||||||
this.event = event;
|
this.event = event;
|
||||||
this.unixTime = Date.now();
|
this.unixTime = Date.now();
|
||||||
}
|
}
|
||||||
|
|
||||||
public get timeString(): string {
|
public get timeString(): string {
|
||||||
const date = new Date(this.unixTime * 1000);
|
const date = new Date(this.unixTime * 1000);
|
||||||
const hours = date.getHours();
|
const hours = date.getHours();
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
export interface IPipelineMeta {
|
export interface IPipelineMeta {
|
||||||
pipelineIsRunning: boolean;
|
pipelineIsRunning: boolean;
|
||||||
projectUUID?: string | null;
|
projectUUID?: string | null;
|
||||||
lastProcessCompleteCount: number | null;
|
lastProcessCompleteCount: number | null;
|
||||||
error: any;
|
error: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,7 @@ import { EXEC_TYPE, ExecError, SpawnError } from "../model/exec_error_model";
|
||||||
abstract class IExecutorProgramService {
|
abstract class IExecutorProgramService {
|
||||||
abstract execPath: string;
|
abstract execPath: string;
|
||||||
}
|
}
|
||||||
class P{
|
|
||||||
|
|
||||||
}
|
|
||||||
export class ExecutorProgramService
|
export class ExecutorProgramService
|
||||||
extends TypedEvent<Result<ExecError | SpawnError, ExecutorResult>>
|
extends TypedEvent<Result<ExecError | SpawnError, ExecutorResult>>
|
||||||
implements IExecutorProgramService
|
implements IExecutorProgramService
|
||||||
|
|
|
@ -34,11 +34,12 @@ export class PipelineRealTimeService extends TypedEvent<IPipelineMeta> {
|
||||||
this.iterationErrorObserver(iteration);
|
this.iterationErrorObserver(iteration);
|
||||||
|
|
||||||
// TODO(IDONTSUDO): implements
|
// TODO(IDONTSUDO): implements
|
||||||
// this.iterationLogSaver()
|
this.iterationLogSaver(iteration);
|
||||||
}
|
}
|
||||||
|
|
||||||
iterationLogSaver() {
|
iterationLogSaver(iteration: Iteration): void {
|
||||||
throw new Error("Method not implemented.");
|
// throw new Error("Method not implemented.");
|
||||||
|
// citeration.result.data
|
||||||
}
|
}
|
||||||
|
|
||||||
iterationErrorObserver(iteration: Iteration): void {
|
iterationErrorObserver(iteration: Iteration): void {
|
||||||
|
@ -70,8 +71,7 @@ export class PipelineRealTimeService extends TypedEvent<IPipelineMeta> {
|
||||||
path: string,
|
path: string,
|
||||||
projectUUID: string
|
projectUUID: string
|
||||||
): void {
|
): void {
|
||||||
const testPath = path + "/context";
|
const stack = new StackService(pipelineModels, path);
|
||||||
const stack = new StackService(pipelineModels, testPath);
|
|
||||||
this.status["projectUUID"] = projectUUID;
|
this.status["projectUUID"] = projectUUID;
|
||||||
this.status["pipelineIsRunning"] = true;
|
this.status["pipelineIsRunning"] = true;
|
||||||
stack.on(this.pipelineSubscriber);
|
stack.on(this.pipelineSubscriber);
|
||||||
|
|
|
@ -51,6 +51,7 @@ export class StackService
|
||||||
"$PATH",
|
"$PATH",
|
||||||
this.path
|
this.path
|
||||||
);
|
);
|
||||||
|
console.log(processMetaData.process.command)
|
||||||
return processMetaData;
|
return processMetaData;
|
||||||
}
|
}
|
||||||
public async call() {
|
public async call() {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { IsMongoId, IsEnum, IsOptional } from "class-validator";
|
import { IsMongoId, IsOptional } from "class-validator";
|
||||||
import { Schema, model } from "mongoose";
|
import { Schema, model } from "mongoose";
|
||||||
import { IProcess, StackGenerateType } from "../../core/model/process_model";
|
import { IProcess, StackGenerateType } from "../../core/model/process_model";
|
||||||
import { TriggerModel, triggerSchema } from "../triggers/trigger_model";
|
import { TriggerModel, triggerSchema } from "../triggers/trigger_model";
|
||||||
|
|
|
@ -12,5 +12,4 @@ export class PipelinePresentation extends CrudController<
|
||||||
databaseModel: PipelineDBModel,
|
databaseModel: PipelineDBModel,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { PipelineModel, schemaPipeline } from "../pipelines/pipeline_model";
|
||||||
import { IsArray, IsOptional, IsString } from "class-validator";
|
import { IsArray, IsOptional, IsString } from "class-validator";
|
||||||
|
|
||||||
export interface IProjectModel {
|
export interface IProjectModel {
|
||||||
_id: string;
|
_id?:string;
|
||||||
pipelines: [PipelineModel];
|
pipelines: [PipelineModel];
|
||||||
rootDir: string;
|
rootDir: string;
|
||||||
description: string;
|
description: string;
|
||||||
|
|
|
@ -11,6 +11,7 @@ export class RealTimeValidationModel {
|
||||||
public id: string;
|
public id: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export class RealTimePresentation extends CoreHttpController<RealTimeValidationModel> {
|
export class RealTimePresentation extends CoreHttpController<RealTimeValidationModel> {
|
||||||
constructor() {
|
constructor() {
|
||||||
super({
|
super({
|
||||||
|
@ -20,5 +21,6 @@ export class RealTimePresentation extends CoreHttpController<RealTimeValidationM
|
||||||
});
|
});
|
||||||
super.post(new RunInstancePipelineUseCase().call);
|
super.post(new RunInstancePipelineUseCase().call);
|
||||||
super.get(new PipelineStatusUseCase().call);
|
super.get(new PipelineStatusUseCase().call);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
|
import { App } from "../../../core/controllers/app";
|
||||||
import { Result } from "../../../core/helper/result";
|
import { Result } from "../../../core/helper/result";
|
||||||
|
import { EXEC_TYPE } from "../../../core/model/exec_error_model";
|
||||||
import { ReadByIdDataBaseModelUseCase } from "../../../core/usecases/read_by_id_database_model_usecase";
|
import { ReadByIdDataBaseModelUseCase } from "../../../core/usecases/read_by_id_database_model_usecase";
|
||||||
import { IProjectModel, ProjectDBModel } from "../../projects/projects_model";
|
import { IProjectModel, ProjectDBModel } from "../../projects/projects_model";
|
||||||
import {
|
import {
|
||||||
|
@ -18,13 +20,19 @@ export class RunInstancePipelineUseCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
const projectModel = readByIdDataBaseModelUseCase.value;
|
const projectModel = readByIdDataBaseModelUseCase.value;
|
||||||
|
projectModel.pipelines.map((el) => {
|
||||||
|
el.process.type = EXEC_TYPE.EXEC;
|
||||||
|
});
|
||||||
|
|
||||||
pipelineRealTimeService.runPipeline(
|
pipelineRealTimeService.runPipeline(
|
||||||
projectModel.pipelines,
|
projectModel.pipelines,
|
||||||
projectModel.rootDir,
|
App.staticFilesStoreDir() + projectModel.rootDir + "/",
|
||||||
projectModel._id
|
projectModel._id
|
||||||
);
|
);
|
||||||
|
|
||||||
return Result.ok({ status: "ok" });
|
return Result.ok({ status: "ok" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// /Users/idontsudo/Desktop/testdeck-mocha-seed/server/build/public/ce4e7710-73dc-47fc-87ee-d448ea2412ce
|
||||||
|
// new ObjectId("6554c22d2ef337587505a494")
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
import { EXEC_TYPE } from "../../src/core/model/exec_error_model";
|
import { EXEC_TYPE } from "../../src/core/model/exec_error_model";
|
||||||
import {
|
import {
|
||||||
|
IPipeline,
|
||||||
IssueType,
|
IssueType,
|
||||||
StackGenerateType,
|
StackGenerateType,
|
||||||
} from "../../src/core/model/process_model";
|
} from "../../src/core/model/process_model";
|
||||||
import { TriggerType } from "../../src/features/triggers/trigger_model";
|
import { TriggerType } from "../../src/features/triggers/trigger_model";
|
||||||
|
|
||||||
export const mockSimplePipeline = [
|
export const mockSimplePipeline:IPipeline[] = [
|
||||||
{
|
{
|
||||||
process: {
|
process: {
|
||||||
type: EXEC_TYPE.EXEC,
|
type: EXEC_TYPE.EXEC,
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
"i18next": "^23.6.0",
|
"i18next": "^23.6.0",
|
||||||
"mobx": "^6.10.0",
|
"mobx": "^6.10.0",
|
||||||
"mobx-react-lite": "^4.0.4",
|
"mobx-react-lite": "^4.0.4",
|
||||||
|
"mobx-store-inheritance": "^1.0.6",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-i18next": "^13.3.1",
|
"react-i18next": "^13.3.1",
|
||||||
|
|
|
@ -4,6 +4,7 @@ export class SocketRepository {
|
||||||
serverURL = "ws://localhost:4001";
|
serverURL = "ws://localhost:4001";
|
||||||
socket: Socket | undefined;
|
socket: Socket | undefined;
|
||||||
async connect() {
|
async connect() {
|
||||||
|
console.log('connect')
|
||||||
const socket = io(this.serverURL);
|
const socket = io(this.serverURL);
|
||||||
this.socket = socket;
|
this.socket = socket;
|
||||||
socket.connect();
|
socket.connect();
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {
|
||||||
} from "../../features/all_projects/presentation/all_projects_screen";
|
} from "../../features/all_projects/presentation/all_projects_screen";
|
||||||
import {
|
import {
|
||||||
PipelineInstanceScreen,
|
PipelineInstanceScreen,
|
||||||
PipelineScreenPath,
|
PipelineInstanceScreenPath,
|
||||||
} from "../../features/pipeline_instance_main_screen/pipeline_instance_screen";
|
} from "../../features/pipeline_instance_main_screen/pipeline_instance_screen";
|
||||||
import {
|
import {
|
||||||
SelectProjectScreen,
|
SelectProjectScreen,
|
||||||
|
@ -15,7 +15,15 @@ import {
|
||||||
CreatePipelineScreen,
|
CreatePipelineScreen,
|
||||||
CreatePipelineScreenPath,
|
CreatePipelineScreenPath,
|
||||||
} from "../../features/create_pipeline/presentation/create_pipeline_screen";
|
} from "../../features/create_pipeline/presentation/create_pipeline_screen";
|
||||||
import { CreateProjectScreen, CreateProjectScreenPath } from "../../features/create_project/create_project_screen";
|
import {
|
||||||
|
CreateProjectScreen,
|
||||||
|
CreateProjectScreenPath,
|
||||||
|
} from "../../features/create_project/create_project_screen";
|
||||||
|
import {
|
||||||
|
CreateTriggerScreenPath,
|
||||||
|
TriggerScreen,
|
||||||
|
} from "../../features/create_trigger/presentation/create_trigger_screen";
|
||||||
|
import { CreateProcessScreen, CreateProcessScreenPath } from "../../features/create_process/presentation/create_process_screen";
|
||||||
|
|
||||||
export const router = createBrowserRouter([
|
export const router = createBrowserRouter([
|
||||||
{
|
{
|
||||||
|
@ -23,7 +31,7 @@ export const router = createBrowserRouter([
|
||||||
element: <AllProjectScreen />,
|
element: <AllProjectScreen />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: PipelineScreenPath,
|
path: PipelineInstanceScreenPath,
|
||||||
element: <PipelineInstanceScreen />,
|
element: <PipelineInstanceScreen />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -38,4 +46,12 @@ export const router = createBrowserRouter([
|
||||||
path: CreateProjectScreenPath,
|
path: CreateProjectScreenPath,
|
||||||
element: <CreateProjectScreen />,
|
element: <CreateProjectScreen />,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: CreateTriggerScreenPath,
|
||||||
|
element: <TriggerScreen />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: CreateProcessScreenPath,
|
||||||
|
element: <CreateProcessScreen />,
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { ReactComponent as DeleteIcon } from "../../assets/icons/delete.svg";
|
||||||
|
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import { v4 } from "uuid";
|
import { v4 } from "uuid";
|
||||||
|
import { ILinkTypography, LinkTypography } from "../link/link";
|
||||||
|
|
||||||
export type CallBackFunction = (el: ListElement, index: number) => void;
|
export type CallBackFunction = (el: ListElement, index: number) => void;
|
||||||
|
|
||||||
|
@ -20,6 +21,7 @@ export enum Icon {
|
||||||
export interface IPropsList {
|
export interface IPropsList {
|
||||||
values: ListElement[];
|
values: ListElement[];
|
||||||
headers?: string;
|
headers?: string;
|
||||||
|
link?: ILinkTypography;
|
||||||
onClick?: CallBackFunction;
|
onClick?: CallBackFunction;
|
||||||
icon: Icon;
|
icon: Icon;
|
||||||
}
|
}
|
||||||
|
@ -28,13 +30,20 @@ export const List: React.FunctionComponent<IPropsList> = observer((props) => {
|
||||||
props.values.map((el) => {
|
props.values.map((el) => {
|
||||||
if (el.id === undefined) {
|
if (el.id === undefined) {
|
||||||
el.id = v4();
|
el.id = v4();
|
||||||
return el
|
return el;
|
||||||
}
|
}
|
||||||
return el
|
return el;
|
||||||
});
|
});
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{props.headers !== undefined ? <>{props.headers}</> : <></>}
|
{props.headers !== undefined ? <>{props.headers}</> : <></>}
|
||||||
|
{props.link !== undefined ? (
|
||||||
|
<div>
|
||||||
|
<LinkTypography path={props.link.path} text={props.link.text} />
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
{props.values.map((el, index) => {
|
{props.values.map((el, index) => {
|
||||||
return (
|
return (
|
||||||
<Row
|
<Row
|
||||||
|
|
|
@ -20,6 +20,7 @@ export const LoadPage: React.FunctionComponent<ILoadPage> = observer(
|
||||||
path={props.path}
|
path={props.path}
|
||||||
largeText={props.largeText}
|
largeText={props.largeText}
|
||||||
minText={props.minText}
|
minText={props.minText}
|
||||||
|
needBackButton={props.needBackButton}
|
||||||
/>
|
/>
|
||||||
{props.isError ? (
|
{props.isError ? (
|
||||||
<>
|
<>
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
import { HttpRepository } from "../../../core/repository/http_repository";
|
import { HttpMethod, HttpRepository } from "../../../core/repository/http_repository";
|
||||||
|
import { IProjectModel } from "../model/project_model";
|
||||||
|
|
||||||
export class ProjectRepository extends HttpRepository {}
|
export class ProjectRepository extends HttpRepository {
|
||||||
|
async getAllProject() {
|
||||||
|
return this.jsonRequest<IProjectModel[]>(HttpMethod.GET,'/project')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
8
ui/src/features/all_projects/model/project_model.ts
Normal file
8
ui/src/features/all_projects/model/project_model.ts
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
import { PipelineModel } from "../../create_project/create_project_repository";
|
||||||
|
|
||||||
|
export interface IProjectModel {
|
||||||
|
_id?: string;
|
||||||
|
pipelines: [PipelineModel];
|
||||||
|
rootDir: string;
|
||||||
|
description: string;
|
||||||
|
}
|
|
@ -1,18 +1,35 @@
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
|
import { AllProjectStore } from "./all_projects_store";
|
||||||
|
import { ProjectRepository } from "../data/project_repository";
|
||||||
|
import { LoadPage } from "../../../core/ui/pages/load_page";
|
||||||
|
import { observer } from "mobx-react-lite";
|
||||||
import { SelectProjectScreenPath } from "../../select_project/presentation/select_project";
|
import { SelectProjectScreenPath } from "../../select_project/presentation/select_project";
|
||||||
import { Header } from "../../../core/ui/header/header";
|
|
||||||
|
|
||||||
export const AllProjectScreenPath = "/";
|
export const AllProjectScreenPath = "/";
|
||||||
|
|
||||||
export const AllProjectScreen: React.FunctionComponent = () => {
|
export const AllProjectScreen: React.FunctionComponent = observer(() => {
|
||||||
|
const [allProjectStore] = React.useState(
|
||||||
|
() => new AllProjectStore(new ProjectRepository())
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Header
|
<LoadPage
|
||||||
path={SelectProjectScreenPath}
|
|
||||||
largeText={"Projects"}
|
largeText={"Projects"}
|
||||||
minText={"select instance project?"}
|
needBackButton={false}
|
||||||
needBackButton={true}
|
minText="create project?"
|
||||||
|
path={SelectProjectScreenPath}
|
||||||
|
isError={allProjectStore.isError}
|
||||||
|
isLoading={allProjectStore.isLoading}
|
||||||
|
children={
|
||||||
|
<div>
|
||||||
|
{allProjectStore.projectsModels?.map((el) => {
|
||||||
|
return <div>{el.description}</div>;
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
|
|
|
@ -1,12 +1,42 @@
|
||||||
import { makeAutoObservable } from "mobx";
|
import makeAutoObservable from "mobx-store-inheritance";
|
||||||
import { ProjectRepository } from "../data/project_repository";
|
import { ProjectRepository } from "../data/project_repository";
|
||||||
|
import { IProjectModel } from "../model/project_model";
|
||||||
class AllProjectStore {
|
import { Result } from "../../../core/helper/result";
|
||||||
|
|
||||||
|
// TODO(IDONTSUDO): нужно переписать все сторы под BaseStore
|
||||||
|
class BaseStore {
|
||||||
|
isLoading = false;
|
||||||
|
isError = false;
|
||||||
|
|
||||||
|
async loadingHelper<T>(callBack: Promise<Result<any, T>>) {
|
||||||
|
this.isLoading = true;
|
||||||
|
|
||||||
|
const result = await callBack;
|
||||||
|
if (result.isFailure()) {
|
||||||
|
this.isError = true;
|
||||||
|
this.isLoading = false;
|
||||||
|
return result.forward();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isLoading = false;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export class AllProjectStore extends BaseStore {
|
||||||
|
projectsModels?: IProjectModel[];
|
||||||
|
repository: ProjectRepository;
|
||||||
constructor(repository: ProjectRepository) {
|
constructor(repository: ProjectRepository) {
|
||||||
|
super();
|
||||||
|
this.repository = repository;
|
||||||
|
this.getProjects();
|
||||||
makeAutoObservable(this);
|
makeAutoObservable(this);
|
||||||
}
|
}
|
||||||
|
async getProjects() {
|
||||||
|
const result = await this.loadingHelper(this.repository.getAllProject());
|
||||||
|
if (result.isSuccess()) {
|
||||||
|
this.projectsModels = result.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const allProjectStore = new AllProjectStore(new ProjectRepository());
|
|
|
@ -4,6 +4,8 @@ import { LoadPage } from "../../../core/ui/pages/load_page";
|
||||||
import { createPipelineStore } from "./create_pipeline_store";
|
import { createPipelineStore } from "./create_pipeline_store";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import { Icon, List } from "../../../core/ui/list/list";
|
import { Icon, List } from "../../../core/ui/list/list";
|
||||||
|
import { CreateTriggerScreenPath } from "../../create_trigger/presentation/create_trigger_screen";
|
||||||
|
import { CreateProcessScreenPath } from "../../create_process/presentation/create_process_screen";
|
||||||
|
|
||||||
export const CreatePipelineScreenPath = "/create_pipeline";
|
export const CreatePipelineScreenPath = "/create_pipeline";
|
||||||
|
|
||||||
|
@ -19,6 +21,7 @@ export const CreatePipelineScreen: React.FunctionComponent = observer(() => {
|
||||||
<Row>
|
<Row>
|
||||||
<List
|
<List
|
||||||
headers={"process"}
|
headers={"process"}
|
||||||
|
link={{ path: CreateProcessScreenPath, text: "create process" }}
|
||||||
values={createPipelineStore.processModels.map((el) => {
|
values={createPipelineStore.processModels.map((el) => {
|
||||||
return { text: el.description, id: el._id };
|
return { text: el.description, id: el._id };
|
||||||
})}
|
})}
|
||||||
|
@ -41,6 +44,7 @@ export const CreatePipelineScreen: React.FunctionComponent = observer(() => {
|
||||||
|
|
||||||
<List
|
<List
|
||||||
headers="triggers"
|
headers="triggers"
|
||||||
|
link={{ path: CreateTriggerScreenPath, text: "create trigger" }}
|
||||||
values={createPipelineStore.triggersModels.map((el) => {
|
values={createPipelineStore.triggersModels.map((el) => {
|
||||||
return { text: el.description, id: el._id };
|
return { text: el.description, id: el._id };
|
||||||
})}
|
})}
|
||||||
|
|
|
@ -10,6 +10,7 @@ export interface IProcess extends DatabaseModel {
|
||||||
timeout?: number;
|
timeout?: number;
|
||||||
commit?: string | undefined;
|
commit?: string | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum EXEC_TYPE {
|
export enum EXEC_TYPE {
|
||||||
SPAWN = "SPAWN",
|
SPAWN = "SPAWN",
|
||||||
EXEC = "EXEC",
|
EXEC = "EXEC",
|
||||||
|
@ -19,7 +20,6 @@ export enum IssueType {
|
||||||
ERROR = "ERROR",
|
ERROR = "ERROR",
|
||||||
}
|
}
|
||||||
export const processModelMock: IProcess = {
|
export const processModelMock: IProcess = {
|
||||||
_id: "",
|
|
||||||
description: "",
|
description: "",
|
||||||
type: EXEC_TYPE.SPAWN,
|
type: EXEC_TYPE.SPAWN,
|
||||||
command: "",
|
command: "",
|
||||||
|
|
|
@ -12,7 +12,7 @@ import {
|
||||||
import { Formik } from "formik";
|
import { Formik } from "formik";
|
||||||
import { Row, Col } from "antd";
|
import { Row, Col } from "antd";
|
||||||
import { EXEC_TYPE, IssueType, processModelMock } from "../model/process_model";
|
import { EXEC_TYPE, IssueType, processModelMock } from "../model/process_model";
|
||||||
|
export const CreateProcessScreenPath = '/create/process'
|
||||||
export const CreateProcessScreen = observer(() => {
|
export const CreateProcessScreen = observer(() => {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -87,3 +87,4 @@ export const CreateProjectScreen: React.FunctionComponent = observer(() => {
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { CodeTriggerForm } from "./components/code_trigger_form";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import { triggerStore } from "./trigger_store";
|
import { triggerStore } from "./trigger_store";
|
||||||
import { FileTriggerForm } from "./components/file_trigger_form";
|
import { FileTriggerForm } from "./components/file_trigger_form";
|
||||||
import { ReactComponent as DeleteIcon } from "../../../assets/icons/delete.svg";
|
import { ReactComponent as DeleteIcon } from "../../../core/assets/icons/delete.svg";
|
||||||
import { Loader } from "../../../core/ui/loader/loader";
|
import { Loader } from "../../../core/ui/loader/loader";
|
||||||
|
|
||||||
const { Title } = Typography;
|
const { Title } = Typography;
|
||||||
|
@ -45,7 +45,7 @@ const Bottom = observer(() => {
|
||||||
</Col>
|
</Col>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
export const CreateTriggerScreenPath = '/create/trigger'
|
||||||
export const TriggerScreen: React.FunctionComponent = observer(() => {
|
export const TriggerScreen: React.FunctionComponent = observer(() => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Button } from "antd";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export const PipelineScreenPath = '/pipeline_instance/:id'
|
export const PipelineInstanceScreenPath = '/pipeline_instance/:id'
|
||||||
export const PipelineInstanceScreen: React.FunctionComponent = () => {
|
export const PipelineInstanceScreen: React.FunctionComponent = () => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
|
@ -1,12 +1,18 @@
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { selectProjectStore } from "./select_project_store";
|
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import { LoadPage } from "../../../core/ui/pages/load_page";
|
import { LoadPage } from "../../../core/ui/pages/load_page";
|
||||||
import { CreateProjectScreenPath } from "../../create_project/create_project_screen";
|
import { CreateProjectScreenPath } from "../../create_project/create_project_screen";
|
||||||
|
import { SelectProjectStore } from "./select_project_store";
|
||||||
|
import { SelectProjectRepository } from "../data/select_project_repository";
|
||||||
|
|
||||||
export const SelectProjectScreenPath = "/select_project";
|
export const SelectProjectScreenPath = "/select_project";
|
||||||
|
|
||||||
export const SelectProjectScreen: React.FunctionComponent = observer(() => {
|
export const SelectProjectScreen: React.FunctionComponent = observer(() => {
|
||||||
|
const [selectProjectStore] = React.useState(
|
||||||
|
() => new SelectProjectStore(new SelectProjectRepository())
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<LoadPage
|
<LoadPage
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { makeAutoObservable } from "mobx";
|
||||||
import { SelectProjectRepository } from "../data/select_project_repository";
|
import { SelectProjectRepository } from "../data/select_project_repository";
|
||||||
import { IProjectModel } from "../model/project_model";
|
import { IProjectModel } from "../model/project_model";
|
||||||
|
|
||||||
class SelectProjectStore {
|
export class SelectProjectStore {
|
||||||
repository: SelectProjectRepository;
|
repository: SelectProjectRepository;
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
isError = false;
|
isError = false;
|
||||||
|
@ -29,7 +29,4 @@ class SelectProjectStore {
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const selectProjectStore = new SelectProjectStore(
|
|
||||||
new SelectProjectRepository()
|
|
||||||
);
|
|
Loading…
Add table
Add a link
Reference in a new issue