Skip to content

Commit

Permalink
Merge pull request #44 from oneops/master
Browse files Browse the repository at this point in the history
pulling changes
  • Loading branch information
okornev committed Dec 21, 2017
2 parents 98a0793 + 5eb9d28 commit 5989aa1
Show file tree
Hide file tree
Showing 46 changed files with 299 additions and 102 deletions.
2 changes: 1 addition & 1 deletion adapter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.oneops</groupId>
<artifactId>oneops-parent</artifactId>
<version>17.11.01-16-SNAPSHOT</version>
<version>17.11.01-18-SNAPSHOT</version>
</parent>
<groupId>com.oneops.cms</groupId>
<artifactId>adapter</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,21 @@ public List<CmsDeployment> findDeployment(
@RequestParam(value="deploymentState", required = false) String state,
@RequestParam(value="latest", required = false) Boolean latest,
@RequestParam(value="recursive", required = false) Boolean recursive,
@RequestParam(value="start", required = false) Long start,
@RequestParam(value="end", required = false) Long end,
@RequestHeader(value="X-Cms-Scope", required = false) String scope){

if (latest == null) latest = false;

List<CmsDeployment> dpmtList = null;

if (nsPath != null) {
dpmtList = djManager.findDeployment(nsPath, state, recursive, latest);
if (start != null || end != null) {
dpmtList = djManager.findDeploymentsByTimePeriod(nsPath, recursive, start == null ? null : new Date(start), end == null ? null : new Date(end));
}
else {
dpmtList = djManager.findDeployment(nsPath, state, recursive, latest);
}
} else if (releaseId != null) {
dpmtList = djManager.findDeploymentByReleaseId(releaseId, state, latest);
}
Expand Down
2 changes: 1 addition & 1 deletion amq-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.oneops</groupId>
<artifactId>oneops-parent</artifactId>
<version>17.11.01-16-SNAPSHOT</version>
<version>17.11.01-18-SNAPSHOT</version>
</parent>
<groupId>com.oneops</groupId>
<artifactId>amqplugin</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion antenna/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.oneops</groupId>
<artifactId>oneops-parent</artifactId>
<version>17.11.01-16-SNAPSHOT</version>
<version>17.11.01-18-SNAPSHOT</version>
</parent>
<groupId>com.oneops</groupId>
<artifactId>antenna</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion batch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.oneops</groupId>
<artifactId>oneops-parent</artifactId>
<version>17.11.01-16-SNAPSHOT</version>
<version>17.11.01-18-SNAPSHOT</version>
</parent>
<groupId>com.oneops</groupId>
<artifactId>batch</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion cms-admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.oneops</groupId>
<artifactId>oneops-parent</artifactId>
<version>17.11.01-16-SNAPSHOT</version>
<version>17.11.01-18-SNAPSHOT</version>
</parent>
<groupId>com.oneops</groupId>
<artifactId>cms-admin</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion cmsdal/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.oneops</groupId>
<artifactId>oneops-parent</artifactId>
<version>17.11.01-16-SNAPSHOT</version>
<version>17.11.01-18-SNAPSHOT</version>
</parent>
<groupId>com.oneops.cms</groupId>
<artifactId>cmsdal</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public interface DJDpmtMapper {
CmsDeployment getDeploymentSimple(long deploymentId);
List<CmsDeployment> findDeployment(@Param("nsPath") String nsPath,@Param("state") String state);
List<CmsDeployment> findDeploymentRecursive(@Param("ns") String ns, @Param("nsLike") String nsLike, @Param("state") String state);
List<CmsDeployment> findDeploymentsByTimePeriod(@Param("ns") String ns, @Param("nsLike") String nsLike, @Param("start") Date start, @Param("end") Date end);
List<CmsDeployment> findLatestDeployment(@Param("nsPath") String nsPath,@Param("state") String state);
List<CmsDeployment> findLatestDeploymentRecursive(@Param("ns") String ns, @Param("nsLike") String nsLike, @Param("state") String state);
List<CmsDeployment> findDeploymentByReleaseId(@Param("releaseId") long releaseId, @Param("state") String state);
Expand Down
32 changes: 31 additions & 1 deletion cmsdal/src/main/java/com/oneops/cms/dj/dal/DJDpmtMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,39 @@
and (#{state}::varchar is null or ds.state_name = #{state})
</select>

<select id="findDeploymentsByTimePeriod" parameterType="map" useCache="false" resultType="com.oneops.cms.dj.domain.CmsDeployment">
SELECT d.deployment_id as deploymentId,
d.release_id as releaseId,
ns.ns_path as nsPath,
d.created_by as createdBy,
d.updated_by as updatedBy,
d.description,
d.comments,
d.flags,
d.ops,
ds.state_name as deploymentState,
d.process_id as processId,
d.created,
d.updated
from dj_deployment d, ns_namespaces ns, dj_deployment_states ds
where d.ns_id = ns.ns_id
and d.state_id = ds.state_id
and (ns.ns_path = #{ns}
<if test="nsLike != null">
or ns.ns_path like #{nsLike}
</if>)
<if test="start != null">
and d.created >= #{start}
</if>
<if test="end != null">
and d.created &lt;= #{end}
</if>
order by d.created
</select>

<select id="findLatestDeployment" parameterType="map" useCache="false" resultType="com.oneops.cms.dj.domain.CmsDeployment">
SELECT d.deployment_id as deploymentId,
d.release_id as releaseId,
d.release_id as releaseId,
ns.ns_path as nsPath,
ds.state_name as deploymentState,
d.created_by as createdBy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public interface CmsDjManager {
CmsDpmtApproval getDeploymentApproval(long approvalId);

List<CmsDeployment> findDeployment(String nsPath, String state, Boolean recursive, boolean latest);
List<CmsDeployment> findDeploymentsByTimePeriod(String nsPath, Boolean recursive, Date start, Date end);
long countDeployments(String nsPath, String state, Boolean recursive);
Map<String, Long> countDeploymentGroupByNsPath(String nsPath, String state);
List<CmsDeployment> findDeploymentByReleaseId(long releaseId, String state, boolean latest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,10 @@ public List<CmsDeployment> findDeployment(String nsPath, String state, Boolean r
}
}


public List<CmsDeployment> findDeploymentsByTimePeriod(String nsPath, Boolean recursive, Date start, Date end) {
return dpmtProcessor.findDeploymentsByTimePeriod(nsPath, recursive, start, end);
}

/* (non-Javadoc)
* @see com.oneops.cms.dj.service.CmsDjManager#countDeployments(java.lang.String, java.lang.String, java.lang.Boolean)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -767,15 +767,31 @@ public List<CmsDeployment> findLatestDeployment(String nsPath, String state, Boo
}
}


/**
* Count deployment.
* Returns a list of deployments for a given namespace and time period.
*
* @param nsPath the ns path
* @param state the state
* @param recursive the recursive
* @return the long
* @param nsPath namespace
* @param recursive find deployments recursively for a given nsPath
* @param start start timestamp
* @param end end timestamp
* @return list of deployments
*/
public List<CmsDeployment> findDeploymentsByTimePeriod(String nsPath, Boolean recursive, Date start, Date end) {
String nsLike = null;
if (recursive != null && recursive) {
nsLike = CmsUtil.likefyNsPath(nsPath);
}
return dpmtMapper.findDeploymentsByTimePeriod(nsPath, nsLike, start, end);
}

/**
* Count deployment.
*
* @param nsPath the ns path
* @param state the state
* @param recursive the recursive
* @return the long
*/
public long countDeployment(String nsPath, String state, Boolean recursive) {
if (recursive != null && recursive) {
String nsLike = CmsUtil.likefyNsPath(nsPath);
Expand Down
2 changes: 1 addition & 1 deletion controller/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.oneops</groupId>
<artifactId>oneops-parent</artifactId>
<version>17.11.01-16-SNAPSHOT</version>
<version>17.11.01-18-SNAPSHOT</version>
</parent>
<groupId>com.oneops</groupId>
<artifactId>controller</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion daq/daq-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<artifactId>daq-parent</artifactId>

<relativePath>../pom.xml</relativePath>
<version>17.11.01-16-SNAPSHOT</version>
<version>17.11.01-18-SNAPSHOT</version>
</parent>
<groupId>com.oneops</groupId>
<artifactId>daq-api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion daq/daq-collector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<artifactId>daq-parent</artifactId>

<relativePath>../pom.xml</relativePath>
<version>17.11.01-16-SNAPSHOT</version></parent>
<version>17.11.01-18-SNAPSHOT</version></parent>
<groupId>com.oneops</groupId>
<artifactId>daq-collector</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion daq/daq-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<artifactId>daq-parent</artifactId>

<relativePath>../pom.xml</relativePath>
<version>17.11.01-16-SNAPSHOT</version></parent>
<version>17.11.01-18-SNAPSHOT</version></parent>
<groupId>com.oneops</groupId>
<artifactId>daq-common</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion daq/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.oneops</groupId>
<artifactId>oneops-parent</artifactId>
<version>17.11.01-16-SNAPSHOT</version>
<version>17.11.01-18-SNAPSHOT</version>
</parent>
<groupId>com.oneops</groupId>
<artifactId>daq-parent</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion db-schema/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.oneops</groupId>
<artifactId>oneops-parent</artifactId>
<version>17.11.01-16-SNAPSHOT</version>
<version>17.11.01-18-SNAPSHOT</version>
</parent>
<groupId>com.oneops</groupId>
<artifactId>db-schema</artifactId>
Expand Down
13 changes: 2 additions & 11 deletions display/app/assets/stylesheets/layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -3613,19 +3613,10 @@ div.modal-body .comment {
width: calc(100% - 20px);
}

/*div.modal-footer {
padding: 20px;
text-align: center;
}
div.modal-footer .btn {
margin: 0 10px 0 10px;
div.modal-footer .dropdown-menu {
text-align: left;
}

div.modal-footer table {
margin: 0 auto;
}*/

div.edit-form-controls {
text-align: right;
margin-right: 5px;
Expand Down
34 changes: 22 additions & 12 deletions display/app/controllers/assemblies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,31 +189,39 @@ def new_clone
end

def clone
ci = nil
errors = nil
ci = {:ciName => params[:ciName], :ciAttributes => {:description => params[:description]}}
export = params[:export]
if export.present?
action = 'save'
ci[:nsPath] = private_catalog_designs_ns_path
ci[:ciClassName] = 'account.Design'
ci = Cms::Ci.build(:ciName => params[:ciName],
:nsPath => private_catalog_designs_ns_path,
:ciClassName => 'account.Design',
:ciAttributes => {:description => params[:description]})
else
action = 'clone'
org_name = params[:to_org].presence || current_user.organization.name
org = current_user.organizations.where('organizations.name = ?', org_name).first
team = current_user.manages_access?(org.id)
if org && team
ci[:nsPath] = organization_ns_path(org.name)
ci[:ciClassName] = 'account.Assembly'
ci[:ciAttributes][:owner] = @assembly.ciAttributes.owner
ci = Cms::Ci.build(:ciName => params[:ciName],
:nsPath => organization_ns_path(org.name),
:ciClassName => 'account.Assembly',
:ciAttributes => {:description => params[:description],
:owner => current_user.email.presence || @assembly.ciAttributes.owner})
else
errors = ["No permission to create assembly in organization '#{org_name}'."]
end
end

if ci
ci.valid?
errors = ci.errors.full_messages
end
if errors.blank?
ci_id, message = Transistor.clone_assembly(@assembly.ciId, ci)
if ci_id
Cms::Ci.headers['X-Cms-Scope'] = ci[:nsPath] if action == 'clone'
Cms::Ci.headers['X-Cms-Scope'] = ci.nsPath if action == 'clone'
@new_ci = Cms::Ci.find(ci_id)
if export.blank? && !is_admin?(org)
current_user.update_attribute(:organization_id, org.id)
Expand Down Expand Up @@ -243,14 +251,15 @@ def users
end

aggregator = lambda do |h, u|
h[u.id] ||= {:user => u, :dto => Team::DTO_NONE, :teams => {}}
h[u.id] ||= {:user => u, :dto => Team::DTO_NONE, :manages_access => false, :teams => {}}
h[u.id][:dto] |= Team.calculate_dto_permissions(u.design, u.transition, u.operations) if h[u.id][:dto] < Team::DTO_ALL
h[u.id][:manages_access] ||= u.manages_access
h[u.id][:teams][u.team] = true
h
end

org_id = org.id
select = 'users.*, teams.name as team, teams.design as design, teams.transition as transition, teams.operations as operations'
select = 'users.*, teams.name as team, teams.design as design, teams.transition as transition, teams.operations as operations, teams.manages_access as manages_access'

where = {'teams.organization_id' => org_id, 'teams.org_scope' => true}
users = User.joins(:teams).select(select).where(where).inject(users, &aggregator)
Expand All @@ -269,6 +278,7 @@ def users
:name => user.name,
:created_at => user.created_at,
:last_sign_in_at => user.current_sign_in_at || user.last_sign_in_at,
:manages_access => r[:manages_access],
:design => dto & Team::DTO_DESIGN > 0,
:transition => dto & Team::DTO_TRANSITION > 0,
:operations => dto & Team::DTO_OPERATIONS > 0,
Expand All @@ -280,8 +290,8 @@ def users
format.js

format.csv do
fields = [:id, :username, :email, :name, :created_at, :last_sign_in_at, :design, :transition, :operations, :teams]
data = users.map do |u|
fields = [:id, :username, :email, :name, :created_at, :last_sign_in_at, :manages_access, :design, :transition, :operations, :teams]
data = @users.map do |u|
fields.map do |f|
value = u[f]
value.is_a?(Array) ? value.join(' ') : value
Expand All @@ -290,7 +300,7 @@ def users
render :text => fields.join(',') + "\n" + data.join("\n") #, :content_type => 'text/data_string'
end

format.yaml {render :text => users.to_yaml, :content_type => 'text/data_string'}
format.yaml {render :text => @users.to_yaml, :content_type => 'text/data_string'}

format.any {render :json => users}
end
Expand Down
Loading

0 comments on commit 5989aa1

Please sign in to comment.