Skip to content

Commit 3daa9b1

Browse files
Merge pull request #109 from seqcode/danying
bug fixes and feature enhancements closes #107 #106 #105 #60 #104 #103 #99 #97 #64
2 parents 286858b + bdb2e18 commit 3daa9b1

40 files changed

Lines changed: 1200 additions & 211 deletions

pegr/grails-app/assets/javascripts/pegr.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function createSelect(tr, classname, data) {
6767
elem.hide();
6868
td.find("select").select2({
6969
data: data,
70-
placeholder: tagPlaceholder,
70+
placeholder: "Select or type",
7171
tags: true
7272
});
7373
}

pegr/grails-app/assets/stylesheets/pegr.css

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ div.spacer
1919
margin-bottom: 15px;
2020
border-style: none;
2121
border-radius: 0;
22-
background-color: #bf8226;
22+
background-color: #0077c2;
2323
z-index: +200;
2424
}
2525

2626
.navbar-brand {
2727
padding: 7px 0;
28-
background-color: #bf8226;//#496799;
28+
background-color: #0077c2;
2929
}
3030

3131
.affix {
@@ -204,6 +204,12 @@ div.spacer
204204
background-color: #1E407C;
205205
}
206206

207+
.edit:hover, .edit:active, .edit:focus {
208+
text-decoration: none;
209+
color: #f6f6f6;
210+
background-color: #467ad2;
211+
}
212+
207213
.subnumber OL {
208214
counter-reset: item;
209215
padding-left: 10px;

pegr/grails-app/conf/Config.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ log4j = {
138138

139139
root {
140140
warn 'stdout', 'stacktrace'
141-
debug 'stacktrace'
142141
additivity = true
143142
}
144143
}
@@ -203,6 +202,9 @@ grails.plugin.springsecurity.interceptUrlMap = [
203202
'/sequenceRun/upload/**': ['ROLE_ADMIN'],
204203
'/sequenceRun/updateQueue/**': ['ROLE_ADMIN'],
205204
'/sequenceRun/convertCsv/**': ['ROLE_ADMIN'],
205+
'/sequenceRun/continueCsv/**': ['ROLE_ADMIN'],
206+
'/sequenceRun/convertXlsx/**': ['ROLE_ADMIN'],
207+
'/sequenceRun/continueXlsx/**': ['ROLE_ADMIN'],
206208
'/sequenceRun/create/**': ['ROLE_ADMIN'],
207209
'/sequenceRun/save/**': ['ROLE_ADMIN'],
208210
'/sequenceRun/**': ['ROLE_MEMBER', 'ROLE_ADMIN'],

pegr/grails-app/conf/DataSource.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ hibernate {
3535
environments {
3636
development {
3737
dataSource {
38-
dbCreate = "" // one of 'create', 'create-drop', 'update', 'validate', ''
38+
dbCreate = "none" // one of 'create', 'create-drop', 'update', 'validate', ''
3939
url = ""
4040
username=""
4141
password=""

pegr/grails-app/conf/pegr/SecurityFilters.groovy

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,37 @@ class SecurityFilters {
2929
}
3030
}
3131

32+
/**
33+
* The current user must be the owner of all the merged from and merged to projects or the admin
34+
*/
35+
projectMerge(controller:'project', action:'showChecked|merge') {
36+
before = {
37+
def currUser = springSecurityService.currentUser
38+
def auth = true
39+
if (!currUser.isAdmin() && session.checkedProject) {
40+
def projects = session.checkedProject
41+
if (params.projectName) {
42+
def mergeToProject = Project.where {name == params.projectName}.get(max:1)
43+
if (mergeToProject) {
44+
projects.push(mergeToProject.id)
45+
}
46+
}
47+
48+
projects.each { projectId ->
49+
def projectUser = ProjectUser.where {project.id == projectId && user.id == currUser.id}.find()
50+
if (!projectUser || projectUser.projectRole != ProjectRole.OWNER) {
51+
auth = false
52+
}
53+
}
54+
}
55+
if (auth == false) {
56+
session.checkedProject = null
57+
render(view: '/login/denied')
58+
}
59+
return auth
60+
}
61+
}
62+
3263
/*
3364
* The authorization to view a summary report is the same as
3465
* that of viewing the project that the report belongs to.

pegr/grails-app/controllers/pegr/ProjectController.groovy

Lines changed: 140 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,15 @@ class ProjectController {
1313
def currentUser = springSecurityService.currentUser
1414

1515
// query the user's the projects
16+
if (!params.sort) {
17+
params.sort = "dateCreated"
18+
params.order = "desc"
19+
}
1620
def c = ProjectUser.createCriteria()
1721
def projects = c.list(max: max, offset: offset) {
1822
eq("user", currentUser)
1923
project {
20-
order("dateCreated", "desc")
24+
order(params.sort, params.order)
2125
}
2226
}.collect{it.project}
2327
// get the total count of projects linked to the user
@@ -205,7 +209,7 @@ class ProjectController {
205209
render "success"
206210
}
207211

208-
def search(String str) {
212+
def search(String str, String merge) {
209213
def c = Project.createCriteria()
210214
def listParams = [
211215
max: params.max ?: 25,
@@ -219,9 +223,132 @@ class ProjectController {
219223
ilike "description", "%${str}%"
220224
}
221225
}
222-
[projects: projects, totalCount: projects.totalCount, str: str]
226+
if (merge == "Merge") {
227+
def checkedCount = 0;
228+
if (session.checkedProject) {
229+
checkedCount = session.checkedProject.size()
230+
}
231+
render(view: "mergeSelect", model: [totalCount: projects.totalCount, projects: projects, str: str, checkedCount: checkedCount])
232+
} else {
233+
[projects: projects, totalCount: projects.totalCount, str: str]
234+
}
235+
}
236+
237+
def merge(UserRoleListCommand cmd) {
238+
if (session.checkedProject) {
239+
try {
240+
def mergeToProjectId = projectService.mergeProjects(cmd.projectName, session.checkedProject, cmd.userRoles)
241+
session.checkedProject = null
242+
flash.message = "Success!"
243+
redirect(action: "show", id: mergeToProjectId)
244+
} catch (Exception e) {
245+
flash.message = e.message
246+
redirect(action: "showChecked")
247+
}
248+
} else {
249+
flash.message = "No projects selected to merge from!"
250+
redirect(action: "all")
251+
}
252+
}
253+
254+
def cancelMerge() {
255+
if (session.checkedProject) {
256+
session.checkedProject = null
257+
}
258+
redirect(action: "all")
259+
}
260+
261+
def clearCheckedProjectAjax(){
262+
if (session.checkedProject) {
263+
session.checkedProject = null
264+
}
265+
render true
266+
}
267+
268+
def addCheckedProjectAjax(Long id) {
269+
if (!session.checkedProject) {
270+
session.checkedProject = []
271+
}
272+
if (!(id in session.checkedProject)) {
273+
session.checkedProject << id
274+
}
275+
render session.checkedProject.size()
276+
}
277+
278+
def removeCheckedProjectAjax(Long id) {
279+
if (id in session.checkedProject) {
280+
session.checkedProject.remove(id)
281+
}
282+
render session.checkedProject.size()
283+
}
284+
285+
def showChecked(){
286+
def projects = []
287+
if (session.checkedProject) {
288+
session.checkedProject.each {
289+
def project = Project.get(it)
290+
if (project) {
291+
projects.push(Project.get(it))
292+
}
293+
}
294+
}
295+
if (projects.size() == 0) {
296+
flash.message = "No projects to merge!"
297+
redirect(action: "all")
298+
}
299+
300+
[projects: projects]
223301
}
224302

303+
def confirmUsersInMergedProject(String projectName) {
304+
def projects = []
305+
def mergeFromProjects = []
306+
if (session.checkedProject) {
307+
session.checkedProject.each {
308+
def project = Project.get(it)
309+
if (project) {
310+
mergeFromProjects.push(Project.get(it))
311+
}
312+
}
313+
}
314+
if (mergeFromProjects.size() == 0) {
315+
flash.message = "No projects to merge!"
316+
redirect(action: "all")
317+
}
318+
319+
// add mergeToProject
320+
def mergeToProject = Project.where {name == projectName}.get(max:1)
321+
if (mergeToProject && !projects.contains(mergeToProject)) {
322+
projects = [mergeFromProjects, mergeToProject]
323+
} else {
324+
projects = mergeFromProjects
325+
}
326+
327+
def projectUsers = []
328+
projects.each { p ->
329+
def oldProjectUsers = ProjectUser.where {project == p}.list()
330+
if (oldProjectUsers && oldProjectUsers.size() > 0) {
331+
oldProjectUsers.each { pu ->
332+
if (!projectUsers.collect { it.user }.contains(pu.user)) {
333+
projectUsers.push(pu)
334+
}
335+
}
336+
}
337+
}
338+
339+
// add current user
340+
def currUser = springSecurityService.currentUser
341+
if (!projectUsers.collect { it.user }.contains(currUser)) {
342+
projectUsers.push(new ProjectUser(user:currUser,
343+
projectRole: ProjectRole.OWNER))
344+
}
345+
[projectName: projectName, mergeFromProjects: mergeFromProjects, projectUsers: projectUsers, mergeToProject: mergeToProject]
346+
}
347+
348+
def updateCohortNotesAjax(Long cohortId, String notes) {
349+
projectService.updateCohortNotes(cohortId, notes)
350+
render notes
351+
}
225352
}
226353

227354

@@ -272,4 +399,14 @@ class SampleListCommand {
272399
Long assayId
273400
Long projectId
274401
List<SampleCommand> samples = [].withLazyDefault { new SampleCommand() }
402+
}
403+
404+
class UserRoleCommand {
405+
Long userId
406+
String role
407+
}
408+
409+
class UserRoleListCommand {
410+
String projectName
411+
List<UserRoleCommand> userRoles = [].withLazyDefault { new UserRoleCommand() }
275412
}

pegr/grails-app/controllers/pegr/SampleController.groovy

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class SampleController {
129129
redirect(action: "edit", params: [sampleId: sampleId])
130130
} catch(SampleException e) {
131131
flash.message = e.message
132-
redirect(action: "editProtocol", params: [sampleId: sampleId])
132+
redirect(action: "editTarget", params: [sampleId: sampleId])
133133
}
134134
} else {
135135
render(view: "/404")
@@ -169,12 +169,20 @@ class SampleController {
169169
[antibody: cmd, item: item, sampleId: sampleId, antibodyId: antibodyId, itemTypeOptions: itemTypeOptions]
170170
}
171171

172-
def updateAntibody(Long sampleId, Long antibodyId, AntibodyCommand cmd, Item item) {
172+
def updateAntibody(Long sampleId, Long antibodyId, AntibodyCommand cmd, Item item, String ifUpdateItem) {
173173
try {
174174
if (antibodyId) {
175-
antibodyService.update(cmd, item)
175+
if (ifUpdateItem == "yes") {
176+
antibodyService.update(cmd, item)
177+
} else {
178+
antibodyService.update(cmd)
179+
}
176180
} else {
177-
antibodyService.saveInSample(sampleId, cmd, item)
181+
if (ifUpdateItem == "yes") {
182+
antibodyService.saveInSample(sampleId, cmd, item)
183+
} else {
184+
antibodyService.saveInSample(sampleId, cmd)
185+
}
178186
}
179187
flash.message = "Antibody update!"
180188
redirect(action: "edit", params: [sampleId: sampleId])
@@ -246,20 +254,27 @@ class SampleController {
246254
[cellSource: cmd, item: item, sampleId: sampleId, cellSourceId: cellSourceId, itemTypeOptions: itemTypeOptions]
247255
}
248256

249-
def updateCellSource(Long sampleId, Long cellSourceId, CellSourceCommand cmd, Item item) {
257+
def updateCellSource(Long sampleId, Long cellSourceId, CellSourceCommand cmd, Item item, String ifUpdateItem) {
250258
try {
251259
if (cellSourceId) {
252-
cellSourceService.update(cmd, item)
260+
if (ifUpdateItem == "yes") {
261+
cellSourceService.update(cmd, item)
262+
} else {
263+
cellSourceService.update(cmd)
264+
}
253265
} else {
254-
cellSourceService.saveInSample(sampleId, cmd, item)
266+
if (ifUpdateItem == "yes") {
267+
cellSourceService.saveInSample(sampleId, cmd, item)
268+
} else {
269+
cellSourceService.saveInSample(sampleId, cmd)
270+
}
255271
}
256-
itemService.updateCustomizedFields(item, params)
257272
flash.message = "Cell source information updated!"
258-
redirect(action:"edit", params:[sampleId: sampleId])
273+
redirect(action:"edit", params:[sampleId: sampleId])
259274
} catch (CellSourceException e) {
260275
flash.message = e.message
261276
redirect(action: "editCellSource", params: [sampleId: sampleId, cellSourceId: cellSourceId])
262-
}
277+
}
263278
}
264279

265280
def searchCellSource(Long sampleId) {
@@ -325,14 +340,14 @@ class SampleController {
325340
}
326341

327342
def searchForm() {
328-
def galaxy = Holders.config.defaultGalaxy
343+
def galaxy = Holders.config.defaultGalaxy
329344
[defaultGalaxy: galaxy]
330345
}
331346

332347
def search(QuerySampleRegistrationCommand cmd) {
333348
// cmd.max = cmd.max ?: 15
334349
def samples = sampleService.search(cmd)
335-
def galaxy = Holders.config.defaultGalaxy
350+
def galaxy = Holders.config.defaultGalaxy
336351

337352
def checkedCount = 0;
338353
if (session.checkedSample) {

0 commit comments

Comments
 (0)