From 0442e5e1dd95a931d5967ffa7f102ec6da8f3099 Mon Sep 17 00:00:00 2001
From: "vincent.steinman" <vincent.steinmann@etu.hesge.ch>
Date: Mon, 10 Jun 2024 15:36:04 +0200
Subject: [PATCH] remove tag from gitignore

---
 .gitignore                                    |  2 +-
 NodeApp/src/commander/tags/TagCommand.ts      | 30 ++++++++++++++++
 .../src/commander/tags/subcommands/TagAdd.ts  | 33 +++++++++++++++++
 .../tags/subcommands/TagAnswerPropose.ts      | 35 ++++++++++++++++++
 .../commander/tags/subcommands/TagDelete.ts   | 33 +++++++++++++++++
 .../tags/subcommands/TagGetPropose.ts         | 36 +++++++++++++++++++
 .../tags/subcommands/TagPostPropose.ts        | 33 +++++++++++++++++
 7 files changed, 201 insertions(+), 1 deletion(-)
 create mode 100644 NodeApp/src/commander/tags/TagCommand.ts
 create mode 100644 NodeApp/src/commander/tags/subcommands/TagAdd.ts
 create mode 100644 NodeApp/src/commander/tags/subcommands/TagAnswerPropose.ts
 create mode 100644 NodeApp/src/commander/tags/subcommands/TagDelete.ts
 create mode 100644 NodeApp/src/commander/tags/subcommands/TagGetPropose.ts
 create mode 100644 NodeApp/src/commander/tags/subcommands/TagPostPropose.ts

diff --git a/.gitignore b/.gitignore
index 5d889f5..7a4b14b 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 0000000..28bf1d2
--- /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 0000000..904a357
--- /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 0000000..b7b9178
--- /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 0000000..4490eac
--- /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 0000000..3ce3665
--- /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 0000000..9851485
--- /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
-- 
GitLab