Skip to content

Commit

Permalink
Merge pull request #113 from mozilla/revert-105-98_upstream
Browse files Browse the repository at this point in the history
Revert "98 upstream merge"
  • Loading branch information
alison985 authored Jul 12, 2017
2 parents c191a44 + 39cb71f commit 984e44d
Show file tree
Hide file tree
Showing 37 changed files with 315 additions and 487 deletions.
8 changes: 2 additions & 6 deletions client/app/components/dynamic-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,8 @@ function DynamicForm($http, toastr, $q) {
toastr.success('Saved.');
$scope.dataSourceForm.$setPristine();
},
(error) => {
if (error.status === 400 && 'message' in error.data) {
toastr.error(error.data.message);
} else {
toastr.error('Failed saving.');
}
() => {
toastr.error('Failed saving.');
}
);
};
Expand Down
1 change: 0 additions & 1 deletion client/app/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ export { default as rdTimeAgo } from './rd-time-ago';
export { default as overlay } from './overlay';
export { default as routeStatus } from './route-status';
export { default as filters } from './filters';
export { default as sortIcon } from './sort-icon';
26 changes: 0 additions & 26 deletions client/app/components/sort-icon.js

This file was deleted.

1 change: 0 additions & 1 deletion client/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ registerVisualizations(ngModule);

ngModule.config(($routeProvider, $locationProvider, $compileProvider,
uiSelectConfig, toastrConfig) => {
$compileProvider.debugInfoEnabled(false);
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|http|data):/);
$locationProvider.html5Mode(true);
uiSelectConfig.theme = 'bootstrap';
Expand Down
12 changes: 6 additions & 6 deletions client/app/pages/alerts-list/alerts-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
</page-header>

<div class="container">
<div class="bg-white">
<div class="container bg-white">
<table class="table table-condensed table-hover">
<thead>
<tr>
<th class="sortable-column" ng-click="$ctrl.alerts.orderBy('name')">Name <sort-icon column="'name'" sort-column="$ctrl.alerts.orderByField" reverse="$ctrl.alerts.orderByReverse"></sort-icon></th>
<th class="sortable-column" ng-click="$ctrl.alerts.orderBy('created_by')">Created By <sort-icon column="'created_by'" sort-column="$ctrl.alerts.orderByField" reverse="$ctrl.alerts.orderByReverse"></sort-icon></th>
<th class="sortable-column" ng-click="$ctrl.alerts.orderBy('state')">State <sort-icon column="'state'" sort-column="$ctrl.alerts.orderByField" reverse="$ctrl.alerts.orderByReverse"></sort-icon></th>
<th class="sortable-column" ng-click="$ctrl.alerts.orderBy('created_at')">Created By <sort-icon column="'created_at'" sort-column="$ctrl.alerts.orderByField" reverse="$ctrl.alerts.orderByReverse"></sort-icon></th>
<th>Name</th>
<th>Created By</th>
<th>State</th>
<th>Created At</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in $ctrl.alerts.getPageRows()">
<td><a href="alerts/{{row.id}}">{{row.name}}</a></td>
<td>{{row.created_by}}</td>
<td>{{row.user.name}}</td>
<td><span ng-class="row.class">{{row.state | uppercase}}</span> since <span am-time-ago="row.updated_at"></span></td>
<td><span am-time-ago="row.created_at"></span></td>
</tr>
Expand Down
26 changes: 12 additions & 14 deletions client/app/pages/alerts-list/index.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
import { Paginator } from '../../utils';
import template from './alerts-list.html';

const stateClass = {
ok: 'label label-success',
triggered: 'label label-danger',
unknown: 'label label-warning',
};

class AlertsListCtrl {
constructor(Events, Alert) {
Events.record('view', 'page', 'alerts');

this.alerts = new Paginator([], { itemsPerPage: 20 });

Alert.query((alerts) => {
this.alerts.updateRows(alerts.map(alert => ({
name: alert.name,
state: alert.state,
class: stateClass[alert.state],
created_by: alert.user.name,
created_at: alert.created_at,
updated_at: alert.updated_at,
})));
const stateClass = {
ok: 'label label-success',
triggered: 'label label-danger',
unknown: 'label label-warning',
};

alerts.forEach((alert) => {
alert.class = stateClass[alert.state];
});

this.alerts.updateRows(alerts);
});
}
}
Expand Down
10 changes: 1 addition & 9 deletions client/app/pages/dashboards/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,20 +156,12 @@ function DashboardCtrl($rootScope, $routeParams, $location, $timeout, $q, $uibMo

this.editDashboard = () => {
this.dashboard.existing_name = this.dashboard.name;
const previousFiltersState = this.dashboard.dashboard_filters_enabled;
$uibModal.open({
component: 'editDashboardDialog',
resolve: {
dashboard: () => this.dashboard,
},
}).result.then((dashboard) => {
const shouldRenderDashboard = !previousFiltersState && dashboard.dashboard_filters_enabled;
this.dashboard = dashboard;

if (shouldRenderDashboard) {
renderDashboard(this.dashboard);
}
});
}).result.then((dashboard) => { this.dashboard = dashboard; });
};

