issue-7 #9
5
.gitignore
vendored
5
.gitignore
vendored
@ -27,8 +27,8 @@ replay_pid*
|
||||
# ---> JetBrains
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/
|
||||
# User-specific stff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
@ -50,6 +50,7 @@ replay_pid*
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
8
backend/.idea/.gitignore
vendored
8
backend/.idea/.gitignore
vendored
@ -1,8 +0,0 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
1658
backend/.idea/dataSources/777acb96-8451-4627-b14b-d635cd5e928a.xml
Normal file
1658
backend/.idea/dataSources/777acb96-8451-4627-b14b-d635cd5e928a.xml
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,2 @@
|
||||
#n:information_schema
|
||||
!<md> [null, 0, null, null, -2147483648, -2147483648]
|
@ -0,0 +1,2 @@
|
||||
#n:mysql
|
||||
!<md> [null, 0, null, null, -2147483648, -2147483648]
|
@ -0,0 +1,2 @@
|
||||
#n:performance_schema
|
||||
!<md> [null, 0, null, null, -2147483648, -2147483648]
|
@ -0,0 +1,2 @@
|
||||
#n:restservice
|
||||
!<md> [1695647618000, 0, null, null, -2147483648, -2147483648]
|
@ -1,3 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
|
@ -1,124 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
100
backend/.idea/workspace.xml
Normal file
100
backend/.idea/workspace.xml
Normal file
@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AutoImportSettings">
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="Structure Taskgroups in Hierarchies">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/../frontend/src/app/taskgroups/taskgroup-creation/taskgroup-creation.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/taskgroups/taskgroup-creation/taskgroup-creation.component.ts" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/../frontend/src/app/taskgroups/taskgroup-dashboard/taskgroup-dashboard.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/taskgroups/taskgroup-dashboard/taskgroup-dashboard.component.ts" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
|
||||
</component>
|
||||
<component name="ProjectColorInfo">{
|
||||
"customColor": "",
|
||||
"associatedIndex": 6
|
||||
}</component>
|
||||
<component name="ProjectId" id="2VtEzh5AmQfX7fTAeLmHDDS0AYv" />
|
||||
<component name="ProjectViewState">
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"RequestMappingsPanelOrder0": "0",
|
||||
"RequestMappingsPanelOrder1": "1",
|
||||
"RequestMappingsPanelWidth0": "75",
|
||||
"RequestMappingsPanelWidth1": "75",
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"WebServerToolWindowFactoryState": "false",
|
||||
"git-widget-placeholder": "issue-7",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
},
|
||||
"keyToStringList": {
|
||||
"DatabaseDriversLRU": [
|
||||
"mariadb"
|
||||
]
|
||||
}
|
||||
}</component>
|
||||
<component name="RunManager">
|
||||
<configuration name="DemoApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" nameIsGenerated="true">
|
||||
<module name="demo" />
|
||||
<option name="SPRING_BOOT_MAIN_CLASS" value="core.DemoApplication" />
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="Default task">
|
||||
<changelist id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="" />
|
||||
<created>1695647243767</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1695647243767</updated>
|
||||
<workItem from="1695647249321" duration="397000" />
|
||||
<workItem from="1696183811713" duration="4994000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Structure Taskgroups in Hierarchies">
|
||||
<option name="closed" value="true" />
|
||||
<created>1696188127465</created>
|
||||
<option name="number" value="00001" />
|
||||
<option name="presentableId" value="LOCAL-00001" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1696188127467</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="2" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
<option name="version" value="3" />
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="Structure Taskgroups in Hierarchies" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Structure Taskgroups in Hierarchies" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
<breakpoints>
|
||||
<line-breakpoint enabled="true" type="java-line">
|
||||
<url>file://$PROJECT_DIR$/src/main/java/core/services/TaskgroupService.java</url>
|
||||
<line>52</line>
|
||||
<option name="timeStamp" value="1" />
|
||||
</line-breakpoint>
|
||||
</breakpoints>
|
||||
</breakpoint-manager>
|
||||
</component>
|
||||
</project>
|
@ -1,2 +0,0 @@
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
|
||||
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
|
@ -10,11 +10,13 @@ import core.services.ServiceResult;
|
||||
import core.services.TaskgroupService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.scheduling.config.Task;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@CrossOrigin(origins = "*", maxAge = 3600)
|
||||
@RestController
|
||||
@ -74,8 +76,23 @@ public class TaskgroupController {
|
||||
|
||||
@GetMapping("/taskgroups")
|
||||
public ResponseEntity<List<TaskgroupEntityInfo>> listTaskgroupsOfUser() {
|
||||
List<Taskgroup> taskgroups = taskgroupService.getTaskgroupsByUser(SecurityContextHolder.getContext().getAuthentication().getName());
|
||||
List<Taskgroup> taskgroups = taskgroupService.getTopTaskgroupsByUser(SecurityContextHolder.getContext().getAuthentication().getName());
|
||||
List<TaskgroupEntityInfo> taskgroupEntityInfos = taskgroups.stream().map(TaskgroupEntityInfo::new).toList();
|
||||
return ResponseEntity.ok(taskgroupEntityInfos);
|
||||
}
|
||||
|
||||
@GetMapping("/taskgroups/{taskgroupID}")
|
||||
public ResponseEntity<?> getDetails(@PathVariable long taskgroupID) {
|
||||
PermissionResult<Taskgroup> taskgroupPermissionResult = taskgroupService.getTaskgroupByIDAndUsername(taskgroupID, SecurityContextHolder.getContext().getAuthentication().getName());
|
||||
if(!taskgroupPermissionResult.isHasPermissions()) {
|
||||
return ResponseEntity.status(403).body(new SimpleStatusResponse("failed"));
|
||||
}
|
||||
|
||||
if(taskgroupPermissionResult.getExitCode() == ServiceExitCode.MISSING_ENTITY) {
|
||||
return ResponseEntity.status(404).body(new SimpleStatusResponse("failed"));
|
||||
}
|
||||
|
||||
Set<Taskgroup> children = taskgroupPermissionResult.getResult().getChildren();
|
||||
return ResponseEntity.ok(children.stream().map(TaskgroupEntityInfo::new));
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,17 @@ public class TaskgroupEntityInfo {
|
||||
private long taskgroupID;
|
||||
private String taskgroupName;
|
||||
|
||||
private TaskgroupEntityInfo parentTaskgroup;
|
||||
|
||||
public TaskgroupEntityInfo(Taskgroup taskgroup) {
|
||||
this.taskgroupID = taskgroup.getTaskgroupID();
|
||||
this.taskgroupName = taskgroup.getTaskgroupName();
|
||||
|
||||
if(taskgroup.getParent() == null) {
|
||||
this.parentTaskgroup = null;
|
||||
} else {
|
||||
this.parentTaskgroup = new TaskgroupEntityInfo(taskgroup.getParent());
|
||||
}
|
||||
}
|
||||
|
||||
public long getTaskgroupID() {
|
||||
@ -27,4 +35,12 @@ public class TaskgroupEntityInfo {
|
||||
public void setTaskgroupName(String taskgroupName) {
|
||||
this.taskgroupName = taskgroupName;
|
||||
}
|
||||
|
||||
public TaskgroupEntityInfo getParentTaskgroup() {
|
||||
return parentTaskgroup;
|
||||
}
|
||||
|
||||
public void setParentTaskgroup(TaskgroupEntityInfo parentTaskgroup) {
|
||||
this.parentTaskgroup = parentTaskgroup;
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,8 @@ public class TaskgroupFieldInfo {
|
||||
@Length(max = 255)
|
||||
private String name;
|
||||
|
||||
private long parentID;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@ -20,4 +22,12 @@ public class TaskgroupFieldInfo {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public long getParentID() {
|
||||
return parentID;
|
||||
}
|
||||
|
||||
public void setParentID(long parentID) {
|
||||
this.parentID = parentID;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import core.entities.User;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.Set;
|
||||
|
||||
@Entity
|
||||
@Table(name= "taskgroups")
|
||||
@ -21,6 +22,13 @@ public class Taskgroup {
|
||||
@JoinColumn(name = "taskgroupuser", nullable = false)
|
||||
private User user;
|
||||
|
||||
@OneToMany(mappedBy = "parent", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
private Set<Taskgroup> children;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "parent_id")
|
||||
private Taskgroup parent;
|
||||
|
||||
public Taskgroup(String taskgroupName, User user) {
|
||||
this.taskgroupName = taskgroupName;
|
||||
this.user = user;
|
||||
@ -52,4 +60,20 @@ public class Taskgroup {
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public Set<Taskgroup> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(Set<Taskgroup> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public Taskgroup getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void setParent(Taskgroup parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,9 @@ public interface TaskgroupRepository extends CrudRepository<Taskgroup, Long> {
|
||||
@Query("SELECT tg FROM Taskgroup tg WHERE tg.user.username = ?1")
|
||||
List<Taskgroup> findAllByUser(String username);
|
||||
|
||||
@Query("SELECT tg FROM Taskgroup tg WHERE tg.user.username = ?1 AND tg.parent IS NULL")
|
||||
List<Taskgroup> findAllTopTaskgroupsByUser(String username);
|
||||
|
||||
@Modifying
|
||||
@Transactional
|
||||
void deleteAllByUser(User user);
|
||||
|
@ -40,8 +40,20 @@ public class TaskgroupService {
|
||||
}
|
||||
|
||||
if(!taskgroupRepository.existsByTaskgroupNameAndUser(taskData.getName(), user.get())) {
|
||||
Taskgroup taskgroup;
|
||||
if(taskData.getParentID() < 0) {
|
||||
taskgroup = new Taskgroup(taskData.getName(), user.get());
|
||||
} else {
|
||||
Optional<Taskgroup> parentTaskgroup = taskgroupRepository.findById(taskData.getParentID());
|
||||
if(parentTaskgroup.isEmpty()) {
|
||||
return new ServiceResult<>(ServiceExitCode.MISSING_ENTITY);
|
||||
} else {
|
||||
taskgroup = new Taskgroup(taskData.getName(), user.get());
|
||||
taskgroup.setParent(parentTaskgroup.get());
|
||||
parentTaskgroup.get().getChildren().add(taskgroup);
|
||||
}
|
||||
}
|
||||
|
||||
Taskgroup taskgroup = new Taskgroup(taskData.getName(), user.get());
|
||||
taskgroupRepository.save(taskgroup);
|
||||
return new ServiceResult<>(taskgroup);
|
||||
} else {
|
||||
@ -72,6 +84,10 @@ public class TaskgroupService {
|
||||
return taskgroupRepository.findAllByUser(username);
|
||||
}
|
||||
|
||||
public List<Taskgroup> getTopTaskgroupsByUser(String username) {
|
||||
return taskgroupRepository.findAllTopTaskgroupsByUser(username);
|
||||
}
|
||||
|
||||
public void deleteTaskgroupByUser(User user) {
|
||||
taskgroupRepository.deleteAllByUser(user);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
spring.datasource.url=jdbc:mariadb://127.0.0.1:3306/restservice?createDatabaseIfNotExist=true&autoReconnect=true
|
||||
spring.datasource.url=jdbc:mariadb://127.0.0.1:3306/timemanager?createDatabaseIfNotExist=true&autoReconnect=true
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=edkvcjReDxJ9Z8hq
|
||||
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
|
||||
|
@ -94,6 +94,61 @@ export class TaskgroupService {
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public taskgroupsAllGet(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<Array<TaskgroupEntityInfo>>;
|
||||
public taskgroupsAllGet(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpResponse<Array<TaskgroupEntityInfo>>>;
|
||||
public taskgroupsAllGet(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpEvent<Array<TaskgroupEntityInfo>>>;
|
||||
public taskgroupsAllGet(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<any> {
|
||||
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
|
||||
let localVarCredential: string | undefined;
|
||||
// authentication (API_TOKEN) required
|
||||
localVarCredential = this.configuration.lookupCredential('API_TOKEN');
|
||||
if (localVarCredential) {
|
||||
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
|
||||
}
|
||||
|
||||
let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
|
||||
if (localVarHttpHeaderAcceptSelected === undefined) {
|
||||
// to determine the Accept header
|
||||
const httpHeaderAccepts: string[] = [
|
||||
'application/json'
|
||||
];
|
||||
localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
}
|
||||
if (localVarHttpHeaderAcceptSelected !== undefined) {
|
||||
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
let localVarHttpContext: HttpContext | undefined = options && options.context;
|
||||
if (localVarHttpContext === undefined) {
|
||||
localVarHttpContext = new HttpContext();
|
||||
}
|
||||
|
||||
|
||||
let responseType_: 'text' | 'json' = 'json';
|
||||
if(localVarHttpHeaderAcceptSelected && localVarHttpHeaderAcceptSelected.startsWith('text')) {
|
||||
responseType_ = 'text';
|
||||
}
|
||||
|
||||
return this.httpClient.get<Array<TaskgroupEntityInfo>>(`${this.configuration.basePath}/taskgroups/all`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
responseType: <any>responseType_,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
headers: localVarHeaders,
|
||||
observe: observe,
|
||||
reportProgress: reportProgress
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* list all top level taskgroups of authorized user
|
||||
* list all taskgroups of authorized user
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public taskgroupsGet(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<Array<TaskgroupEntityInfo>>;
|
||||
public taskgroupsGet(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpResponse<Array<TaskgroupEntityInfo>>>;
|
||||
public taskgroupsGet(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpEvent<Array<TaskgroupEntityInfo>>>;
|
||||
@ -268,6 +323,65 @@ export class TaskgroupService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* get details of an existing taskgroup
|
||||
* get details of an existing taskgroup
|
||||
* @param taskgroupID internal id of taskgroup
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public taskgroupsTaskgroupIDGet(taskgroupID: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<Array<TaskgroupEntityInfo>>;
|
||||
public taskgroupsTaskgroupIDGet(taskgroupID: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpResponse<Array<TaskgroupEntityInfo>>>;
|
||||
public taskgroupsTaskgroupIDGet(taskgroupID: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpEvent<Array<TaskgroupEntityInfo>>>;
|
||||
public taskgroupsTaskgroupIDGet(taskgroupID: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<any> {
|
||||
if (taskgroupID === null || taskgroupID === undefined) {
|
||||
throw new Error('Required parameter taskgroupID was null or undefined when calling taskgroupsTaskgroupIDGet.');
|
||||
}
|
||||
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
|
||||
let localVarCredential: string | undefined;
|
||||
// authentication (API_TOKEN) required
|
||||
localVarCredential = this.configuration.lookupCredential('API_TOKEN');
|
||||
if (localVarCredential) {
|
||||
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
|
||||
}
|
||||
|
||||
let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
|
||||
if (localVarHttpHeaderAcceptSelected === undefined) {
|
||||
// to determine the Accept header
|
||||
const httpHeaderAccepts: string[] = [
|
||||
'application/json'
|
||||
];
|
||||
localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
}
|
||||
if (localVarHttpHeaderAcceptSelected !== undefined) {
|
||||
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
let localVarHttpContext: HttpContext | undefined = options && options.context;
|
||||
if (localVarHttpContext === undefined) {
|
||||
localVarHttpContext = new HttpContext();
|
||||
}
|
||||
|
||||
|
||||
let responseType_: 'text' | 'json' = 'json';
|
||||
if(localVarHttpHeaderAcceptSelected && localVarHttpHeaderAcceptSelected.startsWith('text')) {
|
||||
responseType_ = 'text';
|
||||
}
|
||||
|
||||
return this.httpClient.get<Array<TaskgroupEntityInfo>>(`${this.configuration.basePath}/taskgroups/${encodeURIComponent(String(taskgroupID))}`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
responseType: <any>responseType_,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
headers: localVarHeaders,
|
||||
observe: observe,
|
||||
reportProgress: reportProgress
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* edits taskgroup
|
||||
* edits taskgroup
|
||||
|
@ -20,5 +20,6 @@ export interface TaskgroupEntityInfo {
|
||||
* name of taskgroup
|
||||
*/
|
||||
taskgroupName: string;
|
||||
parentTaskgroup: TaskgroupEntityInfo;
|
||||
}
|
||||
|
||||
|
@ -16,5 +16,9 @@ export interface TaskgroupFieldInfo {
|
||||
* name of taskgroup
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* internal id of parent Taskgroup
|
||||
*/
|
||||
parentID: number;
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,8 @@ const routes: Routes = [
|
||||
{path: '', component: MainComponent},
|
||||
{path: 'admin', component: AdminDashboardComponent},
|
||||
{path: 'user/settings', component: UserSettingsComponent},
|
||||
{path: 'taskgroups', component: TaskgroupDashboardComponent}
|
||||
{path: 'taskgroups', component: TaskgroupDashboardComponent},
|
||||
{path: 'taskgroups/:taskgroupID', component: TaskgroupDashboardComponent}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
@ -0,0 +1,6 @@
|
||||
import {TaskgroupEntityInfo} from "../../../api";
|
||||
|
||||
export interface TaskgroupCreationData {
|
||||
taskgroup: TaskgroupEntityInfo | undefined,
|
||||
taskgroupID: number
|
||||
}
|
@ -4,6 +4,8 @@ import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
|
||||
import {TaskgroupEntityInfo, TaskgroupService} from "../../../api";
|
||||
import {error} from "@angular/compiler/src/util";
|
||||
import {MatSnackBar} from "@angular/material/snack-bar";
|
||||
import {ActivatedRoute} from "@angular/router";
|
||||
import {TaskgroupCreationData} from "./TaskgroupCreationData";
|
||||
|
||||
@Component({
|
||||
selector: 'app-taskgroup-creation',
|
||||
@ -18,11 +20,11 @@ export class TaskgroupCreationComponent implements OnInit {
|
||||
constructor(private dialogRef: MatDialogRef<TaskgroupCreationComponent>,
|
||||
private taskgroupService: TaskgroupService,
|
||||
private snackbar: MatSnackBar,
|
||||
@Inject(MAT_DIALOG_DATA) public data: TaskgroupEntityInfo | undefined) { }
|
||||
@Inject(MAT_DIALOG_DATA) public data: TaskgroupCreationData) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
if(this.data != undefined) {
|
||||
this.nameCtrl.setValue(this.data!.taskgroupName)
|
||||
if(this.data.taskgroup != undefined) {
|
||||
this.nameCtrl.setValue(this.data.taskgroup!.taskgroupName)
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,9 +34,10 @@ export class TaskgroupCreationComponent implements OnInit {
|
||||
|
||||
save() {
|
||||
this.pending = true;
|
||||
if(this.data == undefined) {
|
||||
if(this.data.taskgroup == undefined) {
|
||||
this.taskgroupService.taskgroupsPut({
|
||||
name: this.nameCtrl.value
|
||||
name: this.nameCtrl.value,
|
||||
parentID: this.data.taskgroupID,
|
||||
}).subscribe({
|
||||
next: resp => {
|
||||
this.pending = false;
|
||||
@ -50,12 +53,13 @@ export class TaskgroupCreationComponent implements OnInit {
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.taskgroupService.taskgroupsTaskgroupIDPost(this.data.taskgroupID, {
|
||||
name: this.nameCtrl.value
|
||||
this.taskgroupService.taskgroupsTaskgroupIDPost(this.data.taskgroup!.taskgroupID, {
|
||||
name: this.nameCtrl.value,
|
||||
parentID: this.data.taskgroupID
|
||||
}).subscribe({
|
||||
next: resp => {
|
||||
this.pending = false;
|
||||
this.data!.taskgroupName = this.nameCtrl.value
|
||||
this.data.taskgroup!.taskgroupName = this.nameCtrl.value
|
||||
this.dialogRef.close(true);
|
||||
},
|
||||
error: err => {
|
||||
|
@ -9,7 +9,7 @@
|
||||
<mat-card *ngFor="let taskgroup of taskgroups">
|
||||
<mat-card-content>
|
||||
<h1>{{taskgroup.taskgroupName}}</h1>
|
||||
<button mat-raised-button color="primary">Detail</button>
|
||||
<button mat-raised-button color="primary" [routerLink]="['/taskgroups', taskgroup.taskgroupID]">Detail</button>
|
||||
<button mat-raised-button class="edit-btn" (click)="openTaskgroupEditor(taskgroup)">Rename</button>
|
||||
<button mat-raised-button color="warn" (click)="openTaskgroupDeletion(taskgroup)">Delete</button>
|
||||
</mat-card-content>
|
||||
|
@ -3,6 +3,7 @@ import {MatDialog} from "@angular/material/dialog";
|
||||
import {TaskgroupCreationComponent} from "../taskgroup-creation/taskgroup-creation.component";
|
||||
import {TaskgroupEntityInfo, TaskgroupService} from "../../../api";
|
||||
import {TaskgroupDeletionComponent} from "../taskgroup-deletion/taskgroup-deletion.component";
|
||||
import {ActivatedRoute} from "@angular/router";
|
||||
|
||||
@Component({
|
||||
selector: 'app-taskgroup-dashboard',
|
||||
@ -12,20 +13,34 @@ import {TaskgroupDeletionComponent} from "../taskgroup-deletion/taskgroup-deleti
|
||||
export class TaskgroupDashboardComponent implements OnInit {
|
||||
|
||||
constructor(private dialog: MatDialog,
|
||||
private taskgroupService: TaskgroupService) { }
|
||||
private taskgroupService: TaskgroupService,
|
||||
private activatedRoute: ActivatedRoute) { }
|
||||
|
||||
taskgroups: TaskgroupEntityInfo[] = []
|
||||
taskgroupID: number = -1;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.taskgroupService.taskgroupsGet().subscribe({
|
||||
next: resp => {
|
||||
this.taskgroups = resp;
|
||||
this.activatedRoute.paramMap.subscribe(params => {
|
||||
if(params.has('taskgroupID')) {
|
||||
this.taskgroupID = Number(params.get('taskgroupID'));
|
||||
this.taskgroupService.taskgroupsTaskgroupIDGet(this.taskgroupID).subscribe({
|
||||
next: resp => {
|
||||
this.taskgroups = resp
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.taskgroupService.taskgroupsGet().subscribe({
|
||||
next: resp => {
|
||||
this.taskgroups = resp;
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
openTaskgroupCreation() {
|
||||
const dialogRef = this.dialog.open(TaskgroupCreationComponent, {minWidth: "400px"})
|
||||
const dialogRef = this.dialog.open(TaskgroupCreationComponent, {data: {taskgroup: undefined, taskgroupID: this.taskgroupID}, minWidth: "400px"})
|
||||
dialogRef.afterClosed().subscribe(res => {
|
||||
if(res != undefined) {
|
||||
this.taskgroups.push(res);
|
||||
@ -34,7 +49,7 @@ export class TaskgroupDashboardComponent implements OnInit {
|
||||
}
|
||||
|
||||
openTaskgroupEditor(taskgroup: TaskgroupEntityInfo) {
|
||||
const dialogRef = this.dialog.open(TaskgroupCreationComponent, {data: taskgroup, minWidth: "400px"});
|
||||
const dialogRef = this.dialog.open(TaskgroupCreationComponent, {data: {taskgroup: taskgroup, taskgroupID: this.taskgroupID}, minWidth: "400px"});
|
||||
dialogRef.afterClosed().subscribe(res => {
|
||||
if(res) {
|
||||
const data = this.taskgroups
|
||||
|
83
openapi.yaml
83
openapi.yaml
@ -564,7 +564,7 @@ paths:
|
||||
example: "failed"
|
||||
enum:
|
||||
- "failed"
|
||||
/taskgroups:
|
||||
/taskgroups/all:
|
||||
get:
|
||||
security:
|
||||
- API_TOKEN: []
|
||||
@ -581,6 +581,23 @@ paths:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/TaskgroupEntityInfo'
|
||||
/taskgroups:
|
||||
get:
|
||||
security:
|
||||
- API_TOKEN: []
|
||||
tags:
|
||||
- taskgroup
|
||||
summary: list all top level taskgroups of authorized user
|
||||
description: list all taskgroups of authorized user
|
||||
responses:
|
||||
200:
|
||||
description: Anfrage erfolgreich
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/TaskgroupEntityInfo'
|
||||
put:
|
||||
security:
|
||||
- API_TOKEN: []
|
||||
@ -616,6 +633,60 @@ paths:
|
||||
enum:
|
||||
- "failed"
|
||||
/taskgroups/{taskgroupID}:
|
||||
get:
|
||||
security:
|
||||
- API_TOKEN: []
|
||||
tags:
|
||||
- taskgroup
|
||||
summary: get details of an existing taskgroup
|
||||
description: get details of an existing taskgroup
|
||||
parameters:
|
||||
- name: taskgroupID
|
||||
in: path
|
||||
description: internal id of taskgroup
|
||||
required: true
|
||||
schema:
|
||||
type: number
|
||||
example: 1
|
||||
responses:
|
||||
200:
|
||||
description: Anfrage erfolgreich
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/TaskgroupEntityInfo'
|
||||
403:
|
||||
description: No permission
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
type: object
|
||||
required:
|
||||
- status
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
description: Status
|
||||
example: "failed"
|
||||
enum:
|
||||
- "failed"
|
||||
404:
|
||||
description: Taskgroup does not exist
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
type: object
|
||||
required:
|
||||
- status
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
description: Status
|
||||
example: "failed"
|
||||
enum:
|
||||
- "failed"
|
||||
post:
|
||||
security:
|
||||
- API_TOKEN: []
|
||||
@ -948,6 +1019,7 @@ components:
|
||||
required:
|
||||
- taskgroupID
|
||||
- taskgroupName
|
||||
- parentTaskgroup
|
||||
additionalProperties: false
|
||||
properties:
|
||||
taskgroupID:
|
||||
@ -960,9 +1032,13 @@ components:
|
||||
example: Taskgroup 1
|
||||
maxLength: 255
|
||||
minLength: 1
|
||||
parentTaskgroup:
|
||||
type: object
|
||||
$ref: '#/components/schemas/TaskgroupEntityInfo'
|
||||
TaskgroupFieldInfo:
|
||||
required:
|
||||
- name
|
||||
- parentID
|
||||
additionalProperties: false
|
||||
properties:
|
||||
name:
|
||||
@ -971,3 +1047,8 @@ components:
|
||||
example: Taskgroup 1
|
||||
maxLength: 255
|
||||
minLength: 1
|
||||
parentID:
|
||||
type: number
|
||||
description: internal id of parent Taskgroup
|
||||
example: 1
|
||||
|
Loading…
Reference in New Issue
Block a user