Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default defineConfig([
rules: {
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-this-alias': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
},
]);
8 changes: 6 additions & 2 deletions src/alert/alert.js → src/alert/alert.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
class Alert {
constructor(opts = {}) {
private conditions: any[];

private state: any;

constructor(opts: any = {}) {
this.conditions = [];

this.state = {
Expand Down Expand Up @@ -46,4 +50,4 @@ class Alert {
}
}

module.exports = Alert;
export = Alert;
7 changes: 6 additions & 1 deletion src/alert/condition.js → src/alert/condition.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
class Condition {
private state: object;
private _evaluator: { params: any[]; type: string };
private _operator: { type: string };
private _query: { params: any[] };
private _reducer: { params: any[]; type: string };
constructor(opts = {}) {
this.state = {};

Expand Down Expand Up @@ -105,4 +110,4 @@ class Condition {
}
}

module.exports = Condition;
export = Condition;
9 changes: 0 additions & 9 deletions src/alert/index.js

This file was deleted.

7 changes: 7 additions & 0 deletions src/alert/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Alert = require('./alert');
import Condition = require('./condition');

export = {
Alert: Alert,
Condition: Condition,
};
11 changes: 5 additions & 6 deletions src/annotations/graphite.js → src/annotations/graphite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

'use strict';

var errors = require('../errors');
import errors = require('../errors');

class Graphite {
constructor(opts = {}) {
private state: any;
constructor(opts: any = {}) {
if (!opts.name) {
throw errors.UnfulfilledRequirement.create(
'{component} missing requirement: {unfulfilledArg}',
Expand All @@ -44,7 +43,7 @@ class Graphite {
);
}

var defaults = {
const defaults = {
name: 'no name',
datasource: 'graphite',
showLine: true,
Expand All @@ -67,4 +66,4 @@ class Graphite {
}
}

module.exports = Graphite;
export = Graphite;
6 changes: 2 additions & 4 deletions src/annotations/index.js → src/annotations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

'use strict';
import Graphite = require('./graphite');

var Graphite = require('./graphite');

module.exports = {
export = {
Graphite: Graphite,
};
7 changes: 3 additions & 4 deletions src/config.js → src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

'use strict';
var xtend = require('xtend');
import xtend = require('xtend');

/**
* `user` - Auth user, defaults to "guest"
Expand All @@ -28,7 +27,7 @@ var xtend = require('xtend');
* `cookie` - Key/value pair for auth, defaults to"auth-openid="
* `headers` - Map of header keys/values, defaults to no headers
*/
var configurations = {
let configurations = {
user: 'guest',
group: 'guest',
url: 'https://your.graphite.url.com/elasticsearch/grafana-dash/dashboard/',
Expand All @@ -44,7 +43,7 @@ function getConfig() {
return configurations;
}

module.exports = {
export = {
configure: configure,
getConfig: getConfig,
};
13 changes: 7 additions & 6 deletions src/dashboard.js → src/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

'use strict';

var Templates = require('./templates');
var Annotations = require('./annotations');
var ExternalLink = require('./external-link');
import Templates = require('./templates');
import Annotations = require('./annotations');
import ExternalLink = require('./external-link');

class Dashboard {
state: any;
rows: any[];
links: any[];
constructor(opts = {}) {
this.state = {};
this._init(opts);
Expand Down Expand Up @@ -123,4 +124,4 @@ class Dashboard {
}
}

module.exports = Dashboard;
export = Dashboard;
11 changes: 8 additions & 3 deletions src/errors.js → src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,20 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

'use strict';
var SError = require('error').SError;
import error = require('error');

// eslint-disable-next-line @typescript-eslint/no-unused-vars
declare class _SError extends error.SError {
static create(message: string, info: Record<string, any>): error.SError;
}
const SError = error.SError as typeof _SError;

class UnfulfilledRequirement extends SError {}
class InvalidState extends SError {}
class Misconfigured extends SError {}
class ResponseError extends SError {}

module.exports = {
export = {
UnfulfilledRequirement: UnfulfilledRequirement,
InvalidState: InvalidState,
Misconfigured: Misconfigured,
Expand Down
3 changes: 2 additions & 1 deletion src/external-link.js → src/external-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// THE SOFTWARE.

class ExternalLink {
private state: any;
constructor(opts = {}) {
const defaults = {
title: '',
Expand Down Expand Up @@ -61,4 +62,4 @@ class ExternalLink {
}
}

module.exports = ExternalLink;
export = ExternalLink;
6 changes: 2 additions & 4 deletions src/id.js → src/id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

'use strict';

// Used to provide unique if for
// generated graphs

var graphId = 0;
let graphId = 0;
function generateGraphId() {
graphId = graphId + 1;
return graphId;
}

module.exports = generateGraphId;
export = generateGraphId;
28 changes: 13 additions & 15 deletions src/index.js → src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,20 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

'use strict';
import Dashboard = require('./dashboard');
import Row = require('./row');
import ExternalLink = require('./external-link');
import Target = require('./target');
import Panels = require('./panels');
import Alert = require('./alert/alert');
import Condition = require('./alert/condition');
import Templates = require('./templates');
import publish = require('./publish');
import generateGraphId = require('./id');
import config = require('./config');
import Annotations = require('./annotations');

var Dashboard = require('./dashboard');
var Row = require('./row');
var ExternalLink = require('./external-link');
var Target = require('./target');
var Panels = require('./panels');
var Alert = require('./alert/alert');
var Condition = require('./alert/condition');
var Templates = require('./templates');
var publish = require('./publish');
var generateGraphId = require('./id');
var config = require('./config');
var Annotations = require('./annotations');

module.exports = {
export = {
Dashboard: Dashboard,
Row: Row,
ExternalLink: ExternalLink,
Expand Down
9 changes: 4 additions & 5 deletions src/panels/dashboard_list.js → src/panels/dashboard_list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

'use strict';

var generateGraphId = require('../id');
import generateGraphId = require('../id');

class DashboardList {
constructor(opts = {}) {
state: any;
constructor(opts: any = {}) {
this.state = {
title: 'dashboard list',
error: false,
Expand Down Expand Up @@ -60,4 +59,4 @@ class DashboardList {
}
}

module.exports = DashboardList;
export = DashboardList;
10 changes: 5 additions & 5 deletions src/panels/graph.js → src/panels/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

'use strict';

const generateGraphId = require('../id');
import generateGraphId = require('../id');

class Graph {
constructor(opts = {}) {
private _currentRefIndex: number;
state: any;
constructor(opts: any = {}) {
this._currentRefIndex = 0;

const defaults = {
Expand Down Expand Up @@ -150,4 +150,4 @@ function handleRefTargets(target, targets) {
return {};
}

module.exports = Graph;
export = Graph;
13 changes: 6 additions & 7 deletions src/panels/index.js → src/panels/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

'use strict';
var Graph = require('./graph');
var SingleStat = require('./singlestat');
var Text = require('./text');
var Table = require('./table');
var DashboardList = require('./dashboard_list');
import Graph = require('./graph');
import SingleStat = require('./singlestat');
import Text = require('./text');
import Table = require('./table');
import DashboardList = require('./dashboard_list');

module.exports = {
export = {
Graph: Graph,
SingleStat: SingleStat,
Text: Text,
Expand Down
11 changes: 5 additions & 6 deletions src/panels/singlestat.js → src/panels/singlestat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

'use strict';

var generateGraphId = require('../id');
import generateGraphId = require('../id');

class SingleStat {
constructor(opts = {}) {
var defaults = {
state: any;
constructor(opts: any = {}) {
const defaults = {
id: generateGraphId(),
title: 'single stat',
targets: [],
Expand Down Expand Up @@ -104,4 +103,4 @@ class SingleStat {
}
}

module.exports = SingleStat;
export = SingleStat;
11 changes: 5 additions & 6 deletions src/panels/table.js → src/panels/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

'use strict';

var generateGraphId = require('../id');
import generateGraphId = require('../id');

class Table {
constructor(opts = {}) {
var defaults = {
state: any;
constructor(opts: any = {}) {
const defaults = {
title: 'Panel Title',
error: false,
span: 12,
Expand Down Expand Up @@ -107,4 +106,4 @@ class Table {
}
}

module.exports = Table;
export = Table;
11 changes: 5 additions & 6 deletions src/panels/text.js → src/panels/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

'use strict';

var generateGraphId = require('../id');
import generateGraphId = require('../id');

class Text {
constructor(opts = {}) {
var defaults = {
state: any;
constructor(opts: any = {}) {
const defaults = {
title: '',
id: generateGraphId(),
error: false,
Expand Down Expand Up @@ -59,4 +58,4 @@ class Text {
}
}

module.exports = Text;
export = Text;
Loading