Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rsiminel committed Dec 18, 2024
1 parent 7e419b8 commit fb0bac6
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 68 deletions.
132 changes: 75 additions & 57 deletions manager2/src/app/admin/group/group.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,70 +6,88 @@ import { User } from "../../user/user.service";
import { Table } from "primeng/table";

@Component({
selector: "app-groups",
templateUrl: "./group.component.html",
// styleUrls: ['./group.component.css']
selector: "app-groups",
templateUrl: "./group.component.html"
// styleUrls: ['./group.component.css']
})
export class GroupComponent implements OnInit {
@ViewChild("dtg") tableGroups: Table;
@ViewChild("dtu") tableUsers: Table;
@ViewChild("dtg") tableGroups: Table;
@ViewChild("dtu") tableUsers: Table;

msg: string;
err_msg: string;
del_err_msg: string;
group: Group;
projects: Project[];
users: User[];
msg: string;
err_msg: string;
del_err_msg: string;
group: Group;
projects: Project[];
users: User[];

constructor(
private route: ActivatedRoute,
private router: Router,
private groupsService: GroupsService,
private projectsService: ProjectsService
) {
this.group = new Group();
this.projects = null;
this.users = null;
}
constructor(
private route: ActivatedRoute,
private router: Router,
private groupsService: GroupsService,
private projectsService: ProjectsService
) {
this.group = new Group();
this.projects = null;
this.users = null;
}

ngOnDestroy(): void {}
ngOnDestroy(): void {}

ngAfterViewInit(): void {}
ngAfterViewInit(): void {}

ngOnInit() {
this.route.params.subscribe((params) => {
let group_name = params.id;
this.groupsService.get(group_name).subscribe(
(resp) => (this.group = resp),
(err) => console.log("failed to get group")
);
this.projectsService.getProjectsInGroup(group_name).subscribe(
(resp) => (this.projects = resp),
(err) => console.log("failed to get projects in group")
);
this.groupsService.getUsers(group_name).subscribe(
(resp) => (this.users = resp),
(err) => console.log("failed to get group's users")
);
});
}
ngOnInit() {
this.deleteGroup = this.deleteGroup.bind(this);
this.route.params.subscribe((params) => {
let group_name = params.id;
this.groupsService.get(group_name).subscribe(
(group) => (this.group = group),
(err) => console.log("failed to get group")
);
this.projectsService.getProjectsInGroup(group_name).subscribe(
(project_list) => (this.projects = project_list),
(err) => console.log("failed to get projects in group")
);
this.groupsService.getUsers(group_name).subscribe(
(user_list) => {
this.users = user_list;
for (var i = 0; i < user_list.length; i++) {
var is_authorized = false;
if (user_list[i].projects) {
for (var j = 0; j < this.projects.length; j++) {
if (user_list[i].projects.indexOf(this.projects[j].id) >= 0) {
is_authorized = true;
break;
}
}
}
this.users[i].temp = {
...this.users[i].temp,
authorized: is_authorized
};
}
},
(err) => console.log("failed to get group's users")
);
});
}

deleteGroup() {
this.groupsService.delete(this.group.name).subscribe(
(resp) =>
this.router.navigate(["/admin/group"], {
queryParams: { deleted: "ok" },
}),
(err) => (this.del_err_msg = err.error.message)
);
}
deleteGroup() {
this.groupsService.delete(this.group.name).subscribe(
(resp) =>
this.router.navigate(["/admin/group"], {
queryParams: { deleted: "ok" }
}),
(err) => (this.del_err_msg = err.error.message)
);
}

updateGroup() {
this.msg = "";
this.err_msg = "";
this.groupsService.update(this.group).subscribe(
(resp) => (this.msg = "Group updated"),
(err) => (this.err_msg = err.error.message)
);
}
updateGroup() {
this.msg = "";
this.err_msg = "";
this.groupsService.update(this.group).subscribe(
(resp) => (this.msg = "Group updated"),
(err) => (this.err_msg = err.error.message)
);
}
}
13 changes: 5 additions & 8 deletions manager2/src/app/admin/groups/groups.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Component, OnInit, ViewChild } from '@angular/core';
import { Group, GroupsService } from './groups.service';
import { ActivatedRoute } from '@angular/router';
import { User } from '../../user/user.service';

import { Table } from 'primeng/table';

@Component({
Expand Down Expand Up @@ -42,18 +41,16 @@ export class GroupsComponent implements OnInit {
ngOnInit() {
this.route.queryParams
.subscribe(params => {
if (params.deleted == "ok") {
this.notification = "Project was deleted successfully";
if (params.deleted == 'ok') {
this.notification = 'Group was deleted successfully';
};
});
this.listGroups();
}

addGroup(){
this.notification = "";
if (this.new_group.name === '') {
return;
}
addGroup() {
this.notification = '';
if (this.new_group.name === '') { return; }
this.err_msg = '';
this.success_msg = '';
this.groupsService.add(this.new_group).subscribe(
Expand Down
6 changes: 3 additions & 3 deletions manager2/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { RegisterComponent } from './auth/register/register.component';
import { LogoutComponent } from './auth/logout/logout.component';
import { TpsComponent } from './tps/tps.component';
import { ProjectComponent } from './project/project.component';
import { DatabasesComponent as AdminDatabaseComponent} from './admin/databases/databases.component';
import { GroupsComponent as AdminGroupsComponent} from './admin/groups/groups.component';
import { GroupComponent as AdminGroupComponent} from './admin/group/group.component';
import { DatabasesComponent as AdminDatabaseComponent } from './admin/databases/databases.component';
import { GroupsComponent as AdminGroupsComponent } from './admin/groups/groups.component';
import { GroupComponent as AdminGroupComponent } from './admin/group/group.component';
import { LogsComponent as AdminLogComponent} from './admin/logs/logs.component';
import { MessagesComponent as AdminMessageComponent} from './admin/messages/messages.component';
import { ProjectsComponent as AdminProjectsComponent} from './admin/projects/projects.component';
Expand Down

0 comments on commit fb0bac6

Please sign in to comment.