prettier: change to single quoting

This commit is contained in:
Torkel Ödegaard
2017-12-20 12:33:33 +01:00
parent 2a360c45a2
commit 85879a7014
304 changed files with 10558 additions and 10519 deletions

View File

@@ -1,13 +1,13 @@
import _ from "lodash";
import coreModule from "../../core/core_module";
import _ from 'lodash';
import coreModule from '../../core/core_module';
export class PlaylistEditCtrl {
filteredDashboards: any = [];
filteredTags: any = [];
searchQuery = "";
searchQuery = '';
loading = false;
playlist: any = {
interval: "5m"
interval: '5m',
};
playlistItems: any = [];
@@ -24,28 +24,28 @@ export class PlaylistEditCtrl {
$route,
navModelSrv
) {
this.navModel = navModelSrv.getNav("dashboards", "playlists", 0);
this.navModel = navModelSrv.getNav('dashboards', 'playlists', 0);
this.isNew = $route.current.params.id;
if ($route.current.params.id) {
var playlistId = $route.current.params.id;
backendSrv.get("/api/playlists/" + playlistId).then(result => {
backendSrv.get('/api/playlists/' + playlistId).then(result => {
this.playlist = result;
this.navModel.node = {
text: result.name,
icon: this.navModel.node.icon
icon: this.navModel.node.icon,
};
this.navModel.breadcrumbs.push(this.navModel.node);
});
backendSrv.get("/api/playlists/" + playlistId + "/items").then(result => {
backendSrv.get('/api/playlists/' + playlistId + '/items').then(result => {
this.playlistItems = result;
});
} else {
this.navModel.node = {
text: "New playlist",
icon: this.navModel.node.icon
text: 'New playlist',
icon: this.navModel.node.icon,
};
this.navModel.breadcrumbs.push(this.navModel.node);
}
@@ -67,7 +67,7 @@ export class PlaylistEditCtrl {
addPlaylistItem(playlistItem) {
playlistItem.value = playlistItem.id.toString();
playlistItem.type = "dashboard_by_id";
playlistItem.type = 'dashboard_by_id';
playlistItem.order = this.playlistItems.length + 1;
this.playlistItems.push(playlistItem);
@@ -77,9 +77,9 @@ export class PlaylistEditCtrl {
addTagPlaylistItem(tag) {
var playlistItem: any = {
value: tag.term,
type: "dashboard_by_tag",
type: 'dashboard_by_tag',
order: this.playlistItems.length + 1,
title: tag.term
title: tag.term,
};
this.playlistItems.push(playlistItem);
@@ -99,16 +99,16 @@ export class PlaylistEditCtrl {
playlist.items = playlistItems;
savePromise = playlist.id
? this.backendSrv.put("/api/playlists/" + playlist.id, playlist)
: this.backendSrv.post("/api/playlists", playlist);
? this.backendSrv.put('/api/playlists/' + playlist.id, playlist)
: this.backendSrv.post('/api/playlists', playlist);
savePromise.then(
() => {
this.$scope.appEvent("alert-success", ["Playlist saved", ""]);
this.$location.path("/playlists");
this.$scope.appEvent('alert-success', ['Playlist saved', '']);
this.$location.path('/playlists');
},
() => {
this.$scope.appEvent("alert-error", ["Unable to save playlist", ""]);
this.$scope.appEvent('alert-error', ['Unable to save playlist', '']);
}
);
}
@@ -118,7 +118,7 @@ export class PlaylistEditCtrl {
}
backToList() {
this.$location.path("/playlists");
this.$location.path('/playlists');
}
searchStarted(promise) {
@@ -148,4 +148,4 @@ export class PlaylistEditCtrl {
}
}
coreModule.controller("PlaylistEditCtrl", PlaylistEditCtrl);
coreModule.controller('PlaylistEditCtrl', PlaylistEditCtrl);

View File

@@ -1,6 +1,6 @@
///<reference path="../../headers/common.d.ts" />
import coreModule from "../../core/core_module";
import coreModule from '../../core/core_module';
export class PlaylistSearchCtrl {
query: any;
@@ -10,10 +10,10 @@ export class PlaylistSearchCtrl {
/** @ngInject */
constructor($timeout, private backendSrv) {
this.query = { query: "", tag: [], starred: false, limit: 30 };
this.query = { query: '', tag: [], starred: false, limit: 30 };
$timeout(() => {
this.query.query = "";
this.query.query = '';
this.searchDashboards();
}, 100);
}
@@ -25,7 +25,7 @@ export class PlaylistSearchCtrl {
prom.promise = this.backendSrv.search(this.query).then(result => {
return {
dashboardResult: result,
tagResult: []
tagResult: [],
};
});
@@ -39,7 +39,7 @@ export class PlaylistSearchCtrl {
queryHasNoFilters() {
return (
this.query.query === "" &&
this.query.query === '' &&
this.query.starred === false &&
this.query.tag.length === 0
);
@@ -56,10 +56,10 @@ export class PlaylistSearchCtrl {
getTags() {
var prom: any = {};
prom.promise = this.backendSrv.get("/api/dashboards/tags").then(result => {
prom.promise = this.backendSrv.get('/api/dashboards/tags').then(result => {
return {
dashboardResult: [],
tagResult: result
tagResult: result,
};
});
@@ -69,15 +69,15 @@ export class PlaylistSearchCtrl {
export function playlistSearchDirective() {
return {
restrict: "E",
templateUrl: "public/app/features/playlist/partials/playlist_search.html",
restrict: 'E',
templateUrl: 'public/app/features/playlist/partials/playlist_search.html',
controller: PlaylistSearchCtrl,
bindToController: true,
controllerAs: "ctrl",
controllerAs: 'ctrl',
scope: {
searchStarted: "&"
}
searchStarted: '&',
},
};
}
coreModule.directive("playlistSearch", playlistSearchDirective);
coreModule.directive('playlistSearch', playlistSearchDirective);

View File

@@ -1,8 +1,8 @@
///<reference path="../../headers/common.d.ts" />
import coreModule from "../../core/core_module";
import kbn from "app/core/utils/kbn";
import appEvents from "app/core/app_events";
import coreModule from '../../core/core_module';
import kbn from 'app/core/utils/kbn';
import appEvents from 'app/core/app_events';
class PlaylistSrv {
private cancelPromise: any;
@@ -31,23 +31,23 @@ class PlaylistSrv {
}
var dash = this.dashboards[this.index];
this.$location.url("dashboard/" + dash.uri);
this.$location.url('dashboard/' + dash.uri);
this.index++;
this.cancelPromise = this.$timeout(() => this.next(), this.interval);
}
getUrlWithKioskMode() {
const inKioskMode = document.body.classList.contains("page-kiosk-mode");
const inKioskMode = document.body.classList.contains('page-kiosk-mode');
// check if should add kiosk query param
if (inKioskMode && this.startUrl.indexOf("kiosk") === -1) {
return this.startUrl + "?kiosk=true";
if (inKioskMode && this.startUrl.indexOf('kiosk') === -1) {
return this.startUrl + '?kiosk=true';
}
// check if should remove kiosk query param
if (!inKioskMode) {
return this.startUrl.split("?")[0];
return this.startUrl.split('?')[0];
}
// already has kiosk query param, just return startUrl
@@ -67,7 +67,7 @@ class PlaylistSrv {
this.isPlaying = true;
if (this.$routeParams.kiosk) {
appEvents.emit("toggle-kiosk-mode");
appEvents.emit('toggle-kiosk-mode');
}
this.backendSrv.get(`/api/playlists/${playlistId}`).then(playlist => {
@@ -91,4 +91,4 @@ class PlaylistSrv {
}
}
coreModule.service("playlistSrv", PlaylistSrv);
coreModule.service('playlistSrv', PlaylistSrv);

View File

@@ -1,7 +1,7 @@
///<reference path="../../headers/common.d.ts" />
import _ from "lodash";
import coreModule from "../../core/core_module";
import _ from 'lodash';
import coreModule from '../../core/core_module';
export class PlaylistsCtrl {
playlists: any;
@@ -9,9 +9,9 @@ export class PlaylistsCtrl {
/** @ngInject */
constructor(private $scope, private backendSrv, navModelSrv) {
this.navModel = navModelSrv.getNav("dashboards", "playlists", 0);
this.navModel = navModelSrv.getNav('dashboards', 'playlists', 0);
backendSrv.get("/api/playlists").then(result => {
backendSrv.get('/api/playlists').then(result => {
this.playlists = result;
});
}
@@ -19,28 +19,28 @@ export class PlaylistsCtrl {
removePlaylistConfirmed(playlist) {
_.remove(this.playlists, { id: playlist.id });
this.backendSrv.delete("/api/playlists/" + playlist.id).then(
this.backendSrv.delete('/api/playlists/' + playlist.id).then(
() => {
this.$scope.appEvent("alert-success", ["Playlist deleted", ""]);
this.$scope.appEvent('alert-success', ['Playlist deleted', '']);
},
() => {
this.$scope.appEvent("alert-error", ["Unable to delete playlist", ""]);
this.$scope.appEvent('alert-error', ['Unable to delete playlist', '']);
this.playlists.push(playlist);
}
);
}
removePlaylist(playlist) {
this.$scope.appEvent("confirm-modal", {
title: "Delete",
text: "Are you sure you want to delete playlist " + playlist.name + "?",
yesText: "Delete",
icon: "fa-trash",
this.$scope.appEvent('confirm-modal', {
title: 'Delete',
text: 'Are you sure you want to delete playlist ' + playlist.name + '?',
yesText: 'Delete',
icon: 'fa-trash',
onConfirm: () => {
this.removePlaylistConfirmed(playlist);
}
},
});
}
}
coreModule.controller("PlaylistsCtrl", PlaylistsCtrl);
coreModule.controller('PlaylistsCtrl', PlaylistsCtrl);

View File

@@ -1,14 +1,14 @@
import "../playlist_edit_ctrl";
import { describe, beforeEach, it, expect } from "test/lib/common";
import { PlaylistEditCtrl } from "../playlist_edit_ctrl";
import '../playlist_edit_ctrl';
import { describe, beforeEach, it, expect } from 'test/lib/common';
import { PlaylistEditCtrl } from '../playlist_edit_ctrl';
describe("PlaylistEditCtrl", () => {
describe('PlaylistEditCtrl', () => {
var ctx: any;
beforeEach(() => {
let navModelSrv = {
getNav: () => {
return { breadcrumbs: [], node: {} };
}
},
};
ctx = new PlaylistEditCtrl(
@@ -20,56 +20,56 @@ describe("PlaylistEditCtrl", () => {
);
ctx.dashboardresult = [
{ id: 2, title: "dashboard: 2" },
{ id: 3, title: "dashboard: 3" }
{ id: 2, title: 'dashboard: 2' },
{ id: 3, title: 'dashboard: 3' },
];
ctx.tagresult = [{ term: "graphite", count: 1 }, { term: "nyc", count: 2 }];
ctx.tagresult = [{ term: 'graphite', count: 1 }, { term: 'nyc', count: 2 }];
});
describe("searchresult returns 2 dashboards, ", () => {
it("found dashboard should be 2", () => {
describe('searchresult returns 2 dashboards, ', () => {
it('found dashboard should be 2', () => {
expect(ctx.dashboardresult.length).to.be(2);
});
it("filtred result should be 2", () => {
it('filtred result should be 2', () => {
ctx.filterFoundPlaylistItems();
expect(ctx.filteredDashboards.length).to.be(2);
expect(ctx.filteredTags.length).to.be(2);
});
describe("adds one dashboard to playlist, ", () => {
describe('adds one dashboard to playlist, ', () => {
beforeEach(() => {
ctx.addPlaylistItem({ id: 2, title: "dashboard: 2" });
ctx.addTagPlaylistItem({ term: "graphite" });
ctx.addPlaylistItem({ id: 2, title: 'dashboard: 2' });
ctx.addTagPlaylistItem({ term: 'graphite' });
ctx.filterFoundPlaylistItems();
});
it("playlistitems should be increased by one", () => {
it('playlistitems should be increased by one', () => {
expect(ctx.playlistItems.length).to.be(2);
});
it("filtred playlistitems should be reduced by one", () => {
it('filtred playlistitems should be reduced by one', () => {
expect(ctx.filteredDashboards.length).to.be(1);
expect(ctx.filteredTags.length).to.be(1);
});
it("found dashboard should be 2", () => {
it('found dashboard should be 2', () => {
expect(ctx.dashboardresult.length).to.be(2);
});
describe("removes one dashboard from playlist, ", () => {
describe('removes one dashboard from playlist, ', () => {
beforeEach(() => {
ctx.removePlaylistItem(ctx.playlistItems[0]);
ctx.removePlaylistItem(ctx.playlistItems[0]);
ctx.filterFoundPlaylistItems();
});
it("playlistitems should be increased by one", () => {
it('playlistitems should be increased by one', () => {
expect(ctx.playlistItems.length).to.be(0);
});
it("found dashboard should be 2", () => {
it('found dashboard should be 2', () => {
expect(ctx.dashboardresult.length).to.be(2);
expect(ctx.filteredDashboards.length).to.be(2);
expect(ctx.filteredTags.length).to.be(2);