Revamp interface

This commit is contained in:
Wedge 2016-05-04 18:49:30 +03:00
parent 7dc0a74348
commit 9f825906f4
15 changed files with 223 additions and 265 deletions

View File

@ -1,11 +1,11 @@
RosaABF.controller('BuildListsController', ['$scope', 'BuildListsService', '$location', '$interval', '$uibModal', 'ProjectSelectService',
function($scope, BuildListsService, $location, $interval, $uibModal, ProjectSelectService) {
RosaABF.controller('BuildListsController', ['$scope', 'BuildListsService', '$location', '$interval', '$uibModal',
function($scope, BuildListsService, $location, $interval, $uibModal) {
$scope.params = null;
$scope.build_lists = [];
$scope.isRequest = false; // Disable 'Search' button
$scope.opened = {};
$scope.ProjectSelectService = ProjectSelectService;
var selectedProject = "";
var refresh, is_autoreload_on;
var default_filters = {page: '1', per_page: '25', 'ownership': 'owned'};
@ -23,17 +23,20 @@ function($scope, BuildListsService, $location, $interval, $uibModal, ProjectSele
}
}
$scope.getBuildLists = function() {
$scope.getBuildLists = function(project) {
if ($scope.isRequest) {
return;
}
ProjectSelectService.disable_bl = true;
$scope.isRequest = true;
if(ProjectSelectService.project) {
var project = ProjectSelectService.project;
if(selectedProject) {
project = selectedProject;
}
else {
selectedProject = project;
}
$scope.widgetTitle = project;
$scope.isRequest = true;
var filter = Object.assign(Object.create(null), default_filters, $location.search());
var fixed_filter = Object.create(null);
@ -66,15 +69,9 @@ function($scope, BuildListsService, $location, $interval, $uibModal, ProjectSele
$location.search(Object.assign(filter, res.filter));
$scope.per_page = filter.per_page;
$scope.isRequest = false;
ProjectSelectService.disable_bl = false;
ProjectSelectService.load_project_info = ProjectSelectService.project;
});
}
$scope.clearProject = function() {
ProjectSelectService.project = "";
}
$scope.showRelated = function(build_list) {
build_list.relatedHidden = false;
$scope.opened[build_list.id] = true;
@ -129,28 +126,6 @@ function($scope, BuildListsService, $location, $interval, $uibModal, ProjectSele
}
$scope.setAutoreload(true);
var project_hash = $location.search();
if(project_hash['project']) {
ProjectSelectService.project = project_hash['project'];
$location.search('project', null);
}
$scope.$watch(function() {
return ProjectSelectService.project;
}, function() {
var turn_back_on = is_autoreload_on;
if(ProjectSelectService.project) {
$scope.widget_title = " | " + ProjectSelectService.project;
}
else {
$scope.widget_title = "";
}
$scope.setAutoreload(false);
$scope.getBuildLists();
$scope.setAutoreload(turn_back_on);
});
}]);
RosaABF.controller('FiltersInstanceController', ['$scope', '$uibModalInstance', 'params',

View File

@ -7,6 +7,24 @@ RosaABF.controller('RosaABFController', ['$scope', 'LocalesHelper', 'SoundNotifi
//moment.locale(locale);
SoundNotificationsHelper.enabled(sound_notifications);
$timeout(function() { $scope.hideAlerts = true; }, 5000);
console.log($scope);
}
var mobileView = 992;
$scope.getWidth = function() {
return window.innerWidth;
};
$scope.$watch($scope.getWidth, function(newValue, oldValue) {
if (newValue >= mobileView) {
$scope.toggle = true;
}
else {
$scope.toggle = false;
}
});
$scope.toggleSidebar = function() {
$scope.toggle = !$scope.toggle;
};
}]);

View File

@ -3,7 +3,7 @@ class HomeController < ApplicationController
skip_after_action :verify_authorized
def index
redirect_to projects_dashboard_path
redirect_to projects_path
end
def activity(is_my_activity = false)

View File

@ -16,6 +16,7 @@ class Projects::BuildListsController < Projects::BaseController
params[:filter].each{|k,v| params[:filter].delete(k) if v.blank? } if params[:filter]
respond_to do |format|
format.html
format.json do
@filter = BuildList::Filter.new(@project, current_user, params[:filter] || {})
params[:page] = params[:page].to_i == 0 ? nil : params[:page]

View File

@ -9,6 +9,7 @@ class Projects::ProjectsController < Projects::BaseController
def index
authorize :project
respond_to do |format|
format.html
format.json {
if not params[:search].present?
@projects = Project.find(current_user.build_lists.group(:project_id).limit(10).pluck(:project_id))

View File

@ -14,12 +14,13 @@ html
body[ ng-app='RosaABF' ng-controller='RosaABFController' ng-strict-di=''
ng-init="init('#{I18n.locale}', #{!!current_user.try(:sound_notifications)})" ng-cloak="true"]
.page-wrapper.open
.page-wrapper ng-class="{'open': toggle}"
.sidebar-wrapper
ul.sidebar
li.sidebar-main
a href="/"
= link_to image_tag('logo-mini.png', alt: 'ABF'), root_path
a ng-click="toggleSidebar()"
= image_tag('logo-mini.png', alt: 'ABF')
span class="menu-icon glyphicon glyphicon-transfer"
== render 'layouts/menu/new_top'
.content-wrapper

View File

@ -1,9 +1,4 @@
-if current_user
-if policy(:project).dashboard?
li.sidebar-list
a href=projects_dashboard_path
=t 'dashboard.dashboard_name'
span.menu-icon.fa.fa-tachometer
- (collection = t 'top_menu').each do |base, title|
- if policy(base.to_s.singularize.to_sym).index?
li.sidebar-list

View File

@ -1,67 +1,71 @@
- if policy(build_list).cancel?
.row
= link_to t("layout.build_lists.cancel"),
cancel_build_list_path(build_list),
method: :put,
data: { confirm: t('layout.confirm') },
class: 'btn btn-primary roffset5 boffset5',
class: 'btn btn-primary',
'ng-show' => 'build_list.can_cancel'
.row.top-space ng-show="build_list.can_publish && build_list.status == #{BuildList::BUILD_PUBLISHED}"
= submit_tag t('layout.publish_again'),
data: { confirm: t("layout.publish_again_warning") },
name: 'publish',
class: 'btn btn-primary roffset5 boffset5',
'ng-show' => "build_list.can_publish && build_list.status == #{BuildList::BUILD_PUBLISHED}"
class: 'btn btn-primary'
.row.top-space ng-show="build_list.can_publish && build_list.can_publish_in_future && build_list.extra_build_lists_published && build_list.status == #{BuildList::TESTS_FAILED}"
= submit_tag t('layout.publish'),
data: { confirm: t('layout.build_lists.tests_failed') },
name: 'publish',
class: 'btn btn-primary roffset5 boffset5',
'ng-show' => "build_list.can_publish && build_list.can_publish_in_future && build_list.extra_build_lists_published && build_list.status == #{BuildList::TESTS_FAILED}"
class: 'btn btn-primary'
.row.top-space ng-show="build_list.can_publish && build_list.can_publish_in_future && build_list.extra_build_lists_published && build_list.status != #{BuildList::TESTS_FAILED} && build_list.status != #{BuildList::BUILD_PUBLISHED}"
= submit_tag t('layout.publish'),
data: { confirm: t('layout.confirm') },
name: 'publish',
class: 'btn btn-primary roffset5 boffset5',
'ng-show' => "build_list.can_publish && build_list.can_publish_in_future && build_list.extra_build_lists_published && build_list.status != #{BuildList::TESTS_FAILED} && build_list.status != #{BuildList::BUILD_PUBLISHED}"
class: 'btn btn-primary'
.row.top-space ng-show='build_list.can_publish_into_testing'
= link_to t('layout.publish_into_testing'),
publish_into_testing_build_list_path(build_list),
method: :put,
data: { confirm: t('layout.confirm') },
class: 'btn btn-primary roffset5 boffset5',
'ng-show' => 'build_list.can_publish_into_testing'
class: 'btn btn-primary'
- if policy(build_list).reject_publish?
.row.top-space ng-show='build_list.can_reject_publish'
= link_to t('layout.reject_publish'),
reject_publish_build_list_path(build_list),
method: :put,
data: { confirm: t('layout.confirm') },
class: 'btn btn-primary roffset5 boffset5',
'ng-show' => 'build_list.can_reject_publish'
class: 'btn btn-primary'
- if policy(build_list).rerun_tests?
.row.top-space ng-show="build_list.status == #{BuildList::TESTS_FAILED} || build_list.status == #{BuildList::SUCCESS}"
= link_to t('layout.build_lists.rerun_tests'),
rerun_tests_build_list_path(build_list),
method: :put,
data: { confirm: t('layout.confirm') },
class: 'btn btn-primary roffset5 boffset5',
'ng-show' => "build_list.status == #{BuildList::TESTS_FAILED} || build_list.status == #{BuildList::SUCCESS}"
class: 'btn btn-primary'
- if policy(build_list).create_container?
.row.top-space ng-show='build_list.can_create_container'
= link_to t('layout.build_lists.create_container'),
create_container_build_list_path(build_list),
method: :put,
data: { confirm: t("layout.confirm") },
class: 'btn btn-primary roffset5 boffset5',
'ng-show' => 'build_list.can_create_container'
class: 'btn btn-primary'
- if policy(build_list).create?
.row.top-space
= link_to t('layout.build_lists.recreate_build_list'), new_project_build_list_path(build_list.project,
build_list_id: build_list.id),
class: 'btn btn-primary roffset5 boffset5'
class: 'btn btn-primary'
- if can_run_dependent_build_lists?(build_list)
.row.top-space ng-show='build_list.dependent_projects_exists'
= link_to t('projects.build_lists.dependent_projects.title'),
dependent_projects_build_list_path(build_list),
class: 'btn btn-primary roffset5 boffset5',
'ng-show' => 'build_list.dependent_projects_exists'
class: 'btn btn-primary'

View File

@ -0,0 +1,80 @@
.row.top-space
.col-md-12 ng-controller="BuildListsController" ng-init=('getBuildLists("'+params[:name_with_owner].to_s+'")')
== render 'projects/build_lists/filter'
rd-widget
rd-widget-header title="Build Lists {{::widgetTitle}}" icon="fa-gears"
.form-inline ng-init="autoreload=true"
button ng-model="autoreload" ng-click="setAutoreload(autoreload)" class="btn btn-default" uib-btn-checkbox=""
= t 'layout.autoreload_page'
button class="btn btn-default" ng-click="openFilters()" ng-disabled="isRequest"
| Filters
rd-widget-body classes="no-padding" loading="isRequest"
.row
table.table.table-condensed
thead
tr
th
th= t('activerecord.attributes.build_list.id')
th= t('activerecord.attributes.build_list.status')
th= t('activerecord.attributes.build_list.project')
th= t('diff')
th= t('activerecord.attributes.build_list.project_version')
th= t('activerecord.attributes.build_list.save_to_repository')
th= t('activerecord.attributes.build_list.arch_short')
th= t('activerecord.attributes.build_list.user')
th= t('activerecord.attributes.build_list.hostname')
tbody
tr[ ng-repeat = 'bl in build_lists'
class = '{{::bl.status_color}}'
id = 'build-list-{{::bl.id}}'
ng-class = "{'group-start': !bl.relatedHidden, 'group-end': bl.lastRelated}"
ng-show = 'bl.show' ]
td.build-list-chevrons
a.expand ng-show = '::bl.hasRelated'
span.fa.fa-chevron-down ng-show = 'bl.relatedHidden' ng-click = 'showRelated(bl)'
span.fa.fa-chevron-up ng-hide = 'bl.relatedHidden' ng-click = 'hideRelated(bl)'
/ id
td.build-list-statuses
a[ ng-href = '{{::bl.url}}' ] {{::bl.id}}
div ng-show = '::bl.hasRelated' ng-bind-html="::bl.chevronHtml"
/ status
td
| {{::bl.human_status | i18n}}
br
time ng-show = '::bl.duration'
| {{::bl.duration}}
time ng-show = '::bl.average_build_time'
| /{{::bl.average_build_time}}
/ project
td.centered ng-hide = '::bl.project' colspan = 2
= t('layout.projects.unexisted_project')
td ng-show = '::bl.project'
| {{::bl.project.name_with_owner}}
/ diff
td
a ng-href = '{{::bl.version_link_url}}' ng-show = '::bl.project'
| {{::bl.version_link_text}}
/ project_version
td[] {{::bl.version_release}}
/ save_to_repository
td
a[ ng-href = '{{::bl.save_to_repository_url}}' ] {{::bl.save_to_repository_name}}
/ arch_short
td[ ng-show = '::bl.arch' ] {{::bl.arch.name}}
td[ ng-hide = '::bl.arch' ]= t('layout.arches.unexisted_arch')
/ user
td
a[ ng-href = '{{::bl.user.url}}' ] {{::bl.user.fullname}}
/ hostname
td[] {{::bl.hostname}}
rd-widget-footer ng-show="total_items > per_page"
== angularjs_paginate( per_page: 'per_page' )

View File

@ -16,7 +16,16 @@ div[ ng-controller='BuildListController'
| )
.row
div ng-class="{'col-md-6': build_list.packages || build_list.results, 'col-md-12': !build_list.packages && !build_list.results}"
.col-md-8
= render 'packages'
.col-md-4
= render 'shared/build_results', subject: @build_list
.row.top-space ng-show="build_list.status == #{BuildList::BUILD_STARTED}"
= render 'shared/log', { build_started: true, get_log_path: log_build_list_path(@build_list) }
.row.top-space
.col-md-10
rd-widget
rd-widget-header title=t('layout.build_lists.main_data')
rd-widget-body class="no-padding"
@ -175,19 +184,9 @@ div[ ng-controller='BuildListController'
tr.alert.alert-danger ng-show='build_list.can_publish && build_list.can_publish_in_future && !build_list.can_publish_into_repository'
td colspan=2
= t('flash.build_list.not_all_build_lists_success')
rd-widget-footer
.col-md-2
rd-widget
rd-widget-header title="Actions"
rd-widget-body
= form_for @build_list, url: publish_build_list_path(@build_list), html: {class: :"form-inline"} do |f|
= render 'buttons', build_list: @build_list
.col-md-6
= render 'packages'
.top-space ng-show="build_list.packages"
= render 'shared/build_results', subject: @build_list
.row.top-space ng-show="build_list.status == #{BuildList::BUILD_STARTED}"
= render 'shared/log', { build_started: true, get_log_path: log_build_list_path(@build_list) }
.row.top-space
.col-md-12
= render 'item_groups'
.row.top-space

View File

@ -1,146 +0,0 @@
.row.top-space
.col-md-12
== render 'projects/build_lists/filter'
rd-widget
div ng-controller="BuildListsController"
rd-widget-header title="Build Lists{{widget_title}}" icon="fa-gears"
.form-inline ng-init="autoreload=true"
button ng-model="autoreload" ng-click="setAutoreload(autoreload)" class="btn btn-default" uib-btn-checkbox=""
= t 'layout.autoreload_page'
button class="btn btn-default" ng-click="openFilters()" ng-disabled="isRequest"
| Filters
button [class="btn btn-default" ng-show="widget_title"
ng-click="clearProject()" ng-disabled="ProjectSelectService.disable()"]
| Clear selected project
rd-widget-body classes="large no-padding" loading="isRequest"
.row
table.table.table-condensed
thead
tr
th
th= t('activerecord.attributes.build_list.id')
th= t('activerecord.attributes.build_list.status')
th= t('activerecord.attributes.build_list.project')
th= t('diff')
th= t('activerecord.attributes.build_list.project_version')
th= t('activerecord.attributes.build_list.save_to_repository')
th= t('activerecord.attributes.build_list.arch_short')
th= t('activerecord.attributes.build_list.user')
th= t('activerecord.attributes.build_list.hostname')
th= t('activerecord.attributes.build_list.updated_at')
tbody
tr[ ng-repeat = 'bl in build_lists'
class = '{{::bl.status_color}}'
id = 'build-list-{{::bl.id}}'
ng-class = "{'group-start': !bl.relatedHidden, 'group-end': bl.lastRelated}"
ng-show = 'bl.show' ]
td.build-list-chevrons
a.expand ng-show = '::bl.hasRelated'
span.fa.fa-chevron-down ng-show = 'bl.relatedHidden' ng-click = 'showRelated(bl)'
span.fa.fa-chevron-up ng-hide = 'bl.relatedHidden' ng-click = 'hideRelated(bl)'
/ id
td.build-list-statuses
a[ ng-href = '{{::bl.url}}' ] {{::bl.id}}
div ng-show = '::bl.hasRelated' ng-bind-html="::bl.chevronHtml"
/ status
td
| {{::bl.human_status | i18n}}
br
time ng-show = '::bl.duration'
| {{::bl.duration}}
time ng-show = '::bl.average_build_time'
| /{{::bl.average_build_time}}
/ project
td.centered ng-hide = '::bl.project' colspan = 2
= t('layout.projects.unexisted_project')
td ng-show = '::bl.project'
| {{::bl.project.name_with_owner}}
/ diff
td
a ng-href = '{{::bl.version_link_url}}' ng-show = '::bl.project'
| {{::bl.version_link_text}}
/ project_version
td[] {{::bl.version_release}}
/ save_to_repository
td
a[ ng-href = '{{::bl.save_to_repository_url}}' ] {{::bl.save_to_repository_name}}
/ arch_short
td[ ng-show = '::bl.arch' ] {{::bl.arch.name}}
td[ ng-hide = '::bl.arch' ]= t('layout.arches.unexisted_arch')
/ user
td
a[ ng-href = '{{::bl.user.url}}' ] {{::bl.user.fullname}}
/ hostname
td[] {{::bl.hostname}}
/ updated_at
td title = '{{::bl.updated_at_utc}}'
| {{::bl.updated_at | amDateFormat:'YYYY-MM-DD HH:mm' }}
rd-widget-footer ng-show="total_items > per_page"
== angularjs_paginate( per_page: 'per_page' )
.row.top-space
.col-md-6
rd-widget
div ng-controller="ProjectsController"
rd-widget-header title=(t "dashboard.projects.title") icon="fa-cube"
input.form-control.input-sm [ng-model="search" placeholder=(t "dashboard.projects.search")
ng-change="searchProjects(search)" ng-model-options="{ debounce: 500 }"]
rd-widget-body classes="medium no-padding" loading="requesting"
.table-responsive
table.table ng-cloak=true
thead
tr
th ng-show="search" = t 'dashboard.projects.name'
th ng-hide="search" = t 'dashboard.projects.last_projects'
th
th
tbody
tr ng-repeat = 'item in projects'
td
button[ ng-click = 'selectProject(item.name_with_owner)'
ng-disabled="ProjectSelectService.disable()" class="btn btn-xs btn-link"] {{::item.name_with_owner}}
td
a[ ng-href = '{{::item.new_build_list_link}}'] = t 'dashboard.projects.new_build'
td
a[ ng-href = '{{::item.edit_link}}'
ng-show='::item.edit_link' target='_blank'] = t 'project_menu.settings'
- if policy(:project).create?
rd-widget-footer
ul.nav.nav-justified
li
= link_to t('layout.projects.new'), new_project_path, target: '_blank'
.col-md-6
rd-widget
div ng-controller="ProjectInfoController"
rd-widget-header title=(t('dashboard.project_info.title') + '{{widget_title}}')
rd-widget-body class="medium" loading="requesting"
div ng-hide="widget_title"
= t('dashboard.project_info.select')
div ng-show="widget_title"
div
a ng-href="{{project_info.html_url}}" target="_blank"
| {{project}}
div.bottom-space
| {{project_info.description}}
div
div.bottom-space ng-repeat="commit in project_info.commits"
div
span
| {{::commit.branch}}
span.pull-right
a ng-href="{{::commit.committer_url}}" target="_blank"
| {{::commit.committer_login}}
div
a ng-href="{{::commit.url}}" target="_blank"
| {{::commit.sha}}
div
| {{::commit.message}}

View File

@ -0,0 +1,29 @@
.row.top-space
.col-md-6
rd-widget
div ng-controller="ProjectsController"
rd-widget-header title=(t "dashboard.projects.title") icon="fa-cube"
input.form-control.input-sm [ng-model="search" placeholder=(t "dashboard.projects.search")
ng-change="searchProjects(search)" ng-model-options="{ debounce: 500 }"]
rd-widget-body classes="medium no-padding" loading="requesting"
.table-responsive
table.table ng-cloak=true
thead
tr
th ng-show="search" = t 'dashboard.projects.name'
th ng-hide="search" = t 'dashboard.projects.last_projects'
th
th
tbody
tr ng-repeat = 'item in projects'
td
a ng-href="{{::item.project_link}}" {{::item.name_with_owner}}
td
a[ ng-href = '{{::item.new_build_list_link}}'] = t 'dashboard.projects.new_build'
td
a[ ng-href = '{{::item.edit_link}}' ng-show='::item.edit_link'] = t 'project_menu.settings'
- if policy(:project).create?
rd-widget-footer
ul.nav.nav-justified
li
= link_to t('layout.projects.new'), new_project_path, target: '_blank'

View File

@ -2,6 +2,7 @@ json.projects do
json.array!(@projects) do |item|
json.cache! item, expires_in: 1.minutes do
json.name_with_owner item.name_with_owner
json.project_link project_build_lists_path(item.name_with_owner)
json.new_build_list_link new_project_build_list_path(item.name_with_owner)
json.edit_link edit_project_path(item) if policy(item).update?
end

View File

@ -4,6 +4,8 @@ en:
personal_repository: My repository
products: Products
top_menu:
projects: Projects
build_lists: Build Lists
platforms: Platforms
groups: Groups
statistics: Statistics

View File

@ -262,8 +262,6 @@ Rails.application.routes.draw do
end
end
get '/projects_dashboard' => 'projects#dashboard', as: :projects_dashboard
resources :projects, only: [:index, :new, :create]
scope '*name_with_owner', name_with_owner: Project::OWNER_AND_NAME_REGEXP do # project