Skip to content

Commit

Permalink
#296 Dashboard creation dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoraboeuf committed Jan 30, 2014
1 parent 6676e3a commit 61de022
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ public ImportResult importCheck(String uuid) {
);
}

@Override
public List<BranchSummary> getBranchAll() {
return list(getDefaultLocale(), "/ui/manage/branch", BranchSummary.class);
}

@Override
public List<BranchSummary> getBranchList(String project) {
return list(getDefaultLocale(), format("/ui/manage/project/%s/branch", project), BranchSummary.class);
Expand Down
2 changes: 2 additions & 0 deletions ontrack-core/src/main/java/net/ontrack/core/ui/ManageUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public interface ManageUI {

// Branches

List<BranchSummary> getBranchAll();

List<BranchSummary> getBranchList(String project);

List<BranchLastStatus> getBranchLastStatusList(Locale locale, String project);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,17 @@ ImportResult importCheck(@PathVariable String uuid) {
return exportService.importCheck(uuid);
}

@Override
@RequestMapping(value = "/ui/manage/branch", method = RequestMethod.GET)
@ResponseBody
public List<BranchSummary> getBranchAll() {
List<BranchSummary> branches = new ArrayList<>();
for (ProjectSummary project : getProjectList()) {
branches.addAll(managementService.getBranchList(project.getId()));
}
return branches;
}

@Override
@RequestMapping(value = "/ui/manage/project/{project:[A-Za-z0-9_\\.\\-]+}/validation-stamp-mgt", method = RequestMethod.POST)
public
Expand Down
4 changes: 4 additions & 0 deletions ontrack-web/src/main/resources/META-INF/strings/web.ls
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,10 @@ dashboard.custom
en -> Custom dashboard
fr -> Dashboard personnalisé
dashboard.custom.branches
en -> Selected branches
fr -> Branches sélectionnées
[acl]
acl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<@layout_std
page="dashboard-custom"
style=true
title=loc('dashboard.custom.list')
breadcrumbs = {
loc("home"): ""
Expand Down
7 changes: 7 additions & 0 deletions ontrack-web/src/main/webapp/static/css/dashboard-custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.dashboard-custom-dialog-branch.dashboard-custom-branch-selected {
background-color: #ffff00 !important;
}

.dashboard-custom-dialog-branch {
cursor: pointer;
}
67 changes: 53 additions & 14 deletions ontrack-web/src/main/webapp/static/js/app/dashboard-custom.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,65 @@
define(['jquery','ajax','dialog','dynamic'], function ($, ajax, dialog, dynamic) {
define(['jquery', 'ajax', 'dialog', 'dynamic'], function ($, ajax, dialog, dynamic) {

// Dashboard creation
function createDashboard() {
dialog.show({
title: 'dashboard.custom'.loc(),
templateId: 'dashboard-custom-dialog',
submitFn: function (config) {
ajax.post({
url: 'ui/manage/dashboard',
function createDashboard(btn) {
ajax.get({
url: 'ui/manage/branch',
loading: {
el: $(btn)
},
successFn: function (branches) {
dialog.show({
title: 'dashboard.custom'.loc(),
templateId: 'dashboard-custom-dialog',
data: {
name: $('#dashboard-custom-name').val()
branches: branches
},
successFn: function () {
config.closeFn();
dynamic.reloadSection('dashboard-custom');
initFn: function (config) {
config.form.find('.dashboard-custom-dialog-branch').each(function (i, tr) {
var branchId = $(tr).attr('id');
// TODO Initial state
// TODO Checks for authz
// Selection of branches
$(tr).click(function () {
$(tr).data('branch-selected', !$(tr).data('branch-selected'));
if ($(tr).data('branch-selected')) {
$(tr).addClass('dashboard-custom-branch-selected');
} else {
$(tr).removeClass('dashboard-custom-branch-selected');
}
})
})
},
errorFn: ajax.simpleAjaxErrorFn(config.errorFn)
submitFn: function (config) {
// Selected branches
var branches = [];
config.form.find('.dashboard-custom-dialog-branch').each(function (i, tr) {
var branchId = $(tr).attr('id');
if ($(tr).data('branch-selected')) {
branches.push(branchId);
}
});
// Posting the creation
ajax.post({
url: 'ui/manage/dashboard',
data: {
name: $('#dashboard-custom-name').val(),
branches: branches
},
successFn: function () {
config.closeFn();
dynamic.reloadSection('dashboard-custom');
},
errorFn: ajax.simpleAjaxErrorFn(config.errorFn)
});
}
});
}
});
}

$('#dashboard-custom-create').click(createDashboard);
$('#dashboard-custom-create').click(function () {
createDashboard(this);
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,23 @@
<input type="text" id="dashboard-custom-name" value="" size="40" maxlength="80" required="required" />
</div>
</div>
<div class="control-group">
<label class="control-label">{{loc 'dashboard.custom.branches'}}</label>
</div>
<div class="control-group">
<table class="table table-condensed table-hover">
<tbody>
{{#branches}}
<tr class="dashboard-custom-dialog-branch" id="{{id}}">
<td>
{{project.name}}
</td>
<td>
{{name}}
</td>
</tr>
{{/branches}}
</tbody>
</table>
</div>
</form>

0 comments on commit 61de022

Please sign in to comment.