set active project
This commit is contained in:
parent
814eb485eb
commit
4e726be376
25 changed files with 58 additions and 151 deletions
|
@ -13,6 +13,6 @@ export class ProjectRepository extends HttpRepository {
|
|||
return this._jsonRequest<UUID>(HttpMethod.GET, "/projects/get/active/project/id");
|
||||
}
|
||||
async setActivePipeline(id: string) {
|
||||
return this._jsonRequest(HttpMethod.POST, `/project_instance/set/active/project?id=${id}`);
|
||||
return this._jsonRequest(HttpMethod.POST, `/projects/set/active/project?id=${id}`);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ export const AllProjectScreen: React.FunctionComponent = observer(() => {
|
|||
<div>
|
||||
{store.projectsModels?.map((el) => {
|
||||
return (
|
||||
<div style={{ margin: "10px", backgroundColor: "Highlight" }}>
|
||||
<div style={{ margin: 10, backgroundColor: "chartreuse" }}>
|
||||
{el.isActive ? (
|
||||
<Button
|
||||
onClick={() => {
|
||||
|
@ -39,7 +39,7 @@ export const AllProjectScreen: React.FunctionComponent = observer(() => {
|
|||
>
|
||||
instance screen
|
||||
</Button>
|
||||
) : null}
|
||||
) : <Button style={{ backgroundColor: 'red' }} onClick={() => store.setActiveProject(el._id as string)}>active project</Button>}
|
||||
<div style={{ margin: "10px", display: "contents" }}> {el.description}</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -19,6 +19,7 @@ export class ProjectView {
|
|||
}
|
||||
}
|
||||
export class AllProjectStore extends SimpleErrorState {
|
||||
|
||||
projectsModels?: IProjectModel[];
|
||||
activeProjectId?: UUID;
|
||||
repository: ProjectRepository;
|
||||
|
@ -33,12 +34,15 @@ export class AllProjectStore extends SimpleErrorState {
|
|||
async getActiveProjectId(): Promise<void> {
|
||||
await this.mapOk<UUID>("activeProjectId", this.repository.getActivePipeline());
|
||||
}
|
||||
setActiveProject = async (id: string) => {
|
||||
await this.messageHttp(this.repository.setActivePipeline(id), { successMessage: "проект активирован", errorMessage: 'ошибка активации' })
|
||||
await this.mapOk<UUID>("activeProjectId", this.repository.getActivePipeline());
|
||||
await this.mapOk<IProjectModel[]>("projectsModels", this.repository.getAllProject());
|
||||
}
|
||||
async init() {
|
||||
await Promise.all([this.getProjects(), this.getActiveProjectId()]);
|
||||
this.projectsModels?.map((el) => (el._id === this.activeProjectId ? ((el.isActive = true), el) : el));
|
||||
}
|
||||
|
||||
async setPipelineActive(id: string) {
|
||||
await this.httpHelper(this.repository.setActivePipeline(id));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue