style: update UI

This commit is contained in:
夜鹰 2022-10-13 14:54:18 +08:00
parent e8fd71ede0
commit 8d2b1f07f3
13 changed files with 418 additions and 287 deletions

View File

@ -15,6 +15,7 @@ export class Canvas extends Render {
init: [...this.children.init],
data: [...this.children.data],
methods: [...this.children.methods],
resetFn: [...this.children.resetFn],
};
}
}

View File

@ -179,6 +179,13 @@ export class Form extends Render implements formType {
const footer = footerRender(this.footer || []);
const footerTemplate = footer?.length ? `${footer.map((it) => it.template).join('\n')}` : '';
return {
elementType: 'form',
resetFn: [
`
\/\/ * auto clear form
this.validate${this.id}Form.reset()`,
...this.children.resetFn,
],
imports: [
{
target: [

View File

@ -25,6 +25,12 @@ export class Input extends Render {
render() {
return {
type: 'element',
resetFn: [
`
\/\/ * auto clear form
this.input${this.id}Value = ''`,
...this.children.resetFn,
],
imports: [
{
target: [{ name: 'NzInputModule', type: 'module' }],

View File

@ -0,0 +1,100 @@
import * as _ from 'lodash';
import { Render } from 'ecode/dist/render';
import { Button } from './button';
type modalType = {
footer?: { label: string; event: any; status: any; theme?: string[] }[] | null;
close: () => string;
// static close: () => string
};
const eventHash = new Map().set('open', 'nzAfterOpen').set('close', 'nzAfterClose');
const eventTranlate = (event) =>
Object.entries(event).reduce((total, [e, cb]) => {
total[eventHash.get(e)] = cb;
return total;
}, {});
export class Modal extends Render implements modalType {
footer;
id = '';
title;
width;
init;
constructor({ id = '', event = {}, width = null, title, children, footer = null }) {
super({ children, event: eventTranlate(event) });
this.id = Render.toCamel(id);
this.title = title;
this.footer = footer;
this.width = width;
this.init = [];
}
wakeUp() {
return `
// * 唤起弹窗
const ${this.id}ModalRef = this.modal.create({
nzTitle: '${this.title}',
nzWidth: ${this.width},
nzCloseable: true,
nzContent: this.modal${this.id}Tpl,
})
`;
}
close() {
return `
// * 关闭弹窗
${this.id}ModalRef.close()
`;
}
render() {
return {
template: `<ng-templete #modal${this.id}Tpl let-params>${this.children.template}</ng-templete>`,
data: [...this.children.data],
init: [...this.children.init],
imports: [
{
target: [
{
name: 'NzModalService',
type: 'service',
inject: { name: 'modal' },
},
{ name: 'NzModalModule', type: 'module' },
],
from: 'ng-zorro-antd/modal',
},
{
target: [
{
name: 'ViewChild',
type: 'base',
},
],
from: '@angular/core',
},
{ name: 'NzModalModule', type: 'module' },
...this.children.imports,
],
methods: [...this.methods, ...this.children.methods],
};
}
static wakeUp(id) {
return `
// * 唤起弹窗
const ${this.id}ModalRef = this.modal.create({
nzTitle: '${this.title}',
nzWidth: ${this.width},
nzCloseable: true,
nzContent: this.modal${this.id}Tpl,
})
`;
}
static close(id) {
return `
// * 关闭弹窗
this.is${Render.toCamel(id)}ModalVisible = false
`;
}
}

View File

@ -10,9 +10,10 @@ type modalType = {
const eventHash = new Map().set('open', 'nzAfterOpen').set('close', 'nzAfterClose');
const eventTranlate = (event) =>
Object.entries(event).reduce((total, [e, cb]) => {
total[eventHash.get(e)] = cb;
const eventTranlate = (list) =>
list.reduce((total, [e, cb]) => {
const key = eventHash.get(e);
total[key] = total[key] ? total[key].concat(cb) : [cb];
return total;
}, {});
@ -22,7 +23,14 @@ export class Modal extends Render implements modalType {
title;
width;
constructor({ id = '', event = {}, width = null, title, children, footer = null }) {
super({ children, event: eventTranlate(event) });
const close = children
.flat(Infinity)
.map((it) => it.render())
.filter((it) => it.resetFn)
.map((it) => it.resetFn)
.flat(Infinity)
.filter((it) => it);
super({ children, event: eventTranlate([...Object.entries({ close }), ...Object.entries(event)]) });
this.id = Render.toCamel(id);
this.title = title;
this.footer = footer;

View File

@ -1,8 +1,42 @@
import { Render } from 'ecode/dist/render';
import { Render, Component } from 'ecode/dist/render';
export class ModalS extends Render {
components;
template;
constructor() {
super({ children: [] });
this.components = [];
this.template = '';
}
wakeUp({ id, title, children, event = { open: null, close: null } }) {
this.template = '';
}
component({ id, title, children, event = { open: null, close: null } }) {
const comp = new Component({
id,
children,
imports: [...children.map((it) => it.render().imports)],
init: [],
});
this.components.push(comp.render());
const { open, close } = event;
return `
const ${Render.toCamel(id)}Modal = this.modal.create({
nzTitle: '${title}',
nzContent: ${Render.toCamel(id)}Component,
nzViewContainerRef: this.viewContainerRef,
nzComponentParams: {},
nzOnOk: () => {},
nzFooter: []
});
${open ? `${Render.toCamel(id)}Modal.afterOpen.subscribe(() => { ${Render.callbackRender(open)} })` : ''}
${close ? `${Render.toCamel(id)}Modal.afterClose.subscribe(result => { ${Render.callbackRender(close)} })` : ''}
`;
}
close(id) {
return `
// * close the modal and clear data cache
${Render.toCamel(id)}Modal.close()`;
}
danger({ title, content, okText = 'Delete' }) {
return `
@ -45,6 +79,7 @@ export class ModalS extends Render {
imports: [
{
target: [
{ name: 'NzModalRef', type: 'base' },
{
name: 'NzModalService',
type: 'service',
@ -54,10 +89,21 @@ export class ModalS extends Render {
],
from: 'ng-zorro-antd/modal',
},
// {
// target: [
// {
// name: 'ViewContainerRef',
// type: 'service',
// inject: { name: 'viewContainerRef' },
// },
// ],
// from: '@angular/core',
// },
],
template: ``,
data: [],
methods: [],
components: [...this.components],
};
}
}

View File

@ -40,7 +40,7 @@ import { Component, OnInit } from '@angular/core'
type="submit"
class="w-[84px]"
nzType="primary"
(click)="btngykhneCallback()"
(click)="btn5txtxwCallback()"
i18n
>
Save
@ -123,7 +123,7 @@ import { Component, OnInit } from '@angular/core'
type="submit"
class="w-[84px]"
nzType="primary"
(click)="btn12cjg5Callback()"
(click)="btnl3ugn7Callback()"
i18n
>
Reset
@ -171,7 +171,7 @@ export class AccountComponent implements OnInit {
username: this.user.userProfile?.username
})
}
async btngykhneCallback() {
async btn5txtxwCallback() {
// * click event callback
const { username: user } = this.validateUsernameForm.value
const [data, err]: any = await this.api.api_userUpdateUserProfile({
@ -214,7 +214,7 @@ export class AccountComponent implements OnInit {
}
return {}
}
async btn12cjg5Callback() {
async btnl3ugn7Callback() {
// * click event callback
const { oldPassword: oldPassword } = this.validatePasswordForm.value
const { newPassword: newPassword } = this.validatePasswordForm.value

View File

@ -1,4 +1,4 @@
import { NzModalService } from 'ng-zorro-antd/modal'
import { NzModalService, NzModalRef } from 'ng-zorro-antd/modal'
import { UserService } from 'eo/workbench/browser/src/app/shared/services/user/user.service'
import { MessageService } from 'eo/workbench/browser/src/app/shared/services/message/message.service'
import { RemoteService } from 'eo/workbench/browser/src/app/shared/services/storage/remote.service'
@ -15,7 +15,7 @@ import { Component, OnInit } from '@angular/core'
[nzFooter]="null"
[(nzVisible)]="isInvateModalVisible"
(nzOnCancel)="handleInvateModalCancel()"
(nzAfterClose)="eritvfsCallback()"
(nzAfterClose)="ejpi10eCallback()"
nzTitle="Add people to the workspace"
i18n-nzTitle
>
@ -32,8 +32,8 @@ import { Component, OnInit } from '@angular/core'
class=""
nzType="primary"
nzBlock
(click)="btnrzdn15Callback()"
[disabled]="btn193ksdStatus()"
(click)="btn7ty1q2Callback()"
[disabled]="btnvj7r3wStatus()"
i18n
>
Select a member above
@ -47,8 +47,8 @@ import { Component, OnInit } from '@angular/core'
nz-button
class=""
nzType="primary"
(click)="btnkjotm1Callback()"
[disabled]="btnuk14mmStatus()"
(click)="btnmlnjqqCallback()"
[disabled]="btnem7sukStatus()"
i18n
>
Add people
@ -57,7 +57,7 @@ import { Component, OnInit } from '@angular/core'
<section class="py-5">
<eo-manage-access
[data]="memberList"
(eoOnRemove)="e006qnoCallback($event)"
(eoOnRemove)="evqg0xcCallback($event)"
></eo-manage-access>
</section>
</section>`
@ -115,11 +115,15 @@ export class MemberComponent implements OnInit {
// * 关闭弹窗
this.isInvateModalVisible = false
}
async eritvfsCallback() {
async ejpi10eCallback() {
// * nzAfterClose event callback
{
// * auto clear form
this.inputPersonValue = ''
}
this.inputPersonValue = ''
}
async btnrzdn15Callback() {
async btn7ty1q2Callback() {
// * click event callback
const username = this.inputPersonValue
const [uData, uErr]: any = await this.api.api_userSearch({ username })
@ -181,17 +185,17 @@ export class MemberComponent implements OnInit {
const Member = wData.filter((it) => it.roleName !== 'Owner')
this.memberList = Owner.concat(Member)
}
btn193ksdStatus() {
btnvj7r3wStatus() {
// * disabled status status
return this.inputPersonValue === ''
}
async btnkjotm1Callback() {
async btnmlnjqqCallback() {
// * click event callback
// * 唤起弹窗
this.isInvateModalVisible = true
}
btnuk14mmStatus() {
btnem7sukStatus() {
// * disabled status status
return
return (
@ -199,7 +203,7 @@ export class MemberComponent implements OnInit {
this.workspace.authEnum.canEdit
)
}
async e006qnoCallback($event) {
async evqg0xcCallback($event) {
// * eoOnRemove event callback
const confirm = () =>

View File

@ -1,6 +1,6 @@
import { NgModule } from '@angular/core'
import { CommonModule } from '@angular/common'
import { NzModalService, NzModalModule } from 'ng-zorro-antd/modal'
import { NzModalService, NzModalModule, NzModalRef } from 'ng-zorro-antd/modal'
import { NzInputModule } from 'ng-zorro-antd/input'
import { FormsModule } from '@angular/forms'
import { NzButtonModule } from 'ng-zorro-antd/button'

View File

@ -1,20 +1,15 @@
import { UserService } from 'eo/workbench/browser/src/app/shared/services/user/user.service'
import { MessageService } from 'eo/workbench/browser/src/app/shared/services/message/message.service'
import { RemoteService } from 'eo/workbench/browser/src/app/shared/services/storage/remote.service'
import { EoMessageService } from 'eo/workbench/browser/src/app/eoui/message/eo-message.service'
import { ProjectService } from 'eo/workbench/browser/src/app/shared/services/project/project.service'
import { DataSourceService } from 'eo/workbench/browser/src/app/shared/services/data-source/data-source.service'
import { distinct } from 'rxjs/operators'
import { interval } from 'rxjs'
import { NzModalService } from 'ng-zorro-antd/modal'
import {
UntypedFormBuilder,
UntypedFormControl,
UntypedFormGroup,
Validators
} from '@angular/forms'
import { WorkspaceService } from 'eo/workbench/browser/src/app/shared/services/workspace/workspace.service'
import { Component, OnInit } from '@angular/core'
import { UserService } from 'eo/workbench/browser/src/app/shared/services/user/user.service';
import { MessageService } from 'eo/workbench/browser/src/app/shared/services/message/message.service';
import { RemoteService } from 'eo/workbench/browser/src/app/shared/services/storage/remote.service';
import { EoMessageService } from 'eo/workbench/browser/src/app/eoui/message/eo-message.service';
import { ProjectService } from 'eo/workbench/browser/src/app/shared/services/project/project.service';
import { DataSourceService } from 'eo/workbench/browser/src/app/shared/services/data-source/data-source.service';
import { distinct } from 'rxjs/operators';
import { interval } from 'rxjs';
import { NzModalService } from 'ng-zorro-antd/modal';
import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms';
import { WorkspaceService } from 'eo/workbench/browser/src/app/shared/services/workspace/workspace.service';
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'eo-user-modal',
@ -22,13 +17,13 @@ import { Component, OnInit } from '@angular/core'
[nzFooter]="modalSyncFooter"
[(nzVisible)]="isSyncModalVisible"
(nzOnCancel)="handleSyncModalCancel()"
(nzAfterClose)="eelsfnjCallback()"
nzTitle="Do you want to upload local data to the cloud ?"
i18n-nzTitle
>
<ng-container *nzModalContent>
<span i18n>
After confirmation, the system will create a cloud space to upload the
local data to the cloud.
After confirmation, the system will create a cloud space to upload the local data to the cloud.
</span>
<nz-alert
nzType="warning"
@ -37,58 +32,25 @@ import { Component, OnInit } from '@angular/core'
></nz-alert>
</ng-container>
<ng-template #modalSyncFooter>
<button
nz-button
class=""
nzType="default"
(click)="btndym1alCallback()"
i18n
>
Cancel
</button>
<button
nz-button
class=""
nzType="primary"
(click)="btnobcnblCallback()"
i18n
>
Sync
</button>
<button nz-button class="" nzType="default" (click)="btnp1daq9Callback()" i18n>Cancel</button>
<button nz-button class="" nzType="primary" (click)="btn94e09oCallback()" i18n>Sync</button>
</ng-template>
</nz-modal>
<nz-modal
[nzFooter]="modalCheckConnectFooter"
[(nzVisible)]="isCheckConnectModalVisible"
(nzOnCancel)="handleCheckConnectModalCancel()"
(nzAfterClose)="e7v9f3eCallback()"
nzTitle="Check your connection"
i18n-nzTitle
>
<ng-container *nzModalContent>
<span i18n> Can't connect right now, click to retry or </span>
<span style="color: #1890ff" (click)="textx6e63wCallback()" i18n>
config in the configuration
</span>
<span style="color: #1890ff" (click)="text5jk0zaCallback()" i18n> config in the configuration </span>
</ng-container>
<ng-template #modalCheckConnectFooter>
<button
nz-button
class=""
nzType="default"
(click)="btnev86beCallback()"
i18n
>
Cancel
</button>
<button
nz-button
class=""
nzType="primary"
(click)="btnuft0cqCallback()"
i18n
>
Retry
</button>
<button nz-button class="" nzType="default" (click)="btnsxnnseCallback()" i18n>Cancel</button>
<button nz-button class="" nzType="primary" (click)="btnx0y1pjCallback()" i18n>Retry</button>
</ng-template>
</nz-modal>
<nz-modal
@ -96,7 +58,7 @@ import { Component, OnInit } from '@angular/core'
[nzWidth]="400"
[(nzVisible)]="isLoginModalVisible"
(nzOnCancel)="handleLoginModalCancel()"
(nzAfterClose)="e5l5t29Callback()"
(nzAfterClose)="emvl4itCallback()"
nzTitle="Sign In/Up"
i18n-nzTitle
>
@ -125,13 +87,9 @@ import { Component, OnInit } from '@angular/core'
i18n-placeholder
/>
<ng-template #passwordErrorTpl let-control>
<ng-container *ngIf="control.hasError('required')" i18n>
Please input your password;
</ng-container>
<ng-container *ngIf="control.hasError('required')" i18n> Please input your password; </ng-container>
<ng-container *ngIf="control.hasError('minlength')" i18n>
Min length is 6;
</ng-container>
<ng-container *ngIf="control.hasError('minlength')" i18n> Min length is 6; </ng-container>
</ng-template>
</nz-form-control>
</nz-form-item>
@ -142,7 +100,7 @@ import { Component, OnInit } from '@angular/core'
class="h-10 mt-2"
nzType="primary"
nzBlock
(click)="btnmympi6Callback()"
(click)="btnfut4cnCallback()"
i18n
>
Sign In/Up
@ -155,14 +113,13 @@ import { Component, OnInit } from '@angular/core'
[nzFooter]="null"
[(nzVisible)]="isOpenSettingModalVisible"
(nzOnCancel)="handleOpenSettingModalCancel()"
(nzAfterClose)="ebfy6zcCallback()"
nzTitle="Open setting"
i18n-nzTitle
>
<ng-container *nzModalContent>
<span i18n> If you want to collaborate, please </span>
<span style="color: #1890ff" (click)="textkmcrwvCallback()" i18n>
open the settings
</span>
<span style="color: #1890ff" (click)="text4fn9sfCallback()" i18n> open the settings </span>
<span i18n> and fill in the configuration </span>
</ng-container>
</nz-modal>
@ -170,48 +127,27 @@ import { Component, OnInit } from '@angular/core'
[nzFooter]="modalAddWorkspaceFooter"
[(nzVisible)]="isAddWorkspaceModalVisible"
(nzOnCancel)="handleAddWorkspaceModalCancel()"
(nzAfterClose)="ehr6ppmCallback()"
(nzAfterClose)="etuv4keCallback()"
nzTitle="Add Workspace"
i18n-nzTitle
>
<ng-container *nzModalContent>
<input
nz-input
[(ngModel)]="inputWorkspaceNameValue"
i18n-placeholder
placeholder="Workspace Name"
/>
<input nz-input [(ngModel)]="inputWorkspaceNameValue" i18n-placeholder placeholder="Workspace Name" />
</ng-container>
<ng-template #modalAddWorkspaceFooter>
<button
nz-button
class=""
nzType="default"
(click)="btn2op86eCallback()"
i18n
>
Cancel
</button>
<button
nz-button
class=""
nzType="primary"
(click)="btnv0jv0tCallback()"
i18n
>
Save
</button>
<button nz-button class="" nzType="default" (click)="btnua379iCallback()" i18n>Cancel</button>
<button nz-button class="" nzType="primary" (click)="btn539vb6Callback()" i18n>Save</button>
</ng-template>
</nz-modal>`
</nz-modal>`,
})
export class UserModalComponent implements OnInit {
isSyncModalVisible
isCheckConnectModalVisible
isLoginModalVisible
validateLoginForm
isOpenSettingModalVisible
isAddWorkspaceModalVisible
inputWorkspaceNameValue
isSyncModalVisible;
isCheckConnectModalVisible;
isLoginModalVisible;
validateLoginForm;
isOpenSettingModalVisible;
isAddWorkspaceModalVisible;
inputWorkspaceNameValue;
constructor(
public user: UserService,
public message: MessageService,
@ -223,13 +159,13 @@ export class UserModalComponent implements OnInit {
public fb: UntypedFormBuilder,
public workspace: WorkspaceService
) {
this.isSyncModalVisible = false
this.isCheckConnectModalVisible = false
this.isLoginModalVisible = false
this.validateLoginForm = UntypedFormGroup
this.isOpenSettingModalVisible = false
this.isAddWorkspaceModalVisible = false
this.inputWorkspaceNameValue = ''
this.isSyncModalVisible = false;
this.isCheckConnectModalVisible = false;
this.isLoginModalVisible = false;
this.validateLoginForm = UntypedFormGroup;
this.isOpenSettingModalVisible = false;
this.isAddWorkspaceModalVisible = false;
this.inputWorkspaceNameValue = '';
}
async ngOnInit(): Promise<void> {
this.message
@ -238,346 +174,360 @@ export class UserModalComponent implements OnInit {
.subscribe(async ({ type, data }) => {
if (type === 'login') {
// * 唤起弹窗
this.isLoginModalVisible = true
this.isLoginModalVisible = true;
return
return;
}
if (type === 'clear-user') {
this.user.clearAuth()
this.user.clearAuth();
this.user.setUserProfile({
id: -1,
password: '',
username: '',
workspaces: []
})
return
workspaces: [],
});
return;
}
if (type === 'http-401') {
const { id } = this.workspace.currentWorkspace
const { id } = this.workspace.currentWorkspace;
if (id === -1) {
return
return;
}
// * 唤起弹窗
this.isLoginModalVisible = true
this.isLoginModalVisible = true;
return
return;
}
if (type === 'logOut') {
this.workspace.setCurrentWorkspaceID(-1)
this.workspace.setCurrentWorkspaceID(-1);
this.user.setUserProfile({
id: -1,
password: '',
username: '',
workspaces: []
})
workspaces: [],
});
{
this.workspace.setWorkspaceList([])
this.workspace.setWorkspaceList([]);
}
this.workspace.setCurrentWorkspace(
this.workspace.getLocalWorkspaceInfo()
)
this.eMessage.success($localize`Successfully logged out !`)
const refreshToken = this.user.refreshToken
this.user.clearAuth()
this.workspace.setCurrentWorkspace(this.workspace.getLocalWorkspaceInfo());
this.eMessage.success($localize`Successfully logged out !`);
const refreshToken = this.user.refreshToken;
this.user.clearAuth();
{
const [data, err]: any = await this.api.api_authLogout({
refreshToken
})
refreshToken,
});
if (err) {
if (err.status === 401) {
this.message.send({ type: 'clear-user', data: {} })
this.message.send({ type: 'clear-user', data: {} });
if (this.user.isLogin) {
return
return;
}
this.message.send({ type: 'http-401', data: {} })
this.message.send({ type: 'http-401', data: {} });
}
return
return;
}
}
return
return;
}
if (type === 'ping-fail') {
this.eMessage.error($localize`Connect failed`)
this.eMessage.error($localize`Connect failed`);
// * 唤起弹窗
this.isCheckConnectModalVisible = true
this.isCheckConnectModalVisible = true;
return
return;
}
if (type === 'ping-success') {
this.eMessage.success($localize`Connect success`)
return
this.eMessage.success($localize`Connect success`);
return;
}
if (type === 'need-config-remote') {
// * 唤起弹窗
this.isOpenSettingModalVisible = true
this.isOpenSettingModalVisible = true;
return
return;
}
if (type === 'addWorkspace') {
// * 唤起弹窗
this.isAddWorkspaceModalVisible = true
this.isAddWorkspaceModalVisible = true;
return
return;
}
if (type === 'retry') {
// * 唤起弹窗
this.isCheckConnectModalVisible = true
this.isCheckConnectModalVisible = true;
return
return;
}
})
});
// * Init Login form
this.validateLoginForm = this.fb.group({
username: [null, [Validators.required]],
password: [null, [Validators.required, Validators.minLength(6)]]
})
password: [null, [Validators.required, Validators.minLength(6)]],
});
const { id: workspaceID } = this.workspace.currentWorkspace
const [data, err]: any = await this.api.api_workspaceList({})
const { id: workspaceID } = this.workspace.currentWorkspace;
const [data, err]: any = await this.api.api_workspaceList({});
if (err) {
if (err.status === 401) {
this.message.send({ type: 'clear-user', data: {} })
this.message.send({ type: 'clear-user', data: {} });
if (this.user.isLogin) {
return
return;
}
this.message.send({ type: 'http-401', data: {} })
this.message.send({ type: 'http-401', data: {} });
}
return
return;
}
this.workspace.setWorkspaceList(data)
this.workspace.setWorkspaceList(data);
if (workspaceID !== -1) {
const { projects } = await this.workspace.getWorkspaceInfo(workspaceID)
this.project.setCurrentProjectID(projects.at(0).uuid)
const { projects } = await this.workspace.getWorkspaceInfo(workspaceID);
this.project.setCurrentProjectID(projects.at(0).uuid);
}
const url = this.dataSource.mockUrl
const url = this.dataSource.mockUrl;
if (url === '') {
// * 唤起弹窗
this.isOpenSettingModalVisible = true
this.isOpenSettingModalVisible = true;
return
return;
}
const { id: currentWorkspaceID } = this.workspace.currentWorkspace
const { id: currentWorkspaceID } = this.workspace.currentWorkspace;
if (currentWorkspaceID === -1) {
return
return;
}
const status = this.dataSource.isConnectRemote
const status = this.dataSource.isConnectRemote;
if (!status) {
// * 唤起弹窗
this.isCheckConnectModalVisible = true
this.isCheckConnectModalVisible = true;
return
return;
}
}
handleSyncModalCancel(): void {
// * 关闭弹窗
this.isSyncModalVisible = false
this.isSyncModalVisible = false;
}
async btndym1alCallback() {
async eelsfnjCallback() {
// * nzAfterClose event callback
{
}
}
async btnp1daq9Callback() {
// * click event callback
// * 关闭弹窗
this.isSyncModalVisible = false
this.isSyncModalVisible = false;
}
async btnobcnblCallback() {
async btn94e09oCallback() {
// * click event callback
const eData = await this.project.exportLocalProjectData()
const eData = await this.project.exportLocalProjectData();
const [data, err]: any = await this.api.api_workspaceUpload(eData)
const [data, err]: any = await this.api.api_workspaceUpload(eData);
if (err) {
if (err.status === 401) {
this.message.send({ type: 'clear-user', data: {} })
this.message.send({ type: 'clear-user', data: {} });
if (this.user.isLogin) {
return
return;
}
this.message.send({ type: 'http-401', data: {} })
this.message.send({ type: 'http-401', data: {} });
}
return
return;
}
const { workspace } = data
const { workspace } = data;
const list = this.workspace.getWorkspaceList().filter((it) => it.id !== -1)
this.workspace.setWorkspaceList([...list, workspace])
this.workspace.setCurrentWorkspaceID(workspace)
const list = this.workspace.getWorkspaceList().filter((it) => it.id !== -1);
this.workspace.setWorkspaceList([...list, workspace]);
this.workspace.setCurrentWorkspaceID(workspace);
// * 关闭弹窗
this.isSyncModalVisible = false
this.isSyncModalVisible = false;
}
handleCheckConnectModalCancel(): void {
// * 关闭弹窗
this.isCheckConnectModalVisible = false
this.isCheckConnectModalVisible = false;
}
async btnev86beCallback() {
async e7v9f3eCallback() {
// * nzAfterClose event callback
{
}
}
async btnsxnnseCallback() {
// * click event callback
// * 关闭弹窗
this.isCheckConnectModalVisible = false
this.isCheckConnectModalVisible = false;
}
async btnuft0cqCallback() {
async btnx0y1pjCallback() {
// * click event callback
this.dataSource.checkRemoteAndTipModal()
this.dataSource.checkRemoteAndTipModal();
// * 关闭弹窗
this.isCheckConnectModalVisible = false
this.isCheckConnectModalVisible = false;
}
async textx6e63wCallback() {
async text5jk0zaCallback() {
// * click event callback
// * 关闭弹窗
this.isOpenSettingModalVisible = false
this.isOpenSettingModalVisible = false;
}
handleLoginModalCancel(): void {
// * 关闭弹窗
this.isLoginModalVisible = false
this.isLoginModalVisible = false;
}
async e5l5t29Callback() {
async emvl4itCallback() {
// * nzAfterClose event callback
// * Clear Login form
this.validateLoginForm.reset()
{
// * auto clear form
this.validateLoginForm.reset();
}
}
async btnmympi6Callback() {
async btnfut4cnCallback() {
// * click event callback
const isOk = this.validateLoginForm.valid
const isOk = this.validateLoginForm.valid;
if (!isOk) {
this.eMessage.error($localize`Please check you username or password`)
return
this.eMessage.error($localize`Please check you username or password`);
return;
}
// * get login form values
const formData = this.validateLoginForm.value
const [data, err]: any = await this.api.api_authLogin(formData)
const formData = this.validateLoginForm.value;
const [data, err]: any = await this.api.api_authLogin(formData);
if (err) {
this.eMessage.error($localize`Authentication failed !`)
this.eMessage.error($localize`Authentication failed !`);
if (err.status === 401) {
this.message.send({ type: 'clear-user', data: {} })
this.message.send({ type: 'clear-user', data: {} });
if (this.user.isLogin) {
return
return;
}
this.message.send({ type: 'http-401', data: {} })
this.message.send({ type: 'http-401', data: {} });
}
return
return;
}
this.user.setLoginInfo(data)
this.user.setLoginInfo(data);
// * 关闭弹窗
this.isLoginModalVisible = false
this.isLoginModalVisible = false;
{
const [data, err]: any = await this.api.api_userReadProfile(null)
const [data, err]: any = await this.api.api_userReadProfile(null);
if (err) {
if (err.status === 401) {
this.message.send({ type: 'clear-user', data: {} })
this.message.send({ type: 'clear-user', data: {} });
if (this.user.isLogin) {
return
return;
}
this.message.send({ type: 'http-401', data: {} })
this.message.send({ type: 'http-401', data: {} });
}
return
return;
}
this.user.setUserProfile(data)
this.user.setUserProfile(data);
}
{
const [data, err]: any = await this.api.api_workspaceList({})
const [data, err]: any = await this.api.api_workspaceList({});
if (err) {
if (err.status === 401) {
this.message.send({ type: 'clear-user', data: {} })
this.message.send({ type: 'clear-user', data: {} });
if (this.user.isLogin) {
return
return;
}
this.message.send({ type: 'http-401', data: {} })
this.message.send({ type: 'http-401', data: {} });
}
return
return;
}
this.workspace.setWorkspaceList(data)
this.workspace.setWorkspaceList(data);
}
if (!data.isFirstLogin) {
return
return;
}
// * 唤起弹窗
this.isSyncModalVisible = true
this.isSyncModalVisible = true;
}
handleOpenSettingModalCancel(): void {
// * 关闭弹窗
this.isOpenSettingModalVisible = false
this.isOpenSettingModalVisible = false;
}
async textkmcrwvCallback() {
async ebfy6zcCallback() {
// * nzAfterClose event callback
{
}
}
async text4fn9sfCallback() {
// * click event callback
this.message.send({ type: 'open-setting', data: {} })
this.message.send({ type: 'open-setting', data: {} });
// * 关闭弹窗
this.isOpenSettingModalVisible = false
this.isOpenSettingModalVisible = false;
}
handleAddWorkspaceModalCancel(): void {
// * 关闭弹窗
this.isAddWorkspaceModalVisible = false
this.isAddWorkspaceModalVisible = false;
}
async ehr6ppmCallback() {
async etuv4keCallback() {
// * nzAfterClose event callback
this.inputWorkspaceNameValue = ''
{
// * auto clear form
this.inputWorkspaceNameValue = '';
}
}
async btn2op86eCallback() {
async btnua379iCallback() {
// * click event callback
// * 关闭弹窗
this.isAddWorkspaceModalVisible = false
this.inputWorkspaceNameValue = ''
this.isAddWorkspaceModalVisible = false;
}
async btnv0jv0tCallback() {
async btn539vb6Callback() {
// * click event callback
const title = this.inputWorkspaceNameValue
const title = this.inputWorkspaceNameValue;
{
const [data, err]: any = await this.api.api_workspaceCreate({ title })
const [data, err]: any = await this.api.api_workspaceCreate({ title });
if (err) {
if (err.status === 401) {
this.message.send({ type: 'clear-user', data: {} })
this.message.send({ type: 'clear-user', data: {} });
if (this.user.isLogin) {
return
return;
}
this.message.send({ type: 'http-401', data: {} })
this.message.send({ type: 'http-401', data: {} });
}
return
return;
}
}
this.eMessage.success($localize`Create new workspace successfully !`)
this.eMessage.success($localize`Create new workspace successfully !`);
// * 关闭弹窗
this.isAddWorkspaceModalVisible = false
this.isAddWorkspaceModalVisible = false;
this.inputWorkspaceNameValue = ''
{
const [data, err]: any = await this.api.api_workspaceList({})
const [data, err]: any = await this.api.api_workspaceList({});
if (err) {
if (err.status === 401) {
this.message.send({ type: 'clear-user', data: {} })
this.message.send({ type: 'clear-user', data: {} });
if (this.user.isLogin) {
return
return;
}
this.message.send({ type: 'http-401', data: {} })
this.message.send({ type: 'http-401', data: {} });
}
return
return;
}
this.workspace.setWorkspaceList(data)
this.workspace.setWorkspaceList(data);
}
}
}

View File

@ -1,4 +1,4 @@
import { NzModalService } from 'ng-zorro-antd/modal'
import { NzModalRef, NzModalService } from 'ng-zorro-antd/modal'
import { WorkspaceService } from 'eo/workbench/browser/src/app/shared/services/workspace/workspace.service'
import { EoMessageService } from 'eo/workbench/browser/src/app/eoui/message/eo-message.service'
import { UserService } from 'eo/workbench/browser/src/app/shared/services/user/user.service'
@ -48,7 +48,7 @@ import { Component, OnInit } from '@angular/core'
nz-button
class=""
nzType="primary"
(click)="btnof6jmpCallback()"
(click)="btnfx9imhCallback()"
i18n
>
Save
@ -68,7 +68,7 @@ import { Component, OnInit } from '@angular/core'
class=""
nzType="primary"
nzDanger
(click)="btnmisciqCallback()"
(click)="btnw960jpCallback()"
i18n
>
Delete
@ -102,7 +102,7 @@ export class WorkspaceComponent implements OnInit {
workspace: currentWsp
})
}
async btnof6jmpCallback() {
async btnfx9imhCallback() {
// * click event callback
const { id: currentWsp } = this.workspace.currentWorkspace
const { workspace: title } = this.validateWspNameForm.value
@ -136,7 +136,7 @@ export class WorkspaceComponent implements OnInit {
}
this.workspace.setWorkspaceList(list)
}
async btnmisciqCallback() {
async btnw960jpCallback() {
// * click event callback
const confirm = () =>

View File

@ -1,6 +1,6 @@
import { NgModule } from '@angular/core'
import { CommonModule } from '@angular/common'
import { NzModalService, NzModalModule } from 'ng-zorro-antd/modal'
import { NzModalRef, NzModalService, NzModalModule } from 'ng-zorro-antd/modal'
import { WorkspaceService } from 'eo/workbench/browser/src/app/shared/services/workspace/workspace.service'
import { EoMessageService } from 'eo/workbench/browser/src/app/eoui/message/eo-message.service'
import { UserService } from 'eo/workbench/browser/src/app/shared/services/user/user.service'

View File

@ -135,14 +135,11 @@ const addWorkspace = new Modal({
id: 'add-workspace',
title: { text: 'Add Workspace' },
children: [newWorkspaceName],
event: {
close: [newWorkspaceName.reset()],
},
footer: [
{
label: 'Cancel',
type: 'default',
click: [Modal.close('add-workspace'), newWorkspaceName.reset()],
click: [Modal.close('add-workspace')],
disabled: [],
},
{
@ -153,7 +150,6 @@ const addWorkspace = new Modal({
[httpS.send('api_workspaceCreate', '{ title }')],
messageS.success('Create new workspace successfully !'),
Modal.close('add-workspace'),
newWorkspaceName.reset(),
// * update workspace list
[httpS.send('api_workspaceList', '{}'), workspaceS.setWorkspaceList('data')],
],
@ -176,12 +172,24 @@ const login = new Modal({
}),
],
footer: [],
event: {
//!TODO modal control self statusno need to reset
close: [loginForm.reset()],
},
});
// const login = modalS.component({
// id: 'login',
// title: 'Sign In/Up',
// children: [
// messageS,
// userS,
// httpS,
// workspaceS,
// new EventS({}),
// new Canvas({
// class: ['my-3'],
// children: [loginForm],
// }),
// ],
// });
const checkConnect = new Modal({
id: 'check-connect',
title: { text: 'Check your connection' },
@ -329,6 +337,7 @@ export default new Component({
messageS,
eventS,
sync,
// modalS,
checkConnect,
login,
openSetting,