diff --git a/.gitignore b/.gitignore index 5d889f542ad1b6de7093a00bd316a0e421d049f5..7a4b14b17f6c684d9bb8d343f5523e66c3157453 100644 --- a/.gitignore +++ b/.gitignore @@ -350,6 +350,6 @@ Sessionx.vim .netrwhist *~ # Auto-generated tag files -tags +# tags # Persistent undo [._]*.un~ diff --git a/NodeApp/src/commander/tags/TagCommand.ts b/NodeApp/src/commander/tags/TagCommand.ts new file mode 100644 index 0000000000000000000000000000000000000000..28bf1d24672fecaa366119a9c71e87c5f5425c23 --- /dev/null +++ b/NodeApp/src/commander/tags/TagCommand.ts @@ -0,0 +1,30 @@ +import CommanderCommand from '../CommanderCommand'; +import TagAdd from './subcommands/TagAdd'; +import TagDelete from './subcommands/TagDelete'; +import TagGetPropose from './subcommands/TagGetPropose'; +import TagPostPropose from './subcommands/TagPostPropose'; +import TagAnswerPropose from './subcommands/TagAnswerPropose'; + + + +class AddTagCommand extends CommanderCommand { + protected commandName: string = 'tag'; + + protected defineCommand() { + this.command + .description('Manages tags'); + } + + protected defineSubCommands() { + TagAdd.registerOnCommand(this.command); + TagDelete.registerOnCommand(this.command); + TagGetPropose.registerOnCommand(this.command); + TagPostPropose.registerOnCommand(this.command); + TagAnswerPropose.registerOnCommand(this.command); + } + + protected async commandAction(): Promise<void> { } +} + + +export default new AddTagCommand(); \ No newline at end of file diff --git a/NodeApp/src/commander/tags/subcommands/TagAdd.ts b/NodeApp/src/commander/tags/subcommands/TagAdd.ts new file mode 100644 index 0000000000000000000000000000000000000000..904a357de6f03f2357b8778a15ee5a5867d81b5b --- /dev/null +++ b/NodeApp/src/commander/tags/subcommands/TagAdd.ts @@ -0,0 +1,33 @@ +import CommanderCommand from '../../CommanderCommand'; +import SessionManager from '../../../managers/SessionManager'; +import DojoBackendManager from "../../../managers/DojoBackendManager"; +import Tags from '../../../sharedByClients/models/Tag'; + + +class TagAddCommand extends CommanderCommand { + protected commandName: string = 'add'; + + protected defineCommand() { + this.command + .description('Add a tag') + .argument('<tagName>', 'name of the tag') //test + .argument('<tagType>', 'type of the tag') + .action(this.commandAction.bind(this)); + } + + protected async commandAction(name : string, type: string): Promise<void> { + let tag : Tags | undefined; + { + if ( !await SessionManager.testSession(true, null) ) { + return; + } + tag = await DojoBackendManager.addTag(name, type); + if ( !tag ) { + return; + } + } + } + +} + +export default new TagAddCommand(); \ No newline at end of file diff --git a/NodeApp/src/commander/tags/subcommands/TagAnswerPropose.ts b/NodeApp/src/commander/tags/subcommands/TagAnswerPropose.ts new file mode 100644 index 0000000000000000000000000000000000000000..b7b9178cdea0ad07f9251c571ff0309175cd84bb --- /dev/null +++ b/NodeApp/src/commander/tags/subcommands/TagAnswerPropose.ts @@ -0,0 +1,35 @@ +import CommanderCommand from '../../CommanderCommand'; +import SessionManager from '../../../managers/SessionManager'; +import TagSubmit from '../../../sharedByClients/models/TagSubmit'; +import DojoBackendManager from "../../../managers/DojoBackendManager"; + + +class TagAnswerProposeCommand extends CommanderCommand { + protected commandName: string = 'answer'; + + protected defineCommand() { + this.command + .description('Answer to a tag proposition') + .argument('<tagProposalName>', 'name of the tag') + .argument('<tagType>', 'name of the tag') + .argument('<tagState>', 'name of the tag') + .argument('<tagDetail>', 'name of the tag') + .action(this.commandAction.bind(this)); + } + + protected async commandAction(tagProposalName: string, type: string, state: string, detail: string): Promise<void> { + let tag : TagSubmit | undefined; + { + if ( !await SessionManager.testSession(true, null) ) { + return; + } + tag = await DojoBackendManager.answerProposeTag(tagProposalName, type, state, detail); + if ( !tag ) { + return; + } + } + } + +} + +export default new TagAnswerProposeCommand(); \ No newline at end of file diff --git a/NodeApp/src/commander/tags/subcommands/TagDelete.ts b/NodeApp/src/commander/tags/subcommands/TagDelete.ts new file mode 100644 index 0000000000000000000000000000000000000000..4490eacd2a552b8aba0fd2bb2a9753e4271a012e --- /dev/null +++ b/NodeApp/src/commander/tags/subcommands/TagDelete.ts @@ -0,0 +1,33 @@ +import CommanderCommand from '../../CommanderCommand'; +import SessionManager from '../../../managers/SessionManager'; +import DojoBackendManager from "../../../managers/DojoBackendManager"; +import Tags from "../../../sharedByClients/models/Tag"; + + +class TagDeleteCommand extends CommanderCommand { + protected commandName: string = 'delete'; + + protected defineCommand() { + this.command + .description('Delete a tag') + .argument('<tagName>', 'name of the tag') + .action(this.commandAction.bind(this)); + } + + protected async commandAction(name : string): Promise<void> { + let tag : Tags; + { + if ( !await SessionManager.testSession(true, null) ) { + return; + } + + tag = await DojoBackendManager.deleteTag(name); + if ( !tag ) { + return; + } + } + } + +} + +export default new TagDeleteCommand(); \ No newline at end of file diff --git a/NodeApp/src/commander/tags/subcommands/TagGetPropose.ts b/NodeApp/src/commander/tags/subcommands/TagGetPropose.ts new file mode 100644 index 0000000000000000000000000000000000000000..3ce3665f546e05c64359bb3d3c853d5a8618fe38 --- /dev/null +++ b/NodeApp/src/commander/tags/subcommands/TagGetPropose.ts @@ -0,0 +1,36 @@ +import CommanderCommand from '../../CommanderCommand'; +import SessionManager from '../../../managers/SessionManager'; +import TagSubmit from '../../../sharedByClients/models/TagSubmit'; +import DojoBackendManager from "../../../managers/DojoBackendManager"; + + +class TagGetProposeCommand extends CommanderCommand { + protected commandName: string = 'get-propose'; + + protected defineCommand() { + this.command + .description('Get a tag proposition') + .argument('<stateTag>', 'state of the tags') + .action(this.commandAction.bind(this)); + } + + protected async commandAction(state : string): Promise<void> { + let tag : TagSubmit | undefined; + if(state == null){ + state = "PendingApproval"; + } + { + if ( !await SessionManager.testSession(true, null) ) { + return; + } + + tag = await DojoBackendManager.getProposeTag(state); + if ( !tag ) { + return; + } + } + } + +} + +export default new TagGetProposeCommand(); \ No newline at end of file diff --git a/NodeApp/src/commander/tags/subcommands/TagPostPropose.ts b/NodeApp/src/commander/tags/subcommands/TagPostPropose.ts new file mode 100644 index 0000000000000000000000000000000000000000..985148566dd2dd8464e6cf290c35117523a4fe65 --- /dev/null +++ b/NodeApp/src/commander/tags/subcommands/TagPostPropose.ts @@ -0,0 +1,33 @@ +import CommanderCommand from '../../CommanderCommand'; +import SessionManager from '../../../managers/SessionManager'; +import DojoBackendManager from "../../../managers/DojoBackendManager"; +import TagSubmit from '../../../sharedByClients/models/TagSubmit'; + +class TagPostProposeCommand extends CommanderCommand { + protected commandName: string = 'post-propose'; + + protected defineCommand() { + this.command + .description('Propose a tag') + .argument('<tagName>', 'name of the tag') + .argument('<tagType>', 'type of the tag') + .action(this.commandAction.bind(this)); + } + + protected async commandAction(name : string, type: string): Promise<void> { + let tag : TagSubmit | undefined; + { + if ( !await SessionManager.testSession(true, null) ) { + return; + } + + tag = await DojoBackendManager.postProposeTag(name, type); + if ( !tag ) { + return; + } + } + } + +} + +export default new TagPostProposeCommand(); \ No newline at end of file