Skip to content

Commit a90bd37

Browse files
committed
Convert some classes to TypeScript
1 parent e267b9e commit a90bd37

File tree

3 files changed

+53
-55
lines changed

3 files changed

+53
-55
lines changed

src/model/Alert.model.js renamed to src/model/Alert.model.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,17 @@
1717

1818
/** Alert model */
1919
export class Alert {
20-
/**
21-
* @param {Error|string} err - original thrown error to log if possible, or an error message.
22-
* @param {string} color - color of the displayed alert.
23-
* @param {?string} msg - a custom message to display in the alert instead of err.
24-
*/
25-
constructor (err, color, msg = null) {
26-
this.err = err
20+
/** The text content of the displayed alert. */
21+
text: string | Error
22+
23+
constructor (
24+
/** Original thrown error to log if possible, or an error message. */
25+
public err: Error | string,
26+
/** Color of the displayed alert. */
27+
public color: string,
28+
/** A custom message to display in the alert instead of err. */
29+
msg?: string
30+
) {
2731
this.text = msg || err
28-
this.color = color
2932
}
3033
}

src/model/User.model.js

Lines changed: 0 additions & 47 deletions
This file was deleted.

src/model/User.model.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (C) NIWA & British Crown (Met Office) & Contributors.
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
export default class User {
19+
constructor (
20+
/** The authenticated user (full info only available when authenticated
21+
* via the hub) */
22+
public username: string,
23+
/** User groups */
24+
public groups: string[],
25+
/** Date when the user was created */
26+
public created: string,
27+
/** Whether the user is an administrator or not */
28+
public admin: boolean,
29+
/** Server URL */
30+
public server: string,
31+
/** UIS owner (the user whose workflows we are looking at) (this might not
32+
* be the authenticated user for multi-user setups) */
33+
public owner: string,
34+
/** List of permissions */
35+
public permissions: string[],
36+
public mode: 'single user' | 'multi user',
37+
/** User initials */
38+
public initials: string
39+
) {
40+
this.server ||= '?' // server can be unset
41+
}
42+
}

0 commit comments

Comments
 (0)