this.addWidget = () => {
Expand Down
9 changes: 1 addition & 8 deletions client/app/pages/dashboards/edit-dashboard-dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ <h4 class="modal-title">Edit: {{$ctrl.dashboard.name}}</h4>
<p ng-if="myForm.dashboardName.$invalid" class="alert alert-warning">A name is required.</p>


<p ng-if="$ctrl.dashboard.id">
<label>
<input name="input" type="checkbox" ng-model="$ctrl.dashboard.dashboard_filters_enabled">
Use Dashboard Level Filters
</label>
</p>

<div gridster="$ctrl.gridsterOptions" ng-if="$ctrl.items | notEmpty">
<ul>
<li gridster-item="item" ng-repeat="item in $ctrl.items" class="widget panel panel-default gs-w">
Expand All @@ -28,5 +21,5 @@ <h4 class="modal-title">Edit: {{$ctrl.dashboard.name}}</h4>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" ng-disabled="$ctrl.saveInProgress" ng-click="$ctrl.closeWithoutSave()">Close</button>
<button type="button" class="btn btn-primary" ng-disabled="$ctrl.saveInProgress || myForm.dashboardName.$invalid || !$ctrl.isFormValid()" ng-click="$ctrl.saveDashboard()">Save</button>
<button type="button" class="btn btn-primary" ng-disabled="$ctrl.saveInProgress || myForm.dashboardName.$invalid" ng-click="$ctrl.saveDashboard()">Save</button>
</div>
5 changes: 1 addition & 4 deletions client/app/pages/dashboards/edit-dashboard-dialog.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isEmpty, sortBy } from 'underscore';
import { sortBy } from 'underscore';
import template from './edit-dashboard-dialog.html';

const EditDashboardDialog = {
Expand Down Expand Up @@ -45,8 +45,6 @@ const EditDashboardDialog = {
});
}

this.isFormValid = () => !isEmpty(this.dashboard.name);

this.saveDashboard = () => {
this.saveInProgress = true;

Expand All @@ -67,7 +65,6 @@ const EditDashboardDialog = {
slug: this.dashboard.id,
name: this.dashboard.name,
version: this.dashboard.version,
dashboard_filters_enabled: this.dashboard.dashboard_filters_enabled,
layout: JSON.stringify(layout),
};

Expand Down
7 changes: 1 addition & 6 deletions client/app/pages/queries/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,7 @@ function QueryViewCtrl($scope, Events, $route, $routeParams, $location, $window,

$scope.saveName = () => {
Events.record('edit_name', 'query', $scope.query.id);

if ($scope.query.is_draft && clientConfig.autoPublishNamedQueries && $scope.query.name !== 'New Query') {
$scope.query.is_draft = false;
}

$scope.saveQuery(undefined, { name: $scope.query.name, is_draft: $scope.query.is_draft });
$scope.saveQuery(undefined, { name: $scope.query.name });
};

$scope.cancelExecution = () => {
Expand Down
2 changes: 1 addition & 1 deletion client/app/pages/queries/visualization-embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function (ngModule) {
return session($http, $route, Auth).then(() => {
const queryId = $route.current.params.queryId;
const query = $http.get(`api/queries/${queryId}`).then(response => response.data);
const queryResult = $http.get(`api/queries/${queryId}/results.json${location.search}`).then(response => response.data);
const queryResult = $http.get(`api/queries/${queryId}/results.json`).then(response => response.data);
return $q.all([query, queryResult]);
});
}
Expand Down
2 changes: 1 addition & 1 deletion client/app/services/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function AuthService($window, $location, $q, $http) {
}

this.setApiKey(null);
return $http.get('api/session').then((response) => {
return $http.get('/api/session').then((response) => {
storeSession(response.data);
return session;
});
Expand Down
20 changes: 0 additions & 20 deletions client/app/utils/paginator.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import { sortBy } from 'underscore';

export default class Paginator {
constructor(rows, { page = 1, itemsPerPage = 20, totalCount = undefined } = {}) {
this.page = page;
this.itemsPerPage = itemsPerPage;
this.updateRows(rows, totalCount);
this.orderByField = undefined;
this.orderByReverse = false;
}

setPage(page) {
Expand All @@ -28,20 +24,4 @@ export default class Paginator {
this.totalCount = 0;
}
}

orderBy(column) {
if (column === this.orderByField) {
this.orderByReverse = !this.orderByReverse;
} else {
this.orderByField = column;
this.orderByReverse = false;
}

if (this.orderByField) {
this.rows = sortBy(this.rows, this.orderByField);
if (this.orderByReverse) {
this.rows = this.rows.reverse();
}
}
}
}
Loading

0 comments on commit 984e44d

Please sign in to comment.